com.planet_ink.coffee_mud.Common
Class DefaultCharState

java.lang.Object
  extended by com.planet_ink.coffee_mud.Common.DefaultCharState
All Implemented Interfaces:
CharState, CMCommon, CMObject, Modifiable, java.lang.Cloneable, java.lang.Comparable<CMObject>

public class DefaultCharState
extends java.lang.Object
implements CharState


Field Summary
protected  int annoyanceTicker
           
protected  int botherCycle
           
protected  long Fatigue
           
protected  int[] states
           
protected  int ticksHungry
           
protected  int ticksThirsty
           
 
Fields inherited from interface com.planet_ink.coffee_mud.Common.interfaces.CharState
ADJUST_FACTOR, ANNOYANCE_DEFAULT_TICKS, DEATH_HUNGER_TICKS, DEATH_THIRST_TICKS, FATIGUED_EXHAUSTED_MILLIS, FATIGUED_MILLIS, REST_PER_TICK, STAT_HITPOINTS, STAT_HUNGER, STAT_MANA, STAT_MOVE, STAT_NUM_BASE_STATS, STAT_NUMSTATS, STAT_THIRST
 
Constructor Summary
DefaultCharState()
           
 
Method Summary
 boolean adjFatigue(long byThisMuch, CharState max)
          Set the number of fatigue points, respecting boundaries.
 boolean adjHitPoints(int byThisMuch, CharState max)
          Set the number of hit points, respecting boundaries.
 boolean adjHunger(int byThisMuch, int max)
          Set the number of hunger points, respecting boundaries.
 boolean adjMana(int byThisMuch, CharState max)
          Set the number of mana points, respecting boundaries.
 boolean adjMovement(int byThisMuch, CharState max)
          Set the number of movement points, respecting boundaries.
 boolean adjThirst(int byThisMuch, int max)
          Set the number of thirst points, respecting boundaries.
 int compareTo(CMObject o)
           
 void copyInto(CharState intoState)
          Copies the internal data of this object into another of kind.
 CMObject copyOf()
          Similar to Cloneable.clone(), but does its best to make sure that any internal objects to this class are also copyOfed.
 void expendEnergy(MOB mob, CharState maxState, boolean expendMovement)
          During movement and combat, this method will be called to allow the movement to be expended and hunger/thirst to occur.
protected  int getCodeNum(java.lang.String code)
           
 java.lang.String getCombatStats()
          Get primary combat stats as displayable code string
 long getFatigue()
          Get the number of fatigue points for the player
 int getHitPoints()
          Get the number of hit points for the player
 int getHunger()
          Get the number of hunger points for the player
 int getMana()
          Get the number of mana points for the player
 int getMovement()
          Get the number of movement points for the player
 int getSaveStatIndex()
          Returns the index into the stat codes array where extra savable fields begins.
 java.lang.String getStat(java.lang.String code)
          An alternative means of retreiving the values of those fields on this object which are modifiable at run-time by builders.
 java.lang.String[] getStatCodes()
          Returns an array of the string names of those fields which are modifiable on this object at run-time by builders.
 int getThirst()
          Get the number of thirst points for the player
 java.lang.String ID()
          The CoffeeMud Java Class ID shared by all instances of this object.
 void initializeClass()
          Called ONCE after all objects are loaded, but before the map is read in during initialization.
 boolean isStat(java.lang.String code)
          An alternative means of retreiving the values of those fields on this object which are modifiable at run-time by builders.
 int maxHunger(int baseWeight)
          This method is used to recalculate the maximum thirhungerst for a mob, based on their weight and the default maximum hunger
 int maxThirst(int baseWeight)
          This method is used to recalculate the maximum thirst for a mob, based on their weight and the default maximum thirst
 CMObject newInstance()
          Returns a new instance of this class.
 void recoverTick(MOB mob, CharState maxState)
          During rest, and even standing still, this method will be called to allow the fields in this object to recover some of their value.
 boolean sameAs(CharState E)
          Whether this object instance is functionally identical to the object passed in.
 void setAllValues(int def)
          Sets all the values in this object to a single given value
 void setFatigue(long newVal)
          Set the number of fatigue points
 void setHitPoints(int newVal)
          Set the number of hit points
 void setHunger(int newVal)
          Set the number of hunger points
 void setMana(int newVal)
          Set the number of mana points
 void setMovement(int newVal)
          Set the number of movement points
 void setStat(java.lang.String code, java.lang.String val)
          An alternative means of setting the values of those fields on this object which are modifiable at run-time by builders.
 void setThirst(int newVal)
          Set the number of thirst points
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

states

protected int[] states

Fatigue

protected long Fatigue

botherCycle

protected int botherCycle

ticksHungry

protected int ticksHungry

ticksThirsty

protected int ticksThirsty

annoyanceTicker

protected int annoyanceTicker
Constructor Detail

DefaultCharState

public DefaultCharState()
Method Detail

ID

public java.lang.String ID()
Description copied from interface: CMObject
The CoffeeMud Java Class ID shared by all instances of this object. Unlike the Java Class name, this method does not include package information. However, it must return a String value unique to its class category in the ClassLoader. Class categories include Libraries, Common, Areas, Abilities, Behaviors, CharClasses, Commands, Exits Locales, MOBS, Races, WebMacros, Basic Items, Armor, Weapons, ClanItems, MiscTech. The name is typically identical to the class name.

Specified by:
ID in interface CMObject
Returns:
the name of this class

newInstance

public CMObject newInstance()
Description copied from interface: CMObject
Returns a new instance of this class.

Specified by:
newInstance in interface CMObject
Returns:
a new instance of this class

initializeClass

public void initializeClass()
Description copied from interface: CMObject
Called ONCE after all objects are loaded, but before the map is read in during initialization.

Specified by:
initializeClass in interface CMObject

setAllValues

public void setAllValues(int def)
Description copied from interface: CharState
Sets all the values in this object to a single given value

Specified by:
setAllValues in interface CharState
Parameters:
def - the value to give to all

copyInto

public void copyInto(CharState intoState)
Description copied from interface: CharState
Copies the internal data of this object into another of kind.

Specified by:
copyInto in interface CharState
Parameters:
intoState - another CharState object.

getHitPoints

public int getHitPoints()
Description copied from interface: CharState
Get the number of hit points for the player

Specified by:
getHitPoints in interface CharState
Returns:
number of hit points

setHitPoints

public void setHitPoints(int newVal)
Description copied from interface: CharState
Set the number of hit points

Specified by:
setHitPoints in interface CharState
Parameters:
newVal - number of hit points

adjHitPoints

public boolean adjHitPoints(int byThisMuch,
                            CharState max)
Description copied from interface: CharState
Set the number of hit points, respecting boundaries. 0 is always lowest.

Specified by:
adjHitPoints in interface CharState
Parameters:
byThisMuch - a positive or negative change in value
max - the highest amount to allow the hit points number to reach
Returns:
whether the highest or lowest boundary was reached

getFatigue

public long getFatigue()
Description copied from interface: CharState
Get the number of fatigue points for the player

Specified by:
getFatigue in interface CharState
Returns:
number of fatigue points

setFatigue

public void setFatigue(long newVal)
Description copied from interface: CharState
Set the number of fatigue points

Specified by:
setFatigue in interface CharState
Parameters:
newVal - number of fatigue points

adjFatigue

public boolean adjFatigue(long byThisMuch,
                          CharState max)
Description copied from interface: CharState
Set the number of fatigue points, respecting boundaries. 0 is always lowest.

Specified by:
adjFatigue in interface CharState
Parameters:
byThisMuch - a positive or negative change in value
max - the highest amount to allow the fatigue number to reach
Returns:
whether the highest or lowest boundary was reached

getHunger

public int getHunger()
Description copied from interface: CharState
Get the number of hunger points for the player

Specified by:
getHunger in interface CharState
Returns:
number of hunger points

setHunger

public void setHunger(int newVal)
Description copied from interface: CharState
Set the number of hunger points

Specified by:
setHunger in interface CharState
Parameters:
newVal - number of hunger points

adjHunger

public boolean adjHunger(int byThisMuch,
                         int max)
Description copied from interface: CharState
Set the number of hunger points, respecting boundaries. 0 is always lowest.

Specified by:
adjHunger in interface CharState
Parameters:
byThisMuch - a positive or negative change in value
max - the highest amount to allow the hunger number to reach
Returns:
whether the highest or lowest boundary was reached

maxHunger

public int maxHunger(int baseWeight)
Description copied from interface: CharState
This method is used to recalculate the maximum thirhungerst for a mob, based on their weight and the default maximum hunger

Specified by:
maxHunger in interface CharState
Parameters:
baseWeight - the base weight of the mob
Returns:
the new maximum hunger to set

getThirst

public int getThirst()
Description copied from interface: CharState
Get the number of thirst points for the player

Specified by:
getThirst in interface CharState
Returns:
number of thirst points

setThirst

public void setThirst(int newVal)
Description copied from interface: CharState
Set the number of thirst points

Specified by:
setThirst in interface CharState
Parameters:
newVal - number of thirst points

adjThirst

public boolean adjThirst(int byThisMuch,
                         int max)
Description copied from interface: CharState
Set the number of thirst points, respecting boundaries. 0 is always lowest.

Specified by:
adjThirst in interface CharState
Parameters:
byThisMuch - a positive or negative change in value
max - the highest amount to allow the thirst number to reach
Returns:
whether the highest or lowest boundary was reached

maxThirst

public int maxThirst(int baseWeight)
Description copied from interface: CharState
This method is used to recalculate the maximum thirst for a mob, based on their weight and the default maximum thirst

Specified by:
maxThirst in interface CharState
Parameters:
baseWeight - the base weight of the mob
Returns:
the new maximum thirst to set

getCombatStats

public java.lang.String getCombatStats()
Description copied from interface: CharState
Get primary combat stats as displayable code string

Specified by:
getCombatStats in interface CharState
Returns:
primary combat stats as displayable code string

getMana

public int getMana()
Description copied from interface: CharState
Get the number of mana points for the player

Specified by:
getMana in interface CharState
Returns:
number of mana points

setMana

public void setMana(int newVal)
Description copied from interface: CharState
Set the number of mana points

Specified by:
setMana in interface CharState
Parameters:
newVal - number of mana points

adjMana

public boolean adjMana(int byThisMuch,
                       CharState max)
Description copied from interface: CharState
Set the number of mana points, respecting boundaries. 0 is always lowest.

Specified by:
adjMana in interface CharState
Parameters:
byThisMuch - a positive or negative change in value
max - the highest amount to allow the mana number to reach
Returns:
whether the highest or lowest boundary was reached

getMovement

public int getMovement()
Description copied from interface: CharState
Get the number of movement points for the player

Specified by:
getMovement in interface CharState
Returns:
number of movement points

setMovement

public void setMovement(int newVal)
Description copied from interface: CharState
Set the number of movement points

Specified by:
setMovement in interface CharState
Parameters:
newVal - number of movement points

adjMovement

public boolean adjMovement(int byThisMuch,
                           CharState max)
Description copied from interface: CharState
Set the number of movement points, respecting boundaries. 0 is always lowest.

Specified by:
adjMovement in interface CharState
Parameters:
byThisMuch - a positive or negative change in value
max - the highest amount to allow the movement number to reach
Returns:
whether the highest or lowest boundary was reached

recoverTick

public void recoverTick(MOB mob,
                        CharState maxState)
Description copied from interface: CharState
During rest, and even standing still, this method will be called to allow the fields in this object to recover some of their value. It is called by the mob tick(Tickable,int) method every CMProps.getTickMillis() milliseconds

Specified by:
recoverTick in interface CharState
Parameters:
mob - the mob recovering
maxState - The CharState objects which represents the maximum values for these fields
See Also:
MOB

expendEnergy

public void expendEnergy(MOB mob,
                         CharState maxState,
                         boolean expendMovement)
Description copied from interface: CharState
During movement and combat, this method will be called to allow the movement to be expended and hunger/thirst to occur. It is called by methods executing the appropriate events when they are performed and by the mob tick(Tickable,int) method

Specified by:
expendEnergy in interface CharState
Parameters:
mob - the mob expending
maxState - The CharState objects which represents the maximum values for these fields
expendMovement - whether to skip movement expending
See Also:
MOB

getSaveStatIndex

public int getSaveStatIndex()
Description copied from interface: Modifiable
Returns the index into the stat codes array where extra savable fields begins. This number is always the same as getStatCodes().length unless there are extra fields which need to be saved in xml for generic objects. This method is used by editors for post-build user-defined fields.

Specified by:
getSaveStatIndex in interface Modifiable
Returns:
the index into getStatCodes()
See Also:
Modifiable.getStatCodes(), Modifiable.getStat(String), Modifiable.setStat(String, String)

getStatCodes

public java.lang.String[] getStatCodes()
Description copied from interface: Modifiable
Returns an array of the string names of those fields which are modifiable on this object at run-time by builders.

Specified by:
getStatCodes in interface Modifiable
Returns:
list of the fields which may be set.
See Also:
Modifiable.getStat(String), Modifiable.setStat(String, String)

isStat

public boolean isStat(java.lang.String code)
Description copied from interface: Modifiable
An alternative means of retreiving the values of those fields on this object which are modifiable at run-time by builders. See getStatCodes() for possible values for the code passed to this method. Values returned are always strings, even if the field itself is numeric or a list.

Specified by:
isStat in interface Modifiable
Parameters:
code - the name of the field to read.
Returns:
true if the code is a real value, false otherwise
See Also:
Modifiable.getStatCodes()

getCodeNum

protected int getCodeNum(java.lang.String code)

sameAs

public boolean sameAs(CharState E)
Description copied from interface: CharState
Whether this object instance is functionally identical to the object passed in. Works by repeatedly calling getStat on both objects and comparing the values.

Specified by:
sameAs in interface CharState
Parameters:
E - the object to compare this one to
Returns:
whether this object is the same as the one passed in
See Also:
Modifiable.getStatCodes(), Modifiable.getStat(String)

setStat

public void setStat(java.lang.String code,
                    java.lang.String val)
Description copied from interface: Modifiable
An alternative means of setting the values of those fields on this object which are modifiable at run-time by builders. See getStatCodes() for possible values for the code passed to this method. The value passed in is always a string, even if the field itself is numeric or a list.

Specified by:
setStat in interface Modifiable
Parameters:
code - the name of the field to set
val - the value to set the field to
See Also:
Modifiable.getStatCodes()

getStat

public java.lang.String getStat(java.lang.String code)
Description copied from interface: Modifiable
An alternative means of retreiving the values of those fields on this object which are modifiable at run-time by builders. See getStatCodes() for possible values for the code passed to this method. Values returned are always strings, even if the field itself is numeric or a list.

Specified by:
getStat in interface Modifiable
Parameters:
code - the name of the field to read.
Returns:
the value of the field read
See Also:
Modifiable.getStatCodes()

copyOf

public CMObject copyOf()
Description copied from interface: CMObject
Similar to Cloneable.clone(), but does its best to make sure that any internal objects to this class are also copyOfed.

Specified by:
copyOf in interface CMObject
Returns:
a clone of this object

compareTo

public int compareTo(CMObject o)
Specified by:
compareTo in interface java.lang.Comparable<CMObject>