Moved the parts of network out of server.
Partly added extensions to tic-tac-toe py.
This commit is contained in:
parent
f59d59814a
commit
71fa6f30ba
10 changed files with 237 additions and 74 deletions
23
games/tic-tac-toe/server.py
Normal file
23
games/tic-tac-toe/server.py
Normal file
|
@ -0,0 +1,23 @@
|
|||
#server.py
|
||||
import json
|
||||
from socket import socket, AF_INET, SOCK_STREAM
|
||||
|
||||
|
||||
class server(object):
|
||||
def __init__(self, port=None):
|
||||
self.port = port
|
||||
self.world = GGS.init()
|
||||
self.socket = socket(AF_INET, SOCK_STREAM)
|
||||
self.socket.connect(("www.???.com", 80))
|
||||
|
||||
def turn(self, id, index):
|
||||
rows = sqrt(board.nr_of_rectangles)
|
||||
x = int(index / rows)
|
||||
y = int(index % rows)
|
||||
|
||||
json.dumps({"x": x, "y": y}
|
||||
world.callCommand("tictactoe", "set", json.dumps({"x": x, "y": y}))
|
||||
|
||||
sent = 0
|
||||
length = len(
|
||||
while sent
|
Reference in a new issue