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)
Exemple #2
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
 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)
 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)
 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)
Exemple #6
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)
 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)
Exemple #8
0
 def test_cast_execution_recap(self):
     error = "Recap for execution of a cast was incorrect"
     team_a = make_combat_team()
     team_b = make_combat_team()
     combat = Combat([team_a], [team_b], Mock())
     team_a.handle_cast_time(Castable(ShiningLaser()))
     team_b.make_move(Claw())
     team_b.make_move(Claw())
     turn_logs = combat.turn_logger.logs[-2]
     self.assertIn("used Shining Laser!", turn_logs[0].recap, error)
     self.assertIn("used Shining Laser!", turn_logs[1].recap, error)
 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)
Exemple #10
0
 def test_channel_recap(self):
     error = "Recap for the execution of a channeled ability was incorrect"
     team_a = make_combat_team()
     team_b = make_combat_team()
     combat = Combat([team_a], [team_b], Mock())
     team_a.make_move(Rampage())
     team_b.make_move(Claw())
     team_b.make_move(Claw())
     elemental = team_a.active_elemental
     turn_logs = combat.turn_logger.logs[-2]
     self.assertEqual(f"{elemental.nickname}'s Rampage continues!", turn_logs[0].recap, error)
     self.assertEqual(f"{elemental.nickname}'s Rampage continues!", turn_logs[1].recap, error)
Exemple #11
0
 def fight(self):
     Combat([CombatTeam(self.npc_one.team)],
            [CombatTeam(self.npc_two.team)], Mock())
def get_mocked_combat(team_a=None, team_b=None) -> Combat:
    return Combat([team_a or make_combat_team()],
                  [team_b or make_combat_team()],
                  data_manager=Mock())
Exemple #13
0
 def get_mocked_combat() -> Combat:
     return Combat(data_manager=Mock())
Exemple #14
0
 def get_mocked_combat() -> Combat:
     combat = Combat([], [], data_manager=Mock())
     combat.get_target = MagicMock(
         return_value=CombatElementalBuilder().build())
     return combat
 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)