Browse Source

Refactor Player

AIPlayer
FelixKrull 3 years ago
parent
commit
e0ab6f0c46
  1. 12
      src/main/java/Game.java
  2. 6
      src/main/java/Player.java
  3. 2
      src/test/java/PlayerTest.java

12
src/main/java/Game.java

@ -16,9 +16,9 @@ public class Game {
dice = p.rollDice();
/*
rolldice()
= Done rolldice()
--> dice(1-6)
List<Integer> getUsableFigures (dice, g, p)
= List<Integer> getUsableFigures (dice, g, p)
--> {0,1,2,3}
int choose(List<Integer> 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) {

6
src/main/java/Player.java

@ -8,15 +8,13 @@ public class Player {
ArrayList<Figure> 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;
}
}

2
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

Loading…
Cancel
Save