From 0ae5c165fbce33fcdc60f92cceb18109124aabde Mon Sep 17 00:00:00 2001
From: Christian Heller <c.heller@plomlompom.de>
Date: Sun, 13 Dec 2020 05:31:33 +0100
Subject: [PATCH] Don't enter enter_hat menu in client if not wearing hat.

---
 rogue_chat.html      | 12 ++++++------
 rogue_chat_curses.py |  2 ++
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/rogue_chat.html b/rogue_chat.html
index 4285ded..26322e9 100644
--- a/rogue_chat.html
+++ b/rogue_chat.html
@@ -794,15 +794,15 @@ let tui = {
     }
     this.draw_face = false;
     this.tile_draw = false;
-      if (mode_name == 'command_thing' && (!game.player.carrying
-                                           || !game.player.carrying.commandable)) {
+    if (mode_name == 'command_thing' && (!game.player.carrying
+                                         || !game.player.carrying.commandable)) {
         return fail('not carrying anything commandable', 'play');
-    };
-    if (mode_name == 'take_thing' && game.player.carrying) {
+    } else if (mode_name == 'take_thing' && game.player.carrying) {
         return fail('already carrying something', 'play');
-    };
-    if (mode_name == 'drop_thing' && !game.player.carrying) {
+    } else if (mode_name == 'drop_thing' && !game.player.carrying) {
         return fail('not carrying anything droppable', 'play');
+    } else if (mode_name == 'enter_hat' && !game.player.hat) {
+        return fail('not wearing hat to edit', 'edit');
     }
     if (mode_name == 'admin_enter' && this.is_admin) {
         mode_name = 'admin';
diff --git a/rogue_chat_curses.py b/rogue_chat_curses.py
index e9f7f6b..9519a95 100755
--- a/rogue_chat_curses.py
+++ b/rogue_chat_curses.py
@@ -686,6 +686,8 @@ class TUI:
             return fail('already carrying something')
         if mode_name == 'drop_thing' and not self.game.player.carrying:
             return fail('not carrying anything droppable')
+        if mode_name == 'enter_hat' and not hasattr(self.game.player, 'hat'):
+            return fail('not wearing hat to edit', 'edit')
         if mode_name == 'admin_enter' and self.is_admin:
             mode_name = 'admin'
         elif mode_name in {'name_thing', 'admin_thing_protect'}:
-- 
2.30.2