예제 #1
0
 def test_is_over(self):
     f1 = Faction('Goblins', [Goblin(), Goblin()])
     f2 = Faction('Orcs', [Orc(), Orc()])
     a = Arena([f1, f2])
     f1.get_entities()[0].state = EntityState.DEAD
     f1.get_entities()[1].state = EntityState.DEAD
     self.assertTrue(a.is_over())
예제 #2
0
 def test_get_winning_faction(self):
     f1 = Faction('Goblins', [Goblin(), Goblin()])
     f2 = Faction('Orcs', [Orc(), Orc()])
     a = Arena([f1, f2])
     f1.get_entities()[0].state = EntityState.DEAD
     f1.get_entities()[1].state = EntityState.DEAD
     self.assertEqual(a.get_winning_faction(), f2)
예제 #3
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))
예제 #4
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)
예제 #5
0
 def test_all_factions_dead(self):
     f1 = Faction('Goblins', [Goblin(), Goblin()])
     f2 = Faction('Orcs', [Orc(), Orc()])
     a = Arena([f1, f2])
     f1.get_entities()[0].state = EntityState.DEAD
     f1.get_entities()[1].state = EntityState.DEAD
     f2.get_entities()[0].state = EntityState.DEAD
     f2.get_entities()[1].state = EntityState.DEAD
     self.assertIsNone(a.get_winning_faction())
예제 #6
0
 def test_is_not_over(self):
     f1 = Faction('Goblins', [Goblin(), Goblin()])
     f2 = Faction('Orcs', [Orc(), Orc()])
     f3 = Faction('More Bad Orcs', [Orc(), Orc()])
     a = Arena([f1, f2, f3])
     # kill the first faction and then one from the other two
     f1.get_entities()[0].state = EntityState.DEAD
     f1.get_entities()[1].state = EntityState.DEAD
     f2.get_entities()[0].state = EntityState.DEAD
     f3.get_entities()[1].state = EntityState.DEAD
     self.assertFalse(a.is_over())
예제 #7
0
 def test_random_target(self):
     g = Goblin()
     o1 = Orc()
     o2 = Orc()
     o3 = Orc()
     goblins = Faction('Goblins', [g])
     orcs = Faction('Orcs', [o1, o2, o3])
     arena = Arena([goblins, orcs])
     # this is only for testing, need to set the arena on the goblin
     # normally this would happen via the take_turn method
     g.arena = arena
     g.select_target(TargetStrategy.RANDOM)
     self.assertTrue(g.target is not None)
     self.assertIn(g.target, [o1, o2, o3])
예제 #8
0
 def test_goblin_stats(self):
     g = Goblin()
     self.assertEqual(g.get_str(), 8)
     self.assertEqual(g.get_dex(), 14)
     self.assertEqual(g.get_con(), 10)
     self.assertEqual(g.get_int(), 10)
     self.assertEqual(g.get_wis(), 8)
     self.assertEqual(g.get_cha(), 8)
예제 #9
0
 def test_goblin_str_mod(self):
     g = Goblin()
     self.assertEqual(g.get_str_mod(), -1)
     self.assertEqual(g.get_dex_mod(), 2)
     self.assertEqual(g.get_con_mod(), 0)
     self.assertEqual(g.get_int_mod(), 0)
     self.assertEqual(g.get_wis_mod(), -1)
     self.assertEqual(g.get_cha_mod(), -1)
예제 #10
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)
예제 #11
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)
예제 #12
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)
예제 #13
0
 def test_get_opposing_factions(self):
     f1 = Faction('Goblins', [Goblin()])
     f2 = Faction('Orcs', [Orc()])
     f3 = Faction('More Bad Orcs', [Orc()])
     a = Arena([f1, f2, f3])
     opposing = a.get_opposing_factions(f1)
     self.assertNotIn(f1, opposing)
예제 #14
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)
예제 #15
0
 def test_goblin_vs_orc(self):
     # this means hp rolls, initiative rolls, to hit roll and damage rolls until one dead
     set_values([3, 3, 4, 4, 20, 10, 10, 3, 10, 8])
     with patch('game_engine.dice._random_int', side_effect=value):
         f1 = Faction('Goblins', [Goblin()])
         f2 = Faction('Orcs', [Orc()])
         game = Game([f1, f2])
         winner = game.play()
         self.assertEqual(winner.get_name(), 'Orcs')
예제 #16
0
 def test_initiative(self):
     f1 = Faction('Goblins', [Goblin()])
     f2 = Faction('Orcs', [Orc()])
     a = Arena([f1, f2])
     with patch('game_engine.dice._random_int') as mock_roll:
         mock_roll.return_value = 10
         a.determine_initiative_order()
         self.assertIsInstance(a.get_init_order()[0], Goblin)
         self.assertIsInstance(a.get_init_order()[1], Orc)
예제 #17
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)
예제 #18
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)
예제 #19
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)
예제 #20
0
 def test_goblin_initiative_patch(self):
     g = Goblin()
     with patch('game_engine.dice._random_int') as mock_roll:
         mock_roll.return_value = 10
         self.assertEqual(g.roll_initiative(), 12)
예제 #21
0
 def test_rounding_str_mod(self):
     g = Goblin()
     g.str = 13  # just for testing
     self.assertEqual(g.get_str_mod(), 1)
예제 #22
0
 def test_get_ac(self):
     g = Goblin()
     self.assertEqual(g.get_ac(), 15)
예제 #23
0
 def test_create_arena(self):
     f1 = Faction('Goblins', [Goblin()])
     f2 = Faction('Orcs', [Orc()])
     a = Arena([f1, f2])
     self.assertIsNotNone(a)
예제 #24
0
 def test_goblin_initiative(self):
     g = Goblin()
     # goblin dex mod
     self.assertTrue(3 <= g.roll_initiative() <= 22)
예제 #25
0
 def test_get_hd(self):
     g = Goblin()
     self.assertEqual(g.get_hd(), '2d6')
예제 #26
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)
예제 #27
0
 def test_goblin_actions(self):
     g = Goblin()
     self.assertIsInstance(g.get_actions()[0], Scimitar)
예제 #28
0
 def test_get_hp(self):
     g = Goblin()
     self.assertTrue(2 <= g.get_hp() <= 12)
예제 #29
0
 def test_no_winning_faction_yet(self):
     f1 = Faction('Goblins', [Goblin(), Goblin()])
     f2 = Faction('Orcs', [Orc(), Orc()])
     a = Arena([f1, f2])
     self.assertIsNone(a.get_winning_faction())
예제 #30
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)