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 d5d8e7f..23ccd9f 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 @@ -17,6 +17,7 @@ import javafx.scene.shape.Rectangle; 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 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"); @@ -36,7 +37,12 @@ public class Cell extends Rectangle { StackPane sp = new StackPane(); Image in; if(object instanceof Player){ - in = PLAYER_IMAGE; + if(((Player) object).isShieldDeploy()){ + in = PLAYER_SHIELD_IMAGE; + } + else{ + in = PLAYER_IMAGE; + } } else if(object instanceof EnergyBall){ in = ENERGY_BALL_IMAGE; } else if(object instanceof Bomb){ 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 1138bd9..0162831 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,12 +24,12 @@ public class Terminal extends AbstractView { @Override public void displayWinner(Player winner) { - System.out.println("Le joueur " + winner + " a gagné la partie"); + System.out.println(winner + " " + winner.getId() + " a gagné la partie"); } @Override public Action choseAction() { - List actions = generateAvailableActions(); + List actions = player.generateAvailableActions(); List listActions = choseReunionSameAction(actions).getActions(); Action action = null; String error = "Veuillez renseigner une valeur numérique comprise entre 1 et " + listActions.size(); 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 0280a77..6e89f8c 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 @@ -27,7 +27,7 @@ public record ViewManager( } 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()); + System.out.println("Il a joué l'action: " + game.getSelectedAction().getClass().getSimpleName()); 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 0815b0f..059433a 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 @@ -62,7 +62,7 @@ public class Window extends AbstractView { @Override public Action choseAction() { - List actions = generateAvailableActions(); + List actions = player.generateAvailableActions(); List listActions = choseReunionSameAction(actions).getActions(); Action action = null; do { @@ -125,7 +125,7 @@ public class Window extends AbstractView { public void putStatePlayerPane(Pane principalPane){ int Y = 0; for(int i=0;i getPlayers() { return players; } diff --git a/server/src/main/java/fr/lnl/game/server/games/player/RandomComputerPlayer.java b/server/src/main/java/fr/lnl/game/server/games/player/RandomComputerPlayer.java index f735b49..35ee9fa 100644 --- a/server/src/main/java/fr/lnl/game/server/games/player/RandomComputerPlayer.java +++ b/server/src/main/java/fr/lnl/game/server/games/player/RandomComputerPlayer.java @@ -1,7 +1,9 @@ package fr.lnl.game.server.games.player; +import fr.lnl.game.server.games.Game; import fr.lnl.game.server.games.action.Action; import fr.lnl.game.server.games.action.Nothing; +import fr.lnl.game.server.games.grid.Grid; import fr.lnl.game.server.utils.Point; import java.util.Random; @@ -13,18 +15,17 @@ public class RandomComputerPlayer extends ComputerPlayer { } @Override - public Action choseAction() { + public Action strategy(Game game) { Action action = null; - switch (getActions().size()){ - case 0 -> action = new Nothing(); - case 1 -> action = getActions().get(0); - default -> { - Random random = new Random(); - while (action == null || !action.isPossible()) { - action = getActions().get(random.nextInt(0,getActions().size())); - } - } + Random random = new Random(); + while (action == null || !action.isPossible()) { + action = getActions().get(random.nextInt(0, getActions().size())); } return action; } + + @Override + public String toString() { + return "Random"; + } }