cleaned the source code 2
parent
8aa26ca8de
commit
2ae745c638
|
@ -24,7 +24,6 @@ public class LaticeApplicationConsole {
|
|||
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);
|
||||
|
||||
|
@ -38,19 +37,14 @@ 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));
|
||||
GameBoard board = new GameBoard();
|
||||
|
||||
|
||||
Scanner play = new Scanner(System.in);
|
||||
Player player;
|
||||
Boolean round;
|
||||
|
@ -74,15 +68,17 @@ 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 (à partir de la deuxième tuile jouée, cela coûtera 2 points)\n"
|
||||
+ " 2. Acheter une action supplémentaire\n"
|
||||
+ " 1. Jouer une Tuile\n"
|
||||
+ " 2. Acheter une action supplémentaire(coûte 2 points)\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) {
|
||||
|
@ -102,17 +98,25 @@ 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 (player.getScore()>=3) {
|
||||
//Buy another action and remove 2 points from score
|
||||
player.Play(play, board, 0);
|
||||
player.removePointsFromScore(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 !");
|
||||
}else {
|
||||
System.out.println("Il vous faut 2 points pour acheter une nouvelle action !");
|
||||
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 !");
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -64,7 +64,7 @@ public class LaticeApplicationWindow extends Application {
|
|||
//lists for tiles
|
||||
ArrayList<Tile> listRackTile;
|
||||
ArrayList<Image> listOfTilesInRack;
|
||||
ArrayList<Tile> listOfTile = new ArrayList<Tile>();
|
||||
//ArrayList<Tile> listOfTile = new ArrayList<Tile>();
|
||||
static StackPane rootLayout;
|
||||
|
||||
public static int indexTileClicked;
|
||||
|
@ -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
|
||||
|
@ -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.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,12 +320,13 @@ public class LaticeApplicationWindow extends Application {
|
|||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
confirmBtnClickedCount++;
|
||||
player.getRack().displayRack();
|
||||
|
||||
////// for the actual player //////
|
||||
player.getRack().updateRack();
|
||||
|
||||
player.getRack().displayRack();
|
||||
|
||||
////// changing player //////
|
||||
//making names colored in red to make the players know which player's round is
|
||||
if (confirmBtnClickedCount%2 == 0) {
|
||||
playerFX.setFillName(Constant.realColor.BLACK);
|
||||
|
@ -339,12 +340,14 @@ public class LaticeApplicationWindow extends Application {
|
|||
playerFX.setFillName(Constant.realColor.RED);
|
||||
}
|
||||
|
||||
////// for the next player //////
|
||||
isFreePlacement = true;
|
||||
|
||||
rackTileImage = player.getRack().createTileImage();
|
||||
//Setting drag n drop on tiles
|
||||
setDragnDropOnRack(rackTileImage, player);
|
||||
setDragnDropOnRectangles(rect, board, referee, player);
|
||||
rackTileImage.getChildren().addAll(confirmButton, changeButton, buyActionButton);
|
||||
rackTileImage.getChildren().addAll(confirmButton, changeButton/*, buyActionButton*/);
|
||||
borderPane.setBottom(rackTileImage);
|
||||
|
||||
|
||||
|
@ -378,7 +381,7 @@ public class LaticeApplicationWindow extends Application {
|
|||
|
||||
});
|
||||
|
||||
//With Image
|
||||
//Rack with Image
|
||||
rackTileImage = player.getRack().createTileImage();
|
||||
|
||||
//Adding lists to Arraylists
|
||||
|
@ -393,7 +396,7 @@ public class LaticeApplicationWindow extends Application {
|
|||
public void handle(MouseEvent arg0) {
|
||||
|
||||
////// for the actual player //////
|
||||
if (player.getScore() > 1) {
|
||||
if (player.getScore() >= 3) {
|
||||
System.out.println("Changing Rack");
|
||||
confirmBtnClickedCount++;
|
||||
player.getRack().changeRack();
|
||||
|
@ -421,7 +424,7 @@ public class LaticeApplicationWindow extends Application {
|
|||
//Setting drag n drop on tiles
|
||||
setDragnDropOnRack(rackTileImage, player);
|
||||
|
||||
rackTileImage.getChildren().addAll(confirmButton, changeButton, buyActionButton);
|
||||
rackTileImage.getChildren().addAll(confirmButton, changeButton/*, buyActionButton*/);
|
||||
setDragnDropOnRectangles(rect, board, referee, player);
|
||||
borderPane.setBottom(rackTileImage);
|
||||
|
||||
|
@ -434,16 +437,16 @@ public class LaticeApplicationWindow extends Application {
|
|||
|
||||
});
|
||||
|
||||
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 !");
|
||||
}
|
||||
|
||||
});
|
||||
});*/
|
||||
|
||||
rackTileImage.getChildren().addAll(confirmButton, changeButton, buyActionButton);
|
||||
rackTileImage.getChildren().addAll(confirmButton, changeButton/*, buyActionButton*/);
|
||||
setDragnDropOnRack(rackTileImage, player);
|
||||
System.out.println();
|
||||
borderPane.setBottom(rackTileImage);
|
||||
|
@ -564,7 +567,7 @@ public class LaticeApplicationWindow extends Application {
|
|||
|
||||
}else {
|
||||
//if it's not the first round of the game
|
||||
//not removing the tile from the rack
|
||||
//putting the position of the gameboard's case on the tile from the rack
|
||||
player.getRack().getListRackTile().get(indexTileClicked).setPosition(new Position(a,b));
|
||||
|
||||
//verify if a tile is already placed
|
||||
|
|
|
@ -60,8 +60,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;
|
||||
|
|
|
@ -24,19 +24,6 @@ public class Player {
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -111,32 +111,38 @@ public class Rules {
|
|||
return this.moonRule(board, tile);
|
||||
}else {
|
||||
System.out.println("-----------------------------");
|
||||
if (this.sunRule(board, tile)){
|
||||
player.addPointsToScore(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 !");
|
||||
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é");
|
||||
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);
|
||||
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);
|
||||
}
|
||||
}
|
||||
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;
|
||||
|
@ -39,9 +39,6 @@ public class GameBoard {
|
|||
this.gridBoard[i][j] = BLUE;
|
||||
}
|
||||
|
||||
if (j == 8) {
|
||||
System.out.println("|");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -53,28 +50,28 @@ public class GameBoard {
|
|||
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 (i == 4 && j == 4) { //display moon in the center of the board
|
||||
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
|
||||
}else if (i == j && (i <= 2 || i >= 6)) { //display the diagonal ('\') of the sun
|
||||
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
|
||||
}else if (i == DIMENSION-1-j && (i <= 2 || i >= 6)) { //display the diagonal ('/') of the sun
|
||||
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é ('+')
|
||||
}else if ( ((i == 0 || i == 8)&& j == 4) || (i== 4 && (j == 0 || j == 8)) ) {//display the suns at the middle of each side ('+')
|
||||
if (this.gridBoardTile[i][j] == null) {
|
||||
System.out.print(this.gridBoard[i][j]);
|
||||
}else {
|
||||
|
|
|
@ -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);
|
||||
|
@ -29,15 +29,9 @@ public class Rack {
|
|||
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() {
|
||||
|
@ -52,7 +46,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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue