+def cmd_THING_DESIGN(game, design, pw, connection_id):
+ player = game.get_player(connection_id)
+ if not player:
+ raise GameError('need to be logged in for this')
+ if not player.carrying:
+ raise GameError('need to carry a thing to re-draw it')
+ if not game.can_do_thing_with_pw(player.carrying, pw):
+ raise GameError('wrong password for thing')
+ if not hasattr(player.carrying, 'design'):
+ raise GameError('carried thing not designable')
+ size = player.carrying.design_size
+ if len(design) != size.y * size.x:
+ raise GameError('design for carried thing of wrong length')
+ player.carrying.design = design
+ game.changed = True
+ game.record_change(player.carrying.position, 'other')
+cmd_THING_DESIGN.argtypes = 'string string'
+
+def cmd_GOD_THING_DESIGN(game, thing_id, design):
+ t = game.get_thing(thing_id)
+ if not t:
+ raise GameError('thing of ID %s not found' % thing_id)
+ if not hasattr(t, 'design'):
+ raise GameError('thing of ID %s not designable' % thing_id)
+ if len(design) != t.design_size.y * t.design_size.x:
+ raise GameError('design for thing of ID %s of wrong length' % thing_id)
+ t.design = design
+cmd_GOD_THING_DESIGN.argtypes = 'int:pos string'
+
+# TODO: refactor similar god and player commands
+