home · contact · privacy
Enable Hat editing with characters earned by eating cookies from a CookieSpawner.
[plomrogue2] / rogue_chat.html
index 883afc9322ad994c260c3a422921f477c58fb2e7..4285ded541ea1912fd83f36ba37337761407f074 100644 (file)
@@ -69,6 +69,7 @@ terminal rows: <input id="n_rows" type="number" step=4 min=24 value=24 />
       <button id="switch_to_name_thing"></button>
       <button id="switch_to_password"></button>
       <button id="switch_to_enter_face"></button>
+      <button id="switch_to_enter_hat"></button>
     </td>
   </tr>
   <tr>
@@ -104,6 +105,7 @@ terminal rows: <input id="n_rows" type="number" step=4 min=24 value=24 />
 <li>(un-)wear: <input id="key_wear" type="text" value="W" />
 <li><input id="key_switch_to_drop_thing" type="text" value="u" />
 <li><input id="key_switch_to_enter_face" type="text" value="f" />
+<li><input id="key_switch_to_enter_hat" type="text" value="H" />
 <li><input id="key_switch_to_take_thing" type="text" value="z" />
 <li><input id="key_switch_to_chat" type="text" value="t" />
 <li><input id="key_switch_to_play" type="text" value="p" />
@@ -173,6 +175,11 @@ let 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': '',
@@ -536,6 +543,7 @@ let server = {
             explorer.info_cached = false;
             game.things = game.things_new;
             game.player = game.things[game.player_id];
+            game.players_hat_chars = game.players_hat_chars_new;
             game.turn_complete = true;
             if (tui.mode.name == 'post_login_wait') {
                 tui.switch_mode('play');
@@ -551,6 +559,8 @@ let server = {
              tui.log_msg('#MUSICPLAYER: ' + tokens[1], 1);
         } else if (tokens[0] === 'PLAYER_ID') {
             game.player_id = parseInt(tokens[1]);
+        } else if (tokens[0] === 'PLAYERS_HAT_CHARS') {
+            game.players_hat_chars_new = tokens[1];
         } else if (tokens[0] === 'LOGIN_OK') {
             this.send(['GET_GAMESTATE']);
             tui.switch_mode('post_login_wait');
@@ -688,6 +698,7 @@ let tui = {
   mode_take_thing: new Mode('take_thing', true),
   mode_drop_thing: new Mode('drop_thing', true),
   mode_enter_face: new Mode('enter_face', true),
+  mode_enter_hat: new Mode('enter_hat', true),
   mode_admin_enter: new Mode('admin_enter', true),
   mode_admin: new Mode('admin'),
   mode_control_pw_pw: new Mode('control_pw_pw', true),
@@ -724,7 +735,7 @@ let tui = {
       this.mode_control_tile_draw.available_actions = ["toggle_tile_draw"];
       this.mode_edit.available_modes = ["write", "annotate", "portal", "name_thing",
                                         "password", "chat", "study", "play",
-                                        "admin_enter", "enter_face"]
+                                        "admin_enter", "enter_face", "enter_hat"]
       this.mode_edit.available_actions = ["move", "flatten", "install",
                                           "toggle_map_mode"]
       this.inputEl = document.getElementById("input");
@@ -1322,6 +1333,7 @@ let game = {
         this.map_size_new = [0,0];
         this.portals = {};
         this.portals_new = {};
+        this.players_hat_chars = "";
     },
     get_thing_temp: function(id_, create_if_not_found=false) {
         if (id_ in game.things_new) {
@@ -1543,6 +1555,14 @@ tui.inputEl.addEventListener('keydown', (event) => {
         }
         tui.inputEl.value = "";
         tui.switch_mode('edit');
+    } else if (tui.mode.name == 'enter_hat' && event.key == 'Enter') {
+        if (tui.inputEl.value.length != 18) {
+            tui.log_msg('? wrong input length, aborting');
+        } else {
+            server.send(['PLAYER_HAT', tui.inputEl.value]);
+        }
+        tui.inputEl.value = "";
+        tui.switch_mode('edit');
     } else if (tui.mode.name == 'command_thing' && event.key == 'Enter') {
         server.send(['TASK:COMMAND', tui.inputEl.value]);
         tui.inputEl.value = "";