summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoe Anderson <jandew+dev@gmail.com>2016-02-17 06:07:16 -0800
committerJoe Anderson <jandew+dev@gmail.com>2016-02-17 06:07:16 -0800
commit67c34028c5c8bf296611cb9dbc587cd98d451c2a (patch)
tree74d80feeb674a1220a57ac5c31761eb8547077ae
parent654226a79816c0401e0d9bfffe7ffcb593b0c6fa (diff)
downloadoo-67c34028c5c8bf296611cb9dbc587cd98d451c2a.tar.gz
oo-67c34028c5c8bf296611cb9dbc587cd98d451c2a.zip
added extra hard mode, fixed toroidal motion
-rw-r--r--oo.py57
1 files changed, 43 insertions, 14 deletions
diff --git a/oo.py b/oo.py
index 287b4a1..92213bf 100644
--- a/oo.py
+++ b/oo.py
@@ -407,8 +407,9 @@ class ooPlay:
# initialize flags
self.help_ind = 0
self.show_errors = False
- self.toroidal = False
self.inverted = False
+ self.toroidal = False
+ self.extra_hard = False
# draw the board state and help area
self.screen.clear()
@@ -438,6 +439,14 @@ class ooPlay:
X = self.X
Y = self.Y - 2
self.puzzle = ooPuzzle(X, Y, toroidal = self.toroidal)
+ if self.extra_hard:
+ while True:
+ for piece in self.puzzle.pieces.values():
+ if piece in [0, 5]:
+ break
+ else:
+ break
+ self.puzzle.set_pieces_from_game_id()
self.puzzle.random_orients()
# draw the board state and help area
@@ -462,8 +471,6 @@ class ooPlay:
"""Update one position on the board."""
#TODO: use inverted_pieces and not_inverted_pieces
# if self.inverted
- #TODO: quadruple the display of the puzzle
- # if self.puzzle.toroidal
piece, orient = self.puzzle.get_piece_orient(x, y)
string = self.PIECE_ORIENT_TO_STRING[piece][orient]
is_error = False
@@ -504,7 +511,7 @@ class ooPlay:
if string is wider than line:
scrolls through string
- if a string is not given, then "h" is used
+ if a string is not given, then "H" is used
if pause is True, there will be a pause for reading
if pause is not given but a string is, there will be a pause
if neither a pause nor a string is given, there will not be a pause
@@ -559,6 +566,7 @@ class ooPlay:
self.write("s: toggle show errors")
self.write("t: toggle toroidal mode")
self.write("i: toggle inverted mode")
+ self.write("x: toggle extra hard mode")
self.write("The next help is game explanation.")
self.write()
@@ -573,6 +581,8 @@ class ooPlay:
self.write("If game is toroidal," +
" the borders loop back" +
" and may connect to the opposite side.")
+ self.write("If game is extra hard," +
+ " then no completely (un)filled pieces are used.")
self.write("The next help is on controls.")
self.write()
@@ -622,8 +632,6 @@ class ooPlay:
self.display()
self.write()
#TODO: add in show solution, with undo option
- #TODO: add in "Xx" for extra hard mode
- # which has no blank or full pieces
elif inp in "Ii":
self.write("Puzzle is now"
+ " NOT"*self.inverted
@@ -637,16 +645,37 @@ class ooPlay:
+ " be toroidal.")
self.toroidal = not self.toroidal
self.write()
+ elif inp in "Xx":
+ self.write("Next new game will"
+ + " NOT"*self.extra_hard
+ + " be extra hard.")
+ self.extra_hard = not self.extra_hard
+ self.write()
# parse arrow/vi key input for motion
- if inp in [curses.KEY_UP, "k"] and self.ypos > 0:
- self.ypos -= 1
- elif inp in [curses.KEY_DOWN, "j"] and self.ypos < self.max_ypos:
- self.ypos += 1
- elif inp in [curses.KEY_LEFT, "h"] and self.xpos > 0:
- self.xpos -= 1
- elif inp in [curses.KEY_RIGHT, "l"] and self.xpos < self.max_xpos:
- self.xpos += 1
+ if inp in [curses.KEY_UP, "k"]:
+ if self.toroidal:
+ self.ypos = (self.ypos - 1) % (self.max_ypos + 1)
+ elif self.ypos > 0:
+ self.ypos -= 1
+
+ elif inp in [curses.KEY_DOWN, "j"]:
+ if self.toroidal:
+ self.ypos = (self.ypos + 1) % (self.max_ypos + 1)
+ elif self.ypos < self.max_ypos:
+ self.ypos += 1
+
+ elif inp in [curses.KEY_LEFT, "h"]:
+ if self.toroidal:
+ self.xpos = (self.xpos - 1) % (self.max_xpos + 1)
+ elif self.xpos > 0:
+ self.xpos -= 1
+
+ elif inp in [curses.KEY_RIGHT, "l"]:
+ if self.toroidal:
+ self.xpos = (self.xpos + 1) % (self.max_xpos + 1)
+ elif self.xpos < self.max_xpos:
+ self.xpos += 1
def main():
curses.wrapper(ooPlay)