X-Git-Url: https://plomlompom.com/repos/?p=plomrogue2-experiments;a=blobdiff_plain;f=new%2Fplomrogue%2Fcommands.py;h=7eecf23b77a7e2fb515674626a99f33f72389855;hp=744d471fac100bc5e326813899d93466a353566e;hb=ecf3799b03f0a9098956d529f26be54f37c6534b;hpb=b7587718cee2308bd2a27462e0996dc279bd3038 diff --git a/new/plomrogue/commands.py b/new/plomrogue/commands.py index 744d471..7eecf23 100644 --- a/new/plomrogue/commands.py +++ b/new/plomrogue/commands.py @@ -18,13 +18,23 @@ def cmd_MAP_SIZE(game, size): game.map_size = size cmd_MAP_SIZE.argtypes = 'yx_tuple:pos' -def cmd_MAP(game, map_pos): - """Ensure (possibly empty/'?'-filled) map at position map_pos.""" - game.get_map(map_pos) -cmd_MAP.argtypes = 'yx_tuple' +def cmd_MAP(game, map_pos, awakeness): + """Ensure (possibly empty/'?'-filled) map at position map_pos. + + Awakeness > 0 puts the map into the player's reality bubble. + + """ + m = game.get_map(map_pos) + m.awake = awakeness +cmd_MAP.argtypes = 'yx_tuple int:nonneg' + +def cmd_MAP_STATS(game, map_pos, type_, population, health): + m = game.get_map(map_pos) + m.stats[type_] = {'population': population, 'health': health} +cmd_MAP_STATS = 'yx_tuple string:thingtype int:nonneg int:nonneg' def cmd_THING_TYPE(game, i, type_): - t_old = game.get_thing(i) + t_old = game.get_thing(i, create_unfound=True) t_new = game.thing_types[type_](game, i) #attr_names_of_old = [name for name in dir(t_old) where name[:2] != '__'] #attr_names_of_new = [name for name in dir(t_new) where name[:2] != '__'] @@ -46,21 +56,21 @@ def cmd_THING_TYPE(game, i, type_): cmd_THING_TYPE.argtypes = 'int:nonneg string:thingtype' def cmd_THING_POS(game, i, big_yx, small_yx): - t = game.get_thing(i) + t = game.get_thing(i, create_unfound=True) t.position = (big_yx, small_yx) cmd_THING_POS.argtypes = 'int:nonneg yx_tuple yx_tuple:nonneg' def cmd_THING_INVENTORY(game, id_, ids): - carrier = game.get_thing(id_) + carrier = game.get_thing(id_, create_unfound=True) carrier.inventory = ids for id_ in ids: - t = game.get_thing(id_) + t = game.get_thing(id_, create_unfound=True) t.in_inventory = True t.position = carrier.position cmd_THING_INVENTORY.argtypes = 'int:nonneg seq:int:nonneg' def cmd_THING_HEALTH(game, id_, health): - t = game.get_thing(id_) + t = game.get_thing(id_, create_unfound=True) t.health = health cmd_THING_HEALTH.argtypes = 'int:nonneg int:nonneg' @@ -106,7 +116,12 @@ def cmd_SAVE(game): write(f, 'SEED %s' % game.rand.prngod_seed) write(f, 'MAP_SIZE %s' % (game.map_size,)) for map_pos in game.maps: - write(f, 'MAP %s' % (map_pos,)) + m = game.maps[map_pos] + write(f, 'MAP %s %s' % (map_pos, m.awake)) + for t_type in m.stats: + write(f, 'MAP_STATS %s %s %s %s' % + (map_pos, t_type, m.stats[t_type]['population'], + m.stats[t_type]['health'])) for map_pos in game.maps: for y, line in game.maps[map_pos].lines(): write(f, 'TERRAIN_LINE %s %5s %s' % (map_pos, y, quote(line)))