Small refactor

This commit is contained in:
2026-05-25 17:32:17 +02:00
parent 24ae732805
commit 22c4c6cc0f
4 changed files with 38 additions and 46 deletions
@@ -83,14 +83,13 @@ public class ClientController {
* <p>If the specified player is not the current player, an error message
* is shown. Otherwise, the request is forwarded to the network client.
*
* @param playerUsername the username of the player performing the action.
* @param pos the index of the card to draw.
*/
public void drawUpperTribeCard(String playerUsername, int pos) {
if (!Objects.equals(playerUsername, miniModel.currentState.getCurrentPlayer().getUserName())) {
public void drawUpperTribeCard(int pos) {
if (!Objects.equals(myUsername, miniModel.currentState.getCurrentPlayer().getUserName())) {
view.showError("It's not your turn!");
} else {
client.drawUpperTribeCard(playerUsername, pos);
client.drawUpperTribeCard(myUsername, pos);
}
}
@@ -100,14 +99,13 @@ public class ClientController {
* <p>If the specified player is not the current player, an error message
* is shown. Otherwise, the request is forwarded to the network client.
*
* @param playerUsername the username of the player performing the action.
* @param pos the index of the card to draw.
*/
public void drawLowerTribeCard(String playerUsername, int pos) {
if (!Objects.equals(playerUsername, miniModel.currentState.getCurrentPlayer().getUserName())) {
public void drawLowerTribeCard(int pos) {
if (!Objects.equals(myUsername, miniModel.currentState.getCurrentPlayer().getUserName())) {
view.showError("It's not your turn!");
} else {
client.drawLowerTribeCard(playerUsername, pos);
client.drawLowerTribeCard(myUsername, pos);
}
}
@@ -117,14 +115,13 @@ public class ClientController {
* <p>If the specified player is not the current player, an error message
* is shown. Otherwise, the request is forwarded to the network client.
*
* @param playerUsername the username of the player performing the action.
* @param pos the index of the card to draw.
*/
public void drawUpperBuildingCard(String playerUsername, int pos) {
if (!Objects.equals(playerUsername, miniModel.currentState.getCurrentPlayer().getUserName())) {
public void drawUpperBuildingCard(int pos) {
if (!Objects.equals(myUsername, miniModel.currentState.getCurrentPlayer().getUserName())) {
view.showError("It's not your turn!");
} else {
client.drawUpperBuildingCard(playerUsername, pos);
client.drawUpperBuildingCard(myUsername, pos);
}
}
@@ -134,14 +131,13 @@ public class ClientController {
* <p>If the specified player is not the current player, an error message
* is shown. Otherwise, the request is forwarded to the network client.
*
* @param playerUsername the username of the player performing the action.
* @param pos the index of the card to draw.
*/
public void drawLowerBuildingCard(String playerUsername, int pos) {
if (!Objects.equals(playerUsername, miniModel.currentState.getCurrentPlayer().getUserName())) {
public void drawLowerBuildingCard(int pos) {
if (!Objects.equals(myUsername, miniModel.currentState.getCurrentPlayer().getUserName())) {
view.showError("It's not your turn!");
} else {
client.drawLowerBuildingCard(playerUsername, pos);
client.drawLowerBuildingCard(myUsername, pos);
}
}
@@ -150,14 +146,12 @@ public class ClientController {
*
* <p>If the specified player is not the current player, an error message
* is shown. Otherwise, the request is forwarded to the network client.
*
* @param playerUsername the username of the player performing the action.
*/
public void skipTurn(String playerUsername) {
if (!Objects.equals(playerUsername, miniModel.currentState.getCurrentPlayer().getUserName())) {
public void skipTurn() {
if (!Objects.equals(myUsername, miniModel.currentState.getCurrentPlayer().getUserName())) {
view.showError("It's not your turn!");
} else {
client.skipTurn(playerUsername);
client.skipTurn(myUsername);
}
}
@@ -167,14 +161,13 @@ public class ClientController {
* <p>If the specified player is not the current player, an error message
* is shown. Otherwise, the request is forwarded to the network client.
*
* @param playerUsername the username of the player performing the action.
* @param pos the index of the selected slot.
*/
public void slotChoice(String playerUsername, int pos) {
if (!Objects.equals(playerUsername, miniModel.currentState.getCurrentPlayer().getUserName())) {
public void slotChoice(int pos) {
if (!Objects.equals(myUsername, miniModel.currentState.getCurrentPlayer().getUserName())) {
view.showError("It's not your turn!");
} else {
client.slotChoice(playerUsername, pos);
client.slotChoice(myUsername, pos);
}
}
@@ -185,14 +178,13 @@ public class ClientController {
* is shown. Otherwise, the selected totem is retrieved from the available
* totems list and the choice is forwarded to the network client.
*
* @param playerUsername the username of the player making the choice.
* @param pos the index of the selected totem in the available totems list.
*/
public void totemChoice(String playerUsername, int pos) {
if (!Objects.equals(playerUsername, miniModel.currentState.getCurrentPlayer().getUserName())) {
public void totemChoice(int pos) {
if (!Objects.equals(myUsername, miniModel.currentState.getCurrentPlayer().getUserName())) {
view.showError("It's not your turn!");
} else {
client.totemChoice(playerUsername, String.valueOf(miniModel.availableTotems.get(pos)));
client.totemChoice(myUsername, String.valueOf(miniModel.availableTotems.get(pos)));
}
}