wyvern.lib.commands.autobag
Class AutobagRule

java.lang.Object
  extended bywyvern.lib.commands.autobag.AutobagRule

public class AutobagRule
extends java.lang.Object

Encapsulates a single Autobag rule, including the rule name, the conditions for activating this rule, and the bag(s) to put the items in when the rule is activated.

Version:
1.0, Dec 27, 2003
Author:
Steve Yegge

Constructor Summary
AutobagRule()
           
 
Method Summary
 void appendBagDesc(java.lang.StringBuffer sb)
           
 void appendConditions(java.lang.StringBuffer sb)
           
 boolean apply(Player p, GameObject o)
          Applies the rule by placing the item into the appropriate bag, if possible.
static java.lang.String encodeXMLStream(java.lang.String input)
          Escapes XML characters: &, <, >.
 BagList getBagList()
          Returns the list of destination bags for this rule.
 AutobagConditions getConditions()
          Returns the conditions for this rule.
 java.lang.String getName()
          Returns the name of the rule.
 boolean isDropRule()
          Returns true if there's only one bag name in this Rule, and it's "drop item".
 boolean match(GameObject obj)
          Returns true if the passed object passes our conditions.
 java.lang.String serialize()
          Returns a serialized version of the rule, in a canonical format similar to how the rules are specified.
 void setBagList(BagList list)
          Sets the list of bags we're going to insert into for this rule.
 void setConditions(AutobagConditions c)
           
 void setName(java.lang.String name)
           
 java.lang.String toString()
          Pretty-prints the rule.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

AutobagRule

public AutobagRule()
Method Detail

setBagList

public void setBagList(BagList list)
Sets the list of bags we're going to insert into for this rule.


setName

public void setName(java.lang.String name)

setConditions

public void setConditions(AutobagConditions c)

getName

public java.lang.String getName()
Returns the name of the rule.


getConditions

public AutobagConditions getConditions()
Returns the conditions for this rule.


match

public boolean match(GameObject obj)
Returns true if the passed object passes our conditions.

Parameters:
obj - the object to consider
Returns:
true if our AutobagConditions predicate passed the object

getBagList

public BagList getBagList()
Returns the list of destination bags for this rule.


toString

public java.lang.String toString()
Pretty-prints the rule.


appendBagDesc

public void appendBagDesc(java.lang.StringBuffer sb)

appendConditions

public void appendConditions(java.lang.StringBuffer sb)

serialize

public java.lang.String serialize()
Returns a serialized version of the rule, in a canonical format similar to how the rules are specified.


apply

public boolean apply(Player p,
                     GameObject o)
Applies the rule by placing the item into the appropriate bag, if possible.

Parameters:
p - the player
o - the item
Returns:
true if successful in placing it in one of the bags from the bag list for this rule

encodeXMLStream

public static java.lang.String encodeXMLStream(java.lang.String input)
Escapes XML characters: &, <, >. Quotes seem to work OK, so we're not escaping them.


isDropRule

public boolean isDropRule()
Returns true if there's only one bag name in this Rule, and it's "drop item". In this case, the item will be placed on the ground immediately instead of being autobagged.