From 51defac6f39fdc39989c20e5197b6763ff270d74 Mon Sep 17 00:00:00 2001 From: MikeZyeman Date: Wed, 8 Dec 2021 15:01:33 +0100 Subject: [PATCH] Added methods as setup and new datafields for test cases --- test/ch/zhaw/catan/SiedlerGameTest.java | 34 +++++++++++++++++++++---- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/test/ch/zhaw/catan/SiedlerGameTest.java b/test/ch/zhaw/catan/SiedlerGameTest.java index 8332480..93a3099 100644 --- a/test/ch/zhaw/catan/SiedlerGameTest.java +++ b/test/ch/zhaw/catan/SiedlerGameTest.java @@ -32,6 +32,23 @@ public class SiedlerGameTest { private final static int DEFAULT_WINPOINTS = 10; private final static int DEFAULT_PLAYERAMOUNT = 4; + + private final static Map START_SETTLEMENT_POSITIONS = new HashMap<>( + Map.of( + Config.Faction.BLUE, new Point(5, 7), + Config.Faction.RED, new Point(1, 3), + Config.Faction.GREEN, new Point(11, 13), + Config.Faction.YELLOW, new Point(13, 5) + )); + + private final static Map> START_ROADS_POSITIONS = new HashMap<>( + Map.of( + Config.Faction.BLUE, new Tuple<>(new Point(5, 6), new Point(5, 6)), + Config.Faction.RED, new Tuple<>(new Point(1, 2), new Point(1, 1)), + Config.Faction.GREEN, new Tuple<>(new Point(12, 12), new Point(13, 11)), + Config.Faction.YELLOW, new Tuple<>(new Point(13, 6), new Point(13, 7)) + )); + /** * To Test getLongestRoad in SiedlerGame isolatet do: * 1. make SiedlerGame.getLongestRoadFaction, Siedlergame.countRoad && Siedlergame.getNextPoint static @@ -103,7 +120,7 @@ public class SiedlerGameTest { @Test public void TestGameInSetupPhase() { - SiedlerGame game = new SiedlerGame(DEFAULT_WINPOINTS, DEFAULT_PLAYERAMOUNT); + SiedlerGame game = startGame(); for (Config.Faction faction: game.getPlayerFactions()) { HashMap resources = game.getCurrentPlayerResource(); @@ -120,14 +137,14 @@ public class SiedlerGameTest { @Test public void TestGameAfterSetupPhase() { - SiedlerGame game = new SiedlerGame(DEFAULT_WINPOINTS, DEFAULT_PLAYERAMOUNT); + SiedlerGame game = gameAfterSetupPhase(); throwDiceSeveralTimes(game, 5, 5); System.out.println("\n\nVerteilung \n\n"); for (Config.Faction faction: game.getPlayerFactions()) { HashMap resources = game.getCurrentPlayerResource(); - System.out.printf(faction.toString() + "\n"); + System.out.println(faction.toString() + "\n"); System.out.println(" BRICK " + resources.get(Config.Resource.BRICK).toString()); System.out.println(" GRAIN " + resources.get(Config.Resource.GRAIN)); System.out.println(" LUMBER " + resources.get(Config.Resource.LUMBER)); @@ -138,12 +155,15 @@ public class SiedlerGameTest { } } - @Test public void TestGameInMiddle() { } + private SiedlerGame startGame() { + return new SiedlerGame(DEFAULT_WINPOINTS, DEFAULT_PLAYERAMOUNT); + } + private void throwDiceSeveralTimes(SiedlerGame game, int dice, int amountDiceThrows) { for (int i = 0; i < amountDiceThrows; i++) { System.out.println(game.getCurrentPlayerFaction().toString()); @@ -152,10 +172,14 @@ public class SiedlerGameTest { } private SiedlerGame gameAfterSetupPhase() { - SiedlerGame game = new SiedlerGame(DEFAULT_WINPOINTS, DEFAULT_PLAYERAMOUNT); + SiedlerGame game = startGame(); for (Config.Faction faction: game.getPlayerFactions()) { + game.buildSettlement(START_SETTLEMENT_POSITIONS.get(faction)); + game.buildRoad(START_ROADS_POSITIONS.get(faction).first, START_ROADS_POSITIONS.get(faction).second); + + game.switchToNextPlayer(); } return game;