wyvern.lib.properties
Class AutoGrab

java.lang.Object
  extended bywyvern.lib.properties.AutoGrab
All Implemented Interfaces:
MutableProperty, Predicate, SelfExternalizable

public class AutoGrab
extends java.lang.Object
implements SelfExternalizable, MutableProperty, Predicate

Keeps track of which item types the user automatically picks up.

Version:
1.0, Oct 4, 2000
Author:
Steve Yegge

Field Summary
protected  boolean all_
           
protected  boolean armor_
           
protected  boolean food_
           
protected  boolean magic_
           
protected  boolean missiles_
           
protected  boolean treasure_
           
protected  boolean weapons_
           
 
Constructor Summary
AutoGrab()
           
 
Method Summary
static java.lang.String allSettings()
          Returns all currently allowable settings, excluding "all" and "none".
static void copy(AutoGrab src, AutoGrab dest)
          Copies the boolean properties from one to the other.
 java.lang.Object createClone()
          Produces a clone of the property for the caller.
 void handleAutoGrab(Commandable agent)
          Looks under the agent to try to grab stuff we like.
 boolean hasNoSettings()
          Returns true if none of the settings are on for this object.
static AutoGrab parseSettings(java.lang.String settings)
          Parses the new settings.
 boolean predicate(GameObject obj)
          Returns true if the possessor of this AutoGrab property should pick up the passed item when moving over it.
 java.lang.String printSettings()
          Returns the current settings.
 void readData(org.w3c.dom.Node bean)
          Initializes the object from the XML file.
 boolean shouldWrite()
          Returns true if we should write the object at all.
 java.lang.String toString()
          Prints a debugging string representing this object.
 java.util.List writeData()
          Writes the object's externalized representation to the specified output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

all_

protected boolean all_

food_

protected boolean food_

magic_

protected boolean magic_

armor_

protected boolean armor_

weapons_

protected boolean weapons_

treasure_

protected boolean treasure_

missiles_

protected boolean missiles_
Constructor Detail

AutoGrab

public AutoGrab()
Method Detail

readData

public void readData(org.w3c.dom.Node bean)
              throws java.lang.Exception
Initializes the object from the XML file.

Specified by:
readData in interface SelfExternalizable
Parameters:
bean - the node representing the SelfExternalizable bean object, which should have at least one child data node.
Throws:
java.lang.Exception

writeData

public java.util.List writeData()
                         throws java.lang.Exception
Writes the object's externalized representation to the specified output stream.

Specified by:
writeData in interface SelfExternalizable
Returns:
a String containing the serialized version of the object.
Throws:
java.lang.Exception

shouldWrite

public boolean shouldWrite()
Returns true if we should write the object at all.

Specified by:
shouldWrite in interface SelfExternalizable
Returns:
false if we have no autograb settings

createClone

public java.lang.Object createClone()
Produces a clone of the property for the caller.

Specified by:
createClone in interface MutableProperty

handleAutoGrab

public void handleAutoGrab(Commandable agent)
Looks under the agent to try to grab stuff we like.

Parameters:
agent - the player or monster with autograb settings

predicate

public boolean predicate(GameObject obj)
Returns true if the possessor of this AutoGrab property should pick up the passed item when moving over it.

Specified by:
predicate in interface Predicate
Parameters:
obj - the object under consideration
Returns:
true if the player should pick it up

toString

public java.lang.String toString()
Prints a debugging string representing this object.


printSettings

public java.lang.String printSettings()
Returns the current settings.


parseSettings

public static AutoGrab parseSettings(java.lang.String settings)
Parses the new settings.

Parameters:
settings - a string like "armor magic food weapons"

copy

public static void copy(AutoGrab src,
                        AutoGrab dest)
Copies the boolean properties from one to the other.

Parameters:
src - the "from" object
dest - the "to" object

allSettings

public static java.lang.String allSettings()
Returns all currently allowable settings, excluding "all" and "none".


hasNoSettings

public boolean hasNoSettings()
Returns true if none of the settings are on for this object.