Added buy action button but not yet implemented in jFX
parent
76a6581326
commit
a93ab4954d
|
@ -167,6 +167,15 @@ public class LaticeApplicationConsole {
|
|||
|
||||
|
||||
case 2:
|
||||
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 !");
|
||||
}
|
||||
|
||||
|
||||
|
||||
case 3: player.getRack().changeRack();
|
||||
System.out.println("Votre rack à été changé avec succès !");
|
||||
|
|
|
@ -39,6 +39,7 @@ import javafx.stage.Stage;
|
|||
import latice.controller.MainScreenController;
|
||||
import latice.controller.PlayerNameInputController;
|
||||
import latice.model.Color;
|
||||
import latice.model.Constant;
|
||||
import latice.model.Player;
|
||||
import latice.model.Shape;
|
||||
import latice.model.Tile;
|
||||
|
@ -49,18 +50,6 @@ import latice.model.window.RectangleFX;
|
|||
|
||||
public class LaticeApplicationWindow extends Application {
|
||||
|
||||
private static final int NUMBER_OF_BOX_ON_ONE_LINE = 9;
|
||||
|
||||
private static final int RECTANGLE_HEIGHT = 50;
|
||||
|
||||
private static final int RECTANGLE_WIDTH = 50;
|
||||
|
||||
private static final int Y_CENTER = 37;
|
||||
|
||||
private static final int X_CENTER = 355;
|
||||
|
||||
private static final int BOX_WIDTH = 52;
|
||||
|
||||
javafx.scene.paint.Color realColor = new javafx.scene.paint.Color(0, 0, 0, 0);
|
||||
|
||||
Image image = new Image("backgroundLatice.png");
|
||||
|
@ -132,10 +121,10 @@ public class LaticeApplicationWindow extends Application {
|
|||
Rectangle[][] r = new Rectangle[9][9];
|
||||
int counterI = 0;
|
||||
int counterJ = 0;
|
||||
for (int i=1; i<=NUMBER_OF_BOX_ON_ONE_LINE ; i++) {
|
||||
for (int j=1; j <= NUMBER_OF_BOX_ON_ONE_LINE ; j++) {
|
||||
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*BOX_WIDTH+X_CENTER,j*BOX_WIDTH+Y_CENTER,RECTANGLE_WIDTH,RECTANGLE_HEIGHT);
|
||||
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]);
|
||||
|
@ -209,6 +198,8 @@ public class LaticeApplicationWindow extends Application {
|
|||
Image checkMark = new Image("checkMark.png");
|
||||
ImageView checkMarkView = new ImageView(checkMark);
|
||||
Button confirmButton = new Button("Confirm", checkMarkView);
|
||||
confirmButton.setPrefWidth(Constant.ACTION_BUTTONS_WIDTH);
|
||||
confirmButton.setPrefHeight(Constant.ACTION_BUTTONS_HEIGHT);
|
||||
|
||||
confirmButton.setOnMouseClicked(new EventHandler<MouseEvent>() {
|
||||
|
||||
|
@ -234,7 +225,15 @@ public class LaticeApplicationWindow extends Application {
|
|||
Image changeIconImage = new Image("changeIcon.png");
|
||||
ImageView changeIconView = new ImageView(changeIconImage);
|
||||
Button changeButton = new Button("Change Rack", changeIconView);
|
||||
changeButton.setPrefWidth(Constant.ACTION_BUTTONS_WIDTH);
|
||||
changeButton.setPrefHeight(Constant.ACTION_BUTTONS_HEIGHT);
|
||||
|
||||
//Buy another action Button
|
||||
Image buyActionImage = new Image("buyAction.png");
|
||||
ImageView buyActionView = new ImageView(buyActionImage);
|
||||
Button buyActionButton = new Button("Buy Action", buyActionView);
|
||||
buyActionButton.setPrefWidth(Constant.ACTION_BUTTONS_WIDTH);
|
||||
buyActionButton.setPrefHeight(Constant.ACTION_BUTTONS_HEIGHT);
|
||||
|
||||
changeButton.setOnMouseClicked(new EventHandler<MouseEvent>() {
|
||||
|
||||
|
@ -247,14 +246,30 @@ public class LaticeApplicationWindow extends Application {
|
|||
|
||||
rackImage.getChildren().clear();
|
||||
|
||||
rackImage.getChildren().addAll(rack2.createTileImage(), confirmButton, changeButton);
|
||||
rackImage.getChildren().addAll(rack2.createTileImage(), confirmButton, changeButton, buyActionButton);
|
||||
|
||||
//Setting drag n drop on tiles
|
||||
setDragnDropOnRack(rackImage);
|
||||
}
|
||||
|
||||
});
|
||||
rackImage.getChildren().addAll(confirmButton, changeButton);
|
||||
|
||||
buyActionButton.setOnMouseClicked(new EventHandler<MouseEvent>() {
|
||||
|
||||
@Override
|
||||
public void handle(MouseEvent arg0) {
|
||||
//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 !");
|
||||
}*/
|
||||
}
|
||||
|
||||
});
|
||||
rackImage.getChildren().addAll(confirmButton, changeButton, buyActionButton);
|
||||
root.setBottom(rackImage);
|
||||
|
||||
//Adding lists to Arraylists
|
||||
|
@ -274,12 +289,33 @@ public class LaticeApplicationWindow extends Application {
|
|||
|
||||
//------------------------------------------------------------------------
|
||||
//###################### creating all rectangles and DragnDrop ######################//
|
||||
RectangleFX rectFX = new RectangleFX();
|
||||
rectFX.createRectangle(root, pane);
|
||||
rectFX.dragnDropOnAllRectangles(player1, indexTileClicked, validateBtnClickedCount);
|
||||
rectFX.dragnDropOnAllRectangles(player2, indexTileClicked, validateBtnClickedCount);
|
||||
//ectangleFX rectFX = new RectangleFX();
|
||||
//rectFX.createRectangle(root, pane);
|
||||
//rectFX.dragnDropOnAllRectangles(player1, indexTileClicked, validateBtnClickedCount);
|
||||
//rectFX.dragnDropOnAllRectangles(player2, indexTileClicked, validateBtnClickedCount);
|
||||
//------------------------------------------------------------------------
|
||||
|
||||
//Setting drag & drop on rectangles
|
||||
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++) {
|
||||
int a = i;
|
||||
int b = j;
|
||||
|
||||
r[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())));
|
||||
}
|
||||
arg0.consume();
|
||||
}
|
||||
});
|
||||
|
||||
r[a][b].setOnDragExited(new EventHandler<DragEvent>() {
|
||||
|
||||
@Override
|
||||
public void handle(DragEvent arg0) {
|
||||
if (arg0.isDropCompleted() == false) {
|
||||
|
@ -315,8 +351,8 @@ public class LaticeApplicationWindow extends Application {
|
|||
}else {
|
||||
moonErrorLabel.setText("Error ! Please place the first tile on the moon");
|
||||
//removing all tiles from gameboard
|
||||
for(int i=0; i<NUMBER_OF_BOX_ON_ONE_LINE; i++) {
|
||||
for(int j=0; j<NUMBER_OF_BOX_ON_ONE_LINE; j++) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -332,6 +368,25 @@ public class LaticeApplicationWindow extends Application {
|
|||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//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(nameplayer.getName(), FontWeight.BOLD, 20));
|
||||
name.setText(nameplayer.getName());
|
||||
|
@ -377,6 +432,7 @@ public class LaticeApplicationWindow extends Application {
|
|||
//Setting drag n drop on tiles
|
||||
for (int i=0; i<5; i++) {
|
||||
int a = i;
|
||||
System.out.println(a);
|
||||
rackImage.getChildren().get(a).setOnDragDetected(new EventHandler<MouseEvent>() {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package latice.model;
|
||||
|
||||
public class Constant {
|
||||
//for creating rectangles
|
||||
public static final int NUMBER_OF_BOX_ON_ONE_LINE = 9;
|
||||
|
||||
public static final int RECTANGLE_HEIGHT = 50;
|
||||
|
||||
public static final int RECTANGLE_WIDTH = 50;
|
||||
|
||||
public static final int Y_CENTER = 37;
|
||||
|
||||
public static final int X_CENTER = 355;
|
||||
|
||||
public static final int BOX_WIDTH = 52;
|
||||
|
||||
public static final int ACTION_BUTTONS_WIDTH = 120;
|
||||
|
||||
public static final int ACTION_BUTTONS_HEIGHT = 45;
|
||||
|
||||
}
|
|
@ -1,20 +1,20 @@
|
|||
package latice;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import latice.model.Color;
|
||||
import latice.model.Deck;
|
||||
import latice.model.Player;
|
||||
import latice.model.Position;
|
||||
import latice.model.Rack;
|
||||
import latice.model.Score;
|
||||
import latice.model.Shape;
|
||||
import latice.model.Tile;
|
||||
import latice.model.console.Deck;
|
||||
import latice.model.console.Rack;
|
||||
import latice.model.console.Score;
|
||||
|
||||
class LaticeTest {
|
||||
|
||||
|
|
Loading…
Reference in New Issue