From 160e2a01bd676908c2967f1d1f7cbf402b31da65 Mon Sep 17 00:00:00 2001 From: FelixKrull Date: Tue, 1 Feb 2022 11:10:51 +0100 Subject: [PATCH] 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