+
+def cmd_THING(game, yx, thing_type, thing_id):
+ if not thing_type in game.thing_types:
+ raise GameError('illegal thing type %s' % thing_type)
+ if yx.y < 0 or yx.x < 0 or yx.y >= game.map.size.y or yx.x >= game.map.size.x:
+ raise GameError('illegal position %s' % yx)
+ t_old = None
+ if thing_id > 0:
+ t_old = game.get_thing(thing_id)
+ t_new = game.thing_types[thing_type](game, id_=thing_id, position=yx)
+ if t_old:
+ game.things[game.things.index(t_old)] = t_new
+ else:
+ game.things += [t_new]
+ game.changed = True
+cmd_THING.argtypes = 'yx_tuple:nonneg string:thing_type int:nonneg'