home · contact · privacy
Add dancing task/action.
authorChristian Heller <c.heller@plomlompom.de>
Thu, 17 Dec 2020 00:29:30 +0000 (01:29 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Thu, 17 Dec 2020 00:29:30 +0000 (01:29 +0100)
config.json
plomrogue/tasks.py
plomrogue/things.py
rogue_chat.html
rogue_chat.py
rogue_chat_curses.py

index 79537a94deec4490963d60be0332c606744a9ac0..437a4965e1f50fa156b24714225e7ea734735845 100644 (file)
@@ -24,6 +24,7 @@
     "wear": "W",
     "consume": "C",
     "spin": "S",
+    "dance": "T",
     "help": "h",
     "toggle_map_mode": "L",
     "toggle_tile_draw": "m",
index 6f42109362fc7aaf7e2810921e65ffe66d74a3d2..cc375272c1edd941aeafbbb4117a3d30db142d8c 100644 (file)
@@ -374,3 +374,12 @@ class Task_SPIN(Task):
     def do(self):
         self.thing.carrying.spin()
         self.thing.send_msg('CHAT "You spin this object."')
+
+
+
+class Task_DANCE(Task):
+
+    def do(self):
+        self.thing.send_msg('CHAT "You dance."')
+        self.thing.dancing += 10
+        self.thing.game.changed = True
index dbec52f57a329b826d1300642b08c378e3973165..c538a235d8c4a7d301800563022470b3a41638c7 100644 (file)
@@ -678,7 +678,7 @@ class Thing_Player(ThingAnimate):
         if 1000000 * random.random() < self.energy:
             self.send_msg('CHAT "Your body tries to '
                           'dance off its energy surplus."')
-            self.dancing = 50
+            self.dancing += 50
             self.game.changed = True
 
     def send_msg(self, msg):
index 47bf58d3aa4c937dfe5b078a6a161c25349ccd16..6497fa9a1832262b612abf203a9c06cdad0a7dfd 100644 (file)
@@ -54,6 +54,7 @@ terminal rows: <input id="n_rows" type="number" step=4 min=24 value=24 />
       <button id="switch_to_drop_thing"></button>
       <button id="door"></button>
       <button id="consume"></button>
+      <button id="dance"></button>
       <button id="switch_to_command_thing"></button>
       <button id="teleport"></button>
       <button id="wear"></button>
@@ -101,6 +102,7 @@ terminal rows: <input id="n_rows" type="number" step=4 min=24 value=24 />
 <li>flatten surroundings: <input id="key_flatten" type="text" value="F" />
 <li>teleport: <input id="key_teleport" type="text" value="p" />
 <li>spin: <input id="key_spin" type="text" value="S" />
+<li>dance: <input id="key_dance" type="text" value="T" />
 <li>open/close: <input id="key_door" type="text" value="D" />
 <li>consume: <input id="key_consume" type="text" value="C" />
 <li>install: <input id="key_install" type="text" value="I" />
@@ -262,6 +264,7 @@ let key_descriptions = {
     'install': '(un-)install',
     'wear': '(un-)wear',
     'spin': 'spin',
+    'dance': 'dance',
     'toggle_map_mode': 'toggle map view',
     'toggle_tile_draw': 'toggle protection character drawing',
     'hex_move_upleft': 'up-left',
@@ -724,6 +727,7 @@ let tui = {
       'command': 'COMMAND',
       'consume': 'INTOXICATE',
       'spin': 'SPIN',
+      'dance': 'DANCE',
   },
   offset: [0,0],
   map_lines: [],
@@ -735,7 +739,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",
-                                          "wear", "spin"];
+                                          "wear", "spin", "dance"];
       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",
@@ -1686,6 +1690,8 @@ tui.inputEl.addEventListener('keydown', (event) => {
               server.send(["TASK:WEAR"]);
           } else if (event.key === tui.keys.spin && tui.task_action_on('spin')) {
               server.send(["TASK:SPIN"]);
+          } else if (event.key === tui.keys.dance && tui.task_action_on('dance')) {
+              server.send(["TASK:DANCE"]);
           } else if (event.key in tui.movement_keys && tui.task_action_on('move')) {
               server.send(['TASK:MOVE', tui.movement_keys[event.key]]);
           } else if (event.key === tui.keys.teleport) {
@@ -1798,8 +1804,8 @@ document.getElementById("install").onclick = function() {
 document.getElementById("wear").onclick = function() {
     server.send(['TASK:WEAR']);
 };
-document.getElementById("spin").onclick = function() {
-    server.send(['TASK:SPIN']);
+document.getElementById("dance").onclick = function() {
+    server.send(['TASK:DANCE']);
 };
 document.getElementById("teleport").onclick = function() {
     game.teleport();
index cc6421f0384d48e7d6062c78836c51bfe72dabbf..1fe4c91abff816b1ed2cc3e68898ba6d996b0b34 100755 (executable)
@@ -20,7 +20,7 @@ from plomrogue.commands import (cmd_ALL, cmd_LOGIN, cmd_NICK, cmd_PING, cmd_THIN
 from plomrogue.tasks import (Task_WAIT, Task_MOVE, Task_WRITE, Task_PICK_UP,
                              Task_DROP, Task_FLATTEN_SURROUNDINGS, Task_DOOR,
                              Task_INTOXICATE, Task_COMMAND, Task_INSTALL,
-                             Task_WEAR, Task_SPIN)
+                             Task_WEAR, Task_SPIN, Task_DANCE)
 from plomrogue.things import (Thing_Player, Thing_Item, Thing_ItemSpawner,
                               Thing_SpawnPoint, Thing_SpawnPointSpawner,
                               Thing_Door, Thing_DoorSpawner, Thing_Bottle,
@@ -86,6 +86,7 @@ game.register_task(Task_COMMAND)
 game.register_task(Task_INSTALL)
 game.register_task(Task_WEAR)
 game.register_task(Task_SPIN)
+game.register_task(Task_DANCE)
 game.register_thing_type(Thing_Player)
 game.register_thing_type(Thing_Item)
 game.register_thing_type(Thing_ItemSpawner)
index f0ec6633ca6591da4d954a90b8321de7f2eca9a9..a58b842e70a46154341ea003f904d333f10b5972 100755 (executable)
@@ -512,7 +512,7 @@ class TUI:
                                           "command_thing", "take_thing",
                                           "drop_thing"]
         self.mode_play.available_actions = ["move", "teleport", "door", "consume",
-                                            "install", "wear", "spin"]
+                                            "install", "wear", "spin", "dance"]
         self.mode_study.available_modes = ["chat", "play", "admin_enter", "edit"]
         self.mode_study.available_actions = ["toggle_map_mode", "move_explorer"]
         self.mode_admin.available_modes = ["admin_thing_protect", "control_pw_type",
@@ -566,6 +566,7 @@ class TUI:
             'install': 'I',
             'wear': 'W',
             'spin': 'S',
+            'dance': 'T',
             'help': 'h',
             'toggle_map_mode': 'L',
             'toggle_tile_draw': 'm',
@@ -1144,6 +1145,7 @@ class TUI:
             'door': 'open/close',
             'consume': 'consume',
             'spin': 'spin',
+            'dance': 'dance',
         }
 
         action_tasks = {
@@ -1157,6 +1159,7 @@ class TUI:
             'command': 'COMMAND',
             'consume': 'INTOXICATE',
             'spin': 'SPIN',
+            'dance': 'DANCE',
         }
 
         curses.curs_set(False)  # hide cursor
@@ -1329,6 +1332,8 @@ class TUI:
                     self.send('TASK:WEAR')
                 elif key == self.keys['spin'] and task_action_on('spin'):
                     self.send('TASK:SPIN')
+                elif key == self.keys['dance'] and task_action_on('dance'):
+                    self.send('TASK:DANCE')
                 elif key == self.keys['teleport']:
                     if self.game.player.position in self.game.portals:
                         self.host = self.game.portals[self.game.player.position]