Commits

Dominic Kexel committed 7e69282 Merge

Zusammenführen

  • Participants
  • Parent commits 8ff23a9, 3ac9710
  • Branches cocos

Comments (0)

Files changed (4)

client/pygameclient/scenes/scene.py

         self.txtName = gui.TextBox(position=(x, y), parent=app, text=name)
         y += 25
 
+        self.txtServer = gui.TextBox(position=(x, y), parent=app, text='xxx.x.x.x:xxx')
+        y += 25
+
         self.btnQuick = gui.Button(position=(x, y), size=(150, 0),
                                    parent=app, text="Quick Match")
         self.btnQuick.onClick = self.quick_match
         self.btnEditor.onClick = self.deck_editor
         y += 25
 
-        self.btnJoin = gui.Button(position=(x, y), size=(150, 0), parent=
-                                  app, text="Join Game")
+        self.btnJoin = gui.Button(position=(x, y), size=(150, 0), parent=app, text="Join Game")
         self.btnJoin.onClick = lambda *args: self.req_con()
         y += 25
 
         
     def req_con(self):
         self.client.name = self.txtName.text
-        addr = find_server()
+        if self.txtServer.text != 'xxx.x.x.x:xxx' and self.txtServer.text:
+            addr = self.txtServer.text.split(':')
+        else:
+            addr = find_server()
         self.client.port = int(addr[1])
         self.client.server = addr[0]
         RequestConnectEvent(self.client.server, self.client.port).post(self.client.ev)
         st.start()
 
         addr = st.poll()
+        logging.info("Server runs on %s" % str(addr))
         udp = UDPServerThread(addr)
         udp.start()
         self.client.threads.append(st)

game/global_options.py

-debug_mode = False
+debug_mode = False
+port=0
 
 parser = argparse.ArgumentParser(description='Regnancy - the deck building game.')
 parser.add_argument('-d', '--debug', action='store_true', help='run Regnancy in debug mode')
+parser.add_argument('-p', '--port', action='store', help='always try to run servers on this port')
 parser.add_argument('-n', '--name', action='store', nargs='+', help='sets the player name')
 group = parser.add_mutually_exclusive_group()
 group.add_argument('-j', '--join', action='store_true', help='join a running game immediately')
 
 if __name__ == "__main__":
     game.global_options.debug_mode = args['debug']
+    if args['port']:
+        game.global_options.port = int(args['port'])
     name = " ".join(args['name']) if args['name'] else None
     #client = gc.PygameClient(name, args['start'], args['join'], args['quickmatch'])
     client = gc.CocosClient(name, args['start'], args['join'], args['quickmatch'])

server/regnancyserver.py

 
 from framework.PodSixNet.Server import Server
 from framework.locals import *
-from game import game
+from game import game, global_options
 from regnancychannel import RegnancyChannel
 from time import sleep
 from weakref import WeakKeyDictionary
         self.clients = WeakKeyDictionary()
         self.masterplayer = None
 
-        self.localaddr = (nwp.get_lan_ip(), 0)
+        self.localaddr = (nwp.get_lan_ip(), global_options.port)
         Server.__init__(self, RegnancyChannel, localaddr=self.localaddr)
         self.addr = self.socket.getsockname()
         self.__game = game.Game()