From 10848a7b463d807a4706ce1b5438a53cad46a096 Mon Sep 17 00:00:00 2001 From: FelixKrull Date: Tue, 1 Feb 2022 10:22:00 +0100 Subject: [PATCH 01/16] Implement checkDice method --- src/main/java/Game.java | 43 +++++++++++++++++++----- src/main/java/Player.java | 7 ++-- src/test/java/GameTest.java | 63 +++++++++++++++++++++++++++++++++++ src/test/java/PlayerTest.java | 14 ++++---- 4 files changed, 109 insertions(+), 18 deletions(-) diff --git a/src/main/java/Game.java b/src/main/java/Game.java index c2654d9..2f2d509 100644 --- a/src/main/java/Game.java +++ b/src/main/java/Game.java @@ -1,21 +1,48 @@ +import java.util.ArrayList; + public class Game { Gameboard gb; - Player p1; - Player p2; - Player p3; - Player p4; + ArrayList players; public static void main(String[] args) { Game g = new Game(); + /*while (checkDice() != 0) { + int dice = g.players[0].rollDice(); + System.out.println("Würfel: " + dice); + }*/ } public Game() { this.gb = new Gameboard(); gb.initGameboard(); - p1 = new Player("Rot", 40, 43); - p2 = new Player("Blau", 44, 47); - p3 = new Player("Gelb", 48, 51); - p4 = new Player("Grün", 52, 55); + players = new ArrayList<>(); + players.add(new Player("Rot", 40, 43)); + players.add(new Player("Blau", 44, 47)); + players.add(new Player("Gelb", 48, 51)); + players.add(new Player("Grün", 52, 55)); + } + + public int checkDice(int dice, Player p) { + int figuresInBase = p.checkFigureInBase(p.figures); + if(figuresInBase == 4) { + if(dice == 6) { + return 1; + } else { + return 0; + } + } else if(figuresInBase > 0) { + if(dice == 6) { + return 3; + } else { + return 2; + } + } else { + if(dice == 6) { + return 5; + } else { + return 4; + } + } } } diff --git a/src/main/java/Player.java b/src/main/java/Player.java index c143347..140b144 100644 --- a/src/main/java/Player.java +++ b/src/main/java/Player.java @@ -41,16 +41,17 @@ public class Player { return true; } - public boolean checkFigureInBase(ArrayList
figures) { + public int checkFigureInBase(ArrayList
figures) { Iterator
it = figures.iterator(); Figure f; + int count = 0; while(it.hasNext()) { f = it.next(); if(f.getPosition() == -1) { - return true; + count++; } } - return false; + return count; } public int choose() { diff --git a/src/test/java/GameTest.java b/src/test/java/GameTest.java index bd47a51..bd357c6 100644 --- a/src/test/java/GameTest.java +++ b/src/test/java/GameTest.java @@ -1,4 +1,14 @@ +import static org.assertj.core.api.Assertions.*; + import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; +import org.junit.jupiter.params.provider.MethodSource; + +import java.util.Arrays; +import java.util.Collection; +import java.util.Iterator; +import java.util.stream.Stream; public class GameTest { @@ -10,4 +20,57 @@ public class GameTest { g = new Game(); } + @ParameterizedTest + @MethodSource("checkDiceTestData") + void checkDiceTest(String testname, Player testPlayer, Collection positions, int dice, int expectedResult) { + Iterator
it = testPlayer.figures.iterator(); + Iterator it2 = positions.iterator(); + while(it.hasNext()) { + it.next().setPosition(it2.next()); + } + int calculatedResult = g.checkDice(dice, testPlayer); + assertThat(calculatedResult).describedAs(testname).isEqualTo(expectedResult); + } + + static Stream checkDiceTestData () { + return Stream.of( + Arguments.of("No figures on Field - not a 6", + new Player("Rot", 40, 43), + Arrays.asList(-1, -1, -1, -1), + 1, + 0 + ), + Arguments.of("No figures on Field - a 6", + new Player("Rot", 40, 43), + Arrays.asList(-1, -1, -1, -1), + 6, + 1 + ), + Arguments.of("Few Figures in Field - not a 6", + new Player("Rot", 40, 43), + Arrays.asList(25, -1, 13, -1), + 2, + 2 + ), + Arguments.of("Few Figures in Field - a 6", + new Player("Rot", 40, 43), + Arrays.asList(25, -1, 13, -1), + 6, + 3 + ), + Arguments.of("All Figures in Field - not a 6", + new Player("Rot", 40, 43), + Arrays.asList(2, 10, 15, 21), + 3, + 4 + ), + Arguments.of("All Figures in Field - a 6", + new Player("Rot", 40, 43), + Arrays.asList(2, 10, 15, 21), + 6, + 5 + ) + + ); + } } diff --git a/src/test/java/PlayerTest.java b/src/test/java/PlayerTest.java index c419115..5695f87 100644 --- a/src/test/java/PlayerTest.java +++ b/src/test/java/PlayerTest.java @@ -64,13 +64,13 @@ public class PlayerTest { @ParameterizedTest @MethodSource("BaseTestData") - void checkFigureInBase(String testname, ArrayList
figures, Collection positions, boolean expectedResult) { + void checkFigureInBase(String testname, ArrayList
figures, Collection positions, int expectedResult) { Iterator
it = figures.iterator(); Iterator it2 = positions.iterator(); while(it.hasNext()) { it.next().setPosition(it2.next()); } - boolean calculatedResult = p.checkFigureInBase(figures); + int calculatedResult = p.checkFigureInBase(figures); assertThat(calculatedResult).describedAs(testname).isEqualTo(expectedResult); } @@ -134,7 +134,7 @@ public class PlayerTest { new Figure(), new Figure()) ), Arrays.asList(-1, -1, -1, -1), - true), + 4), Arguments.of("Three Figures in Base", new ArrayList<>( Arrays.asList( @@ -143,7 +143,7 @@ public class PlayerTest { new Figure(), new Figure()) ), Arrays.asList(40, -1, -1, -1), - true), + 3), Arguments.of("Two Figures in Base", new ArrayList<>( Arrays.asList( @@ -152,7 +152,7 @@ public class PlayerTest { new Figure(), new Figure()) ), Arrays.asList(40, 41, -1, -1), - true), + 2), Arguments.of("One Figure in Base", new ArrayList<>( Arrays.asList( @@ -161,7 +161,7 @@ public class PlayerTest { new Figure(), new Figure()) ), Arrays.asList(40, 41, 42, -1), - true), + 1), Arguments.of("No Figures in Base", new ArrayList<>( Arrays.asList( @@ -170,7 +170,7 @@ public class PlayerTest { new Figure(), new Figure()) ), Arrays.asList(40, 41, 42, 43), - false) + 0) ); } From a6c3fef1c21445b89ef965496012c40f7ab60605 Mon Sep 17 00:00:00 2001 From: FelixKrull Date: Tue, 1 Feb 2022 10:48:24 +0100 Subject: [PATCH 02/16] Refactoring checkDice method --- src/main/java/Game.java | 41 +++++++++++++---------------- src/test/java/GameTest.java | 51 ++++++++++++++++++++----------------- 2 files changed, 46 insertions(+), 46 deletions(-) diff --git a/src/main/java/Game.java b/src/main/java/Game.java index 2f2d509..ba7a903 100644 --- a/src/main/java/Game.java +++ b/src/main/java/Game.java @@ -1,4 +1,5 @@ import java.util.ArrayList; +import java.util.Iterator; public class Game { @@ -7,10 +8,20 @@ public class Game { public static void main(String[] args) { Game g = new Game(); - /*while (checkDice() != 0) { - int dice = g.players[0].rollDice(); - System.out.println("Würfel: " + dice); - }*/ + while(true){ + for (Player p : g.players) { + int c = 0; + int dice; + + do { + dice = p.rollDice(); + c++; + } while (g.checkDice(dice, p, c)); + + + p.checkGameWin(p.figures); + } + } } public Game() { @@ -23,26 +34,10 @@ public class Game { players.add(new Player("Grün", 52, 55)); } - public int checkDice(int dice, Player p) { + public boolean checkDice(int dice, Player p, int countRolls) { int figuresInBase = p.checkFigureInBase(p.figures); if(figuresInBase == 4) { - if(dice == 6) { - return 1; - } else { - return 0; - } - } else if(figuresInBase > 0) { - if(dice == 6) { - return 3; - } else { - return 2; - } - } else { - if(dice == 6) { - return 5; - } else { - return 4; - } - } + return countRolls <= 3; + } else return dice == 6; } } diff --git a/src/test/java/GameTest.java b/src/test/java/GameTest.java index bd357c6..036b7db 100644 --- a/src/test/java/GameTest.java +++ b/src/test/java/GameTest.java @@ -22,55 +22,60 @@ public class GameTest { @ParameterizedTest @MethodSource("checkDiceTestData") - void checkDiceTest(String testname, Player testPlayer, Collection positions, int dice, int expectedResult) { + void checkDiceTest(String testname, Player testPlayer, Collection positions, int dice, int c, boolean expectedResult) { Iterator
it = testPlayer.figures.iterator(); Iterator it2 = positions.iterator(); while(it.hasNext()) { it.next().setPosition(it2.next()); } - int calculatedResult = g.checkDice(dice, testPlayer); + boolean calculatedResult = g.checkDice(dice, testPlayer, c); assertThat(calculatedResult).describedAs(testname).isEqualTo(expectedResult); } static Stream checkDiceTestData () { return Stream.of( - Arguments.of("No figures on Field - not a 6", + Arguments.of("No figures on Field - d: 1 - c: 1", new Player("Rot", 40, 43), Arrays.asList(-1, -1, -1, -1), 1, - 0 + 1, + true ), - Arguments.of("No figures on Field - a 6", + Arguments.of("No figures on Field - d: 1 - c: 2", new Player("Rot", 40, 43), Arrays.asList(-1, -1, -1, -1), - 6, - 1 + 1, + 2, + true ), - Arguments.of("Few Figures in Field - not a 6", + Arguments.of("No figures on Field - d: 1 - c: 3", new Player("Rot", 40, 43), - Arrays.asList(25, -1, 13, -1), - 2, - 2 + Arrays.asList(-1, -1, -1, -1), + 1, + 3, + true ), - Arguments.of("Few Figures in Field - a 6", + Arguments.of("No figures on Field - d: 1 - c: 4", new Player("Rot", 40, 43), - Arrays.asList(25, -1, 13, -1), - 6, - 3 + Arrays.asList(-1, -1, -1, -1), + 1, + 4, + false ), - Arguments.of("All Figures in Field - not a 6", + Arguments.of("Figures on Field - d: 1 - c: 1", new Player("Rot", 40, 43), - Arrays.asList(2, 10, 15, 21), - 3, - 4 + Arrays.asList(10, -1, 2, -1), + 1, + 1, + false ), - Arguments.of("All Figures in Field - a 6", + Arguments.of("Figures on Field - d: 6 - c: 1", new Player("Rot", 40, 43), - Arrays.asList(2, 10, 15, 21), + Arrays.asList(10, -1, 2, -1), 6, - 5 + 1, + true ) - ); } } From 85336014de29611e8e811d93fe6ae927939c64c3 Mon Sep 17 00:00:00 2001 From: FelixKrull Date: Tue, 1 Feb 2022 10:55:36 +0100 Subject: [PATCH 03/16] Add GameLoop next steps --- src/main/java/Game.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/Game.java b/src/main/java/Game.java index ba7a903..4e41325 100644 --- a/src/main/java/Game.java +++ b/src/main/java/Game.java @@ -16,9 +16,15 @@ public class Game { do { dice = p.rollDice(); c++; + if(p.checkFigureInBase(p.figures) == 4 && dice == 6) { + //choose + //moveToStart + } else { + //choose + //moveToDice + } } while (g.checkDice(dice, p, c)); - p.checkGameWin(p.figures); } } From 160e2a01bd676908c2967f1d1f7cbf402b31da65 Mon Sep 17 00:00:00 2001 From: FelixKrull Date: Tue, 1 Feb 2022 11:10:51 +0100 Subject: [PATCH 04/16] Add Startpos attribute to Player --- src/main/java/Game.java | 15 ++++++++------- src/main/java/Player.java | 4 +++- src/test/java/PlayerTest.java | 2 +- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/main/java/Game.java b/src/main/java/Game.java index 4e41325..f98b288 100644 --- a/src/main/java/Game.java +++ b/src/main/java/Game.java @@ -17,10 +17,11 @@ public class Game { dice = p.rollDice(); c++; if(p.checkFigureInBase(p.figures) == 4 && dice == 6) { - //choose - //moveToStart + int figId = p.choose() - 1; + //checkIfKicked + p.figures.get(figId).setPosition(p.startPos); } else { - //choose + int figId = p.choose() - 1; //moveToDice } } while (g.checkDice(dice, p, c)); @@ -34,10 +35,10 @@ public class Game { this.gb = new Gameboard(); gb.initGameboard(); players = new ArrayList<>(); - players.add(new Player("Rot", 40, 43)); - players.add(new Player("Blau", 44, 47)); - players.add(new Player("Gelb", 48, 51)); - players.add(new Player("Grün", 52, 55)); + players.add(new Player("Rot",0, 40, 43)); + players.add(new Player("Blau",10, 44, 47)); + players.add(new Player("Gelb",20, 48, 51)); + players.add(new Player("Grün",30, 52, 55)); } public boolean checkDice(int dice, Player p, int countRolls) { diff --git a/src/main/java/Player.java b/src/main/java/Player.java index 140b144..85a0ab8 100644 --- a/src/main/java/Player.java +++ b/src/main/java/Player.java @@ -6,12 +6,14 @@ public class Player { String name; ArrayList
figures; + int startPos; int startHome; int endHome; Scanner scanner; - public Player (String name, int startHome, int endHome) { + public Player (String name,int startPos, int startHome, int endHome) { this.name = name; + this.startPos = startPos; this.startHome = startHome; this.endHome = endHome; figures = new ArrayList<>(); diff --git a/src/test/java/PlayerTest.java b/src/test/java/PlayerTest.java index 5695f87..4e8ad33 100644 --- a/src/test/java/PlayerTest.java +++ b/src/test/java/PlayerTest.java @@ -19,7 +19,7 @@ public class PlayerTest { @BeforeEach void setup() { - p = new Player("Rot", 40, 43); + p = new Player("Rot",0, 40, 43); } @Test From ec29bc93f5b2d332ff68aab6ba20fcc56fa739c5 Mon Sep 17 00:00:00 2001 From: Jonas Wagner Date: Tue, 8 Feb 2022 08:41:08 +0100 Subject: [PATCH 05/16] Refactor GameTest Player init --- src/test/java/GameTest.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/test/java/GameTest.java b/src/test/java/GameTest.java index 036b7db..a7b9bf7 100644 --- a/src/test/java/GameTest.java +++ b/src/test/java/GameTest.java @@ -13,64 +13,60 @@ import java.util.stream.Stream; public class GameTest { private Game g; + private Player p; @BeforeEach void setup() { g = new Game(); + p = new Player("Rot", 1, 40, 43); } @ParameterizedTest @MethodSource("checkDiceTestData") - void checkDiceTest(String testname, Player testPlayer, Collection positions, int dice, int c, boolean expectedResult) { - Iterator
it = testPlayer.figures.iterator(); + void checkDiceTest(String testname, Collection positions, int dice, int c, boolean expectedResult) { + Iterator
it = p.figures.iterator(); Iterator it2 = positions.iterator(); while(it.hasNext()) { it.next().setPosition(it2.next()); } - boolean calculatedResult = g.checkDice(dice, testPlayer, c); + boolean calculatedResult = g.checkDice(dice, p, c); assertThat(calculatedResult).describedAs(testname).isEqualTo(expectedResult); } static Stream checkDiceTestData () { return Stream.of( Arguments.of("No figures on Field - d: 1 - c: 1", - new Player("Rot", 40, 43), Arrays.asList(-1, -1, -1, -1), 1, 1, true ), Arguments.of("No figures on Field - d: 1 - c: 2", - new Player("Rot", 40, 43), Arrays.asList(-1, -1, -1, -1), 1, 2, true ), Arguments.of("No figures on Field - d: 1 - c: 3", - new Player("Rot", 40, 43), Arrays.asList(-1, -1, -1, -1), 1, 3, true ), Arguments.of("No figures on Field - d: 1 - c: 4", - new Player("Rot", 40, 43), Arrays.asList(-1, -1, -1, -1), 1, 4, false ), Arguments.of("Figures on Field - d: 1 - c: 1", - new Player("Rot", 40, 43), Arrays.asList(10, -1, 2, -1), 1, 1, false ), Arguments.of("Figures on Field - d: 6 - c: 1", - new Player("Rot", 40, 43), Arrays.asList(10, -1, 2, -1), 6, 1, From 3586cfad3ec2e1119664846795030c5a9b3df7e9 Mon Sep 17 00:00:00 2001 From: Jonas Wagner Date: Tue, 8 Feb 2022 09:33:41 +0100 Subject: [PATCH 06/16] Create method checkFieldClear --- src/main/java/Game.java | 26 +++++++++++++++++++++++++- src/test/java/GameTest.java | 34 ++++++++++++++++++++++++++++++---- 2 files changed, 55 insertions(+), 5 deletions(-) diff --git a/src/main/java/Game.java b/src/main/java/Game.java index f98b288..6720ef5 100644 --- a/src/main/java/Game.java +++ b/src/main/java/Game.java @@ -1,3 +1,4 @@ +import java.sql.SQLOutput; import java.util.ArrayList; import java.util.Iterator; @@ -16,7 +17,8 @@ public class Game { do { dice = p.rollDice(); c++; - if(p.checkFigureInBase(p.figures) == 4 && dice == 6) { + //g.checkFieldClear(p.startPos, p, g) + if(p.checkFigureInBase(p.figures) > 0 && dice == 6) { int figId = p.choose() - 1; //checkIfKicked p.figures.get(figId).setPosition(p.startPos); @@ -47,4 +49,26 @@ public class Game { return countRolls <= 3; } else return dice == 6; } + + public int checkFieldClear(int posToCheck, Player p, Game g) { + int mode; + for (Player currentPlayer : g.players) { + //System.out.println("Player"); + if (currentPlayer.name.equals(p.name)) { + System.out.println("TEST"); + mode = 2; + } else { + System.out.println("TEST2"); + mode = 1; + } + for (Figure f : currentPlayer.figures) { + //System.out.println("Figure"); + System.out.println(f.getPosition()); + if (posToCheck == f.getPosition()) { + return mode; + } + } + } + return 0; + } } diff --git a/src/test/java/GameTest.java b/src/test/java/GameTest.java index a7b9bf7..b01581d 100644 --- a/src/test/java/GameTest.java +++ b/src/test/java/GameTest.java @@ -1,6 +1,7 @@ import static org.assertj.core.api.Assertions.*; import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; @@ -13,24 +14,26 @@ import java.util.stream.Stream; public class GameTest { private Game g; - private Player p; + private Player p1; + private Player p2; @BeforeEach void setup() { g = new Game(); - p = new Player("Rot", 1, 40, 43); + p1 = new Player("Rot", 1, 40, 43); + p2 = new Player("Blau",10, 44, 47); } @ParameterizedTest @MethodSource("checkDiceTestData") void checkDiceTest(String testname, Collection positions, int dice, int c, boolean expectedResult) { - Iterator
it = p.figures.iterator(); + Iterator
it = p1.figures.iterator(); Iterator it2 = positions.iterator(); while(it.hasNext()) { it.next().setPosition(it2.next()); } - boolean calculatedResult = g.checkDice(dice, p, c); + boolean calculatedResult = g.checkDice(dice, p1, c); assertThat(calculatedResult).describedAs(testname).isEqualTo(expectedResult); } @@ -74,4 +77,27 @@ public class GameTest { ) ); } + + @Test + void checkFieldClearTestFieldNotTaken() { + int expectedResult = 0; + int calculatedResult = g.checkFieldClear(1, p1, g); + assertThat(calculatedResult).describedAs("Check Field Clear").isEqualTo(expectedResult); + } + + @Test + void checkFieldClearTestFieldTakenByOtherPlayer() { + int expectedResult = 1; + g.players.get(1).figures.get(0).setPosition(1); + int calculatedResult = g.checkFieldClear(1, g.players.get(0), g); + assertThat(calculatedResult).describedAs("Check Field Clear").isEqualTo(expectedResult); + } + + @Test + void checkFieldClearTestFieldTakenByOwnFigure() { + int expectedResult = 2; + g.players.get(0).figures.get(1).setPosition(1); + int calculatedResult = g.checkFieldClear(1, g.players.get(0), g); + assertThat(calculatedResult).describedAs("Check Field Clear").isEqualTo(expectedResult); + } } From 0c861332586402977ac6bd1253fa9c83a2c264b3 Mon Sep 17 00:00:00 2001 From: Jonas Wagner Date: Tue, 8 Feb 2022 09:35:07 +0100 Subject: [PATCH 07/16] Refactor Game and GameTest --- src/main/java/Game.java | 7 ------- src/test/java/GameTest.java | 2 -- 2 files changed, 9 deletions(-) diff --git a/src/main/java/Game.java b/src/main/java/Game.java index 6720ef5..20df95d 100644 --- a/src/main/java/Game.java +++ b/src/main/java/Game.java @@ -1,6 +1,4 @@ -import java.sql.SQLOutput; import java.util.ArrayList; -import java.util.Iterator; public class Game { @@ -53,17 +51,12 @@ public class Game { public int checkFieldClear(int posToCheck, Player p, Game g) { int mode; for (Player currentPlayer : g.players) { - //System.out.println("Player"); if (currentPlayer.name.equals(p.name)) { - System.out.println("TEST"); mode = 2; } else { - System.out.println("TEST2"); mode = 1; } for (Figure f : currentPlayer.figures) { - //System.out.println("Figure"); - System.out.println(f.getPosition()); if (posToCheck == f.getPosition()) { return mode; } diff --git a/src/test/java/GameTest.java b/src/test/java/GameTest.java index b01581d..b3e9297 100644 --- a/src/test/java/GameTest.java +++ b/src/test/java/GameTest.java @@ -15,14 +15,12 @@ public class GameTest { private Game g; private Player p1; - private Player p2; @BeforeEach void setup() { g = new Game(); p1 = new Player("Rot", 1, 40, 43); - p2 = new Player("Blau",10, 44, 47); } @ParameterizedTest From 5365036371678c9a26da1f55af2fff0b6582c2b9 Mon Sep 17 00:00:00 2001 From: FelixKrull Date: Tue, 8 Feb 2022 11:44:41 +0100 Subject: [PATCH 08/16] Implement getUsableFigures --- src/main/java/Game.java | 54 ++++++++++++++++++++++++--- src/main/java/Player.java | 4 +- src/test/java/GameTest.java | 69 +++++++++++++++++++++++++++++++---- src/test/java/PlayerTest.java | 2 +- 4 files changed, 115 insertions(+), 14 deletions(-) diff --git a/src/main/java/Game.java b/src/main/java/Game.java index 20df95d..b66f7b6 100644 --- a/src/main/java/Game.java +++ b/src/main/java/Game.java @@ -14,11 +14,25 @@ public class Game { do { dice = p.rollDice(); + + /* + rolldice() + --> dice(1-6) + List getUsableFigures (dice, g, p) + --> {0,1,2,3} + int choose(List figs, p) + --> 1 + setFigure (p.figures.get(1), dice, g, p) + --> nächster Spieler + */ + + c++; //g.checkFieldClear(p.startPos, p, g) if(p.checkFigureInBase(p.figures) > 0 && dice == 6) { int figId = p.choose() - 1; //checkIfKicked + p.figures.get(figId).setPosition(p.startPos); } else { int figId = p.choose() - 1; @@ -35,10 +49,10 @@ public class Game { this.gb = new Gameboard(); gb.initGameboard(); players = new ArrayList<>(); - players.add(new Player("Rot",0, 40, 43)); - players.add(new Player("Blau",10, 44, 47)); - players.add(new Player("Gelb",20, 48, 51)); - players.add(new Player("Grün",30, 52, 55)); + players.add(new Player("Rot",0, 40, 43, 39)); + players.add(new Player("Blau",10, 44, 47, 9)); + players.add(new Player("Gelb",20, 48, 51, 19)); + players.add(new Player("Grün",30, 52, 55, 29)); } public boolean checkDice(int dice, Player p, int countRolls) { @@ -64,4 +78,34 @@ public class Game { } return 0; } -} + + public ArrayList getUsableFigures(int dice, Player p, Game g) { + ArrayList result = new ArrayList<>(); + for(int i = 0; i < p.figures.size(); i++) { + if(figureIsUsable(dice, i, p, g)) { + result.add(i); + } + } + return result; + } + + public boolean figureIsUsable(int dice, int figId, Player p, Game g) { + Figure f = p.figures.get(figId); + + if(p.checkFigureInBase(p.figures) > 0 && dice == 6){ + if(g.checkFieldClear(p.startPos, p, g) == 2) { + return f.getPosition() == p.startPos; //TODO Wenn Figur auf Startpos von anderer Figur blockiert ist + } + return f.getPosition() == -1; + } else if (f.getPosition() <= p.jumpToHome && (f.getPosition() + dice) > p.jumpToHome) { + if((f.getPosition() + dice) <= p.jumpToHome + 4) { + return g.checkFieldClear(f.getPosition() + dice - p.jumpToHome + p.startHome - 1, p, g) != 2; + } else { + return false; + } + } else if(f.getPosition() != -1) { + return g.checkFieldClear((f.getPosition() + dice) % 40, p, g) != 2; + } + return false; + } +} \ No newline at end of file diff --git a/src/main/java/Player.java b/src/main/java/Player.java index 85a0ab8..96e91e2 100644 --- a/src/main/java/Player.java +++ b/src/main/java/Player.java @@ -9,13 +9,15 @@ public class Player { int startPos; int startHome; int endHome; + int jumpToHome; Scanner scanner; - public Player (String name,int startPos, int startHome, int endHome) { + public Player (String name,int startPos, int startHome, int endHome, int jumpToHome) { this.name = name; this.startPos = startPos; this.startHome = startHome; this.endHome = endHome; + this.jumpToHome = jumpToHome; figures = new ArrayList<>(); for(int i = 0; i < 4; i++) { figures.add(new Figure()); diff --git a/src/test/java/GameTest.java b/src/test/java/GameTest.java index b3e9297..c8523f1 100644 --- a/src/test/java/GameTest.java +++ b/src/test/java/GameTest.java @@ -6,9 +6,7 @@ import org.junit.jupiter.params.ParameterizedTest; import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; -import java.util.Arrays; -import java.util.Collection; -import java.util.Iterator; +import java.util.*; import java.util.stream.Stream; public class GameTest { @@ -20,7 +18,7 @@ public class GameTest { @BeforeEach void setup() { g = new Game(); - p1 = new Player("Rot", 1, 40, 43); + p1 = g.players.get(0); } @ParameterizedTest @@ -87,15 +85,72 @@ public class GameTest { void checkFieldClearTestFieldTakenByOtherPlayer() { int expectedResult = 1; g.players.get(1).figures.get(0).setPosition(1); - int calculatedResult = g.checkFieldClear(1, g.players.get(0), g); + int calculatedResult = g.checkFieldClear(1, p1, g); assertThat(calculatedResult).describedAs("Check Field Clear").isEqualTo(expectedResult); } @Test void checkFieldClearTestFieldTakenByOwnFigure() { int expectedResult = 2; - g.players.get(0).figures.get(1).setPosition(1); - int calculatedResult = g.checkFieldClear(1, g.players.get(0), g); + p1.figures.get(1).setPosition(1); + int calculatedResult = g.checkFieldClear(1, p1, g); assertThat(calculatedResult).describedAs("Check Field Clear").isEqualTo(expectedResult); } + + @ParameterizedTest + @MethodSource("usableFiguresData") + void getUsableFiguresTest(String testname, int dice, Collection positions, ArrayList expectedResult) { + Iterator
figureIt = p1.figures.iterator(); + Iterator posIt = positions.iterator(); + while(figureIt.hasNext()) { + Figure f = figureIt.next(); + f.setPosition(posIt.next()); + } + + List calculatedResult = g.getUsableFigures(dice, p1, g); + assertThat(calculatedResult).describedAs(testname).isEqualTo(expectedResult); + } + + static Stream usableFiguresData () { + return Stream.of( + Arguments.of( //Würfel 1-6 - Keine Figur im Ziel - Alle Figuren auf dem Spielfeld - StartFeld frei - Keine Figur vor Ziel + "Alle Figuren", + 1, + Arrays.asList(10, 25, 2, 17), + new ArrayList<>(Arrays.asList(0, 1, 2, 3)) + ), + Arguments.of( //Würfel 6 - Keine Figur im Ziel - 1 Figur auf dem Spielfeld - StartFeld frei - Keine Figur vor Ziel + "Figuren die nicht am Spielfeld stehen", + 6, + Arrays.asList(10, -1, -1, -1), + new ArrayList<>(Arrays.asList(1, 2, 3)) + ), + Arguments.of( //Würfel 6 - Keine Figur im Ziel - 1 Figur auf dem Spielfeld - StartFeld besetzt - Keine Figur vor Ziel + "Figur die das Startfeld besetzt", + 6, + Arrays.asList(10, 0, -1, -1), + new ArrayList<>(List.of(1)) + ), + Arguments.of( //Würfel 5 - Keine Figur im Ziel - 1 Figur auf dem Spielfeld - StartFeld besetzt - Figur vor Ziel + "Figur vor dem Ziel - kann man benutzen", + 5, + Arrays.asList(10, 37, -1, -1), + new ArrayList<>(Arrays.asList(0,1)) + ), + Arguments.of( //Würfel 5 - Keine Figur im Ziel - 1 Figur auf dem Spielfeld - StartFeld besetzt - Figur vor Ziel + "Figur vor dem Ziel - kann man nicht benutzen", + 5, + Arrays.asList(10, 39, -1, -1), + new ArrayList<>(List.of(0)) + ), + Arguments.of( //Würfel 5 - Figur im Ziel - 1 Figur auf dem Spielfeld - StartFeld besetzt - Figur vor Ziel + "Nur Figuren die auf ein freies Feld kommen", + 2, + Arrays.asList(10, 12, -1, -1), + new ArrayList<>(List.of(1)) + ) + ); + } } + + diff --git a/src/test/java/PlayerTest.java b/src/test/java/PlayerTest.java index 4e8ad33..960e245 100644 --- a/src/test/java/PlayerTest.java +++ b/src/test/java/PlayerTest.java @@ -19,7 +19,7 @@ public class PlayerTest { @BeforeEach void setup() { - p = new Player("Rot",0, 40, 43); + p = new Player("Rot",0, 40, 43, 39); } @Test From e0ab6f0c464686b6e4ff5d0fecdb93a8a3097c83 Mon Sep 17 00:00:00 2001 From: FelixKrull Date: Wed, 9 Feb 2022 10:39:58 +0100 Subject: [PATCH 09/16] Refactor Player --- src/main/java/Game.java | 12 ++++++------ src/main/java/Player.java | 6 ++---- src/test/java/PlayerTest.java | 2 +- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/main/java/Game.java b/src/main/java/Game.java index b66f7b6..84b8122 100644 --- a/src/main/java/Game.java +++ b/src/main/java/Game.java @@ -16,9 +16,9 @@ public class Game { dice = p.rollDice(); /* - rolldice() + = Done rolldice() --> dice(1-6) - List getUsableFigures (dice, g, p) + = List getUsableFigures (dice, g, p) --> {0,1,2,3} int choose(List figs, p) --> 1 @@ -49,10 +49,10 @@ public class Game { this.gb = new Gameboard(); gb.initGameboard(); players = new ArrayList<>(); - players.add(new Player("Rot",0, 40, 43, 39)); - players.add(new Player("Blau",10, 44, 47, 9)); - players.add(new Player("Gelb",20, 48, 51, 19)); - players.add(new Player("Grün",30, 52, 55, 29)); + players.add(new Player("Rot",0, 40, 39)); + players.add(new Player("Blau",10, 44, 9)); + players.add(new Player("Gelb",20, 48, 19)); + players.add(new Player("Grün",30, 52, 29)); } public boolean checkDice(int dice, Player p, int countRolls) { diff --git a/src/main/java/Player.java b/src/main/java/Player.java index 96e91e2..a276573 100644 --- a/src/main/java/Player.java +++ b/src/main/java/Player.java @@ -8,15 +8,13 @@ public class Player { ArrayList
figures; int startPos; int startHome; - int endHome; int jumpToHome; Scanner scanner; - public Player (String name,int startPos, int startHome, int endHome, int jumpToHome) { + public Player(String name, int startPos, int startHome, int jumpToHome) { this.name = name; this.startPos = startPos; this.startHome = startHome; - this.endHome = endHome; this.jumpToHome = jumpToHome; figures = new ArrayList<>(); for(int i = 0; i < 4; i++) { @@ -38,7 +36,7 @@ public class Player { Figure f; while(it.hasNext()) { f = it.next(); - if(!(f.getPosition() >= startHome && f.getPosition() <= endHome)) { + if(!(f.getPosition() >= startHome && f.getPosition() <= startHome+3)) { return false; } } diff --git a/src/test/java/PlayerTest.java b/src/test/java/PlayerTest.java index 960e245..cab2608 100644 --- a/src/test/java/PlayerTest.java +++ b/src/test/java/PlayerTest.java @@ -19,7 +19,7 @@ public class PlayerTest { @BeforeEach void setup() { - p = new Player("Rot",0, 40, 43, 39); + p = new Player("Rot",0, 40, 39); } @Test From 459a35fe2d378267eb166ab9e34b830f11de6fc2 Mon Sep 17 00:00:00 2001 From: FelixKrull Date: Wed, 9 Feb 2022 10:50:33 +0100 Subject: [PATCH 10/16] Change Choose method to use List of Figures --- src/main/java/Player.java | 14 ++++++-------- src/test/java/PlayerTest.java | 24 +++++++++++++----------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/main/java/Player.java b/src/main/java/Player.java index a276573..2180cb4 100644 --- a/src/main/java/Player.java +++ b/src/main/java/Player.java @@ -1,6 +1,4 @@ -import java.util.ArrayList; -import java.util.Iterator; -import java.util.Scanner; +import java.util.*; public class Player { @@ -56,20 +54,20 @@ public class Player { return count; } - public int choose() { + public int choose(ArrayList usableFigures) { scanner = new Scanner(System.in); - System.out.print("Wählen Sie eine Figur(1-4): "); + System.out.print("Wählen Sie eine Figur " + usableFigures.toString() + ": "); try{ int input = scanner.nextInt(); - if (input > 4 || input < 1) { + if (input > Collections.max(usableFigures) || input < Collections.min(usableFigures)) { System.out.println("Die eingegebene Zahl war zu groß oder zu klein.\n" + - "Bitte nur Zahlen von 1 bis 4 eingeben."); + "Bitte nur Zahlen von " + Collections.min(usableFigures) + " bis " + Collections.max(usableFigures) + " eingeben."); return -1; } return input; } catch (Exception e) { System.out.println("Die Eingabe hat keine Zahl bekommen.\n" + - "Bitte nur Zahlen von 1 bis 4 eingeben."); + "Bitte nur Zahlen von " + Collections.min(usableFigures) + " bis " + Collections.max(usableFigures) + " eingeben."); return -1; } } diff --git a/src/test/java/PlayerTest.java b/src/test/java/PlayerTest.java index cab2608..093e870 100644 --- a/src/test/java/PlayerTest.java +++ b/src/test/java/PlayerTest.java @@ -176,23 +176,25 @@ public class PlayerTest { @ParameterizedTest @MethodSource("checkChooseMethodData") - void checkChoose(String testName, String input, int expectedResult) { + void checkChoose(String testName, String input,ArrayList usableFiugres, int expectedResult) { System.setIn(new ByteArrayInputStream(input.getBytes())); - int calculatedResult = p.choose(); + int calculatedResult = p.choose(usableFiugres); assertThat(calculatedResult).describedAs(testName).isEqualTo(expectedResult); } static Stream checkChooseMethodData() { return Stream.of( - Arguments.of("Figure 1 choosen", "1\n", 1), - Arguments.of("Figure 2 choosen", "2\n", 2), - Arguments.of("Figure 3 choosen", "3\n", 3), - Arguments.of("Figure 4 choosen", "4\n", 4), - Arguments.of("Index out of bounds choosen", "16\n", -1), - Arguments.of("Index out of bounds choosen", "-2\n", -1), - Arguments.of("Input a letter or char", "g\n", -1), - Arguments.of("Input a empty string", "\n", -1), - Arguments.of("Input a special character", "&\n", -1) + Arguments.of("Figure 1 choosen", "1\n", new ArrayList<>(Arrays.asList(1,2,3,4)), 1), + Arguments.of("Figure 2 choosen", "2\n", new ArrayList<>(Arrays.asList(1,2,3,4)), 2), + Arguments.of("Figure 3 choosen", "3\n", new ArrayList<>(Arrays.asList(1,2,3,4)),3), + Arguments.of("Figure 4 choosen", "4\n", new ArrayList<>(Arrays.asList(1,2,3,4)),4), + Arguments.of("Index out of bounds choosen", "16\n",new ArrayList<>(Arrays.asList(1,2,3,4)), -1), + Arguments.of("Index out of bounds choosen", "-2\n",new ArrayList<>(Arrays.asList(1,2,3,4)), -1), + Arguments.of("Input a letter or char", "g\n",new ArrayList<>(Arrays.asList(1,2,3,4)), -1), + Arguments.of("Input a empty string", "\n",new ArrayList<>(Arrays.asList(1,2,3,4)), -1), + Arguments.of("Input a special character", "&\n",new ArrayList<>(Arrays.asList(1,2,3,4)), -1), + Arguments.of("Only one Figure available", "1\n", new ArrayList<>(Arrays.asList(1)),1), + Arguments.of("Figure not available", "4\n", new ArrayList<>(Arrays.asList(1,2)),-1) ); } } From 1d2743f544be20489339e2724d6b6cc8acfc8825 Mon Sep 17 00:00:00 2001 From: FelixKrull Date: Wed, 9 Feb 2022 10:51:07 +0100 Subject: [PATCH 11/16] Refactor PlayerTest --- src/test/java/PlayerTest.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/test/java/PlayerTest.java b/src/test/java/PlayerTest.java index 093e870..93a2c43 100644 --- a/src/test/java/PlayerTest.java +++ b/src/test/java/PlayerTest.java @@ -7,10 +7,7 @@ import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; import java.io.ByteArrayInputStream; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Iterator; +import java.util.*; import java.util.stream.Stream; public class PlayerTest { @@ -193,7 +190,7 @@ public class PlayerTest { Arguments.of("Input a letter or char", "g\n",new ArrayList<>(Arrays.asList(1,2,3,4)), -1), Arguments.of("Input a empty string", "\n",new ArrayList<>(Arrays.asList(1,2,3,4)), -1), Arguments.of("Input a special character", "&\n",new ArrayList<>(Arrays.asList(1,2,3,4)), -1), - Arguments.of("Only one Figure available", "1\n", new ArrayList<>(Arrays.asList(1)),1), + Arguments.of("Only one Figure available", "1\n", new ArrayList<>(List.of(1)),1), Arguments.of("Figure not available", "4\n", new ArrayList<>(Arrays.asList(1,2)),-1) ); } From ba2cfb3854f8eb5aabb89dc8c8e0670b8654792d Mon Sep 17 00:00:00 2001 From: FelixKrull Date: Wed, 9 Feb 2022 10:54:57 +0100 Subject: [PATCH 12/16] Rewrite GameLoop with new methods --- src/main/java/Game.java | 25 ++----------------------- 1 file changed, 2 insertions(+), 23 deletions(-) diff --git a/src/main/java/Game.java b/src/main/java/Game.java index 84b8122..89ac454 100644 --- a/src/main/java/Game.java +++ b/src/main/java/Game.java @@ -14,32 +14,11 @@ public class Game { do { dice = p.rollDice(); - - /* - = Done rolldice() - --> dice(1-6) - = List getUsableFigures (dice, g, p) - --> {0,1,2,3} - int choose(List figs, p) - --> 1 - setFigure (p.figures.get(1), dice, g, p) - --> nächster Spieler - */ - - c++; - //g.checkFieldClear(p.startPos, p, g) - if(p.checkFigureInBase(p.figures) > 0 && dice == 6) { - int figId = p.choose() - 1; - //checkIfKicked + ArrayList usableFigures = g.getUsableFigures(dice, p, g); + int figId = p.choose(usableFigures); - p.figures.get(figId).setPosition(p.startPos); - } else { - int figId = p.choose() - 1; - //moveToDice - } } while (g.checkDice(dice, p, c)); - p.checkGameWin(p.figures); } } From e06cc3a7a3b9f70070d008ac63ce1241c644b7bd Mon Sep 17 00:00:00 2001 From: Jonas Wagner Date: Wed, 9 Feb 2022 11:19:12 +0100 Subject: [PATCH 13/16] Implement setFigure method --- src/main/java/Game.java | 15 +++++++++++++++ src/test/java/GameTest.java | 22 ++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/src/main/java/Game.java b/src/main/java/Game.java index 89ac454..7168661 100644 --- a/src/main/java/Game.java +++ b/src/main/java/Game.java @@ -87,4 +87,19 @@ public class Game { } return false; } + + public int setFigure(int figId, int dice, Player p, Game g) { + int preCalculated = (p.figures.get(figId).getPosition() + dice) % 40; + int kicked = 0; + for(Player currentPlayer : g.players) { + for(Figure currentFigure : currentPlayer.figures) { + if(currentFigure.getPosition() == preCalculated) { + currentFigure.setPosition(-1); + kicked = 1; + } + } + } + p.figures.get(figId).setPosition(preCalculated); + return kicked; + } } \ No newline at end of file diff --git a/src/test/java/GameTest.java b/src/test/java/GameTest.java index c8523f1..e389c57 100644 --- a/src/test/java/GameTest.java +++ b/src/test/java/GameTest.java @@ -13,12 +13,20 @@ public class GameTest { private Game g; private Player p1; + private Game g2; + private Player p2; @BeforeEach void setup() { g = new Game(); p1 = g.players.get(0); + + g2 = new Game(); + p2 = g2.players.get(0); + p2.figures.get(0).setPosition(5); + p2.figures.get(1).setPosition(10); + g2.players.get(3).figures.get(1).setPosition(14); } @ParameterizedTest @@ -151,6 +159,20 @@ public class GameTest { ) ); } + + @ParameterizedTest + @MethodSource("setFigureData") + void setFigureTest(String testname, int figId, int dice, int expectedResult) { + int calculatedResult = g.setFigure(figId, dice, p2, g2); + assertThat(calculatedResult).describedAs(testname).isEqualTo(expectedResult); + } + + static Stream setFigureData () { + return Stream.of( + Arguments.of("Figur wird auf Feld gesetzt - Niemand gekicked", 0, 4, 0), + Arguments.of("Figur wird auf Feld gesetzt - Jemand gekicked", 1, 4, 1) + ); + } } From 80c8a8c0f79d22b42c7d6b1daf831930f81cf6b6 Mon Sep 17 00:00:00 2001 From: Jonas Wagner Date: Wed, 9 Feb 2022 11:37:54 +0100 Subject: [PATCH 14/16] Improve GameLoop --- src/main/java/Game.java | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/main/java/Game.java b/src/main/java/Game.java index 7168661..11069c7 100644 --- a/src/main/java/Game.java +++ b/src/main/java/Game.java @@ -1,25 +1,40 @@ import java.util.ArrayList; +import java.util.concurrent.TimeUnit; + +import static java.lang.System.exit; public class Game { Gameboard gb; ArrayList players; - public static void main(String[] args) { + public static void main(String[] args) throws InterruptedException { Game g = new Game(); + Player winner; while(true){ for (Player p : g.players) { int c = 0; int dice; - + System.out.println("Spieler " + p.toString() + " an der Reihe."); do { + int figId; dice = p.rollDice(); + TimeUnit.SECONDS.sleep(1L); + System.out.println("Würfel: " + dice); c++; ArrayList usableFigures = g.getUsableFigures(dice, p, g); - int figId = p.choose(usableFigures); - + if(usableFigures.size() > 0) { + do { + figId = p.choose(usableFigures); + } while(figId == -1); + g.setFigure(figId, dice, p, g); + } } while (g.checkDice(dice, p, c)); - p.checkGameWin(p.figures); + if(p.checkGameWin(p.figures)) { + winner = p; + System.out.println("Spieler " + winner.toString() + " gewinnt!"); + exit(42); + } } } } From 8a8bf9aadbc4ea13a0e2a03c2fdbf39d3657f957 Mon Sep 17 00:00:00 2001 From: Jonas Wagner Date: Wed, 9 Feb 2022 11:48:38 +0100 Subject: [PATCH 15/16] Fix GameLoop --- src/main/java/Game.java | 7 ++++++- src/test/java/GameTest.java | 6 ++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/main/java/Game.java b/src/main/java/Game.java index 11069c7..1bccc63 100644 --- a/src/main/java/Game.java +++ b/src/main/java/Game.java @@ -104,7 +104,12 @@ public class Game { } public int setFigure(int figId, int dice, Player p, Game g) { - int preCalculated = (p.figures.get(figId).getPosition() + dice) % 40; + int preCalculated; + if(p.figures.get(figId).getPosition() == -1) { + preCalculated = p.startPos; + } else { + preCalculated = (p.figures.get(figId).getPosition() + dice) % 40; + } int kicked = 0; for(Player currentPlayer : g.players) { for(Figure currentFigure : currentPlayer.figures) { diff --git a/src/test/java/GameTest.java b/src/test/java/GameTest.java index e389c57..27d63dc 100644 --- a/src/test/java/GameTest.java +++ b/src/test/java/GameTest.java @@ -156,6 +156,12 @@ public class GameTest { 2, Arrays.asList(10, 12, -1, -1), new ArrayList<>(List.of(1)) + ), + Arguments.of( //Würfel 6 - 1 Figur auf dem Spielfeld - StartFeld besetzt + "Figur auf Startfeld", + 6, + Arrays.asList(-1, -1, -1, 0), + new ArrayList<>(List.of(3)) ) ); } From d1ee446cc4c819d5311e538b794c73145020738f Mon Sep 17 00:00:00 2001 From: Jonas Wagner Date: Wed, 9 Feb 2022 11:49:52 +0100 Subject: [PATCH 16/16] Refactor Player toString --- src/main/java/Game.java | 4 ++-- src/main/java/Player.java | 5 ----- src/test/java/PlayerTest.java | 7 ------- 3 files changed, 2 insertions(+), 14 deletions(-) diff --git a/src/main/java/Game.java b/src/main/java/Game.java index 1bccc63..504800c 100644 --- a/src/main/java/Game.java +++ b/src/main/java/Game.java @@ -15,7 +15,7 @@ public class Game { for (Player p : g.players) { int c = 0; int dice; - System.out.println("Spieler " + p.toString() + " an der Reihe."); + System.out.println("Spieler " + p.name + " an der Reihe."); do { int figId; dice = p.rollDice(); @@ -32,7 +32,7 @@ public class Game { } while (g.checkDice(dice, p, c)); if(p.checkGameWin(p.figures)) { winner = p; - System.out.println("Spieler " + winner.toString() + " gewinnt!"); + System.out.println("Spieler " + winner.name + " gewinnt!"); exit(42); } } diff --git a/src/main/java/Player.java b/src/main/java/Player.java index 2180cb4..fd04ee1 100644 --- a/src/main/java/Player.java +++ b/src/main/java/Player.java @@ -20,11 +20,6 @@ public class Player { } } - @Override - public String toString() { - return name; - } - public int rollDice() { return (int) (Math.random() * 6 + 1); } diff --git a/src/test/java/PlayerTest.java b/src/test/java/PlayerTest.java index 93a2c43..0a38a78 100644 --- a/src/test/java/PlayerTest.java +++ b/src/test/java/PlayerTest.java @@ -25,13 +25,6 @@ public class PlayerTest { assertThat(calculatedResult).describedAs("Dice result").isBetween(1,6); } - @Test - void testToString() { - String expectedResult = "Rot"; - String calculatedResult = p.toString(); - assertThat(calculatedResult).describedAs("Player Name").isEqualTo(expectedResult); - } - @Test void checkStartPositionOfFigures() { int expectedResult = -1;