home
·
contact
·
privacy
projects
/
plomrogue2-experiments
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Minor client help screen improvements.
[plomrogue2-experiments]
/
game_common.py
diff --git
a/game_common.py
b/game_common.py
index 1119ce1b4f8b694a6f8a7f5da6b8686d07434752..7731c61eebe782e8c8e07187e9925a1d20343539 100644
(file)
--- a/
game_common.py
+++ b/
game_common.py
@@
-3,12
+3,9
@@
from parser import ArgError
class MapManager:
class MapManager:
- def __init__(self, globs):
- """With globs a globals() call, collect caller's Map classes."""
- self.map_classes = []
- for name in globs:
- if name[:3] == 'Map':
- self.map_classes += [globs[name]]
+ def __init__(self, map_classes):
+ """Collects tuple of basic Map[Geometry] classes."""
+ self.map_classes = map_classes
def get_map_geometries(self):
geometries = []
def get_map_geometries(self):
geometries = []
@@
-54,13
+51,15
@@
class World:
self.turn = 0
self.things = []
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
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)
def new_map(self, geometry, yx):
map_type = self.game.map_manager.get_map_class(geometry)
@@
-80,12
+79,8
@@
class CommonCommandsMixin:
def cmd_MAP(self, geometry, yx):
"""Create new map of grid geometry, size yx and only '?' cells."""
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)
self.world.new_map(geometry, yx)
- cmd_MAP.argtypes = 'string yx_tuple:pos'
+ cmd_MAP.argtypes = 'string
:geometry
yx_tuple:pos'
def cmd_THING_TYPE(self, i, type_):
t = self.world.get_thing(i)
def cmd_THING_TYPE(self, i, type_):
t = self.world.get_thing(i)