public class GameManager
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected Bank |
gameBank |
protected int |
gameID |
protected GameState |
gameState |
protected java.lang.String |
gameTitle |
protected GameActionLog |
log |
protected MapModel |
map |
protected OfferedTrade |
offeredTrade |
protected int |
playerCanMoveRobber |
protected int[] |
playerColors |
protected java.util.List<Player> |
players |
protected int |
version |
protected VictoryPointManager |
victoryPointManager |
protected ChatBox |
waterCooler |
Constructor and Description |
---|
GameManager()
Constructor for the game manager
|
GameManager(java.lang.String name,
int id)
Creates a game manager with the specified id
|
Modifier and Type | Method and Description |
---|---|
int |
AddPlayer(java.lang.String name,
CatanColor color,
boolean isHuman)
Adds a player to the game
|
int |
AddPlayer(java.lang.String name,
CatanColor color,
boolean isHuman,
int playerID)
Adds a players to the game
|
PlayerInfo[] |
allCurrentPlayers() |
void |
BuildCity(int playerIndex,
Coordinate location)
Attempts to build a road
|
void |
BuildRoad(int playerIndex,
Coordinate start,
Coordinate end,
boolean free)
Attempts to build a road
|
void |
BuildSettlement(int playerIndex,
Coordinate location,
boolean free)
Attempts to build a road
|
DevCardType |
BuyDevCard(int playerIndex)
Attempts to buy a dev card
|
boolean |
canAcceptTrade(int playerIndex)
Can do method for whether a player can accept an article
|
boolean |
CanBuildCity(int playerIndex)
Checks if a player can build a city
|
boolean |
CanBuildCity(int playerIndex,
Coordinate location)
Checks to see if a player can build a city
|
boolean |
CanBuildRoad(int playerIndex)
Just checks if a player can build a road
|
boolean |
CanBuildRoad(int playerIndex,
Coordinate start,
Coordinate end)
Checks to see if a player can build a road at a location
|
boolean |
CanBuildSettlement(int playerIndex)
Checks if a player can build the settlement
|
boolean |
CanBuildSettlement(int playerIndex,
Coordinate location)
checks to see if a player can build a settlement
|
boolean |
CanBuyDevCard(int playerIndex)
Checks to see if a player can buy a dev card
|
boolean |
canChat(int playerIndex)
Check if player can chat
|
boolean |
CanDiscardCards(int playerIndex,
ResourceType type,
int amount)
See if a player can discard cards
|
boolean |
CanFinishTurn()
Checks whether the current player can finish their turn
|
boolean |
CanFinishTurn(int playerIndex)
Checks whether a player can finish their turn
|
boolean |
CanMaritimeTrade(int playerIndex)
Can do method for determining whether a player can maritime trade
|
boolean |
CanOfferTrade(int playerIndex) |
boolean |
CanPlaceRobber(int playerIndex)
Checks to see if a player can place the robber
|
boolean |
CanPlayDevCard(int playerIndex,
DevCardType type)
Determines whenter player can play card
|
boolean |
CanPlayerPlay(int playerIndex)
Checks to see if it's a player's turn
|
boolean |
CanRollNumber(int playerIndex)
Checks to see if a player can roll their number
|
boolean |
CanUseMonopoly(int playerIndex)
Checks to see if a player can play a monopoly card
|
boolean |
CanUseMonument(int playerIndex)
Check to see if they have the momument card
|
boolean |
CanUseRoadBuilder(int playerIndex)
Checks if a player can use the road builder?
|
boolean |
CanUseSoldier(int playerIndex)
Checks if a player can play a solider card
|
boolean |
CanUseYearOfPlenty(int playerIndex)
Checks to see if the player can use a year of plenty picture
|
void |
CurrentPlayerChat(java.lang.String message)
When the player chats currently playing
|
int |
CurrentPlayersTurn()
Gets the player index of the current player
|
GameRound |
CurrentState()
Returns the current round of the game
|
void |
DiceRoll(int diceRoll)
Handles the roll of a die
|
void |
FinishTurn()
Ends the current player's turn
|
int |
getBankResourceCount(ResourceType resourceType)
Returns the number of the requested type of resource held by the bank
|
ChatBox |
getChat()
Returns the chat
|
protected Player |
GetCurrentPlayer()
Gets the current player
|
java.lang.String |
getCurrentPlayerName() |
GameActionLog |
getGameActionLog()
Returns the log
|
int |
GetGameID()
Returns the ID of the game
|
java.lang.String |
GetGameTitle()
Returns the game's title
|
int |
getNumberPlayers()
Gets the current number of players
|
protected Player |
GetPlayer(int playerIndex)
Gets the specified player
|
CatanColor |
getPlayerColorByIndex(int playerIndex) |
protected int |
GetPlayerIDbyIndex(int playerIndex)
Gets a player's ID
|
int |
getPlayerIndexByColor(CatanColor color)
Gets the player index by color
|
java.lang.String |
getPlayerNameByIndex(int playerIndex) |
int |
getTradeRatio(int playerIndex,
ResourceType type)
Gets the trade ratio for a given resource for a player
|
int |
GetVersion()
Returns the current version
|
VictoryPointManager |
getVictoryPointManager()
Returns the VictoryPointManager
|
boolean |
hasGameStarted()
Check whether the game has started
|
protected void |
LogAction(int playerIndex,
java.lang.String message)
Logs a action into the state log
|
protected boolean |
NeedToDiscardAfterRoll()
Determines if there is a player with over 7 cards
|
int |
NumberActivePlayers()
The number of players in a game
|
void |
payDayForDayz()
Testing function
|
void |
placeRobber(int playerIndex)
Places the robber
|
void |
playDevCard(int playerIndex,
DevCardType type)
Plays a dev card
|
void |
PlayerChat(int playerIndex,
java.lang.String message)
Chats for the specified player
|
int |
playerDevCardCount(int playerIndex)
Gets the total number of dev cards for a player
|
int |
playerDevCardCount(int playerIndex,
DevCardType type)
Gets the number of devCards for the current player
|
private boolean |
PlayerHasADevCard(int playerIndex,
DevCardType type)
Checks if a player has at least one dev card of the type
|
int |
playerPieceCount(int playerIndex,
PieceType type)
Gets the number of pieces for the current player
|
int |
playerResourceCount(int playerIndex,
ResourceType type)
Gets the number of resources for the player
|
void |
removeTradeOffer()
Removes any trade offers, if any exist
|
void |
reset()
Resets a game to default state
|
int |
RollDice() |
void |
SetPlayers(java.util.List<Player> players)
Sets the players
|
void |
setTradeOffer(OfferedTrade offeredTrade)
Sets the trade offer when one is made, it doesn't need to notify because this is already checked in the client
|
void |
StartGame()
Starts the game
|
protected int gameID
protected java.lang.String gameTitle
protected GameState gameState
protected Bank gameBank
protected java.util.List<Player> players
protected VictoryPointManager victoryPointManager
protected ChatBox waterCooler
protected OfferedTrade offeredTrade
protected GameActionLog log
protected MapModel map
protected int version
protected int[] playerColors
protected int playerCanMoveRobber
public GameManager()
public GameManager(java.lang.String name, int id)
name
- the title of the gameid
- public void reset()
public int AddPlayer(java.lang.String name, CatanColor color, boolean isHuman, int playerID) throws ModelException
name
- The name of the playercolor
- The piece colorisHuman
- True if human, else AIplayerID
- The id of the playerModelException
- Thrown if the player can't be addedpublic int AddPlayer(java.lang.String name, CatanColor color, boolean isHuman) throws ModelException
name
- ModelException
- if there are too many players already in the game or if that color has been usedpublic void SetPlayers(java.util.List<Player> players)
players
- public int getNumberPlayers()
public PlayerInfo[] allCurrentPlayers()
public java.lang.String getPlayerNameByIndex(int playerIndex)
playerIndex
- protected int GetPlayerIDbyIndex(int playerIndex)
playerIndexReceiving
- public java.lang.String getCurrentPlayerName()
public int getPlayerIndexByColor(CatanColor color)
color
- public CatanColor getPlayerColorByIndex(int playerIndex)
public int playerResourceCount(int playerIndex, ResourceType type)
playerIndex
- type
- public int playerDevCardCount(int playerIndex, DevCardType type)
playerIndex
- type
- public int playerDevCardCount(int playerIndex)
playerIndex
- public int playerPieceCount(int playerIndex, PieceType type)
playerIndex
- type
- public int NumberActivePlayers()
public void setTradeOffer(OfferedTrade offeredTrade)
offeredTrade
- public void removeTradeOffer()
public int GetVersion()
public int RollDice() throws ModelException
ModelException
- if we aren't in the rolling phaseprotected boolean NeedToDiscardAfterRoll()
protected void LogAction(int playerIndex, java.lang.String message)
playerIndex
- message
- public void DiceRoll(int diceRoll) throws ModelException
roll
- ModelException
public void BuildRoad(int playerIndex, Coordinate start, Coordinate end, boolean free) throws ModelException
playerIndex
- ModelException
- if the player doesn't have the resourcespublic void BuildSettlement(int playerIndex, Coordinate location, boolean free) throws ModelException
playerIndex
- ModelException
- if the player doesn't have the resourcespublic void BuildCity(int playerIndex, Coordinate location) throws ModelException
playerIndex
- ModelException
- if the player doesn't have the resourcesMapException
- if the Location doesn't existpublic DevCardType BuyDevCard(int playerIndex) throws ModelException
playerIndex
- 0 to 3ModelException
- if the player doesn't have the resourcespublic void playDevCard(int playerIndex, DevCardType type) throws ModelException
playerIndex
- type
- ModelException
public int getTradeRatio(int playerIndex, ResourceType type)
playerIndex
- public void placeRobber(int playerIndex) throws ModelException
playerIndex
- location
- ModelException
public boolean CanPlayerPlay(int playerIndex)
playerIndex
- 0 to 3public boolean CanDiscardCards(int playerIndex, ResourceType type, int amount)
playerIndex
- 0 to 3type
- the type of the resourceamount
- number to discardpublic boolean CanRollNumber(int playerIndex)
playerIndex
- public boolean CanBuildRoad(int playerIndex, Coordinate start, Coordinate end)
playerIndex
- 0-3location
- the edge's locationend
- public boolean CanBuildRoad(int playerIndex)
playerIndex
- public boolean CanBuildSettlement(int playerIndex, Coordinate location)
playerIndex
- location
- the vertexpublic boolean CanBuildSettlement(int playerIndex)
playerIndex
- public boolean CanBuildCity(int playerIndex, Coordinate location)
playerIndex
- 0 to 3location
- the vertexpublic boolean CanBuildCity(int playerIndex)
playerIndex
- public boolean CanOfferTrade(int playerIndex)
playerIndex
- public boolean canAcceptTrade(int playerIndex)
playerIndex
- public void payDayForDayz()
public boolean CanMaritimeTrade(int playerIndex)
playerIndex
- public boolean CanFinishTurn(int playerIndex)
playerIndex
- public boolean CanFinishTurn()
public boolean CanBuyDevCard(int playerIndex)
playerIndex
- 0 to 3public boolean canChat(int playerIndex)
playerIndex
- private boolean PlayerHasADevCard(int playerIndex, DevCardType type)
playerIndex
- type
- public boolean CanUseYearOfPlenty(int playerIndex)
playerIndex
- public boolean CanUseRoadBuilder(int playerIndex)
playerIndex
- public boolean CanUseSoldier(int playerIndex)
playerIndex
- public boolean CanUseMonopoly(int playerIndex)
playerIndex
- public boolean CanUseMonument(int playerIndex)
playerIndex
- public boolean CanPlayDevCard(int playerIndex, DevCardType type)
playerIndex
- type
- public boolean CanPlaceRobber(int playerIndex)
playerIndex
- public void CurrentPlayerChat(java.lang.String message)
message
- public void PlayerChat(int playerIndex, java.lang.String message)
playerIndex
- 0-3message
- public void StartGame()
public void FinishTurn() throws ModelException
ModelException
public int CurrentPlayersTurn()
protected Player GetPlayer(int playerIndex) throws ModelException
playerIndex
- 0 to 3ModelException
protected Player GetCurrentPlayer() throws ModelException
ModelException
public GameRound CurrentState()
public boolean hasGameStarted()
public java.lang.String GetGameTitle()
public int GetGameID()
public GameActionLog getGameActionLog()
public ChatBox getChat()
public VictoryPointManager getVictoryPointManager()
public int getBankResourceCount(ResourceType resourceType)
resourceType
-