home · contact · privacy
Enable Hat editing with characters earned by eating cookies from a CookieSpawner.
[plomrogue2] / rogue_chat_curses.py
index d76c3bebd0b41622a41d3191b8db20836e989f8d..e9f7f6b93c21936d37e783eb9d2d651553e8fc0d 100755 (executable)
@@ -56,6 +56,11 @@ mode_helps = {
         'intro': '@ enter face line (enter nothing to abort):',
         'long': 'Draw your face as ASCII art.  The string you enter must be 18 characters long, and will be divided on display into 3 lines of 6 characters each, from top to bottom..'
     },
+    'enter_hat': {
+        'short': 'enter your hat',
+        'intro': '@ enter hat line (enter nothing to abort):',
+        'long': 'Draw your hat as ASCII art.  The string you enter must be 18 characters long, and will be divided on display into 3 lines of 6 characters each, from top to bottom..'
+    },
     'write': {
         'short': 'change terrain',
         'intro': '',
@@ -211,6 +216,10 @@ def cmd_PLAYER_ID(game, player_id):
     game.player_id = player_id
 cmd_PLAYER_ID.argtypes = 'int:nonneg'
 
+def cmd_PLAYERS_HAT_CHARS(game, hat_chars):
+    game.players_hat_chars_new = hat_chars
+cmd_PLAYERS_HAT_CHARS.argtypes = 'string'
+
 def cmd_THING(game, yx, thing_type, protection, thing_id, portable, commandable):
     t = game.get_thing_temp(thing_id)
     if not t:
@@ -284,6 +293,7 @@ def cmd_GAME_STATE_COMPLETE(game):
     game.map_content = game.map_content_new
     game.map_control_content = game.map_control_content_new
     game.player = game.get_thing(game.player_id)
+    game.players_hat_chars = game.players_hat_chars_new
     game.turn_complete = True
     if game.tui.mode.name == 'post_login_wait':
         game.tui.switch_mode('play')
@@ -382,6 +392,7 @@ class Game(GameBase):
         self.register_command(cmd_PORTAL)
         self.register_command(cmd_ANNOTATION)
         self.register_command(cmd_GAME_STATE_COMPLETE)
+        self.register_command(cmd_PLAYERS_HAT_CHARS)
         self.register_command(cmd_ARGUMENT_ERROR)
         self.register_command(cmd_GAME_ERROR)
         self.register_command(cmd_PLAY_ERROR)
@@ -390,6 +401,7 @@ class Game(GameBase):
         self.register_command(cmd_DEFAULT_COLORS)
         self.register_command(cmd_RANDOM_COLORS)
         self.map_content = ''
+        self.players_hat_chars = ''
         self.player_id = -1
         self.annotations = {}
         self.annotations_new = {}
@@ -480,6 +492,7 @@ class TUI:
     mode_take_thing = Mode('take_thing', has_input_prompt=True)
     mode_drop_thing = Mode('drop_thing', has_input_prompt=True)
     mode_enter_face = Mode('enter_face', has_input_prompt=True)
+    mode_enter_hat = Mode('enter_hat', has_input_prompt=True)
     is_admin = False
     tile_draw = False
 
@@ -501,7 +514,7 @@ class TUI:
         self.mode_control_tile_draw.available_actions = ["move_explorer",
                                                          "toggle_tile_draw"]
         self.mode_edit.available_modes = ["write", "annotate", "portal",
-                                          "name_thing", "enter_face", "password",
+                                          "name_thing", "enter_face", "enter_hat", "password",
                                           "chat", "study", "play", "admin_enter"]
         self.mode_edit.available_actions = ["move", "flatten", "install",
                                             "toggle_map_mode"]
@@ -534,6 +547,7 @@ class TUI:
             'switch_to_admin_thing_protect': 'T',
             'flatten': 'F',
             'switch_to_enter_face': 'f',
+            'switch_to_enter_hat': 'H',
             'switch_to_take_thing': 'z',
             'switch_to_drop_thing': 'u',
             'teleport': 'p',
@@ -731,6 +745,8 @@ class TUI:
                 ['HERE'] + list(self.game.tui.movement_keys.values())
             for i in range(len(self.selectables)):
                 self.log_msg(str(i) + ': ' + self.selectables[i])
+        elif self.mode.name == 'enter_hat':
+            self.log_msg('legal characters: ' + self.game.players_hat_chars)
         elif self.mode.name == 'command_thing':
             self.send('TASK:COMMAND ' + quote('HELP'))
         elif self.mode.name == 'control_pw_pw':
@@ -1176,6 +1192,13 @@ class TUI:
                     self.send('PLAYER_FACE %s' % quote(self.input_))
                 self.input_ = ""
                 self.switch_mode('edit')
+            elif self.mode.name == 'enter_hat' and key == '\n':
+                if len(self.input_) != 18:
+                    self.log_msg('? wrong input length, aborting')
+                else:
+                    self.send('PLAYER_HAT %s' % quote(self.input_))
+                self.input_ = ""
+                self.switch_mode('edit')
             elif self.mode.name == 'take_thing' and key == '\n':
                 pick_selectable('PICK_UP')
             elif self.mode.name == 'drop_thing' and key == '\n':