home · contact · privacy
Enable Hat editing with characters earned by eating cookies from a CookieSpawner.
[plomrogue2] / plomrogue / commands.py
index df4b7e204a26b353c8e46db71281e7b9d345717e..aed5830b5d64c6ea1615fdb57210f8229b3ab50d 100644 (file)
@@ -347,6 +347,26 @@ def cmd_PLAYER_FACE(game, face, connection_id):
     game.record_fov_change(t.position)
 cmd_PLAYER_FACE.argtypes = 'string'
 
+def cmd_PLAYER_HAT(game, hat, connection_id):
+    t = game.get_player(connection_id)
+    if not t:
+        raise GameError('can only edit hat when already logged in')
+    if not t.name in game.hats:
+        raise GameError('not currently wearing an editable hat')
+    if len(hat) != 18:
+        raise GameError('wrong hat string length')
+    legal_chars = t.get_cookie_chars()
+    for c in hat:
+        if c not in legal_chars:
+            raise GameError('used illegal character: "%s" – '
+                            'allowed characters: %s'
+                            % (c, legal_chars))
+    game.hats[t.name] = hat
+    game.changed = True
+    # FIXME: pseudo-FOV-change actually
+    game.record_fov_change(t.position)
+cmd_PLAYER_HAT.argtypes = 'string'
+
 def cmd_GOD_PLAYER_FACE(game, name, face):
     if len(face) != 18:
         raise GameError('wrong face string length')
@@ -359,6 +379,10 @@ def cmd_GOD_PLAYER_HAT(game, name, hat):
     game.hats[name] = hat
 cmd_GOD_PLAYER_HAT.argtypes = 'string string'
 
+def cmd_GOD_PLAYERS_HAT_CHARS(game, name, hat_chars):
+    game.players_hat_chars[name] = hat_chars
+cmd_GOD_PLAYERS_HAT_CHARS.argtypes = 'string string'
+
 def cmd_THING_HAT_DESIGN(game, thing_id, design):
     if len(design) != 18:
         raise GameError('hat design of wrong length')