Browse Source

Fix GameLoop

AIPlayer
Jonas Wagner 3 years ago
parent
commit
8a8bf9aadb
  1. 7
      src/main/java/Game.java
  2. 6
      src/test/java/GameTest.java

7
src/main/java/Game.java

@ -104,7 +104,12 @@ public class Game {
} }
public int setFigure(int figId, int dice, Player p, Game g) { 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; int kicked = 0;
for(Player currentPlayer : g.players) { for(Player currentPlayer : g.players) {
for(Figure currentFigure : currentPlayer.figures) { for(Figure currentFigure : currentPlayer.figures) {

6
src/test/java/GameTest.java

@ -156,6 +156,12 @@ public class GameTest {
2, 2,
Arrays.asList(10, 12, -1, -1), Arrays.asList(10, 12, -1, -1),
new ArrayList<>(List.of(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))
) )
); );
} }

Loading…
Cancel
Save