diff options
author | Joe Anderson <jandew+dev@gmail.com> | 2016-02-16 06:50:58 -0800 |
---|---|---|
committer | Joe Anderson <jandew+dev@gmail.com> | 2016-02-16 06:50:58 -0800 |
commit | 94af92116aad2178699a95c02da793332a22981a (patch) | |
tree | d5399b06f3e7a0da9421594c8af09d1a3a055769 /oo.py | |
parent | feff6225011c1401d8391a313229d641ea295620 (diff) | |
download | oo-94af92116aad2178699a95c02da793332a22981a.tar.gz oo-94af92116aad2178699a95c02da793332a22981a.zip |
make conditional readable, add vi movement
Diffstat (limited to 'oo.py')
-rw-r--r-- | oo.py | 24 |
1 files changed, 14 insertions, 10 deletions
@@ -195,10 +195,8 @@ class ooPuzzle: l_edge = self.PIECE_ORIENT_TO_EDGES[l_piece, l_orient][2] r_edge = self.PIECE_ORIENT_TO_EDGES[r_piece, r_orient][0] if not self.toroidal and x1 == 0: - if l_edge or r_edge: return False - else: - if l_edge != r_edge: return False - return True + return not l_edge and not r_edge + return l_edge == r_edge def check_down(self, x, y0): """Check the vertical edge pair below (x, y0).""" @@ -210,10 +208,8 @@ class ooPuzzle: u_edge = self.PIECE_ORIENT_TO_EDGES[u_piece, u_orient][3] d_edge = self.PIECE_ORIENT_TO_EDGES[d_piece, d_orient][1] if not self.toroidal and y1 == 0: - if u_edge or d_edge: return False - else: - if u_edge != d_edge: return False - return True + return not u_edge and not d_edge + return u_edge == d_edge def is_solved(self): """Check whether the puzzle is in a solved state.""" @@ -296,7 +292,7 @@ class ooPlay: ooPlay.pause_length is the number of milliseconds per character to pause """ if string == None: - string = "h" + string = "H" if pause == None: pause = False if pause == None: @@ -393,7 +389,7 @@ class ooPlay: self.puzzle.random_orients() self.display() self.write() - elif inp in "Hh": + elif inp in "H": self.write_help() elif inp in "Ii": self.write("Inverted mode is not implemented.") @@ -401,6 +397,14 @@ class ooPlay: elif inp in "Tt": self.write("Toroidal mode is not implemented.") self.write() + elif inp in "k" and self.ypos > 0: + self.ypos -= 1 + elif inp in "j" and self.ypos < self.puzzle.Y - 1: + self.ypos += 1 + elif inp in "h" and self.xpos > 0: + self.xpos -= 1 + elif inp in "l" and self.xpos < self.puzzle.X - 1: + self.xpos += 1 # parse arrow key input elif inp == curses.KEY_UP and self.ypos > 0: |