Пример #1
0
 def test_kills_ghost(self):
     self.ghosts_list.append(self.ghost_1)
     bomb = Bomb.Bomb(self.screen, 50, 50, 3, 2)
     while not bomb.explosion(self.ghosts_list,
                              self.player.get_player_position_on_map(),
                              self.player.reduce_health_by_one):
         pass
     self.assertNotEqual(len(self.ghosts_list), 3)
Пример #2
0
 def test_reduces_player_hp(self):
     temp = [self.player.health]
     bomb = Bomb.Bomb(self.screen, 50, 50, 3, 2)
     while not self.bomb.explosion(self.ghosts_list,
                                   self.player.get_player_position_on_map(),
                                   self.player.reduce_health_by_one):
         pass
     self.assertEqual(self.player.health, temp[0])
Пример #3
0
    def test_remove_block_true(self):
        self.ghosts_list = []
        self.ghosts_list.clear()
        self.ghosts_list.append(self.ghost_1)

        init.generate_map(init.game_map)
        bomb = Bomb.Bomb(self.screen, 150, 100, 10, 10)

        while not bomb.explosion(self.ghosts_list,
                                 self.player.get_player_position_on_map(),
                                 self.player.reduce_health_by_one):
            pass
        self.assertEqual(init.game_map[3][3], Constants.CLEAR)
Пример #4
0
 def is_bomb_added_to_list(self):
     pressed = pygame.key.get_pressed()
     grid_x = (self.position_x +
               20) // Constants.BLOCK_SIZE * Constants.BLOCK_SIZE + 3
     grid_y = (self.position_y +
               20) // Constants.BLOCK_SIZE * Constants.BLOCK_SIZE + 3
     if pressed[pygame.K_SPACE]:
         if self.bomb_amount > 0:
             pop_sound = pygame.mixer.Sound("Sounds/Pop-Sound Effect.wav")
             pop_sound.play()
             self.bomb_list.append(
                 Bomb.Bomb(self.screen, grid_x, grid_y, self.bomb_range,
                           time.time()))
             self.bomb_amount -= 1
             return True
     return False
Пример #5
0
 def setUpClass(cls):
     pygame.init()
     pygame.mixer.init()
     cls.screen = pygame.display.set_mode((750, 750))
     Constants.Assets.load()
     cls.player = Characters.Player(cls.screen, 200, 150, 5, 6, 13, 13,
                                    Constants.HERO_IMG_PATH)
     cls.bomb = Bomb.Bomb(cls.screen, 50, 50, 3, 2)
     cls.ghost_1 = Characters.Ghost(cls.screen, 650, 50, 1, 4, 2, 1,
                                    Constants.WHITE_GHOST_PATH,
                                    Constants.EASY)
     cls.ghost_2 = Characters.Ghost(cls.screen, 50, 650, 1, 3, 2, 1,
                                    Constants.BLUE_GHOST_PATH,
                                    Constants.MEDIUM)
     cls.ghost_3 = Characters.Ghost(cls.screen, 650, 650, 1, 1, 1, 1,
                                    Constants.RED_GHOST_PATH,
                                    Constants.HARD)
     cls.ghosts_list = []
     init.generate_map(init.game_map)
Пример #6
0
 def test_blocks_to_destroy_up_false(self):
     bomb = Bomb.Bomb(self.screen, 100, 150, 5, 5)
     blocks = []
     bomb.get_explosion_blocks(blocks)
     self.assertIn((2, 6), blocks)
Пример #7
0
 def test_blocks_to_destroy_up_true(self):
     bomb = Bomb.Bomb(self.screen, 250, 250, 5, 5)
     blocks = []
     bomb.get_explosion_blocks(blocks)
     self.assertIn((5, 4), blocks)