wyvern.kernel.combat
Class DamageType

java.lang.Object
  extended bywyvern.kernel.combat.DamageType
Direct Known Subclasses:
AcidDamage, CutDamage, DrownDamage, FireDamage, FrostDamage, LightningDamage, MagicDamage, PoisonDamage, SlayDamage, SmashDamage, StabDamage

public abstract class DamageType
extends java.lang.Object

Base class for legal damage types.

Version:
1.0, Aug 23, 1999
Author:
Steve Yegge

Field Summary
static java.lang.String[] DAMAGE_YOU_MSGS
           
static java.lang.String[] INANIMATE_DAMAGE_MSGS
           
protected  int wc_
           
static java.lang.String[] YOU_DAMAGE_MSGS
           
 
Constructor Summary
DamageType()
          Default no-arg constructor for Class.newInstance();
DamageType(int wc)
          Constructs a new DamageType
 
Method Summary
 DamageType createClone()
          Makes a clone of the DamageType.
 java.lang.String[] getAttackerMessages()
          Returns an array of messages from least to most.
 java.lang.String[] getAttackerMessagesInanimate()
          Returns an array of messages from least to most.
 java.lang.String getAttackerMsg(GameObject defender, int damage)
          Returns a message for the attacker dependent on the amount of damage done.
static java.lang.Class getDamageClass(java.lang.String name)
          Returns the DamageType subclass for the specified type.
 java.lang.String[] getDefenderMessages()
          Returns an array of messages from least to most.
 java.lang.String getDefenderMsg(GameObject attacker, GameObject defender, int damage)
          Returns a default damage-description to give the defender.
 java.lang.String getNegativeDamageAttackerMessage(GameObject defender)
          Returns the message to tell the attacker if the attack resulted in healing the defender.
 java.lang.String getNegativeDamageDefenderMessage(GameObject attacker)
          Returns the message to tell the defender if the damage is negative; i.e. the defender is getting healed by the attack.
 java.lang.String getNoDamageAttackerMessage(GameObject defender)
          Returns the message to tell the attacker if the damage amount was zero.
 java.lang.String getNoDamageDefenderMessage(GameObject attacker)
          Returns the message to tell the defender if the damage was zero.
abstract  java.lang.String getShortName()
          Returns "fire", "cold", "smash" or whatever else is used in the archetype files for this damage type.
 int getWC()
          Returns the weapon class for this damage type.
 void setWC(int wc)
          Sets the wc for this damage type.
 java.lang.String toString()
          Returns a short (debugging) description.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

wc_

protected int wc_

INANIMATE_DAMAGE_MSGS

public static final java.lang.String[] INANIMATE_DAMAGE_MSGS

YOU_DAMAGE_MSGS

public static final java.lang.String[] YOU_DAMAGE_MSGS

DAMAGE_YOU_MSGS

public static final java.lang.String[] DAMAGE_YOU_MSGS
Constructor Detail

DamageType

public DamageType()
Default no-arg constructor for Class.newInstance();


DamageType

public DamageType(int wc)
Constructs a new DamageType

Parameters:
wc - the weapon class
Method Detail

getDamageClass

public static java.lang.Class getDamageClass(java.lang.String name)
Returns the DamageType subclass for the specified type. Allows weapon archetypes to use keywords like "fire" and "frost" instead of fully qualified classnames.

Parameters:
name - the damage type-name, such as "lightning" or "smash"
Returns:
the DamageType associated with the name, or throws an IllegalArgumentException if no such type exists.

getWC

public int getWC()
Returns the weapon class for this damage type.

Returns:
the wc, which is weapon-dependent. If called on an instance not associated with a weapon, returns zero.

setWC

public void setWC(int wc)
Sets the wc for this damage type.


getShortName

public abstract java.lang.String getShortName()
Returns "fire", "cold", "smash" or whatever else is used in the archetype files for this damage type.

Returns:
the damage name

getAttackerMsg

public java.lang.String getAttackerMsg(GameObject defender,
                                       int damage)
Returns a message for the attacker dependent on the amount of damage done.

Parameters:
defender - the thing that got damaged
damage - the damage: can be zero or negative - subclasses need to handle these cases
Returns:
something like "You hit so-and-so" or "You burned so-and-so".

getDefenderMsg

public java.lang.String getDefenderMsg(GameObject attacker,
                                       GameObject defender,
                                       int damage)
Returns a default damage-description to give the defender.

Parameters:
attacker - the attacker
defender - the thing being damaged
damage - the damage amount (can be zero or negative)
Returns:
a suitable damage message

getNoDamageAttackerMessage

public java.lang.String getNoDamageAttackerMessage(GameObject defender)
Returns the message to tell the attacker if the damage amount was zero.

Parameters:
defender - the thing being attacked
Returns:
the message to use

getNegativeDamageAttackerMessage

public java.lang.String getNegativeDamageAttackerMessage(GameObject defender)
Returns the message to tell the attacker if the attack resulted in healing the defender.

Parameters:
defender - the thing being attacked
Returns:
the message to use

getNoDamageDefenderMessage

public java.lang.String getNoDamageDefenderMessage(GameObject attacker)
Returns the message to tell the defender if the damage was zero.

Parameters:
attacker - the thing doing the attack
Returns:
the message

getNegativeDamageDefenderMessage

public java.lang.String getNegativeDamageDefenderMessage(GameObject attacker)
Returns the message to tell the defender if the damage is negative; i.e. the defender is getting healed by the attack.

Parameters:
attacker - the thing doing the attack
Returns:
the message

getAttackerMessages

public java.lang.String[] getAttackerMessages()
Returns an array of messages from least to most.

Returns:
an array of messages to send to the attacker, depending on the damage done. Default messages are for physical attacks (cut/stab/smash).

getDefenderMessages

public java.lang.String[] getDefenderMessages()
Returns an array of messages from least to most.

Returns:
an array of messages to send to the defender depending on the damage done. Default messages are for physical attacks (cut/stab/smash).

getAttackerMessagesInanimate

public java.lang.String[] getAttackerMessagesInanimate()
Returns an array of messages from least to most.

Returns:
an array of messages to send to the attacker, depending on the damage done. Default messages are for physical attacks (cut/stab/smash).

toString

public java.lang.String toString()
Returns a short (debugging) description.


createClone

public DamageType createClone()
Makes a clone of the DamageType.