Esempio n. 1
0
 def elementalist_money(self):
     error = "Elementalist didn't award money"
     winning_teams = [CombatTeam([], PlayerBuilder().build())]
     losing_teams = [CombatTeam([], NPCBuilder().build())]
     generator = LootGenerator(winning_teams, losing_teams)
     generator.generate_loot()
     self.assertGreater(generator.gold_earned, 0, error)
Esempio n. 2
0
 def test_victory_elementalist_no_loot(self):
     error = "Elementalist shouldn't award loot"
     winning_teams = [CombatTeam([], PlayerBuilder().build())]
     elemental = ElementalBuilder().with_species(Manapher()).build()  # Manapher has 100% drop rate
     losing_teams = [CombatTeam([elemental], NPCBuilder().build())]
     generator = LootGenerator(winning_teams, losing_teams)
     generator.generate_loot()
     self.assertEqual(len(generator.items_dropped), 0, error)
Esempio n. 3
0
 def wild_elemental_loot(self):
     error = "Wild elemental didn't award loot"
     winning_teams = [CombatTeam.from_team(TeamBuilder().build())]
     wild_elemental = ElementalBuilder().with_species(Manapher()).build()  # Manapher has 100% drop rate
     losing_teams = [CombatTeam([wild_elemental])]  # Wild elemental teams have no owner
     generator = LootGenerator(winning_teams, losing_teams)
     generator.generate_loot()
     self.assertGreater(len(generator.items_dropped), 0, error)
Esempio n. 4
0
 def create_duel(player: Player, other_player: Player) -> None:
     """
     Start a fight between two players.
     """
     Combat([CombatTeam.from_team(player.team)],
            [CombatTeam.from_team(other_player.team)],
            data_manager=DataManager(),
            allow_flee=False,
            allow_items=False)
Esempio n. 5
0
 def test_switch_ko(self):
     error = "CombatTeam incorrectly allowed a knocked out CombatElemental to be switched in"
     team = CombatTeam([
         ElementalBuilder().with_current_hp(0).build(),
         ElementalBuilder().build()
     ])
     Combat([team], [], Mock())
     is_switched = team.attempt_switch(team.elementals[0])
     self.assertFalse(is_switched, error)
Esempio n. 6
0
 def test_get_enemy_target(self):
     error = "Ability that targets an enemy didn't get the correct target"
     team_a = CombatTeam([ElementalBuilder().build()],
                         PlayerBuilder().build())
     team_b = CombatTeam([ElementalBuilder().build()],
                         PlayerBuilder().build())
     combat = Combat([team_a], [team_b], Mock())
     ability = Mock()
     ability.targeting = Target.ENEMY
     target = combat.get_target(ability, team_a.active_elemental)
     self.assertEqual(target, team_b.active_elemental, error)
Esempio n. 7
0
 def test_mana_per_turn(self):
     error = "CombatTeam eligible Elementals on the bench didn't gain mana on turn start"
     team = CombatTeam(
         [ElementalBuilder().build(),
          ElementalBuilder().build()])
     Combat([team], [], Mock())
     bench = team.eligible_bench
     starting_mana = bench[0].current_mana
     team.turn_start()
     resultant_mana = bench[0].current_mana
     self.assertGreater(resultant_mana, starting_mana, error)
Esempio n. 8
0
 def test_player_exp_gain(self):
     error = "Knocking out an elemental didn't grant exp to player"
     player = PlayerBuilder().build()
     team_a = CombatTeam([ElementalBuilder().build()], player)
     team_b = make_combat_team()
     get_mocked_combat(team_a, team_b)
     # Nearly fatal damage
     damage = team_b.active_elemental.max_hp - 1
     team_b.active_elemental.receive_damage(damage, team_a.elementals[0])
     exp_before = player.current_exp
     team_a.make_move(Claw())
     team_b.make_move(Claw())
     exp_after = player.current_exp
     self.assertGreater(exp_after, exp_before, error)
Esempio n. 9
0
 def test_elemental_exp_gain(self):
     error = "Knocking out an elemental didn't grant exp to player's elementals"
     elemental = ElementalBuilder().with_level(5).build()
     team_a = CombatTeam([elemental], PlayerBuilder().build())
     team_b = make_combat_team()
     get_mocked_combat(team_a, team_b)
     # Nearly fatal damage
     damage = team_b.active_elemental.max_hp - 1
     team_b.active_elemental.receive_damage(damage, team_a.active_elemental)
     exp_before = elemental.current_exp
     team_a.make_move(Claw())
     team_b.make_move(Claw())
     exp_after = elemental.current_exp
     self.assertGreater(exp_after, exp_before, error)
Esempio n. 10
0
 def test_team_defensive_copy(self):
     error = "Changing the member of a Team incorrectly affected the CombatTeam"
     # Not that it should be possible to change your elementals when you're in combat.
     team = TeamBuilder().build()
     combat_team = CombatTeam.from_team(team)
     team.remove_elemental(0)
     self.assertEqual(len(combat_team.elementals), 1, error)
Esempio n. 11
0
 def test_bench(self):
     error = "CombatTeam incorrectly included the active CombatElemental in bench"
     team = CombatTeam(
         [ElementalBuilder().build(),
          ElementalBuilder().build()])
     Combat([team], [], Mock())
     self.assertEqual(len(team.bench), 1, error)
     self.assertEqual(team.bench[0].id, team.elementals[0].id, error)
Esempio n. 12
0
 def create_pve_combat(player: Player) -> CombatTeam:
     if player.battles_fought < 2:
         opponent = BattleManager._tutorial_opponent(player)
     else:
         opponent = BattleManager._get_random_opponent(player)
     player_team = CombatTeam.from_team(player.team)
     Combat([player_team], [opponent], data_manager=DataManager())
     return player_team
Esempio n. 13
0
 def test_eligible_bench(self):
     error = "CombatTeam incorrectly included knocked out CombatElementals in the eligible bench"
     team = CombatTeam([
         ElementalBuilder().with_current_hp(0).build(),
         ElementalBuilder().build()
     ])
     Combat([team], [], Mock())
     self.assertEqual(len(team.eligible_bench), 0, error)
Esempio n. 14
0
 def test_skip_ko_active(self):
     error = "CombatTeam incorrectly set a 0 HP Elemental as the active Elemental"
     team = CombatTeam([
         ElementalBuilder().with_current_hp(0).build(),
         ElementalBuilder().build()
     ])
     Combat([team], [], Mock())
     self.assertGreater(team.active_elemental.current_hp, 0, error)
Esempio n. 15
0
 def test_elemental_action(self):
     error = "ElementalAction could incorrectly trigger when the elemental is KOed."
     elemental = ElementalBuilder().build()
     team = CombatTeam([elemental], PlayerBuilder().build())
     elemental.receive_damage(10000)
     action = ElementalAction(actor=team.elementals[0],
                              ability=Claw(),
                              combat=Mock())
     self.assertFalse(action.can_execute, error)
Esempio n. 16
0
 def _get_random_opponent(player: Player) -> CombatTeam:
     """
     A random encounter with an Elemental or NPC.
     """
     coin_flip = random.randint(0, 1)
     if coin_flip:
         opponent = NPCInitializer().get_random_opponent()
         opponent.generate_team(player)
         return CombatTeam.from_team(opponent.team)
     return BattleManager._get_wild_elemental(player)
Esempio n. 17
0
 def test_rolling_thunder_duration(self):
     error = "Rolling Thunder turn duration didn't decrement"
     effect = RollingThunderEffect()
     team = CombatTeam([ElementalBuilder().build()],
                       PlayerBuilder().build())
     effect.applier = team.elementals[0]
     enemy_team = CombatTeam([ElementalBuilder().build()],
                             PlayerBuilder().build())
     get_mocked_combat(team, enemy_team)
     enemy_team.add_status_effect(effect)
     duration_before = effect.rounds_remaining
     enemy_team.end_round()
     self.assertLess(effect.rounds_remaining, duration_before, error)
Esempio n. 18
0
 def test_is_npc(self):
     error = "CombatTeam didn't flag itself as NPC when its owner was an NPC"
     npc = NPCBuilder().build()
     combat_team = CombatTeam([ElementalBuilder().build()], npc)
     self.assertIs(combat_team.is_npc, True, error)
Esempio n. 19
0
 def _tutorial_opponent(player: Player) -> CombatTeam:
     if player.battles_fought == 0:
         tutorial_elemental = Tophu()
     else:
         tutorial_elemental = Manapher()
     return CombatTeam([ElementalInitializer.make(tutorial_elemental)])
Esempio n. 20
0
 def test_all_knocked_out(self):
     error = "CombatTeam.is_all_knocked_out didn't resolve correctly"
     team = CombatTeam([
         ElementalBuilder().with_current_hp(0).build(),
     ])
     self.assertIs(team.is_all_knocked_out, True, error)
Esempio n. 21
0
 def _get_wild_elemental(player: Player) -> CombatTeam:
     team_average = player.team.average_elemental_level
     min_level = team_average - 1
     max_level = team_average + player.team.size
     level = random.randint(min_level, max_level)
     return CombatTeam([ElementalInitializer.make_random(level)])
Esempio n. 22
0
def make_combat_team() -> CombatTeam:
    return CombatTeam([ElementalBuilder().build()], PlayerBuilder().build())
Esempio n. 23
0
 def get_combat_team() -> CombatTeam:
     elemental = ElementalBuilder().build()
     team = TeamBuilder().build()
     team.add_elemental(elemental)
     return CombatTeam(team)
Esempio n. 24
0
 def fight(self):
     Combat([CombatTeam(self.npc_one.team)],
            [CombatTeam(self.npc_two.team)], Mock())
Esempio n. 25
0
 def test_setup_active(self):
     error = "CombatTeam didn't assign an active CombatElemental on combat start"
     team = CombatTeam([ElementalBuilder().build()])
     Combat([team], [], Mock())
     self.assertIsInstance(team.active_elemental, CombatElemental, error)