diff options
-rw-r--r-- | oo.py | 22 |
1 files changed, 16 insertions, 6 deletions
@@ -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 |