fixed problem with win

This commit is contained in:
Jeena Paradies 2011-05-16 17:09:35 +02:00
commit e85b2baffc
3 changed files with 40 additions and 19 deletions

@ -1 +1 @@
Subproject commit a94993dc5a626605bdf45c45f398270fe33eaaf1 Subproject commit 2d5eaad6fdeb6e07d8b7f86ba53cda3e6351835a

View file

@ -23,15 +23,15 @@ class GGSTTT:
#Create our dictionay and connect it #Create our dictionay and connect it
dic = { "on_window1_destroy_event" : gtk.main_quit dic = { "on_window1_destroy_event" : gtk.main_quit
,"on_x0y0_clicked" : lambda x: self.sendMove("{'x':0,'y':0}") ,"on_x0y0_clicked" : lambda x: self.sendMove("{\"x\":0,\"y\":0}")
,"on_x0y1_clicked" : lambda x: self.sendMove("{'x':0,'y':1}") ,"on_x0y1_clicked" : lambda x: self.sendMove("{\"x\":0,\"y\":1}")
,"on_x0y2_clicked" : lambda x: self.sendMove("{'x':0,'y':2}") ,"on_x0y2_clicked" : lambda x: self.sendMove("{\"x\":0,\"y\":2}")
,"on_x1y0_clicked" : lambda x: self.sendMove("{'x':1,'y':0}") ,"on_x1y0_clicked" : lambda x: self.sendMove("{\"x\":1,\"y\":0}")
,"on_x1y1_clicked" : lambda x: self.sendMove("{'x':1,'y':1}") ,"on_x1y1_clicked" : lambda x: self.sendMove("{\"x\":1,\"y\":1}")
,"on_x1y2_clicked" : lambda x: self.sendMove("{'x':1,'y':2}") ,"on_x1y2_clicked" : lambda x: self.sendMove("{\"x\":1,\"y\":2}")
,"on_x2y0_clicked" : lambda x: self.sendMove("{'x':2,'y':0}") ,"on_x2y0_clicked" : lambda x: self.sendMove("{\"x\":2,\"y\":0}")
,"on_x2y1_clicked" : lambda x: self.sendMove("{'x':2,'y':1}") ,"on_x2y1_clicked" : lambda x: self.sendMove("{\"x\":2,\"y\":1}")
,"on_x2y2_clicked" : lambda x: self.sendMove("{'x':2,'y':2}") ,"on_x2y2_clicked" : lambda x: self.sendMove("{\"x\":2,\"y\":2}")
,"on_connectBtn_clicked" : lambda x: self.doConnect() ,"on_connectBtn_clicked" : lambda x: self.doConnect()
} }
@ -53,10 +53,6 @@ class GGSTTT:
"Content-Length: %s\n" % len(token)+ "Content-Length: %s\n" % len(token)+
"\n"+ "\n"+
token) token)
self.s.send("Game-Command: hi\n" +
"Content-Type: text\n" +
"Content-Length: 0\n"+
"\n")
def sendMove(self, move): def sendMove(self, move):
print "Sending move", move print "Sending move", move
@ -93,15 +89,39 @@ class GGSTTT:
if defined == "false": if defined == "false":
print "Defining game" print "Defining game"
js = open("server.js").read() js = open("server.js").read()
self.wTree.get_widget("token").set_text(table_token)
self.s.send("Server-Command: define\n"+ self.s.send("Server-Command: define\n"+
"Content-Type: text\n" + "Content-Type: text\n" +
("Content-Length: %s\n" % len(js))+ "Content-Length: %s\n" % str(len(js))+
"\n%s" % js) "\n" +
js)
if defined == "true":
self.s.send("Game-Command: hi\n" +
"Content-Type: text\n" +
"Content-Length: 0\n"+
"\n")
elif msg["Client-Command"] == "welcome": elif msg["Client-Command"] == "welcome":
self.setStatus("You are player %s" % msg["data"]) self.setStatus("You are player %s" % msg["DATA"])
elif msg["Client-Command"] == "chat": elif msg["Client-Command"] == "warning":
gobject.idle_add(self.updateChatText, msg["DATA"]) self.setStatus("Warning: %s" % msg["DATA"])
elif msg["Client-Command"] == "not_welcome":
self.setStatus("You are not welcome: %s" % msg["DATA"])
elif msg["Client-Command"] == "game_board":
self.wTree.get_widget("x0y0").set_label(msg["DATA"][0])
self.wTree.get_widget("x0y1").set_label(msg["DATA"][1])
self.wTree.get_widget("x0y2").set_label(msg["DATA"][2])
self.wTree.get_widget("x1y0").set_label(msg["DATA"][3])
self.wTree.get_widget("x1y1").set_label(msg["DATA"][4])
self.wTree.get_widget("x1y2").set_label(msg["DATA"][5])
self.wTree.get_widget("x2y0").set_label(msg["DATA"][6])
self.wTree.get_widget("x2y1").set_label(msg["DATA"][7])
self.wTree.get_widget("x2y2").set_label(msg["DATA"][8])
elif msg["Client-Command"] == "defined":
self.s.send("Game-Command: hi\n" +
"Content-Type: text\n" +
"Content-Length: 0\n"+
"\n")
elif msg["Client-Command"] == "lusers": elif msg["Client-Command"] == "lusers":
print msg print msg
gobject.idle_add(self.updateUsers, msg["DATA"]) gobject.idle_add(self.updateUsers, msg["DATA"])

View file

@ -102,6 +102,7 @@ handle_cast({srv_cmd, "hello", _Headers, TableToken}, State) ->
{noreply, State#state{ table = TPid } } {noreply, State#state{ table = TPid } }
end; end;
handle_cast({srv_cmd, "define", _Headers, Data}, #state { table = Table } = State) -> handle_cast({srv_cmd, "define", _Headers, Data}, #state { table = Table } = State) ->
erl:display(Data),
ggs_table:notify(Table, self(), {server, define, Data}), ggs_table:notify(Table, self(), {server, define, Data}),
{noreply, State}; {noreply, State};
handle_cast({game_cmd, Command, _Headers, Data}, #state { table = Table } = State) -> handle_cast({game_cmd, Command, _Headers, Data}, #state { table = Table } = State) ->