Ejemplo n.º 1
0
 def test_should_subtract_attack_power_amount_from_health(self, mock_unit):
     receiver = UnitBase()
     receiver.position = mock.Mock()
     receiver._health = 5
     mock_unit.return_value = receiver
     self.attack.perform()
     self.assertEqual(receiver.health, 2)
Ejemplo n.º 2
0
 def setUp(self):
     self.unit = UnitBase()
     self.floor = Floor()
     self.floor.width = 6
     self.floor.height = 5
     self.floor.add(self.unit, 1, 2, "north")
     self.position = self.unit.position
Ejemplo n.º 3
0
 def test_should_fetch_other_units_not_warrior(self):
     unit = UnitBase()
     warrior = Warrior()
     self.floor.add(unit, 0, 0, 'north')
     self.floor.add(warrior, 1, 0, 'north')
     self.assertNotIn(warrior, self.floor.other_units())
     self.assertIn(unit, self.floor.other_units())
Ejemplo n.º 4
0
 def test_should_subtract_100_health_from_each_unit_on_the_floor(self):
     unit = UnitBase()
     unit._health = 20
     self.floor.add(unit, 0, 1)
     self.captive._health = 10
     self.explode.perform()
     self.assertEqual(self.captive.health, -90)
     self.assertEqual(unit.health, -80)
Ejemplo n.º 5
0
    def setUp(self):
        self.floor = Floor()
        self.floor.width = 4
        self.floor.height = 3
        self.warrior = Warrior()
        self.warrior._health = 20
        self.detonate = Detonate(self.warrior)

        self.target = UnitBase()
        self.target._health = 10

        self.floor.add(self.warrior, 0, 1, 'east')
Ejemplo n.º 6
0
 def test_should_return_space_with_units_but_not_main_unit(self):
     self.floor.add(UnitBase(), 0, 1)
     self.assertEqual(1, len(self.listen.perform()))
Ejemplo n.º 7
0
 def test_should_bind_recipient(self):
     receiver = UnitBase()
     self.bind.unit = mock.Mock(return_value=receiver)
     self.bind.perform()
     self.assertTrue(receiver.is_bound())
Ejemplo n.º 8
0
 def test_should_get_relative_object_diagonally_when_rotating(self):
     unit = UnitBase()
     self.floor.add(unit, 0, 1)
     self.position.rotate(2)
     self.assertFalse(self.position.relative_space(-1, 1).is_empty())
Ejemplo n.º 9
0
 def test_should_get_relative_object_diagonally(self):
     unit = UnitBase()
     self.floor.add(unit, 0, 1)
     self.assertFalse(self.position.relative_space(1, -1).is_empty())
Ejemplo n.º 10
0
 def test_should_get_relative_object_in_front_when_rotated(self):
     unit = UnitBase()
     self.floor.add(unit, 2, 2)
     self.position.rotate(1)
     self.assertFalse(self.position.relative_space(1).is_empty())
Ejemplo n.º 11
0
 def test_should_get_relative_space_in_front(self):
     unit = UnitBase()
     self.floor.add(unit, 1, 1)
     self.assertFalse(self.position.relative_space(1).is_empty())
Ejemplo n.º 12
0
 def setUp(self):
     self.unit = UnitBase()
Ejemplo n.º 13
0
 def test_should_return_unique_units(self):
     u1 = UnitBase()
     self.floor.add(u1, 0, 0)
     self.floor.add(UnitBase(), 1, 0)
     self.assertEqual(self.floor.unique_units, [u1])
Ejemplo n.º 14
0
 def test_should_not_consider_unit_on_floor_if_no_position(self):
     unit = UnitBase()
     self.floor.add(unit, 0, 1, "north")
     unit.position = None
     self.assertEqual(self.floor.units, [])
Ejemplo n.º 15
0
 def test_should_be_able_to_add_and_fetch_a_unit(self):
     unit = UnitBase()
     self.floor.add(unit, 0, 1, "north")
     self.assertEqual(self.floor.get(0, 1), unit)