Improve display of classes in the view, add player shield icon
This commit is contained in:
parent
2e99366e56
commit
4c52bedc9f
@ -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){
|
||||
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){
|
||||
|
@ -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<ReunionSameAction> actions = generateAvailableActions();
|
||||
List<ReunionSameAction> actions = player.generateAvailableActions();
|
||||
List<Action> listActions = choseReunionSameAction(actions).getActions();
|
||||
Action action = null;
|
||||
String error = "Veuillez renseigner une valeur numérique comprise entre 1 et " + listActions.size();
|
||||
|
@ -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);
|
||||
|
@ -62,7 +62,7 @@ public class Window extends AbstractView {
|
||||
|
||||
@Override
|
||||
public Action choseAction() {
|
||||
List<ReunionSameAction> actions = generateAvailableActions();
|
||||
List<ReunionSameAction> actions = player.generateAvailableActions();
|
||||
List<Action> 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<game.getPlayers().size();i++){
|
||||
StackPane sp = showStatePlayer(i);
|
||||
StackPane sp = showStatePlayer(game.getPlayers().get(i).toString(),i);
|
||||
sp.setLayoutX(480);
|
||||
sp.setLayoutY(Y);
|
||||
Y+=90;
|
||||
@ -133,9 +133,9 @@ public class Window extends AbstractView {
|
||||
}
|
||||
}
|
||||
|
||||
public StackPane showStatePlayer(int playerNumber){
|
||||
public StackPane showStatePlayer(String type, int playerNumber){
|
||||
StackPane subSp = new StackPane();
|
||||
String s = "Joueur " + (playerNumber+1) + "\n" +
|
||||
String s = type + " " + (playerNumber+1) + "\n" +
|
||||
"Energie : " + game.getPlayers().get(playerNumber).getEnergy() + "\n" +
|
||||
"Arme : " + game.getPlayers().get(playerNumber).getWeapon().getClass().getSimpleName() + "\n";
|
||||
Text t = new Text(s);
|
||||
@ -161,8 +161,9 @@ public class Window extends AbstractView {
|
||||
|
||||
public StackPane showMoveText(){
|
||||
StackPane subSp = new StackPane();
|
||||
String s = "Joueur : " + (player.getId()+1) + "\n" +
|
||||
"Vient de jouer : " + game.getSelectedAction() + "\n";
|
||||
String action = game.getSelectedAction() == null ? "null" : game.getSelectedAction().getClass().getSimpleName();
|
||||
String s = player + " : " + (player.getId()+1) + "\n" +
|
||||
"Vient de jouer : " + action + "\n";
|
||||
Text t = new Text(s);
|
||||
Rectangle r = new Rectangle();
|
||||
r.setWidth(478);
|
||||
|
BIN
client/src/main/resources/player_shield.png
Normal file
BIN
client/src/main/resources/player_shield.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 7.6 KiB |
@ -1,7 +1,6 @@
|
||||
package fr.lnl.game.server.games.action;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -90,7 +90,7 @@ public class Grid {
|
||||
str.append(" \033[0;34m").append(value.getA().getId()).append("\033[0m");
|
||||
}
|
||||
else if (value.getB() instanceof Wall) {
|
||||
str.append(" \033[0;32m□\033[0m");
|
||||
str.append(" \033[0;32m#\033[0m");
|
||||
}
|
||||
else if(value.getB() instanceof EnergyBall){
|
||||
str.append(" \033[0;31mE\033[0m");
|
||||
@ -119,7 +119,7 @@ public class Grid {
|
||||
str.append(" \033[0;34m").append(value.getA().getId()).append("\033[0m");
|
||||
}
|
||||
else if (value.getB() instanceof Wall) {
|
||||
str.append(" \033[0;32m□\033[0m");
|
||||
str.append(" \033[0;32m#\033[0m");
|
||||
}
|
||||
else if(value.getB() instanceof EnergyBall){
|
||||
str.append(" \033[0;31mE\033[0m");
|
||||
@ -149,6 +149,14 @@ public class Grid {
|
||||
return board;
|
||||
}
|
||||
|
||||
public Player getGridPlayer(Point point){
|
||||
return getBoard().get(point).getA();
|
||||
}
|
||||
|
||||
public Box getGridBox(Point point){
|
||||
return getBoard().get(point).getB();
|
||||
}
|
||||
|
||||
public List<Player> getPlayers() {
|
||||
return players;
|
||||
}
|
||||
|
@ -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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
return action;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Random";
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user