Exemplo n.º 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)
Exemplo n.º 2
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)
Exemplo n.º 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)
Exemplo n.º 4
0
 def test_unproficient_armor(self):
     attacker = Player('Bob', [10, 10, 17, 17, 17, 17], Human(), Rogue())
     target = Goblin()
     attacker.set_armor(armors[ArmorId.PLATE])
     set_values([20, 3])
     with patch('game_engine.dice._random_int', side_effect=value):
         self.assertEqual(roll_to_hit(attacker, target, weapons[WeaponId.DAGGER], None), HitType.MISS)
Exemplo n.º 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)
Exemplo n.º 6
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)
Exemplo n.º 7
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)
Exemplo n.º 8
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)
Exemplo n.º 9
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)
Exemplo n.º 10
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)
Exemplo n.º 11
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))
Exemplo n.º 12
0
 def test_proficieny_matters_not_rogue(self):
     # makes sure to use the higher mod to be able to hit
     # goblin AC is 15
     # rolls a 13
     attacker = Player('Bob', [10, 10, 17, 17, 17, 17], Human(), Rogue())
     target = Goblin()
     attack = weapons[WeaponId.MAUL]
     set_values([13])
     with patch('game_engine.dice._random_int', side_effect=value):
         self.assertEqual(roll_to_hit(attacker, target, attack, None), HitType.MISS)
Exemplo n.º 13
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())
Exemplo n.º 14
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))
Exemplo n.º 15
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())
Exemplo n.º 16
0
 def test_create(self):
     stats, _ = CharacterBuilder.roll_stats()
     player = Player('Radrick', stats, Human(), Fighter())
     self.assertIsNotNone(player)
Exemplo n.º 17
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())
Exemplo n.º 18
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())
Exemplo n.º 19
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())
Exemplo n.º 20
0
 def test_replace(self):
     player = Player('bob', [10, 10, 10, 10, 10, 10], Human(), Rogue())
     player.set_right_hand(weapons[WeaponId.RAPIER])
     player.set_left_hand(armors[ArmorId.SHIELD])
     player.set_left_hand(weapons[WeaponId.DAGGER])
     self.assertEqual(WeaponId.DAGGER, player.get_left_hand().get_id())
Exemplo n.º 21
0
 def test_ac_naked(self):
     player = Player('Radrick', [10, 18, 10, 10, 10, 10], Human(),
                     Fighter())
     self.assertEqual(14, player.get_ac())
Exemplo n.º 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())
Exemplo n.º 23
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)
Exemplo n.º 24
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())
Exemplo n.º 25
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())
Exemplo n.º 26
0
 def test_not_proficient_armor_none(self):
     player = Player('bob', [10, 10, 10, 10, 10, 10], Human(), Rogue())
     player.set_armor(armors[ArmorId.PLATE])
     self.assertTrue(player.wearing_unproficient_armor())
Exemplo n.º 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())
Exemplo n.º 28
0
 def test_no_shield(self):
     player = Player('bob', [10, 10, 10, 10, 10, 10], Human(), Rogue())
     self.assertIsNone(player.get_shield())
Exemplo n.º 29
0
 def available_races():
     return [Human(), Halfling()]
Exemplo n.º 30
0
 def test_left_shield(self):
     player = Player('bob', [10, 10, 10, 10, 10, 10], Human(), Rogue())
     player.set_left_hand(armors[ArmorId.SHIELD])
     self.assertEqual(ArmorType.SHIELD, player.get_shield().get_type())