home · contact · privacy
Exclude non-portable things from pick_up selection.
authorChristian Heller <c.heller@plomlompom.de>
Mon, 7 Dec 2020 01:59:16 +0000 (02:59 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Mon, 7 Dec 2020 01:59:16 +0000 (02:59 +0100)
plomrogue/game.py
rogue_chat.html
rogue_chat_curses.py

index cd1ce2ea8ee5e3c947e10075acb2a0e39ae64969..7d4103da3d793078d65554607a259b15ba31b7f1 100755 (executable)
@@ -231,8 +231,10 @@ class Game(GameBase):
             self.io.send('MAP_CONTROL %s' % quote(visible_control), c_id)
             for t in [t for t in self.things if player.fov_test(*t.position)]:
                 target_yx = player.fov_stencil.target_yx(*t.position)
-                self.io.send('THING %s %s %s %s' % (target_yx, t.type_,
-                                                    quote(t.protection), t.id_), c_id)
+                self.io.send('THING %s %s %s %s %s' % (target_yx, t.type_,
+                                                       quote(t.protection),
+                                                       t.id_, int(t.portable)),
+                             c_id)
                 if hasattr(t, 'name'):
                     self.io.send('THING_NAME %s %s' % (t.id_, quote(t.name)), c_id)
                 if hasattr(t, 'thing_char'):
index 41cf365c0a5f88fe71dad7977a1e1e6aa12f4d03..f0f2faa1213ac1786ca59eaaafeb4f4eac9467e9 100644 (file)
@@ -474,6 +474,7 @@ let server = {
             t.position = parser.parse_yx(tokens[1]);
             t.type_ = tokens[2];
             t.protection = tokens[3];
+            t.portable = parseInt(tokens[5]);
         } else if (tokens[0] === 'THING_NAME') {
             let t = game.get_thing(tokens[1], false);
             if (t) {
@@ -809,7 +810,7 @@ let tui = {
     } else if (this.mode.is_single_char_entry) {
         this.show_help = true;
     } else if (this.mode.name == 'take_thing') {
-        this.log_msg("Things in reach for pick-up:");
+        this.log_msg("Portable things in reach for pick-up:");
         const player = game.things[game.player_id];
         const y = player.position[0]
         const x = player.position[1]
@@ -832,7 +833,7 @@ let tui = {
             const t = game.things[t_id];
             if (select_range.includes(t.position[0].toString()
                                       + ':' + t.position[1].toString())
-                && t != player && t.type_ != 'Player') {
+                && t.portable) {
                 this.selectables.push([t_id, t]);
             }
         };
index c539062bcfe19db3e5d2fef294d7c220c2222eb9..e6ddda87a20f62e71d64974dba56ad82d1e1653c 100755 (executable)
@@ -194,7 +194,7 @@ def cmd_PLAYER_ID(game, player_id):
     game.player_id = player_id
 cmd_PLAYER_ID.argtypes = 'int:nonneg'
 
-def cmd_THING(game, yx, thing_type, protection, thing_id):
+def cmd_THING(game, yx, thing_type, protection, thing_id, portable):
     t = game.get_thing(thing_id)
     if not t:
         t = ThingBase(game, thing_id)
@@ -202,7 +202,8 @@ def cmd_THING(game, yx, thing_type, protection, thing_id):
     t.position = yx
     t.type_ = thing_type
     t.protection = protection
-cmd_THING.argtypes = 'yx_tuple:nonneg string:thing_type char int:nonneg'
+    t.portable = portable
+cmd_THING.argtypes = 'yx_tuple:nonneg string:thing_type char int:nonneg bool'
 
 def cmd_THING_NAME(game, thing_id, name):
     t = game.get_thing(thing_id)
@@ -630,7 +631,7 @@ class TUI:
             else:
                 self.log_msg('@ enter username')
         elif self.mode.name == 'take_thing':
-            self.log_msg('Things in reach for pick-up:')
+            self.log_msg('Portable things in reach for pick-up:')
             player = self.game.get_thing(self.game.player_id)
             select_range = [player.position,
                             player.position + YX(0,-1),
@@ -645,8 +646,7 @@ class TUI:
                     select_range += [player.position + YX(-1, -1),
                                      player.position + YX(1, -1)]
             self.selectables = [t for t in self.game.things
-                                if t != player and t.type_ != 'Player'
-                                and t.position in select_range]
+                                if t.portable and t.position in select_range]
             if len(self.selectables) == 0:
                 self.log_msg('none')
             else: