Пример #1
0
 def test_finesse_str(self):
     # makes sure to use the higher mod to be able to hit
     # goblin AC is 15
     # proficiency is +2
     # rolls a 10
     # needs a str mod of +3 to hit
     attacker = Player('Bob', [17, 10, 10, 10, 10, 10], StoutHalfling(), Fighter())
     target = Goblin()
     attack = weapons[WeaponId.DAGGER]
     set_values([10])
     with patch('game_engine.dice._random_int', side_effect=value):
         self.assertEqual(roll_to_hit(attacker, target, attack, None), HitType.HIT)
Пример #2
0
 def test_ranged(self):
     # will hit if using the dex bonus not the str bonus (or no bonus for that matter)
     # goblin AC is 15
     # proficiency is +2
     # rolls a 10
     # needs a dex mod of +3 to hit
     attacker = Player('Bob', [10, 17, 10, 10, 10, 10], StoutHalfling(), Fighter())
     target = Goblin()
     attack = weapons[WeaponId.LIGHT_CROSSBOW]
     set_values([10])
     with patch('game_engine.dice._random_int', side_effect=value):
         self.assertEqual(roll_to_hit(attacker, target, attack, None), HitType.HIT)
Пример #3
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)
Пример #4
0
 def test_goblin_attack_orc(self):
     attacker = Goblin()
     target = Orc()
     set_values([13])
     with patch('game_engine.dice._random_int', side_effect=value):
         self.assertEqual(roll_to_hit(attacker, target, attacker.get_actions()[0], None), HitType.HIT)
Пример #5
0
 def test_natural_1(self):
     attacker = Player('Bob', [18, 18, 17, 17, 17, 17], Human(), Fighter())
     target = Goblin()
     set_values([1])
     with patch('game_engine.dice._random_int', side_effect=value):
         self.assertEqual(roll_to_hit(attacker, target, weapons[WeaponId.DAGGER], None), HitType.CRITICAL_MISS)