You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
1.9 KiB
67 lines
1.9 KiB
import java.util.ArrayList;
|
|
|
|
public class Game {
|
|
|
|
Gameboard gb;
|
|
ArrayList<Player> players;
|
|
|
|
public static void main(String[] args) {
|
|
Game g = new Game();
|
|
while(true){
|
|
for (Player p : g.players) {
|
|
int c = 0;
|
|
int dice;
|
|
|
|
do {
|
|
dice = p.rollDice();
|
|
c++;
|
|
//g.checkFieldClear(p.startPos, p, g)
|
|
if(p.checkFigureInBase(p.figures) > 0 && dice == 6) {
|
|
int figId = p.choose() - 1;
|
|
//checkIfKicked
|
|
p.figures.get(figId).setPosition(p.startPos);
|
|
} else {
|
|
int figId = p.choose() - 1;
|
|
//moveToDice
|
|
}
|
|
} while (g.checkDice(dice, p, c));
|
|
|
|
p.checkGameWin(p.figures);
|
|
}
|
|
}
|
|
}
|
|
|
|
public Game() {
|
|
this.gb = new Gameboard();
|
|
gb.initGameboard();
|
|
players = new ArrayList<>();
|
|
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) {
|
|
int figuresInBase = p.checkFigureInBase(p.figures);
|
|
if(figuresInBase == 4) {
|
|
return countRolls <= 3;
|
|
} else return dice == 6;
|
|
}
|
|
|
|
public int checkFieldClear(int posToCheck, Player p, Game g) {
|
|
int mode;
|
|
for (Player currentPlayer : g.players) {
|
|
if (currentPlayer.name.equals(p.name)) {
|
|
mode = 2;
|
|
} else {
|
|
mode = 1;
|
|
}
|
|
for (Figure f : currentPlayer.figures) {
|
|
if (posToCheck == f.getPosition()) {
|
|
return mode;
|
|
}
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
}
|