games.strategy.engine.data
Class AllianceTracker

java.lang.Object
  extended by games.strategy.engine.data.GameDataComponent
      extended by games.strategy.engine.data.AllianceTracker
All Implemented Interfaces:
java.io.Serializable

public class AllianceTracker
extends GameDataComponent

Tracks alliances between players. An alliance is a named entity, players are added to an alliance.

Version:
1.0
Author:
Sean Bridges
See Also:
Serialized Form

Constructor Summary
AllianceTracker(GameData data)
          Creates new Alliance Tracker.
 
Method Summary
protected  void addToAlliance(PlayerID player, java.lang.String allianceName)
          Adds PlayerID player to the alliance specified by allianceName.
 java.util.Set<java.lang.String> getAlliances()
           
 java.util.Set<PlayerID> getPlayersInAlliance(java.lang.String allianceName)
          Returns the PlayerID's that are members of the alliance specified by the String allianceName
 boolean isAllied(PlayerID p1, PlayerID p2)
          Returns whether two players are allied.
protected  void removeFromAlliance(PlayerID player, java.lang.String allianceName)
          Removes player from alliance allianceName.
 
Methods inherited from class games.strategy.engine.data.GameDataComponent
getData, readInternal, writeInternal
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AllianceTracker

public AllianceTracker(GameData data)
Creates new Alliance Tracker.

Method Detail

addToAlliance

protected void addToAlliance(PlayerID player,
                             java.lang.String allianceName)
Adds PlayerID player to the alliance specified by allianceName.

Parameters:
player - The player to add to the alliance.
allianceName - The alliance to add to.

removeFromAlliance

protected void removeFromAlliance(PlayerID player,
                                  java.lang.String allianceName)
Removes player from alliance allianceName. Throws an exception if player is not in that alliance. Throws an exception if the player is not in the specified alliance.

Parameters:
player - The player to remove from the alliance.
allianceName - The alliance to remove from.

isAllied

public boolean isAllied(PlayerID p1,
                        PlayerID p2)
Returns whether two players are allied.
isAllied(a,a) returns true.


getAlliances

public java.util.Set<java.lang.String> getAlliances()
Returns:
a set of all the games alliances

getPlayersInAlliance

public java.util.Set<PlayerID> getPlayersInAlliance(java.lang.String allianceName)
Returns the PlayerID's that are members of the alliance specified by the String allianceName

Parameters:
allianceName - Alliance name
Returns:
all the players in the given alliance