summaryrefslogtreecommitdiff
path: root/backend/src/test/java/org/luxons
diff options
context:
space:
mode:
authorJoffrey BION <joffrey.bion@gmail.com>2017-05-20 10:39:24 +0200
committerJoffrey BION <joffrey.bion@gmail.com>2017-05-20 10:39:24 +0200
commit3bd7e6c8ab4a5e46270d34b206a10e7c65113036 (patch)
treed1a121c7239f6d548ea7cc4ed35716e774709e6f /backend/src/test/java/org/luxons
parentAdd "sayReady" for players to call to receive their hand (diff)
downloadseven-wonders-3bd7e6c8ab4a5e46270d34b206a10e7c65113036.tar.gz
seven-wonders-3bd7e6c8ab4a5e46270d34b206a10e7c65113036.tar.bz2
seven-wonders-3bd7e6c8ab4a5e46270d34b206a10e7c65113036.zip
Add checks on last played moves in GameTest
Diffstat (limited to 'backend/src/test/java/org/luxons')
-rw-r--r--backend/src/test/java/org/luxons/sevenwonders/game/GameTest.java21
1 files changed, 20 insertions, 1 deletions
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 56829951..e504126d 100644
--- a/backend/src/test/java/org/luxons/sevenwonders/game/GameTest.java
+++ b/backend/src/test/java/org/luxons/sevenwonders/game/GameTest.java
@@ -1,20 +1,25 @@
package org.luxons.sevenwonders.game;
import java.util.Collection;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.junit.Test;
import org.luxons.sevenwonders.game.api.CustomizableSettings;
import org.luxons.sevenwonders.game.api.HandCard;
import org.luxons.sevenwonders.game.api.PlayerMove;
import org.luxons.sevenwonders.game.api.PlayerTurnInfo;
+import org.luxons.sevenwonders.game.api.Table;
import org.luxons.sevenwonders.game.cards.Card;
import org.luxons.sevenwonders.game.data.GameDefinitionLoader;
+import org.luxons.sevenwonders.game.moves.Move;
import org.luxons.sevenwonders.game.moves.MoveType;
import org.luxons.sevenwonders.game.test.TestUtils;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
public class GameTest {
@@ -43,16 +48,30 @@ public class GameTest {
private static void playTurn(int nbPlayers, Game game, int ageToCheck, int handSize) {
Collection<PlayerTurnInfo> turnInfos = game.getCurrentTurnInfo();
assertEquals(nbPlayers, turnInfos.size());
+
+ Map<Integer, PlayerMove> sentMoves = new HashMap<>(turnInfos.size());
for (PlayerTurnInfo turnInfo : turnInfos) {
assertEquals(ageToCheck, turnInfo.getCurrentAge());
assertEquals(handSize, turnInfo.getHand().size());
PlayerMove move = getFirstAvailableMove(turnInfo);
if (move != null) {
game.prepareMove(turnInfo.getPlayerIndex(), move);
+ sentMoves.put(turnInfo.getPlayerIndex(), move);
}
}
assertTrue(game.allPlayersPreparedTheirMove());
- game.playTurn();
+ Table table = game.playTurn();
+ checkLastPlayedMoves(sentMoves, table);
+ }
+
+ private static void checkLastPlayedMoves(Map<Integer, PlayerMove> sentMoves, Table table) {
+ for (Move move : table.getLastPlayedMoves()) {
+ PlayerMove sentMove = sentMoves.get(move.getPlayerIndex());
+ assertNotNull(sentMove);
+ assertNotNull(move.getCard());
+ assertEquals(sentMove.getCardName(), move.getCard().getName());
+ assertSame(sentMove.getType(), move.getType());
+ }
}
private static PlayerMove getFirstAvailableMove(PlayerTurnInfo turnInfo) {
bgstack15