From e0ab6f0c464686b6e4ff5d0fecdb93a8a3097c83 Mon Sep 17 00:00:00 2001 From: FelixKrull Date: Wed, 9 Feb 2022 10:39:58 +0100 Subject: [PATCH] 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