Compare commits
No commits in common. "ccb61b5ef8594d75123eb955d1c38d8d91d66b53" and "5d3ff112ebdd320d1d097fb0402cc361fb0dcd44" have entirely different histories.
ccb61b5ef8
...
5d3ff112eb
|
@ -20,16 +20,80 @@ public class LaticeApplicationConsole {
|
|||
|
||||
ArrayList<Tile> listOfTile = new ArrayList<Tile>();
|
||||
|
||||
//System.out.println("Hello Latice !");
|
||||
|
||||
/*
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
System.out.println("-----------------");
|
||||
System.out.println("Notre Deck :");
|
||||
Deck deck = new Deck(listOfTile);
|
||||
deck.displayListTile();
|
||||
System.out.println("-----------------");
|
||||
Rack rack = new Rack(deck);
|
||||
System.out.println("-----------------");
|
||||
deck.displayListTile();
|
||||
|
||||
System.out.println("-----------------");
|
||||
GameBoard board = new GameBoard();
|
||||
board.displayGameBoard();
|
||||
System.out.println("-----------------");
|
||||
board.setGridBoard(" NV ", 4, 4);
|
||||
board.displayGameBoard();
|
||||
System.out.println("-----------------");
|
||||
Score scorePlayer1 = new Score();
|
||||
Score scorePlayer2 = new Score();
|
||||
Player player1 = new Player("player1", scorePlayer1);
|
||||
Player player2 = new Player("player2", scorePlayer2);
|
||||
|
||||
System.out.println(player1.getName() + " a " + scorePlayer1.getScore() +" points");
|
||||
System.out.println(player2.getName() + " a " + scorePlayer2.getScore() +" points");
|
||||
|
||||
rack.displayRack();
|
||||
|
||||
*/
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("-----------------");
|
||||
//System.out.println("Notre Deck :");
|
||||
//Deck deck1 = new Deck(listOfTile);
|
||||
//Deck deck2 = new Deck(listOfTile);
|
||||
//deck1.displayListTile();
|
||||
System.out.println("-----------------");
|
||||
//Rack rack1 = new Rack(deck1);
|
||||
//Rack rack2 = new Rack(deck2);
|
||||
//Score scorePlayer1 = new Score();
|
||||
//Score scorePlayer2 = new Score();
|
||||
//Player player1 = new Player("player1", scorePlayer1);
|
||||
//Player player2 = new Player("player2", scorePlayer2);
|
||||
|
||||
System.out.println("-----------------");
|
||||
//GameBoard board = new GameBoard();
|
||||
//board.displayGameBoard();
|
||||
System.out.println("-----------------");
|
||||
|
||||
//System.out.println(player1.getName() + " a " + scorePlayer1.getScore() +" points");
|
||||
//System.out.println(player2.getName() + " a " + scorePlayer2.getScore() +" points");
|
||||
//rack1.displayRack();
|
||||
|
||||
|
||||
System.out.println("Hello Latice !");
|
||||
|
@ -37,15 +101,19 @@ public class LaticeApplicationConsole {
|
|||
|
||||
Deck deck1 = new Deck(listOfTile);
|
||||
Deck deck2 = new Deck(listOfTile);
|
||||
|
||||
Rack rack1 = new Rack(deck1);
|
||||
Rack rack2 = new Rack(deck2);
|
||||
|
||||
Score scorePlayer1 = new Score();
|
||||
Score scorePlayer2 = new Score();
|
||||
Player player1 = new Player("player1", deck1);
|
||||
Player player2 = new Player("player2", deck2);
|
||||
|
||||
|
||||
System.out.println("-----------------");
|
||||
GameBoard board = new GameBoard();
|
||||
board.displayGameBoard();
|
||||
|
||||
|
||||
System.out.println(Objects.equals(board.getGridBoard()[1][0], Tile.class));
|
||||
Scanner play = new Scanner(System.in);
|
||||
Player player;
|
||||
Boolean round;
|
||||
|
@ -69,17 +137,15 @@ public class LaticeApplicationConsole {
|
|||
while (round) {
|
||||
player.getRack().displayRack();
|
||||
System.out.println("Vous avez " + player.getScore() +" points, que voulez-vous faire ?\n"
|
||||
+ " 1. Jouer une Tuile\n"
|
||||
+ " 2. Acheter une action supplémentaire(coûte 2 points)\n"
|
||||
+ " 1. Jouer une Tuile (à partir de la deuxième tuile jouée, cela coûtera 2 points)\n"
|
||||
+ " 2. Acheter une action supplémentaire\n"
|
||||
+ " 3. Changer le Rack et passer(coûte 3 points)\n"
|
||||
+ " 4. Passer\n");
|
||||
|
||||
System.out.print("Choix : ");
|
||||
int choiceMenu = Integer.parseInt(play.next());
|
||||
switch(choiceMenu) {
|
||||
|
||||
case 1: if (freeTile) {
|
||||
freeTile = false;
|
||||
Boolean rulesCheck = false;
|
||||
|
||||
while (rulesCheck == false) {
|
||||
|
@ -99,25 +165,17 @@ public class LaticeApplicationConsole {
|
|||
player.getRack().removeTile(tile);
|
||||
board.displayGameBoard();
|
||||
|
||||
}else {
|
||||
System.out.println("Vous n'avez pas acheter une action pour jouer un autre tuile dans ce tour ! Veuillez en acheter une ou passer votre tour !");
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
||||
case 2:
|
||||
if (freeTile) {
|
||||
System.out.println("Vous avez dejà une action pour jouer une tuile ! Veuillez jouer votre tuile d'abord pour ensuite acheter une nouvelle action pour jouer une autre tuile !");
|
||||
if (player.getScore()>=3) {
|
||||
//Donner une action supplémentaire et enlever 3 points au joueur
|
||||
player.Play(play, board, 0);
|
||||
player.diffScore(2);
|
||||
}else {
|
||||
if (player.getScore()>=2) {
|
||||
//Buy another action and remove 2 points from score
|
||||
player.Play(play, board, 0);
|
||||
player.removePointsFromScore(2);
|
||||
freeTile = true;
|
||||
}else {
|
||||
System.out.println("Il vous faut 2 points pour acheter une nouvelle action !");
|
||||
}
|
||||
System.out.println("Il vous faut 2 points pour acheter une nouvelle action !");
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -63,8 +63,8 @@ public class LaticeApplicationWindow extends Application {
|
|||
|
||||
//lists for tiles
|
||||
ArrayList<Tile> listRackTile;
|
||||
ArrayList<Image> listOfTilesInRack;
|
||||
//ArrayList<Tile> listOfTile = new ArrayList<Tile>();
|
||||
ArrayList<Image> listRackImage;
|
||||
ArrayList<Tile> listOfTile = new ArrayList<Tile>();
|
||||
static StackPane rootLayout;
|
||||
|
||||
public static int indexTileClicked;
|
||||
|
@ -92,7 +92,7 @@ public class LaticeApplicationWindow extends Application {
|
|||
Paint tileOnRect;
|
||||
|
||||
//tile is free when it's the first tile put but tile is payable after
|
||||
Boolean isFreePlacement = true;
|
||||
Boolean freeOrPayableTile = true;
|
||||
|
||||
public static BorderPane borderPane = new BorderPane();
|
||||
|
||||
|
@ -102,9 +102,9 @@ public class LaticeApplicationWindow extends Application {
|
|||
|
||||
Stage primaryStageCopy;
|
||||
StackPane parentStackPane = new StackPane();
|
||||
Label gameInfoLabel = new Label();
|
||||
Label ErrorLabel = new Label();
|
||||
|
||||
HBox rackTileImage;
|
||||
HBox rackImage;
|
||||
static Label nameWinner = new Label();
|
||||
|
||||
int confirmBtnClickedCount;
|
||||
|
@ -152,7 +152,7 @@ public class LaticeApplicationWindow extends Application {
|
|||
stage.setScene(menu);
|
||||
|
||||
parentStackPane.getChildren().remove(root);
|
||||
parentStackPane.getChildren().add(root);
|
||||
//parentStackPane.getChildren().add(root);
|
||||
parentStackPane.getChildren().remove(menuBorderPane);
|
||||
}else {
|
||||
|
||||
|
@ -186,9 +186,9 @@ public class LaticeApplicationWindow extends Application {
|
|||
topVbox.setAlignment(Pos.CENTER);
|
||||
|
||||
//error label for displaying errors
|
||||
gameInfoLabel.setFont(new Font(20));
|
||||
gameInfoLabel.setTextFill(Constant.realColor.RED);
|
||||
topVbox.getChildren().add(gameInfoLabel);
|
||||
ErrorLabel.setFont(new Font(20));
|
||||
ErrorLabel.setTextFill(Constant.realColor.RED);
|
||||
topVbox.getChildren().add(ErrorLabel);
|
||||
borderPane.setTop(topVbox);
|
||||
|
||||
//background image
|
||||
|
@ -260,21 +260,21 @@ public class LaticeApplicationWindow extends Application {
|
|||
|
||||
|
||||
//Creating tiles
|
||||
/*for (Color color : Color.values()) {
|
||||
for (Color color : Color.values()) {
|
||||
for (Shape shape : Shape.values()) {
|
||||
Tile tile = new Tile(color, shape);
|
||||
|
||||
listOfTile.add(tile);
|
||||
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
/*System.out.println("-----------------");
|
||||
System.out.println("-----------------");
|
||||
System.out.println("Notre Deck :");
|
||||
Deck deck = new Deck(listOfTile);
|
||||
System.out.println("-----------------");
|
||||
Rack rack = new Rack(deck);
|
||||
System.out.println("-----------------");*/
|
||||
System.out.println("-----------------");
|
||||
|
||||
|
||||
//Player
|
||||
|
@ -286,7 +286,7 @@ public class LaticeApplicationWindow extends Application {
|
|||
//Confirm Button
|
||||
Image checkMark = new Image("checkMark.png");
|
||||
ImageView checkMarkView = new ImageView(checkMark);
|
||||
confirmButton = new Button("End Turn", checkMarkView);
|
||||
confirmButton = new Button("Confirm", checkMarkView);
|
||||
confirmButton.setPrefWidth(Constant.ACTION_BUTTONS_WIDTH);
|
||||
confirmButton.setPrefHeight(Constant.ACTION_BUTTONS_HEIGHT);
|
||||
|
||||
|
@ -299,11 +299,11 @@ public class LaticeApplicationWindow extends Application {
|
|||
changeButton.setPrefHeight(Constant.ACTION_BUTTONS_HEIGHT);
|
||||
|
||||
//Buy another action Button
|
||||
/*Image buyActionImage = new Image("buyAction.png");
|
||||
Image buyActionImage = new Image("buyAction.png");
|
||||
ImageView buyActionView = new ImageView(buyActionImage);
|
||||
buyActionButton = new Button("Buy Action (2 points)", buyActionView);
|
||||
buyActionButton = new Button("Buy Action", buyActionView);
|
||||
buyActionButton.setPrefWidth(Constant.ACTION_BUTTONS_WIDTH);
|
||||
buyActionButton.setPrefHeight(Constant.ACTION_BUTTONS_HEIGHT);*/
|
||||
buyActionButton.setPrefHeight(Constant.ACTION_BUTTONS_HEIGHT);
|
||||
|
||||
confirmButton.setOnMouseClicked(new EventHandler<MouseEvent>() {
|
||||
//confirming the end of the round and switching round
|
||||
|
@ -320,13 +320,12 @@ public class LaticeApplicationWindow extends Application {
|
|||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
confirmBtnClickedCount++;
|
||||
|
||||
////// for the actual player //////
|
||||
player.getRack().displayRack();
|
||||
player.getRack().updateRack();
|
||||
|
||||
////// changing player //////
|
||||
player.getRack().displayRack();
|
||||
|
||||
//making names colored in red to make the players know which player's round is
|
||||
if (confirmBtnClickedCount%2 == 0) {
|
||||
playerFX.setFillName(Constant.realColor.BLACK);
|
||||
|
@ -340,24 +339,22 @@ public class LaticeApplicationWindow extends Application {
|
|||
playerFX.setFillName(Constant.realColor.RED);
|
||||
}
|
||||
|
||||
////// for the next player //////
|
||||
isFreePlacement = true;
|
||||
freeOrPayableTile = true;
|
||||
|
||||
rackTileImage = player.getRack().createTileImage();
|
||||
//Setting drag n drop on tiles
|
||||
setDragnDropOnRack(rackTileImage, player);
|
||||
rackImage = player.getRack().createTileImage();
|
||||
setDragnDropOnRack(rackImage, player);
|
||||
setDragnDropOnRectangles(rect, board, referee, player);
|
||||
rackTileImage.getChildren().addAll(confirmButton, changeButton/*, buyActionButton*/);
|
||||
borderPane.setBottom(rackTileImage);
|
||||
rackImage.getChildren().addAll(confirmButton, changeButton, buyActionButton);
|
||||
borderPane.setBottom(rackImage);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void switchToGameFinishedScreen() throws IOException {
|
||||
private void switchToGameFinishedScreen() throws IOException {
|
||||
|
||||
//switching to game finished screen if the game finishes
|
||||
System.out.println("confirmBtnClickedCount : " + confirmBtnClickedCount);
|
||||
if (confirmBtnClickedCount>=20) {
|
||||
if (confirmBtnClickedCount>=2) {
|
||||
Parent loader = FXMLLoader.load(getClass().getResource("../view/GameFinishedScreen.fxml"));
|
||||
Scene gameFinishedScreenScene = new Scene(loader, Constant.SCREEN_WIDTH, Constant.SCREEN_HEIGHT);
|
||||
if (player1.getNumberOfTilesRemaining() < player2.getNumberOfTilesRemaining()) {
|
||||
|
@ -381,14 +378,14 @@ public class LaticeApplicationWindow extends Application {
|
|||
|
||||
});
|
||||
|
||||
//Rack with Image
|
||||
rackTileImage = player.getRack().createTileImage();
|
||||
//With Image
|
||||
rackImage = player.getRack().createTileImage();
|
||||
|
||||
//Adding lists to Arraylists
|
||||
listRackTile = player.getRack().getListRackTile();
|
||||
System.out.println(listRackTile);
|
||||
listOfTilesInRack = player.getRack().getRackTileImage();
|
||||
System.out.println("listTileImge : " + listOfTilesInRack);
|
||||
listRackImage = player.getRack().getRackTileImage();
|
||||
System.out.println("listTileImge : " + listRackImage);
|
||||
|
||||
changeButton.setOnMouseClicked(new EventHandler<MouseEvent>() {
|
||||
|
||||
|
@ -396,11 +393,7 @@ public class LaticeApplicationWindow extends Application {
|
|||
public void handle(MouseEvent arg0) {
|
||||
|
||||
////// for the actual player //////
|
||||
if (player.getScore() >= 2 || isFreePlacement) {
|
||||
if (!isFreePlacement) {
|
||||
playerFX.setRemovePointsFromScore(player, 2);
|
||||
}
|
||||
|
||||
if (player.getScore() > 1) {
|
||||
System.out.println("Changing Rack");
|
||||
confirmBtnClickedCount++;
|
||||
player.getRack().changeRack();
|
||||
|
@ -422,39 +415,44 @@ public class LaticeApplicationWindow extends Application {
|
|||
|
||||
|
||||
////// for the next player //////
|
||||
isFreePlacement = true;
|
||||
rackTileImage = player.getRack().createTileImage();
|
||||
freeOrPayableTile = true;
|
||||
rackImage = player.getRack().createTileImage();
|
||||
|
||||
//Setting drag n drop on tiles
|
||||
setDragnDropOnRack(rackTileImage, player);
|
||||
setDragnDropOnRack(rackImage, player);
|
||||
|
||||
rackTileImage.getChildren().addAll(confirmButton, changeButton/*, buyActionButton*/);
|
||||
rackImage.getChildren().addAll(confirmButton, changeButton, buyActionButton);
|
||||
setDragnDropOnRectangles(rect, board, referee, player);
|
||||
borderPane.setBottom(rackTileImage);
|
||||
|
||||
borderPane.setBottom(rackImage);
|
||||
|
||||
}else {
|
||||
System.out.println("Not enough points to change the rack");
|
||||
gameInfoLabel.setText("Error ! " + player.getName() + ", you haven't enough points to change your rack");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/*buyActionButton.setOnMouseClicked(new EventHandler<MouseEvent>() {
|
||||
buyActionButton.setOnMouseClicked(new EventHandler<MouseEvent>() {
|
||||
|
||||
@Override
|
||||
public void handle(MouseEvent arg0) {
|
||||
gameInfoLabel.setText(player.getName() + ", you can now play another time !");
|
||||
//TODO verify score and give another play()
|
||||
/*if (player.getScore()>=3) {
|
||||
//Donner une action supplémentaire et enlever 3 points au joueur
|
||||
player.Play(play, board, 0);
|
||||
player.diffScore(3);
|
||||
}else {
|
||||
System.out.println("Il vous faut 3 points pour acheter une nouvelle action !");
|
||||
}*/
|
||||
}
|
||||
|
||||
});*/
|
||||
});
|
||||
|
||||
rackTileImage.getChildren().addAll(confirmButton, changeButton/*, buyActionButton*/);
|
||||
setDragnDropOnRack(rackTileImage, player);
|
||||
rackImage.getChildren().addAll(confirmButton, changeButton, buyActionButton);
|
||||
setDragnDropOnRack(rackImage, player);
|
||||
System.out.println();
|
||||
borderPane.setBottom(rackTileImage);
|
||||
borderPane.setBottom(rackImage);
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
|
@ -462,7 +460,7 @@ public class LaticeApplicationWindow extends Application {
|
|||
|
||||
|
||||
System.out.println((indexTileClicked));
|
||||
ImagePattern imagePattern = new ImagePattern(listOfTilesInRack.get(getIndexTileClicked()));
|
||||
ImagePattern imagePattern = new ImagePattern(listRackImage.get(getIndexTileClicked()));
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
|
@ -473,7 +471,7 @@ public class LaticeApplicationWindow extends Application {
|
|||
|
||||
|
||||
|
||||
//------if there is already childrens, remove them all to start or restart game--------------------------------
|
||||
//------if there is already childrens, remove them all to start or restart game------------------------------------------------------------
|
||||
root.getChildren().clear();
|
||||
//adding new childrens
|
||||
root.getChildren().addAll(infoPlayers, borderPane);
|
||||
|
@ -492,24 +490,27 @@ public class LaticeApplicationWindow extends Application {
|
|||
|
||||
|
||||
rect[a][b].setOnDragEntered(new EventHandler<DragEvent>() {
|
||||
|
||||
//if we are entering a rectangle
|
||||
|
||||
@Override
|
||||
public void handle(DragEvent arg0) {
|
||||
|
||||
|
||||
tileOnRect = rect[a][b].getFill();
|
||||
//not putting the virtual image drag on the case because an image is already into it
|
||||
player.getRack().getListRackTile().get(indexTileClicked).setPosition(new Position(a,b));
|
||||
if ( referee.checkPositionRule(board, player.getRack().getListRackTile().get(indexTileClicked)) == true ) {
|
||||
rect[a][b].setFill(new ImagePattern(player.getRack().getRackTileImage().get(indexTileClicked)));
|
||||
if (arg0.getDragboard().hasString()){
|
||||
Dragboard dragboard = arg0.getDragboard();
|
||||
|
||||
//not putting the virtual image drag on the case because an image is already into it
|
||||
player.getRack().getListRackTile().get(indexTileClicked).setPosition(new Position(a,b));
|
||||
if ( referee.checkPositionRule(board, player.getRack().getListRackTile().get(indexTileClicked)) == true ) {
|
||||
rect[a][b].setFill(new ImagePattern(player.getRack().getRackTileImage().get(indexTileClicked)));
|
||||
}
|
||||
}
|
||||
arg0.consume();
|
||||
}
|
||||
});
|
||||
|
||||
rect[a][b].setOnDragExited(new EventHandler<DragEvent>() {
|
||||
//if we are leaving a rectangle
|
||||
|
||||
@Override
|
||||
public void handle(DragEvent arg0) {
|
||||
if (arg0.isDropCompleted() == false) {
|
||||
|
@ -522,8 +523,6 @@ public class LaticeApplicationWindow extends Application {
|
|||
});
|
||||
|
||||
rect[a][b].setOnDragOver(new EventHandler <DragEvent>() {
|
||||
|
||||
//If we are traveling over a rectangle
|
||||
@Override
|
||||
public void handle(DragEvent arg0) {
|
||||
|
||||
|
@ -533,24 +532,26 @@ public class LaticeApplicationWindow extends Application {
|
|||
});
|
||||
|
||||
rect[a][b].setOnDragDropped(new EventHandler<DragEvent>() {
|
||||
|
||||
//If we are dropping a tile in a rectangle
|
||||
@Override
|
||||
public void handle(DragEvent arg0) {
|
||||
System.out.println("entered");
|
||||
Dragboard dragboard = arg0.getDragboard();
|
||||
System.out.println("OK2");
|
||||
|
||||
|
||||
rect[a][b].setFill(new ImagePattern(player.getRack().getRackTileImage().get(indexTileClicked)));
|
||||
|
||||
arg0.setDropCompleted(true);
|
||||
gameInfoLabel.setText("");
|
||||
|
||||
//testing if player has enough points
|
||||
if (referee.checkScoreToPlay(player, isFreePlacement) == false) {
|
||||
gameInfoLabel.setText("Error ! " + player.getName() + ", you haven't enough points to play another tile");
|
||||
arg0.setDropCompleted(true);
|
||||
System.out.println("OK");
|
||||
ErrorLabel.setText("");
|
||||
|
||||
if (referee.checkScoreToPlay(player, freeOrPayableTile) == false) {
|
||||
ErrorLabel.setText("Error ! You haven't enough points to play another tile");
|
||||
rect[a][b].setFill(tileOnRect);
|
||||
|
||||
}else {
|
||||
|
||||
//testing if it's the free round
|
||||
if (Constant.START) {
|
||||
if (rect[a][b] == rect[Constant.MOON_BOX_X][Constant.MOON_BOX_Y]) {
|
||||
//if its's the center box (moon box)
|
||||
|
@ -558,11 +559,11 @@ public class LaticeApplicationWindow extends Application {
|
|||
|
||||
board.setGridBoardTile(player.getRack().getListRackTile().get(indexTileClicked), a, b);
|
||||
tileDropped = true;
|
||||
isFreePlacement = false;
|
||||
freeOrPayableTile = false;
|
||||
Constant.START = false;
|
||||
|
||||
}else {
|
||||
gameInfoLabel.setText("Error ! " + player.getName() + ", please place the first tile on the moon");
|
||||
ErrorLabel.setText("Error ! Please place the first tile on the moon");
|
||||
//removing all tiles from gameboard
|
||||
rect[a][b].setFill(Constant.realColor.TRANSPARENT);
|
||||
|
||||
|
@ -572,12 +573,13 @@ public class LaticeApplicationWindow extends Application {
|
|||
|
||||
}else {
|
||||
//if it's not the first round of the game
|
||||
//putting the position of the gameboard's case on the tile from the rack
|
||||
System.out.println("OK3");
|
||||
System.out.println("Règle effectué");
|
||||
player.getRack().getListRackTile().get(indexTileClicked).setPosition(new Position(a,b));
|
||||
|
||||
//verify if a tile is already placed
|
||||
if ( referee.checkPositionRule(board, player.getRack().getListRackTile().get(indexTileClicked)) == false ) {
|
||||
gameInfoLabel.setText("Error ! The tile can't be placed here because there is already a tile placed");
|
||||
ErrorLabel.setText("Error ! The tile can't be placed here because there is already a tile placed");
|
||||
rect[a][b].setFill(tileOnRect);
|
||||
|
||||
}else {
|
||||
|
@ -585,41 +587,37 @@ public class LaticeApplicationWindow extends Application {
|
|||
int nbr = referee.neighborRule(board , player.getRack().getListRackTile().get(indexTileClicked));
|
||||
|
||||
if (nbr == 0) {
|
||||
gameInfoLabel.setText("Error! The tile isn't placed next to another tile or there is no correspondance with the neighbor tiles!");
|
||||
ErrorLabel.setText("Error ! The tile isn't place next to another tile or there is no correspondance with the neighbor tiles !!");
|
||||
rect[a][b].setFill(Constant.realColor.TRANSPARENT);
|
||||
|
||||
}else {
|
||||
|
||||
if (isFreePlacement == false) {
|
||||
playerFX.setRemovePointsFromScore(player, 2);
|
||||
if (freeOrPayableTile == false) {
|
||||
playerFX.setDiffScore(player, 2);
|
||||
}
|
||||
|
||||
if (nbr == 2) {
|
||||
System.out.println("Vous avez gagné 1 point");
|
||||
gameInfoLabel.setText(player.getName() + ", you won 1 point");
|
||||
playerFX.setAddPointsToScore(player, 1);
|
||||
playerFX.setAddScore(player, 1);
|
||||
|
||||
}else if (nbr == 3) {
|
||||
System.out.println("Vous avez gagné 2 points");
|
||||
gameInfoLabel.setText(player.getName() + ", you won 2 points");
|
||||
playerFX.setAddPointsToScore(player, 2);
|
||||
playerFX.setAddScore(player, 2);
|
||||
|
||||
}else if (nbr == 4) {
|
||||
System.out.println("Vous avez gagné 4 points");
|
||||
gameInfoLabel.setText(player.getName() + ", you won 4 points");
|
||||
playerFX.setAddPointsToScore(player, 4);
|
||||
playerFX.setAddScore(player, 4);
|
||||
}
|
||||
|
||||
board.setGridBoardTile(player.getRack().getListRackTile().get(getIndexTileClicked()), a, b);
|
||||
tileDropped = true;
|
||||
isFreePlacement = false;
|
||||
freeOrPayableTile = false;
|
||||
System.out.println("tuile posé!");
|
||||
|
||||
//Sun rule
|
||||
if (referee.sunRule(board, player.getRack().getListRackTile().get(indexTileClicked))) {
|
||||
System.out.println("Vous avez gagné 2 points en mettant votre tuile sur un soleil");
|
||||
gameInfoLabel.setText("Wow! " + player.getName() + ", you won 2 points by placing a tile on a sun !");
|
||||
playerFX.setAddPointsToScore(player, 2);
|
||||
playerFX.setAddScore(player, 2);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -637,12 +635,18 @@ public class LaticeApplicationWindow extends Application {
|
|||
}
|
||||
}
|
||||
}
|
||||
//-------------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private void setDragnDropOnRack(HBox rackBox, Player player) {
|
||||
//Setting drag n drop on tiles
|
||||
for (int i=0; i< player.getRack().getRackTileImage().size(); i++) {
|
||||
int a = i;
|
||||
System.out.println(a);
|
||||
//HBox t = rackBox.getChildren().indexOf(rack);
|
||||
rackBox.getChildren().get(a).setOnDragDetected(new EventHandler<MouseEvent>() {
|
||||
|
||||
@Override
|
||||
|
@ -664,13 +668,14 @@ public class LaticeApplicationWindow extends Application {
|
|||
public void handle(DragEvent arg0) {
|
||||
if (tileDropped) {
|
||||
player.getRack().getListRackTile().remove(a);
|
||||
rackTileImage = player.getRack().createTileImage();
|
||||
rackImage = player.getRack().createTileImage();
|
||||
|
||||
//Setting drag n drop on tiles
|
||||
setDragnDropOnRack(rackTileImage, player);
|
||||
setDragnDropOnRack(rackImage, player);
|
||||
|
||||
rackTileImage.getChildren().addAll(confirmButton, changeButton/*, buyActionButton*/);
|
||||
borderPane.setBottom(rackTileImage);
|
||||
rackImage.getChildren().addAll(confirmButton, changeButton, buyActionButton);
|
||||
//setDragnDropOnRectangles(rect, board, referee, player);
|
||||
borderPane.setBottom(rackImage);
|
||||
tileDropped = false;
|
||||
playerFX.setTilesRemaining(player);
|
||||
}
|
||||
|
@ -686,6 +691,10 @@ public class LaticeApplicationWindow extends Application {
|
|||
return rootLayout;
|
||||
}
|
||||
|
||||
public static String getNameWinner() {
|
||||
return nameWinner.getText();
|
||||
}
|
||||
|
||||
//getter to get the index of the mouse clicked tile
|
||||
public static int getIndexTileClicked() {
|
||||
return indexTileClicked;
|
||||
|
|
|
@ -18,9 +18,7 @@ import javafx.scene.input.MouseEvent;
|
|||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.scene.shape.Rectangle;
|
||||
import javafx.scene.web.WebView;
|
||||
import javafx.stage.Modality;
|
||||
import javafx.stage.Stage;
|
||||
import javafx.util.Duration;
|
||||
|
@ -70,30 +68,40 @@ public class MainScreenController extends LaticeApplicationWindow{
|
|||
// Event Listener on Rectangle[#rulesButton].onMouseClicked
|
||||
@FXML
|
||||
public void rulesButtonClicked(MouseEvent event) {
|
||||
//Adding the Web View of the official Latice Rules
|
||||
System.out.println("rulesButtonClicked");
|
||||
Stage primaryStage = (Stage) ((Node) event.getTarget()).getScene().getWindow();
|
||||
Label secondLabel = new Label("Règles");
|
||||
//TODO règles à saisir
|
||||
StackPane secondaryLayout = new StackPane();
|
||||
secondaryLayout.getChildren().add(secondLabel);
|
||||
|
||||
Scene secondScene = new Scene(secondaryLayout, 230, 100);
|
||||
|
||||
// New window (Stage)
|
||||
Stage newWindow = new Stage();
|
||||
newWindow.setTitle("Règles du jeu Latice");
|
||||
newWindow.setScene(secondScene);
|
||||
|
||||
WebView webView = new WebView();
|
||||
webView.getEngine().load("https://latice.com/how/#rules-objective");
|
||||
VBox videoContainer = new VBox(webView);
|
||||
|
||||
newWindow.setScene(new Scene(videoContainer, 1100, 680));
|
||||
newWindow.show();
|
||||
// Specifies the modality for new window
|
||||
newWindow.initModality(Modality.WINDOW_MODAL);
|
||||
|
||||
// Specifies the owner window
|
||||
newWindow.initOwner(primaryStage);
|
||||
|
||||
// Set position of window
|
||||
newWindow.setX(primaryStage.getX() + 300);
|
||||
newWindow.setY(primaryStage.getY() + 175);
|
||||
|
||||
newWindow.show();
|
||||
}
|
||||
// Event Listener on Rectangle[#exitButton].onMouseClicked
|
||||
@FXML
|
||||
public void exitButtonClicked(MouseEvent event) {
|
||||
//shut down the Platform
|
||||
System.out.println("exitButtonClicked");
|
||||
Platform.exit();
|
||||
}
|
||||
|
||||
public void playerNamesInput(MouseEvent event) throws IOException {
|
||||
//loading the stage to enter player names
|
||||
Parent loader = FXMLLoader.load(getClass().getResource("../view/PlayerNameInput.fxml"));
|
||||
Scene nameInputScene = new Scene(loader, 600, 300);
|
||||
Stage primaryStage = (Stage) ((Node) event.getTarget()).getScene().getWindow();
|
||||
|
@ -122,6 +130,34 @@ public class MainScreenController extends LaticeApplicationWindow{
|
|||
|
||||
}
|
||||
|
||||
/*public void startGame(Stage stage) {
|
||||
parentStackPane = parentStackPaneStock;
|
||||
StackPane root = getRootLayout();
|
||||
root.translateYProperty().set(stage.getHeight());
|
||||
System.out.println(parentStackPane);
|
||||
System.out.println(parentStackPaneStock);
|
||||
parentStackPane.getChildren().add(root);
|
||||
|
||||
players = PlayerFX.displayPlayers(parentStackPane,player1, player2);
|
||||
root.getChildren().addAll(players,LaticeApplicationWindow.borderPane);
|
||||
|
||||
//parameters of the animation
|
||||
Timeline timeline = new Timeline();
|
||||
KeyValue kv = new KeyValue(root.translateYProperty(), 0, Interpolator.EASE_IN);
|
||||
KeyFrame kf = new KeyFrame(Duration.seconds(1), kv);
|
||||
timeline.getKeyFrames().add(kf);
|
||||
|
||||
//when the animation is finished we're removing the main screen
|
||||
timeline.setOnFinished(t -> {
|
||||
parentStackPane.getChildren().remove(menuBorderPane);
|
||||
});
|
||||
timeline.play();
|
||||
|
||||
|
||||
|
||||
//Règles
|
||||
}*/
|
||||
|
||||
public StackPane getParentStackPane() {
|
||||
System.out.println(parentStackPane);
|
||||
return parentStackPane;
|
||||
|
@ -139,6 +175,8 @@ public class MainScreenController extends LaticeApplicationWindow{
|
|||
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);
|
||||
|
||||
}
|
||||
|
|
|
@ -47,7 +47,6 @@ public class PlayerNameInputController {
|
|||
public void validBtnClicked(MouseEvent event) {
|
||||
System.out.println("valid Button Clicked");
|
||||
|
||||
//Verifying if player's names are correct
|
||||
if(nomJoueur1.getText().length() < 3 || nomJoueur1.getText().length() > 16) {
|
||||
label1.setVisible(true);
|
||||
}
|
||||
|
@ -60,8 +59,8 @@ public class PlayerNameInputController {
|
|||
//setting player names
|
||||
String name1 = nomJoueur1.getText();
|
||||
String name2 = nomJoueur2.getText();
|
||||
System.out.println("nom des joueurs :");
|
||||
System.out.println(nomJoueur1.getText());
|
||||
System.out.println("nom des joueurs");
|
||||
System.out.println(nomJoueur2.getText());
|
||||
namePlayer1 = name1;
|
||||
namePlayer2 = name2;
|
||||
|
@ -72,7 +71,7 @@ public class PlayerNameInputController {
|
|||
mainScreenController.player1 = mainScreenController.instanciatePlayer(name1);
|
||||
mainScreenController.player2 = mainScreenController.instanciatePlayer(name2);
|
||||
|
||||
//Starting game
|
||||
//PlayerFX.displayPlayers(root ,laticeApplicationWindow.player1, laticeApplicationWindow.player2);
|
||||
mainScreenController.startGameInstruction(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ public class Constant {
|
|||
|
||||
public static final int BOX_WIDTH = 52;
|
||||
|
||||
public static final int ACTION_BUTTONS_WIDTH = 170;
|
||||
public static final int ACTION_BUTTONS_WIDTH = 120;
|
||||
|
||||
public static final int ACTION_BUTTONS_HEIGHT = 45;
|
||||
|
||||
|
|
|
@ -22,7 +22,20 @@ public class Player {
|
|||
|
||||
public Player(String name, Deck deck) {
|
||||
this(name, new Score(), deck, new Rack(deck));
|
||||
}
|
||||
}
|
||||
|
||||
/*public Player(Score score, Deck deck, Rack rack) {
|
||||
this(namePlayer,score,deck,rack);
|
||||
//Demande le nom du joueur
|
||||
Scanner enterPlayerName = new Scanner(System.in);
|
||||
System.out.println("Veuilez entrer votre nom :");
|
||||
String namePlayer = enterPlayerName.next();
|
||||
|
||||
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
|
@ -40,13 +53,13 @@ public class Player {
|
|||
return this.deck.getListTile().size() + this.rack.getListRackTile().size();
|
||||
}
|
||||
|
||||
public Integer addPointsToScore(Integer value) {
|
||||
public Integer addScore(Integer value) {
|
||||
int newScore = this.score.getScore()+value;
|
||||
this.score.setScore(newScore);
|
||||
return this.score.getScore();
|
||||
}
|
||||
|
||||
public Integer removePointsFromScore(Integer value) {
|
||||
public Integer diffScore(Integer value) {
|
||||
int newScore = this.score.getScore()-value;
|
||||
this.score.setScore(newScore);
|
||||
return this.score.getScore();
|
||||
|
@ -63,7 +76,7 @@ public class Player {
|
|||
|
||||
}
|
||||
|
||||
System.out.print("Quelle tuile voulez-vous jouez ? ");
|
||||
System.out.print("Quel tuile voulez-vous jouez ? ");
|
||||
this.rack.displayRack();
|
||||
Integer idTileToPlay = Integer.parseInt(play.next())-1;
|
||||
Tile tileToPlay = this.rack.getListRackTile().get(idTileToPlay);
|
||||
|
@ -75,6 +88,12 @@ public class Player {
|
|||
tileToPlay.setPosition(new Position(row, column));
|
||||
return tileToPlay;
|
||||
|
||||
//.setGridBoard(" "+tileToPlay.getShapeConsole()+tileToPlay.getColorConsole()+" ", row, column);
|
||||
//this.rack.removeTile(tileToPlay);
|
||||
|
||||
//board.displayGameBoard();
|
||||
|
||||
//this.rack.updateRack();
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -6,9 +6,10 @@ import java.util.regex.Pattern;
|
|||
import latice.model.console.GameBoard;
|
||||
|
||||
public class Rules {
|
||||
//private static boolean START = true;
|
||||
|
||||
public Rules() {
|
||||
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
public Boolean moonRule(GameBoard board, Tile tile) {
|
||||
|
@ -110,38 +111,32 @@ public class Rules {
|
|||
return this.moonRule(board, tile);
|
||||
}else {
|
||||
System.out.println("-----------------------------");
|
||||
if (this.checkPositionRule(board, tile) == false ) {
|
||||
System.out.println("Erreur ! la tuile ne peut pas être placé ici car il y a déjà une tuile placé");
|
||||
if (this.sunRule(board, tile)){
|
||||
player.addScore(2);
|
||||
}
|
||||
int nbr = this.neighborRule(board, tile);
|
||||
if (nbr == 0) {
|
||||
System.out.println("l'emplacement où est posé la tuile n'a pas de voisin ou il n'y a pas de correspondance avec les voisins !");
|
||||
return false;
|
||||
|
||||
}else {
|
||||
int nbr = this.neighborRule(board, tile);
|
||||
if (nbr == 0) {
|
||||
System.out.println("Erreur ! L'emplacement où est posé la tuile n'a pas de voisin ou il n'y a pas de correspondance avec les voisins !");
|
||||
return false;
|
||||
|
||||
}else {
|
||||
if (nbr == 2) {
|
||||
System.out.println("Vous avez gagné 1 point");
|
||||
player.addPointsToScore(1);
|
||||
}else if (nbr == 3) {
|
||||
System.out.println("Vous avez gagné 2 points");
|
||||
player.addPointsToScore(2);
|
||||
}else if (nbr == 4) {
|
||||
System.out.println("Vous avez gagné 4 points");
|
||||
player.addPointsToScore(4);
|
||||
}
|
||||
|
||||
if (this.sunRule(board, tile)){
|
||||
player.addPointsToScore(2);
|
||||
}
|
||||
if (nbr == 2) {
|
||||
System.out.println("Vous avez gagné 1 point");
|
||||
player.addScore(1);
|
||||
}else if (nbr == 3) {
|
||||
System.out.println("Vous avez gagné 2 points");
|
||||
player.addScore(2);
|
||||
}else if (nbr == 4) {
|
||||
System.out.println("Vous avez gagné 4 points");
|
||||
player.addScore(4);
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ public class GameBoard {
|
|||
|
||||
for (int i = 0; i < DIMENSION; i++) {
|
||||
for (int j = 0; j < DIMENSION; j++) {
|
||||
|
||||
System.out.print("|");
|
||||
if (i == 4 && j == 4) { //Affiche la lune au centre du plateau
|
||||
|
||||
this.gridBoard[i][j] = MOON;
|
||||
|
@ -38,41 +38,43 @@ public class GameBoard {
|
|||
}else {
|
||||
this.gridBoard[i][j] = BLUE;
|
||||
}
|
||||
|
||||
|
||||
if (j == 8) {
|
||||
System.out.println("|");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void displayGameBoard() {
|
||||
System.out.println(" 1. 2. 3. 4. 5. 6. 7. 8. 9.");
|
||||
System.out.println(" ____ ____ ____ ____ ____ ____ ____ ____ ____ ");
|
||||
System.out.println(" +----+----+----+----+----+----+----+----+----+");
|
||||
for (int i = 0; i < DIMENSION; i++) {
|
||||
System.out.println(" | | | | | | | | | |");
|
||||
System.out.print(i+1 + ". ");
|
||||
for (int j = 0; j < DIMENSION; j++) {
|
||||
System.out.print("|");
|
||||
if (i == 4 && j == 4) { //display moon in the center of the board
|
||||
if (i == 4 && j == 4) { //Affiche la lune au centre du plateau
|
||||
if (this.gridBoardTile[i][j] == null) {
|
||||
System.out.print(this.gridBoard[i][j]);
|
||||
}else {
|
||||
System.out.print(" " + this.gridBoardTile[i][j].getShapeConsole() + this.gridBoardTile[i][j].getColorConsole() + " ");
|
||||
}
|
||||
|
||||
}else if (i == j && (i <= 2 || i >= 6)) { //display the diagonal ('\') of the sun
|
||||
}else if (i == j && (i <= 2 || i >= 6)) { //Affiche la diagonale ('\') de soleil
|
||||
if (this.gridBoardTile[i][j] == null) {
|
||||
System.out.print(this.gridBoard[i][j]);
|
||||
}else {
|
||||
System.out.print(" " + this.gridBoardTile[i][j].getShapeConsole() + this.gridBoardTile[i][j].getColorConsole() + " ");
|
||||
}
|
||||
|
||||
}else if (i == DIMENSION-1-j && (i <= 2 || i >= 6)) { //display the diagonal ('/') of the sun
|
||||
}else if (i == DIMENSION-1-j && (i <= 2 || i >= 6)) { //Affiche la diagonale ('/') de soleil
|
||||
if (this.gridBoardTile[i][j] == null) {
|
||||
System.out.print(this.gridBoard[i][j]);
|
||||
}else {
|
||||
System.out.print(" " + this.gridBoardTile[i][j].getShapeConsole() + this.gridBoardTile[i][j].getColorConsole() + " ");
|
||||
}
|
||||
|
||||
}else if ( ((i == 0 || i == 8)&& j == 4) || (i== 4 && (j == 0 || j == 8)) ) {//display the suns at the middle of each side ('+')
|
||||
}else if ( ((i == 0 || i == 8)&& j == 4) || (i== 4 && (j == 0 || j == 8)) ) {//Affiche les soleils au mileu de chaque coté ('+')
|
||||
if (this.gridBoardTile[i][j] == null) {
|
||||
System.out.print(this.gridBoard[i][j]);
|
||||
}else {
|
||||
|
@ -89,7 +91,7 @@ public class GameBoard {
|
|||
|
||||
if (j == 8) {
|
||||
System.out.println("|");
|
||||
System.out.println(" |____|____|____|____|____|____|____|____|____|");
|
||||
System.out.println(" +----+----+----+----+----+----+----+----+----+");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ public class Rack {
|
|||
|
||||
Tile tile;
|
||||
|
||||
//System.out.println("Il y a dans le rack : " + listRackTile.size() + " valeurs");
|
||||
System.out.println("Il y a dans le rack : " + listRackTile.size() + " valeurs");
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
int index = (int)(Math.random()*(((this.deck.getListTile()).size()-1)-0+1)+0); //(int)(Math.random()*(max-min+1)+min);
|
||||
|
@ -28,10 +28,16 @@ public class Rack {
|
|||
tile = (this.deck.getListTile()).get(index);
|
||||
this.listRackTile.add(tile);
|
||||
this.deck.getListTile().remove(index);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
//System.out.println("Il y a dans le rack : " + this.listRackTile.size() + " valeurs");
|
||||
System.out.println("Il y a dans le rack : " + this.listRackTile.size() + " valeurs");
|
||||
}
|
||||
|
||||
public ArrayList<Tile> getListRackTile() {
|
||||
|
@ -46,7 +52,7 @@ public class Rack {
|
|||
public void updateRack() {
|
||||
|
||||
Tile tile;
|
||||
//System.out.println("nomdre de tuile dans le rack : " + this.listRackTile.size());
|
||||
System.out.println("nomdre de tuile dans le rack : " + this.listRackTile.size());
|
||||
for (int i = this.listRackTile.size(); i < 5 ; i++) {
|
||||
int index = (int)(Math.random()*( ((this.deck.getListTile()).size()-1)-0+1)+0); //(int)(Math.random()*(max-min+1)+min);
|
||||
|
||||
|
@ -158,5 +164,11 @@ public class Rack {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// TODO add method(s) javafx
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,264 @@
|
|||
package latice.model.window;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.geometry.Insets;
|
||||
import javafx.geometry.Pos;
|
||||
import javafx.scene.control.Button;
|
||||
import javafx.scene.control.Label;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.scene.image.ImageView;
|
||||
import javafx.scene.input.ClipboardContent;
|
||||
import javafx.scene.input.DragEvent;
|
||||
import javafx.scene.input.Dragboard;
|
||||
import javafx.scene.input.MouseEvent;
|
||||
import javafx.scene.input.TransferMode;
|
||||
import javafx.scene.layout.Background;
|
||||
import javafx.scene.layout.BackgroundImage;
|
||||
import javafx.scene.layout.BackgroundPosition;
|
||||
import javafx.scene.layout.BackgroundRepeat;
|
||||
import javafx.scene.layout.BackgroundSize;
|
||||
import javafx.scene.layout.BorderPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.Pane;
|
||||
import javafx.scene.layout.StackPane;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.scene.paint.ImagePattern;
|
||||
import javafx.scene.shape.Rectangle;
|
||||
import javafx.scene.text.Font;
|
||||
import javafx.scene.text.FontWeight;
|
||||
import javafx.scene.text.Text;
|
||||
import javafx.stage.Stage;
|
||||
import latice.model.Color;
|
||||
import latice.model.Player;
|
||||
import latice.model.Shape;
|
||||
import latice.model.Tile;
|
||||
import latice.model.console.Deck;
|
||||
import latice.model.console.Rack;
|
||||
|
||||
public class PlayGame {
|
||||
|
||||
Image image = new Image("backgroundLatice.png");
|
||||
ImageView imageView = new ImageView(image);
|
||||
|
||||
Tile blueBird = new Tile(Color.NAVYBLUE, Shape.BIRD);
|
||||
Tile greenLeaf = new Tile(Color.GREEN, Shape.FEATHER);
|
||||
Tile redFlower = new Tile(Color.RED, Shape.FLOWER);
|
||||
|
||||
ArrayList<Tile> listRackTile;
|
||||
ArrayList<Image> listTileImage;
|
||||
ArrayList<Tile> listOfTile = new ArrayList<Tile>();
|
||||
Map<Rectangle, Tile> assocRectangleTile = new HashMap<Rectangle, Tile>();
|
||||
static StackPane rootLayout;
|
||||
private Label namePlayer1 = new Label("Anonyme");
|
||||
private Label namePlayer2 = new Label("Anonyme");
|
||||
|
||||
public static int indexTileClicked;
|
||||
|
||||
|
||||
//settings players
|
||||
public Player player1;
|
||||
public Player player2;
|
||||
|
||||
//root layout
|
||||
BorderPane borderPane = new BorderPane();
|
||||
|
||||
//StackPane for background image + BorderPane root onto it
|
||||
StackPane root = new StackPane();
|
||||
|
||||
static Stage primaryStageCopy;
|
||||
|
||||
|
||||
int confirmBtnClickedCount;
|
||||
|
||||
public Stage playGame(Stage StageToGame) {
|
||||
//--------------------------------------------------------------------------------------
|
||||
//Title
|
||||
Text title = new Text("Latice");
|
||||
title.setFont(new Font(30));
|
||||
borderPane.setTop(title);
|
||||
borderPane.setAlignment(title, Pos.CENTER);
|
||||
//--------------------------------------------------------------------------------------
|
||||
//Image
|
||||
Pane pane = new Pane();
|
||||
BackgroundImage myBG= new BackgroundImage(image,
|
||||
BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.CENTER,
|
||||
BackgroundSize.DEFAULT);
|
||||
root.setBackground(new Background(myBG));
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
//--------------------------------------------------------------------------------------
|
||||
//###################### creating all rectangles and DragnDrop ######################//
|
||||
RectangleFX rectFX = new RectangleFX();
|
||||
rectFX.createRectangle(borderPane, pane);
|
||||
rectFX.dragnDropOnAllRectangles(player1, indexTileClicked, confirmBtnClickedCount);
|
||||
rectFX.dragnDropOnAllRectangles(player2, indexTileClicked, confirmBtnClickedCount);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
borderPane.setCenter(pane);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
//Rack
|
||||
HBox rackBox = new HBox();
|
||||
|
||||
rackBox.setSpacing(10);
|
||||
rackBox.setPadding(new Insets(15,20, 10,10));
|
||||
|
||||
|
||||
//Creating tiles
|
||||
for (Color color : Color.values()) {
|
||||
for (Shape shape : Shape.values()) {
|
||||
Tile tile = new Tile(color, shape);
|
||||
|
||||
listOfTile.add(tile);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
System.out.println("-----------------");
|
||||
System.out.println("Notre Deck :");
|
||||
Deck deck = new Deck(listOfTile);
|
||||
System.out.println("-----------------");
|
||||
Rack rack = new Rack(deck);
|
||||
System.out.println("-----------------");
|
||||
//deck.displayListTile();
|
||||
|
||||
|
||||
|
||||
//Confirm Button
|
||||
Image checkMark = new Image("checkMark.png");
|
||||
ImageView checkMarkView = new ImageView(checkMark);
|
||||
Button confirmButton = new Button("Confirm", checkMarkView);
|
||||
|
||||
confirmButton.setOnMouseClicked(new EventHandler<MouseEvent>() {
|
||||
|
||||
@Override
|
||||
public void handle(MouseEvent arg0) {
|
||||
|
||||
confirmBtnClickedCount++;
|
||||
System.out.println("confirmed placement");
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
//With Image
|
||||
Rack rack2 = new Rack(deck);
|
||||
HBox rackImage = rack2.createTileImage();
|
||||
rackImage.getChildren().add(confirmButton);
|
||||
rackImage.setMargin(rackImage.getChildren().get(4), new Insets(0,150,0,0));
|
||||
borderPane.setBottom(rackImage);
|
||||
|
||||
//Adding lists to Arraylists
|
||||
listRackTile = rack2.getListRackTile();
|
||||
System.out.println(listRackTile);
|
||||
listTileImage = rack2.getRackTileImage();
|
||||
System.out.println("listTileImge : " + listTileImage);
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
|
||||
//Setting OnDragDetected on tiles
|
||||
setDragnDropOnRack(rackImage);
|
||||
|
||||
System.out.println((indexTileClicked));
|
||||
ImagePattern imagePattern = new ImagePattern(listTileImage.get(indexTileClicked));
|
||||
|
||||
|
||||
|
||||
//rules / referee implementaion
|
||||
|
||||
this.transition(namePlayer1, namePlayer2);
|
||||
//root.setLeft(namePlayer1);
|
||||
|
||||
//###################### display name, score and deck of each player ######################//
|
||||
HBox players = new HBox();
|
||||
|
||||
ArrayList<Player> allPlayers = new ArrayList<>();
|
||||
allPlayers.add(player1);
|
||||
allPlayers.add(player2);
|
||||
|
||||
for (Player nameplayer : allPlayers ) {
|
||||
VBox player = new VBox();
|
||||
|
||||
Text name = new Text();
|
||||
name.setFont(Font.font("Anonyme", FontWeight.BOLD, 20));
|
||||
name.setText("Anonyme");
|
||||
|
||||
Text score = new Text();
|
||||
score.setText("Score : " + nameplayer.getScore());
|
||||
|
||||
Text nbrOfTiles = new Text();
|
||||
nbrOfTiles.setText("Tuiles restantes : " + nameplayer.getNumberOfTilesRemaining());
|
||||
|
||||
player.getChildren().addAll(name, score, nbrOfTiles);
|
||||
player.setSpacing(5);
|
||||
|
||||
players.getChildren().add(player);
|
||||
players.setMargin(player, new Insets(50,0,0,55));
|
||||
}
|
||||
System.out.println("largeur : " + borderPane.getMaxWidth());
|
||||
players.setSpacing(850);
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
setPrimaryStage(StageToGame);
|
||||
setRootLayout(root);
|
||||
root.getChildren().addAll(players, borderPane);
|
||||
|
||||
return StageToGame;
|
||||
|
||||
}
|
||||
|
||||
public void transition(Label player1, Label player2) {
|
||||
|
||||
borderPane.setLeft(player1);
|
||||
borderPane.setRight(player2);
|
||||
}
|
||||
|
||||
public void setPrimaryStage(Stage primaryStage) {
|
||||
this.primaryStageCopy = primaryStage;
|
||||
}
|
||||
|
||||
public static void setRootLayout(StackPane root) {
|
||||
rootLayout = root;
|
||||
}
|
||||
|
||||
private void setDragnDropOnRack(HBox rackImage) {
|
||||
for (int i=0; i<5; i++) {
|
||||
int index = i;
|
||||
rackImage.getChildren().get(index).setOnDragDetected(new EventHandler<MouseEvent>() {
|
||||
|
||||
@Override
|
||||
public void handle(MouseEvent arg0) {
|
||||
Dragboard dragboard = rackImage.getChildren().get(index).startDragAndDrop(TransferMode.ANY);
|
||||
ClipboardContent content = new ClipboardContent();
|
||||
dragboard.setDragView(listTileImage.get(index));
|
||||
content.putString("Hello !");
|
||||
indexTileClicked = index;
|
||||
//setIndexTileClicked(index);
|
||||
dragboard.setContent(content);
|
||||
arg0.consume();
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
rackImage.getChildren().get(index).setOnDragDone(new EventHandler<DragEvent>() {
|
||||
|
||||
@Override
|
||||
public void handle(DragEvent arg0) {
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -19,44 +19,51 @@ public class PlayerFX {
|
|||
private VBox infoPlayer;
|
||||
|
||||
public VBox displayPlayers(StackPane root, Player player) {
|
||||
//-------------- display name, score and deck of each player ---------------//
|
||||
|
||||
this.infoPlayer = new VBox();
|
||||
//###################### display name, score and deck of each player ######################//
|
||||
//HBox players = new HBox();
|
||||
|
||||
this.name = new Text();
|
||||
this.name.setFont(Font.font(player.getName(), FontWeight.BOLD, 20));
|
||||
this.name.setText(player.getName());
|
||||
//ArrayList<Player> allPlayers = new ArrayList<>();
|
||||
//allPlayers.add(player1);
|
||||
//allPlayers.add(player2);
|
||||
|
||||
this.score = new Text();
|
||||
this.score.setText("Score : " + player.getScore());
|
||||
|
||||
this.nbrOfTiles = new Text();
|
||||
this.nbrOfTiles.setText("Tuiles restantes : " + player.getNumberOfTilesRemaining());
|
||||
|
||||
this.infoPlayer.getChildren().addAll(name, score, nbrOfTiles);
|
||||
this.infoPlayer.setSpacing(5);
|
||||
//for (Player namePlayer : allPlayers ) {
|
||||
this.infoPlayer = new VBox();
|
||||
|
||||
this.name = new Text();
|
||||
this.name.setFont(Font.font(player.getName(), FontWeight.BOLD, 20));
|
||||
this.name.setText(player.getName());
|
||||
|
||||
this.score = new Text();
|
||||
this.score.setText("Score : " + player.getScore());
|
||||
|
||||
this.nbrOfTiles = new Text();
|
||||
this.nbrOfTiles.setText("Tuiles restantes : " + player.getNumberOfTilesRemaining());
|
||||
|
||||
this.infoPlayer.getChildren().addAll(name, score, nbrOfTiles);
|
||||
this.infoPlayer.setSpacing(5);
|
||||
|
||||
//players.getChildren().add(infoPlayer);
|
||||
//players.setMargin(infoPlayer, new Insets(50,0,0,55));
|
||||
//}
|
||||
|
||||
//players.setSpacing(850);
|
||||
return this.infoPlayer;
|
||||
}
|
||||
|
||||
//setting the player's nickname who plays in red
|
||||
public void setFillName(javafx.scene.paint.Color color) {
|
||||
name.setFill(color);
|
||||
}
|
||||
|
||||
//adding points to player
|
||||
public void setAddPointsToScore(Player player, Integer score) {
|
||||
player.addPointsToScore(score);
|
||||
public void setAddScore(Player player, Integer score) {
|
||||
player.addScore(score);
|
||||
this.score.setText("Score : " + player.getScore());
|
||||
}
|
||||
|
||||
//Removing points from player
|
||||
public void setRemovePointsFromScore(Player player, Integer score) {
|
||||
player.removePointsFromScore(score);
|
||||
public void setDiffScore(Player player, Integer score) {
|
||||
player.diffScore(score);
|
||||
this.score.setText("Score : " + player.getScore());
|
||||
}
|
||||
|
||||
//Setting the tiles remaining
|
||||
public void setTilesRemaining(Player player) {
|
||||
this.nbrOfTiles.setText("Tuiles restantes : " + player.getNumberOfTilesRemaining());
|
||||
}
|
||||
|
|
|
@ -13,9 +13,9 @@
|
|||
<image>
|
||||
<Image url="@/gameFinishedImage.png" />
|
||||
</image></ImageView>
|
||||
<Label fx:id="nameWinner" alignment="CENTER_RIGHT" layoutX="274.0" layoutY="236.0" prefHeight="51.0" prefWidth="488.0" textAlignment="CENTER" textFill="WHITE">
|
||||
<Label fx:id="nameWinner" alignment="CENTER_RIGHT" layoutX="453.0" layoutY="247.0" prefHeight="22.0" prefWidth="300.0" textAlignment="CENTER">
|
||||
<font>
|
||||
<Font name="Verdana" size="40.0" />
|
||||
<Font name="Bell MT" size="40.0" />
|
||||
</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="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,22 +7,17 @@ import java.util.ArrayList;
|
|||
|
||||
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.Player;
|
||||
import latice.model.Position;
|
||||
import latice.model.Rules;
|
||||
import latice.model.Shape;
|
||||
import latice.model.Tile;
|
||||
import latice.model.console.Deck;
|
||||
import latice.model.console.GameBoard;
|
||||
import latice.model.console.Rack;
|
||||
import latice.model.console.Score;
|
||||
|
||||
class LaticeTest {
|
||||
|
||||
|
||||
//VEUILLEZ SAISIR Marc COMME NOM DU JOUEUR DANS LA CONSOLE
|
||||
|
||||
|
||||
|
@ -207,276 +202,26 @@ class LaticeTest {
|
|||
assertEquals(0, player.getScore());
|
||||
assertEquals(rack, player.getRack());
|
||||
|
||||
player.addPointsToScore(2);
|
||||
player.addScore(2);
|
||||
assertEquals(2, player.getScore());
|
||||
|
||||
player.removePointsFromScore(1);
|
||||
player.diffScore(1);
|
||||
assertEquals(1, player.getScore());
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Test
|
||||
void should_create_tile_image() {
|
||||
/*@Test
|
||||
void () {
|
||||
//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
|
||||
|
||||
//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