Browse Source

Add Startpos attribute to Player

AIPlayer
FelixKrull 3 years ago
parent
commit
160e2a01bd
  1. 15
      src/main/java/Game.java
  2. 4
      src/main/java/Player.java
  3. 2
      src/test/java/PlayerTest.java

15
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) {

4
src/main/java/Player.java

@ -6,12 +6,14 @@ public class Player {
String name;
ArrayList<Figure> 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<>();

2
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

Loading…
Cancel
Save