home · contact · privacy
Add music player.
[plomrogue2] / rogue_chat.html
index cc505bc9af9dd1a4909739c0ee40f5e69b6bd4fe..8efe2a2a637c5e55a8d6a634976a514cb7d6001e 100644 (file)
@@ -55,6 +55,7 @@ keyboard input/control: <span id="keyboard_control"></span>
       <button id="drop_thing"></button>
       <button id="door"></button>
       <button id="consume"></button>
+      <button id="switch_to_command_thing"></button>
       <button id="teleport"></button>
     </td>
   </tr>
@@ -105,6 +106,7 @@ keyboard input/control: <span id="keyboard_control"></span>
 <li><input id="key_switch_to_edit" type="text" value="E" />
 <li><input id="key_switch_to_write" type="text" value="m" />
 <li><input id="key_switch_to_name_thing" type="text" value="N" />
+<li><input id="key_switch_to_command_thing" type="text" value="O" />
 <li><input id="key_switch_to_password" type="text" value="P" />
 <li><input id="key_switch_to_admin_enter" type="text" value="A" />
 <li><input id="key_switch_to_control_pw_type" type="text" value="C" />
@@ -137,6 +139,10 @@ let mode_helps = {
         'short': 'name thing',
         'long': 'Give name to/change name of thing here.'
     },
+    'command_thing': {
+        'short': 'command thing',
+        'long': 'Enter a command to the thing you carry.  Enter nothing to return to play mode.'
+    },
     'admin_thing_protect': {
         'short': 'change thing protection',
         'long': 'Change protection character for thing here.'
@@ -453,6 +459,7 @@ let server = {
         } else if (tokens[0] === 'TASKS') {
             game.tasks = tokens[1].split(',');
             tui.mode_write.legal = game.tasks.includes('WRITE');
+            tui.mode_command_thing.legal = game.tasks.includes('WRITE');
         } else if (tokens[0] === 'THING_TYPE') {
             game.thing_types[tokens[1]] = tokens[2]
         } else if (tokens[0] === 'TERRAIN') {
@@ -476,6 +483,8 @@ let server = {
             tui.full_refresh();
         } else if (tokens[0] === 'CHAT') {
              tui.log_msg('# ' + tokens[1], 1);
+        } else if (tokens[0] === 'REPLY') {
+             tui.log_msg('#MUSICPLAYER: ' + tokens[1], 1);
         } else if (tokens[0] === 'PLAYER_ID') {
             game.player_id = parseInt(tokens[1]);
         } else if (tokens[0] === 'LOGIN_OK') {
@@ -614,6 +623,7 @@ let tui = {
   mode_portal: new Mode('portal', true, true),
   mode_password: new Mode('password', true),
   mode_name_thing: new Mode('name_thing', true, true),
+  mode_command_thing: new Mode('command_thing', true),
   mode_admin_enter: new Mode('admin_enter', true),
   mode_admin: new Mode('admin'),
   mode_control_pw_pw: new Mode('control_pw_pw', true),
@@ -625,13 +635,15 @@ let tui = {
       'drop_thing': 'DROP',
       'move': 'MOVE',
       'door': 'DOOR',
+      'command': 'COMMAND',
       'consume': 'INTOXICATE',
   },
   offset: [0,0],
   map_lines: [],
   init: function() {
       this.mode_chat.available_modes = ["play", "study", "edit", "admin_enter"]
-      this.mode_play.available_modes = ["chat", "study", "edit", "admin_enter"]
+      this.mode_play.available_modes = ["chat", "study", "edit", "admin_enter",
+                                        "command_thing"]
       this.mode_play.available_actions = ["move", "take_thing", "drop_thing",
                                           "teleport", "door", "consume"];
       this.mode_study.available_modes = ["chat", "play", "admin_enter", "edit"]
@@ -764,6 +776,8 @@ let tui = {
         }
     } else if (this.mode.is_single_char_entry) {
         this.show_help = true;
+    } else if (this.mode.name == 'command_thing') {
+        server.send(['TASK:COMMAND', 'HELP']);
     } else if (this.mode.name == 'admin_enter') {
         this.log_msg('@ enter admin password:')
     } else if (this.mode.name == 'control_pw_type') {
@@ -1324,6 +1338,14 @@ tui.inputEl.addEventListener('keydown', (event) => {
         tui.login_name = tui.inputEl.value;
         server.send(['LOGIN', tui.inputEl.value]);
         tui.inputEl.value = "";
+    } else if (tui.mode.name == 'command_thing' && event.key == 'Enter') {
+        if (tui.inputEl.value.length == 0) {
+            tui.log_msg('@ aborted');
+            tui.switch_mode('play');
+        } else if (tui.task_action_on('command')) {
+            server.send(['TASK:COMMAND', tui.inputEl.value]);
+            tui.inputEl.value = "";
+        }
     } else if (tui.mode.name == 'control_pw_pw' && event.key == 'Enter') {
         if (tui.inputEl.value.length == 0) {
             tui.log_msg('@ aborted');