startplay with update render

This commit is contained in:
Aubin DORIVAL
2025-04-07 10:17:46 +02:00
parent 23dec92e66
commit a7214f796f

View File

@@ -24,7 +24,6 @@ public class GomokuGame {
Color colorP1;
int currentPlayerInt;
int nbTokens1, nbTokens2;
Coordinate cellCoor = null;
@@ -58,8 +57,7 @@ public class GomokuGame {
this.colorP1 = colorPlayer1;
currentPlayer = this.player1.color == Color.WHITE ? this.player1: this.player2;
this.currentPlayerInt = this.player1.color == Color.WHITE ? 1 : 2;
this.nbTokens1 = 60;
this.nbTokens2 = 60;
this.renderer = new SwingRenderer();
}
@@ -71,21 +69,21 @@ public class GomokuGame {
System.out.println("c'est gangée !");
}
*/
while(this.nbTokens1 > 0 && this.nbTokens2 > 0){
while(this.player1.tokens > 0 || this.player2.tokens > 0){
GomokuCell currentPlay = null;
while (currentPlay == null) {
currentPlay = this.play(this.currentPlayer);
}
if( NB_CELL_PLAY <= board.countMax(board.countAlignedCells(currentPlay)))
{
this.renderer.updateStatus("Le joueur " + this.currentPlayer + "a gagné !");
return;
}
this.currentPlayer = this.nextPlayer();
}
GomokuCell currentPlay = null;
while (currentPlay == null) {
currentPlay = this.play(this.currentPlayer);
}
this.currentPlayer = this.nextPlayer();
if( NB_CELL_PLAY <= board.countMax(board.countAlignedCells(currentPlay)))
{
System.out.println("c'est gangée !");
return;
}
this.renderer.updateStatus("Match nul, il ne reste plus de jeton.");
return;
}
/**
@@ -142,8 +140,8 @@ public class GomokuGame {
this.getBoard().getHeight(),
colorP1,
currentPlayerInt,
nbTokens1,
nbTokens2
this.player1.tokens,
this.player2.tokens
));
// Write the board
@@ -205,8 +203,8 @@ public class GomokuGame {
h = Integer.parseInt(parts[1]);
colorP1 = Color.valueOf(parts[2]);
currentPlayerInt = Integer.parseInt(parts[3]);
nbTokens1 = Integer.parseInt(parts[4]);
nbTokens2 = Integer.parseInt(parts[5]);
this.player1.tokens = Integer.parseInt(parts[4]);
this.player2.tokens = Integer.parseInt(parts[5]);
if (w <= 0 || h <= 0) {
throw new IllegalArgumentException("Invalid board dimensions");