From 7f83687be6811d718ca1c3c4197200e177f455ea Mon Sep 17 00:00:00 2001 From: Joe Anderson Date: Thu, 18 Feb 2016 10:07:40 -0800 Subject: corrected fixed behavior in toroidal mode --- oo.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/oo.py b/oo.py index 2ca90d7..661fc1a 100644 --- a/oo.py +++ b/oo.py @@ -492,6 +492,16 @@ class ooPlay: "┝┯┥┷", "┿┿┿┿"] + def is_fixed(self, x, y): + x %= self.puzzle.X + y %= self.puzzle.Y + return self.fixed[x, y] + + def toggle_fixed(self, x, y): + x %= self.puzzle.X + y %= self.puzzle.Y + self.fixed[x, y] = not self.fixed[x, y] + def display_subroutine(self, x, y, recursing=False, cursor=None): """Update one position on the board.""" #TODO: use inverted_pieces and not_inverted_pieces @@ -501,10 +511,10 @@ class ooPlay: is_error = False if self.show_errors: is_error = not self.puzzle.check_piece(x, y) - color_val = (1*(x + y) % 2 + - 2*is_error + - 4*bool(cursor) + - 8*self.fixed[x, y]) + color_val = (1*(x + y) % 2 + + 2*is_error + + 4*bool(cursor) + + 8*self.is_fixed(x, y)) color = curses.color_pair(color_val) self.screen.addstr(y, x, string, color) if self.puzzle.toroidal and not recursing: @@ -637,7 +647,7 @@ class ooPlay: # parse character input if 0 < inp < 256: inp = chr(inp) - if inp in " \n" and not self.fixed[self.xpos, self.ypos]: + if inp in " \n" and not self.is_fixed(self.xpos, self.ypos): self.puzzle.rotate_cw(self.xpos, self.ypos) self.display_pos(self.xpos, self.ypos) if self.puzzle.is_solved(): @@ -684,7 +694,7 @@ class ooPlay: self.extra_hard = not self.extra_hard self.write() elif inp in "Ff": - self.fixed[self.xpos, self.ypos] ^= True + self.toggle_fixed(self.xpos, self.ypos) self.display_pos(self.xpos, self.ypos) # parse arrow/vi key input for motion -- cgit v1.2.3-70-g09d2