Mock update and import optimization

This commit is contained in:
Katchan 2021-12-02 20:03:46 +01:00
parent 5201e73772
commit a354d4fb21
12 changed files with 41 additions and 27 deletions

View File

@ -1,10 +1,14 @@
package fr.lnl.game.client;
import fr.lnl.game.client.view.*;
import fr.lnl.game.server.listener.GameFinishEvent;
import fr.lnl.game.client.listener.UpdateViewEvent;
import fr.lnl.game.client.view.AbstractView;
import fr.lnl.game.client.view.Terminal;
import fr.lnl.game.client.view.ViewManager;
import fr.lnl.game.client.view.Window;
import fr.lnl.game.server.games.Game;
import fr.lnl.game.server.games.grid.Grid;
import fr.lnl.game.server.games.player.*;
import fr.lnl.game.server.listener.GameFinishEvent;
import fr.lnl.game.server.utils.CrashException;
import fr.lnl.game.server.utils.Point;
import javafx.application.Application;

View File

@ -3,7 +3,6 @@ package fr.lnl.game.client.view;
import fr.lnl.game.server.games.grid.Bomb;
import fr.lnl.game.server.games.grid.EnergyBall;
import fr.lnl.game.server.games.grid.Mine;
import fr.lnl.game.server.games.grid.Wall;
import fr.lnl.game.server.games.player.Player;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;

View File

@ -1,7 +1,7 @@
package fr.lnl.game.client.view;
import fr.lnl.game.server.listener.ModelListener;
import fr.lnl.game.client.listener.ButtonListener;
import fr.lnl.game.server.listener.ModelListener;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;

View File

@ -1,9 +1,7 @@
package fr.lnl.game.client.view;
import fr.lnl.game.server.games.Game;
import fr.lnl.game.server.games.grid.*;
import fr.lnl.game.server.games.player.AbstractPlayer;
import fr.lnl.game.server.games.player.ClassPlayer;
import fr.lnl.game.server.games.player.Player;
import fr.lnl.game.server.games.player.RandomComputerPlayer;
@ -14,7 +12,6 @@ import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.layout.Pane;
import javafx.scene.layout.StackPane;
import javafx.scene.shape.Rectangle;
import javafx.stage.Modality;
import javafx.stage.Stage;

View File

@ -3,14 +3,11 @@ package fr.lnl.game.client.view;
import fr.lnl.game.client.listener.ButtonListener;
import fr.lnl.game.server.games.Game;
import fr.lnl.game.server.games.player.Player;
import javafx.concurrent.ScheduledService;
import javafx.concurrent.Task;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;
import javafx.util.Duration;
public class Window extends AbstractView {

View File

@ -8,7 +8,6 @@ import fr.lnl.game.server.games.player.Player;
import fr.lnl.game.server.listener.AwakeGame;
import fr.lnl.game.server.listener.ModelListener;
import fr.lnl.game.server.utils.CrashException;
import fr.lnl.game.server.utils.Point;
import java.util.ArrayList;
import java.util.Arrays;

View File

@ -3,9 +3,6 @@ package fr.lnl.game.server.games.action;
import fr.lnl.game.server.games.Game;
import fr.lnl.game.server.games.grid.Mine;
import fr.lnl.game.server.games.player.Player;
import fr.lnl.game.server.utils.Point;
import java.util.List;
public class DropMine extends DropObject {

View File

@ -1,6 +1,5 @@
package fr.lnl.game.server.games.grid;
import fr.lnl.game.server.games.player.AbstractPlayer;
import fr.lnl.game.server.games.player.Player;
import fr.lnl.game.server.utils.Cardinal;
import fr.lnl.game.server.utils.Pair;

View File

@ -1,6 +1,5 @@
package fr.lnl.game.server.games.player;
import fr.lnl.game.server.games.action.Action;
import fr.lnl.game.server.utils.Point;
public class HumanPlayer extends AbstractPlayer {

View File

@ -1,7 +1,5 @@
package fr.lnl.game.server.listener;
import fr.lnl.game.server.listener.AbstractModelListening;
public class GameFinishEvent extends AbstractModelListening {
private final Object lock = new Object();

View File

@ -1,20 +1,17 @@
package fr.lnl.game.server;
import fr.lnl.game.server.games.Game;
import fr.lnl.game.server.games.action.*;
import fr.lnl.game.server.games.grid.Box;
import fr.lnl.game.server.games.grid.EnergyBall;
import fr.lnl.game.server.games.grid.Grid;
import fr.lnl.game.server.games.grid.Wall;
import fr.lnl.game.server.games.player.Player;
import fr.lnl.game.server.utils.Cardinal;
import fr.lnl.game.server.utils.Pair;
import fr.lnl.game.server.utils.Point;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Random;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class GridTest {
@ -44,4 +41,35 @@ public class GridTest {
assertEquals(new EnergyBall(), grid.getBoard().get(new Point(8, 10)).getB());
}
@Test
public void testLock() {
System.out.println("=================== GRID COMPLETE ====================");
System.out.println(grid.toString());
System.out.println("=================== GRID AVEC LOCK ===================");
StringBuilder str = new StringBuilder();
for (int i = 0; i < grid.getRow(); i++) {
str.append("\n");
for (int j = 0; j < grid.getColumn(); j++) {
Pair<Player, Box> value = grid.getBoard().get(new Point(i, j));
if(value.getB() != null){
if(value.getB().isLock()){
str.append(" \033[0;35mL\033[0m");
}
if(value.getB() instanceof Wall){
str.append(" \033[0;32mW\033[0m");
}
if(value.getB() instanceof EnergyBall){
str.append(" \033[0;31mE\033[0m");
}
}
else if(value.getA() != null){
str.append(" \033[0;34mP\033[0m");
}
else {
str.append(" \033[0;37m.\033[0m");
}
}
}
System.out.println(str);
}
}

View File

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