public class Client
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
GUI |
gui |
boolean |
isAI |
ClientListener |
listener |
LocalDataContainer |
localDataContainer |
Messenger |
messenger |
| Constructor and Description |
|---|
Client(boolean isAI)
Constructor for the client class
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
didServerReceiveLogin()
Determines if the server received a login
|
void |
discard(EnumPolicy cardToDiscard)
Requests that the server discard the specified
card.
|
void |
draftCard(PolicyCard cardToBeDrafted)
Requests that the server draft the specified
card.
|
EnumRegion |
getAssignedRegion()
Gets the region assigned to the client by the server
based on the password file.
|
java.util.ArrayList<EnumRegion> |
getAvailableRegions()
Called by the RegionChooser to determine what regions
have already been selected by other players in order to
grey them out.
|
java.lang.String |
getLoginSalt()
Getter for the login salt.
|
javafx.application.Application |
getRegionChooser()
Retrieves the region choose associated with the client
|
java.util.TreeMap<EnumRegion,java.lang.String> |
getTakenRegions()
Gets the Regions taken mapped to the name of the player
who has taken that region.
|
java.lang.String |
getUsername()
Provides getter functionality for the username bound to the client.
|
void |
init()
Called from LandingPage, getWorldData creates a socket
connection with the server and assigns its
messenger object that socket.
|
boolean |
isLoginSuccessful()
Called by the LandingPage to determine whether the
login attempt was successful.
|
boolean |
openConnection(java.lang.String host,
int portNumber)
Opens up a socket connection with the server
|
void |
sendLogin(java.lang.String uname,
java.lang.String passwd)
Called from LandingPage, an attempt by the user to
log into the server.
|
void |
sendRegionChoice(EnumRegion desiredRegion)
Called from RegionChooser to indicate that the user
is attempting to select a region.
|
void |
setLoginSalt(java.lang.String loginNonce)
Sets/initializes the loginSalt with the Hello loginNonce recieved upon opening the client.
|
void |
setReceivedLoginAttempt(boolean receivedLoginAttempt)
Sets the local instance bookkeeping receivedLoginAttempt
|
void |
setUsername(java.lang.String username)
Sets the username of the client once a successful login has been acheived
|
void |
startSelection()
This method is called from LandingPage upon a
successful login by the user.
|
public Messenger messenger
public ClientListener listener
public GUI gui
public LocalDataContainer localDataContainer
public boolean isAI
public Client(boolean isAI)
isAI - true if client is ai, else falsepublic void init()
public void setLoginSalt(java.lang.String loginNonce)
loginNonce - loginNonce, or salt, to set locallypublic java.lang.String getLoginSalt()
public void setUsername(java.lang.String username)
username - username to set in the clientpublic java.lang.String getUsername()
public javafx.application.Application getRegionChooser()
public void startSelection()
public void sendLogin(java.lang.String uname,
java.lang.String passwd)
uname - The entered username.passwd - The entered password.public void sendRegionChoice(EnumRegion desiredRegion)
desiredRegion - The region the user is trying
to select.public void draftCard(PolicyCard cardToBeDrafted)
cardToBeDrafted - card to discard.public void discard(EnumPolicy cardToDiscard)
cardToDiscard - The card to discard.public EnumRegion getAssignedRegion()
public boolean isLoginSuccessful()
public java.util.ArrayList<EnumRegion> getAvailableRegions()
public java.util.TreeMap<EnumRegion,java.lang.String> getTakenRegions()
public void setReceivedLoginAttempt(boolean receivedLoginAttempt)
receivedLoginAttempt - the new value of reveicedLoginAttemppublic boolean didServerReceiveLogin()
public boolean openConnection(java.lang.String host,
int portNumber)
host - The domain address of the hostportNumber - the port number to open the socket with