mstar
Class PlayerMap

java.lang.Object
  |
  +--java.util.AbstractCollection
        |
        +--java.util.AbstractList
              |
              +--java.util.Vector
                    |
                    +--mstar.PlayerMap

public class PlayerMap
extends java.util.Vector
implements java.io.Serializable

A class that implements a general map for storing information about player in the collaborative environment, and a set of methods for searching for players in the map. In addition there are a set of methods for reading and writing the maps to disk in both Java object format and pseudo-MAAS-Neotek format.

Version:
1.6
Author:
Thaddeus O. Cooper (cooper@tweenproject.org)
See Also:
Serialized Form

Fields inherited from class java.util.Vector
capacityIncrement, elementCount, elementData
 
Fields inherited from class java.util.AbstractList
modCount
 
Constructor Summary
PlayerMap()
          Create an empty player map.
PlayerMap(MudPlayer player)
          Create a player map and add the specified player.
 
Method Summary
 void add(MudPlayer player)
          Adds a player to the map and writes the map back to disk.
 void fastAdd(MudPlayer player)
          Adds a player to the map but does not write the maps to disk.
 int getId()
          Returns the player identifier for the next player.
 java.lang.String getMapFilename()
          Gets the output filename for the map
 MudPlayer getMudPlayer(int id)
          Given the id of a player in the map locate and return that player.
 MudPlayer getMudPlayer(MudPlayer p)
          Given a player find the player in the map.
 MudPlayer getMudPlayer(java.lang.String name)
          Locate a player with the given name.
static PlayerMap loadMap()
          Loads the player map from disk.
 boolean playerExists(int id)
          Determines if a player in the map exists with the given id.
 boolean playerExists(MudPlayer theMudPlayer)
          Determines if a MudPlayer in the map exists given another MudPlayer.
 boolean playerExists(java.lang.String name)
          Determines if a player in the map exists with the given name.
 void setMapFilename(java.lang.String mapFilename)
          Sets the output filename for the map
 java.lang.String toString()
          Returns a String representation of the map.
 void WriteMap()
          Writes the map out in psuedo-MAAS-Neotek format.
 void WriteMapAsObjects()
          Write the map out to disk as a set of Java objects.
 
Methods inherited from class java.util.Vector
add, add, addAll, addAll, addElement, capacity, clear, clone, contains, containsAll, copyInto, elementAt, elements, ensureCapacity, equals, firstElement, get, hashCode, indexOf, indexOf, insertElementAt, isEmpty, lastElement, lastIndexOf, lastIndexOf, remove, remove, removeAll, removeAllElements, removeElement, removeElementAt, removeRange, retainAll, set, setElementAt, setSize, size, subList, toArray, toArray, trimToSize
 
Methods inherited from class java.util.AbstractList
iterator, listIterator, listIterator
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PlayerMap

public PlayerMap()
Create an empty player map.

PlayerMap

public PlayerMap(MudPlayer player)
Create a player map and add the specified player.
Parameters:
player - the player to be added to the map.
Method Detail

getId

public int getId()
Returns the player identifier for the next player.
Parameters:
the - integer identifier for the next player to be added.

loadMap

public static PlayerMap loadMap()
Loads the player map from disk.
Returns:
the PlayerMap that was loaded or null if there was no map to load.

add

public void add(MudPlayer player)
Adds a player to the map and writes the map back to disk.
Parameters:
player - the player to add to the map.

fastAdd

public void fastAdd(MudPlayer player)
Adds a player to the map but does not write the maps to disk.
Parameters:
player - the player to add to the map.

getMudPlayer

public MudPlayer getMudPlayer(MudPlayer p)
Given a player find the player in the map.
Parameters:
p - the player to locate in the map.
Returns:
the player from the map or null if the player doesn't exist.

getMudPlayer

public MudPlayer getMudPlayer(int id)
Given the id of a player in the map locate and return that player.
Parameters:
id - of the player to locate in the map.
Returns:
the player from the map or null if the player doesn't exist.

getMudPlayer

public MudPlayer getMudPlayer(java.lang.String name)
Locate a player with the given name.
Parameters:
name - the name of the player to locate.
Returns:
a player with the given name from the map or null if the player is not present in the map.

playerExists

public boolean playerExists(java.lang.String name)
Determines if a player in the map exists with the given name.
Parameters:
name - of the player to check for.
Returns:
true if the player exists, false if they do not.

playerExists

public boolean playerExists(int id)
Determines if a player in the map exists with the given id.
Parameters:
id - of the player to check for.
Returns:
true if the player exists, false if they do not.

playerExists

public boolean playerExists(MudPlayer theMudPlayer)
Determines if a MudPlayer in the map exists given another MudPlayer.
Parameters:
theMudPlayer - to check the map for.
Returns:
true if the player exists, false if they do not.

toString

public java.lang.String toString()
Returns a String representation of the map.
Overrides:
toString in class java.util.Vector
Returns:
a String representation of the map.

setMapFilename

public void setMapFilename(java.lang.String mapFilename)
Sets the output filename for the map
Parameters:
mapFilename - the filename that should be used for reading and writing the map.

getMapFilename

public java.lang.String getMapFilename()
Gets the output filename for the map
Returns:
the filename that should be used for reading and writing the map.

WriteMapAsObjects

public void WriteMapAsObjects()
Write the map out to disk as a set of Java objects.

WriteMap

public void WriteMap()
Writes the map out in psuedo-MAAS-Neotek format.