Search in sources :

Example 1 with PokemonMove

use of POGOProtos.Enums.PokemonMoveOuterClass.PokemonMove in project PokeGOAPI-Java by Grover-c13.

the class Battle method attackSpecial.

/**
	 * Performs a special attack action
	 *
	 * @return the duration of this attack
	 */
public int attackSpecial() {
    PokemonData pokemon = activeAttacker.getPokemon();
    PokemonMove move = pokemon.getMove2();
    MoveSettingsOuterClass.MoveSettings moveSettings = PokemonMeta.getMoveSettings(move);
    int duration = moveSettings.getDurationMs();
    if (activeAttacker.getEnergy() >= -moveSettings.getEnergyDelta()) {
        long time = api.currentTimeMillis();
        ClientAction action = new ClientAction(BattleActionType.ACTION_SPECIAL_ATTACK, time, duration);
        action.setDamageWindow(moveSettings.getDamageWindowStartMs(), moveSettings.getDamageWindowEndMs());
        queuedActions.add(action);
        return duration;
    } else {
        throw new RuntimeException("Not enough energy to use special attack!");
    }
}
Also used : PokemonMove(POGOProtos.Enums.PokemonMoveOuterClass.PokemonMove) MoveSettingsOuterClass(POGOProtos.Settings.Master.MoveSettingsOuterClass) PokemonData(POGOProtos.Data.PokemonDataOuterClass.PokemonData)

Example 2 with PokemonMove

use of POGOProtos.Enums.PokemonMoveOuterClass.PokemonMove in project PokeGOAPI-Java by Grover-c13.

the class FightGymExample method handleAttack.

private static void handleAttack(Battle battle) throws InterruptedException {
    int duration;
    PokemonMove specialMove = battle.getActiveAttacker().getPokemon().getMove2();
    MoveSettingsOuterClass.MoveSettings moveSettings = PokemonMeta.getMoveSettings(specialMove);
    //Check if we have sufficient energy to perform a special attack
    int energy = battle.getActiveAttacker().getEnergy();
    int desiredEnergy = -moveSettings.getEnergyDelta();
    if (energy <= desiredEnergy) {
        duration = battle.attack();
    } else {
        duration = battle.attackSpecial();
    }
    //Attack and sleep for the duration of the attack + some extra time
    Thread.sleep(duration + (long) (Math.random() * 10));
}
Also used : PokemonMove(POGOProtos.Enums.PokemonMoveOuterClass.PokemonMove) MoveSettingsOuterClass(POGOProtos.Settings.Master.MoveSettingsOuterClass) Point(com.pokegoapi.api.map.Point)

Example 3 with PokemonMove

use of POGOProtos.Enums.PokemonMoveOuterClass.PokemonMove in project PokeGOAPI-Java by Grover-c13.

the class Battle method attack.

/**
	 * Performs an attack action
	 *
	 * @return the duration of this attack
	 */
public int attack() {
    PokemonData pokemon = activeAttacker.getPokemon();
    PokemonMove move = pokemon.getMove1();
    MoveSettingsOuterClass.MoveSettings moveSettings = PokemonMeta.getMoveSettings(move);
    int duration = moveSettings.getDurationMs();
    long time = api.currentTimeMillis();
    ClientAction action = new ClientAction(BattleActionType.ACTION_ATTACK, time, duration);
    action.setDamageWindow(moveSettings.getDamageWindowStartMs(), moveSettings.getDamageWindowEndMs());
    queuedActions.add(action);
    return duration;
}
Also used : PokemonMove(POGOProtos.Enums.PokemonMoveOuterClass.PokemonMove) MoveSettingsOuterClass(POGOProtos.Settings.Master.MoveSettingsOuterClass) PokemonData(POGOProtos.Data.PokemonDataOuterClass.PokemonData)

Aggregations

PokemonMove (POGOProtos.Enums.PokemonMoveOuterClass.PokemonMove)3 MoveSettingsOuterClass (POGOProtos.Settings.Master.MoveSettingsOuterClass)3 PokemonData (POGOProtos.Data.PokemonDataOuterClass.PokemonData)2 Point (com.pokegoapi.api.map.Point)1