Ejemplo n.º 1
0
    def initiate_battle_turn(player: int) -> str:
        gs = GameState.get_instance()
        players = gs.get_battle_players(player)
        aktivep1 = PlayerLogic.get_by_team_position(players[0])
        aktivep2 = PlayerLogic.get_by_team_position(players[1])
        dmgp1 = AttackLogic._calculate_damage(aktivep1, aktivep2,
                                              gs.get_queued_attack(players[0]))
        dmgp2 = AttackLogic._calculate_damage(aktivep2, aktivep1,
                                              gs.get_queued_attack(players[1]))

        gs.reset_queued_attacks(players[0], players[1])
        return AttackLogic._battle_order(aktivep1, aktivep2, players, dmgp1,
                                         dmgp2)
Ejemplo n.º 2
0
    def player_attack_input(player: int, attack: Attack) -> str:
        gs = GameState.get_instance()
        if PlayerLogic.get_by_team_position(player).current_hp == 0:
            raise InputError(
                "please use the choose command, your current Pokemon is knocked out!"
            )
        gs.set_battle_input(player, attack)

        if gs.is_player_battle(player) and gs.are_battle_instructions_complete(
                player):
            return AttackLogic.initiate_battle_turn(player)
        elif gs.is_wild_battle(player):
            return AttackLogic.wild_battle_turn(player)
        return "AttackInput saved"
Ejemplo n.º 3
0
    def wild_battle_turn(player):
        gs = GameState.get_instance()
        aktivep = PlayerLogic.get_by_team_position(player)
        wild = gs.get_current_wild_pokemon()
        dmgp1 = AttackLogic._calculate_damage(aktivep, wild,
                                              gs.get_queued_attack(player))
        dmgp2 = AttackLogic._calculate_damage(
            wild, aktivep,
            gs.get_attacks_for_wild_pokemon()[random.randint(0, 3)].attack)

        gs.reset_queued_attacks_wild(player)

        return AttackLogic._battle_order_bot(aktivep, wild,
                                             (player, wild.player_id), dmgp1,
                                             dmgp2)
Ejemplo n.º 4
0
 async def attack(self, ctx, AttackName: str):
     """uses the specified attack of the active pokemon and ends your turn"""
     try:
         if PlayerLogic.is_in_battle(ctx.message.author.id):
             aktive = PlayerLogic.get_by_team_position(ctx.message.author.id)
             attacks = AttackLogic.get_attacks(aktive)
             for a in attacks:
                 if a.attack.attack_name == AttackName:
                     await ctx.channel.send(f"```{aktive.pokemon.pokemon_name} is using {a.attack.attack_name}!```")
                     await ctx.channel.send("```"+AttackLogic.player_attack_input(ctx.message.author.id, a.attack)+"```")
                     return
             await ctx.channel.send("```no such attack```")
         else:
             await ctx.channel.send("```You can´t use this command while not in battle.```")
     except InputError as err:
         await ctx.channel.send(err.message)
Ejemplo n.º 5
0
 async def choose(self, ctx, PokemonTeamNumber: int):
     """swaps in the specified pokemon after the current one got knocked out"""
     if PlayerLogic.is_in_battle(ctx.message.author.id) and PlayerLogic.is_aktive_pokemon_knocked_out(
             ctx.message.author.id):
         try:
             if PokemonTeamNumber == 1:
                 await ctx.channel.send("```Pokemon is already leading your Party!```")
             else:
                 PlayerLogic.set_active_pokemon(ctx.message.author.id, 1, PokemonTeamNumber)
         except (NotAPlayerException, InputError, DatabaseException) as err:
             await ctx.channel.send(err.message)
         newA = PlayerLogic.get_by_team_position(ctx.message.author.id)
         await ctx.channel.send(f"```Give it your all {newA.pokemon.pokemon_name}```")
     else:
         await ctx.channel.send("```You can not use this command while not in battle or not having your lead "
                                "pokemon knocked out.```")
Ejemplo n.º 6
0
 def use_item(player_id: int, item_name: str, team_position: int) ->ItemUseResult:
     """uses the specified item on the pokemon at the specified team position."""
     player = PlayerLogic.get_player_by_id(player_id)
     item = ItemLogic.get_item_by_name(item_name)
     player_pokemon = PlayerLogic.get_by_team_position(player_id)
     gs = GameState.get_instance()
     if gs.is_player_in_combat(player.player_id):
         if ItemLogic.is_heal_item(item_name):
             if player_pokemon.current_hp > 0:
                 raise PokemonAlreadyKnockedOutException()
             else:
                 heal_item = ItemLogic.get_heal_item(item.name)
                 if not ItemLogic.has_item(item.item_name, player.player_id):
                     raise NotEnoughItemsException(item.item_name, 1)
                 if player_pokemon.current_hp <= 0:
                     raise PokemonAlreadyKnockedOutException()
                 PokemonLogic.heal(player_pokemon, heal_item.healing_amount)
                 ItemLogic._consume_item(player, item)
                 return ItemUseResult(heal_item.healing_amount, None)
         else:
             raise CurrentlyInBattleException("use " + item.item_name)
     else:
         if ItemLogic.is_heal_item(item.item_name):
             if player_pokemon.current_hp <= 0:
                 raise PokemonAlreadyKnockedOutException()
             else:
                 heal_item = ItemLogic.get_heal_item(item.name)
                 if not ItemLogic.has_item(item.item_name, player.player_id):
                     raise NotEnoughItemsException(item.item_name, 1)
                 PokemonLogic.heal(player_pokemon, heal_item)
                 ItemLogic._consume_item(player, item)
                 return ItemUseResult(heal_item.healing_amount, None)
         elif ItemLogic.is_evolution_stone(item.item_name):
             if not ItemLogic.has_item(item.item_name, player.player_id):
                 raise NotEnoughItemsException(item.item_name, 1)
             old_pokemon = player_pokemon.pokemon
             res = PokemonLogic.item_evolve(player_pokemon,item)
             ItemLogic._consume_item(player,item)
             return ItemUseResult(evolution_start=old_pokemon, evolution_result=res.pokemon)
         else:
             raise NotAnAppropriateItemException(item.item_name)
Ejemplo n.º 7
0
 def gain_xp(player) -> int:
     return PokemonLogic.add_xp(PlayerLogic.get_by_team_position(player), random.randint(100, 500))