Esempio n. 1
0
    def jumpUp(self, board, direction):
        ox = self._x
        oendx = self._endx
        oy = self._y
        oendy = self._endy
        self._x -= 1
        self._endx -= 1
        jumpPossible = True

        if self.timeSinceLastJump > 10:
            self.jumpCounter = 0
        else:
            if(self.jumpCounter > 2 * self.jump):
                jumpPossible = False

        if move_maadi(self, board, direction) and (jumpPossible):
            board._bufferboard[ox:oendx, oy:oendy] = ""
            board._bufferboard[self._x:self._endx,
                               self._y:self._endy] = self.struct
            self.timeSinceLastJump = 0
            self.jumpCounter += 1
        else:
            self._x = ox
            self._endx = oendx
            self._y = oy
            self._endy = oendy
Esempio n. 2
0
    def jump_up(self, board, direction):
        """ Function to jump """
        orignal_x = self.x_pos
        oendx = self.endx
        orignal_y = self.y_pos
        oendy = self.endy
        self.x_pos -= 1
        self.endx -= 1
        jump_possible = True

        if self.time_since_last_jump > 10:
            self.jump_counter = 0
        else:
            if self.jump_counter > 2 * self.jump:
                jump_possible = False
        return_value_move = move_maadi(self, board, direction)
        if return_value_move == 1 and jump_possible:
            board.bufferboard[orignal_x:oendx, orignal_y:oendy] = ""
            board.bufferboard[self.x_pos:self.endx,
                              self.y_pos:self.endy] = self.struct
            self.time_since_last_jump = 0
            self.jump_counter += 1
            return True
        elif return_value_move == 0 or not jump_possible:
            self.x_pos = orignal_x
            self.endx = oendx
            self.y_pos = orignal_y
            self.endy = oendy
            return False
Esempio n. 3
0
 def moveLeft(self, board, direction='a'):
     ox = self._x
     oendx = self._endx
     oy = self._y
     oendy = self._endy
     self._y -= 1
     self._endy -= 1
     if move_maadi(self, board, direction) == True:
         board._bufferboard[ox:oendx, oy:oendy] = ""
         board._bufferboard[self._x:self._endx,
                            self._y:self._endy] = self.struct
         return True
     else:
         self._x = ox
         self._endx = oendx
         self._y = oy
         self._endy = oendy
         return False
Esempio n. 4
0
 def move_right(self, board, direction='d'):
     """ Function to move right """
     orignal_x = self.x_pos
     oendx = self.endx
     orignal_y = self.y_pos
     oendy = self.endy
     self.y_pos += 1
     self.endy += 1
     return_value_move = move_maadi(self, board, direction)
     if return_value_move == 1:
         board.bufferboard[orignal_x:oendx, orignal_y:oendy] = ""
         board.bufferboard[self.x_pos:self.endx,
                           self.y_pos:self.endy] = self.struct
         return True
     elif return_value_move == 0:
         self.x_pos = orignal_x
         self.endx = oendx
         self.y_pos = orignal_y
         self.endy = oendy
         return False