예제 #1
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)
예제 #2
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)
예제 #3
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
예제 #4
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)
예제 #5
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)