Package org.jpokemon.battle.turn

Source Code of org.jpokemon.battle.turn.RunTurn

package org.jpokemon.battle.turn;

import org.jpokemon.battle.Battle;
import org.jpokemon.battle.slot.Slot;
import org.jpokemon.server.PlayerManager;
import org.jpokemon.trainer.Player;

public class RunTurn extends Turn {
  public RunTurn(Battle b, Slot user) {
    super(b, user, user);
  }

  @Override
  public void execute() {
    Battle battle = (Battle) PlayerManager.getActivity((Player) slot().trainer());
    double chance = 100;

    for (Slot s : battle) {
      if (slot().leader().level() < s.leader().level())
        chance -= 10 * (s.leader().level() - slot().leader().level());
      else if (slot().leader().level() > s.leader().level()) chance += 7 * (slot().leader().level() - s.leader().level());
    }

    if ((chance / 250.0) > Math.random()) {
      // Message message = new Message("SPEECH", "Got away safely!", Message.Level.MESSAGE);
      // PlayerManager.pushMessage((Player) slot().trainer(), message);
      battle.remove(slot().trainer());
    }
    else
      battle().log("Didn't get away!");
  }

  @Override
  public boolean reAdd() {
    return false;
  }

  @Override
  public int compareTo(Turn turn) {
    if (turn instanceof RunTurn) return 0;

    return -1;
  }
}
TOP

Related Classes of org.jpokemon.battle.turn.RunTurn

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.