From 8a8bf9aadbc4ea13a0e2a03c2fdbf39d3657f957 Mon Sep 17 00:00:00 2001 From: Jonas Wagner Date: Wed, 9 Feb 2022 11:48:38 +0100 Subject: [PATCH] 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)) ) ); }