se.chalmers.dat255.risk.model
class WorldHandler extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
WorldHandler.ProvinceResult
enum constants for different outcomes of handleProvinceEvent
|
Constructor and Description |
---|
WorldHandler(TurnAndPhaseManager phaseHandler,
java.lang.String neighboursFile,
java.lang.String continentsFile,
java.util.List<java.lang.String> playersId) |
Modifier and Type | Method and Description |
---|---|
void |
changeOwner(IPlayer player)
changes owner of secondProvince to new player
|
void |
flushProvinces()
Inactivate saved provinces and removes their value
|
IPlayer |
getActivePlayer()
get the player whose turn it is
|
int |
getBonus()
returns the bonus of the current player
|
IProvince |
getNew()
Fetches the second province that was saved
|
IProvince |
getOld()
Fetches the first province that was saved
|
IPlayer |
getOwner(java.lang.String province)
Fetches the owner of a province
|
TurnAndPhaseManager.Phase |
getPhase()
fetches the current phase enum
|
java.util.List<IPlayer> |
getPlayers()
method for getting all players
|
java.util.List<java.lang.String> |
getPlayersContinents(IPlayer player)
returns all continents a player owns
|
java.util.List<IProvince> |
getProvinces()
fetches a list of all provinces
|
WorldMap |
getWorldMap()
method for reaching the worldmap
|
WorldHandler.ProvinceResult |
handleProvinceEvent(IProvince newProvince,
int bonus)
Determines what should be done with the chosen province
|
boolean |
isNeighbours(java.lang.String id,
java.lang.String id2)
checks if two provinces are neighbours
|
void |
moveToProvince(int nrOfUnits)
moves units from one province to another
|
void |
removePlayer(int pos)
removes a player from the game properly
|
boolean |
surrender()
Tell phasehandler to handle surrender
|
void |
updateBonus()
updates some variables
|
public WorldHandler(TurnAndPhaseManager phaseHandler, java.lang.String neighboursFile, java.lang.String continentsFile, java.util.List<java.lang.String> playersId)
public IProvince getOld()
public IProvince getNew()
public IPlayer getOwner(java.lang.String province)
province
- string representive of a provincepublic java.util.List<IProvince> getProvinces()
public boolean isNeighbours(java.lang.String id, java.lang.String id2)
id
- name of first provinceid2
- name of second provincepublic void changeOwner(IPlayer player)
player
- new owner of provincepublic java.util.List<java.lang.String> getPlayersContinents(IPlayer player)
player
- owner of continentspublic void updateBonus()
public IPlayer getActivePlayer()
public java.util.List<IPlayer> getPlayers()
public WorldHandler.ProvinceResult handleProvinceEvent(IProvince newProvince, int bonus)
newProvince
- new province to be handledbonus
- current players bonus unitspublic void flushProvinces()
public WorldMap getWorldMap()
public void moveToProvince(int nrOfUnits)
nrOfUnits
- amount of units to be movedpublic TurnAndPhaseManager.Phase getPhase()
public void removePlayer(int pos)
pos
- the players position in listpublic boolean surrender()
public int getBonus()