wyvern.lib.classes.armor
Class ArmorImpl

java.lang.Object
  extended bywyvern.kernel.properties.PList
      extended bywyvern.kernel.maps.MapObject
          extended bywyvern.lib.classes.armor.ArmorImpl
All Implemented Interfaces:
Armor, Broadcaster, Damageable, GameObject, MethodHookable, PickupInterest, PropertyList
Direct Known Subclasses:
Amulet, BodyArmor, Boots, Bracers, Cloak, Girdle, Gloves, Helmet, Ring, Shield

public abstract class ArmorImpl
extends MapObject
implements Armor, PickupInterest

Superclass of all armor-derived thingies.

Version:
1.0, Sep 02, 1997
Author:
Steve Yegge

Field Summary
 
Fields inherited from class wyvern.kernel.maps.MapObject
IN_MAP_EDITOR, listenerList_
 
Fields inherited from class wyvern.kernel.properties.PList
readOnly_
 
Fields inherited from interface wyvern.lib.PropertyList
PROPERTY_PACKAGE
 
Constructor Summary
ArmorImpl()
           
 
Method Summary
 void adjustHP(int adjust)
          Adjusts the monster's hit points upwards or downwards.
static void applyBonus(Commandable agent, java.lang.String prop, int adjust)
          Adjusts a single property on the agent by the given amount.
static void applyBonuses(PropertyList obj, boolean add, Commandable agent)
          Adds or removes the specific magical bonuses for this armor.
static boolean applySpecial(Commandable agent, java.lang.String stat, int adjust)
          Attempts to locate a special accessor for the passed stat, named "adjust".
 java.lang.String canWear(Commandable agent)
          Called to see if the specified agent can wear this armor.
 java.lang.String checkDrop(Commandable agent, Container dest)
          Checks whether the object can be dropped, thrown, given away, put in a bag, or otherwise disposed of by the bearer.
 void destroy()
          Destroys the armor, unwearing it and removing from inventory/map.
 void dropped(Commandable agent)
          Notifies us we've been dropped.
 void forceRemoval()
          Removes the armor from its wearer, removing the armor from any defense-list on the wearer as well.
 int getAC(DamageType dtype)
          Returns the AC versus a specified DamageType.
 java.lang.String getDescription()
          Returns the long description for the object.
 int getHP()
          Returns the object's current hit points.
 int getMaxHP()
          Returns the object's maximum hit points.
 int getValue()
          Make giant/tiny armor twice as expensive.
 long getWeight()
          Returns the weight of this armor.
 void initialize()
          Initializes the object's default properties.
 boolean isWorn()
          Returns true if this armor is currently being worn.
 void kill(GameObject attacker)
          Destroys the armor, unwearing it if necessary, and removes it from the agent's inventory or from the map.
 void pickedUp(Commandable agent)
          We don't care about this one, although subclasses might.
 void setWorn(boolean worn, Commandable agent)
          Notifies the armor it's being worn.
 java.lang.String toString()
          Returns the name plus "(worn)" if worn.
 
Methods inherited from class wyvern.kernel.maps.MapObject
addContainerChangeListener, addDefaultProperty, addMapChangeListener, addMapMotionListener, addMethodHook, addMotionTracker, addObjectTracker, addPrefix, addSuffix, addToMap, bless, broadcast, broadcast, broadcast, broadcast, broadcast, canEnter, canEnterBlockedBy, canMove, canMove, canMoveBlockedBy, canMoveBlockedBy, canMoveTo, canMoveToBlockedBy, curse, cycleFrame, ensureListenerList, ensureWeight, externalize, fireContainerEntered, fireContainerExited, fireEnteredMap, fireExitedMap, fireMovedInMap, getAlpha, getAppearance, getArchetype, getBaseName, getBaseWeight, getBitmap, getBounds, getCanonicalClassName, getCategory, getContainer, getCreator, getDamagedDescription, getDirection, getGenderPossessive, getGenderPronoun, getImage, getImageDescriptor, getImageDescriptors, getLayer, getLocations, getMap, getMapLink, getMaterial, getMaterialDescription, getMover, getOwningPlayer, getParentMap, getPrefixes, getQuantity, getReferenceLoc, getRelativeLocs, getShortDesc, getSuffixes, getTile, getTile, groupString, inContainer, initLocs, inMapEditor, invalidate, invalidateImage, invalidateParent, invalidateText, isAnimated, isAttackable, isBlessed, isCommandable, isCursed, isDamned, isGroupable, isIdentified, isMonster, isMonsterOrPlayer, isPlayer, isTerrain, isUncursed, isUnpaid, isWizard, makeClone, markPaid, markUnpaid, move, occupies, positionAt, positionAtMap, remove, removeContainerChangeListener, removeFromMap, removeMapChangeListener, removeMapMotionListener, removeMethodHook, removeMotionTracker, removeObjectTracker, removePrefix, removeSuffix, runMethodHook, setAlpha, setAnimated, setBitmap, setCategory, setContainer, setDefaultBitmap, setDefaultCategory, setDefaultDesc, setDefaultImage, setDefaultIntProperty, setDefaultLayer, setDefaultMaterial, setDefaultProperty, setDefaultShortDesc, setDirection, setImage, setImage, setLayer, setLocations, setMap, setMapLink, setQuantity, setShape, setSize, setTransientSize, setWeight, setWeight, teleport, updateMapLocation
 
Methods inherited from class wyvern.kernel.properties.PList
addProperty, addTransientProperty, adjustDoubleProperty, adjustIntProperty, adjustLongProperty, adjustTransientDoubleProperty, adjustTransientIntProperty, adjustTransientLongProperty, countLocalProperties, debugProperties, dismantlePropertyList, getDoubleProperty, getInheritedProperty, getInteger, getIntProperty, getLocalProperties, getLocalProperty, getLongProperty, getParent, getPersistentDoubleProperty, getPersistentIntProperty, getPersistentLocalProperties, getPersistentLongProperty, getPersistentProperty, getProfilingInfo, getProperties, getProperties, getPropertiesIncludingTransients, getPropertiesIncludingTransients, getProperty, getSerializableProperties, getSerializableProperty, getStringProperty, getTransientDoubleProperty, getTransientIntProperty, getTransientLongProperty, getTransientProperties, getTransientProperty, hasLocalProperty, hasPersistentProperty, hasProperty, hasTransientProperty, inheritProperty, isReadOnly, isRemoved, isTransientlyRemoved, printLocalProperties, printProperties, printProperties, printTransientProperties, removeProperty, removeTransientProperty, setDoubleProperty, setIntProperty, setLongProperty, setParent, setProperty, setReadOnly, setTransientDoubleProperty, setTransientIntProperty, setTransientLongProperty, setTransientProperty, toString, transientlyRemoveProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface wyvern.lib.Armor
getRequiredSlots
 
Methods inherited from interface wyvern.lib.GameObject
addContainerChangeListener, addMapChangeListener, addMapMotionListener, addMotionTracker, addObjectTracker, addPrefix, addSuffix, bless, canEnter, canEnterBlockedBy, canMove, canMove, canMoveBlockedBy, canMoveBlockedBy, canMoveTo, canMoveToBlockedBy, curse, cycleFrame, externalize, getAlpha, getAppearance, getArchetype, getBaseWeight, getBitmap, getBounds, getCanonicalClassName, getCategory, getContainer, getCreator, getDamagedDescription, getDirection, getGenderPossessive, getGenderPronoun, getImage, getImageDescriptor, getImageDescriptors, getLayer, getLocations, getMap, getMapLink, getMaterial, getMaterialDescription, getMover, getOwningPlayer, getParentMap, getPrefixes, getQuantity, getReferenceLoc, getRelativeLocs, getShortDesc, getSuffixes, getTile, getTile, inContainer, inMapEditor, invalidate, invalidateImage, invalidateParent, invalidateText, isAnimated, isAttackable, isBlessed, isCommandable, isCursed, isDamned, isGroupable, isIdentified, isMonster, isMonsterOrPlayer, isPlayer, isTerrain, isUncursed, isUnpaid, isWizard, makeClone, markPaid, markUnpaid, move, occupies, positionAt, positionAtMap, remove, removeContainerChangeListener, removeMapChangeListener, removeMapMotionListener, removeMotionTracker, removeObjectTracker, removePrefix, removeSuffix, setAlpha, setAnimated, setBitmap, setCategory, setContainer, setDirection, setImage, setImage, setLayer, setLocations, setMap, setMapLink, setQuantity, setShape, setSize, setTransientSize, setWeight, setWeight, teleport
 
Methods inherited from interface wyvern.lib.PropertyList
addProperty, addTransientProperty, adjustDoubleProperty, adjustIntProperty, adjustLongProperty, adjustTransientDoubleProperty, adjustTransientIntProperty, adjustTransientLongProperty, countLocalProperties, getDoubleProperty, getInheritedProperty, getIntProperty, getLocalProperties, getLocalProperty, getLongProperty, getParent, getPersistentDoubleProperty, getPersistentIntProperty, getPersistentLocalProperties, getPersistentLongProperty, getPersistentProperty, getProperties, getProperties, getPropertiesIncludingTransients, getPropertiesIncludingTransients, getProperty, getSerializableProperties, getSerializableProperty, getStringProperty, getTransientDoubleProperty, getTransientIntProperty, getTransientLongProperty, getTransientProperties, getTransientProperty, hasLocalProperty, hasPersistentProperty, hasProperty, hasTransientProperty, inheritProperty, isReadOnly, isRemoved, isTransientlyRemoved, printLocalProperties, printProperties, printProperties, printTransientProperties, removeProperty, removeTransientProperty, setDoubleProperty, setIntProperty, setLongProperty, setParent, setProperty, setReadOnly, setTransientDoubleProperty, setTransientIntProperty, setTransientLongProperty, setTransientProperty, toString, transientlyRemoveProperty
 
Methods inherited from interface wyvern.lib.MethodHookable
addMethodHook, removeMethodHook, runMethodHook
 
Methods inherited from interface wyvern.lib.Broadcaster
broadcast, broadcast, broadcast, broadcast, broadcast
 

Constructor Detail

ArmorImpl

public ArmorImpl()
Method Detail

initialize

public void initialize()
Description copied from interface: GameObject
Initializes the object's default properties. Any GameObject implementation that wishes to initialize itself should do so here, rather than in the constructor. This is because nearly all game objects inherit from an archetype, and the archetype parent pointer isn't set until the object's constructor finishes. This is a good place to add any class-default properties for an object - properties that the object gets regardless of which archetype it inherits from. WARNING: don't forget to call the superclass' initialize() method, or the object may not function properly. For instance, it won't become animated even if it specifies animation parameters in the archetype.

Specified by:
initialize in interface GameObject
Overrides:
initialize in class MapObject

setWorn

public void setWorn(boolean worn,
                    Commandable agent)
Notifies the armor it's being worn. Don't call this to remove the armor! Call forceRemoval() instead, or the armor will eventually get into a corrupted state and disappear.

Specified by:
setWorn in interface Armor
Parameters:
worn - true if worn, false if not
agent - the person wearing/unwearing it

isWorn

public boolean isWorn()
Returns true if this armor is currently being worn.

Specified by:
isWorn in interface Armor
Returns:
true if worn

toString

public java.lang.String toString()
Returns the name plus "(worn)" if worn.

Overrides:
toString in class MapObject
Returns:
item description

dropped

public void dropped(Commandable agent)
Notifies us we've been dropped.

Specified by:
dropped in interface PickupInterest
Parameters:
agent - the agent that dropped the object

getWeight

public long getWeight()
Returns the weight of this armor. Doubles the weight for giant armor, and halves it for tiny armor.

Specified by:
getWeight in interface GameObject
Overrides:
getWeight in class MapObject

pickedUp

public void pickedUp(Commandable agent)
We don't care about this one, although subclasses might.

Specified by:
pickedUp in interface PickupInterest
Parameters:
agent - the agent picking up the object

getAC

public int getAC(DamageType dtype)
Returns the AC versus a specified DamageType.

Specified by:
getAC in interface Armor
Parameters:
dtype - the DamageType to defend against
Returns:
the ac against that DamageType

applyBonuses

public static void applyBonuses(PropertyList obj,
                                boolean add,
                                Commandable agent)
Adds or removes the specific magical bonuses for this armor.

Has various side effects:

This method is called by WeaponImpl.applyBonuses, so the properties above work for both armor and weapons.

Parameters:
agent - the wearer
add - true to add bonuses, false to subtract them
obj - the object applying the bonuses

applyBonus

public static void applyBonus(Commandable agent,
                              java.lang.String prop,
                              int adjust)
Adjusts a single property on the agent by the given amount. Checks for special accessors.


applySpecial

public static boolean applySpecial(Commandable agent,
                                   java.lang.String stat,
                                   int adjust)
Attempts to locate a special accessor for the passed stat, named "adjust". If stat is 1 or 2 letters, it'll all be uppercased, for instance "adjustHP" for "hp".

Parameters:
agent - the agent to apply the bonus to
stat - the int property to adjust
adjust - the amount by which to adjust it

forceRemoval

public void forceRemoval()
Removes the armor from its wearer, removing the armor from any defense-list on the wearer as well. This is the proper way to remove a piece of armor from a wearer.

Specified by:
forceRemoval in interface Armor

getHP

public int getHP()
Returns the object's current hit points.

Specified by:
getHP in interface Damageable

getMaxHP

public int getMaxHP()
Returns the object's maximum hit points.

Specified by:
getMaxHP in interface Damageable

adjustHP

public void adjustHP(int adjust)
Adjusts the monster's hit points upwards or downwards.

Specified by:
adjustHP in interface Damageable
Parameters:
adjust - a number (possibly negative) to add to the monster's hp

kill

public void kill(GameObject attacker)
Destroys the armor, unwearing it if necessary, and removes it from the agent's inventory or from the map. Just calls the destroy() method.

Specified by:
kill in interface Damageable
Parameters:
attacker - the player/monster/iron-gate/whatever that did the final blow. Can be null.

destroy

public void destroy()
Destroys the armor, unwearing it and removing from inventory/map.

Runs a method-hook called "destroy" with no args after the item is removed (if worn) and destroyed.

Specified by:
destroy in interface GameObject
Overrides:
destroy in class MapObject

checkDrop

public java.lang.String checkDrop(Commandable agent,
                                  Container dest)
Checks whether the object can be dropped, thrown, given away, put in a bag, or otherwise disposed of by the bearer. Handles checks for, e.g. cursed weapons, worn armor, etc.

Specified by:
checkDrop in interface GameObject
Overrides:
checkDrop in class MapObject
Parameters:
agent - the person trying to drop it
dest - where they're trying to put it
Returns:
null if it's OK to drop/throw/etc. the object. If non-null, it's a message to display to the user as to why they can't get rid of it. In this case, vetoes the drop if the armor is worn and cursed.

getValue

public int getValue()
Make giant/tiny armor twice as expensive.

Specified by:
getValue in interface GameObject
Overrides:
getValue in class MapObject

getDescription

public java.lang.String getDescription()
Returns the long description for the object. Shows the level requirement, if any.

Specified by:
getDescription in interface GameObject
Overrides:
getDescription in class MapObject

canWear

public java.lang.String canWear(Commandable agent)
Called to see if the specified agent can wear this armor. Gives the armor a chance to provide arbitrarily complex checking to see if the agent can wear it.

Specified by:
canWear in interface Armor
Parameters:
agent - the player or monster trying to wear the armor
Returns:
null if they can wear it. If they can't wear it, returns a message to send to the wearer explaining why not. For example: "You must be a Naga Monk to wear this armor."