From dab710597badbd14eacb12ac2c475c022602f152 Mon Sep 17 00:00:00 2001 From: Katchan <35238981+KatchanNve@users.noreply.github.com> Date: Wed, 8 Dec 2021 21:47:34 +0100 Subject: [PATCH] Improve display in terminal view and add Shot icon in Window view --- .../main/java/fr/lnl/game/client/view/Cell.java | 10 ++++++++-- .../java/fr/lnl/game/client/view/Terminal.java | 4 +++- .../fr/lnl/game/client/view/ViewManager.java | 6 ++++-- .../java/fr/lnl/game/client/view/Window.java | 2 +- client/src/main/resources/player_shot.png | Bin 0 -> 8078 bytes .../main/java/fr/lnl/game/server/games/Game.java | 7 +++++++ 6 files changed, 23 insertions(+), 6 deletions(-) create mode 100644 client/src/main/resources/player_shot.png 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 0000000000000000000000000000000000000000..975d15d1483f3727766604813eca51a4357d5812 GIT binary patch literal 8078 zcmZX2WmFtZ*X;lyxP$<~WpIKF?(Xgm!5s#NK?VpA0t9ymE>@03f&v01%GFt;((d z0O*dk5)!I%5)u@uu1;3A4we9bZufT`FI|lR{A`2x*w}G+WLcCSD8ErCXhQHsecm{P zP{*p8DIzmo*A%ZUNWF5{D-AOi1V_=2?*#7f6?sp6hNB zc@*5Cyowp`-hPj_whI5ri`~5(q>PW}98bX=2>B?ApI-cXo+2|gr{>d)wcI>Y5{yY_ z!AZyTPrD#bTH!_jGp@5HELA!V#DHgp+N1p`FOeXOi^4N`n^wBST^bi*l7`ixenkv!H>M;k{<;jtS81a zWOd2#WD?g0jsRlmkb#;HSbB*NbGfbxXEAxLZf z5YD#OUB{suF4-S>+xOpQVJ{$Kq0Ay5g&1r~xfO_b^WoG3tVA>X+&feZ&z45!@)bz1<$1YDMjtN|RY*X(R>voHk ziu-eNk$=hM23kGrO3OZ~?HCd!k5&`0H$$s}&JiB+dSVKMZ~;@bD?OcPivtMtYoRITY&y~1uQ~#HkL80{B9)J`%d2n@?FVV(_cTpMZa z5H8D5zc_I{0u8R6hI3txSHC-XQ!Oc%cGW>BiU_r0 zZ1jiwG#B(UuL9d;WNsx-V5S>vB5xmxp_W`V;JP;(GH?JruIYXiefL38# z8(~e9iqrrUsl2#X)EEPzHE-B}GT$iO;?ynp)IT~%+Qka}g4^PC#k7?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Q7boOw`qQjlUSod>%0qYG*ojxn3ANvVE~mwb0S)jjE<8 zM&ssOal#nI)G=18ty6rNjCg|3+^mzcgV1td9vs{KJaPC1#yV+!e?)=_AM^L;lbn>Y KWQDj%(Ek9&VodD- literal 0 HcmV?d00001 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