Ejemplo n.º 1
0
    def test_multiple_stuns(self):
        error_msg = "2 StunThrowers stunning 2 Bees doesn't stun each Bee for exactly one turn."
        stun1 = ants.StunThrower()
        stun2 = ants.StunThrower()
        bee1 = ants.Bee(3)
        bee2 = ants.Bee(3)

        self.colony.places["tunnel_0_0"].add_insect(stun1)
        self.colony.places["tunnel_0_1"].add_insect(bee1)
        self.colony.places["tunnel_0_2"].add_insect(stun2)
        self.colony.places["tunnel_0_3"].add_insect(bee2)

        stun1.action(self.colony)
        stun2.action(self.colony)
        bee1.action(self.colony)
        bee2.action(self.colony)

        self.assertEqual("tunnel_0_1", bee1.place.name, error_msg)
        self.assertEqual("tunnel_0_3", bee2.place.name, error_msg)

        bee1.action(self.colony)
        bee2.action(self.colony)

        self.assertEqual("tunnel_0_0", bee1.place.name, error_msg)
        self.assertEqual("tunnel_0_2", bee2.place.name, error_msg)
Ejemplo n.º 2
0
 def test_status_parameters(self):
     slow = ants.SlowThrower()
     stun = ants.StunThrower()
     self.assertEqual(4, ants.SlowThrower.food_cost, 'SlowThrower has wrong cost')
     self.assertEqual(6, ants.StunThrower.food_cost, 'StunThrower has wrong cost')
     self.assertEqual(1, slow.armor, 'SlowThrower has wrong armor')
     self.assertEqual(1, stun.armor, 'StunThrower has wrong armor')
Ejemplo n.º 3
0
    def test_effect_stack(self):
        stun = ants.StunThrower()
        bee = ants.Bee(3)
        stun_place = self.colony.places['tunnel_0_0']
        bee_place = self.colony.places['tunnel_0_4']
        stun_place.add_insect(stun)
        bee_place.add_insect(bee)
        for _ in range(4): # stun bee four times
            stun.action(self.colony)
        for _ in range(4):
            bee.action(self.colony)
            self.assertEqual('tunnel_0_4', bee.place.name,
                             'Status effects do not stack')

	 def test_die_the_old_fashioned_way(self):
		bee = ants.Bee(3)
		queen = TestProblem9.queen
		# The bee has an uninterrupted path to the heart of the colony
		self.colony.places['tunnel_0_1'].add_insect(bee)
		self.colony.places['tunnel_0_2'].add_insect(queen)
		queen.action(self.colony)
		bee.action(self.colony)
		self.assertIs(False, len(self.colony.queen.bees) > 0, 'Game ended')
		queen.action(self.colony)
		bee.action(self.colony)
		self.assertIs(True, len(self.colony.queen.bees) > 0, 'Game not ended')
Ejemplo n.º 4
0
 def test_stun(self):
     error_msg = "StunThrower doesn't stun for exactly one turn."
     stun = ants.StunThrower()
     bee = ants.Bee(3)
     self.colony.places["tunnel_0_0"].add_insect(stun)
     self.colony.places["tunnel_0_4"].add_insect(bee)
     stun.action(self.colony)
     bee.action(self.colony)
     self.assertEqual("tunnel_0_4", bee.place.name, error_msg)
     bee.action(self.colony)
     self.assertEqual("tunnel_0_3", bee.place.name, error_msg)
Ejemplo n.º 5
0
 def test_stun(self):
     error_msg = 'StunThrower doesn\'t stun for exactly one turn.'
     stun = ants.StunThrower()
     bee = ants.Bee(3)
     self.colony.places['tunnel_0_0'].add_insect(stun)
     self.colony.places['tunnel_0_4'].add_insect(bee)
     stun.action(self.colony)
     bee.action(self.colony)
     self.assertEqual('tunnel_0_4', bee.place.name, error_msg)
     bee.action(self.colony)
     self.assertEqual('tunnel_0_3', bee.place.name, error_msg)
Ejemplo n.º 6
0
 def test_effect_stack(self):
     stun = ants.StunThrower()
     bee = ants.Bee(3)
     stun_place = self.colony.places["tunnel_0_0"]
     bee_place = self.colony.places["tunnel_0_4"]
     stun_place.add_insect(stun)
     bee_place.add_insect(bee)
     for _ in range(4):  # stun bee four times
         stun.action(self.colony)
     for _ in range(4):
         bee.action(self.colony)
         self.assertEqual("tunnel_0_4", bee.place.name,
                          "Status effects do not stack")
Ejemplo n.º 7
0
    def test_long_effect_stack(self):
        stun = ants.StunThrower()
        slow = ants.SlowThrower()
        bee = ants.Bee(3)
        self.colony.places["tunnel_0_0"].add_insect(stun)
        self.colony.places["tunnel_0_1"].add_insect(slow)
        self.colony.places["tunnel_0_4"].add_insect(bee)
        for _ in range(3):  # slow bee three times
            slow.action(self.colony)
        stun.action(self.colony)  # stun bee once

        self.colony.time = 0
        bee.action(self.colony)  # stunned
        self.assertEqual("tunnel_0_4", bee.place.name)

        self.colony.time = 1
        bee.action(self.colony)  # slowed thrice
        self.assertEqual("tunnel_0_4", bee.place.name)

        self.colony.time = 2
        bee.action(self.colony)  # slowed thrice
        self.assertEqual("tunnel_0_3", bee.place.name)

        self.colony.time = 3
        bee.action(self.colony)  # slowed thrice
        self.assertEqual("tunnel_0_3", bee.place.name)

        self.colony.time = 4
        bee.action(self.colony)  # slowed twice
        self.assertEqual("tunnel_0_2", bee.place.name)

        self.colony.time = 5
        bee.action(self.colony)  # slowed twice
        self.assertEqual("tunnel_0_2", bee.place.name)

        self.colony.time = 6
        bee.action(self.colony)  # slowed once
        self.assertEqual("tunnel_0_1", bee.place.name)

        self.colony.time = 7
        bee.action(self.colony)  # no effects
        self.assertEqual(0, slow.armor)