shoddybattle
Class Pokemon

java.lang.Object
  extended by shoddybattle.PokemonSpecies
      extended by shoddybattle.Pokemon
All Implemented Interfaces:
java.io.Serializable

public class Pokemon
extends PokemonSpecies

This class represents a pokemon in a battle. Its stats are automatically modified as it attacks and is attacked, so no method for directly modifying its stats are provided. Using this class requires a BattleMechanics object to initialise its stats.

See Also:
Serialized Form

Field Summary
static int S_ACCURACY
           
static int S_ATTACK
           
static int S_DEFENCE
           
static int S_EVASION
           
static int S_HP
           
static int S_SPATTACK
           
static int S_SPDEFENCE
           
static int S_SPEED
           
 
Fields inherited from class shoddybattle.PokemonSpecies
GENDER_BOTH, GENDER_FEMALE, GENDER_MALE, GENDER_NONE, m_base, m_genders, m_name, m_species, m_type
 
Constructor Summary
Pokemon(BattleMechanics mech, PokemonSpecies species, PokemonNature nature, java.lang.String ability, java.lang.String item, int gender, int level, int[] ivs, int[] evs, MoveListEntry[] moves, int[] ppUps)
          Create and validate a new pokemon.
Pokemon(BattleMechanics mech, PokemonSpecies species, PokemonNature nature, java.lang.String ability, java.lang.String item, int gender, int level, int[] ivs, int[] evs, MoveListEntry[] moves, int[] ppUps, boolean validate)
          Creates a new instance of Pokemon
 
Method Summary
 StatusEffect addStatus(Pokemon source, StatusEffect eff)
          Add a status effect to this pokemon.
 void attachToField(BattleField field, int party, int position)
          Attach this pokemon to a battle field.
 void beginStatusTicks()
          Begin ticking effects.
 void calculateStats(int[] base, int[] ivs, int[] evs)
          Calculate stats from a given set of IVs and EVs.
 boolean canSwitch()
          Return whether this pokemon can switch.
 void changeHealth(int hp)
          Change the health of this pokemon, doing damage to a substitute if one is present.
 void changeHealth(int hp, boolean throughSubstitute)
          Change the health of this pokemon, optionally hitting through a substitute.
 boolean createSubstitute()
          Create a substitute to take hits for this pokemon.
 void dispose()
          Dispose of this object.
 void executeTurn(BattleTurn turn)
          This method is called when the pokemon is just about to execute its turn.
 void faint()
          Cause this pokemon to faint.
 IntrinsicAbility getAbility()
          Return this pokemon's ability.
 java.lang.String getAbilityName()
          Return the name of this pokemon's ability.
 StatMultiplier getAccuracy()
           
 int getCriticalHitFactor()
          Get the (additive) critical hit ability of this Pokemon.
 StatusEffect getEffect(java.lang.Class type)
          Return the effect of a particular class applied to this pokemon, or null if there is no such effect.
 StatusEffect getEffect(int lock)
          Return the effect applied to this pokemon of a particular lock or null if there is no such effect applied.
static double getEffectiveness(java.util.List statuses, PokemonType move, PokemonType pokemon, boolean enemy)
          Get the effectiveness of this pokemon attacking a particular type.
 double getEffectiveness(PokemonType move, PokemonType pokemon, boolean enemy)
           
 int getEv(int i)
           
 StatMultiplier getEvasion()
           
 BattleField getField()
          Get the field to which this pokemon is attached.
 int getGender()
          Return this Pokemon's gender.
 int getHealth()
          Get the health of this pokemon.
 int getId()
          Get this pokemon's position on the field to which it is attached.
 HoldItem getItem()
          Get this pokemon's item.
 java.lang.String getItemName()
          Return the name of this pokemon's item.
 int getIv(int i)
           
 MoveListEntry getLastMove()
          Get the last move used by this pokemon, or null if the pokemon has not used a move since it has been out.
 int getLevel()
           
 int getMaxPp(int i)
          Get a move's max pp.
 MoveListEntry getMove(int i)
          Get one of this pokemon's moves.
 java.lang.String getMoveName(int i)
          Get the name of this pokemon's moves.
 StatMultiplier getMultiplier(int i)
          Get a stat multiplier, including the ones for accuracy and evasion.
 java.lang.String getName()
          Get the display name of this pokemon (i.e.
 PokemonNature getNature()
           
 java.util.List getNormalStatuses(int lock)
          Get a list of statuses that are not special, weather, abilities, or items.
 Pokemon getOpponent()
          Get the Pokemon that this Pokemon is fighting in a battle.
 IntrinsicAbility getOriginalAbility()
          Return the original ability of this pokemon.
 int getParty()
          Get this pokemon's party.
 int getPp(int i)
          Get a move's pp.
 int getPpUpCount(int i)
          Get the number of PP Ups that have been applied to the given move slot.
static Pokemon getRandomPokemon(ModData data, BattleMechanics mech)
          Get a random Pokemon object.
 int getRawStat(int i)
           
 java.lang.String getSpeciesName()
          Get the name of this species.
 int getStat(int i)
           
 int getStat(int i, double multiplier)
           
static java.lang.String getStatName(int stat)
          Get the name of a stat.
static java.lang.String getStatShortName(int stat)
          Get the shortened name of a stat.
 java.util.List getStatusesByTier(int tier)
          Get all status effects of a certain tier.
 int getSubstitute()
          Get the health of the substitute.
 Pokemon[] getTeammates()
          Get this pokemon's teammates, including this pokemon.
 java.lang.String getTrainerName()
          Get the name of this pokemon's trainer.
protected  MoveListEntry getTransformedMove(MoveListEntry move, boolean enemy)
          Transform a move based on the status effects applied to the pokemon.
 StatusEffect getVetoingEffect(int idx)
          Return the effect that vetoes the use of a particular one of this pokemon's moves.
 boolean hasAbility(java.lang.String name)
          Return whether this pokemon has a particular ability.
 boolean hasEffect(java.lang.Class type)
          Return whether this Pokemon has a particular class of effect.
 boolean hasEffect(int lock)
          Return whether this Pokemon has a particular class of effect.
 boolean hasEffect(StatusEffect eff)
          Return whether this pokemon has a particular effect.
 boolean hasItem(java.lang.String name)
          Return whether this pokemon has a particular item.
 boolean hasSubstitute()
          Return whether this pokemon has a substitute.
 boolean isActive()
          Return whether this pokemon is active (able to choose moves and switch).
 boolean isCriticalImmune()
          Return whether this Pokemon is immune to critical hits.
 boolean isFainted()
          Determine whether this pokemon has fainted.
 boolean isFirstTurn()
          Return whether it is the pokemon's first turn out.
 boolean isImmobilised(java.lang.Class exception)
          Is this pokemon immobilised?
 boolean isShiny()
          Return whether this pokemon is shiny.
 boolean isType(PokemonType type)
          Return whether a pokemon is a particular type.
 boolean mustStruggle()
          Return whether this pokemon must struggle if it wants to use a move.
 void removeStatus(java.lang.Class type)
          Remove statuses by class type.
 void removeStatus(int lock)
          Remove a class of statuses from this pokemon.
 void removeStatus(StatusEffect eff)
          Remove a status effect from this pokemon.
 void setAbility(IntrinsicAbility abl, boolean ignoreTransferability)
          Set this pokemon's ability.
 void setItem(HoldItem item)
          Set this pokemon's item.
 void setName(java.lang.String name)
          Set this pokemon's name.
 void setPp(int i, int value)
          Set a move's pp.
 void setRawStat(int i, int newStat)
           
 void setShiny(boolean shiny)
          Set whether this pokemon is shiny.
 void setSubstitute(int hp)
          Set the health of the substitute.
 void switchIn()
          Switch in this pokemon.
 void switchOut()
          Switch out this pokemon.
 void synchroniseStatuses()
          Remove status effects that have ended.
 int useMove(int i, Pokemon target)
          Use one of this pokemon's intrinsic moves.
 int useMove(MoveListEntry move, Pokemon target)
          Use a a move from the move list (so its name is known and displayed).
 int useMove(PokemonMove move, Pokemon target)
          Check for accuracy and then use an arbitrary move.
 void validate(ModData data)
          Validate this pokemon.
 
Methods inherited from class shoddybattle.PokemonSpecies
canLearn, canUseAbility, getBase, getBaseStats, getDefaultData, getLearnableMoves, getMoveSet, getPossibleAbilities, getPossibleGenders, getTypes, readObject, setDefaultData, setPossibleGenders, setType
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

S_HP

public static final int S_HP
See Also:
Constant Field Values

S_ATTACK

public static final int S_ATTACK
See Also:
Constant Field Values

S_DEFENCE

public static final int S_DEFENCE
See Also:
Constant Field Values

S_SPEED

public static final int S_SPEED
See Also:
Constant Field Values

S_SPATTACK

public static final int S_SPATTACK
See Also:
Constant Field Values

S_SPDEFENCE

public static final int S_SPDEFENCE
See Also:
Constant Field Values

S_ACCURACY

public static final int S_ACCURACY
See Also:
Constant Field Values

S_EVASION

public static final int S_EVASION
See Also:
Constant Field Values
Constructor Detail

Pokemon

public Pokemon(BattleMechanics mech,
               PokemonSpecies species,
               PokemonNature nature,
               java.lang.String ability,
               java.lang.String item,
               int gender,
               int level,
               int[] ivs,
               int[] evs,
               MoveListEntry[] moves,
               int[] ppUps,
               boolean validate)
        throws StatException
Creates a new instance of Pokemon

Throws:
StatException

Pokemon

public Pokemon(BattleMechanics mech,
               PokemonSpecies species,
               PokemonNature nature,
               java.lang.String ability,
               java.lang.String item,
               int gender,
               int level,
               int[] ivs,
               int[] evs,
               MoveListEntry[] moves,
               int[] ppUps)
        throws StatException
Create and validate a new pokemon.

Throws:
StatException
Method Detail

createSubstitute

public boolean createSubstitute()
Create a substitute to take hits for this pokemon.


setSubstitute

public void setSubstitute(int hp)
Set the health of the substitute.


getSubstitute

public int getSubstitute()
Get the health of the substitute.


hasSubstitute

public boolean hasSubstitute()
Return whether this pokemon has a substitute.


dispose

public void dispose()
Dispose of this object.


getStatName

public static java.lang.String getStatName(int stat)
Get the name of a stat.


getStatShortName

public static java.lang.String getStatShortName(int stat)
Get the shortened name of a stat.


getRandomPokemon

public static Pokemon getRandomPokemon(ModData data,
                                       BattleMechanics mech)
Get a random Pokemon object.


setShiny

public void setShiny(boolean shiny)
Set whether this pokemon is shiny.


isShiny

public boolean isShiny()
Return whether this pokemon is shiny.


getGender

public int getGender()
Return this Pokemon's gender.


getAbilityName

public java.lang.String getAbilityName()
Return the name of this pokemon's ability.


getAbility

public IntrinsicAbility getAbility()
Return this pokemon's ability.


setAbility

public void setAbility(IntrinsicAbility abl,
                       boolean ignoreTransferability)
Set this pokemon's ability. If ignoreTransferability is true then the isTransferrable() method of the ability is ignored. Otherwise it is respected.


getItemName

public java.lang.String getItemName()
Return the name of this pokemon's item.


getItem

public HoldItem getItem()
Get this pokemon's item.


setItem

public void setItem(HoldItem item)
Set this pokemon's item.


validate

public void validate(ModData data)
              throws ValidationException
Validate this pokemon.

Throws:
ValidationException

getPpUpCount

public int getPpUpCount(int i)
Get the number of PP Ups that have been applied to the given move slot.


calculateStats

public void calculateStats(int[] base,
                           int[] ivs,
                           int[] evs)
Calculate stats from a given set of IVs and EVs. The data given are assumed to be valid; no checking is done for illegal values in this function.


getTeammates

public Pokemon[] getTeammates()
Get this pokemon's teammates, including this pokemon.


getTrainerName

public java.lang.String getTrainerName()
Get the name of this pokemon's trainer.


getOpponent

public Pokemon getOpponent()
Get the Pokemon that this Pokemon is fighting in a battle.


isType

public boolean isType(PokemonType type)
Return whether a pokemon is a particular type.


getCriticalHitFactor

public int getCriticalHitFactor()
Get the (additive) critical hit ability of this Pokemon.


isCriticalImmune

public boolean isCriticalImmune()
Return whether this Pokemon is immune to critical hits.


setPp

public void setPp(int i,
                  int value)
Set a move's pp.


getPp

public int getPp(int i)
Get a move's pp.


getMaxPp

public int getMaxPp(int i)
Get a move's max pp.


getMove

public MoveListEntry getMove(int i)
Get one of this pokemon's moves.


executeTurn

public void executeTurn(BattleTurn turn)
This method is called when the pokemon is just about to execute its turn.

Parameters:
turn - the turn that is about to be executed

isFirstTurn

public boolean isFirstTurn()
Return whether it is the pokemon's first turn out.


switchIn

public void switchIn()
Switch in this pokemon.


getOriginalAbility

public IntrinsicAbility getOriginalAbility()
Return the original ability of this pokemon.


switchOut

public void switchOut()
Switch out this pokemon.


getVetoingEffect

public StatusEffect getVetoingEffect(int idx)
                              throws MoveQueueException
Return the effect that vetoes the use of a particular one of this pokemon's moves.

Throws:
MoveQueueException

hasEffect

public boolean hasEffect(StatusEffect eff)
Return whether this pokemon has a particular effect.


hasEffect

public boolean hasEffect(int lock)
Return whether this Pokemon has a particular class of effect.


getEffect

public StatusEffect getEffect(int lock)
Return the effect applied to this pokemon of a particular lock or null if there is no such effect applied.


getEffect

public StatusEffect getEffect(java.lang.Class type)
Return the effect of a particular class applied to this pokemon, or null if there is no such effect.


hasEffect

public boolean hasEffect(java.lang.Class type)
Return whether this Pokemon has a particular class of effect.


hasAbility

public boolean hasAbility(java.lang.String name)
Return whether this pokemon has a particular ability.


hasItem

public boolean hasItem(java.lang.String name)
Return whether this pokemon has a particular item.


isActive

public boolean isActive()
Return whether this pokemon is active (able to choose moves and switch).


getSpeciesName

public java.lang.String getSpeciesName()
Get the name of this species.


setName

public void setName(java.lang.String name)
Set this pokemon's name.

Overrides:
setName in class PokemonSpecies

getName

public java.lang.String getName()
Get the display name of this pokemon (i.e. its nickname).

Overrides:
getName in class PokemonSpecies

getStatusesByTier

public java.util.List getStatusesByTier(int tier)
Get all status effects of a certain tier.


getNormalStatuses

public java.util.List getNormalStatuses(int lock)
Get a list of statuses that are not special, weather, abilities, or items.

Parameters:
lock - status lock to allow

canSwitch

public boolean canSwitch()
Return whether this pokemon can switch.


beginStatusTicks

public void beginStatusTicks()
Begin ticking effects.


synchroniseStatuses

public void synchroniseStatuses()
Remove status effects that have ended.


removeStatus

public void removeStatus(StatusEffect eff)
Remove a status effect from this pokemon.


removeStatus

public void removeStatus(int lock)
Remove a class of statuses from this pokemon.


removeStatus

public void removeStatus(java.lang.Class type)
Remove statuses by class type.


attachToField

public void attachToField(BattleField field,
                          int party,
                          int position)
Attach this pokemon to a battle field. Additionally, initialise this pokemon's held item and ability.


getParty

public int getParty()
Get this pokemon's party. This will be in the range [0, parties - 1] where parties is the number of parties on the battle field (probably two).


getId

public int getId()
Get this pokemon's position on the field to which it is attached.


getField

public BattleField getField()
Get the field to which this pokemon is attached.


getMoveName

public java.lang.String getMoveName(int i)
Get the name of this pokemon's moves.


isFainted

public boolean isFainted()
Determine whether this pokemon has fainted.


getEffectiveness

public static double getEffectiveness(java.util.List statuses,
                                      PokemonType move,
                                      PokemonType pokemon,
                                      boolean enemy)
Get the effectiveness of this pokemon attacking a particular type.


getEffectiveness

public double getEffectiveness(PokemonType move,
                               PokemonType pokemon,
                               boolean enemy)

isImmobilised

public boolean isImmobilised(java.lang.Class exception)
Is this pokemon immobilised?

Parameters:
exception - status not to check for

getTransformedMove

protected MoveListEntry getTransformedMove(MoveListEntry move,
                                           boolean enemy)
Transform a move based on the status effects applied to the pokemon.

Parameters:
enemy - whether this Pokemon is an enemy

getLastMove

public MoveListEntry getLastMove()
Get the last move used by this pokemon, or null if the pokemon has not used a move since it has been out.


useMove

public int useMove(int i,
                   Pokemon target)
Use one of this pokemon's intrinsic moves.


useMove

public int useMove(MoveListEntry move,
                   Pokemon target)
Use a a move from the move list (so its name is known and displayed).


useMove

public int useMove(PokemonMove move,
                   Pokemon target)
Check for accuracy and then use an arbitrary move.


changeHealth

public void changeHealth(int hp)
Change the health of this pokemon, doing damage to a substitute if one is present.


changeHealth

public void changeHealth(int hp,
                         boolean throughSubstitute)
Change the health of this pokemon, optionally hitting through a substitute.


faint

public void faint()
Cause this pokemon to faint.


getHealth

public int getHealth()
Get the health of this pokemon.


mustStruggle

public boolean mustStruggle()
Return whether this pokemon must struggle if it wants to use a move.


addStatus

public StatusEffect addStatus(Pokemon source,
                              StatusEffect eff)
Add a status effect to this pokemon.


getNature

public PokemonNature getNature()

getAccuracy

public StatMultiplier getAccuracy()

getEvasion

public StatMultiplier getEvasion()

getLevel

public int getLevel()

getIv

public int getIv(int i)
          throws StatException
Throws:
StatException

getEv

public int getEv(int i)
          throws StatException
Throws:
StatException

getMultiplier

public StatMultiplier getMultiplier(int i)
                             throws StatException
Get a stat multiplier, including the ones for accuracy and evasion.

Throws:
StatException

getRawStat

public int getRawStat(int i)

setRawStat

public void setRawStat(int i,
                       int newStat)

getStat

public int getStat(int i,
                   double multiplier)

getStat

public int getStat(int i)