UPDATE Constant LaticeApplicationConsole LaticeAplicationWindow
MainScreenController | ADD attribute to GameBoard, method getNumberOfTilesRemaining to Tilemaster
parent
596a675aaf
commit
933340b2ef
|
@ -132,19 +132,20 @@ public class LaticeApplicationConsole {
|
|||
player = player2;
|
||||
}
|
||||
|
||||
while (round) {
|
||||
System.out.println("c'est à votre tour de jouer " + player.getName() +"!");
|
||||
|
||||
while (round) {
|
||||
player.getRack().displayRack();
|
||||
System.out.println("Vous avez " + player.getScore() +" points, que voulez-vous faire ?\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 (arbitre.checkScoreToPlay(player, freeTile) == false){
|
||||
System.out.println("Il vous faut 2 points pour jouer un nouvelle tuile !!!");
|
||||
}else {
|
||||
case 1: if (freeTile) {
|
||||
Boolean rulesCheck = false;
|
||||
|
||||
while (rulesCheck == false) {
|
||||
|
@ -158,10 +159,12 @@ public class LaticeApplicationConsole {
|
|||
start = false;
|
||||
}
|
||||
|
||||
board.setGridBoard(" "+tile.getShapeConsole()+tile.getColorConsole()+" ", tile.getPositionRow(), tile.getPositionColumn());
|
||||
board.setGridBoardTile(tile, tile.getPositionRow(), tile.getPositionColumn());
|
||||
|
||||
|
||||
player.getRack().removeTile(tile);
|
||||
board.displayGameBoard();
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -170,10 +173,11 @@ public class LaticeApplicationConsole {
|
|||
if (player.getScore()>=3) {
|
||||
//Donner une action supplémentaire et enlever 3 points au joueur
|
||||
player.Play(play, board, 0);
|
||||
player.diffScore(3);
|
||||
player.diffScore(2);
|
||||
}else {
|
||||
System.out.println("Il vous faut 3 points pour acheter une nouvelle action !");
|
||||
System.out.println("Il vous faut 2 points pour acheter une nouvelle action !");
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
|
||||
|
@ -181,6 +185,7 @@ public class LaticeApplicationConsole {
|
|||
System.out.println("Votre rack à été changé avec succès !");
|
||||
|
||||
case 4: System.out.println("Votre tour est terminé " + player.getName() + " !");
|
||||
player.getRack().updateRack();
|
||||
round = false;
|
||||
break;
|
||||
|
||||
|
@ -189,43 +194,23 @@ public class LaticeApplicationConsole {
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
if (PlayOrPass == 2) {
|
||||
round = false;
|
||||
System.out.println("Votre tour est terminé " + player.getName() + " !");
|
||||
System.out.println("-------------------------------------------------------------------------------------------");
|
||||
|
||||
if (player1.getNumberOfTilesRemaining() < player2.getNumberOfTilesRemaining()) {
|
||||
System.out.println("-------------- Félicitations" + player1.getName() + " pour votre victoire !! --------------");
|
||||
System.out.println("-------------- Nos condoléances " + player2.getName() + " pour votre victoire !! --------------");
|
||||
System.out.println("Le gagnant de la partie est " + player1.getName() + " car il a posé le plus de tuiles sur le plateau Latice !!");
|
||||
System.out.println(player2.getName() + ", vous êtes tombés sur un joueur plus fort que vous. Réentrainez-vous pour pouvoir prendre votre vengeance hehe");
|
||||
|
||||
}else if (player2.getNumberOfTilesRemaining() < player1.getNumberOfTilesRemaining()){
|
||||
System.out.println("-------------- Félicitations" + player2.getName() + " pour votre victoire !! --------------");
|
||||
System.out.println("-------------- Nos condoléances " + player1.getName() + " pour votre victoire !! --------------");
|
||||
System.out.println("Le gagnant de la partie est " + player2.getName() + " car il a posé le plus de tuiles sur le plateau Latice !!");
|
||||
System.out.println(player1.getName() + ", vous êtes tombés sur un joueur plus fort que vous. Réentrainez-vous pour pouvoir prendre votre vengeance hehe");
|
||||
}else {
|
||||
System.out.println("Match nul !! Recommencez une partie si vous voulez vous départagez !!");
|
||||
}
|
||||
|
||||
while (round) {
|
||||
Boolean rulesCheck = false;
|
||||
|
||||
System.out.println("c'est à votre tour de jouer " + player.getName() +"!");
|
||||
|
||||
while (rulesCheck == false) {
|
||||
tile = player.Play(play,board,i);
|
||||
rulesCheck = arbitre.arbitration(player, board, tile, START);
|
||||
|
||||
};
|
||||
|
||||
if (i == 0) {
|
||||
START = false;
|
||||
}
|
||||
|
||||
board.setGridBoard(" "+tile.getShapeConsole()+tile.getColorConsole()+" ", tile.getPositionRow(), tile.getPositionColumn());
|
||||
|
||||
player.getRack().removeTile(tile);
|
||||
board.displayGameBoard();
|
||||
|
||||
|
||||
System.out.println(player.getName() + " ! Voulez-vous passer votre tour ou continuer à jouer ? 1.continuer ou 2.passer");
|
||||
int ContinueOrPass = Integer.parseInt(play.next());
|
||||
if (ContinueOrPass == 2) {
|
||||
round = false;
|
||||
System.out.println("Votre tour est terminé " + player.getName() + " !");
|
||||
}
|
||||
}
|
||||
|
||||
player.getRack().updateRack();*/
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,10 +4,11 @@ import java.util.ArrayList;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javafx.animation.Interpolator;
|
||||
import javafx.animation.KeyFrame;
|
||||
import javafx.animation.KeyValue;
|
||||
import javafx.animation.Timeline;
|
||||
import javafx.application.Application;
|
||||
import javafx.beans.binding.Bindings;
|
||||
import javafx.beans.property.SimpleStringProperty;
|
||||
import javafx.beans.property.StringProperty;
|
||||
import javafx.event.EventHandler;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.geometry.Insets;
|
||||
|
@ -36,25 +37,24 @@ 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 javafx.util.Duration;
|
||||
import latice.controller.MainScreenController;
|
||||
import latice.controller.PlayerNameInputController;
|
||||
import latice.model.Color;
|
||||
import latice.model.Constant;
|
||||
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;
|
||||
import latice.model.window.PlayerFX;
|
||||
import latice.model.window.RectangleFX;
|
||||
|
||||
public class LaticeApplicationWindow extends Application {
|
||||
|
||||
javafx.scene.paint.Color realColor = new javafx.scene.paint.Color(0, 0, 0, 0);
|
||||
|
||||
Image image = new Image("backgroundLatice.png");
|
||||
ImageView imageView = new ImageView(image);
|
||||
|
@ -81,6 +81,7 @@ public class LaticeApplicationWindow extends Application {
|
|||
//StackPane for background image + BorderPane onto it
|
||||
StackPane root = new StackPane();
|
||||
|
||||
|
||||
static Stage primaryStageCopy;
|
||||
StackPane parentStackPane = new StackPane();
|
||||
Label moonErrorLabel = new Label();
|
||||
|
@ -99,8 +100,46 @@ public class LaticeApplicationWindow extends Application {
|
|||
public void start(Stage primaryStage) throws Exception{
|
||||
Parent loader = FXMLLoader.load(getClass().getResource("../view/MainScreen.fxml"));
|
||||
Scene menu = new Scene(loader, 1280, 720);
|
||||
|
||||
MainScreenController MSC = new MainScreenController();
|
||||
|
||||
parentStackPane = MSC.getParentStackPane();
|
||||
|
||||
setPrimaryStage(primaryStageCopy);
|
||||
|
||||
setRootLayout(root);
|
||||
|
||||
primaryStage.setResizable(false);
|
||||
primaryStage.setTitle("Latice");
|
||||
primaryStage.setScene(menu);
|
||||
primaryStage.show();
|
||||
|
||||
}
|
||||
|
||||
public void startGame(Stage stage, StackPane parentStackPaneStock, Player player1, Player player2, Object menuBorderPane) {
|
||||
parentStackPane = parentStackPaneStock;
|
||||
//StackPane root = getRootLayout();
|
||||
//root.translateYProperty().set(stage.getHeight());
|
||||
System.out.println(parentStackPane);
|
||||
System.out.println(parentStackPaneStock);
|
||||
parentStackPane.getChildren().add(root);
|
||||
|
||||
|
||||
//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();
|
||||
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
//Title
|
||||
VBox topVbox = new VBox();
|
||||
|
@ -109,7 +148,7 @@ public class LaticeApplicationWindow extends Application {
|
|||
topVbox.getChildren().add(title);
|
||||
topVbox.setAlignment(Pos.CENTER);
|
||||
moonErrorLabel.setFont(new Font(20));
|
||||
moonErrorLabel.setTextFill(realColor.RED);
|
||||
moonErrorLabel.setTextFill(Constant.realColor.RED);
|
||||
topVbox.getChildren().add(moonErrorLabel);
|
||||
borderPane.setTop(topVbox);
|
||||
|
||||
|
@ -122,16 +161,16 @@ public class LaticeApplicationWindow extends Application {
|
|||
|
||||
//--------------------------------------------------------------------------------------
|
||||
//Creating rectangle for tiles placement
|
||||
Rectangle[][] r = new Rectangle[9][9];
|
||||
Rectangle[][] rect = new Rectangle[9][9];
|
||||
int counterI = 0;
|
||||
int counterJ = 0;
|
||||
for (int i=1; i<=Constant.NUMBER_OF_BOX_ON_ONE_LINE ; i++) {
|
||||
for (int j=1; j <= Constant.NUMBER_OF_BOX_ON_ONE_LINE ; j++) {
|
||||
|
||||
r[counterI][counterJ] = new Rectangle(i*Constant.BOX_WIDTH+Constant.X_CENTER,j*Constant.BOX_WIDTH+Constant.Y_CENTER,Constant.RECTANGLE_WIDTH,Constant.RECTANGLE_HEIGHT);
|
||||
r[counterI][counterJ].setFill(realColor.TRANSPARENT);
|
||||
pane.getChildren().add(r[counterI][counterJ]);
|
||||
System.out.println(r[counterI][counterJ]);
|
||||
rect[counterI][counterJ] = new Rectangle(i*Constant.BOX_WIDTH+Constant.X_CENTER,j*Constant.BOX_WIDTH+Constant.Y_CENTER,Constant.RECTANGLE_WIDTH,Constant.RECTANGLE_HEIGHT);
|
||||
rect[counterI][counterJ].setFill(Constant.realColor.TRANSPARENT);
|
||||
pane.getChildren().add(rect[counterI][counterJ]);
|
||||
System.out.println(rect[counterI][counterJ]);
|
||||
System.out.println(counterJ);
|
||||
counterJ++;
|
||||
}
|
||||
|
@ -141,36 +180,14 @@ public class LaticeApplicationWindow extends Application {
|
|||
}
|
||||
|
||||
borderPane.setCenter(pane);
|
||||
System.out.println(r);
|
||||
System.out.println(rect);
|
||||
//--------------------------------------------------------------------------------------
|
||||
|
||||
//###################### Instantiating of players ######################///
|
||||
//create the list of all tiles
|
||||
ArrayList<Tile> listOfTile = new ArrayList<Tile>();
|
||||
for (Color color : Color.values()) {
|
||||
for (Shape shape : Shape.values()) {
|
||||
Tile tile = new Tile(color, shape);
|
||||
//System.out.println(color.getStringColor() + shape.getStringShape()+ ".png");
|
||||
//GameBoard
|
||||
GameBoard board = new GameBoard();
|
||||
|
||||
listOfTile.add(tile);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//setting decks for the 2 players
|
||||
Deck deck1 = new Deck(listOfTile);
|
||||
Deck deck2 = new Deck(listOfTile);
|
||||
|
||||
//setting player names
|
||||
StringProperty name1 = new SimpleStringProperty();
|
||||
StringProperty name2 = new SimpleStringProperty();
|
||||
//name1.bind(PlayerNameInputController.namePlayer1);
|
||||
//name2.bind(PlayerNameInputController.namePlayer2);
|
||||
|
||||
//Player player1 = new Player(namePlayer1.getText(), new Score(), deck1, new Rack(deck1));
|
||||
//Player player2 = new Player(namePlayer2.getText(), new Score(), deck2, new Rack(deck2));
|
||||
//Player player1 = MSC.instanciatePlayer(PlayerNameInputController.getNomJoueur1());
|
||||
//Player player2 = MSC.instanciatePlayer(PlayerNameInputController.getNomJoueur2());
|
||||
//Referee
|
||||
Rules referee = new Rules();
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
//Rack
|
||||
|
@ -199,6 +216,8 @@ public class LaticeApplicationWindow extends Application {
|
|||
//deck.displayListTile();
|
||||
|
||||
|
||||
//Player
|
||||
Player player = player1;
|
||||
|
||||
|
||||
//Confirm Button
|
||||
|
@ -277,7 +296,8 @@ public class LaticeApplicationWindow extends Application {
|
|||
|
||||
});
|
||||
rackImage.getChildren().addAll(confirmButton, changeButton, buyActionButton);
|
||||
root.setBottom(rackImage);
|
||||
borderPane.setBottom(rackImage);
|
||||
|
||||
|
||||
//Adding lists to Arraylists
|
||||
listRackTile = rack2.getListRackTile();
|
||||
|
@ -308,32 +328,32 @@ public class LaticeApplicationWindow extends Application {
|
|||
int a = i;
|
||||
int b = j;
|
||||
|
||||
r[a][b].setOnDragEntered(new EventHandler<DragEvent>() {
|
||||
rect[a][b].setOnDragEntered(new EventHandler<DragEvent>() {
|
||||
|
||||
@Override
|
||||
public void handle(DragEvent arg0) {
|
||||
if (arg0.getDragboard().hasString()){
|
||||
Dragboard dragboard = arg0.getDragboard();
|
||||
|
||||
r[a][b].setFill(new ImagePattern(listTileImage.get(getIndexTileClicked())));
|
||||
rect[a][b].setFill(new ImagePattern(listTileImage.get(getIndexTileClicked())));
|
||||
}
|
||||
arg0.consume();
|
||||
}
|
||||
});
|
||||
|
||||
r[a][b].setOnDragExited(new EventHandler<DragEvent>() {
|
||||
rect[a][b].setOnDragExited(new EventHandler<DragEvent>() {
|
||||
|
||||
@Override
|
||||
public void handle(DragEvent arg0) {
|
||||
if (arg0.isDropCompleted() == false) {
|
||||
r[a][b].setFill(realColor.TRANSPARENT);
|
||||
rect[a][b].setFill(Constant.realColor.TRANSPARENT);
|
||||
}
|
||||
arg0.consume();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
r[a][b].setOnDragOver(new EventHandler <DragEvent>() {
|
||||
rect[a][b].setOnDragOver(new EventHandler <DragEvent>() {
|
||||
@Override
|
||||
public void handle(DragEvent arg0) {
|
||||
arg0.acceptTransferModes(TransferMode.ANY);
|
||||
|
@ -341,31 +361,70 @@ public class LaticeApplicationWindow extends Application {
|
|||
}
|
||||
});
|
||||
|
||||
r[a][b].setOnDragDropped(new EventHandler<DragEvent>() {
|
||||
rect[a][b].setOnDragDropped(new EventHandler<DragEvent>() {
|
||||
@Override
|
||||
public void handle(DragEvent arg0) {
|
||||
System.out.println("entered");
|
||||
Dragboard dragboard = arg0.getDragboard();
|
||||
System.out.println("OK2");
|
||||
rect[a][b].setFill(new ImagePattern(listTileImage.get(getIndexTileClicked())));
|
||||
|
||||
|
||||
r[a][b].setFill(new ImagePattern(listTileImage.get(getIndexTileClicked())));
|
||||
arg0.setDropCompleted(true);
|
||||
assocRectangleTile.put(r[a][b], listRackTile.get(getIndexTileClicked()));
|
||||
System.out.println(assocRectangleTile.toString());
|
||||
System.out.println("OK");
|
||||
//assocRectangleTile.put(rect[a][b], listRackTile.get(getIndexTileClicked()));
|
||||
//System.out.println(assocRectangleTile.toString());
|
||||
moonErrorLabel.setText("");
|
||||
if (validateBtnClickedCount == 0){
|
||||
if (r[a][b] == r[4][4]) {
|
||||
if (Constant.START) {
|
||||
if (rect[a][b] == rect[4][4]) {
|
||||
System.out.println("MOON valid placement");
|
||||
//assocRectangleTile.put(rect[a][b], listRackTile.get(getIndexTileClicked()));
|
||||
|
||||
board.setGridBoardTile(listRackTile.get(getIndexTileClicked()), a, b);
|
||||
|
||||
Constant.START = false;
|
||||
}else {
|
||||
moonErrorLabel.setText("Error ! Please place the first tile on the moon");
|
||||
//removing all tiles from gameboard
|
||||
for(int i=0; i<Constant.NUMBER_OF_BOX_ON_ONE_LINE; i++) {
|
||||
for(int j=0; j<Constant.NUMBER_OF_BOX_ON_ONE_LINE; j++) {
|
||||
r[i][j].setFill(realColor.TRANSPARENT);
|
||||
}
|
||||
}
|
||||
rect[a][b].setFill(Constant.realColor.TRANSPARENT);
|
||||
|
||||
System.out.println("Please place first Tile on MOON");
|
||||
|
||||
}
|
||||
|
||||
}else {
|
||||
System.out.println("OK3");
|
||||
System.out.println("Règle effectué");
|
||||
listRackTile.get(getIndexTileClicked()).setPosition(new Position(a,b));
|
||||
int nbr = referee.neighborRule(board , listRackTile.get(getIndexTileClicked()));
|
||||
|
||||
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 !");
|
||||
rect[a][b].setFill(Constant.realColor.TRANSPARENT);
|
||||
|
||||
}else {
|
||||
if (nbr == 2) {
|
||||
System.out.println("Vous avez gagné 1 point");
|
||||
}else if (nbr == 3) {
|
||||
System.out.println("Vous avez gagné 2 points");
|
||||
}else if (nbr == 4) {
|
||||
System.out.println("Vous avez gagné 4 points");
|
||||
}
|
||||
//assocRectangleTile.put(rect[a][b], listRackTile.get(getIndexTileClicked()));
|
||||
board.setGridBoardTile(listRackTile.get(getIndexTileClicked()), a, b);
|
||||
System.out.println("tuile posé!");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -381,57 +440,25 @@ public class LaticeApplicationWindow extends Application {
|
|||
|
||||
//rules / referee implementaion
|
||||
|
||||
this.transition(namePlayer1, namePlayer2);
|
||||
//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(nameplayer.getName(), FontWeight.BOLD, 20));
|
||||
name.setText(nameplayer.getName());
|
||||
|
||||
Text score = new Text();
|
||||
score.setText("Score : ");
|
||||
|
||||
Text nbrOfTiles = new Text();
|
||||
nbrOfTiles.setText("Tuiles restantes : ");
|
||||
|
||||
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 : " + root.getMaxWidth());
|
||||
players.setSpacing(850);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
parentStackPane = MSC.getParentStackPane();
|
||||
|
||||
|
||||
|
||||
HBox players = PlayerFX.displayPlayers(parentStackPane,player1, player2);
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
setPrimaryStage(primaryStage);
|
||||
|
||||
setRootLayout(root);
|
||||
//root.getChildren().add(borderPane);
|
||||
root.getChildren().addAll(players, borderPane);
|
||||
|
||||
primaryStage.setResizable(false);
|
||||
primaryStage.setTitle("Latice");
|
||||
primaryStage.setScene(menu);
|
||||
primaryStage.show();
|
||||
|
||||
//Règles
|
||||
}
|
||||
|
||||
|
||||
|
@ -439,7 +466,6 @@ public class LaticeApplicationWindow extends Application {
|
|||
|
||||
|
||||
|
||||
|
||||
private void setDragnDropOnRack(HBox rackImage) {
|
||||
//Setting drag n drop on tiles
|
||||
for (int i=0; i<5; i++) {
|
||||
|
@ -493,28 +519,4 @@ public class LaticeApplicationWindow extends Application {
|
|||
LaticeApplicationWindow.indexTileClicked = indexTileClicked;
|
||||
}
|
||||
|
||||
/*//player names setters
|
||||
public void setNamePlayer1(String namePlayer1) {
|
||||
this.namePlayer1.setText(namePlayer1);
|
||||
}
|
||||
|
||||
public void setNamePlayer2(String namePlayer2) {
|
||||
this.namePlayer2.setText(namePlayer2);
|
||||
}*/
|
||||
|
||||
public void playerNamesEntered() {
|
||||
System.out.println("entered playNamesEntered()" + namePlayer1.getText() + " VS " + namePlayer2.getText());
|
||||
|
||||
MainScreenController MSC = new MainScreenController();
|
||||
MSC.setParentStackPane(parentStackPane);
|
||||
|
||||
primaryStageCopy.setTitle("working");
|
||||
}
|
||||
|
||||
public void transition(Label player1, Label player2) {
|
||||
|
||||
borderPane.setLeft(player1);
|
||||
borderPane.setRight(player2);
|
||||
}
|
||||
|
||||
}
|
|
@ -125,10 +125,11 @@ public class MainScreenController extends LaticeApplicationWindow{
|
|||
}
|
||||
|
||||
public void startGameInstruction() {
|
||||
startGame(mainStage);
|
||||
|
||||
startGame(mainStage, parentStackPaneStock, player1, player2, menuBorderPane);
|
||||
}
|
||||
|
||||
public void startGame(Stage stage) {
|
||||
/*public void startGame(Stage stage) {
|
||||
parentStackPane = parentStackPaneStock;
|
||||
StackPane root = getRootLayout();
|
||||
root.translateYProperty().set(stage.getHeight());
|
||||
|
@ -150,9 +151,14 @@ public class MainScreenController extends LaticeApplicationWindow{
|
|||
parentStackPane.getChildren().remove(menuBorderPane);
|
||||
});
|
||||
timeline.play();
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Règles
|
||||
}*/
|
||||
|
||||
public StackPane getParentStackPane() {
|
||||
System.out.println(parentStackPane);
|
||||
return parentStackPane;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
package latice.model;
|
||||
|
||||
public class Constant {
|
||||
//
|
||||
public static Boolean START = true;
|
||||
|
||||
//for creating rectangles
|
||||
public static final int NUMBER_OF_BOX_ON_ONE_LINE = 9;
|
||||
|
||||
|
@ -18,4 +21,7 @@ public class Constant {
|
|||
|
||||
public static final int ACTION_BUTTONS_HEIGHT = 45;
|
||||
|
||||
//Color
|
||||
public static javafx.scene.paint.Color realColor = new javafx.scene.paint.Color(0, 0, 0, 0);
|
||||
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ public class Player {
|
|||
|
||||
public Tile Play(Scanner play, GameBoard board, Integer start) {
|
||||
|
||||
if (this.getScore() == 0) {
|
||||
if (this.getScore() <= 1) {
|
||||
|
||||
System.out.println("Vous avez " + this.getScore() + " point");
|
||||
|
||||
|
@ -74,13 +74,12 @@ public class Player {
|
|||
|
||||
System.out.print("Quel tuile voulez-vous jouez ? ");
|
||||
this.rack.displayRack();
|
||||
System.out.println(1);
|
||||
Integer idTileToPlay = Integer.parseInt(play.next())-1;
|
||||
Tile tileToPlay = this.rack.getListRackTile().get(idTileToPlay);
|
||||
System.out.print("Sur quelle ligne, voulez-vous placer la tuile ?");
|
||||
int row = Integer.parseInt(play.next());
|
||||
int row = Integer.parseInt(play.next())-1;
|
||||
System.out.print("Sur quelle colonne, voulez-vous placer la tuile ?");
|
||||
int column = Integer.parseInt(play.next());
|
||||
int column = Integer.parseInt(play.next())-1;
|
||||
|
||||
tileToPlay.setPosition(new Position(row, column));
|
||||
return tileToPlay;
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
package latice.model.console;
|
||||
|
||||
import latice.model.Position;
|
||||
import latice.model.Tile;
|
||||
|
||||
public class GameBoard {
|
||||
private Integer DIMENSION = 9;
|
||||
public static final String SUN = " SU ";
|
||||
|
@ -7,6 +10,7 @@ public class GameBoard {
|
|||
public static final String BLUE = " ";
|
||||
|
||||
private String[][] gridBoard;
|
||||
private Tile[][] gridBoardTile = new Tile[DIMENSION][DIMENSION];;
|
||||
|
||||
public GameBoard() {
|
||||
this.gridBoard = new String[DIMENSION][DIMENSION];
|
||||
|
@ -43,34 +47,54 @@ public class GameBoard {
|
|||
}
|
||||
|
||||
public void displayGameBoard() {
|
||||
|
||||
System.out.println(" 1. 2. 3. 4. 5. 6. 7. 8. 9.");
|
||||
System.out.println(" +----+----+----+----+----+----+----+----+----+");
|
||||
for (int i = 0; i < DIMENSION; i++) {
|
||||
System.out.print(i+1 + ". ");
|
||||
for (int j = 0; j < DIMENSION; j++) {
|
||||
System.out.print("|");
|
||||
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)) { //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)) { //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)) ) {//Affiche les soleils au mileu de chaque coté ('+')
|
||||
|
||||
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 (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() + " ");
|
||||
}
|
||||
}
|
||||
|
||||
if (j == 8) {
|
||||
System.out.println("|");
|
||||
|
||||
System.out.println(" +----+----+----+----+----+----+----+----+----+");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -84,5 +108,15 @@ public class GameBoard {
|
|||
}
|
||||
|
||||
|
||||
public Tile[][] getGridBoardTile() {
|
||||
return gridBoardTile;
|
||||
}
|
||||
|
||||
public void setGridBoardTile(Tile tile, Integer x, Integer y) {
|
||||
tile.setPosition(new Position(x,y));
|
||||
this.gridBoardTile[x][y] = tile;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -22,18 +22,18 @@ public class PlayerFX {
|
|||
allPlayers.add(player1);
|
||||
allPlayers.add(player2);
|
||||
|
||||
for (Player nameplayer : allPlayers ) {
|
||||
for (Player namePlayer : allPlayers ) {
|
||||
VBox player = new VBox();
|
||||
|
||||
Text name = new Text();
|
||||
name.setFont(Font.font(nameplayer.getName(), FontWeight.BOLD, 20));
|
||||
name.setText(nameplayer.getName());
|
||||
name.setFont(Font.font(namePlayer.getName(), FontWeight.BOLD, 20));
|
||||
name.setText(namePlayer.getName());
|
||||
|
||||
Text score = new Text();
|
||||
score.setText("Score : ");
|
||||
score.setText("Score : " + namePlayer.getScore());
|
||||
|
||||
Text nbrOfTiles = new Text();
|
||||
nbrOfTiles.setText("Tuiles restantes : ");
|
||||
nbrOfTiles.setText("Tuiles restantes : " + namePlayer.getNumberOfTilesRemaining());
|
||||
|
||||
player.getChildren().addAll(name, score, nbrOfTiles);
|
||||
player.setSpacing(5);
|
||||
|
@ -41,7 +41,7 @@ public class PlayerFX {
|
|||
players.getChildren().add(player);
|
||||
players.setMargin(player, new Insets(50,0,0,55));
|
||||
}
|
||||
System.out.println("largeur : " + root.getMaxWidth());
|
||||
|
||||
players.setSpacing(850);
|
||||
return players;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue