spellcast.beings
Class Being

java.lang.Object
  extended by spellcast.beings.Being
All Implemented Interfaces:
java.io.Serializable, IBeing, PropertyUpdater, util.Nullable
Direct Known Subclasses:
Monster, NullBeing, Wizard

public abstract class Being
extends java.lang.Object
implements java.io.Serializable, PropertyUpdater, IBeing

The base class for all Beings in Spellcast. TODO: add equals() and hashCode()

Version:
$Revision: 1.1 $
Author:
Barrie Treloar
See Also:
Serialized Form

Field Summary
static java.lang.String ACTIVE_PROP
          The property for the being's active value.
 
Constructor Summary
protected Being()
          Provided for serialization, do not use as a constructor.
  Being(Id anId, java.lang.String aName, Gender aGender, int theMaxHitPoints)
          Creates a new BeingImpl object.
 
Method Summary
 void addEnchantment(Enchantment anEnchantment)
          Add an enchantment to this Being.
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
          Adds a PropertyChangeListener to this Being.
 Enchantment[] getEnchantments()
          Return an array of all Enchantments that are in effect upon this Being.
 Gender getGender()
          Return the Gender of this Being.
 int getHitPoints()
          Returns the value of the current Hit Points for this Being.
 Id getId()
          The Id of this Being.
 boolean getLeavesCorpse()
          Indicates whether this Being should leave a corpse when it dies.
 int getMaxHitPoints()
          Returns the value for the Maximum Hit Points for this Being.
 java.lang.String getName()
          The name of the Being.
protected  java.beans.PropertyChangeSupport getPropertySupport()
          The PropertyChangeSupport object used to notify listeners of changes to properties.
 boolean isActive()
          Indicates whether this Being is active this turn.
 boolean isAlive()
          Determine if this Being is currently alive.
 boolean isNull()
          
static IBeing newNull()
          Return a Null IBeing.
 void removeEnchantment(Enchantment enchantment)
          Remove the specified Enchantment from this Being.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
          Remove a PropertyChangeListener from this Being.
 void setActive(boolean isActive)
          Sets this Being as active for this turn.
 void setAlive(boolean isAlive)
          Sets whether this Being is currently alive.
 void setGender(Gender theGender)
          Sets the Gender of this Being.
 void setHitPoints(int theHitPoints)
          Set the value for the current HitPoints for this Being.
 void setId(Id theId)
          Set the Id of this Being.
 void setLeavesCorpse(boolean shouldLeaveCorpse)
          This Being will leave a corpse on death if this value is true, otherwise no corpse will be created.
 void setMaxHitPoints(int theMaxHitPoints)
          Set the value for the Maximum Hit Points for this Being.
 void setName(java.lang.String theName)
          Sets the name of this Being.
 void setNull(boolean isNullable)
          Set whether this object is a Nullable.
 void shouldDie()
          Determine if this being should die.
 void takeDamage(Damage damageDealt)
          The specified damage is dealt to this Being.
 void updateEnchantments()
          Each Enchantment on this Being is notified that the turn has been completed via turnComplete.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ACTIVE_PROP

public static final java.lang.String ACTIVE_PROP
The property for the being's active value.

See Also:
Constant Field Values
Constructor Detail

Being

protected Being()
Provided for serialization, do not use as a constructor.


Being

public Being(Id anId,
             java.lang.String aName,
             Gender aGender,
             int theMaxHitPoints)
Creates a new BeingImpl object.

Parameters:
anId - theId to use for this Being.
aName - the name of thisBeing.
aGender - theGender of this Being.
theMaxHitPoints - the maximum hit points of thisBeing.
Method Detail

getPropertySupport

protected final java.beans.PropertyChangeSupport getPropertySupport()
The PropertyChangeSupport object used to notify listeners of changes to properties.

Returns:
the PropertyChangeSupport.

addPropertyChangeListener

public final void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a PropertyChangeListener to this Being.

Specified by:
addPropertyChangeListener in interface PropertyUpdater
Parameters:
listener - the PropertyChangeListener to add.

removePropertyChangeListener

public final void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Remove a PropertyChangeListener from this Being.

Specified by:
removePropertyChangeListener in interface PropertyUpdater
Parameters:
listener - the PropertyChangeListener to remove.

addEnchantment

public final void addEnchantment(Enchantment anEnchantment)
Add an enchantment to this Being.

Specified by:
addEnchantment in interface IBeing
Parameters:
anEnchantment - the enchantment to add.

removeEnchantment

public final void removeEnchantment(Enchantment enchantment)
Remove the specified Enchantment from this Being. If the enchantment does not exist then nothing is removed.

Specified by:
removeEnchantment in interface IBeing
Parameters:
enchantment - the enchantment to remove. Ignored if the enchantment is not in effect on this Being.

getEnchantments

public final Enchantment[] getEnchantments()
Return an array of all Enchantments that are in effect upon this Being.

Specified by:
getEnchantments in interface IBeing
Returns:
an array of all Enchantments that are in effect upon this Being.

updateEnchantments

public final void updateEnchantments()
Each Enchantment on this Being is notified that the turn has been completed via turnComplete. If the Enchantment indicates that it should no longer be in effect then it is removed.

Specified by:
updateEnchantments in interface IBeing
See Also:
Enchantment.turnComplete()

isActive

public final boolean isActive()
Indicates whether this Being is active this turn.

Specified by:
isActive in interface IBeing
Returns:
whether this Being is active this turn.

setActive

public final void setActive(boolean isActive)
Sets this Being as active for this turn.

Specified by:
setActive in interface IBeing
Parameters:
isActive - if thisBeing is active for this turn, false otherwise.

isAlive

public final boolean isAlive()
Determine if this Being is currently alive. True if alive, false otherwise.

Specified by:
isAlive in interface IBeing
Returns:
true if the Being is alive, false otherwise.

setAlive

public final void setAlive(boolean isAlive)
Sets whether this Being is currently alive. True if alive, false otherwise.

Specified by:
setAlive in interface IBeing
Parameters:
isAlive - true if alive, false otherwise.

shouldDie

public final void shouldDie()
Determine if this being should die. TODO this should probably return an object which indicates: who killed the Being and what killed them.

Specified by:
shouldDie in interface IBeing

getId

public final Id getId()
The Id of this Being.

Specified by:
getId in interface IBeing
Returns:
the Id of this Being.

setId

public final void setId(Id theId)
Set the Id of this Being.

Specified by:
setId in interface IBeing
Parameters:
theId - the Id of this Being.

getHitPoints

public final int getHitPoints()
Returns the value of the current Hit Points for this Being. The current hit points will never exceed max hit points.

Specified by:
getHitPoints in interface IBeing
Returns:
the value of the current Hit Points for this Being.

setHitPoints

public final void setHitPoints(int theHitPoints)
Set the value for the current HitPoints for this Being. Any values that are negative are converted into 0. Any values that are greater than getMaxHitPoints are converted into getMaxHitPoints.

Specified by:
setHitPoints in interface IBeing
Parameters:
theHitPoints - the value to set the Hit Points to. Any negative values are converted to 0. Any values that are greater thangetMaxHitPoints are converted into getMaxHitPoints.

getMaxHitPoints

public final int getMaxHitPoints()
Returns the value for the Maximum Hit Points for this Being.

Specified by:
getMaxHitPoints in interface IBeing
Returns:
the maximum hit points for this Being.

setMaxHitPoints

public final void setMaxHitPoints(int theMaxHitPoints)
Set the value for the Maximum Hit Points for this Being. Only positive values are allowed for maxHitPoints. Any invalid values are silently ignored and the value is set to 0.

Specified by:
setMaxHitPoints in interface IBeing
Parameters:
theMaxHitPoints - the value to set the Maximum Hit Points to. Valid values are > 0. Invalid values are silently ignored and the value is set to 0.

takeDamage

public final void takeDamage(Damage damageDealt)
The specified damage is dealt to this Being. If there are any Enchantments that provide resistance to the DamageType being dealt then the damage is reduced to zero.

Specified by:
takeDamage in interface IBeing
Parameters:
damageDealt - the damage to deal to this Being.

getName

public final java.lang.String getName()
The name of the Being.

Specified by:
getName in interface IBeing
Returns:
the name of the Being.

setName

public final void setName(java.lang.String theName)
Sets the name of this Being.

Specified by:
setName in interface IBeing
Parameters:
theName - the name for this Being.

getGender

public final Gender getGender()
Return the Gender of this Being.

Specified by:
getGender in interface IBeing
Returns:
the Gender of this Being.

setGender

public final void setGender(Gender theGender)
Sets the Gender of this Being.

Specified by:
setGender in interface IBeing
Parameters:
theGender - the Gender of this Being.

getLeavesCorpse

public final boolean getLeavesCorpse()
Indicates whether this Being should leave a corpse when it dies.

Specified by:
getLeavesCorpse in interface IBeing
Returns:
true if a corpse should be created on death, false otherwise.

setLeavesCorpse

public final void setLeavesCorpse(boolean shouldLeaveCorpse)
This Being will leave a corpse on death if this value is true, otherwise no corpse will be created.

Specified by:
setLeavesCorpse in interface IBeing
Parameters:
shouldLeaveCorpse - true if a corpse should be created on death, false otherwise.

isNull

public final boolean isNull()

Specified by:
isNull in interface util.Nullable

setNull

public final void setNull(boolean isNullable)
Set whether this object is a Nullable.

Parameters:
isNullable - true if this object is a Null instance, false otherwise.

newNull

public static IBeing newNull()
Return a Null IBeing.

Returns:
an instance of the Null IBeing.


Copyright © 2001-2005 Spellcast. All Rights Reserved.