wyvern.kernel.player
Class GroundViewer

java.lang.Object
  extended bywyvern.kernel.player.GroundViewer
All Implemented Interfaces:
Visitor

public class GroundViewer
extends java.lang.Object
implements Visitor

This class visits the items beneath a player and formats them for display in the client's ground view.

Version:
1.0, Mar 25, 1998
Author:
Steve Yegge

Constructor Summary
GroundViewer(Player player, Predicate exclude)
          Constructs a new GroundViewer
 
Method Summary
 void addObject(GameObject obj)
          Adds an object to the list, provided it's not in the cache already.
protected  boolean checkAdd(GameObject obj)
          Right now, we use a non-extensible method of determining visibility for the ground camera.
 boolean checkVisibility(GameObject obj)
          Checks if the player can see the object using various visibility rules.
 java.lang.String getCommands(GameObject obj)
          Returns a string containing the commands valid for this object, for displaying in a popup menu on the client when click on the object in inventory.
 java.util.List getLists()
          Returns a list of arrays.
 java.util.List getObjects()
          Returns the list of object descriptors to send to the client.
 boolean isExcludableSpell(GameObject obj)
          Returns true if ground-view spells are off for this client, and the passed object is a spell.
 void setLocations(java.util.List locs)
          Sets the locations this viewer wants to check.
 boolean shouldExclude(GameObject obj)
          Returns true if the Predicate passed in to our constructor wants to exclude the object.
 void visit(GameObject obj)
          Visits an object in the map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GroundViewer

public GroundViewer(Player player,
                    Predicate exclude)
Constructs a new GroundViewer

Parameters:
player - the player
exclude - a Predicate that returns true if the object should not be visible in the Ground view. Can be null.
Method Detail

setLocations

public void setLocations(java.util.List locs)
Sets the locations this viewer wants to check.


visit

public void visit(GameObject obj)
Visits an object in the map.

Specified by:
visit in interface Visitor
Parameters:
obj - a GameObject from the map to look at

addObject

public void addObject(GameObject obj)
Adds an object to the list, provided it's not in the cache already.

Parameters:
obj - the object to add and create a descriptor for

getObjects

public java.util.List getObjects()
Returns the list of object descriptors to send to the client.

Returns:
List a linked list of GroundObjDescriptors. Can be null if no visible objects were found.

checkAdd

protected boolean checkAdd(GameObject obj)
Right now, we use a non-extensible method of determining visibility for the ground camera. Lame, but we can fix it later. We can, for example, add an interface that a GameObject could implement to decide if it's visible in a player's ground view.

Parameters:
obj - a GameObject
Returns:
true to add the object

shouldExclude

public boolean shouldExclude(GameObject obj)
Returns true if the Predicate passed in to our constructor wants to exclude the object.


checkVisibility

public boolean checkVisibility(GameObject obj)
Checks if the player can see the object using various visibility rules.


isExcludableSpell

public boolean isExcludableSpell(GameObject obj)
Returns true if ground-view spells are off for this client, and the passed object is a spell.


getLists

public java.util.List getLists()
Returns a list of arrays.

Returns:
a List of 3 elements. The first element is a String[] of the object names. The second is a short[] of tile numbers. The final element is a short[] of offsets, where each element of the offset array has the x offset in the high byte and the y offset in the low byte;

getCommands

public java.lang.String getCommands(GameObject obj)
Returns a string containing the commands valid for this object, for displaying in a popup menu on the client when click on the object in inventory.