Conflict resolution

This commit is contained in:
Katchan 2021-12-02 20:11:23 +01:00
parent e862e79a62
commit 7afd79b929
4 changed files with 5 additions and 16 deletions

View File

@ -38,7 +38,7 @@ public class App extends Application {
public static void startGame(ViewLambda lambda) throws IllegalArgumentException, InvocationTargetException, NoSuchMethodException, public static void startGame(ViewLambda lambda) throws IllegalArgumentException, InvocationTargetException, NoSuchMethodException,
InstantiationException, IllegalAccessException { InstantiationException, IllegalAccessException {
List<Player> players = parsePlayers(); List<Player> players = parsePlayers();
game = new Game(new Grid(12, 12, players), players, new GameFinishEvent()); game = new Game(new Grid(12, 12, players, 0.80F,0.95F), players, new GameFinishEvent());
for (Player player : game.getPlayers()) { for (Player player : game.getPlayers()) {
playerList.put(player, new ClientPlayer(player, lambda.createViewLambda(player))); playerList.put(player, new ClientPlayer(player, lambda.createViewLambda(player)));
} }

View File

@ -12,6 +12,7 @@ import javafx.scene.Scene;
import javafx.scene.control.Button; import javafx.scene.control.Button;
import javafx.scene.layout.Pane; import javafx.scene.layout.Pane;
import javafx.scene.layout.StackPane; import javafx.scene.layout.StackPane;
import javafx.scene.shape.Rectangle;
import javafx.stage.Modality; import javafx.stage.Modality;
import javafx.stage.Stage; import javafx.stage.Stage;
@ -105,7 +106,7 @@ public class GUI {
private Grid getGrid() { private Grid getGrid() {
List<Player> players = Arrays.asList(new RandomComputerPlayer(1, null, ClassPlayer.DEFAULT), List<Player> players = Arrays.asList(new RandomComputerPlayer(1, null, ClassPlayer.DEFAULT),
new RandomComputerPlayer(2, null, ClassPlayer.DEFAULT)); new RandomComputerPlayer(2, null, ClassPlayer.DEFAULT));
Grid grid = new Grid(16, 16, players); Grid grid = new Grid(16, 16, players, 0.80F, 0.95F);
//grid.placePlayersBRUT(); //grid.placePlayersBRUT();
return grid; return grid;
} }

View File

@ -23,27 +23,15 @@ public class Game {
private Action selectedAction = null; private Action selectedAction = null;
public Game(Grid grid, List<Player> players, ModelListener gameFinishEvent) throws IllegalArgumentException { public Game(Grid grid, List<Player> players, ModelListener gameFinishEvent) throws IllegalArgumentException {
if(players.size() < 2) if(players.size() < 2 || players.size() > grid.getNumberNeutralBox())
throw new IllegalArgumentException("The game need 2 or more player to start"); throw new IllegalArgumentException("The game need 2 or more player to start");
this.players = players; this.players = players;
this.currentPlayer = players.get(0); this.currentPlayer = players.get(0);
this.grid = grid; this.grid = grid;
this.gameFinishEvent = gameFinishEvent; this.gameFinishEvent = gameFinishEvent;
placePlayersBRUT();
currentPlayer.setActions(generateAndGetPlayerActions(currentPlayer)); currentPlayer.setActions(generateAndGetPlayerActions(currentPlayer));
} }
/**
* @deprecated utiliser pour le moment, nécessite une meilleure implémentation pour savoir ou placé les joueurs
*/
@Deprecated
public void placePlayersBRUT(){
grid.getBoard().get(new Point(7,7)).setA(grid.getPlayers().get(0));
grid.getPlayers().get(0).setPosition(new Point(7, 7));
grid.getBoard().get(new Point(7,8)).setA(grid.getPlayers().get(1));
grid.getPlayers().get(1).setPosition(new Point(7, 8));
}
public void play() { public void play() {
if (currentPlayer instanceof ComputerPlayer player) { if (currentPlayer instanceof ComputerPlayer player) {
selectedAction = player.choseAction(); selectedAction = player.choseAction();

View File

@ -22,7 +22,7 @@ public class Mock {
public Mock() { public Mock() {
List<Player> players = Arrays.asList(new RandomComputerPlayer(1,null, ClassPlayer.DEFAULT), List<Player> players = Arrays.asList(new RandomComputerPlayer(1,null, ClassPlayer.DEFAULT),
new RandomComputerPlayer(2,null, ClassPlayer.DEFAULT)); new RandomComputerPlayer(2,null, ClassPlayer.DEFAULT));
this.grid = new Grid(16,16, players); this.grid = new Grid(16,16, players,0.80F, 0.95F);
placePlayersBRUT(); placePlayersBRUT();
placeEnergyBallBRUT(); placeEnergyBallBRUT();
placeInternWallBRUT(); placeInternWallBRUT();