public class ClientGameManager extends GameManager implements ModelSubject
Modifier and Type | Field and Description |
---|---|
private Coordinate |
lastRoadBuiltEnd |
private Coordinate |
lastRoadBuiltStart |
private PieceType |
lastSelectedPiece |
private CatanColor |
myPlayerColor |
private int |
myPlayerIndex |
protected NotificationCenter |
notifyCenter |
private int |
playerIndexSendingOffer |
private int |
playerIndexWithTradeOffer |
private ServerProxy |
proxy |
private int |
refreshCount |
private int[] |
resourceToTrade |
private TurnState |
turnState |
private boolean |
updateInProgress
Reloads the game
|
gameBank, gameID, gameState, gameTitle, log, map, offeredTrade, playerCanMoveRobber, playerColors, players, version, victoryPointManager, waterCooler
Constructor and Description |
---|
ClientGameManager(GSONServerProxy clientProxy,
int myPlayerIndex)
Gets a client proxy
|
ClientGameManager(ServerProxy clientProxy)
Creates the client game manager with the proxy
|
Modifier and Type | Method and Description |
---|---|
void |
BuildCity(Coordinate point)
Builds a city for the current player
|
void |
BuildRoad(Coordinate start,
Coordinate end)
Builds a road for the current player
|
void |
BuildSettlement(Coordinate point)
Builds a settlement
|
boolean |
BuyDevCard()
Buys a dev card for the current player
|
boolean |
canBuildPiece(PieceType p) |
boolean |
CanPlaceRobber(int playerIndex)
Checks to see if a player can place the robber
|
GameInfo |
createGame(boolean randomTiles,
boolean randomNumbers,
boolean randomPorts,
java.lang.String name)
Joins a game
|
void |
DiscardCards(java.util.List<java.lang.Integer> resourceList)
Discards the cards specified by the resourceList list for the current player
|
void |
doneDiscarding()
Uses to let the discarding state to finish
|
void |
endTurn()
Ends the current player's turn
|
IMapModel |
GetMapModel() |
int |
getPlayerIndexWithTradeOffer() |
int |
getPlayerSendingOfferIndex() |
int |
GetPlayerSoliderCount()
Gets the number of soliders the current player has
|
int |
GetRefreshCount()
The number of times the server has refreshed itself- used to test the poller
|
int[] |
getResourceToTrade()
Returns the resources of the offered trade
|
TurnState |
getTurnState()
Gets the current TurnState
|
boolean |
joinGame(GameInfo game,
CatanColor color)
Joins a game
|
void |
LoadGame(GameInfo model)
Loads the game from the model recieved from the server
|
void |
maritimeTradeCurrentPlayer(int ratio,
ResourceType inputResource,
ResourceType outputResource)
Takes resource from the bank and gives them to the current player
|
CatanColor |
myPlayerColor()
The current player's color
|
int |
myPlayerIndex()
Get the Index of the current player client
|
PieceType |
myPlayerLastPiece() |
void |
offerTrade(java.util.List<java.lang.Integer> resourceList,
int receiver)
Offers a trade to a player
|
void |
PlaceRobber(Coordinate point) |
int |
playerDevCardCount(DevCardType type)
Gets the number of devCards for the current player
|
int |
playerNewDevCardCount(DevCardType type) |
int |
playerPieceCount(PieceType type)
Gets the number of devCards for the current player
|
int |
PlayerPoints()
Gets the points of the current player
|
int |
playerResourceCount(ResourceType type)
Gets the number of resources for the player
|
boolean |
PlayMonopoly(ResourceType resource)
Plays the monopoly card for the current player
|
boolean |
PlayMonument()
Plays the monument card for the current player
|
boolean |
PlayRoadBuilder()
Plays the road builder card for the current player
|
boolean |
PlaySolider()
Plays the monopoly card for the current player
|
boolean |
PlayYearOfPlenty(ResourceType resource1,
ResourceType resource2)
Plays the road builder card for the current player
|
void |
RefreshFromServer()
What the poller pokes to refresh the game model from teh server
|
private void |
reloadGame(GameModel model)
Loads in a game
|
private void |
reloadGame(GameModel game,
boolean forced) |
void |
RobVictim(int victimIndex) |
int |
RollDice()
Notifies the server after rolling the dice
|
void |
SendChat(java.lang.String message)
Sends a chat message for the current player
|
void |
setPlayerIndexWithTradeOffer(int index) |
void |
setPlayerSendingOfferIndex(int index) |
private void |
setTurnState(TurnState newstate)
Sets the turn state and calls the notification center
|
void |
startBuilding(PieceType piece)
Starts building a piece
|
void |
StartGame()
Starts the game
|
boolean |
startListening(ModelObserver listener)
Starts listening to all changes
|
boolean |
startListening(ModelObserver listener,
ModelNotification type)
starts listening for a specific type of change
|
boolean |
stopListening(ModelObserver listener)
Stops listening on a model observer
|
AddPlayer, AddPlayer, allCurrentPlayers, BuildCity, BuildRoad, BuildSettlement, BuyDevCard, canAcceptTrade, CanBuildCity, CanBuildCity, CanBuildRoad, CanBuildRoad, CanBuildSettlement, CanBuildSettlement, CanBuyDevCard, canChat, CanDiscardCards, CanFinishTurn, CanFinishTurn, CanMaritimeTrade, CanOfferTrade, CanPlayDevCard, CanPlayerPlay, CanRollNumber, CanUseMonopoly, CanUseMonument, CanUseRoadBuilder, CanUseSoldier, CanUseYearOfPlenty, CurrentPlayerChat, CurrentPlayersTurn, CurrentState, DiceRoll, FinishTurn, getBankResourceCount, getChat, GetCurrentPlayer, getCurrentPlayerName, getGameActionLog, GetGameID, GetGameTitle, getNumberPlayers, GetPlayer, getPlayerColorByIndex, GetPlayerIDbyIndex, getPlayerIndexByColor, getPlayerNameByIndex, getTradeRatio, GetVersion, getVictoryPointManager, hasGameStarted, LogAction, NeedToDiscardAfterRoll, NumberActivePlayers, payDayForDayz, placeRobber, playDevCard, PlayerChat, playerDevCardCount, playerDevCardCount, playerPieceCount, playerResourceCount, removeTradeOffer, reset, SetPlayers, setTradeOffer
private ServerProxy proxy
private int myPlayerIndex
private TurnState turnState
private int playerIndexWithTradeOffer
private int playerIndexSendingOffer
private int[] resourceToTrade
private int refreshCount
private CatanColor myPlayerColor
private PieceType lastSelectedPiece
private Coordinate lastRoadBuiltStart
private Coordinate lastRoadBuiltEnd
protected NotificationCenter notifyCenter
private boolean updateInProgress
public ClientGameManager(ServerProxy clientProxy)
clientProxy
- public ClientGameManager(GSONServerProxy clientProxy, int myPlayerIndex)
clientProxy
- myPlayerID
- public boolean startListening(ModelObserver listener)
startListening
in interface ModelSubject
public boolean startListening(ModelObserver listener, ModelNotification type)
startListening
in interface ModelSubject
public boolean stopListening(ModelObserver listener)
stopListening
in interface ModelSubject
public int myPlayerIndex()
public CatanColor myPlayerColor()
public PieceType myPlayerLastPiece()
public int playerResourceCount(ResourceType type)
type
- public int playerDevCardCount(DevCardType type)
type
- public int playerNewDevCardCount(DevCardType type)
public int playerPieceCount(PieceType type)
type
- public void setPlayerIndexWithTradeOffer(int index)
index
- public int getPlayerIndexWithTradeOffer()
public void setPlayerSendingOfferIndex(int index)
index
- public int getPlayerSendingOfferIndex()
public int[] getResourceToTrade()
public boolean joinGame(GameInfo game, CatanColor color)
gameID
- color
- public GameInfo createGame(boolean randomTiles, boolean randomNumbers, boolean randomPorts, java.lang.String name)
randomTiles
- randomNumbers
- randomPorts
- name
- public int RollDice()
RollDice
in class GameManager
private void setTurnState(TurnState newstate)
newstate
- public void BuildRoad(Coordinate start, Coordinate end)
start
- end
- public void BuildSettlement(Coordinate point)
point
- public boolean BuyDevCard()
public boolean PlayMonopoly(ResourceType resource)
resource
- public boolean PlaySolider()
resource
- public boolean PlayMonument()
resource
- public boolean PlayRoadBuilder()
resource
- public boolean PlayYearOfPlenty(ResourceType resource1, ResourceType resource2)
resource
- public void BuildCity(Coordinate point)
point
- public void PlaceRobber(Coordinate point)
point
- public void RobVictim(int victimIndex)
victimIndex
- public void endTurn()
public void DiscardCards(java.util.List<java.lang.Integer> resourceList)
resourceList
- the list of resources to discardpublic void SendChat(java.lang.String message)
message
- public boolean canBuildPiece(PieceType p)
public boolean CanPlaceRobber(int playerIndex)
GameManager
CanPlaceRobber
in class GameManager
public void startBuilding(PieceType piece)
road
- public void StartGame()
GameManager
StartGame
in class GameManager
public int PlayerPoints()
private void reloadGame(GameModel model) throws ModelException
model
- the model to be loaded inModelException
- if model is incorrectprivate void reloadGame(GameModel game, boolean forced) throws ModelException
ModelException
public void LoadGame(GameInfo model) throws ModelException
model
- ModelException
public void doneDiscarding()
public int GetRefreshCount()
public void RefreshFromServer() throws ModelException
ModelException
Poller
public TurnState getTurnState()
public IMapModel GetMapModel()
public void offerTrade(java.util.List<java.lang.Integer> resourceList, int receiver) throws ServerProxyException
resourceList
- the resources to tradereceiver
- the player index getting the offerServerProxyException
public void maritimeTradeCurrentPlayer(int ratio, ResourceType inputResource, ResourceType outputResource) throws ModelException, ServerProxyException
type
- count
- ModelException
ServerProxyException
public int GetPlayerSoliderCount()