home · contact · privacy
Don't open think taking menu if carrying something.
authorChristian Heller <c.heller@plomlompom.de>
Thu, 10 Dec 2020 23:48:32 +0000 (00:48 +0100)
committerChristian Heller <c.heller@plomlompom.de>
Thu, 10 Dec 2020 23:48:32 +0000 (00:48 +0100)
rogue_chat.html
rogue_chat_curses.py

index 1ba0ff1f6fcf02debf88eaefcc07b2c9e71c3d07..fe78f6b7118571666775d0f15df731ec3b710193 100644 (file)
@@ -763,22 +763,26 @@ let tui = {
       return game.tasks.includes(this.action_tasks[action]);
   },
   switch_mode: function(mode_name) {
+
+    function fail(msg) {
+        tui.log_msg('? ' + msg);
+        terminal.blink_screen();
+        this.switch_mode('play');
+    }
+
     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');
     };
-    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');
+    };
+    if (mode_name == 'drop_thing' && !game.player.carrying) {
+        return fail('not carrying anything droppable');
     }
     if (mode_name == 'admin_enter' && this.is_admin) {
         mode_name = 'admin';
@@ -796,9 +800,7 @@ let tui = {
             }
         }
         if (!thing_id) {
-            terminal.blink_screen();
-            this.log_msg('? not standing over thing');
-            return;
+            return fail('not standing over thing');
         } else {
             this.selected_thing_id = thing_id;
         }
index f10c79650020d615ff2480ff26af0b5a384347ba..f75877aff1af88ca76cdf0e228c58cac01a69f1c 100755 (executable)
@@ -628,21 +628,23 @@ class TUI:
             self.map_mode = 'terrain only'
 
     def switch_mode(self, mode_name):
+
+        def fail(msg):
+            self.log_msg('? ' + msg)
+            self.flash = True
+            self.switch_mode('play')
+
         if self.mode and self.mode.name == 'control_tile_draw':
             self.log_msg('@ finished tile protection drawing.')
         self.tile_draw = False
         if mode_name == 'command_thing' and\
            (not self.game.player.carrying or
             not self.game.player.carrying.commandable):
-            self.log_msg('? not carrying anything commandable')
-            self.flash = True
-            self.switch_mode('play')
-            return
+            return fail('not carrying anything commandable')
+        if mode_name == 'take_thing' and self.game.player.carrying:
+            return fail('already carrying something')
         if mode_name == 'drop_thing' and not self.game.player.carrying:
-            self.log_msg('? not carrying anything droppable')
-            self.flash = True
-            self.switch_mode('play')
-            return
+            return fail('not carrying anything droppable')
         if mode_name == 'admin_enter' and self.is_admin:
             mode_name = 'admin'
         elif mode_name in {'name_thing', 'admin_thing_protect'}:
@@ -653,9 +655,7 @@ class TUI:
                 thing = t
                 break
             if not thing:
-                self.flash = True
-                self.log_msg('? not standing over thing')
-                return
+                return fail('not standing over thing')
             else:
                 self.thing_selected = thing
         self.mode = getattr(self, 'mode_' + mode_name)
@@ -693,10 +693,7 @@ class TUI:
             self.selectables = [t.id_ for t in self.game.things
                                 if t.portable and t.position in select_range]
             if len(self.selectables) == 0:
-                self.log_msg('none')
-                self.flash = True
-                self.switch_mode('play')
-                return
+                return fail('nothing to pick-up')
             else:
                 for i in range(len(self.selectables)):
                     t = self.game.get_thing(self.selectables[i])