+from plomrogue.game import GameBase
+from plomrogue.parser import Parser
+from plomrogue.mapping import YX
+from plomrogue.things import ThingBase
+from plomrogue.misc import quote
+
+# TODO: fix screen refreshes on intermediary map results
+
+def cmd_TURN(game, n):
+ game.turn = n
+ game.things = []
+ game.portals = {}
+cmd_TURN.argtypes = 'int:nonneg'
+
+def cmd_LOGIN_OK(game):
+ game.tui.switch_mode('post_login_wait')
+ game.tui.socket.send('GET_GAMESTATE')
+ game.tui.log_msg('@ welcome')
+cmd_LOGIN_OK.argtypes = ''
+
+def cmd_CHAT(game, msg):
+ game.tui.log_msg('# ' + msg)
+ game.tui.do_refresh = True
+cmd_CHAT.argtypes = 'string'
+
+def cmd_PLAYER_ID(game, player_id):
+ game.player_id = player_id
+cmd_PLAYER_ID.argtypes = 'int:nonneg'
+
+def cmd_THING_POS(game, thing_id, position):
+ t = game.get_thing(thing_id, True)
+ t.position = position
+cmd_THING_POS.argtypes = 'int:nonneg yx_tuple:nonneg'
+
+def cmd_THING_NAME(game, thing_id, name):
+ t = game.get_thing(thing_id, True)
+ t.name = name
+cmd_THING_NAME.argtypes = 'int:nonneg string'
+
+def cmd_MAP(game, size, content):
+ game.map_size = size
+ game.map_content = content
+cmd_MAP.argtypes = 'yx_tuple:pos string'
+
+def cmd_GAME_STATE_COMPLETE(game):
+ game.info_db = {}
+ if game.tui.mode.name == 'post_login_wait':
+ game.tui.switch_mode('play')
+ if game.tui.mode.shows_info:
+ game.tui.query_info()
+ game.tui.do_refresh = True
+cmd_GAME_STATE_COMPLETE.argtypes = ''
+
+def cmd_PORTAL(game, position, msg):
+ game.portals[position] = msg
+cmd_PORTAL.argtypes = 'yx_tuple:nonneg string'
+
+def cmd_PLAY_ERROR(game, msg):
+ game.tui.log_msg('imagine the screen flicker (TODO)')
+ game.tui.do_refresh = True
+cmd_PLAY_ERROR.argtypes = 'string'
+
+def cmd_ARGUMENT_ERROR(game, msg):
+ game.tui.log_msg('? syntax error: ' + msg)
+ game.tui.do_refresh = True
+cmd_ARGUMENT_ERROR.argtypes = 'string'
+
+def cmd_ANNOTATION(game, position, msg):
+ game.info_db[position] = msg
+ if game.tui.mode.shows_info:
+ game.tui.do_refresh = True
+cmd_ANNOTATION.argtypes = 'yx_tuple:nonneg string'