diff --git a/src/main/java/Game.java b/src/main/java/Game.java index 9e3704a..30a81e5 100644 --- a/src/main/java/Game.java +++ b/src/main/java/Game.java @@ -15,12 +15,14 @@ public class Game { for (Player p : g.players) { int c = 0; int dice; - System.out.println("Spieler " + p.name + " an der Reihe."); do { + clearScreen(); int figId; dice = p.rollDice(); - TimeUnit.SECONDS.sleep(1L); - System.out.println("Würfel: " + dice); + System.out.println(g.printGameboard(g,p,dice)); + TimeUnit.MILLISECONDS.sleep(600L); + System.out.println("Würfel: "+ dice); + TimeUnit.MILLISECONDS.sleep(600L); c++; ArrayList usableFigures = g.getUsableFigures(dice, p, g); if(usableFigures.size() > 0) { @@ -28,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,dice)); } } while (g.checkDice(dice, p, c)); if(p.checkGameWin(p.figures)) { @@ -49,8 +53,8 @@ public class Game { players.add(new Player("Grün",30, 52, 29)); } - public String printGameboard(Game g, Player p) { - return gb.printBoard(g, p); + public String printGameboard(Game g, Player p, int dice) { + return gb.printBoard(g, p, dice); } public static void clearScreen() { diff --git a/src/main/java/Gameboard.java b/src/main/java/Gameboard.java index 4f571f1..379d09d 100644 --- a/src/main/java/Gameboard.java +++ b/src/main/java/Gameboard.java @@ -28,8 +28,9 @@ public class Gameboard { } - public String printBoard(Game g, Player p) { + public String printBoard(Game g, Player p, int dice) { String[] f = getFiguresOnBoard(g); + String[] d = getDice(dice); String color = ""; switch (p.name) { case "Rot" -> color = RED; @@ -38,11 +39,11 @@ public class Gameboard { case "Grün" -> color = GREEN; } return "" + - BLUE +"+---+ +---+"+ RESET +" +---+ +---+ +---+ "+ YELLOW +"+---+ +---+\n" + - BLUE +"| "+ f[60] + BLUE +" | | "+ f[61] + BLUE +" |"+ RESET +" | "+ f[18] +" | | "+ f[19] +" | | "+ f[20] +" | "+ YELLOW +"| "+ f[64] + YELLOW + " | | "+ f[65] + YELLOW +" |\n" + - BLUE +"+---+ +---+"+ RESET +" +---+ +---+ +---+ "+ YELLOW +"+---+ +---+\n" + - BLUE +"+---+ +---+"+ RESET +" +---+ "+ YELLOW +"+---+"+ RESET +" +---+ "+ YELLOW +"+---+ +---+\n" + - BLUE +"| "+ f[62] + BLUE + " | | "+ f[63] + BLUE +" |"+ RESET +" | "+ f[17] +" | "+ YELLOW +" | "+ f[48] + YELLOW +" | "+ RESET +" | "+ f[21] +" | "+ YELLOW +"| "+ f[66] + YELLOW +" | | "+ f[67] + YELLOW +" |\n" + + BLUE +"+---+ +---+"+ RESET +" +---+ +---+ +---+ "+ YELLOW +"+---+ +---+"+ RESET +" ---------\n" + + BLUE +"| "+ f[60] + BLUE +" | | "+ f[61] + BLUE +" |"+ RESET +" | "+ f[18] +" | | "+ f[19] +" | | "+ f[20] +" | "+ YELLOW +"| "+ f[64] + YELLOW + " | | "+ f[65] + YELLOW +" | "+ RESET + " | "+ d[0] +" "+ d[1] +" "+ d[2] +" |\n" + + BLUE +"+---+ +---+"+ RESET +" +---+ +---+ +---+ "+ YELLOW +"+---+ +---+"+ RESET +" | "+ d[3] +" |\n" + + BLUE +"+---+ +---+"+ RESET +" +---+ "+ YELLOW +"+---+"+ RESET +" +---+ "+ YELLOW +"+---+ +---+"+ RESET +" | "+d[4]+" "+d[5]+" "+d[6]+" |\n" + + BLUE +"| "+ f[62] + BLUE + " | | "+ f[63] + BLUE +" |"+ RESET +" | "+ f[17] +" | "+ YELLOW +" | "+ f[48] + YELLOW +" | "+ RESET +" | "+ f[21] +" | "+ YELLOW +"| "+ f[66] + YELLOW +" | | "+ f[67] + YELLOW +" | "+ RESET +" ---------\n" + BLUE +"+---+ +---+"+ RESET +" +---+ "+ YELLOW +"+---+"+ RESET +" +---+ "+ YELLOW +"+---+ +---+\n" + RESET + " +---+ "+ YELLOW +" +---+ "+ RESET +" +---+\n" + " | "+ f[16] +" | "+ YELLOW +" | "+ f[49] + YELLOW +" | "+ RESET +" | "+ f[22] +" |\n" + @@ -77,7 +78,68 @@ public class Gameboard { public static void main(String[] args) { Game g = new Game(); - System.out.println(g.gb.printBoard(g, g.players.get(0))); + System.out.println(g.gb.printBoard(g, g.players.get(0), 6)); + } + + public String[] getDice (int dice) { + String[] res = new String[7]; + switch (dice) { + case 1 -> { + res[0] = " "; + res[1] = " "; + res[2] = " "; + res[3] = "o"; + res[4] = " "; + res[5] = " "; + res[6] = " "; + } + case 2 -> { + res[0] = "o"; + res[1] = " "; + res[2] = " "; + res[3] = " "; + res[4] = " "; + res[5] = " "; + res[6] = "o"; + } + case 3 -> { + res[0] = "o"; + res[1] = " "; + res[2] = " "; + res[3] = "o"; + res[4] = " "; + res[5] = " "; + res[6] = "o"; + } + case 4 -> { + res[0] = "o"; + res[1] = " "; + res[2] = "o"; + res[3] = " "; + res[4] = "o"; + res[5] = " "; + res[6] = "o"; + } + case 5 -> { + res[0] = "o"; + res[1] = " "; + res[2] = "o"; + res[3] = "o"; + res[4] = "o"; + res[5] = " "; + res[6] = "o"; + } + case 6 -> { + res[0] = "o"; + res[1] = "o"; + res[2] = "o"; + res[3] = " "; + res[4] = "o"; + res[5] = "o"; + res[6] = "o"; + } + } + return res; } public String[] getFiguresOnBoard(Game g) {