Esempio n. 1
0
 def activate(self, player):
     """
     Method that allows the player leave a crossbomb
     """
     player.has_cross_bomb = True
     pos_i = self.get_x()
     pos_j = self.get_y()
     self.matrix[pos_i][pos_j] = Matrix.Blank((pos_i, pos_j))
Esempio n. 2
0
 def activate(self, player):
     """
     Method that makes the player have a shoe
     """
     player.has_shoe = True
     pos_i = self.get_x()
     pos_j = self.get_y()
     self.matrix[pos_i][pos_j] = Matrix.Blank((pos_i, pos_j))
Esempio n. 3
0
 def activate(self, player):
     """
     Method that makes the player gain a live
     Theres a maximum live stat that limits this value
     """
     if player.lives < 3:
         player.lives += 1
     pos_i = self.get_x()
     pos_j = self.get_y()
     self.matrix[pos_i][pos_j] = Matrix.Blank((pos_i, pos_j))
Esempio n. 4
0
 def activate(self, player):
     """
     Method that makes the player have a shield, this is
     similar to an extra live but just for a certain amount of time
     """
     self.player = player
     self.player.has_shield = True
     self.start()
     pos_i = self.get_x()
     pos_j = self.get_y()
     self.matrix[pos_i][pos_j] = Matrix.Blank((pos_i, pos_j))
Esempio n. 5
0
 def kick_bomb(self, position):
     """
     Auxiliary method for the Shoe power up, changes
     the position of the "kicked" bomb
     """
     pos_i = position[0]
     pos_j = position[1]
     self.matrix[pos_i][pos_j] = Matrix.Blank((pos_i, pos_j))
     new_position_found = False
     # Searches until it founds a Black position to add the bomb
     while not new_position_found:
         pos_i = random.randint(0, Matrix.ROWS - 1)
         pos_j = random.randint(0, Matrix.COLUMNS - 1)
         if isinstance(self.matrix[pos_i][pos_j], Matrix.Blank):
             new_position_found = True
     self.matrix[pos_i][pos_j] = Bomb.Bomb((pos_i, pos_j), self.matrix,
                                           self.explosion_radius, self)
     self.has_shoe = False
Esempio n. 6
0
 def moving_aux(self, actual_pos, next_pos):
     """
     Auxiliary method for the move_right, move_left, move_up and
     move_down methods
     :param: next_object -> the object located in the position
     where the player is moving
     :param: actual_pos <Tuple> -> contains the player coordinates before the movement
     :param: next_pos <Tuple> -> contains the player coordinates after the movement
     :return: string -> action that the player most follow, the possible
     actions are:
     1) Moved -> the player moves and does nothing else
     2) Breakable -> indicates that the next object is a breakable block
     3) Abort movement -> indicates the player to stop moving
     """
     # Activate  a power up if it follows the movement
     if self.lives == 0:
         return ""
     if isinstance(self.matrix[next_pos[0]][next_pos[1]], PowerUp.PowerUp):
         self.matrix[next_pos[0]][next_pos[1]].activate(self)
     # Do the normal movement when the next position is Blank
     if isinstance(self.matrix[next_pos[0]][next_pos[1]], Matrix.Blank):
         if self.lives == 0:
             return ""
         self.matrix[next_pos[0]][next_pos[1]] = self
         if self.new_bomb and not isinstance(
                 self.matrix[actual_pos[0]][actual_pos[1]], Fire.Fire):
             self.leave_bomb()
         else:
             self.matrix[actual_pos[0]][actual_pos[1]] = Matrix.Blank(
                 actual_pos)
         self.position = next_pos
         return "Moved"
     # Inform if the next position is a Breakbale Block
     elif isinstance(self.matrix[next_pos[0]][next_pos[1]],
                     Block.Breakable):
         return "Breakable"
     # Every other object will kill the movement
     else:
         if isinstance(self.matrix[next_pos[0]][next_pos[1]],
                       Bomb.Bomb) and self.has_shoe:
             self.kick_bomb(next_pos)
         return "Abort movement"