UPDATE Constant, PlayerFX, Rack, Rules
parent
933340b2ef
commit
afe085a20e
|
@ -1,7 +1,7 @@
|
||||||
package latice.model;
|
package latice.model;
|
||||||
|
|
||||||
public class Constant {
|
public class Constant {
|
||||||
//
|
//for the start of the game
|
||||||
public static Boolean START = true;
|
public static Boolean START = true;
|
||||||
|
|
||||||
//for creating rectangles
|
//for creating rectangles
|
||||||
|
@ -11,7 +11,7 @@ public class Constant {
|
||||||
|
|
||||||
public static final int RECTANGLE_WIDTH = 50;
|
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;
|
public static final int X_CENTER = 355;
|
||||||
|
|
||||||
|
@ -24,4 +24,7 @@ public class Constant {
|
||||||
//Color
|
//Color
|
||||||
public static javafx.scene.paint.Color realColor = new javafx.scene.paint.Color(0, 0, 0, 0);
|
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;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,32 +26,35 @@ public class Rules {
|
||||||
public Integer neighborRule(GameBoard board, Tile tile) {
|
public Integer neighborRule(GameBoard board, Tile tile) {
|
||||||
|
|
||||||
Integer nbrNeighbor = 0;
|
Integer nbrNeighbor = 0;
|
||||||
String checkNeighbor = null;
|
Tile checkNeighbor = null;
|
||||||
Boolean checkCase = false;
|
Boolean checkCase = false;
|
||||||
|
Boolean badNeighbor = false;
|
||||||
|
|
||||||
for(int i = 0; i < 2 ; i++) {
|
for(int i = 0; i < 2 ; i++) {
|
||||||
for(int j = -1; j < 2 ; j=j+2) {
|
for(int j = -1; j < 2 ; j=j+2) {
|
||||||
if (i == 0) {
|
if (i == 0) {
|
||||||
if (tile.getPositionColumn()+j >= 0 && tile.getPositionColumn()+j <= 9) {
|
if (tile.getPositionRow() >= 0 && tile.getPositionColumn()+j <= 9) {
|
||||||
checkNeighbor = board.getGridBoard()[tile.getPositionRow()][tile.getPositionColumn()+j];
|
checkNeighbor = board.getGridBoardTile()[tile.getPositionRow()][tile.getPositionColumn()+j];
|
||||||
|
|
||||||
checkCase = true;
|
checkCase = true;
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
if (tile.getPositionRow()+j >= 0 && tile.getPositionRow()+j <= 9) {
|
if (tile.getPositionRow()+j >= 0 && tile.getPositionColumn() <= 9) {
|
||||||
checkNeighbor = board.getGridBoard()[tile.getPositionRow()+j][tile.getPositionColumn()];
|
checkNeighbor = board.getGridBoardTile()[tile.getPositionRow()+j][tile.getPositionColumn()];
|
||||||
checkCase = true;
|
checkCase = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (checkCase) {
|
if (checkCase) {
|
||||||
if (!(GameBoard.SUN.equals(checkNeighbor)) || !(GameBoard.BLUE.equals(checkNeighbor))) {
|
if ( checkNeighbor != null) {
|
||||||
|
|
||||||
System.out.println("Il y a une tuile");
|
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 !");
|
System.out.println("Il y a correspondance avec la tuile !");
|
||||||
nbrNeighbor = nbrNeighbor + 1;
|
nbrNeighbor = nbrNeighbor + 1;
|
||||||
}else {
|
}else {
|
||||||
|
badNeighbor = true;
|
||||||
System.out.println("Il n'y a pas correspondance avec la tuile !");
|
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;
|
return nbrNeighbor;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Boolean sunRule(GameBoard board, Tile tile) {
|
public Boolean sunRule(GameBoard board, Tile tile) {
|
||||||
|
|
||||||
|
|
|
@ -134,13 +134,15 @@ public class Rack {
|
||||||
int index;
|
int index;
|
||||||
|
|
||||||
HBox rack = new HBox();
|
HBox rack = new HBox();
|
||||||
|
rackTileImage.clear();
|
||||||
|
|
||||||
for (int i = 0; i < 5; i++) {
|
for (int i = 0; i < this.getListRackTile().size(); i++) {
|
||||||
index = i;
|
index = i;
|
||||||
|
|
||||||
tile = (this.getListRackTile()).get(index);
|
tile = (this.getListRackTile()).get(index);
|
||||||
|
|
||||||
image = new Image(tile.getShape().getStringShape() + "_" + tile.getColor().getStringColor()+ ".png");
|
image = new Image(tile.getShape().getStringShape() + "_" + tile.getColor().getStringColor()+ ".png");
|
||||||
|
|
||||||
rackTileImage.add(image);
|
rackTileImage.add(image);
|
||||||
imageView = new ImageView(image);
|
imageView = new ImageView(image);
|
||||||
imageView.setFitHeight(80);
|
imageView.setFitHeight(80);
|
||||||
|
|
|
@ -6,44 +6,54 @@ import javafx.geometry.Insets;
|
||||||
import javafx.scene.layout.HBox;
|
import javafx.scene.layout.HBox;
|
||||||
import javafx.scene.layout.StackPane;
|
import javafx.scene.layout.StackPane;
|
||||||
import javafx.scene.layout.VBox;
|
import javafx.scene.layout.VBox;
|
||||||
|
import javafx.scene.paint.Color;
|
||||||
import javafx.scene.text.Font;
|
import javafx.scene.text.Font;
|
||||||
import javafx.scene.text.FontWeight;
|
import javafx.scene.text.FontWeight;
|
||||||
import javafx.scene.text.Text;
|
import javafx.scene.text.Text;
|
||||||
import latice.model.Player;
|
import latice.model.Player;
|
||||||
|
|
||||||
public class PlayerFX {
|
public class PlayerFX {
|
||||||
|
private Text name;
|
||||||
|
private Text score;
|
||||||
|
private Text nbrOfTiles;
|
||||||
|
private VBox infoPlayer;
|
||||||
|
|
||||||
|
public VBox displayPlayers(StackPane root, Player player) {
|
||||||
public static HBox displayPlayers(StackPane root, Player player1, Player player2) {
|
|
||||||
//###################### display name, score and deck of each player ######################//
|
//###################### display name, score and deck of each player ######################//
|
||||||
HBox players = new HBox();
|
//HBox players = new HBox();
|
||||||
|
|
||||||
ArrayList<Player> allPlayers = new ArrayList<>();
|
//ArrayList<Player> allPlayers = new ArrayList<>();
|
||||||
allPlayers.add(player1);
|
//allPlayers.add(player1);
|
||||||
allPlayers.add(player2);
|
//allPlayers.add(player2);
|
||||||
|
|
||||||
for (Player namePlayer : allPlayers ) {
|
//for (Player namePlayer : allPlayers ) {
|
||||||
VBox player = new VBox();
|
infoPlayer = new VBox();
|
||||||
|
|
||||||
Text name = new Text();
|
name = new Text();
|
||||||
name.setFont(Font.font(namePlayer.getName(), FontWeight.BOLD, 20));
|
name.setFont(Font.font(player.getName(), FontWeight.BOLD, 20));
|
||||||
name.setText(namePlayer.getName());
|
name.setText(player.getName());
|
||||||
|
|
||||||
Text score = new Text();
|
score = new Text();
|
||||||
score.setText("Score : " + namePlayer.getScore());
|
score.setText("Score : " + player.getScore());
|
||||||
|
|
||||||
Text nbrOfTiles = new Text();
|
nbrOfTiles = new Text();
|
||||||
nbrOfTiles.setText("Tuiles restantes : " + namePlayer.getNumberOfTilesRemaining());
|
nbrOfTiles.setText("Tuiles restantes : " + player.getNumberOfTilesRemaining());
|
||||||
|
|
||||||
player.getChildren().addAll(name, score, nbrOfTiles);
|
infoPlayer.getChildren().addAll(name, score, nbrOfTiles);
|
||||||
player.setSpacing(5);
|
infoPlayer.setSpacing(5);
|
||||||
|
|
||||||
players.getChildren().add(player);
|
//players.getChildren().add(infoPlayer);
|
||||||
players.setMargin(player, new Insets(50,0,0,55));
|
//players.setMargin(infoPlayer, new Insets(50,0,0,55));
|
||||||
|
//}
|
||||||
|
|
||||||
|
//players.setSpacing(850);
|
||||||
|
return infoPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
players.setSpacing(850);
|
public void setFillName(javafx.scene.paint.Color color) {
|
||||||
return players;
|
name.setFill(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue