heurgame.ui
Class PlayerColors

java.lang.Object
  extended byheurgame.ui.PlayerColors
All Implemented Interfaces:
PlayerListener

public class PlayerColors
extends java.lang.Object
implements PlayerListener

Author:
David Kaplin Many games use Colors to represent a player. This class attempts to assign unique colors from a random pool of 32-bit colors to each player as they enter the system.

Constructor Summary
PlayerColors()
           
 
Method Summary
 java.awt.Color getColor(PlayerToken t)
          Retrieves the color associated with a Token
 void playerJoined(PlayerEvent e)
          Adds a new color to represent the player
 void playerLeft(PlayerEvent e)
          Removes the color from the field
 void playerMoves(PlayerEvent e)
          Ignored
 void playerStatusChanged(PlayerEvent e)
          Ignored
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PlayerColors

public PlayerColors()
Method Detail

getColor

public java.awt.Color getColor(PlayerToken t)
Retrieves the color associated with a Token

Parameters:
t - The Token to be represented
Returns:
null, if the player hasn't joined, which is a highly unlikely scenareo because of the PlayerListener Interface.

playerJoined

public void playerJoined(PlayerEvent e)
Adds a new color to represent the player

Specified by:
playerJoined in interface PlayerListener
Parameters:
e - Player Specific information
See Also:
PlayerListener.playerJoined(heurgame.event.PlayerEvent)

playerLeft

public void playerLeft(PlayerEvent e)
Removes the color from the field

Specified by:
playerLeft in interface PlayerListener
Parameters:
e - Player Specific information
See Also:
PlayerListener.playerLeft(heurgame.event.PlayerEvent)

playerMoves

public void playerMoves(PlayerEvent e)
Ignored

Specified by:
playerMoves in interface PlayerListener
Parameters:
e - Information about the Player and the status of the Move
See Also:
PlayerListener.playerMoves(heurgame.event.PlayerEvent)

playerStatusChanged

public void playerStatusChanged(PlayerEvent e)
Ignored

Specified by:
playerStatusChanged in interface PlayerListener
Parameters:
e - Implementation defined
See Also:
PlayerListener.playerStatusChanged(heurgame.event.PlayerEvent)