def test_side(self):
     testing_side = unit_packs.Side([
         unit_packs.Squad([
             Unit.new('soldier'),
             Unit.new('soldier'),
             Unit.new('soldier')
         ]),
         unit_packs.Squad([
             Unit.new('soldier'),
             Unit.new('soldier'),
             Unit.new('soldier')
         ]),
         unit_packs.Squad([
             Unit.new('soldier'),
             Unit.new('soldier'),
             Unit.new('soldier')
         ])
     ],
                                    name='testing_side')
     self.assertEqual(testing_side.total_health(), 900)
     testing_side.squads[0].take_damage(1000)
     testing_side.squads[0].take_damage(1000)
     testing_side.squads[0].take_damage(1000)
     testing_side.update()
     self.assertEqual(len(testing_side.squads), 2)
 def test_squad(self):
     testing_squad = unit_packs.Squad(
         [Unit.new('soldier'),
          Unit.new('soldier'),
          Unit.new('soldier')])
     self.assertEqual(testing_squad.total_health(), 300)
     testing_squad.take_damage(1000)
     self.assertEqual(len(testing_squad.units), 2)
     testing_squad.take_damage(1000)
     testing_squad.take_damage(1000)
     self.assertFalse(testing_squad.is_alive)
Exemple #3
0
    def test_battlefield(self, mock_side):
        test_sides = [
            Side([
                Squad([
                    Unit.new('soldier'),
                    Unit.new('soldier'),
                    Unit.new('soldier')
                ])
            ],
                 name='side_1'),
            Side([
                Squad([
                    Unit.new('soldier'),
                    Unit.new('soldier'),
                    Unit.new('soldier')
                ])
            ],
                 name='side_2'),
            Side([
                Squad([
                    Unit.new('soldier'),
                    Unit.new('soldier'),
                    Unit.new('soldier')
                ])
            ],
                 name='side_3')
        ]
        testing_battlefield = b.Battlefield(test_sides)

        enemy_sides_test = [
            s.name for s in testing_battlefield.filter_enemy_sides(
                playing_side_index=1)
        ]
        self.assertEqual(enemy_sides_test, ['side_1', 'side_3'])

        testing_battlefield.side_attack(mock_side, enemy_sides=None)
        self.assertFalse(testing_battlefield.is_running)
Exemple #4
0
 def test_attack_success_max_exp(self):
     unit = Unit.new('vehicle', operator='soldier', u_count=1)
     for i in range(50):
         unit.exp_increase()
     self.assertLess(0, unit.attack_success)
Exemple #5
0
 def test_attack_success_low_health(self):
     unit = Unit.new('vehicle', operator='soldier', u_count=1)
     unit.take_damage(unit.health - 1)
     self.assertLess(0, unit.attack_success)
Exemple #6
0
 def test_damage_low_health(self):
     unit = Unit.new('vehicle', operator='soldier', u_count=1)
     unit.take_damage((unit.health - 1) * 1.7)
     self.assertLess(0, unit.damage)
Exemple #7
0
 def test_attack_success_zero_exp(self):
     unit = Unit.new('vehicle', operator='soldier', u_count=1)
     self.assertLess(0, unit.attack_success)
Exemple #8
0
 def test_damage_zero_exp(self):
     unit = Unit.new('vehicle', operator='soldier', u_count=1)
     self.assertLess(0, unit.damage)
Exemple #9
0
 def test_damage_max_exp(self):
     unit = Unit.new('vehicle', operator='soldier', u_count=1)
     for i in range(1000):
         unit.exp_increase()
     self.assertLess(0, unit.damage)
Exemple #10
0
 def test_is_alive(self):
     unit = Unit.new('soldier')
     self.assertTrue(unit.is_alive)
Exemple #11
0
 def test_damage_max_exp(self):
     unit = Unit.new('soldier')
     for i in range(50):
         unit.exp_increase()
     self.assertLess(0, unit.damage)
Exemple #12
0
 def test_attack_success_low_health(self):
     unit = Unit.new('soldier')
     unit.take_damage(unit.health - 1)
     self.assertLess(0, unit.attack_success)
Exemple #13
0
 def test_max_experience(self):
     unit = Unit.new('soldier')
     for i in range(1000):
         unit.exp_increase()
     self.assertLessEqual(unit.experience, 50)
Exemple #14
0
 def test_attack_success_max_exp(self):
     unit = Unit.new('soldier')
     for i in range(50):
         unit.exp_increase()
     self.assertLess(0, unit.attack_success)
Exemple #15
0
 def test_attack_success_zero_exp(self):
     unit = Unit.new('soldier')
     self.assertLess(0, unit.attack_success)
Exemple #16
0
 def test_damage_low_health(self):
     unit = Unit.new('soldier')
     unit.take_damage((unit.health - 1))
     self.assertLess(0, unit.damage)
Exemple #17
0
 def test_is_dead(self):
     unit = Unit.new('soldier')
     unit.take_damage(unit.health)
     self.assertFalse(unit.is_alive)
Exemple #18
0
 def test_is_dead(self):
     unit = Unit.new('vehicle', operator='soldier', u_count=1)
     unit.take_damage(unit.health * 1.7)
     self.assertFalse(unit.is_alive)
Exemple #19
0
 def test_is_alive(self):
     unit = Unit.new('vehicle', operator='soldier', u_count=1)
     self.assertTrue(unit.is_alive)
Exemple #20
0
 def test_damage_zero_exp(self):
     unit = Unit.new('soldier')
     self.assertLess(0, unit.damage)