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(); dice = p.rollDice();
c++; c++;
if(p.checkFigureInBase(p.figures) == 4 && dice == 6) { if(p.checkFigureInBase(p.figures) == 4 && dice == 6) {
//choose
//moveToStart
int figId = p.choose() - 1;
//checkIfKicked
p.figures.get(figId).setPosition(p.startPos);
} else { } else {
//choose
int figId = p.choose() - 1;
//moveToDice //moveToDice
} }
} while (g.checkDice(dice, p, c)); } while (g.checkDice(dice, p, c));
@ -34,10 +35,10 @@ public class Game {
this.gb = new Gameboard(); this.gb = new Gameboard();
gb.initGameboard(); gb.initGameboard();
players = new ArrayList<>(); 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) { public boolean checkDice(int dice, Player p, int countRolls) {

4
src/main/java/Player.java

@ -6,12 +6,14 @@ public class Player {
String name; String name;
ArrayList<Figure> figures; ArrayList<Figure> figures;
int startPos;
int startHome; int startHome;
int endHome; int endHome;
Scanner scanner; Scanner scanner;
public Player (String name, int startHome, int endHome) {
public Player (String name,int startPos, int startHome, int endHome) {
this.name = name; this.name = name;
this.startPos = startPos;
this.startHome = startHome; this.startHome = startHome;
this.endHome = endHome; this.endHome = endHome;
figures = new ArrayList<>(); figures = new ArrayList<>();

2
src/test/java/PlayerTest.java

@ -19,7 +19,7 @@ public class PlayerTest {
@BeforeEach @BeforeEach
void setup() { void setup() {
p = new Player("Rot", 40, 43);
p = new Player("Rot",0, 40, 43);
} }
@Test @Test

Loading…
Cancel
Save