From 6f7e2cfe59a48d4b6687b1f24b1983ecf0b67a8b Mon Sep 17 00:00:00 2001 From: FelixKrull Date: Tue, 15 Feb 2022 10:37:48 +0100 Subject: [PATCH] Edit Board String and add player --- src/main/java/Gameboard.java | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/src/main/java/Gameboard.java b/src/main/java/Gameboard.java index 429d0f7..4f571f1 100644 --- a/src/main/java/Gameboard.java +++ b/src/main/java/Gameboard.java @@ -28,47 +28,56 @@ public class Gameboard { } - public String printBoard(Game g) { + public String printBoard(Game g, Player p) { String[] f = getFiguresOnBoard(g); + String color = ""; + switch (p.name) { + case "Rot" -> color = RED; + case "Blau" -> color = BLUE; + case "Gelb" -> color = YELLOW; + 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] +" | | "+ f[65] +" |\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] +" | | "+ f[63] +" |"+ RESET +" | "+ f[17] +" | "+ YELLOW +" | "+ f[48] +" | "+ RESET +" | "+ f[21] +" | "+ YELLOW +"| "+ f[66] +" | | "+ f[67] +" |\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 +" +---+ "+ YELLOW +"+---+ +---+\n" + RESET + " +---+ "+ YELLOW +" +---+ "+ RESET +" +---+\n" + - " | "+ f[16] +" | "+ YELLOW +" | "+ f[49] +" | "+ RESET +" | "+ f[22] +" |\n" + + " | "+ f[16] +" | "+ YELLOW +" | "+ f[49] + YELLOW +" | "+ RESET +" | "+ f[22] +" |\n" + " +---+ "+ YELLOW +" +---+ "+ RESET +" +---+\n" + " +---+ "+ YELLOW +" +---+ "+ RESET +" +---+\n" + - " | "+ f[15] +" | "+ YELLOW +" | "+ f[50] +" | "+ RESET +" | "+ f[23] +" |\n" + + " | "+ f[15] +" | "+ YELLOW +" | "+ f[50] + YELLOW +" | "+ RESET +" | "+ f[23] +" |\n" + " +---+ "+ YELLOW +" +---+ "+ RESET +" +---+\n" + "+---+ +---+ +---+ +---+ +---+ "+ YELLOW +" +---+ "+ RESET +" +---+ +---+ +---+ +---+ +---+ \n" + "| "+ f[10] +" | | "+ f[11] +" | | "+ f[12] +" | | "+ f[13] +" | | "+ f[14] +" | "+ YELLOW +" | "+ f[51] +" | "+ RESET +" | "+ f[24] +" | | "+ f[25] +" | | "+ f[26] +" | | "+ f[27] +" | | "+ f[28] +" | \n" + "+---+ +---+ +---+ +---+ +---+ "+ YELLOW +" +---+ "+ RESET +" +---+ +---+ +---+ +---+ +---+ \n" + "+---+ "+ BLUE +" +---+ +---+ +---+ +---+ "+ GREEN +"+---+ +---+ +---+ +---+ "+ RESET +" +---+ \n" + - "| "+ f[9] +" | "+ BLUE +" | "+ f[44] +" | | "+ f[45] +" | | "+ f[46] +" | | "+ f[47] +" | "+ GREEN +" | "+ f[55] +" | | "+ f[54] +" | | "+ f[53] +" | | "+ f[52] +" | "+ RESET +" | "+ f[29] +" | \n" + + "| "+ f[9] +" | "+ BLUE +" | "+ f[44] + BLUE +" | | "+ f[45] + BLUE + " | | "+ f[46] + BLUE + " | | "+ f[47] + BLUE +" | "+ GREEN +" | "+ f[55] + GREEN + " | | "+ f[54] + GREEN +" | | "+ f[53] + GREEN +" | | "+ f[52] + GREEN +" | "+ RESET +" | "+ f[29] +" | \n" + "+---+ "+ BLUE +" +---+ +---+ +---+ +---+ "+ GREEN +"+---+ +---+ +---+ +---+ "+ RESET +" +---+ \n" + "+---+ +---+ +---+ +---+ +---+ "+ RED +" +---+ "+ RESET +" +---+ +---+ +---+ +---+ +---+ \n" + - "| "+ f[8] +" | | "+ f[7] +" | | "+ f[6] +" | | "+ f[5] +" | | "+ f[4] +" | "+ RED +" | "+ f[43] +" | "+ RESET +" | "+ f[34] +" | | "+ f[33] +" | | "+ f[32] +" | | "+ f[31] +" | | "+ f[30] +" | \n" + + "| "+ f[8] +" | | "+ f[7] +" | | "+ f[6] +" | | "+ f[5] +" | | "+ f[4] +" | "+ RED +" | "+ f[43] + RED +" | "+ RESET +" | "+ f[34] +" | | "+ f[33] +" | | "+ f[32] +" | | "+ f[31] +" | | "+ f[30] +" | \n" + "+---+ +---+ +---+ +---+ +---+ "+ RED +" +---+ "+ RESET +" +---+ +---+ +---+ +---+ +---+ \n" + " +---+ "+ RED +" +---+ "+ RESET +" +---+\n" + - " | "+ f[3] +" | "+ RED +" | "+ f[42] +" | "+ RESET +" | "+ f[35] +" |\n" + + " | "+ f[3] +" | "+ RED +" | "+ f[42] + RED +" | "+ RESET +" | "+ f[35] +" |\n" + " +---+ "+ RED +" +---+ "+ RESET +" +---+\n" + " +---+ "+ RED +" +---+ "+ RESET +" +---+\n" + - " | "+ f[2] +" | "+ RED +" | "+ f[41] +" | "+ RESET +" | "+ f[36] +" |\n" + + " | "+ f[2] +" | "+ RED +" | "+ f[41] + RED +" | "+ RESET +" | "+ f[36] +" |\n" + " +---+ "+ RED +" +---+ "+ RESET +" +---+\n" + RED +"+---+ +---+"+ RESET +" +---+ "+ RED +" +---+ "+ RESET +" +---+ "+ GREEN +"+---+ +---+\n" + - RED +"| "+ f[56] +" | | "+ f[57] +" |"+ RESET +" | "+ f[1] +" | "+ RED +" | "+ f[40] +" | "+ RESET +" | "+ f[37] +" | "+ GREEN +"| "+ f[68] +" | | "+ f[69] +" |\n" + + RED +"| "+ f[56] + RED +" | | "+ f[57] + RED +" |"+ RESET +" | "+ f[1] +" | "+ RED +" | "+ f[40] + RED +" | "+ RESET +" | "+ f[37] +" | "+ GREEN +"| "+ f[68] + GREEN +" | | "+ f[69] + GREEN +" |\n" + RED +"+---+ +---+"+ RESET +" +---+ "+ RED +" +---+ "+ RESET +" +---+ "+ GREEN +"+---+ +---+\n" + RED +"+---+ +---+"+ RESET +" +---+ +---+ +---+ "+ GREEN +"+---+ +---+\n" + - RED +"| "+ f[58] +" | | "+ f[59] +" |"+ RESET +" | "+ f[0] +" | | "+ f[39] +" | | "+ f[38] +" | "+ GREEN +"| "+ f[70] +" | | "+ f[71] +" |\n" + - RED +"+---+ +---+"+ RESET +" +---+ +---+ +---+ "+ GREEN +"+---+ +---+\n" + RESET; + RED +"| "+ f[58] + RED +" | | "+ f[59] + RED +" |"+ RESET +" | "+ f[0] +" | | "+ f[39] +" | | "+ f[38] +" | "+ GREEN +"| "+ f[70] + GREEN +" | | "+ f[71] + GREEN +" |\n" + + RED +"+---+ +---+"+ RESET +" +---+ +---+ +---+ "+ GREEN +"+---+ +---+\n" + RESET + + "===========================================================================\n" + + "Spieler " + color + p.name + RESET + " ist an der Reihe"; } public static void main(String[] args) { Game g = new Game(); - System.out.println(g.gb.printBoard(g)); + System.out.println(g.gb.printBoard(g, g.players.get(0))); } public String[] getFiguresOnBoard(Game g) {