wyvern.lib.predicates
Class NameMatchPredicate

java.lang.Object
  extended bywyvern.lib.predicates.NameMatchPredicate
All Implemented Interfaces:
Predicate

public class NameMatchPredicate
extends java.lang.Object
implements Predicate

This class tests to see if the passed object's name matches a specified string. This is useful for finding the first object that matches some string the user types, e.g. "get sign" or "look at horse".

The matcher first looks for a short-description property, then a long-description, and failing to match these converts the class name.

Version:
1.0, Aug 26, 1997
Author:
Steve Yegge

Constructor Summary
NameMatchPredicate(java.lang.String match)
          Constructs a new NameMatchPredicate.
 
Method Summary
static boolean matches(java.lang.String m, GameObject obj)
          Returns true if the passed object matches the passed description.
 boolean predicate(GameObject obj)
          Returns true if our match-string is found in the passed Object's description.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

NameMatchPredicate

public NameMatchPredicate(java.lang.String match)
Constructs a new NameMatchPredicate.

Parameters:
match - the string to match in an object's description, insensitive of case.
Method Detail

predicate

public boolean predicate(GameObject obj)
Returns true if our match-string is found in the passed Object's description.

Specified by:
predicate in interface Predicate
Parameters:
obj - any GameObject
Returns:
true if the object passes, else false

matches

public static boolean matches(java.lang.String m,
                              GameObject obj)
Returns true if the passed object matches the passed description. (Thread-safe utility method).

Parameters:
obj - the GameObject to check
m - the name to match against the obj's description, using the same algorithm as is used in the predicate() method.

toString

public java.lang.String toString()