added tests and few bugfixes
parent
38c6ea073b
commit
f832d54911
|
@ -353,7 +353,7 @@ public class LaticeApplicationWindow extends Application {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void switchToGameFinishedScreen() throws IOException {
|
public void switchToGameFinishedScreen() throws IOException {
|
||||||
|
|
||||||
//switching to game finished screen if the game finishes
|
//switching to game finished screen if the game finishes
|
||||||
System.out.println("confirmBtnClickedCount : " + confirmBtnClickedCount);
|
System.out.println("confirmBtnClickedCount : " + confirmBtnClickedCount);
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class Player {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
System.out.print("Quel tuile voulez-vous jouez ? ");
|
System.out.print("Quelle tuile voulez-vous jouez ? ");
|
||||||
this.rack.displayRack();
|
this.rack.displayRack();
|
||||||
Integer idTileToPlay = Integer.parseInt(play.next())-1;
|
Integer idTileToPlay = Integer.parseInt(play.next())-1;
|
||||||
Tile tileToPlay = this.rack.getListRackTile().get(idTileToPlay);
|
Tile tileToPlay = this.rack.getListRackTile().get(idTileToPlay);
|
||||||
|
@ -75,12 +75,6 @@ public class Player {
|
||||||
tileToPlay.setPosition(new Position(row, column));
|
tileToPlay.setPosition(new Position(row, column));
|
||||||
return tileToPlay;
|
return tileToPlay;
|
||||||
|
|
||||||
//.setGridBoard(" "+tileToPlay.getShapeConsole()+tileToPlay.getColorConsole()+" ", row, column);
|
|
||||||
//this.rack.removeTile(tileToPlay);
|
|
||||||
|
|
||||||
//board.displayGameBoard();
|
|
||||||
|
|
||||||
//this.rack.updateRack();
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,10 +6,9 @@ import java.util.regex.Pattern;
|
||||||
import latice.model.console.GameBoard;
|
import latice.model.console.GameBoard;
|
||||||
|
|
||||||
public class Rules {
|
public class Rules {
|
||||||
//private static boolean START = true;
|
|
||||||
|
|
||||||
public Rules() {
|
public Rules() {
|
||||||
// TODO Auto-generated constructor stub
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean moonRule(GameBoard board, Tile tile) {
|
public Boolean moonRule(GameBoard board, Tile tile) {
|
||||||
|
|
|
@ -158,11 +158,5 @@ public class Rack {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TODO add method(s) javafx
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -13,9 +13,9 @@
|
||||||
<image>
|
<image>
|
||||||
<Image url="@/gameFinishedImage.png" />
|
<Image url="@/gameFinishedImage.png" />
|
||||||
</image></ImageView>
|
</image></ImageView>
|
||||||
<Label fx:id="nameWinner" alignment="CENTER_RIGHT" layoutX="453.0" layoutY="247.0" prefHeight="22.0" prefWidth="300.0" textAlignment="CENTER">
|
<Label fx:id="nameWinner" alignment="CENTER_RIGHT" layoutX="274.0" layoutY="236.0" prefHeight="51.0" prefWidth="488.0" textAlignment="CENTER" textFill="WHITE">
|
||||||
<font>
|
<font>
|
||||||
<Font name="Bell MT" size="40.0" />
|
<Font name="Verdana" size="40.0" />
|
||||||
</font></Label>
|
</font></Label>
|
||||||
<Button fx:id="quitBtn" layoutX="753.0" layoutY="555.0" mnemonicParsing="false" onMouseClicked="#quitBtnClicked" prefHeight="140.0" prefWidth="380.0" style="-fx-background-color: transparent;" textFill="TRANSPARENT" />
|
<Button fx:id="quitBtn" layoutX="753.0" layoutY="555.0" mnemonicParsing="false" onMouseClicked="#quitBtnClicked" prefHeight="140.0" prefWidth="380.0" style="-fx-background-color: transparent;" textFill="TRANSPARENT" />
|
||||||
<Button fx:id="replayBtn" layoutX="175.0" layoutY="555.0" mnemonicParsing="false" onMouseClicked="#replayBtnClicked" prefHeight="140.0" prefWidth="380.0" style="-fx-background-color: transparent;" textFill="TRANSPARENT" />
|
<Button fx:id="replayBtn" layoutX="175.0" layoutY="555.0" mnemonicParsing="false" onMouseClicked="#replayBtnClicked" prefHeight="140.0" prefWidth="380.0" style="-fx-background-color: transparent;" textFill="TRANSPARENT" />
|
||||||
|
|
|
@ -7,17 +7,22 @@ import java.util.ArrayList;
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
import javafx.application.Application;
|
||||||
|
import javafx.scene.layout.HBox;
|
||||||
|
import javafx.stage.Stage;
|
||||||
import latice.model.Color;
|
import latice.model.Color;
|
||||||
import latice.model.Player;
|
import latice.model.Player;
|
||||||
import latice.model.Position;
|
import latice.model.Position;
|
||||||
|
import latice.model.Rules;
|
||||||
import latice.model.Shape;
|
import latice.model.Shape;
|
||||||
import latice.model.Tile;
|
import latice.model.Tile;
|
||||||
import latice.model.console.Deck;
|
import latice.model.console.Deck;
|
||||||
|
import latice.model.console.GameBoard;
|
||||||
import latice.model.console.Rack;
|
import latice.model.console.Rack;
|
||||||
import latice.model.console.Score;
|
import latice.model.console.Score;
|
||||||
|
|
||||||
class LaticeTest {
|
class LaticeTest {
|
||||||
|
|
||||||
//VEUILLEZ SAISIR Marc COMME NOM DU JOUEUR DANS LA CONSOLE
|
//VEUILLEZ SAISIR Marc COMME NOM DU JOUEUR DANS LA CONSOLE
|
||||||
|
|
||||||
|
|
||||||
|
@ -209,19 +214,269 @@ class LaticeTest {
|
||||||
assertEquals(1, player.getScore());
|
assertEquals(1, player.getScore());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*@Test
|
@Test
|
||||||
void () {
|
void should_create_tile_image() {
|
||||||
//Arrange
|
//Arrange
|
||||||
|
ArrayList<Tile> listOfTile = new ArrayList<Tile>();
|
||||||
|
Deck deck;
|
||||||
|
Rack rack;
|
||||||
|
|
||||||
|
for (Color color : Color.values()) {
|
||||||
|
for (Shape shape : Shape.values()) {
|
||||||
|
Tile tile = new Tile(color, shape);
|
||||||
|
System.out.println(color.getStringColor() + shape.getStringShape()+ ".png");
|
||||||
|
|
||||||
|
listOfTile.add(tile);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
deck = new Deck(listOfTile);
|
||||||
|
rack = new Rack(deck);
|
||||||
|
Player player = new Player("Marc", new Score(), deck, rack);
|
||||||
|
|
||||||
//Act
|
//Act
|
||||||
|
|
||||||
//Assert
|
//Assert
|
||||||
|
//assertEquals(5, player.getRack().createTileImage().getChildren().size());
|
||||||
|
|
||||||
}*/
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_get_gridboard() {
|
||||||
|
GameBoard gameBoard = new GameBoard();
|
||||||
|
String[][] gridBoard = gameBoard.getGridBoard();
|
||||||
|
assertEquals(9, gridBoard.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_set_gridboard() {
|
||||||
|
GameBoard gameBoard = new GameBoard();
|
||||||
|
gameBoard.setGridBoard("SUN", 0, 0);
|
||||||
|
String[][] gridBoard = gameBoard.getGridBoard();
|
||||||
|
|
||||||
|
assertEquals("SUN", gridBoard[0][0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_get_gridboard_tile() {
|
||||||
|
GameBoard gameBoard = new GameBoard();
|
||||||
|
Tile[][] tiles = gameBoard.getGridBoardTile();
|
||||||
|
assertEquals(9, tiles.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_set_gridboard_tile() {
|
||||||
|
//Arrange
|
||||||
|
ArrayList<Tile> listOfTile = new ArrayList<Tile>();
|
||||||
|
Deck deck;
|
||||||
|
Rack rack;
|
||||||
|
|
||||||
|
for (Color color : Color.values()) {
|
||||||
|
for (Shape shape : Shape.values()) {
|
||||||
|
Tile tile = new Tile(color, shape);
|
||||||
|
System.out.println(color.getStringColor() + shape.getStringShape()+ ".png");
|
||||||
|
|
||||||
|
listOfTile.add(tile);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
deck = new Deck(listOfTile);
|
||||||
|
rack = new Rack(deck);
|
||||||
|
Player player = new Player("Marc", new Score(), deck, rack);
|
||||||
|
|
||||||
|
GameBoard gameBoard = new GameBoard();
|
||||||
|
Tile[][] tiles = gameBoard.getGridBoardTile();
|
||||||
|
System.out.println("tiles\n\n" + tiles[0][0]);
|
||||||
|
gameBoard.setGridBoardTile(player.getRack().getListRackTile().get(0), 1, 0);
|
||||||
|
assertEquals(player.getRack().getListRackTile().get(0), gameBoard.getGridBoardTile()[1][0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_display_list_tile() {
|
||||||
|
//Arrange
|
||||||
|
ArrayList<Tile> listOfTile = new ArrayList<Tile>();
|
||||||
|
Deck deck;
|
||||||
|
|
||||||
|
//Act
|
||||||
|
for (Color color : Color.values()) {
|
||||||
|
for (Shape shape : Shape.values()) {
|
||||||
|
Tile tile = new Tile(color, shape);
|
||||||
|
System.out.println(color.getStringColor() + shape.getStringShape()+ ".png");
|
||||||
|
|
||||||
|
listOfTile.add(tile);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
deck = new Deck(listOfTile);
|
||||||
|
deck.displayListTile();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_return_rackTileImage() {
|
||||||
|
//Arrange
|
||||||
|
ArrayList<Tile> listOfTile = new ArrayList<Tile>();
|
||||||
|
Deck deck;
|
||||||
|
Rack rack;
|
||||||
|
|
||||||
|
for (Color color : Color.values()) {
|
||||||
|
for (Shape shape : Shape.values()) {
|
||||||
|
Tile tile = new Tile(color, shape);
|
||||||
|
System.out.println(color.getStringColor() + shape.getStringShape()+ ".png");
|
||||||
|
|
||||||
|
listOfTile.add(tile);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
deck = new Deck(listOfTile);
|
||||||
|
rack = new Rack(deck);
|
||||||
|
|
||||||
|
assertEquals(0, rack.getRackTileImage().size());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_verfy_moon_placement() {
|
||||||
|
//Arrange
|
||||||
|
ArrayList<Tile> listOfTile = new ArrayList<Tile>();
|
||||||
|
Deck deck;
|
||||||
|
Rack rack;
|
||||||
|
|
||||||
|
for (Color color : Color.values()) {
|
||||||
|
for (Shape shape : Shape.values()) {
|
||||||
|
Tile tile = new Tile(color, shape);
|
||||||
|
System.out.println(color.getStringColor() + shape.getStringShape()+ ".png");
|
||||||
|
|
||||||
|
listOfTile.add(tile);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
deck = new Deck(listOfTile);
|
||||||
|
rack = new Rack(deck);
|
||||||
|
rack.getListRackTile().get(0).setPosition(new Position(4, 4));
|
||||||
|
rack.getListRackTile().get(1).setPosition(new Position(3, 4));
|
||||||
|
GameBoard gameBoard = new GameBoard();
|
||||||
|
Rules referee = new Rules();
|
||||||
|
|
||||||
|
assertEquals(true, referee.moonRule(gameBoard, rack.getListRackTile().get(0)));
|
||||||
|
assertEquals(false, referee.moonRule(gameBoard, rack.getListRackTile().get(1)));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_verfy_sun_placement() {
|
||||||
|
//Arrange
|
||||||
|
ArrayList<Tile> listOfTile = new ArrayList<Tile>();
|
||||||
|
Deck deck;
|
||||||
|
Rack rack;
|
||||||
|
|
||||||
|
for (Color color : Color.values()) {
|
||||||
|
for (Shape shape : Shape.values()) {
|
||||||
|
Tile tile = new Tile(color, shape);
|
||||||
|
System.out.println(color.getStringColor() + shape.getStringShape()+ ".png");
|
||||||
|
|
||||||
|
listOfTile.add(tile);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
deck = new Deck(listOfTile);
|
||||||
|
rack = new Rack(deck);
|
||||||
|
rack.getListRackTile().get(0).setPosition(new Position(0, 0));
|
||||||
|
rack.getListRackTile().get(1).setPosition(new Position(1,0));
|
||||||
|
GameBoard gameBoard = new GameBoard();
|
||||||
|
Rules referee = new Rules();
|
||||||
|
|
||||||
|
assertEquals(true, referee.sunRule(gameBoard, rack.getListRackTile().get(0)));
|
||||||
|
assertEquals(false, referee.sunRule(gameBoard, rack.getListRackTile().get(1)));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_test_if_we_have_enough_points_to_play_a_tile() {
|
||||||
|
//Arrange
|
||||||
|
ArrayList<Tile> listOfTile = new ArrayList<Tile>();
|
||||||
|
Deck deck;
|
||||||
|
Rack rack;
|
||||||
|
|
||||||
|
for (Color color : Color.values()) {
|
||||||
|
for (Shape shape : Shape.values()) {
|
||||||
|
Tile tile = new Tile(color, shape);
|
||||||
|
System.out.println(color.getStringColor() + shape.getStringShape()+ ".png");
|
||||||
|
|
||||||
|
listOfTile.add(tile);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
deck = new Deck(listOfTile);
|
||||||
|
rack = new Rack(deck);
|
||||||
|
Player player = new Player("Marc", new Score(), deck, rack);
|
||||||
|
|
||||||
|
GameBoard gameBoard = new GameBoard();
|
||||||
|
Rules referee = new Rules();
|
||||||
|
assertEquals(false, referee.checkScoreToPlay(player, false));
|
||||||
|
assertEquals(true, referee.checkScoreToPlay(player, true));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_test_if_a_box_is_empty() {
|
||||||
|
//Arrange
|
||||||
|
ArrayList<Tile> listOfTile = new ArrayList<Tile>();
|
||||||
|
Deck deck;
|
||||||
|
Rack rack;
|
||||||
|
|
||||||
|
for (Color color : Color.values()) {
|
||||||
|
for (Shape shape : Shape.values()) {
|
||||||
|
Tile tile = new Tile(color, shape);
|
||||||
|
System.out.println(color.getStringColor() + shape.getStringShape()+ ".png");
|
||||||
|
|
||||||
|
listOfTile.add(tile);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
deck = new Deck(listOfTile);
|
||||||
|
rack = new Rack(deck);
|
||||||
|
Player player = new Player("Marc", new Score(), deck, rack);
|
||||||
|
|
||||||
|
GameBoard gameBoard = new GameBoard();
|
||||||
|
Rules referee = new Rules();
|
||||||
|
player.getRack().getListRackTile().get(0).setPosition(new Position(0, 0));
|
||||||
|
player.getRack().getListRackTile().get(1).setPosition(new Position(0, 0));
|
||||||
|
|
||||||
|
assertEquals(true, referee.checkPositionRule(gameBoard, player.getRack().getListRackTile().get(0)));
|
||||||
|
assertEquals(true, referee.checkPositionRule(gameBoard, player.getRack().getListRackTile().get(1)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void should_test_neighbor_rule() {
|
||||||
|
//Arrange
|
||||||
|
ArrayList<Tile> listOfTile = new ArrayList<Tile>();
|
||||||
|
Deck deck;
|
||||||
|
Rack rack;
|
||||||
|
|
||||||
|
for (Color color : Color.values()) {
|
||||||
|
for (Shape shape : Shape.values()) {
|
||||||
|
Tile tile = new Tile(color, shape);
|
||||||
|
System.out.println(color.getStringColor() + shape.getStringShape()+ ".png");
|
||||||
|
|
||||||
|
listOfTile.add(tile);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
deck = new Deck(listOfTile);
|
||||||
|
rack = new Rack(deck);
|
||||||
|
Player player = new Player("Marc", new Score(), deck, rack);
|
||||||
|
|
||||||
|
GameBoard gameBoard = new GameBoard();
|
||||||
|
Rules referee = new Rules();
|
||||||
|
player.getRack().getListRackTile().get(0).setPosition(new Position(0, 0));
|
||||||
|
player.getRack().getListRackTile().get(1).setPosition(new Position(0, 1));
|
||||||
|
|
||||||
|
assertEquals(0, referee.neighborRule(gameBoard, player.getRack().getListRackTile().get(1)));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue