home · contact · privacy
Send THING_CARRYING only after all things have been set up.
[plomrogue2] / rogue_chat.html
index 1ba0ff1f6fcf02debf88eaefcc07b2c9e71c3d07..3a636198a9bd69e888bbcad4607ce26f214f5129 100644 (file)
@@ -57,7 +57,6 @@ keyboard input/control: <span id="keyboard_control"></span>
       <button id="consume"></button>
       <button id="switch_to_command_thing"></button>
       <button id="teleport"></button>
-      <button id="install"></button>
       <button id="wear"></button>
       <button id="spin"></button>
     </td>
@@ -67,6 +66,7 @@ keyboard input/control: <span id="keyboard_control"></span>
     <td>
       <button id="switch_to_write"></button>
       <button id="flatten"></button>
+      <button id="install"></button>
       <button id="switch_to_annotate"></button>
       <button id="switch_to_portal"></button>
       <button id="switch_to_name_thing"></button>
@@ -705,7 +705,7 @@ let tui = {
       this.mode_play.available_modes = ["chat", "study", "edit", "admin_enter",
                                         "command_thing", "take_thing", "drop_thing"]
       this.mode_play.available_actions = ["move", "teleport", "door", "consume",
-                                          "install", "wear", "spin"];
+                                          "wear", "spin"];
       this.mode_study.available_modes = ["chat", "play", "admin_enter", "edit"]
       this.mode_study.available_actions = ["toggle_map_mode", "move_explorer"];
       this.mode_admin.available_modes = ["admin_thing_protect", "control_pw_type",
@@ -717,7 +717,8 @@ let tui = {
       this.mode_edit.available_modes = ["write", "annotate", "portal", "name_thing",
                                         "password", "chat", "study", "play",
                                         "admin_enter", "enter_face"]
-      this.mode_edit.available_actions = ["move", "flatten", "toggle_map_mode"]
+      this.mode_edit.available_actions = ["move", "flatten", "install",
+                                          "toggle_map_mode"]
       this.inputEl = document.getElementById("input");
       this.inputEl.focus();
       this.switch_mode('waiting_for_server');
@@ -763,22 +764,26 @@ let tui = {
       return game.tasks.includes(this.action_tasks[action]);
   },
   switch_mode: function(mode_name) {
+
+    function fail(msg, return_mode) {
+        tui.log_msg('? ' + msg);
+        terminal.blink_screen();
+        this.switch_mode(return_mode);
+    }
+
     if (this.mode && this.mode.name == 'control_tile_draw') {
         tui.log_msg('@ finished tile protection drawing.')
     }
     this.tile_draw = false;
       if (mode_name == 'command_thing' && (!game.player.carrying
                                            || !game.player.carrying.commandable)) {
-        this.log_msg('? not carrying anything commandable');
-        terminal.blink_screen();
-        this.switch_mode('play');
-        return;
+        return fail('not carrying anything commandable', 'play');
     };
-    if (mode_name == 'drop_thing' && (!game.player.carrying)) {
-        this.log_msg('? not carrying anything droppable');
-        terminal.blink_screen();
-        this.switch_mode('play');
-        return;
+    if (mode_name == 'take_thing' && game.player.carrying) {
+        return fail('already carrying something', 'play');
+    };
+    if (mode_name == 'drop_thing' && !game.player.carrying) {
+        return fail('not carrying anything droppable', 'play');
     }
     if (mode_name == 'admin_enter' && this.is_admin) {
         mode_name = 'admin';
@@ -796,9 +801,7 @@ let tui = {
             }
         }
         if (!thing_id) {
-            terminal.blink_screen();
-            this.log_msg('? not standing over thing');
-            return;
+            return fail('not standing over thing', 'fail');
         } else {
             this.selected_thing_id = thing_id;
         }
@@ -1587,8 +1590,6 @@ tui.inputEl.addEventListener('keydown', (event) => {
               server.send(["TASK:INTOXICATE"]);
           } else if (event.key === tui.keys.door && tui.task_action_on('door')) {
               server.send(["TASK:DOOR"]);
-          } else if (event.key === tui.keys.install && tui.task_action_on('install')) {
-              server.send(["TASK:INSTALL"]);
           } else if (event.key === tui.keys.wear && tui.task_action_on('wear')) {
               server.send(["TASK:WEAR"]);
           } else if (event.key === tui.keys.spin && tui.task_action_on('spin')) {
@@ -1627,6 +1628,8 @@ tui.inputEl.addEventListener('keydown', (event) => {
             server.send(['TASK:MOVE', tui.movement_keys[event.key]]);
         } else if (event.key === tui.keys.flatten && tui.task_action_on('flatten')) {
             server.send(["TASK:FLATTEN_SURROUNDINGS", tui.password]);
+          } else if (event.key === tui.keys.install && tui.task_action_on('install')) {
+              server.send(["TASK:INSTALL", tui.password]);
         } else if (event.key == tui.keys.toggle_map_mode) {
             tui.toggle_map_mode();
         }