Browse Source

Implement printGameboard into Gameloop

AIPlayer
FelixKrull 3 years ago
parent
commit
2f8f41b04b
  1. 19
      src/main/java/Game.java

19
src/main/java/Game.java

@ -1,8 +1,10 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.concurrent.TimeUnit;
import static java.lang.System.exit;
public class Game {
Gameboard gb;
@ -13,10 +15,9 @@ public class Game {
Player winner;
while(true){
for (Player p : g.players) {
System.out.println(g.toString());
int c = 0;
int dice;
System.out.println("Spieler " + p.name + " an der Reihe.");
System.out.println(g.printGameboard(g,p));
do {
int figId;
dice = p.rollDice();
@ -29,6 +30,8 @@ public class Game {
figId = p.choose(usableFigures);
} while(figId == -1);
g.setFigure(figId, dice, p, g);
clearScreen();
System.out.println(g.printGameboard(g,p));
}
} while (g.checkDice(dice, p, c));
if(p.checkGameWin(p.figures)) {
@ -36,7 +39,7 @@ public class Game {
System.out.println("Spieler " + winner.name + " gewinnt!");
exit(42);
}
//clear;
clearScreen();
}
}
}
@ -51,9 +54,13 @@ public class Game {
players.add(new Player("Grün",30, 52, 29));
}
@Override
public String toString() {
return gb.toString();
public String printGameboard(Game g, Player p) {
return gb.printBoard(g, p);
}
public static void clearScreen() {
System.out.print("\033[H\033[2J");
System.out.flush();
}
public boolean checkDice(int dice, Player p, int countRolls) {

Loading…
Cancel
Save