This repository has been archived on 2025-08-18. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
GGS/games/tic-tac-toe/server.py
Kallfaktorn 71fa6f30ba Moved the parts of network out of server.
Partly added extensions to tic-tac-toe py.
2011-02-04 14:10:23 +01:00

23 lines
595 B
Python

#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