@Test
public void queueSettlement() throws GameEngineException {
API api = new API();
Long boardId = null;
String playerName = "one";
ScriptableObject board = api.joinBoard(boardId, playerName);
assertEquals(32, board.get("size"));
board = api.save(board);
String settlementPoint = "{\"r\":1,\"g\":1,\"b\":1}";
String resources = "{\"WHEAT\":1,\"FUR\":1,\"STONE\":1}";
String settlementName = "HAMLET";
api.queueSettlement(board, playerName, settlementPoint, settlementName,
resources);
// see if the location got saved
ScriptableObject queuedSettlements = (ScriptableObject) ((ScriptableObject) ((ScriptableObject) board
.get("players")).get(playerName)).get("queuedSettlements");
assertEquals(1, queuedSettlements.size());
assertEquals(settlementName, queuedSettlements.get(settlementPoint));
// see if the queued resources got saved
ScriptableObject queuedSettlementsResources = (ScriptableObject) ((ScriptableObject) ((ScriptableObject) board
.get("players")).get(playerName))
.get("queuedSettlementsResources");
assertEquals(1, queuedSettlementsResources.size());
assertEquals(1,
((ScriptableObject) queuedSettlementsResources
.get(settlementPoint)).get("WHEAT"));
assertEquals(1,
((ScriptableObject) queuedSettlementsResources
.get(settlementPoint)).get("FUR"));
assertEquals(1,
((ScriptableObject) queuedSettlementsResources
.get(settlementPoint)).get("STONE"));
// see if the queued resources got removed from the player
ScriptableObject player = (ScriptableObject) ((ScriptableObject) board
.get("players")).get(playerName);
assertEquals(3.0,
((ScriptableObject) player.get("resources")).get("WHEAT"));
assertEquals(2.0,
((ScriptableObject) player.get("resources")).get("FUR"));
assertEquals(3.0,
((ScriptableObject) player.get("resources")).get("STONE"));
}