diff --git a/client/src/main/java/fr/lnl/game/client/view/Cell.java b/client/src/main/java/fr/lnl/game/client/view/Cell.java index 23ccd9f..2c27805 100644 --- a/client/src/main/java/fr/lnl/game/client/view/Cell.java +++ b/client/src/main/java/fr/lnl/game/client/view/Cell.java @@ -1,5 +1,7 @@ package fr.lnl.game.client.view; +import fr.lnl.game.server.games.Game; +import fr.lnl.game.server.games.action.Shot; import fr.lnl.game.server.games.grid.elements.Bomb; import fr.lnl.game.server.games.grid.elements.EnergyBall; import fr.lnl.game.server.games.grid.elements.Mine; @@ -18,6 +20,7 @@ public class Cell extends Rectangle { private static final Image PLAYER_IMAGE = new Image("player.png"); private static final Image PLAYER_SHIELD_IMAGE = new Image("player_shield.png"); + private static final Image PLAYER_SHOT_IMAGE = new Image("player_shot.png"); private static final Image ENERGY_BALL_IMAGE = new Image("energyBall.png"); private static final Image BOMB_IMAGE = new Image("bomb.png"); private static final Image MINE_IMAGE = new Image("mine.png"); @@ -33,11 +36,14 @@ public class Cell extends Rectangle { - public static StackPane setImageObject(Object object){ + public static StackPane setImageObject(Object object, Game game){ StackPane sp = new StackPane(); Image in; if(object instanceof Player){ - if(((Player) object).isShieldDeploy()){ + if(object.equals(game.getCurrentPlayer()) && game.getSelectedAction() instanceof Shot){ + in = PLAYER_SHOT_IMAGE; + } + else if(((Player) object).isShieldDeploy()){ in = PLAYER_SHIELD_IMAGE; } else{ diff --git a/client/src/main/java/fr/lnl/game/client/view/Terminal.java b/client/src/main/java/fr/lnl/game/client/view/Terminal.java index 0162831..816d87c 100644 --- a/client/src/main/java/fr/lnl/game/client/view/Terminal.java +++ b/client/src/main/java/fr/lnl/game/client/view/Terminal.java @@ -24,7 +24,9 @@ public class Terminal extends AbstractView { @Override public void displayWinner(Player winner) { - System.out.println(winner + " " + winner.getId() + " a gagné la partie"); + System.out.println("\n\033[0;31m====== FIN DU JEU ======\033[0m"); + System.out.println(game.getGrid().toString()); + System.out.println("\n\033[0;33mVictoire de " + winner + " " + winner.getId() + "\033[0m"); } @Override diff --git a/client/src/main/java/fr/lnl/game/client/view/ViewManager.java b/client/src/main/java/fr/lnl/game/client/view/ViewManager.java index 6e89f8c..126fe5a 100644 --- a/client/src/main/java/fr/lnl/game/client/view/ViewManager.java +++ b/client/src/main/java/fr/lnl/game/client/view/ViewManager.java @@ -21,13 +21,15 @@ public record ViewManager( DisplayWinnerEvent displayWinnerEvent = new DisplayWinnerEvent(); while (true) { Player player = game.getCurrentPlayer(); + System.out.println("\n\033[0;34m====== Tour n°" + game.getNbrTurn() + " =======\033[0m"); + System.out.println("\nA \033[0;31m" + player + " " + player.getId() + "\033[0m de jouer"); players.get(game.getCurrentPlayer()).getView().show(); if(game.getCurrentPlayer() instanceof HumanPlayer human) { game.setSelectedAction(players.get(human).getView().choseAction()); } boolean isOver = game.play(); - System.out.println("Le joueur ordinateur numéro " + player.getId() + " a joué"); - System.out.println("Il a joué l'action: " + game.getSelectedAction().getClass().getSimpleName()); + System.out.println("\n\033[0;31m" + player + " " + player.getId() + "\033[0m utilise l'action \033[0;36m"+ + game.getSelectedAction().getClass().getSimpleName() + "\033[0m"); if (isOver) { displayWinnerEvent.updateModel(game.getWinner()); System.exit(0); diff --git a/client/src/main/java/fr/lnl/game/client/view/Window.java b/client/src/main/java/fr/lnl/game/client/view/Window.java index 059433a..00ce2e2 100644 --- a/client/src/main/java/fr/lnl/game/client/view/Window.java +++ b/client/src/main/java/fr/lnl/game/client/view/Window.java @@ -113,7 +113,7 @@ public class Window extends AbstractView { } public void addToPrincipalPanel(Object object, Pane principalPane, int i, int j) { - StackPane sp = Cell.setImageObject(object); + StackPane sp = Cell.setImageObject(object, game); sp.setLayoutY(i * cellSize); sp.setLayoutX(j * cellSize); principalPane.getChildren().add(sp); diff --git a/client/src/main/resources/player_shot.png b/client/src/main/resources/player_shot.png new file mode 100644 index 0000000..975d15d Binary files /dev/null and b/client/src/main/resources/player_shot.png differ diff --git a/server/src/main/java/fr/lnl/game/server/games/Game.java b/server/src/main/java/fr/lnl/game/server/games/Game.java index cfaba42..fed49bf 100644 --- a/server/src/main/java/fr/lnl/game/server/games/Game.java +++ b/server/src/main/java/fr/lnl/game/server/games/Game.java @@ -21,6 +21,7 @@ public class Game { private final List players; private Player currentPlayer; private Action selectedAction = null; + private int nbrTurn; public Game(GridFactoryBuilder buildStrategy, List players) throws IllegalArgumentException { this.grid = buildStrategy.build(); @@ -32,6 +33,7 @@ public class Game { this.buildStrategy = buildStrategy; this.players = players; this.currentPlayer = players.get(0); + this.nbrTurn = 1; initGame(); } @@ -53,6 +55,7 @@ public class Game { gridPlayersUpdate(); nextCurrentPlayer(); currentPlayer.setActions(generateAndGetPlayerActions(currentPlayer)); + nbrTurn++; return isOver(); } @@ -140,4 +143,8 @@ public class Game { public void setSelectedAction(Action selectedAction) { this.selectedAction = selectedAction; } + + public int getNbrTurn() { + return nbrTurn; + } } \ No newline at end of file