wyvern.lib.classes.magic
Class SpellProxy

java.lang.Object
  extended bywyvern.lib.classes.magic.SpellProxy
All Implemented Interfaces:
Readyable, Targetable

public class SpellProxy
extends java.lang.Object
implements Readyable, Targetable

This proxy class allows spells to be readied, like wands or range weapons. The proxy knows the name of the spell that's readied, and instantiates/starts the spell when the agent fires it.

Version:
1.0, Dec 12, 1999
Author:
Steve Yegge

Constructor Summary
SpellProxy(Commandable agent, java.lang.String spellname)
          Constructs a new SpellProxy
 
Method Summary
 boolean canReady(Commandable agent)
          Checks if the specified Commandable may ready the object.
 boolean canUnready(Commandable agent)
          Checks whether the specified agent may unready the object, assuming they've already got it readied.
 void fireDirection(Commandable agent, int dir)
          Tells the spell to fire itself in the specified direction.
 void fireLocation(Commandable agent, Point target)
          Tells the object to fire itself along the line specified from the agent to a destination point.
 java.lang.String getSpellName()
          Returns the name of the spell we're proxying.
 boolean isReadied()
          Returns true if we think we're readied.
 void notifyReady(Commandable agent)
          Notifies the Readyable object that the agent has readied it.
 void notifyUnready(Commandable agent)
          Unreadies the object.
 java.lang.String toString()
          Returns the name of the spell.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SpellProxy

public SpellProxy(Commandable agent,
                  java.lang.String spellname)
Constructs a new SpellProxy

Parameters:
spellname - the spell to ready
agent - the agent readying the spell
Method Detail

canReady

public boolean canReady(Commandable agent)
Checks if the specified Commandable may ready the object. Defaults to true.

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)
Checks whether the specified agent may unready the object, assuming they've already got it readied. For instance, if the object is cursed, it might not be unreadiable. Defaults to true.

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)
Notifies the Readyable object that the agent has readied it. SpellProxy handler does nothing.

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

notifyUnready

public void notifyUnready(Commandable agent)
Unreadies the object. If you call this on the object directly, make sure to remove the agent's "@readied" property as well, or they'll still be able to use the object.

SpellProxy handler does nothing.

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

fireDirection

public void fireDirection(Commandable agent,
                          int dir)
Tells the spell to fire itself in the specified direction. Default handler simply calls start().

Specified by:
fireDirection in interface Targetable
Parameters:
agent - the agent firing the object
dir - a wyvern.lib.Direction cardinal direction

fireLocation

public void fireLocation(Commandable agent,
                         Point target)
Tells the object to fire itself along the line specified from the agent to a destination point. Default handler simply calls start().

Specified by:
fireLocation in interface Targetable
Parameters:
agent - the agent firing the object
target - the destination point, perhaps chosen using the mouse.

toString

public java.lang.String toString()
Returns the name of the spell.


getSpellName

public java.lang.String getSpellName()
Returns the name of the spell we're proxying.

Returns:
a name that can be passed to Spell.cloneSpell()