optimisation de Play()

This commit is contained in:
Cyprien111
2025-04-07 09:09:39 +02:00
parent d8b4e23507
commit 68c3d48f17

View File

@@ -63,22 +63,11 @@ public class GomokuGame {
/** /**
* Place the token on the cell where the player play. * Place the token on the cell where the player play.
* @param turn the turn of the player. * @param Player get player to play the cell.
*/ */
public void play(int turn) { public void play(Player player) {
GomokuCell cellToPlay = null; GomokuCell cellToPlay = player.chooseMove(board);
switch (turn) {
case 1:
cellToPlay = player1.chooseMove(board);
break;
case 2:
cellToPlay = player2.chooseMove(board);
break;
default:
throw new IllegalArgumentException("Invalid turn: " + turn);
}
cellToPlay.setState(colorP1); cellToPlay.setState(colorP1);
} }