Beispiel #1
0
 def test_combat_loop_with_dead_units_does_nothing(self):
     from warlord.combat import do_combat_loop
     unitA = Mock()
     unitB = Mock()
     unitA.health = 0
     unitB.health = 0
     do_combat_loop([unitA, unitB], [1, 1])
     self.assertEqual(unitA.health, 0)
     self.assertEqual(unitB.health, 0)
Beispiel #2
0
 def test_combat_loop_where_unit_death_stops_combat(self, do_cmbt_rnd):
     from warlord.combat import do_combat_loop
     unitA = Mock()
     unitB = Mock()
     unitA.health = 99
     unitB.health = 1
     def dec_health(*args, **kwargs):
         unitB.health -= 1
     do_cmbt_rnd.side_effect = dec_health
     do_combat_loop([unitA, unitB], [99, 99])
     self.assertEqual(unitA.health, 99)
     self.assertEqual(unitB.health, 0)
Beispiel #3
0
 def test_combat_loop_changes_attack_count_when_out_of_uses(self,
         do_cmbt_rnd):
     from warlord.combat import do_combat_loop
     unitA = Mock()
     unitB = Mock()
     unitA.equipped_item.uses = 1
     atk_cnts = [99, 0]
     def side_effect(*args, **kwargs):
         unitA.equipped_item.uses -= 1
     do_cmbt_rnd.side_effect = side_effect
     do_combat_loop([unitA, unitB], atk_cnts)
     self.assertEquals(do_cmbt_rnd.call_count, 1)
     self.assertEquals(atk_cnts, [0, 0])
Beispiel #4
0
 def test_combat_loop(self, do_cmbt_rnd):
     from warlord.combat import do_combat_loop
     unitA = Mock()
     unitB = Mock()
     unitA.health = 99
     unitB.health = 99
     atk_cnts = [1, 1]
     def cmbt_rnd(units, *args, **kwargs):
         units[1].health -= 1
         atk_cnts[0] -= 1
     do_cmbt_rnd.side_effect = cmbt_rnd
     do_combat_loop([unitA, unitB], atk_cnts)
     self.assertEqual(unitA.health, 98)
     self.assertEqual(unitB.health, 98)