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!");
}
}
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));
}
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;
}
Aggregations