Add: complete JavaDoc for networking, heartbeat, totem flow and game events
This commit is contained in:
@@ -26,6 +26,9 @@ public class ClientController {
|
||||
/** Network client (either TCP or RMI) */
|
||||
private IClient client;
|
||||
|
||||
/**
|
||||
* The username of the client associated with this event.
|
||||
*/
|
||||
public String myUsername;
|
||||
|
||||
|
||||
@@ -65,6 +68,11 @@ public class ClientController {
|
||||
view.setModel(miniModel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the username of the client associated with this event.
|
||||
*
|
||||
* @param username the username to set.
|
||||
*/
|
||||
public void setMyUsername (String username) {
|
||||
this.myUsername=username;
|
||||
}
|
||||
@@ -170,7 +178,16 @@ public class ClientController {
|
||||
}
|
||||
}
|
||||
|
||||
//TODO
|
||||
/**
|
||||
* Handles the selection of a totem by the specified player.
|
||||
*
|
||||
* <p>If the player is not the current one, an error message is shown.
|
||||
* Otherwise, the selected totem is retrieved from the available totems
|
||||
* and the choice is forwarded to the client.
|
||||
*
|
||||
* @param playerUsername the username of the player making the choice.
|
||||
* @param pos the position of the selected totem in the available totems list.
|
||||
*/
|
||||
public void totemChoice(String playerUsername,int pos) {
|
||||
if(!Objects.equals(playerUsername, miniModel.currentState.getCurrentPlayer().getUserName()))
|
||||
view.showError("It's not your turn!");
|
||||
|
||||
@@ -30,7 +30,14 @@ public class GameController {
|
||||
*/
|
||||
public GameController() {
|
||||
}
|
||||
//TODO
|
||||
|
||||
/**
|
||||
* Marks the player associated with the specified username as disconnected.
|
||||
*
|
||||
* @param username the username of the player who disconnected.
|
||||
* @return {@code true} if the disconnection is handled successfully,
|
||||
* {@code false} if no player with the specified username exists.
|
||||
*/
|
||||
public boolean DisconnectedPlayer(String username)
|
||||
{
|
||||
Player player= model.getPlayerByUsername(username);
|
||||
@@ -38,7 +45,14 @@ public class GameController {
|
||||
return false;
|
||||
return model.DisconnectedPlayer(player);
|
||||
}
|
||||
//TODO
|
||||
|
||||
/**
|
||||
* Marks the player associated with the specified username as reconnected.
|
||||
*
|
||||
* @param username the username of the player who reconnected.
|
||||
* @return {@code true} if the reconnection is handled successfully,
|
||||
* {@code false} if no player with the specified username exists.
|
||||
*/
|
||||
public boolean ReconnectPlayer(String username)
|
||||
{
|
||||
Player player= model.getPlayerByUsername(username);
|
||||
@@ -46,6 +60,7 @@ public class GameController {
|
||||
return false;
|
||||
return model.ReconnectPlayer(player);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the game model managed by this controller.
|
||||
*
|
||||
@@ -166,7 +181,14 @@ public class GameController {
|
||||
return model.SlotChoiceByIndex(model.getPlayerByUsername(playerUsername),pos);
|
||||
}
|
||||
|
||||
//TODO
|
||||
/**
|
||||
* Applies the totem choice made by the player associated with the specified username.
|
||||
*
|
||||
* @param playerUsername the username of the player making the choice.
|
||||
* @param totem the name of the selected totem.
|
||||
* @return {@code true} if the choice is handled successfully,
|
||||
* {@code false} if no player with the specified username exists.
|
||||
*/
|
||||
public boolean TotemChoice(String playerUsername,String totem) {
|
||||
Player player= model.getPlayerByUsername(playerUsername);
|
||||
if(player==null)
|
||||
|
||||
Reference in New Issue
Block a user