From: Christian Heller Date: Sat, 26 Dec 2020 22:24:29 +0000 (+0100) Subject: Replace hard-coded client login welcome messages with optional server login messages. X-Git-Url: https://plomlompom.com/repos/%7B%7Bprefix%7D%7D/%7B%7Bdb.prefix%7D%7D/%7B%7B%20web_path%20%7D%7D/do_todos?a=commitdiff_plain;h=699621898072da0b0b93748e2b6a49badfdec391;p=plomrogue2 Replace hard-coded client login welcome messages with optional server login messages. --- diff --git a/plomrogue/commands.py b/plomrogue/commands.py index 8376355..ec31b12 100644 --- a/plomrogue/commands.py +++ b/plomrogue/commands.py @@ -463,3 +463,7 @@ def cmd_THING_SPAWNPOINT_CREATED(game, spawnpoint_id, timestamp): spawnpoint.temporary = True spawnpoint.created_at = datetime.datetime.fromtimestamp(timestamp) cmd_THING_SPAWNPOINT_CREATED.argtypes = 'int:pos int:nonneg' + +def cmd_INTRO_MSG(game, msg): + game.intro_messages += [msg] +cmd_INTRO_MSG.argtypes = 'string' diff --git a/plomrogue/game.py b/plomrogue/game.py index 793c322..8784007 100755 --- a/plomrogue/game.py +++ b/plomrogue/game.py @@ -132,6 +132,7 @@ class Game(GameBase): self.annotations = {} self.spawn_points = [] self.portals = {} + self.intro_messages = [] self.player_chars = string.digits + string.ascii_letters self.players_hat_chars = {} self.player_char_i = -1 @@ -355,6 +356,8 @@ class Game(GameBase): print('DEBUG LOGIN', t.name, len(self.sessions)) self.io.send('PLAYER_ID %s' % t.id_, connection_id) self.io.send('LOGIN_OK', connection_id) + for msg in self.intro_messages: + self.io.send('CHAT ' + quote(msg)) self.io.send('CHAT ' + quote(t.name + ' entered the map.')) for s in [s for s in self.things if s.type_ == 'SpawnPoint' and s.name == t.name]: @@ -601,6 +604,8 @@ class Game(GameBase): next_thing_id += 1 for s in self.spawn_points: write(f, 'SPAWN_POINT %s %s' % (s[0], s[1])) + for msg in self.intro_messages: + write(f, 'INTRO_MSG %s' % quote(msg)) diff --git a/rogue_chat.html b/rogue_chat.html index e7004a1..1ace4c3 100644 --- a/rogue_chat.html +++ b/rogue_chat.html @@ -578,8 +578,6 @@ let server = { this.send(['GET_GAMESTATE']); tui.switch_mode('post_login_wait'); tui.log_msg('@ welcome!') - tui.log_msg('@ hint: see top of terminal for how to get help.') - tui.log_msg('@ hint: enter study mode to understand your environment.') } else if (tokens[0] === 'DEFAULT_COLORS') { terminal.set_default_colors(); } else if (tokens[0] === 'RANDOM_COLORS') { diff --git a/rogue_chat.py b/rogue_chat.py index f37477b..6696a73 100755 --- a/rogue_chat.py +++ b/rogue_chat.py @@ -10,7 +10,7 @@ from plomrogue.commands import (cmd_ALL, cmd_LOGIN, cmd_NICK, cmd_PING, cmd_THIN cmd_GOD_THING_NAME, cmd_THING_DOOR_CLOSED, cmd_GOD_THING_PROTECTION, cmd_THING_PROTECTION, cmd_SET_MAP_CONTROL_PASSWORD, cmd_SPAWN_POINT, - cmd_THING_MUSICPLAYER_SETTINGS, + cmd_THING_MUSICPLAYER_SETTINGS, cmd_INTRO_MSG, cmd_THING_MUSICPLAYER_PLAYLIST_ITEM, cmd_TERRAIN, cmd_THING_BOTTLE_EMPTY, cmd_PLAYER_FACE, cmd_GOD_PLAYER_FACE, cmd_GOD_PLAYER_HAT, @@ -83,6 +83,7 @@ game.register_command(cmd_GOD_THING_DESIGN) game.register_command(cmd_GOD_THING_DESIGN_SIZE) game.register_command(cmd_MAP_CONTROL_PRESETS) game.register_command(cmd_THING_SPAWNPOINT_CREATED) +game.register_command(cmd_INTRO_MSG) game.register_task(Task_WAIT) game.register_task(Task_MOVE) game.register_task(Task_WRITE) diff --git a/rogue_chat_curses.py b/rogue_chat_curses.py index d6d8242..1d32772 100755 --- a/rogue_chat_curses.py +++ b/rogue_chat_curses.py @@ -187,8 +187,6 @@ def cmd_LOGIN_OK(game): game.tui.switch_mode('post_login_wait') game.tui.send('GET_GAMESTATE') game.tui.log_msg('@ welcome!') - game.tui.log_msg('@ hint: see top of terminal for how to get help.') - game.tui.log_msg('@ hint: enter study mode to understand your environment.') cmd_LOGIN_OK.argtypes = '' def cmd_ADMIN_OK(game):