home
·
contact
·
privacy
projects
/
plomrogue2
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
dd annotation hints view.
[plomrogue2]
/
rogue_chat_curses.py
diff --git
a/rogue_chat_curses.py
b/rogue_chat_curses.py
index c5e4f9dae3929446b9e8be79cd9d8b3476433cf5..54499daf2551ac335dc93ff9f274d1dcc09bd136 100755
(executable)
--- a/
rogue_chat_curses.py
+++ b/
rogue_chat_curses.py
@@
-51,6
+51,8
@@
class PlomSocketClient(PlomSocket):
pass # we assume socket will be known as dead by now
def cmd_TURN(game, n):
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 = {}
game.turn = n
game.things = []
game.portals = {}
@@
-124,7
+126,6
@@
def cmd_MAP_CONTROL(game, content):
cmd_MAP_CONTROL.argtypes = 'string'
def cmd_GAME_STATE_COMPLETE(game):
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:
if game.tui.mode.name == 'post_login_wait':
game.tui.switch_mode('play')
if game.tui.mode.shows_info:
@@
-138,7
+139,8
@@
def cmd_PORTAL(game, position, msg):
cmd_PORTAL.argtypes = 'yx_tuple:nonneg string'
def cmd_PLAY_ERROR(game, msg):
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_PLAY_ERROR.argtypes = 'string'
@@
-152,8
+154,13
@@
def cmd_ARGUMENT_ERROR(game, msg):
game.tui.do_refresh = True
cmd_ARGUMENT_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
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'
if game.tui.mode.shows_info:
game.tui.do_refresh = True
cmd_ANNOTATION.argtypes = 'yx_tuple:nonneg string'
@@
-195,6
+202,7
@@
class Game(GameBase):
self.register_command(cmd_MAP_CONTROL)
self.register_command(cmd_PORTAL)
self.register_command(cmd_ANNOTATION)
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.register_command(cmd_GAME_STATE_COMPLETE)
self.register_command(cmd_ARGUMENT_ERROR)
self.register_command(cmd_GAME_ERROR)
@@
-204,6
+212,7
@@
class Game(GameBase):
self.map_content = ''
self.player_id = -1
self.info_db = {}
self.map_content = ''
self.player_id = -1
self.info_db = {}
+ self.info_hints = []
self.portals = {}
self.terrains = {}
self.portals = {}
self.terrains = {}
@@
-290,11
+299,9
@@
class TUI:
self.force_instant_connect = True
self.input_lines = []
self.fov = ''
self.force_instant_connect = True
self.input_lines = []
self.fov = ''
+ self.flash = False
curses.wrapper(self.loop)
curses.wrapper(self.loop)
- def flash(self):
- curses.flash()
-
def connect(self):
def handle_recv(msg):
def connect(self):
def handle_recv(msg):
@@
-367,6
+374,7
@@
class TUI:
if self.mode.shows_info:
player = self.game.get_thing(self.game.player_id)
self.explorer = YX(player.position.y, player.position.x)
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':
if self.mode.name == 'waiting_for_server':
self.log_msg('@ waiting for server …')
if self.mode.name == 'edit':
@@
-425,12
+433,12
@@
class TUI:
self.window_width)
def move_explorer(direction):
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:
if target:
self.explorer = target
self.query_info()
else:
- self.flash
()
+ self.flash
= True
def draw_history():
lines = []
def draw_history():
lines = []
@@
-508,7
+516,12
@@
class TUI:
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]]]
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_]
used_positions = []
for t in self.game.things:
symbol = self.game.thing_types[t.type_]
@@
-574,13
+587,12
@@
class TUI:
elif self.mode == self.mode_study:
content += 'Available actions:\n'
content += '[%s] – move question mark\n' % ','.join(self.movement_keys)
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, an
notations, an
d 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 += '\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):
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):
@@
-633,6
+645,9
@@
class TUI:
else:
self.send('PING')
last_ping = now
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
if self.do_refresh:
draw_screen()
self.do_refresh = False
@@
-687,13
+702,6
@@
class TUI:
self.send('NICK ' + quote(tokens[1]))
else:
self.log_msg('? need login name')
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:
else:
self.log_msg('? unknown command')
else:
@@
-720,6
+728,8
@@
class TUI:
self.switch_mode('play')
elif key == self.keys['toggle_map_mode']:
if self.map_mode == 'terrain':
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.map_mode = 'control'
else:
self.map_mode = 'terrain'
@@
-752,7
+762,7
@@
class TUI:
self.host = self.game.portals[player.position]
self.reconnect()
else:
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.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])
@@
-760,4
+770,5
@@
class TUI:
self.send('TASK:WRITE %s %s' % (key, quote(self.password)))
self.switch_mode('play')
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/')