heurgame.event.turn
Class AbstractTurnIterator

java.lang.Object
  extended byheurgame.event.turn.AbstractTurnIterator
Direct Known Subclasses:
AbstractTokenBasedIterator

public abstract class AbstractTurnIterator
extends java.lang.Object

Author:
David Kaplin One pattern I found was using integers to represent each player. By itself is a fine way of doing things, but there seems to be too much of a temptation to change the for loop or the counter in strange ways to make that representation horrible to read and debug. This abstraction allows a variety of different sorts of TurnIterators. Some may be based on the order of Player Tokens, others might not have any discernable order at all.

Field Summary
protected  java.util.Vector mylisteners
          The entities that are intent on finding out the current turn mylisteners
 
Constructor Summary
AbstractTurnIterator()
           
 
Method Summary
 void addTurnListener(TurnListener t)
          Adds a Turn Listener to be notified of changes
abstract  boolean hasMore()
           
abstract  void next()
          Called when the next turn is desired
protected  void notifyTurnListeners(TurnEvent e)
          Unlike other listener/callback patterns this is NOT multithreaded.
 void removeAllTurnListeners()
          Silences the iterator's output
 void removeTurnListener(TurnListener t)
          Removes a Turn Listener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mylisteners

protected java.util.Vector mylisteners
The entities that are intent on finding out the current turn mylisteners

Constructor Detail

AbstractTurnIterator

public AbstractTurnIterator()
Method Detail

addTurnListener

public void addTurnListener(TurnListener t)
Adds a Turn Listener to be notified of changes

Parameters:
t - to be added

next

public abstract void next()
Called when the next turn is desired


hasMore

public abstract boolean hasMore()
Returns:
true if next can produce a valid turn event.

notifyTurnListeners

protected void notifyTurnListeners(TurnEvent e)
Unlike other listener/callback patterns this is NOT multithreaded. Order must be maintained during a single turn.

Parameters:
e - The event to be broadcast to all listeners

removeTurnListener

public void removeTurnListener(TurnListener t)
Removes a Turn Listener

Parameters:
t - to be removed

removeAllTurnListeners

public void removeAllTurnListeners()
Silences the iterator's output