wyvern.lib.classes.magic
Class Wand

java.lang.Object
  extended bywyvern.kernel.properties.PList
      extended bywyvern.kernel.maps.MapObject
          extended bywyvern.lib.classes.DynamicObject
              extended bywyvern.lib.classes.magic.MagicItem
                  extended bywyvern.lib.classes.magic.Wand
All Implemented Interfaces:
Broadcaster, Damageable, GameObject, MethodHookable, PropertyList, Readyable, Targetable
Direct Known Subclasses:
Rod

public class Wand
extends MagicItem
implements Readyable, Targetable

A traditional wand, containing a number of charges of a particular spell or effect.

Version:
1.0, Jan 29, 1998
Author:
Steve Yegge

Nested Class Summary
 class Wand.SimpleWandHandler
          Handles waving the wand.
 
Field Summary
static int DEFAULT_BASE_VALUE
          If no "base-value" property is set on the wand, it defaults to this value, per level, per charge.
static int DEFAULT_DELAY
           
static int DEFAULT_MAX_CHARGES
          If no "max_charges" property is set on the wand, it defaults to having a maximum of this many charges.
protected  Wand.SimpleWandHandler handler_
           
 
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
Wand()
           
 
Method Summary
 boolean canReady(Commandable agent)
          Returns true if the agent can ready us.
 boolean canUnready(Commandable agent)
          Returns true if the agent can unready us.
 void createWaveHandler()
          Creates a command handler for the "wave" command.
 void fireDirection(Commandable agent, int dir)
          Zaps the wand in a certain direction.
 void fireLocation(Commandable agent, Point target)
          Fires the wand towards a specific target location.
 int getCharges()
          Returns the number of charges on the wand, currently.
 java.lang.String getDescription()
          Returns the long-description of the scroll.
 java.lang.String getItemName()
          Returns "wand".
 int getValue()
          Returns the value of the wand, computed from the base price times the number of charges left.
 void initialize()
          Adds special properties for this class.
 boolean isReadied()
          Returns true if we think we're readied.
 void notifyReady(Commandable agent)
          Readies the wand.
 void notifyUnready(Commandable agent)
          Unreadies the wand.
protected  boolean parseWaveEvent(CommandEvent event)
          Figures out where the user is waving us, etc.
 java.lang.String printCharges()
          Prints the number of charges available in the wand.
 void setRandomCharge()
          Sets a random number of charges on the wand, between one and the maximum specified for the wand in the "max_charges" property.
 java.lang.String toString()
          Appends the number of charges to the description if identified.
 boolean waveWand(Monster agent, int direction)
          Fires the wand.
 
Methods inherited from class wyvern.lib.classes.magic.MagicItem
getSpell, inNoSpellsArea, startSpell
 
Methods inherited from class wyvern.lib.classes.DynamicObject
adjustHP, computeHP, getHP, getMaxHP, kill
 
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, checkDrop, curse, cycleFrame, destroy, 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, getWeight, 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.GameObject
addContainerChangeListener, addMapChangeListener, addMapMotionListener, addMotionTracker, addObjectTracker, addPrefix, addSuffix, bless, canEnter, canEnterBlockedBy, canMove, canMove, canMoveBlockedBy, canMoveBlockedBy, canMoveTo, canMoveToBlockedBy, checkDrop, curse, cycleFrame, destroy, 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, getWeight, 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
 

Field Detail

DEFAULT_DELAY

public static final int DEFAULT_DELAY
See Also:
Constant Field Values

DEFAULT_MAX_CHARGES

public static final int DEFAULT_MAX_CHARGES
If no "max_charges" property is set on the wand, it defaults to having a maximum of this many charges. The setRandomCharge() method will choose a number between zero and this number.

See Also:
Constant Field Values

DEFAULT_BASE_VALUE

public static final int DEFAULT_BASE_VALUE
If no "base-value" property is set on the wand, it defaults to this value, per level, per charge.

See Also:
Constant Field Values

handler_

protected Wand.SimpleWandHandler handler_
Constructor Detail

Wand

public Wand()
Method Detail

initialize

public void initialize()
Adds special properties for this class.

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

createWaveHandler

public void createWaveHandler()
Creates a command handler for the "wave" command.


setRandomCharge

public void setRandomCharge()
Sets a random number of charges on the wand, between one and the maximum specified for the wand in the "max_charges" property.


canReady

public boolean canReady(Commandable agent)
Returns true if the agent can ready us.

Specified by:
canReady in interface Readyable
Parameters:
agent - the Commandable trying to ready the object
Returns:
true if it's allowed to do so.

canUnready

public boolean canUnready(Commandable agent)
Returns true if the agent can unready us.

Specified by:
canUnready in interface Readyable
Parameters:
agent - the person who has the item readied
Returns:
true if we can unready it

notifyReady

public void notifyReady(Commandable agent)
Readies the wand.

Specified by:
notifyReady in interface Readyable
Parameters:
agent - the agent using it

notifyUnready

public void notifyUnready(Commandable agent)
Unreadies the wand.

Specified by:
notifyUnready in interface Readyable
Parameters:
agent - the agent using the object

isReadied

public boolean isReadied()
Returns true if we think we're readied.

Specified by:
isReadied in interface Readyable

parseWaveEvent

protected boolean parseWaveEvent(CommandEvent event)
Figures out where the user is waving us, etc.

Parameters:
event - a stock CommandEvent containing the event parameters
Returns:
false if we didn't understand the directions or couldn't fire for some reason.

waveWand

public boolean waveWand(Monster agent,
                        int direction)
Fires the wand.

Parameters:
agent - the monster waving the wand
direction - the Direction to fire it
Returns:
true if the wand fired successfully

fireDirection

public void fireDirection(Commandable agent,
                          int dir)
Zaps the wand in a certain direction.

Specified by:
fireDirection in interface Targetable
Parameters:
agent - the thing waving the wand
dir - the direction it's being zapped

fireLocation

public void fireLocation(Commandable agent,
                         Point target)
Fires the wand towards a specific target location.

Specified by:
fireLocation in interface Targetable
Parameters:
agent - the person waving the wand
target - the target point

getCharges

public int getCharges()
Returns the number of charges on the wand, currently.

Returns:
the number specified in the "charges" property

getValue

public int getValue()
Returns the value of the wand, computed from the base price times the number of charges left. The base price is derived from the level of the spell on the wand. Usually it's best to use the default value, but you can override it by setting a "base-value" int property that's the value to use, per charge. You can also just set a flat value with a "value" int property.

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

toString

public java.lang.String toString()
Appends the number of charges to the description if identified.

Overrides:
toString in class MapObject
Returns:
a short String describing this object. If the object represents a group of items, such as coins, the returned description will be a modified version of the description that includes quantity information.

getItemName

public java.lang.String getItemName()
Returns "wand". Subclasses might return something else.


printCharges

public java.lang.String printCharges()
Prints the number of charges available in the wand. Attaches to the end of the short description; called by toString().

Returns:
something like "(10)"

getDescription

public java.lang.String getDescription()
Returns the long-description of the scroll.

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