pass # we assume socket will be known as dead by now
def cmd_TURN(game, n):
+ game.info_db = {}
+ game.info_hints = []
game.turn = n
game.things = []
game.portals = {}
cmd_MAP_CONTROL.argtypes = '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:
cmd_PORTAL.argtypes = 'yx_tuple:nonneg string'
def cmd_PLAY_ERROR(game, msg):
- game.tui.flash()
+ game.tui.log_msg('? ' + msg)
+ game.tui.flash = True
game.tui.do_refresh = True
cmd_PLAY_ERROR.argtypes = 'string'
game.tui.do_refresh = True
cmd_ARGUMENT_ERROR.argtypes = 'string'
+def cmd_ANNOTATION_HINT(game, position):
+ game.info_hints += [position]
+cmd_ANNOTATION_HINT.argtypes = 'yx_tuple:nonneg'
+
def cmd_ANNOTATION(game, position, msg):
game.info_db[position] = msg
+ game.tui.restore_input_values()
if game.tui.mode.shows_info:
game.tui.do_refresh = True
cmd_ANNOTATION.argtypes = 'yx_tuple:nonneg string'
self.register_command(cmd_MAP_CONTROL)
self.register_command(cmd_PORTAL)
self.register_command(cmd_ANNOTATION)
+ self.register_command(cmd_ANNOTATION_HINT)
self.register_command(cmd_GAME_STATE_COMPLETE)
self.register_command(cmd_ARGUMENT_ERROR)
self.register_command(cmd_GAME_ERROR)
self.map_content = ''
self.player_id = -1
self.info_db = {}
+ self.info_hints = []
self.portals = {}
self.terrains = {}
self.force_instant_connect = True
self.input_lines = []
self.fov = ''
+ self.flash = False
curses.wrapper(self.loop)
- def flash(self):
- curses.flash()
-
def connect(self):
def handle_recv(msg):
if self.mode.shows_info:
player = self.game.get_thing(self.game.player_id)
self.explorer = YX(player.position.y, player.position.x)
+ self.query_info()
if self.mode.name == 'waiting_for_server':
self.log_msg('@ waiting for server …')
if self.mode.name == 'edit':
self.window_width)
def move_explorer(direction):
- target = self.game.map_geometry.move(self.explorer, direction)
+ target = self.game.map_geometry.move_yx(self.explorer, direction)
if target:
self.explorer = target
self.query_info()
else:
- self.flash()
+ self.flash = True
def draw_history():
lines = []
if terrain_char in self.game.terrains:
terrain_desc = self.game.terrains[terrain_char]
info = 'TERRAIN: "%s" / %s\n' % (terrain_char, terrain_desc)
+ protection = self.game.map_control_content[pos_i]
+ if protection == '.':
+ protection = 'unprotected'
+ info = 'PROTECTION: %s\n' % protection
for t in self.game.things:
if t.position == self.explorer:
info += 'THING: %s / %s' % (t.type_,
start = self.game.map_geometry.size.x * y
end = start + self.game.map_geometry.size.x
map_lines_split += [[c + ' ' for c in map_content[start:end]]]
- if self.map_mode == 'terrain':
+ if self.map_mode == 'annotations':
+ for p in self.game.info_hints:
+ map_lines_split[p.y][p.x] = 'A '
+ elif self.map_mode == 'terrain':
+ for p in self.game.portals.keys():
+ map_lines_split[p.y][p.x] = 'P '
used_positions = []
for t in self.game.things:
symbol = self.game.thing_types[t.type_]
elif self.mode == self.mode_study:
content += 'Available actions:\n'
content += '[%s] – move question mark\n' % ','.join(self.movement_keys)
- content += '[%s] – toggle view between terrain, and password protection areas\n' % self.keys['toggle_map_mode']
+ content += '[%s] – toggle view between terrain, annotations, and password protection areas\n' % self.keys['toggle_map_mode']
content += '\n\nOther modes available from here:'
content += '[%s] – chat mode\n' % self.keys['switch_to_chat']
content += '[%s] – play mode\n' % self.keys['switch_to_play']
elif self.mode == self.mode_chat:
content += '/nick NAME – re-name yourself to NAME\n'
- #content += '/msg USER TEXT – send TEXT to USER\n'
content += '/%s or /play – switch to play mode\n' % self.keys['switch_to_play']
content += '/%s or /study – switch to study mode\n' % self.keys['switch_to_study']
for i in range(self.size.y):
else:
self.send('PING')
last_ping = now
+ if self.flash:
+ curses.flash()
+ self.flash = False
if self.do_refresh:
draw_screen()
self.do_refresh = False
self.send('NICK ' + quote(tokens[1]))
else:
self.log_msg('? need login name')
- #elif self.input_.startswith('/msg'):
- # tokens = self.input_.split(maxsplit=2)
- # if len(tokens) == 3:
- # self.send('QUERY %s %s' % (quote(tokens[1]),
- # quote(tokens[2])))
- # else:
- # self.log_msg('? need message target and message')
else:
self.log_msg('? unknown command')
else:
self.switch_mode('play')
elif key == self.keys['toggle_map_mode']:
if self.map_mode == 'terrain':
+ self.map_mode = 'annotations'
+ elif self.map_mode == 'annotations':
self.map_mode = 'control'
else:
self.map_mode = 'terrain'
self.host = self.game.portals[player.position]
self.reconnect()
else:
- self.flash()
+ self.flash = True
self.log_msg('? not standing on portal')
elif key in self.movement_keys and 'MOVE' in self.game.tasks:
self.send('TASK:MOVE ' + self.movement_keys[key])
self.send('TASK:WRITE %s %s' % (key, quote(self.password)))
self.switch_mode('play')
-TUI('localhost:5000')
+#TUI('localhost:5000')
+TUI('wss://plomlompom.com/rogue_chat/')