From: Christian Heller Date: Sun, 27 Dec 2020 03:34:31 +0000 (+0100) Subject: Add alternate map control preset. X-Git-Url: https://plomlompom.com/repos/test?a=commitdiff_plain;h=7f7742ecc229f9f6b5ab5c28daf11ea2a67ad29a;p=plomrogue2 Add alternate map control preset. --- diff --git a/plomrogue/commands.py b/plomrogue/commands.py index ec31b12..909d5be 100644 --- a/plomrogue/commands.py +++ b/plomrogue/commands.py @@ -448,7 +448,7 @@ cmd_THING_CRATE_ITEM.argtypes = 'int:pos int:pos' def cmd_MAP_CONTROL_PRESETS(game, draw_control_presets): game.draw_control_presets = draw_control_presets -cmd_MAP_CONTROL_PRESETS.argtypes = 'bool' +cmd_MAP_CONTROL_PRESETS.argtypes = 'int:nonneg' def cmd_THING_SPAWNPOINT_CREATED(game, spawnpoint_id, timestamp): import datetime diff --git a/plomrogue/game.py b/plomrogue/game.py index 8784007..d51c832 100755 --- a/plomrogue/game.py +++ b/plomrogue/game.py @@ -50,7 +50,14 @@ class SaveableMap(Map): return False return True - def draw_presets(self, alternate_hex=0): + def draw_presets(self, big_yx, type_): + if type_ == 1: + if big_yx.y < 0: + self.terrain = 'X' * self.size_i + elif type_ == 2: + self.draw_presets_grid(big_yx) + + def draw_presets_grid(self, big_yx): old_modified = self.modified if type(self.geometry) == MapGeometrySquare: self.set_line(0, 'X' * self.geometry.size.x) @@ -88,6 +95,7 @@ class SaveableMap(Map): if self.inside(yx): self[yx] = 'X' + alternate_hex = big_yx.y % 2 if alternate_hex: draw_snake(offset + YX(0, 0)) draw_snake(offset + YX((0 + alternate_hex) * distance, @@ -147,7 +155,7 @@ class Game(GameBase): '=': Terrain('=', 'glass', blocks_sound=True, blocks_movement=True), 'T': Terrain('T', 'table', blocks_movement=True), } - self.draw_control_presets = True + self.draw_control_presets = 1 if os.path.exists(self.io.save_file): if not os.path.isfile(self.io.save_file): raise GameError('save file path refers to non-file') @@ -519,7 +527,7 @@ class Game(GameBase): map_geometry_shape = self.get_map_geometry_shape() # must come before MAP, otherwise first get_map uses the default # TODO: refactor into MAP - write(f, 'MAP_CONTROL_PRESETS %s' % int(self.draw_control_presets)) + write(f, 'MAP_CONTROL_PRESETS %s' % self.draw_control_presets) write(f, 'MAP %s %s' % (map_geometry_shape, self.map_geometry.size,)) for terrain in self.terrains.values(): write(f, 'TERRAIN %s %s %s %s %s' % (quote(terrain.character), @@ -616,8 +624,8 @@ class Game(GameBase): maps = self.map_controls if big_yx not in maps: maps[big_yx] = SaveableMap(self.map_geometry) - if self.draw_control_presets and type_ == 'control': - maps[big_yx].draw_presets(big_yx.y % 2) + if type_ == 'control': + maps[big_yx].draw_presets(big_yx, self.draw_control_presets) return maps[big_yx] def new_world(self, map_geometry):