Пример #1
0
 def test_fs_defence_no_armor(self):
     attacker = Player('Bob', [10, 10, 17, 17, 17, 17], Human(), Fighter())
     target = Player('Other Bob', [10, 10, 17, 17, 17, 17], Human(), Fighter())
     target.add_fighting_style(Trait.FIGHTING_STYLE_DEFENCE)
     set_values([8])
     with patch('game_engine.dice._random_int', side_effect=value):
         self.assertEqual(roll_to_hit(attacker, target, weapons[WeaponId.DAGGER], None), HitType.HIT)
Пример #2
0
 def test_lucky(self):
     attacker = Player('Bob', [10, 10, 10, 10, 10, 10], StoutHalfling(), Fighter())
     target = Goblin()
     attack = weapons[WeaponId.DAGGER]
     set_values([1, 17])
     with patch('game_engine.dice._random_int', side_effect=value):
         self.assertEqual(roll_to_hit(attacker, target, attack, None), HitType.HIT)
Пример #3
0
 def test_critical_miss(self):
     attacker = Player('Bob', [10, 10, 10, 10, 10, 10], Human(), Fighter())
     target = Goblin()
     attack = weapons[WeaponId.DAGGER]
     set_values([1])
     with patch('game_engine.dice._random_int', side_effect=value):
         self.assertEqual(roll_to_hit(attacker, target, attack, None), HitType.CRITICAL_MISS)
Пример #4
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)
Пример #5
0
 def test_fs_archery(self):
     attacker = Player('Bob', [10, 10, 17, 17, 17, 17], Human(), Fighter())
     attacker.add_fighting_style(Trait.FIGHTING_STYLE_ARCHERY)
     target = Goblin()
     set_values([11])
     with patch('game_engine.dice._random_int', side_effect=value):
         self.assertEqual(roll_to_hit(attacker, target, weapons[WeaponId.SHORTBOW], None), HitType.HIT)
Пример #6
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)
Пример #7
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)
Пример #8
0
 def test_goblin_attack_player(self):
     attacker = Goblin()
     target = Player('Bob', [10, 10, 10, 10, 10, 10], Human(), Fighter())
     target.set_armor(armors[ArmorId.CHAIN_SHIRT])
     target.set_left_hand(armors[ArmorId.SHIELD])
     set_values([11])
     with patch('game_engine.dice._random_int', side_effect=value):
         self.assertEqual(roll_to_hit(attacker, target, attacker.get_actions()[0], None), HitType.HIT)
Пример #9
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)
Пример #10
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)
Пример #11
0
 def test_fighter_hp(self):
     #              9        12       17       8        9        11
     set_values([
         3, 3, 1, 3, 2, 4, 6, 1, 6, 6, 5, 2, 2, 3, 1, 3, 5, 1, 1, 3, 2, 6,
         3, 3
     ])
     with patch('game_engine.dice._random_int', side_effect=value):
         stats, _ = CharacterBuilder.roll_stats()
         player = Player('Radrick', stats, Human(), Fighter())
         self.assertEqual(14, player.get_cur_hp())
Пример #12
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))
Пример #13
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))
Пример #14
0
 def test_halfling_racial_dex_roll_mod(self):
     # roll a dex of 10, (+0) add 2 for halfling results in a mod of +1
     #              9        10       17       8        9        11
     set_values([
         3, 3, 1, 3, 2, 2, 6, 1, 6, 6, 5, 2, 2, 3, 1, 3, 5, 1, 1, 3, 2, 6,
         3, 3
     ])
     with patch('game_engine.dice._random_int', side_effect=value):
         stats, _ = CharacterBuilder.roll_stats()
         player = Player('Radrick', stats, Halfling(), Fighter())
         self.assertEqual(1, player.get_dex_mod())
Пример #15
0
 def test_proficieny_matters(self):
     # makes sure to use the higher mod to be able to hit
     # goblin AC is 15
     # proficiency is +2
     # rolls a 13
     attacker = Player('Bob', [10, 10, 17, 17, 17, 17], StoutHalfling(), Fighter())
     target = Goblin()
     attack = weapons[WeaponId.DAGGER]
     set_values([13])
     with patch('game_engine.dice._random_int', side_effect=value):
         self.assertEqual(roll_to_hit(attacker, target, attack, None), HitType.HIT)
Пример #16
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)
Пример #17
0
 def test_medium_armor_dex(self):
     player = Player('Radrick', [10, 18, 10, 10, 10, 10], Human(),
                     Fighter())
     player.set_armor(armors[ArmorId.HIDE])
     self.assertEqual(14, player.get_ac())
Пример #18
0
 def test_ac_naked_shield(self):
     player = Player('Radrick', [10, 10, 10, 10, 10, 10], Human(),
                     Fighter())
     player.set_right_hand(armors[ArmorId.SHIELD])
     self.assertEqual(player.get_ac(), 12)
Пример #19
0
 def test_ac_heavy_high_dex(self):
     player = Player('Radrick', [10, 18, 10, 10, 10, 10], Human(),
                     Fighter())
     player.set_right_hand(armors[ArmorId.SHIELD])
     player.set_armor(armors[ArmorId.PLATE])
     self.assertEqual(20, player.get_ac())
Пример #20
0
 def test_too_weak_no_armor(self):
     player = Player('Radrick', [10, 18, 10, 10, 10, 10], Human(),
                     Fighter())
     self.assertFalse(player.too_weak_for_armor())
Пример #21
0
 def test_ac_naked(self):
     player = Player('Radrick', [10, 18, 10, 10, 10, 10], Human(),
                     Fighter())
     self.assertEqual(14, player.get_ac())
Пример #22
0
 def test_too_weak_has_str(self):
     player = Player('Radrick', [13, 18, 10, 10, 10, 10], Human(),
                     Fighter())
     player.set_armor(armors[ArmorId.CHAIN_MAIL])
     self.assertFalse(player.too_weak_for_armor())
Пример #23
0
 def test_halfling_human_int_mods(self):
     stats, _ = CharacterBuilder.roll_stats()
     player = Player('Radrick', stats, Human(), Fighter())
     self.assertEqual(stats[3] + 1, player.get_int())
Пример #24
0
 def test_halfling_racial_dex_mods(self):
     stats, _ = CharacterBuilder.roll_stats()
     player = Player('Radrick', stats, Halfling(), Fighter())
     self.assertEqual(stats[1] + 2, player.get_dex())
Пример #25
0
 def test_create(self):
     stats, _ = CharacterBuilder.roll_stats()
     player = Player('Radrick', stats, Human(), Fighter())
     self.assertIsNotNone(player)
Пример #26
0
 def test_spear_two_hands(self):
     player = Player('bob', [10, 10, 10, 10, 10, 10], Human(), Fighter())
     player.set_two_hands(weapons[WeaponId.SPEAR])
     self.assertEqual(WeaponId.SPEAR, player.get_two_hands().get_id())
Пример #27
0
 def test_too_weak_no_requirement(self):
     player = Player('Radrick', [10, 18, 10, 10, 10, 10], Human(),
                     Fighter())
     player.set_armor(armors[ArmorId.LEATHER])
     self.assertFalse(player.too_weak_for_armor())
Пример #28
0
 def test_encumbered_speed(self):
     player = Player('Radrick', [10, 18, 10, 10, 10, 10], Human(),
                     Fighter())
     player.set_armor(armors[ArmorId.CHAIN_MAIL])
     self.assertEqual(20, player.get_speed())
Пример #29
0
 def available_classes():
     return [Fighter(), Rogue()]
Пример #30
0
 def test_two_hands(self):
     player = Player('bob', [10, 10, 10, 10, 10, 10], Human(), Fighter())
     player.set_right_hand(armors[ArmorId.SHIELD])
     player.set_two_hands(weapons[WeaponId.MAUL])
     self.assertIsNone(player.get_right_hand())
     self.assertEqual(WeaponId.MAUL, player.get_two_hands().get_id())