public class MockServerProxy extends java.lang.Object implements EarlyServerProxy
| Modifier and Type | Field and Description |
|---|---|
private NetGameModel |
currentStateOfGame |
private java.util.ArrayList<NetGame> |
gameList |
private java.util.ArrayList<java.lang.String[]> |
loginCredentials |
private boolean |
userJoinedGame |
private boolean |
userLoggedIn |
| Constructor and Description |
|---|
MockServerProxy()
Default constructor; sets up everything needed for
mock server
|
| Modifier and Type | Method and Description |
|---|---|
NetGameModel |
acceptTrade(boolean willAccept)
Notifies the server whether this player has decided to accept or reject a trade
|
void |
addAI(AIType aiType)
Adds an AI to the game
|
NetGameModel |
buildCity(VertexLocation vertexLocation)
Notifies the server that the user has decided to build a city
|
NetGameModel |
buildRoad(EdgeLocation edgeLocation,
boolean free)
Notifies the server that the user has decided to build a road
|
NetGameModel |
buildSettlement(VertexLocation vertexLocation,
boolean free)
Notifies the server that the user has decided to build a settlement
|
NetGameModel |
buyDevCard()
Notifies the server that the user has bought a development card
|
NetGame |
createGame(boolean randomTiles,
boolean randomNumbers,
boolean randomPorts,
java.lang.String name)
Creates a game on the server
|
NetGameModel |
discardCards(java.util.List<java.lang.Integer> resourceList)
Notifies the server that the user has discarded cards
|
NetGameModel |
finishTurn()
Notifies the server that the user has finished his turn
|
NetGameModel |
getGameModel()
Retrieves the game model from the server
|
int |
getUserId()
Gets the player ID
|
java.lang.String |
getUserName()
Gets the current user's name
|
private void |
initializeStaticListOfGames()
Initializes a hard coded static state of the game
|
private void |
initializeStaticStateOfGame()
Initializes a hard-coded state of the game
|
void |
joinGame(int id,
CatanColor color) |
java.util.List<AIType> |
listAI() |
java.util.List<NetGame> |
listGames()
Fetches a list of ongoing games
|
boolean |
loginUser(java.lang.String username,
java.lang.String password)
Logs the specified user in and returns a User object if the user was
successfully logged in.
|
NetGameModel |
maritimeTrade(int ratio,
ResourceType inputResource,
ResourceType outputResource)
Notifies the server that the user has decided to initiate a maritime trade
|
NetGameModel |
monopolyCard(ResourceType resource)
Notifies the server that the user has played a monopoly card
|
NetGameModel |
monumentCard()
Notifies the server that the user has played a monument card
|
NetGameModel |
offerTrade(java.util.List<java.lang.Integer> resourceList,
int receiver)
Notifies the server that the user has decided to offer a trade to another player
|
private boolean |
passwordIsValid(java.lang.String password) |
boolean |
registerUser(java.lang.String username,
java.lang.String password)
Registers a user with the specified username and password
|
NetGameModel |
roadBuildingCard(EdgeLocation location1,
EdgeLocation location2)
Notifies the server that the user has played a road building card
|
NetGameModel |
robPlayer(int victimIndex,
HexLocation location)
Notifies the server that the user has decided to rob another player
|
NetGameModel |
rollNumber(int roll)
Reports the result of a dice roll to the server
|
NetGameModel |
sendChat(java.lang.String content)
Sends a chat message from the specified user to the server
|
NetGameModel |
soldierCard(int victimIndex,
HexLocation hexLocation)
Notifies the server that the user has played a soldier card
|
private boolean |
usernameIsValid(java.lang.String username) |
NetGameModel |
yearOfPlentyCard(ResourceType resource1,
ResourceType resource2)
Notifies the server that the user has played a year of plenty card
|
private NetGameModel currentStateOfGame
private java.util.ArrayList<NetGame> gameList
private java.util.ArrayList<java.lang.String[]> loginCredentials
private boolean userLoggedIn
private boolean userJoinedGame
public MockServerProxy()
private void initializeStaticStateOfGame()
private void initializeStaticListOfGames()
public boolean loginUser(java.lang.String username,
java.lang.String password)
loginUser in interface EarlyServerProxyusername - The username of the user to log inpassword - The password of the user to log inServerProxyException - if the user could not be logged inpublic boolean registerUser(java.lang.String username,
java.lang.String password)
registerUser in interface EarlyServerProxyusername - The username of the user to be registeredpassword - The password of the user to be registeredServerProxyException - if this user could not be registeredprivate boolean usernameIsValid(java.lang.String username)
private boolean passwordIsValid(java.lang.String password)
public java.util.List<NetGame> listGames()
listGames in interface EarlyServerProxypublic NetGame createGame(boolean randomTiles, boolean randomNumbers, boolean randomPorts, java.lang.String name) throws ServerProxyException
createGame in interface EarlyServerProxyrandomTiles - Whether the server should place random tilesrandomNumbers - Whether the server should place random number chitsrandomPorts - Whether the server should place random portsname - The name of the game to be createdServerProxyException - if something goes wrongpublic void joinGame(int id,
CatanColor color)
throws ServerProxyException
joinGame in interface EarlyServerProxycolor - the color the user wishes to represent himServerProxyException - if something goes wrongpublic NetGameModel getGameModel() throws ServerProxyException
getGameModel in interface EarlyServerProxyServerProxyException - if something goes wrongpublic void addAI(AIType aiType) throws ServerProxyException
addAI in interface EarlyServerProxyaiType - the type of AI the user wishes to addServerProxyException - if there is no logged in userpublic java.util.List<AIType> listAI()
listAI in interface EarlyServerProxyServerProxyException - if there is no logged in userpublic NetGameModel sendChat(java.lang.String content) throws ServerProxyException
sendChat in interface EarlyServerProxycontent - The content of the chat messageServerProxyException - if there is no logged in userpublic NetGameModel rollNumber(int roll) throws ServerProxyException
rollNumber in interface EarlyServerProxyroll - The result of the user's rollServerProxyException - if there is no logged in userpublic NetGameModel robPlayer(int victimIndex, HexLocation location) throws ServerProxyException
robPlayer in interface EarlyServerProxyvictimIndex - The index of the victim of the user's robbinglocation - The new hex location of the robberServerProxyException - if there is no logged in userpublic NetGameModel finishTurn() throws ServerProxyException
finishTurn in interface EarlyServerProxyuser - The User who has finished his turnServerProxyException - if there is no logged in userpublic NetGameModel buyDevCard() throws ServerProxyException
buyDevCard in interface EarlyServerProxyServerProxyException - if there is no logged in userpublic NetGameModel yearOfPlentyCard(ResourceType resource1, ResourceType resource2) throws ServerProxyException
yearOfPlentyCard in interface EarlyServerProxyresource1 - The first chosen resourceresource2 - The second chosen resourceServerProxyException - if there is no logged in userpublic NetGameModel roadBuildingCard(EdgeLocation location1, EdgeLocation location2) throws ServerProxyException
roadBuildingCard in interface EarlyServerProxylocation1 - The EdgeLocation location of the first roadlocation2 - The EdgeLocation location of the second cardServerProxyException - if there is no logged in userpublic NetGameModel soldierCard(int victimIndex, HexLocation hexLocation) throws ServerProxyException
soldierCard in interface EarlyServerProxyvictimIndex - The index of the player who is being robbedhexLocation - The new hex location of the robberServerProxyException - if there is no logged in userpublic NetGameModel monopolyCard(ResourceType resource) throws ServerProxyException
monopolyCard in interface EarlyServerProxyresource - The resource that the player has chosen to have a monopoly onServerProxyException - if there is no logged in userpublic NetGameModel monumentCard() throws ServerProxyException
monumentCard in interface EarlyServerProxyServerProxyException - if there is no logged in userpublic NetGameModel buildRoad(EdgeLocation edgeLocation, boolean free) throws ServerProxyException
buildRoad in interface EarlyServerProxyedgeLocation - The edge location of the roadfree - Whether this road was free (only true during the set up phases)ServerProxyException - if there is no logged in userpublic NetGameModel buildSettlement(VertexLocation vertexLocation, boolean free) throws ServerProxyException
buildSettlement in interface EarlyServerProxyvertexLocation - The vertex location of the settlementfree - Whether this settlement was free (only true during the set up phases)ServerProxyException - if there is no logged in userpublic NetGameModel buildCity(VertexLocation vertexLocation) throws ServerProxyException
buildCity in interface EarlyServerProxyvertexLocation - The vertex location of the cityServerProxyException - if there is no logged in userpublic NetGameModel offerTrade(java.util.List<java.lang.Integer> resourceList, int receiver) throws ServerProxyException
offerTrade in interface EarlyServerProxyresourceList - A list of the resources that the user wishes to trade, in this order: brick, ore, sheep,
wheat, and wood. Negative values denotes that this user will give these resources, and positive values denote
the resources that will be receivedreceiver - The index of the player who will receive this trade offerServerProxyException - if there is no logged in userpublic NetGameModel acceptTrade(boolean willAccept) throws ServerProxyException
acceptTrade in interface EarlyServerProxywillAccept - true if the user will accept the trade, false if notServerProxyException - if there is no logged in userpublic NetGameModel maritimeTrade(int ratio, ResourceType inputResource, ResourceType outputResource) throws ServerProxyException
maritimeTrade in interface EarlyServerProxyratio - The ratio of resources demanded by the harborinputResource - The resources traded awayoutputResource - The resource receivedServerProxyException - if there is no logged in userpublic NetGameModel discardCards(java.util.List<java.lang.Integer> resourceList) throws ServerProxyException
discardCards in interface EarlyServerProxyresourceList - A list of integers that denotes how many of each resource the user will discard. The
order is brick, ore, sheep, wheat, and woodServerProxyException - if there is no logged in userpublic java.lang.String getUserName()
throws ServerProxyException
EarlyServerProxygetUserName in interface EarlyServerProxyServerProxyException - if not logged inpublic int getUserId()
EarlyServerProxygetUserId in interface EarlyServerProxy