From aef6dcf2b7afb1a27170a2c5cf0d021379353d9f Mon Sep 17 00:00:00 2001 From: Cyprien111 <105004796+Cyprien111@users.noreply.github.com> Date: Mon, 14 Apr 2025 10:21:19 +0200 Subject: [PATCH] LES COULEURS --- src/ConsoleRenderer.java | 17 +++++++++++++---- src/GomokuAI.java | 5 +++-- src/GomokuCell.java | 4 ++++ src/Human.java | 2 +- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/ConsoleRenderer.java b/src/ConsoleRenderer.java index ddb236d..f9a613f 100644 --- a/src/ConsoleRenderer.java +++ b/src/ConsoleRenderer.java @@ -14,7 +14,6 @@ public class ConsoleRenderer extends GomokuRenderer { public void update() { // Print the board to the console - //clear la console System.out.print("\033[H\033[2J"); System.out.flush(); @@ -25,7 +24,7 @@ public class ConsoleRenderer extends GomokuRenderer { // Print a separator line, followed by the game infos System.out.println(horizontalLine); - System.out.println("|" + String.format(" %-" + (width*4 - 2) + "s", "Gomoku Game!") + "|"); + System.out.println("|" + String.format(" %-" + (width*4 - 2) + "s", "Gomoku Game!") + "|"+" y"); // System.out.println("Current player: " + game.getCurrentPlayer().getName()); // System.out.println("Number of tokens left: " + game.getCurrentPlayer().getTokensLeft()); @@ -33,13 +32,23 @@ public class ConsoleRenderer extends GomokuRenderer { System.out.println(horizontalLine); for (int i = 0; i < height; i++) { System.out.print("|"); + for (int j=0; j playableCell = board.getPlayableCells(); - GomokuCell playCell; + GomokuCell playCell= null; int x = 0, y = 0; switch (difficulty) { @@ -53,6 +53,7 @@ public class GomokuAI extends Player { playCell = entry.getKey(); } } + break; default: throw new AssertionError(); } diff --git a/src/GomokuCell.java b/src/GomokuCell.java index bfe1df9..b00f055 100644 --- a/src/GomokuCell.java +++ b/src/GomokuCell.java @@ -6,6 +6,10 @@ import java.util.Map; * This class is cell of the board of the Gomoku game. */ public class GomokuCell{ + + public static final String RESET = "\u001B[0m"; + public static final String ROUGE = "\u001B[31m"; + public static final String VERT = "\u001B[32m"; /** Enumerate neighbor with key in Cardinal direction and key representing the cell in that direction. */ private EnumMap neighbour; /** The state of the cell represented by the enumerate Color, Nil is empty, white and black for the color of a token */ diff --git a/src/Human.java b/src/Human.java index 27c23ae..8d2b241 100644 --- a/src/Human.java +++ b/src/Human.java @@ -62,7 +62,7 @@ public class Human extends Player { } } while (!pass); - cell = board.get(y, x); + cell = board.get(x, y); pass = cell == null ? false : cell.isPlayable(); if (!pass) { System.out.println("Cette case n'est pas jouable !");