X-Git-Url: https://plomlompom.com/repos/%7B%7Bdb.prefix%7D%7D/task?a=blobdiff_plain;f=game_common.py;h=c0fb98b3fa9138a5766c3b6be70d47b12ad28240;hb=23462b9ad5f46f8dd323aed66e557235802e3c98;hp=599e54bcda4c51b936b9dac9ac1d90b03debd8af;hpb=2b91efc835f8e68c97830d13d1e3070fdbcf1cc5;p=plomrogue2-experiments diff --git a/game_common.py b/game_common.py index 599e54b..c0fb98b 100644 --- a/game_common.py +++ b/game_common.py @@ -54,13 +54,15 @@ class World: self.turn = 0 self.things = [] - def get_thing(self, id_): + def get_thing(self, id_, create_unfound=True): for thing in self.things: if id_ == thing.id_: return thing - t = self.Thing(self, id_) - self.things += [t] - return t + if create_unfound: + t = self.Thing(self, id_) + self.things += [t] + return t + return None def new_map(self, geometry, yx): map_type = self.game.map_manager.get_map_class(geometry) @@ -80,12 +82,8 @@ class CommonCommandsMixin: def cmd_MAP(self, geometry, yx): """Create new map of grid geometry, size yx and only '?' cells.""" - legal_grids = self.map_manager.get_map_geometries() - if geometry not in legal_grids: - raise ArgError('First map argument must be one of: ' + - ', '.join(legal_grids)) self.world.new_map(geometry, yx) - cmd_MAP.argtypes = 'string yx_tuple:nonneg' + cmd_MAP.argtypes = 'string:geometry yx_tuple:pos' def cmd_THING_TYPE(self, i, type_): t = self.world.get_thing(i)