_executions = 0;
}
@Override
public void execute() {
Pokemon leader = slot().leader();
_executions++;
if (_executions == 1) {
for (ConditionEffect conditionEffect : leader.getConditionEffects()) {
if (conditionEffect.blocksAttack()) {
battle().log(leader.name() + conditionEffect.getPersistanceMessage());
return;
}
}
if (!_move.enabled()) {
battle().log(leader.name() + " cannot use " + _move.name() + ". It's not enabled");
return;
}
else if (!_move.use()) {
battle().log(leader.name() + " tried to use " + _move.name() + ", but it missed");
if (_move.hurtUserOnMiss()) {
int d = Battle.computeDamage(leader, _move, target().leader()) / 8;
slot().takeDamage(d);
battle().log(leader.name() + " took " + d + " recoil damage");
}
return;
}
}
battle().log(slot().trainer().id() + "'s " + slot().leader().name() + " used " + _move.name());
if (_move.style() == MoveStyle.DELAYNEXT && _executions != 1) {
battle().log(slot().trainer().id() + "'s " + slot().leader().name() + " is resting this turn");
return;
}
if (_move.style() == MoveStyle.DELAYBEFORE && _executions != _move.turns()) {
battle().log(slot().trainer().id() + "'s " + slot().leader().name() + " is resting this turn");
return;
}
if (_move.style() == MoveStyle.OHKO) {
int levelDiff = leader.level() - target().leader().level();
if (levelDiff < 0 || (levelDiff + 30.0) / 100.0 <= Math.random()) {
battle().log(leader.name() + " tried to use " + _move.name() + ", but it missed");
return;
}
}
if (_move.style() == MoveStyle.MISC) { // TODO MoveStyle.MISC execution
battle().log(_move.name() + " doesn't work yet. Sorry about that!");