summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Anderson <jandew+dev@gmail.com>2016-02-18 10:07:40 -0800
committerJoe Anderson <jandew+dev@gmail.com>2016-02-18 10:10:36 -0800
commit7f83687be6811d718ca1c3c4197200e177f455ea (patch)
tree585ba24890bd44d17006ca3941d9d1d9bf8a16cf
parentcc516b0cb7eace6731e3aa4a785858ae0135d9c4 (diff)
downloadoo-7f83687be6811d718ca1c3c4197200e177f455ea.tar.gz
oo-7f83687be6811d718ca1c3c4197200e177f455ea.zip
corrected fixed behavior in toroidal mode
-rw-r--r--oo.py22
1 files 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