public class Simulator
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
static java.io.PrintStream |
dbg |
| Constructor and Description |
|---|
Simulator()
This constructor should be called once at the start of each game by the Server.
|
| Modifier and Type | Method and Description |
|---|---|
void |
discard(EnumRegion playerRegion,
EnumPolicy card)
The Server must call this for each card that is discarded before calling
nextTurn().
|
EnumPolicy[] |
drawCards(EnumRegion playerRegion)
The server must call this for each playerRegion before the first turn
and during each turn's draw phase.
|
EnumRegion |
getRegion(double latitude,
double longitude) |
java.util.ArrayList<GeographicArea>[] |
getRegionBoundaries() |
java.util.ArrayList<WorldData> |
getWorldData(int yearFrom,
int yearThrough)
At the start of the game, before dealing cards to players, the Server should call:
getWorldData(Constant.FIRST_DATA_YEAR, Constant.FIRST_GAME_YEAR-1);
|
java.util.List<AbstractEvent> |
getWorldEvents()
Get a list of special events in the world
|
static void |
main(java.lang.String[] args)
This entry point is for testing only.
|
WorldData |
nextTurn(java.util.ArrayList<PolicyCard> cards)
The Server should call nextTurn(cards) when it is ready to advance the simulator
a turn (Constant.YEARS_PER_TURN years).
Before calling nextTurn, the Server must: Verify all policy cards drafted by the clients during the draft phase. Verify that any cards discarded by a player could be discarded. Call discard on each card discarded by a player. End the voting phase and decide the results. Call discard on each card that did not receive enough votes. Call drawCards for each player and send them their new cards. |
static void |
setLogFile(java.lang.String fileName)
Configure the system logger to write to both a log file and the console.
|
public Simulator()
public java.util.ArrayList<WorldData> getWorldData(int yearFrom, int yearThrough)
public java.util.ArrayList<GeographicArea>[] getRegionBoundaries()
public WorldData nextTurn(java.util.ArrayList<PolicyCard> cards)
cards - List of PolicyCards enacted this turn. Note: cards played but not
enacted (did not get required votes) must NOT be in this list.
Such cards must be discarded
(call discard(EnumRegion playerRegion, PolicyCard card))
before calling this method.public EnumPolicy[] drawCards(EnumRegion playerRegion)
playerRegion - region of player who id given the drawn cards.public void discard(EnumRegion playerRegion, EnumPolicy card)
playerRegion - player who owns the discarded card.card - to be discarded.public static void setLogFile(java.lang.String fileName)
throws java.io.IOException
fileName - Path to output log file.java.io.IOExceptionpublic java.util.List<AbstractEvent> getWorldEvents()
public EnumRegion getRegion(double latitude, double longitude)
latitude - Latitude ranges from -90 to 90. North latitude is positive.longitude - Longitude ranges from -180 to 180. East longitude is positive.public static void main(java.lang.String[] args)
This test shows how to instantiate the simulator and how to tell it to deal each player a hand of cards.
args - ignored.