net.sf.colossus.game
Class Caretaker

java.lang.Object
  extended by net.sf.colossus.game.Caretaker

public class Caretaker
extends java.lang.Object

The caretaker tracks the number of creatures still available and those dead. For each creature type the number of creatures still available for mustering and the number of creatures already dead is stored. The latter function means this version of a caretaker integrates what is called a 'graveyard' in a normal Titan game.


Nested Class Summary
static interface Caretaker.ChangeListener
          Callback interface for listening to changes to the numbers.
 
Field Summary
private  java.util.Map<CreatureType,java.lang.Integer> creatureAvailableCounts
          Map of creature types to the number of available creatures.
private  java.util.Map<CreatureType,java.lang.Integer> creatureDeadCounts
          Map of creature types to the number of dead creatures.
private  Game game
          The game of which we manage the creatures.
private  java.util.List<Caretaker.ChangeListener> listeners
          All parties interested in changes to our numbers.
private static java.util.logging.Logger LOGGER
           
 
Constructor Summary
Caretaker(Game game)
           
 
Method Summary
 void addListener(Caretaker.ChangeListener listener)
           
 void adjustAvailableCount(CreatureType type)
           
 int getAvailableCount(CreatureType type)
           
 int getDeadCount(CreatureType type)
           
protected  Game getGame()
           
 void putDeadOne(CreatureType type)
           
 void putOneBack(CreatureType type)
           
 void removeListener(Caretaker.ChangeListener listener)
           
 void resetAllCounts()
           
 void resurrectImmortals()
          Move dead non-Titan immortals back to stacks.
 void setAvailableCount(CreatureType type, int availableCount)
           
 void setDeadCount(CreatureType type, int deadCount)
           
 void takeOne(CreatureType type)
           
private  void triggerFullUpdate()
           
private  void triggerOneAvailabilityCount(CreatureType type, int count)
           
private  void triggerOneCountUpdate(CreatureType type)
           
private  void triggerOneDeadCount(CreatureType type, int count)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

private static final java.util.logging.Logger LOGGER

creatureAvailableCounts

private final java.util.Map<CreatureType,java.lang.Integer> creatureAvailableCounts
Map of creature types to the number of available creatures.


creatureDeadCounts

private final java.util.Map<CreatureType,java.lang.Integer> creatureDeadCounts
Map of creature types to the number of dead creatures.


game

private final Game game
The game of which we manage the creatures.


listeners

private final java.util.List<Caretaker.ChangeListener> listeners
All parties interested in changes to our numbers.

Constructor Detail

Caretaker

public Caretaker(Game game)
Method Detail

resetAllCounts

public void resetAllCounts()

setAvailableCount

public void setAvailableCount(CreatureType type,
                              int availableCount)

setDeadCount

public void setDeadCount(CreatureType type,
                         int deadCount)

getAvailableCount

public int getAvailableCount(CreatureType type)

adjustAvailableCount

public void adjustAvailableCount(CreatureType type)

getDeadCount

public int getDeadCount(CreatureType type)

getGame

protected Game getGame()

addListener

public void addListener(Caretaker.ChangeListener listener)

removeListener

public void removeListener(Caretaker.ChangeListener listener)

triggerOneAvailabilityCount

private void triggerOneAvailabilityCount(CreatureType type,
                                         int count)

triggerOneDeadCount

private void triggerOneDeadCount(CreatureType type,
                                 int count)

triggerOneCountUpdate

private void triggerOneCountUpdate(CreatureType type)

triggerFullUpdate

private void triggerFullUpdate()

takeOne

public void takeOne(CreatureType type)

putOneBack

public void putOneBack(CreatureType type)

putDeadOne

public void putDeadOne(CreatureType type)

resurrectImmortals

public void resurrectImmortals()
Move dead non-Titan immortals back to stacks.