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')
def test_slow(self): error_msg = "SlowThrower doesn't cause slowness on odd turns." slow = ants.SlowThrower() bee = ants.Bee(3) self.colony.places["tunnel_0_0"].add_insect(slow) self.colony.places["tunnel_0_4"].add_insect(bee) slow.action(self.colony) self.colony.time = 1 bee.action(self.colony) self.assertEqual("tunnel_0_4", bee.place.name, error_msg) self.colony.time += 1 bee.action(self.colony) self.assertEqual("tunnel_0_3", bee.place.name, error_msg) for _ in range(3): self.colony.time += 1 bee.action(self.colony) self.assertEqual("tunnel_0_1", bee.place.name, error_msg)
def test_slow(self): error_msg = 'SlowThrower doesn\'t cause slowness on odd turns.' slow = ants.SlowThrower() bee = ants.Bee(3) self.colony.places['tunnel_0_0'].add_insect(slow) self.colony.places['tunnel_0_4'].add_insect(bee) slow.action(self.colony) self.colony.time = 1 bee.action(self.colony) self.assertEqual('tunnel_0_4', bee.place.name, error_msg) self.colony.time += 1 bee.action(self.colony) self.assertEqual('tunnel_0_3', bee.place.name, error_msg) for _ in range(3): self.colony.time += 1 bee.action(self.colony) self.assertEqual('tunnel_0_1', bee.place.name, error_msg)
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)