home · contact · privacy
Add weariness mechanic.
authorChristian Heller <c.heller@plomlompom.de>
Wed, 16 Dec 2020 20:57:04 +0000 (21:57 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Wed, 16 Dec 2020 20:57:04 +0000 (21:57 +0100)
plomrogue/game.py
plomrogue/things.py
rogue_chat.html
rogue_chat_curses.py

index 1658808eda6d1ae108045961e83a75a2bf25b996..5e6c14433a2a8ea045e4cb090d04ad1fc2be9297 100755 (executable)
@@ -277,7 +277,8 @@ class Game(GameBase):
             player = self.get_player(c_id)
             self.io.send('PLAYERS_HAT_CHARS ' + quote(player.get_cookie_chars()),
                          c_id)
-            self.io.send('BLADDER_PRESSURE %s' % player.need_for_toilet, c_id)
+            self.io.send('STATS %s %s' % (player.need_for_toilet,
+                                          player.weariness), c_id)
             if player.id_ in player_ids_send_fov:
                 self.io.send('FOV %s' % quote(player.fov_stencil.terrain), c_id)
                 self.io.send('MAP %s %s %s' % (self.get_map_geometry_shape(),
index 3686ab0c2a2b78f41e024a5f9c8ef14958fc285d..c8ef346b13a05e831d092f9430d9a93c49a8473e 100644 (file)
@@ -452,6 +452,7 @@ class Thing_CookieSpawner(Thing):
 
 
 class ThingAnimate(Thing):
+    weariness = 0
 
     def __init__(self, *args, **kwargs):
         super().__init__(*args, **kwargs)
@@ -480,6 +481,7 @@ class ThingAnimate(Thing):
             task = self.next_task[0]
             self.next_task = [None]
             task.check()
+            task.todo += self.weariness * 10
             return task
 
     def proceed(self):
@@ -624,6 +626,11 @@ class Thing_Player(ThingAnimate):
         elif self.tripping > 0 and self.tripping % 250 == 0:
             self.send_msg('RANDOM_COLORS')
             self.game.changed = True
+        if random.random() > 0.9999:
+            if self.standing:
+                self.weariness += 1
+            elif self.weariness > 0:
+                self.weariness -= 1
 
     def send_msg(self, msg):
         for c_id in self.game.sessions:
index 291a98c341431c6c6cedf5bce2c966c2a63c30aa..84d481c806218a35570d937cd49e485aacbff054 100644 (file)
@@ -129,8 +129,8 @@ terminal rows: <input id="n_rows" type="number" step=4 min=24 value=24 />
 </div>
 <script>
 "use strict";
-//let websocket_location = "wss://plomlompom.com/rogue_chat/";
-let websocket_location = "ws://localhost:8000/";
+let websocket_location = "wss://plomlompom.com/rogue_chat/";
+//let websocket_location = "ws://localhost:8000/";
 
 let mode_helps = {
     'play': {
@@ -489,8 +489,9 @@ let server = {
             game.portals_new = {};
             explorer.annotations_new = {};
             game.things_new = [];
-        } else if (tokens[0] === 'BLADDER_PRESSURE') {
+        } else if (tokens[0] === 'STATS') {
             game.bladder_pressure_new = parseInt(tokens[1])
+            game.weariness_new = parseInt(tokens[2])
         } else if (tokens[0] === 'THING') {
             let t = game.get_thing_temp(tokens[4], true);
             t.position = parser.parse_yx(tokens[1]);
@@ -548,6 +549,7 @@ let server = {
             game.player = game.things[game.player_id];
             game.players_hat_chars = game.players_hat_chars_new;
             game.bladder_pressure = game.bladder_pressure_new
+            game.weariness = game.weariness_new
             game.turn_complete = true;
             if (tui.mode.name == 'post_login_wait') {
                 tui.switch_mode('play');
@@ -1213,7 +1215,9 @@ let tui = {
       terminal.write(0, this.window_width, 'MODE: ' + this.mode.short_desc + ' – ' + help);
   },
   draw_stats_line: function(n) {
-      terminal.write(1, this.window_width, 'BLADDER: ' + game.bladder_pressure);
+      terminal.write(1, this.window_width,
+                     'WEARINESS: ' + game.weariness +
+                     ' BLADDER: ' + game.bladder_pressure);
   },
   draw_history: function() {
       let log_display_lines = [];
index d4693403fcedf8a6aba64fe3d155ac02715fea88..ec9eee5b276b1373a77588b2cfc01a78e1625545 100755 (executable)
@@ -294,6 +294,7 @@ def cmd_GAME_STATE_COMPLETE(game):
     game.player = game.get_thing(game.player_id)
     game.players_hat_chars = game.players_hat_chars_new
     game.bladder_pressure = game.bladder_pressure_new
+    game.weariness = game.weariness_new
     game.turn_complete = True
     if game.tui.mode.name == 'post_login_wait':
         game.tui.switch_mode('play')
@@ -361,9 +362,10 @@ def cmd_RANDOM_COLORS(game):
     game.tui.set_random_colors()
 cmd_RANDOM_COLORS.argtypes = ''
 
-def cmd_BLADDER_PRESSURE(game, bladder_pressure):
+def cmd_STATS(game, bladder_pressure, weariness):
     game.bladder_pressure_new = bladder_pressure
-cmd_BLADDER_PRESSURE.argtypes = 'int:nonneg'
+    game.weariness_new = weariness
+cmd_STATS.argtypes = 'int:nonneg int:nonneg'
 
 class Game(GameBase):
     turn_complete = False
@@ -404,7 +406,7 @@ class Game(GameBase):
         self.register_command(cmd_FOV)
         self.register_command(cmd_DEFAULT_COLORS)
         self.register_command(cmd_RANDOM_COLORS)
-        self.register_command(cmd_BLADDER_PRESSURE)
+        self.register_command(cmd_STATS)
         self.map_content = ''
         self.players_hat_chars = ''
         self.player_id = -1
@@ -414,8 +416,6 @@ class Game(GameBase):
         self.portals_new = {}
         self.terrains = {}
         self.player = None
-        self.bladder_pressure_new = 0
-        self.bladder_pressure = 0
 
     def get_string_options(self, string_option_type):
         if string_option_type == 'map_geometry':
@@ -944,7 +944,9 @@ class TUI:
                 y += 1
 
         def draw_stats():
-            safe_addstr(0, self.window_width, 'BLADDER: ' + str(self.game.bladder_pressure))
+            stats = 'WEARY: %s BLADDER: %s' % (self.game.weariness,
+                                               self.game.bladder_pressure)
+            safe_addstr(0, self.window_width, stats)
 
         def draw_mode():
             help = "hit [%s] for help" % self.keys['help']