X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=new%2Fexample_client.py;h=bd8bcfd1a8a9667f762e74b22414cb13e860663a;hb=8550ed04290fd6690ac73b3fd15412ce19e32b4d;hp=2a4b80cc6e03fe722033790a310f84e90c830f64;hpb=b7587718cee2308bd2a27462e0996dc279bd3038;p=plomrogue2-experiments diff --git a/new/example_client.py b/new/example_client.py index 2a4b80c..bd8bcfd 100755 --- a/new/example_client.py +++ b/new/example_client.py @@ -33,11 +33,11 @@ class ClientMap(Map): cut_end = cut_start + view_width map_lines[:] = [line[cut_start:cut_end] for line in map_lines] - def format_to_view(self, map_cells, center, size, indent_first_line): + def format_to_view(self, map_cells, center, size): def map_cells_to_lines(map_cells): map_view_chars = [] - if indent_first_line: + if self.start_indented: map_view_chars += ['0'] x = 0 y = 0 @@ -51,9 +51,9 @@ class ClientMap(Map): map_view_chars += ['\n'] x = 0 y += 1 - if y % 2 == int(not indent_first_line): + if y % 2 == int(not self.start_indented): map_view_chars += ['0'] - if y % 2 == int(not indent_first_line): + if y % 2 == int(not self.start_indented): map_view_chars = map_view_chars[:-1] map_view_chars = map_view_chars[:-1] return ''.join(map_view_chars).split('\n') @@ -79,15 +79,16 @@ cmd_TURN_FINISHED.argtypes = 'int:nonneg' def cmd_TURN(game, n): """Set game.turn to n, empty game.things.""" + game.log_text = '' game.turn = n game.things = [] game.pickable_items[:] = [] cmd_TURN.argtypes = 'int:nonneg' -def cmd_VISIBLE_MAP(game, offset, size): - game.new_map(offset, size) -cmd_VISIBLE_MAP.argtypes = 'yx_tuple yx_tuple:pos' +def cmd_VISIBLE_MAP(game, size, indent_first_line): + game.new_map(size, indent_first_line) +cmd_VISIBLE_MAP.argtypes = 'yx_tuple:pos bool' def cmd_VISIBLE_MAP_LINE(game, y, terrain_line): @@ -153,9 +154,8 @@ class Game(GameBase): self.do_quit = False self.tui = None - def new_map(self, offset, size): - self.map_ = ClientMap(size) - self.offset = offset + def new_map(self, size, indent_first_line): + self.map_ = ClientMap(size, start_indented=indent_first_line) @property def player(self): @@ -449,10 +449,8 @@ class MapWidget(Widget): center = self.tui.game.player.position if self.tui.examiner_mode: center = self.tui.examiner_position - indent_first_line = not bool(self.tui.game.offset.y % 2) lines = self.tui.game.map_.\ - format_to_view(annotated_terrain, center, self.size, - indent_first_line) + format_to_view(annotated_terrain, center, self.size) pad_or_cut_x(lines) pad_y(lines) self.safe_write(lines_to_colored_chars(lines)) @@ -557,7 +555,8 @@ class TUI: def move_examiner(direction): start_pos = self.examiner_position new_examine_pos = self.game.map_geometry.move(start_pos, direction, - self.game.map_.size) + self.game.map_.size, + self.game.map_.start_indented) if new_examine_pos[0] == (0,0): self.examiner_position = new_examine_pos self.to_update['map'] = True