mechanics
Class BattleMechanics

java.lang.Object
  extended by mechanics.BattleMechanics
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
AdvanceMechanics

public abstract class BattleMechanics
extends java.lang.Object
implements java.io.Serializable

This class represents the mechanics for a battle in a particular generation of pokemon. Derive classes from this class to implement a desired generation.

See Also:
Serialized Form

Constructor Summary
BattleMechanics(int bytes)
          Initialise an instance of the mechanics.
 
Method Summary
abstract  boolean attemptHit(PokemonMove move, Pokemon user, Pokemon target)
          Randomly decide whether a move hits.
 int calculateDamage(PokemonMove move, Pokemon attacker, Pokemon defender)
          Calculate the damage done by a move.
abstract  int calculateDamage(PokemonMove move, Pokemon attacker, Pokemon defender, boolean silent)
          Calculate the damage done by a move.
abstract  int calculateStat(Pokemon p, int i)
          Calculate the initial value of a stat from a pokemon's base stats and hidden stats.
 java.util.Random getRandom()
          Get an instance of the Random class.
static byte[] getRandomBytes(int number)
          Get random bytes using the Crypto API on Windows.
static java.util.Random getRandomSource(int bytes)
          Initialise the battle mechanics.
abstract  boolean isMoveSpecial(PokemonMove move)
          Return whether a given move deals special damage.
abstract  void validateHiddenStats(Pokemon p)
          Validate the hidden stats of a pokemon.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BattleMechanics

public BattleMechanics(int bytes)
Initialise an instance of the mechanics.

Method Detail

calculateStat

public abstract int calculateStat(Pokemon p,
                                  int i)
                           throws StatException
Calculate the initial value of a stat from a pokemon's base stats and hidden stats.

Parameters:
p - the pokemon whose stats to calculate
i - the stat to calculate (use the constants Pokemon.S_HP, etc.)
Throws:
StatException

validateHiddenStats

public abstract void validateHiddenStats(Pokemon p)
                                  throws ValidationException
Validate the hidden stats of a pokemon.

Throws:
ValidationException

attemptHit

public abstract boolean attemptHit(PokemonMove move,
                                   Pokemon user,
                                   Pokemon target)
Randomly decide whether a move hits.


calculateDamage

public abstract int calculateDamage(PokemonMove move,
                                    Pokemon attacker,
                                    Pokemon defender,
                                    boolean silent)
Calculate the damage done by a move. Does not actually inflict damage to pokemon. Optionally do not display any messages.


calculateDamage

public int calculateDamage(PokemonMove move,
                           Pokemon attacker,
                           Pokemon defender)
Calculate the damage done by a move. Does not actually inflict damage to pokemon.


isMoveSpecial

public abstract boolean isMoveSpecial(PokemonMove move)
Return whether a given move deals special damage.


getRandom

public final java.util.Random getRandom()
Get an instance of the Random class.


getRandomBytes

public static byte[] getRandomBytes(int number)
Get random bytes using the Crypto API on Windows.


getRandomSource

public static java.util.Random getRandomSource(int bytes)
Initialise the battle mechanics. Try to use the SecureRandom class for the random number generator, with a seed from /dev/random. However, if /dev/random is unavailable (e.g. if we are running on Windows) then an instance of Random, seeded from the time, is used instead. For best results, use an operating system that supports /dev/random.