def test_move_withSpriteOnTop_movesAdjacent(self):
     world = make_empty_sprite_groups()
     block = TinyBlock(1, 1, world.solid)
     tile = TinyBlock(1, 1)
     result = move_to_nearest_empty_space(tile, world, 3)
     self.assertFalse(result.rect.colliderect(block.rect))
     self.assertTrue(-1 < result.rect.centerx < 3)
     self.assertTrue(-1 < result.rect.centery < 3)
Beispiel #2
0
 def test_generator_withOneGenerator_produceMonsters(self):
     world = make_empty_sprite_groups()
     player_character = Character(PlayerCharacterType.TOBY)
     player = Player(500, 500, player_character, world)
     generator = actors.make_monster(MonsterType.ZOMBIE_GENERATOR, 0, 0,
                                     world)
     generator.targeted_enemy = player
     self.assertEqual(1, len(world.solid))
     generator.do_actions(world)
     self.assertEqual(2, len(world.solid))
Beispiel #3
0
    def test_generator_withTwoGenerators_produceTwoMonsters(self):
        world = make_empty_sprite_groups()
        player_character = Character(PlayerCharacterType.TOBY)
        player = Player(500, 500, player_character, world)
        generators = [
            actors.make_monster(MonsterType.ZOMBIE_GENERATOR, 0, 0, world),
            actors.make_monster(MonsterType.ZOMBIE_GENERATOR, 100, 100, world)
        ]

        self.assertEqual(2, len(world.solid))
        for g in generators:
            g.targeted_enemy = player
            g.do_actions(world)
        self.assertEqual(4, len(world.solid))
 def test_move_withSpriteNextToFreeSpaceBigBlocks_movesIntoSpace(self):
     """
       ####
       # ##
       ####
     """
     world = make_empty_sprite_groups()
     for x in range(0, 40, 10):
         for y in range(0, 30, 10):
             if (x, y) != (10, 10):
                 BigBlock(x, y, world.solid)
     tile = BigBlock(20, 10)
     result = move_to_nearest_empty_space(tile, world, 30)
     self.assertEqual((10, 10), result.rect.center)
 def test_move_withSpriteNextToFreeSpace_movesIntoSpace(self):
     """
       ####
       # ##
       ####
     """
     world = make_empty_sprite_groups()
     for x in range(4):
         for y in range(3):
             if (x, y) != (1, 1):
                 TinyBlock(x, y, world.solid)
     tile = TinyBlock(2, 1)
     result = move_to_nearest_empty_space(tile, world, 3)
     self.assertEqual((1, 1), result.rect.center)
Beispiel #6
0
    def test_generator_withTime_producesMonstersAtRateOfFire(self):
        pygame.time.Clock()
        world = make_empty_sprite_groups()
        player_character = Character(PlayerCharacterType.TOBY)
        player = Player(500, 500, player_character, world)
        generators = [
            actors.make_monster(MonsterType.ZOMBIE_GENERATOR, 0, 0, world),
            actors.make_monster(MonsterType.ZOMBIE_GENERATOR, 100, 100, world)
        ]

        self.assertEqual(2, len(world.solid))
        for g in generators:
            g.targeted_enemy = player
            g.actions[0].rate_of_fire = 10
            g.do_actions(world)
        self.assertEqual(4, len(world.solid))
        t = pygame.time.get_ticks()
        while t + 150 > pygame.time.get_ticks():
            for g in generators:
                g.do_actions(world)
        self.assertEqual(6, len(world.solid))
Beispiel #7
0
 def test_make_monster_withZombie(self):
     world = make_empty_sprite_groups()
     zombie = actors.make_monster(MonsterType.ZOMBIE, 0, 0, world)
     self.assertEqual(3, len(zombie.filmstrips.walk_south))
 def test_move_withSpriteAlreadyInSpace_doesNotMove(self):
     world = make_empty_sprite_groups()
     tile = TinyBlock(1, 1)
     result = move_to_nearest_empty_space(tile, world, 3)
     self.assertEqual((1, 1), result.rect.center)