dip.world
Class TurnState

java.lang.Object
  extended bydip.world.TurnState
All Implemented Interfaces:
java.io.Serializable

public class TurnState
extends java.lang.Object
implements java.io.Serializable

A TurnState represents a snapshot of the game for the given Phase. The essential components of a TurnState are, then:

Note that we store Map (Province) adjacency data seperately from the Map (it's in the World object), so Map objects are re-constituted from a list of Provinces and Powers. This occurs behind-the-scenes when a World (or TurnState) object is deserialized.

This object is NOT SYNCHRONIZED and therefore not inherently threadsafe.

Also note that when a List of orders is obtained for a power, we do not check that the list contains only orders for that power. (e.g., are non-power orders 'snuck in' for a given power)

See Also:
Serialized Form

Constructor Summary
protected TurnState()
          Creates a TurnState object.
  TurnState(Phase phase)
          Creates a TurnState object.
 
Method Summary
 void clearAllOrders()
          Clear all Orders, for all Powers.
 java.util.List getAllOrders()
          Returns a List of orders for all powers.
 java.util.List getOrders(Power power)
          Returns the List of orders for a given Power.
 Phase getPhase()
          Returns the current Phase
 Position getPosition()
          Gets the Position data for this TurnState
 java.util.List getResultList()
          Returns the result list
 boolean getSCOwnerChanged()
          A flag indicating if, after adjudication, any supply centers have changed ownership.
 World getWorld()
          Gets the World object associated with this TurnState.
 boolean isEnded()
          Returns true if game has ended
 boolean isOrderSuccessful(Orderable o)
          Returns if an order has failed, based on results.
 boolean isResolved()
          Returns the turn has been adjudicated
 void setEnded(boolean value)
          Set if game has ended for any reason
 void setOrders(Power power, java.util.List list)
          Sets the orders for the given Power, deleting any existing orders for the power
 void setPhase(Phase phase)
          This should be used with the utmost care.
 void setPosition(Position position)
          Sets the Position data for this TurnState
 void setResolved(boolean value)
          Set if the turn has been adjudicated.
 void setResultList(java.util.List list)
          Sets the Result list, erasing any previously existing result list.
 void setSCOwnerChanged(boolean value)
          Sets the flag indicating if, after adjudication, any supply centers have changed ownership.
 void setWorld(World world)
          Set the World object associated with this TurnState.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TurnState

protected TurnState()
Creates a TurnState object.


TurnState

public TurnState(Phase phase)
Creates a TurnState object.

Method Detail

setWorld

public void setWorld(World world)
Set the World object associated with this TurnState. A null World is not permitted.


getWorld

public World getWorld()
Gets the World object associated with this TurnState. Never should be null.


getPhase

public Phase getPhase()
Returns the current Phase


setPhase

public void setPhase(Phase phase)
This should be used with the utmost care. Null Phases are not allowed.


getPosition

public Position getPosition()
Gets the Position data for this TurnState


setPosition

public void setPosition(Position position)
Sets the Position data for this TurnState


getResultList

public java.util.List getResultList()
Returns the result list


setResultList

public void setResultList(java.util.List list)
Sets the Result list, erasing any previously existing result list.


getSCOwnerChanged

public boolean getSCOwnerChanged()
A flag indicating if, after adjudication, any supply centers have changed ownership.


setSCOwnerChanged

public void setSCOwnerChanged(boolean value)
Sets the flag indicating if, after adjudication, any supply centers have changed ownership.


getAllOrders

public java.util.List getAllOrders()
Returns a List of orders for all powers.

Manipulations to this list will not be reflected in the TurnState object.


clearAllOrders

public void clearAllOrders()
Clear all Orders, for all Powers.


getOrders

public java.util.List getOrders(Power power)
Returns the List of orders for a given Power.

Note that modifications to the returned order List will be reflected in the TurnState.


setOrders

public void setOrders(Power power,
                      java.util.List list)
Sets the orders for the given Power, deleting any existing orders for the power


setEnded

public void setEnded(boolean value)
Set if game has ended for any reason


isEnded

public boolean isEnded()
Returns true if game has ended


setResolved

public void setResolved(boolean value)
Set if the turn has been adjudicated.


isResolved

public boolean isResolved()
Returns the turn has been adjudicated


isOrderSuccessful

public boolean isOrderSuccessful(Orderable o)
Returns if an order has failed, based on results. Note that this only applies once the turnstate has been resolved. If the TurnState is not resolved, this will always return true.



Copyright 2002-2004 Zachary DelProposto / jDip Development Team. All Rights Reserved.