Пример #1
0
 def test_ranged(self):
     attacker = Player('Bob', [10, 16, 10, 10, 10, 10], Human(), Fighter())
     attack = weapons[WeaponId.LIGHT_CROSSBOW]
     set_values([3])
     with patch('game_engine.dice._random_int', side_effect=value):
         self.assertEqual(
             roll_damage(attacker, None, attack, HitType.HIT, None), 6)
Пример #2
0
 def test_miss(self):
     attacker = Player('Bob', [10, 10, 10, 10, 10, 10], Human(), Fighter())
     attack = weapons[WeaponId.DAGGER]
     set_values([3])
     with patch('game_engine.dice._random_int', side_effect=value):
         self.assertEqual(
             roll_damage(attacker, None, attack, HitType.MISS, None), 0)
Пример #3
0
 def test_negative_damage(self):
     attacker = Player('Bob', [3, 3, 10, 10, 10, 10], Human(), Fighter())
     set_values([1])
     attack = weapons[WeaponId.DAGGER]
     with patch('game_engine.dice._random_int', side_effect=value):
         self.assertEqual(
             roll_damage(attacker, None, attack, HitType.HIT, None), 0)
Пример #4
0
 def test_critical_hit_maul(self):
     attacker = Player('Bob', [10, 10, 10, 10, 10, 10], Human(), Fighter())
     attack = weapons[WeaponId.MAUL]
     set_values([4, 3, 6, 5])
     with patch('game_engine.dice._random_int', side_effect=value):
         self.assertEqual(
             roll_damage(attacker, None, attack, HitType.CRITICAL_HIT,
                         None), 18)
Пример #5
0
 def test_monster(self):
     attacker = Goblin()
     set_values([1])
     with patch('game_engine.dice._random_int', side_effect=value):
         self.assertEqual(
             3,
             roll_damage(attacker, None,
                         attacker.get_actions()[0], HitType.HIT, None))
Пример #6
0
 def test_using_versatile_two_handed(self):
     attacker = Player('Bob', [10, 10, 10, 10, 10, 10], Human(), Fighter())
     attacker.set_two_hands(weapons[WeaponId.SPEAR])
     d = roll_damage(attacker, None, attacker.get_two_hands(), HitType.HIT,
                     None)
     # kind of lame, not always going to fail, not sure how else to be sure
     # TODO: could be solved by a debugging option to focus dice to roll max then check for 8
     self.assertTrue(1 <= d <= 8)
Пример #7
0
 def test_fs_greatweapon(self):
     attacker = Player('Bob', [10, 10, 10, 10, 10, 10], Human(), Fighter())
     attacker.set_two_hands(weapons[WeaponId.LONGSWORD])
     attacker.add_fighting_style(Trait.FIGHTING_STYLE_GREAT_WEAPON_FIGHTING)
     set_values([1, 10])
     with patch('game_engine.dice._random_int', side_effect=value):
         self.assertEqual(
             10,
             roll_damage(attacker, None, attacker.get_two_hands(),
                         HitType.HIT, None))
Пример #8
0
 def test_fs_dueling_two_handed(self):
     attacker = Player('Bob', [10, 10, 10, 10, 10, 10], Human(), Fighter())
     attacker.set_two_hands(weapons[WeaponId.SPEAR])
     attacker.add_fighting_style(Trait.FIGHTING_STYLE_DUELING)
     set_values([6])
     with patch('game_engine.dice._random_int', side_effect=value):
         self.assertEqual(
             6,
             roll_damage(attacker, None, attacker.get_two_hands(),
                         HitType.HIT, None))
Пример #9
0
 def attack_action(self, weapon, target):
     hit = to_hit_engine.roll_to_hit(self, target, weapon, self.arena)
     damage = damage_engine.roll_damage(self, target, weapon, hit, self.arena)
     target.apply_damage(damage)