wyvern.kernel.commands
Class TargetedEvent
java.lang.Object
wyvern.kernel.properties.PList
wyvern.kernel.commands.EventImpl
wyvern.kernel.commands.TargetedEvent
- All Implemented Interfaces:
- Broadcaster, CommandEvent, PropertyList
- Direct Known Subclasses:
- AttackEvent, DamageEvent, DeathEvent, GetFromCommand.GetFromEvent, GiveCommand.GiveEvent, HitEvent, LookCommand.LookEvent, PickupEvent, PutCommand.PutEvent, TalkCommand.TalkEvent, WearEvent, WhisperCommand.WhisperEvent
- public class TargetedEvent
- extends EventImpl
This is a utility subclass of CommandEvent for commands (such
as Drop and Pickup) that operate on a single GameObject at a
single map location. It provides some extra bean-style properties
and accessors for these properties. (Note: the properties won't
show up in the getProperties() list).
- Version:
- 1.0, Nov 05, 1997
- Author:
- Steve Yegge
Fields inherited from class wyvern.kernel.commands.EventImpl |
agent_, appendToFile_, argString_, argStringParsed_, argv_, argvParsed_, delay_, failureMessage_, filterObjects_, filters_, handler_, map_, modified_, originalText_, playerOriginated_, redirectFile_, redirecting_, sendToAgent_, successMessage_, verb_, vetoed_, wizParsed_ |
Method Summary |
java.lang.String |
getCloneErrorMsg()
Returns the default error message if cloning the target fails. |
Point |
getLocation()
Gets the map location where the event is occurring. |
int |
getQuantity()
Returns the quantity of the target to operate on. |
GameObject |
getTarget()
Gets the target object for this command. |
java.lang.String |
getTargetName()
Returns the string name that the user referred to the target with. |
boolean |
hasTarget()
Returns true if we have a target set. |
boolean |
isQuantified()
Returns true if this command event involves a quantity of the
target (e.g. |
boolean |
isTargetSpecifiedByHashcode()
Returns true if the command was "get #hashcode ", which
usually means it was created by clicking the mouse on an item
(e.g. in the ground window). |
void |
setLocation(Point location)
Sets the location at which the target object is acted on. |
void |
setQuantified(boolean q)
Sets or clears event flag indicating that the command specified
a partial amount of the object (applies only if the object has
the "groupable" property). |
void |
setQuantity(int q)
Sets the quantity of the target object to operate on.
|
void |
setTarget(GameObject target)
Sets the target object for this event. |
void |
setTargetName(java.lang.String name)
Saves the string name of the target object. |
Methods inherited from class wyvern.kernel.commands.EventImpl |
broadcast, broadcast, broadcast, broadcast, broadcast, checkVeto, fail, filterMessage, findAllMatches, findByHashcode, findInMap, findNeighbor, findObject, findTarget, getAgent, getArgs, getArgString, getDelay, getFailureMessage, getFilterObjects, getFilters, getHandler, getMap, getOriginalText, getRedirectFile, getSuccessMessage, getVerb, hasArgs, isAppending, isModified, isMonster, isPlayer, isPlayerOriginated, isRedirecting, isSendingToAgent, isVetoed, isWizard, main, message, message, noArgs, parseArgString, parseARGV, parseVerb, profileParsing, redirectMessage, runPostHooks, runPreHooks, searchInv, searchInvAndMapNearby, searchInvAndMapUnder, searchInvByHashcode, searchMapNearby, searchMapUnder, searchMapUnderByHashcode, setAgent, setArgs, setDelay, setFailureMessage, setHandler, setMap, setModified, setOriginalText, setPlayerOriginated, setSuccessMessage, setVerb, setVeto, toString, veto |
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.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 |
targetName_
protected java.lang.String targetName_
target_
protected GameObject target_
location_
protected Point location_
quantity_
protected int quantity_
cloneError_
protected java.lang.String cloneError_
- If a groupable object fails to clone itself properly, we have
to issue some sort of message to the agent. This is the default
message.
TargetedEvent
public TargetedEvent()
TargetedEvent
public TargetedEvent(CommandEvent e)
TargetedEvent
public TargetedEvent(java.lang.String text,
Commandable agent)
TargetedEvent
public TargetedEvent(CommandEvent e,
GameObject target)
setTarget
public void setTarget(GameObject target)
- Sets the target object for this event.
- Parameters:
target
- the object that the command is operating on
getTarget
public GameObject getTarget()
- Gets the target object for this command.
- Returns:
- the target GameObject
hasTarget
public boolean hasTarget()
- Returns true if we have a target set.
setLocation
public void setLocation(Point location)
- Sets the location at which the target object is acted on.
- Parameters:
location
- the map coordinates
getLocation
public Point getLocation()
- Gets the map location where the event is occurring.
- Returns:
- the location in the map where the target object resides
The object may be larger than 1 tile, but for TargetedEvents,
it's OK to operate on the object at one of its squares.
getTargetName
public java.lang.String getTargetName()
- Returns the string name that the user referred to the target with.
- Returns:
- the name the command was specified with. This may be
a substring of the target's text description.
setTargetName
public void setTargetName(java.lang.String name)
- Saves the string name of the target object.
- Parameters:
name
- the name used in the event.
setQuantity
public void setQuantity(int q)
- Sets the quantity of the target object to operate on.
For this value to have meaning you must also invoke
setQuantified (true).
- Parameters:
q
- the new quantity
getQuantity
public int getQuantity()
- Returns the quantity of the target to operate on. This value
is meaningless if isQuantified() returns false.
- Returns:
- the quantity specified. The value is not necessarily
a valid one for the target object (e.g. it could be negative,
or greater than the target's total quantity).
isQuantified
public boolean isQuantified()
- Returns true if this command event involves a quantity of the
target (e.g. "get 20 coins").
- Returns:
- true if a quantity was specified.
setQuantified
public void setQuantified(boolean q)
- Sets or clears event flag indicating that the command specified
a partial amount of the object (applies only if the object has
the "groupable" property).
- Parameters:
q
- true if a quantity is involved
getCloneErrorMsg
public java.lang.String getCloneErrorMsg()
- Returns the default error message if cloning the target fails.
- Returns:
- a message that hopefully the agent will never see.
isTargetSpecifiedByHashcode
public boolean isTargetSpecifiedByHashcode()
- Returns true if the command was "get #hashcode ", which
usually means it was created by clicking the mouse on an item
(e.g. in the ground window).
- Returns:
- true if the target of the event is specified by its hashcode.