UPDATE Constant, PlayerFX, Rack, Rules

master
Mathis 2022-06-03 21:10:30 +02:00
parent 933340b2ef
commit afe085a20e
4 changed files with 55 additions and 34 deletions

View File

@ -1,7 +1,7 @@
package latice.model;
public class Constant {
//
//for the start of the game
public static Boolean START = true;
//for creating rectangles
@ -11,7 +11,7 @@ public class Constant {
public static final int RECTANGLE_WIDTH = 50;
public static final int Y_CENTER = 37;
public static final int Y_CENTER = 6;
public static final int X_CENTER = 355;
@ -24,4 +24,7 @@ public class Constant {
//Color
public static javafx.scene.paint.Color realColor = new javafx.scene.paint.Color(0, 0, 0, 0);
//Dimension width and height of the Latice plateau
public static final int DIMENSION = 9;
}

View File

@ -26,32 +26,35 @@ public class Rules {
public Integer neighborRule(GameBoard board, Tile tile) {
Integer nbrNeighbor = 0;
String checkNeighbor = null;
Tile checkNeighbor = null;
Boolean checkCase = false;
Boolean badNeighbor = false;
for(int i = 0; i < 2 ; i++) {
for(int j = -1; j < 2 ; j=j+2) {
if (i == 0) {
if (tile.getPositionColumn()+j >= 0 && tile.getPositionColumn()+j <= 9) {
checkNeighbor = board.getGridBoard()[tile.getPositionRow()][tile.getPositionColumn()+j];
if (tile.getPositionRow() >= 0 && tile.getPositionColumn()+j <= 9) {
checkNeighbor = board.getGridBoardTile()[tile.getPositionRow()][tile.getPositionColumn()+j];
checkCase = true;
}
}else {
if (tile.getPositionRow()+j >= 0 && tile.getPositionRow()+j <= 9) {
checkNeighbor = board.getGridBoard()[tile.getPositionRow()+j][tile.getPositionColumn()];
if (tile.getPositionRow()+j >= 0 && tile.getPositionColumn() <= 9) {
checkNeighbor = board.getGridBoardTile()[tile.getPositionRow()+j][tile.getPositionColumn()];
checkCase = true;
}
}
if (checkCase) {
if (!(GameBoard.SUN.equals(checkNeighbor)) || !(GameBoard.BLUE.equals(checkNeighbor))) {
if ( checkNeighbor != null) {
System.out.println("Il y a une tuile");
if ( tile.getShapeConsole().equals(checkNeighbor.substring(1, 2)) || tile.getColorConsole().equals(checkNeighbor.substring(2, 3)) ) {
if ( tile.getShape() == checkNeighbor.getShape() || tile.getColor() == checkNeighbor.getColor() ) {
System.out.println("Il y a correspondance avec la tuile !");
nbrNeighbor = nbrNeighbor + 1;
}else {
badNeighbor = true;
System.out.println("Il n'y a pas correspondance avec la tuile !");
}
@ -60,9 +63,12 @@ public class Rules {
}
}
if (badNeighbor) {
return 0;
}else {
return nbrNeighbor;
}
}
public Boolean sunRule(GameBoard board, Tile tile) {

View File

@ -134,13 +134,15 @@ public class Rack {
int index;
HBox rack = new HBox();
rackTileImage.clear();
for (int i = 0; i < 5; i++) {
for (int i = 0; i < this.getListRackTile().size(); i++) {
index = i;
tile = (this.getListRackTile()).get(index);
image = new Image(tile.getShape().getStringShape() + "_" + tile.getColor().getStringColor()+ ".png");
rackTileImage.add(image);
imageView = new ImageView(image);
imageView.setFitHeight(80);

View File

@ -6,44 +6,54 @@ import javafx.geometry.Insets;
import javafx.scene.layout.HBox;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import latice.model.Player;
public class PlayerFX {
private Text name;
private Text score;
private Text nbrOfTiles;
private VBox infoPlayer;
public static HBox displayPlayers(StackPane root, Player player1, Player player2) {
public VBox displayPlayers(StackPane root, Player player) {
//###################### display name, score and deck of each player ######################//
HBox players = new HBox();
//HBox players = new HBox();
ArrayList<Player> allPlayers = new ArrayList<>();
allPlayers.add(player1);
allPlayers.add(player2);
//ArrayList<Player> allPlayers = new ArrayList<>();
//allPlayers.add(player1);
//allPlayers.add(player2);
for (Player namePlayer : allPlayers ) {
VBox player = new VBox();
//for (Player namePlayer : allPlayers ) {
infoPlayer = new VBox();
Text name = new Text();
name.setFont(Font.font(namePlayer.getName(), FontWeight.BOLD, 20));
name.setText(namePlayer.getName());
name = new Text();
name.setFont(Font.font(player.getName(), FontWeight.BOLD, 20));
name.setText(player.getName());
Text score = new Text();
score.setText("Score : " + namePlayer.getScore());
score = new Text();
score.setText("Score : " + player.getScore());
Text nbrOfTiles = new Text();
nbrOfTiles.setText("Tuiles restantes : " + namePlayer.getNumberOfTilesRemaining());
nbrOfTiles = new Text();
nbrOfTiles.setText("Tuiles restantes : " + player.getNumberOfTilesRemaining());
player.getChildren().addAll(name, score, nbrOfTiles);
player.setSpacing(5);
infoPlayer.getChildren().addAll(name, score, nbrOfTiles);
infoPlayer.setSpacing(5);
players.getChildren().add(player);
players.setMargin(player, new Insets(50,0,0,55));
//players.getChildren().add(infoPlayer);
//players.setMargin(infoPlayer, new Insets(50,0,0,55));
//}
//players.setSpacing(850);
return infoPlayer;
}
players.setSpacing(850);
return players;
public void setFillName(javafx.scene.paint.Color color) {
name.setFill(color);
}
}