dip.world
Class World

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

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

The entire game World. This contains the state of an entire game.

A World contains:

  1. Map (dip.world.Map) object [constant]
  2. TurnState objects [in a linked hash map]
  3. HashMap of per-power and global state information (used to set various data)

See Also:
Serialized Form

Nested Class Summary
static class World.VariantInfo
          Variant Info is a class which holds information about the variant, map, symbols, and symbol options.
 
Constructor Summary
protected World(Map map)
          Constructs a World object.
 
Method Summary
 java.util.List getAllTurnStates()
          Get all TurnStates.
 GameMetadata getGameMetadata()
          Gets the Game metadata.
 GameSetup getGameSetup()
          Returns the GameSetup object
 java.lang.Object getGlobalState()
          Get the Global state object.
 TurnState getInitialTurnState()
          Gets the first TurnState object
 TurnState getLastTurnState()
          Gets the most current (last in the list) TurnState.
 Map getMap()
          Returns the Map (dip.world.Map) associated with this World.
 TurnState getNextTurnState(TurnState state)
          Gets the TurnState that comes after this phase (if it exists).
 java.util.Set getPhaseSet()
          returns sorted (ascending) set of all Phases
 PlayerMetadata getPlayerMetadata(Power power)
          Gets the metadata for a power.
 java.lang.Object getPowerState(Power power)
          Gets any special per-power state information that is not associated with a particular TurnState.
 PressStore getPressStore()
          Get the PressStore object, which stores and retreives Press messages.
 TurnState getPreviousTurnState(TurnState state)
          Gets the TurnState that comes before the specified phase.
 RuleOptions getRuleOptions()
          Convenience method: gets RuleOptions from VariantInfo object.
 TurnState getTurnState(Phase phase)
          Gets the TurnState associated with the specified Phase
 UndoRedoManager getUndoRedoManager()
          Gets the UndoRedo manager that was saved.
 World.VariantInfo getVariantInfo()
          Get the Variant Info object.
 VictoryConditions getVictoryConditions()
          Get the Victory Conditions
static World open(java.io.File file)
          Reads a World object from a file.
 void removeAllTurnStates()
          Removes all TurnStates from the World.
 void removeTurnState(TurnState turnState)
          Removes a turnstate from the world.
static void save(java.io.File file, World world)
          Saves a World object to a file.
 void setGameMetadata(GameMetadata gmd)
          Sets the Game metadata
 void setGameSetup(GameSetup gs)
          Sets the GameSetup object
 void setGlobalState(java.lang.Object state)
          Set the Global state object.
 void setPlayerMetadata(Power power, PlayerMetadata pmd)
          Sets the metadata for a player, referenced by Power
 void setPowerState(Power power, java.lang.Object state)
          Sets any special per-power state information that is not associated with a particular TurnState.
 void setRuleOptions(RuleOptions ruleOpts)
          Convenience method: sets RuleOptions in VariantInfo object.
 void setTurnState(TurnState turnState)
          If a TurnState with the given phase already exists, it is replaced.
 void setUndoRedoManager(UndoRedoManager urm)
          Sets the UndoRedo manager to be saved.
 void setVariantInfo(World.VariantInfo vi)
          Set the Variant Info object.
 void setVictoryConditions(VictoryConditions value)
          Set the Victory Conditions
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

World

protected World(Map map)
Constructs a World object.

Method Detail

open

public static World open(java.io.File file)
                  throws java.io.IOException
Reads a World object from a file.

Throws:
java.io.IOException

save

public static void save(java.io.File file,
                        World world)
                 throws java.io.IOException
Saves a World object to a file.

Throws:
java.io.IOException

getMap

public Map getMap()
Returns the Map (dip.world.Map) associated with this World.


setPowerState

public void setPowerState(Power power,
                          java.lang.Object state)
Sets any special per-power state information that is not associated with a particular TurnState. This may be set to null.


getPowerState

public java.lang.Object getPowerState(Power power)
Gets any special per-power state information that is not associated with a particular TurnState. This may return null.


setGlobalState

public void setGlobalState(java.lang.Object state)
Set the Global state object. This may be set to null.


getGlobalState

public java.lang.Object getGlobalState()
Get the Global state object. This may return null.


setVictoryConditions

public void setVictoryConditions(VictoryConditions value)
Set the Victory Conditions


getVictoryConditions

public VictoryConditions getVictoryConditions()
Get the Victory Conditions


getInitialTurnState

public TurnState getInitialTurnState()
Gets the first TurnState object


getLastTurnState

public TurnState getLastTurnState()
Gets the most current (last in the list) TurnState.


getTurnState

public TurnState getTurnState(Phase phase)
Gets the TurnState associated with the specified Phase


getNextTurnState

public TurnState getNextTurnState(TurnState state)
Gets the TurnState that comes after this phase (if it exists).

Note that the next phase may not be (due to phase skipping) the same phase generated by phase.getNext(). This will return null iff we are at the last Phase.


getAllTurnStates

public java.util.List getAllTurnStates()
Get all TurnStates. Note that the returned List may be modified, without modifications being reflected in the World object. However, modifications to individual TurnState objects will be reflected in the World object (TurnStates are not cloned here).


getPreviousTurnState

public TurnState getPreviousTurnState(TurnState state)
Gets the TurnState that comes before the specified phase.

Note that the previous phase may not be (due to phase skipping) the same phase generated by phase.getPrevious(). This will return null iff we are at the first (initial) Phase.


setTurnState

public void setTurnState(TurnState turnState)
If a TurnState with the given phase already exists, it is replaced.


removeTurnState

public void removeTurnState(TurnState turnState)
Removes a turnstate from the world. This should be used with caution!


removeAllTurnStates

public void removeAllTurnStates()
Removes all TurnStates from the World.


getPhaseSet

public java.util.Set getPhaseSet()
returns sorted (ascending) set of all Phases


setGameMetadata

public void setGameMetadata(GameMetadata gmd)
Sets the Game metadata


getGameMetadata

public GameMetadata getGameMetadata()
Gets the Game metadata. Never returns null. Does not return a copy.


setPlayerMetadata

public void setPlayerMetadata(Power power,
                              PlayerMetadata pmd)
Sets the metadata for a player, referenced by Power


getPlayerMetadata

public PlayerMetadata getPlayerMetadata(Power power)
Gets the metadata for a power. Never returns null. Does not return a copy.


setUndoRedoManager

public void setUndoRedoManager(UndoRedoManager urm)
Sets the UndoRedo manager to be saved. This may be set to null.


getUndoRedoManager

public UndoRedoManager getUndoRedoManager()
Gets the UndoRedo manager that was saved. Null if none was saved.


setGameSetup

public void setGameSetup(GameSetup gs)
Sets the GameSetup object


getGameSetup

public GameSetup getGameSetup()
Returns the GameSetup object


getPressStore

public PressStore getPressStore()
Get the PressStore object, which stores and retreives Press messages.


getVariantInfo

public World.VariantInfo getVariantInfo()
Get the Variant Info object. This returns a Reference to the Variant information.


setVariantInfo

public void setVariantInfo(World.VariantInfo vi)
Set the Variant Info object.


getRuleOptions

public RuleOptions getRuleOptions()
Convenience method: gets RuleOptions from VariantInfo object.


setRuleOptions

public void setRuleOptions(RuleOptions ruleOpts)
Convenience method: sets RuleOptions in VariantInfo object.



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