Added 1 test
This commit is contained in:
parent
cb4c020fe6
commit
8ca2326c89
@ -6,7 +6,6 @@ import fr.lnl.game.server.games.grid.Mine;
|
|||||||
import fr.lnl.game.server.games.grid.Wall;
|
import fr.lnl.game.server.games.grid.Wall;
|
||||||
import fr.lnl.game.server.games.player.Player;
|
import fr.lnl.game.server.games.player.Player;
|
||||||
import javafx.scene.image.Image;
|
import javafx.scene.image.Image;
|
||||||
import javafx.scene.image.ImageView;
|
|
||||||
import javafx.scene.layout.StackPane;
|
import javafx.scene.layout.StackPane;
|
||||||
import javafx.scene.paint.Color;
|
import javafx.scene.paint.Color;
|
||||||
import javafx.scene.shape.Rectangle;
|
import javafx.scene.shape.Rectangle;
|
||||||
|
@ -28,6 +28,7 @@ public class Game {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Player getWinner() {
|
public Player getWinner() {
|
||||||
|
// On part du principe que isOver est forcément appelé avant d'appeler getWinner
|
||||||
return players.parallelStream().filter(player -> !player.isAlive()).findFirst().orElseThrow(ArrayIndexOutOfBoundsException::new);
|
return players.parallelStream().filter(player -> !player.isAlive()).findFirst().orElseThrow(ArrayIndexOutOfBoundsException::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,6 +48,7 @@ public class Game {
|
|||||||
index = 0;
|
index = 0;
|
||||||
currentPlayer = players.get(index);
|
currentPlayer = players.get(index);
|
||||||
} while(!currentPlayer.isAlive()); // On arrête la boucle dès qu'on trouve un joueur en vie
|
} while(!currentPlayer.isAlive()); // On arrête la boucle dès qu'on trouve un joueur en vie
|
||||||
|
currentPlayer.setShieldDeploy(false); // on reset son état
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,10 @@ public class DropBomb extends DropObject {
|
|||||||
super(game, player);
|
super(game, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated même principe que {@link Shot#doAction()}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
public void doAction() {
|
public void doAction() {
|
||||||
List<Point> points = getValidPoint();
|
List<Point> points = getValidPoint();
|
||||||
|
@ -12,6 +12,11 @@ public class DropMine extends DropObject {
|
|||||||
public DropMine(Game game, Player player){
|
public DropMine(Game game, Player player){
|
||||||
super(game, player);
|
super(game, player);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated même principe que {@link Shot#doAction()}
|
||||||
|
*/
|
||||||
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
public void doAction() {
|
public void doAction() {
|
||||||
List<Point> points = getValidPoint();
|
List<Point> points = getValidPoint();
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package fr.lnl.game.server.games.action;
|
package fr.lnl.game.server.games.action;
|
||||||
|
|
||||||
import fr.lnl.game.server.games.Game;
|
import fr.lnl.game.server.games.Game;
|
||||||
import fr.lnl.game.server.games.grid.*;
|
import fr.lnl.game.server.games.grid.Box;
|
||||||
|
import fr.lnl.game.server.games.grid.InteractiveBox;
|
||||||
|
import fr.lnl.game.server.games.grid.Wall;
|
||||||
import fr.lnl.game.server.games.player.Player;
|
import fr.lnl.game.server.games.player.Player;
|
||||||
import fr.lnl.game.server.utils.Pair;
|
import fr.lnl.game.server.utils.Pair;
|
||||||
import fr.lnl.game.server.utils.Point;
|
import fr.lnl.game.server.utils.Point;
|
||||||
|
@ -16,7 +16,8 @@ public class Shot extends AbstractAction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated a rewrite -> L'aléatoire ne devrait pas être ici, mais au moment de l'instanciation comme dans {@link Move}
|
* @deprecated a rewrite -> L'aléatoire ne devrait pas être ici, mais au moment de l'instanciation par exemple
|
||||||
|
* comme dans {@link Move}
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
package fr.lnl.game.server;
|
package fr.lnl.game.server;
|
||||||
|
|
||||||
import fr.lnl.game.server.games.Game;
|
import fr.lnl.game.server.games.Game;
|
||||||
import fr.lnl.game.server.games.action.Action;
|
import fr.lnl.game.server.games.action.*;
|
||||||
import fr.lnl.game.server.games.action.Move;
|
|
||||||
import fr.lnl.game.server.games.action.NotValidDirectionException;
|
|
||||||
import fr.lnl.game.server.games.action.Shot;
|
|
||||||
import fr.lnl.game.server.games.grid.Grid;
|
import fr.lnl.game.server.games.grid.Grid;
|
||||||
|
import fr.lnl.game.server.games.player.Player;
|
||||||
import fr.lnl.game.server.utils.Point;
|
import fr.lnl.game.server.utils.Point;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.junit.jupiter.api.Assertions;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
@ -23,13 +21,11 @@ public class ActionPlayerTest {
|
|||||||
Mock mock = new Mock();
|
Mock mock = new Mock();
|
||||||
this.grid = mock.grid;
|
this.grid = mock.grid;
|
||||||
this.game = mock.game;
|
this.game = mock.game;
|
||||||
|
Assertions.assertEquals(game.getPlayers().get(0), game.getCurrentPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: 21/10/2021 Vérifier sur Move effectue la bonne action en pensant a appeler isPossible() avant et
|
|
||||||
// en checkant son résultat
|
|
||||||
@Test
|
@Test
|
||||||
public void moveActionTest() {
|
public void moveActionTest() {
|
||||||
Assertions.assertEquals(game.getPlayers().get(0), game.getCurrentPlayer());
|
|
||||||
Action move = null;
|
Action move = null;
|
||||||
Point oldPoint = game.getCurrentPlayer().getPoint();
|
Point oldPoint = game.getCurrentPlayer().getPoint();
|
||||||
Move.Direction savedDirection = null;
|
Move.Direction savedDirection = null;
|
||||||
@ -51,6 +47,14 @@ public class ActionPlayerTest {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void DeployShieldTest() {
|
||||||
|
Player player = game.getCurrentPlayer();
|
||||||
|
Assertions.assertFalse(player.isShieldDeploy());
|
||||||
|
Action action = new DeployShield(player);
|
||||||
|
action.doAction();
|
||||||
|
Assertions.assertTrue(player.isShieldDeploy());
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: 10/28/2021 pas un vrai test et marche qu'avec le mock actuel
|
// TODO: 10/28/2021 pas un vrai test et marche qu'avec le mock actuel
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
Reference in New Issue
Block a user