From: Christian Heller Date: Mon, 7 Dec 2020 00:50:20 +0000 (+0100) Subject: Mark thing-carrying players with $ instead of +. X-Git-Url: https://plomlompom.com/repos/%7B%7B%20web_path%20%7D%7D/decks/%7B%7Bprefix%7D%7D/day?a=commitdiff_plain;h=51addf32b5a876c47325fb55756aacaea65ed0da;p=plomrogue2 Mark thing-carrying players with $ instead of +. --- diff --git a/plomrogue/game.py b/plomrogue/game.py index a1c2ee6..cd1ce2e 100755 --- a/plomrogue/game.py +++ b/plomrogue/game.py @@ -238,6 +238,8 @@ class Game(GameBase): if hasattr(t, 'thing_char'): self.io.send('THING_CHAR %s %s' % (t.id_, quote(t.thing_char)), c_id) + if hasattr(t, 'carrying') and t.carrying: + self.io.send('THING_CARRYING %s' % (t.id_)) for big_yx in self.portals: for little_yx in [little_yx for little_yx in self.portals[big_yx] if player.fov_test(big_yx, little_yx)]: diff --git a/rogue_chat.html b/rogue_chat.html index 573e295..0c0cb30 100644 --- a/rogue_chat.html +++ b/rogue_chat.html @@ -488,6 +488,11 @@ let server = { tui.mode_take_thing.legal = game.tasks.includes('PICK_UP'); } else if (tokens[0] === 'THING_TYPE') { game.thing_types[tokens[1]] = tokens[2] + } else if (tokens[0] === 'THING_CARRYING') { + let t = game.get_thing(tokens[1], false); + if (t) { + t.carrying = true; + }; } else if (tokens[0] === 'TERRAIN') { game.terrains[tokens[1]] = tokens[2] } else if (tokens[0] === 'MAP') { @@ -994,6 +999,9 @@ let tui = { if (used_positions.includes(t.position.toString())) { meta_char = '+'; }; + if (t.carrying) { + meta_char = '$'; + } map_lines_split[t.position[0]][t.position[1]] = symbol + meta_char; used_positions.push(t.position.toString()); } diff --git a/rogue_chat_curses.py b/rogue_chat_curses.py index b759038..6a30f74 100755 --- a/rogue_chat_curses.py +++ b/rogue_chat_curses.py @@ -291,6 +291,10 @@ def cmd_THING_TYPE(game, thing_type, symbol_hint): game.thing_types[thing_type] = symbol_hint cmd_THING_TYPE.argtypes = 'string char' +def cmd_THING_CARRYING(game, thing_id): + game.get_thing(thing_id).carrying = True +cmd_THING_CARRYING.argtypes = 'int:nonneg' + def cmd_TERRAIN(game, terrain_char, terrain_desc): game.terrains[terrain_char] = terrain_desc cmd_TERRAIN.argtypes = 'char string' @@ -325,6 +329,7 @@ class Game(GameBase): self.register_command(cmd_THING_TYPE) self.register_command(cmd_THING_NAME) self.register_command(cmd_THING_CHAR) + self.register_command(cmd_THING_CARRYING) self.register_command(cmd_TERRAIN) self.register_command(cmd_MAP) self.register_command(cmd_MAP_CONTROL) @@ -846,6 +851,8 @@ class TUI: meta_char = t.thing_char if t.position in used_positions: meta_char = '+' + if hasattr(t, 'carrying') and t.carrying: + meta_char = '$' map_lines_split[t.position.y][t.position.x] = symbol + meta_char used_positions += [t.position]