dd.sim
Class GameRoot

java.lang.Object
  extended bydd.sim.SimObject
      extended bydd.sim.GameRoot
All Implemented Interfaces:
java.io.Serializable

public class GameRoot
extends SimObject

The GameRoot contains all of the other objects that make up the game, including the player objects, proposals, scenario, game state, and the map. Other than the accessors for each component, it's mostly just a normal SimObject. It also has a number of functions that require access from the "top-level" of the game data. Functions with no javadoc should be self-explanatory.

Author:
Seth McGinnis
See Also:
Serialized Form

Field Summary
 
Fields inherited from class dd.sim.SimObject
attributes
 
Constructor Summary
GameRoot()
           
 
Method Summary
 void addNewProposal(java.lang.String family)
          Creates a new Proposal of the given family by reading it in from xml, gets an ID for it from the TurnServer and sets it, and stores the Proposal in the registry.
 boolean alwaysTooCostly(Proposal prop)
           
 void castVote(Player player, Proposal proposal, int vote)
           
 void createProposalsPage()
          Creates the (HTML) help page that has a link to each proposal available this round and stores it as a String in the proposalsPage attribute.
 boolean currentlyTooCostly(Proposal prop)
           
 java.util.Collection getActiveProposals()
           
 Registry getConnectedPlayers()
           
static CostTable getCostTable()
           
 java.util.List getCurrentProposals()
          Returns a sorted List of the Proposals in the ProposalRegistry that have status STATUS_NEW or status STATUS_PLAYED.
 java.util.List getFailedProposals()
          Returns a sorted List of the Proposals in the ProposalRegistry that have status STATUS_FAILED.
 java.lang.String getGameName()
           
 int getHumanPlayers()
           
 java.util.List getInactiveProposals()
           
 java.util.List getNewProposals()
          Returns a sorted List of the Proposals in the ProposalRegistry that have status STATUS_NEW.
 Player getOwner(Proposal prop)
           
 java.util.List getPassedProposals()
          Returns a sorted List of the Proposals in the ProposalRegistry that have status STATUS_PASSED.
 java.lang.String getPhase()
           
 java.util.List getPlayedProposals()
          Returns a sorted List of the Proposals in the ProposalRegistry that have status STATUS_PLAYED.
 Registry getPlayers()
           
 java.lang.String getPlayerStatus(java.lang.String pid)
           
 Registry getProposalRegistry()
           
 java.util.Collection getProposals()
           
 java.lang.String getProposalsPage()
           
 java.lang.String getProposalSummaries()
          Creates an HTML string containing an unordered list of the titles and short descriptions of the proposals in the registry with status STATUS_NEW.
 float getRawScore(java.lang.String metric)
           
 float getRawScore(java.lang.String metric, Layer l)
           
 Scenario getScenario()
           
 float getScore(java.lang.String metric)
           
 float getScore(java.lang.String metric, Layer l)
           
 java.util.List getStatusProposals(java.lang.String status)
          Returns a sorted List of the Proposals in the ProposalRegistry that have the given status.
 java.lang.String getTurnSummary()
          Prints a summary of the turn that just finished in HTML format.
 Proposal getUpForVote()
           
 java.lang.String htmlScoreBars()
           
 java.lang.String htmlScoreBars(boolean all)
           
static void main(java.lang.String[] args)
           
 void nextTurn()
          Calls reset() on each Player, resetting their votes.
 Player player(java.lang.String pid)
           
 Proposal proposal(java.lang.String pid)
           
 void resetPlayerStatus()
           
 java.lang.String roleForPlayer(int turnNumber)
           
 void setGameName(java.lang.String name)
           
 void setHumanPlayers(int num)
           
 void setPhase(java.lang.String phase)
           
 void setPlayerStatus(java.lang.String pid, java.lang.String status)
           
 void setProposals(Registry proposals)
           
 void setUpForVote(Proposal p)
          Sets the "upForVote" attribute to the pid of the given proposal and does appropriate things with the one bonus vote players always get.
 void spendRemainingBudget()
           
static GameRoot tutorial()
           
 
Methods inherited from class dd.sim.SimObject
addPropertyChangeListener, addPropertyChangeListener, debug, duplicate, error, fatal, filter, filter, firePropertyChange, getAttribute, getAttribute, getAttributes, getGlobalAttribute, getObjectAttribute, getObjectAttribute, incrementAttribute, incrementAttribute, isSet, log, out, readFromXML, readFromXML, removeAttribute, removePropertyChangeListener, setAttribute, setAttribute, setAttribute, setAttributes, setGlobalAttribute, warning, writeText, writeXML, writeXML
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GameRoot

public GameRoot()
Method Detail

getCostTable

public static CostTable getCostTable()

tutorial

public static GameRoot tutorial()

getProposals

public java.util.Collection getProposals()

getProposalRegistry

public Registry getProposalRegistry()

setProposals

public void setProposals(Registry proposals)

getPlayers

public Registry getPlayers()

setGameName

public void setGameName(java.lang.String name)

getGameName

public java.lang.String getGameName()

setHumanPlayers

public void setHumanPlayers(int num)

getHumanPlayers

public int getHumanPlayers()

getConnectedPlayers

public Registry getConnectedPlayers()

getScenario

public Scenario getScenario()

nextTurn

public void nextTurn()
Calls reset() on each Player, resetting their votes. Everything else happens in Scenario.nextTurn().


addNewProposal

public void addNewProposal(java.lang.String family)
Creates a new Proposal of the given family by reading it in from xml, gets an ID for it from the TurnServer and sets it, and stores the Proposal in the registry.


createProposalsPage

public void createProposalsPage()
Creates the (HTML) help page that has a link to each proposal available this round and stores it as a String in the proposalsPage attribute. Should be called only after all new proposals have been added.


getProposalsPage

public java.lang.String getProposalsPage()

getProposalSummaries

public java.lang.String getProposalSummaries()
Creates an HTML string containing an unordered list of the titles and short descriptions of the proposals in the registry with status STATUS_NEW.


castVote

public void castVote(Player player,
                     Proposal proposal,
                     int vote)

getOwner

public Player getOwner(Proposal prop)

getUpForVote

public Proposal getUpForVote()

setUpForVote

public void setUpForVote(Proposal p)
Sets the "upForVote" attribute to the pid of the given proposal and does appropriate things with the one bonus vote players always get.


spendRemainingBudget

public void spendRemainingBudget()

alwaysTooCostly

public boolean alwaysTooCostly(Proposal prop)

currentlyTooCostly

public boolean currentlyTooCostly(Proposal prop)

proposal

public Proposal proposal(java.lang.String pid)

player

public Player player(java.lang.String pid)

setPhase

public void setPhase(java.lang.String phase)

getPhase

public java.lang.String getPhase()

setPlayerStatus

public void setPlayerStatus(java.lang.String pid,
                            java.lang.String status)

resetPlayerStatus

public void resetPlayerStatus()

getPlayerStatus

public java.lang.String getPlayerStatus(java.lang.String pid)

roleForPlayer

public java.lang.String roleForPlayer(int turnNumber)

getScore

public float getScore(java.lang.String metric)

getScore

public float getScore(java.lang.String metric,
                      Layer l)

getRawScore

public float getRawScore(java.lang.String metric)

getRawScore

public float getRawScore(java.lang.String metric,
                         Layer l)

getNewProposals

public java.util.List getNewProposals()
Returns a sorted List of the Proposals in the ProposalRegistry that have status STATUS_NEW.


getPlayedProposals

public java.util.List getPlayedProposals()
Returns a sorted List of the Proposals in the ProposalRegistry that have status STATUS_PLAYED.


getPassedProposals

public java.util.List getPassedProposals()
Returns a sorted List of the Proposals in the ProposalRegistry that have status STATUS_PASSED.


getFailedProposals

public java.util.List getFailedProposals()
Returns a sorted List of the Proposals in the ProposalRegistry that have status STATUS_FAILED.


getStatusProposals

public java.util.List getStatusProposals(java.lang.String status)
Returns a sorted List of the Proposals in the ProposalRegistry that have the given status. Proposals sort in alphabetical order by title, except that "End Turn Now" always comes last.


getCurrentProposals

public java.util.List getCurrentProposals()
Returns a sorted List of the Proposals in the ProposalRegistry that have status STATUS_NEW or status STATUS_PLAYED.


getInactiveProposals

public java.util.List getInactiveProposals()

getActiveProposals

public java.util.Collection getActiveProposals()

getTurnSummary

public java.lang.String getTurnSummary()
Prints a summary of the turn that just finished in HTML format.

Returns:
an HTML-formatted summary of this turn.

htmlScoreBars

public java.lang.String htmlScoreBars()

htmlScoreBars

public java.lang.String htmlScoreBars(boolean all)

main

public static void main(java.lang.String[] args)