wyvern.kernel.commands
Class GroupManager

java.lang.Object
  extended bywyvern.kernel.commands.GroupManager

public final class GroupManager
extends java.lang.Object

This class provides some static methods for managing Groupable objects.

Version:
1.0, Oct 14, 1998
Author:
Steve Yegge

Method Summary
static boolean canGroup(GameObject first, GameObject second)
          Compares two objects for grouping equality.
static GameObject makeGroup(GameObject one, GameObject two)
          Takes two groupable GameObjects and makes them a single object with the combined quantity.
static java.lang.String quantifyName(GameObject obj, int qty)
          Takes a quantity and a description, and produces a quantified description.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

canGroup

public static boolean canGroup(GameObject first,
                               GameObject second)
Compares two objects for grouping equality.

Several checks are done. The objects must have the same class and the same short description. This predicate doesn't check to see if the objects both have the "groupable" property; it's assumed that the caller ascertains this before passing the objects to the predicate.

Parameters:
first - one of the two objects
second - the other object
Returns:
true if they can be joined into a groupf

makeGroup

public static GameObject makeGroup(GameObject one,
                                   GameObject two)
Takes two groupable GameObjects and makes them a single object with the combined quantity.


quantifyName

public static java.lang.String quantifyName(GameObject obj,
                                            int qty)
Takes a quantity and a description, and produces a quantified description. Relies on the fact that if the object is normally plural (e.g. gold coins), it has a "singular" property with the singular name.

Parameters:
obj - the object to describe
qty - the number
Returns:
if qty is 1, returns "1 " + the singular description. If qty > 1, returns qty + the plural description. returns