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 static int[] DEFAULT_STATES
           
protected  long fatigue
           
protected  int[] states
           
 
Fields inherited from interface com.planet_ink.coffee_mud.Common.interfaces.CharState
ANNOYANCE_DEFAULT_TICKS, DEATH_HUNGER_TICKS, DEATH_THIRST_TICKS, FATIGUED_EXHAUSTED_MILLIS, FATIGUED_MILLIS, REAL_TICK_ADJUST_FACTOR, REST_PER_SIT, REST_PER_SLEEP, STAT_DESCS, STAT_HITPOINTS, STAT_HUNGER, STAT_MANA, STAT_MOVE, STAT_NUMSTATS, STAT_THIRST, STAT_TICKSHUNGRY, STAT_TICKSTHIRSTY
 
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 adjTicksHungry(boolean bumpUp)
          Used to bump and/or read the number of ticks that this user has been consecutively hungry
 int adjTicksThirsty(boolean bumpUp)
          Used to bump and/or read the number of ticks that this user has been consecutively thirsty
 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.
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
 java.lang.String name()
          The displayable name of this object.
 CMObject newInstance()
          Returns a new instance of this class.
 void reset()
          Resets all the stats in this object to their factory defaults.
 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

DEFAULT_STATES

protected static final int[] DEFAULT_STATES

states

protected int[] states

fatigue

protected long fatigue
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, Tech. The name is typically identical to the class name.

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

name

public java.lang.String name()
Description copied from interface: CMObject
The displayable name of this object. May be modified by phyStats() object. Is derived from the Name().

Specified by:
name in interface CMObject
Returns:
the modified final name of this object on the map.
See Also:
Environmental.Name()

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

reset

public void reset()
Description copied from interface: CharState
Resets all the stats in this object to their factory defaults.

Specified by:
reset in interface CharState

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

adjTicksHungry

public int adjTicksHungry(boolean bumpUp)
Description copied from interface: CharState
Used to bump and/or read the number of ticks that this user has been consecutively hungry

Specified by:
adjTicksHungry in interface CharState
Parameters:
bumpUp - true to bump the number by one
Returns:
the ticks of hungriness

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

adjTicksThirsty

public int adjTicksThirsty(boolean bumpUp)
Description copied from interface: CharState
Used to bump and/or read the number of ticks that this user has been consecutively thirsty

Specified by:
adjTicksThirsty in interface CharState
Parameters:
bumpUp - true to bump the number by one
Returns:
the ticks of thirstiness

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

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>