summaryrefslogtreecommitdiff
path: root/backend/src/main
diff options
context:
space:
mode:
authorJoffrey BION <joffrey.bion@gmail.com>2017-05-08 09:55:41 +0200
committerJoffrey BION <joffrey.bion@gmail.com>2017-05-08 09:55:41 +0200
commitd36414b05f1cc051652a8baad16c4d6e4c69bab2 (patch)
treed42a44d78e52e054e83d439d58465e802cc8dc99 /backend/src/main
parentAdd first draft of Game test (diff)
downloadseven-wonders-d36414b05f1cc051652a8baad16c4d6e4c69bab2.tar.gz
seven-wonders-d36414b05f1cc051652a8baad16c4d6e4c69bab2.tar.bz2
seven-wonders-d36414b05f1cc051652a8baad16c4d6e4c69bab2.zip
Rename "prepare card" to "prepare move"
Some moves may not be related to preparing a card from the hand. For instance, picking a neighbouring Guild Card to copy is not what I would call "preparing a card".
Diffstat (limited to 'backend/src/main')
-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
3 files changed, 10 insertions, 9 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());
}
}
bgstack15