Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
Exemple #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)
 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())
Exemple #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))
Exemple #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))
 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())
Exemple #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)
Exemple #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)
 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())
 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)
 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())
 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())
 def test_ac_naked(self):
     player = Player('Radrick', [10, 18, 10, 10, 10, 10], Human(),
                     Fighter())
     self.assertEqual(14, player.get_ac())
 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())
 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())
 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())
 def test_create(self):
     stats, _ = CharacterBuilder.roll_stats()
     player = Player('Radrick', stats, Human(), Fighter())
     self.assertIsNotNone(player)
 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())
 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())
 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())
Exemple #29
0
 def available_classes():
     return [Fighter(), Rogue()]
 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())