summaryrefslogtreecommitdiff
path: root/backend
diff options
context:
space:
mode:
Diffstat (limited to 'backend')
-rw-r--r--backend/src/main/java/org/luxons/sevenwonders/actions/PrepareMoveAction.java (renamed from backend/src/main/java/org/luxons/sevenwonders/actions/PrepareCardAction.java)6
-rw-r--r--backend/src/main/java/org/luxons/sevenwonders/controllers/GameController.java9
-rw-r--r--backend/src/main/java/org/luxons/sevenwonders/game/Game.java4
-rw-r--r--backend/src/test/java/org/luxons/sevenwonders/game/GameTest.java2
4 files changed, 11 insertions, 10 deletions
diff --git a/backend/src/main/java/org/luxons/sevenwonders/actions/PrepareCardAction.java b/backend/src/main/java/org/luxons/sevenwonders/actions/PrepareMoveAction.java
index 629e5806..02899eab 100644
--- a/backend/src/main/java/org/luxons/sevenwonders/actions/PrepareCardAction.java
+++ b/backend/src/main/java/org/luxons/sevenwonders/actions/PrepareMoveAction.java
@@ -6,10 +6,10 @@ import org.jsondoc.core.annotation.ApiObject;
import org.jsondoc.core.annotation.ApiObjectField;
import org.luxons.sevenwonders.game.api.PlayerMove;
-@ApiObject(name = "Prepare Card Action",
- description = "The action to prepare a card during a game.",
+@ApiObject(name = "Prepare Move Action",
+ description = "The action to prepare the next move during a game.",
group = "Actions")
-public class PrepareCardAction {
+public class PrepareMoveAction {
@ApiObjectField
@NotNull
diff --git a/backend/src/main/java/org/luxons/sevenwonders/controllers/GameController.java b/backend/src/main/java/org/luxons/sevenwonders/controllers/GameController.java
index 0ec631f6..8680b00e 100644
--- a/backend/src/main/java/org/luxons/sevenwonders/controllers/GameController.java
+++ b/backend/src/main/java/org/luxons/sevenwonders/controllers/GameController.java
@@ -4,7 +4,7 @@ import java.security.Principal;
import org.jsondoc.core.annotation.Api;
import org.jsondoc.core.annotation.ApiMethod;
-import org.luxons.sevenwonders.actions.PrepareCardAction;
+import org.luxons.sevenwonders.actions.PrepareMoveAction;
import org.luxons.sevenwonders.game.Game;
import org.luxons.sevenwonders.game.api.PlayerTurnInfo;
import org.luxons.sevenwonders.game.cards.CardBack;
@@ -36,12 +36,13 @@ public class GameController {
this.playerRepository = playerRepository;
}
- @ApiMethod(description = "Prepares the user's card")
+ @ApiMethod(description = "Prepares the user's next move. When all players have prepared their moves, all moves "
+ + "are executed.")
@MessageMapping("/game/{gameId}/prepare")
- public void prepareCard(@DestinationVariable long gameId, PrepareCardAction action, Principal principal) {
+ public void prepareMove(@DestinationVariable long gameId, PrepareMoveAction action, Principal principal) {
Player player = playerRepository.find(principal.getName());
Game game = player.getGame();
- CardBack preparedCardBack = game.prepareCard(player.getIndex(), action.getMove());
+ CardBack preparedCardBack = game.prepareMove(player.getIndex(), action.getMove());
PreparedCard preparedCard = new PreparedCard(player, preparedCardBack);
logger.info("Game '{}': player {} prepared move {}", gameId, principal.getName(), action.getMove());
diff --git a/backend/src/main/java/org/luxons/sevenwonders/game/Game.java b/backend/src/main/java/org/luxons/sevenwonders/game/Game.java
index 4f71d6e6..62cbab88 100644
--- a/backend/src/main/java/org/luxons/sevenwonders/game/Game.java
+++ b/backend/src/main/java/org/luxons/sevenwonders/game/Game.java
@@ -99,7 +99,7 @@ public class Game {
}
}
- public CardBack prepareCard(int playerIndex, PlayerMove playerMove) throws InvalidMoveException {
+ public CardBack prepareMove(int playerIndex, PlayerMove playerMove) throws InvalidMoveException {
Card card = decks.getCard(playerMove.getCardName());
Move move = playerMove.getType().resolve(playerIndex, card, playerMove);
validate(move);
@@ -135,8 +135,8 @@ public class Game {
}
private void rotateHandsIfRelevant() {
+ // we don't rotate hands if some player can play his last card (with the special ability)
if (!hands.maxOneCardRemains()) {
- // we don't rotate hands if some player can play his last card (with the special ability)
hands.rotate(table.getHandRotationDirection());
}
}
diff --git a/backend/src/test/java/org/luxons/sevenwonders/game/GameTest.java b/backend/src/test/java/org/luxons/sevenwonders/game/GameTest.java
index a7d10394..98247bb2 100644
--- a/backend/src/test/java/org/luxons/sevenwonders/game/GameTest.java
+++ b/backend/src/test/java/org/luxons/sevenwonders/game/GameTest.java
@@ -30,7 +30,7 @@ public class GameTest {
assertEquals(1, turnInfo.getCurrentAge());
assertEquals(7, turnInfo.getHand().size());
PlayerMove move = getFirstAvailableMove(turnInfo);
- game.prepareCard(turnInfo.getPlayerIndex(), move);
+ game.prepareMove(turnInfo.getPlayerIndex(), move);
}
}
bgstack15