UPDATE method removeTile in Rack, attributes in GameBoard

master
Mathis 2022-05-20 23:31:45 +02:00
parent 0124b6b3b0
commit 61280da595
3 changed files with 23 additions and 11 deletions

View File

@ -2,8 +2,8 @@ package latice.model;
public class GameBoard { public class GameBoard {
private Integer DIMENSION = 9; private Integer DIMENSION = 9;
private final String SUN = " SU "; public static final String SUN = " SU ";
private final String MOON = " MO "; public static final String MOON = " MO ";
private String[][] gridBoard; private String[][] gridBoard;
public GameBoard() { public GameBoard() {

View File

@ -30,6 +30,15 @@ public class Player {
public void Play(Scanner play, GameBoard board) { public void Play(Scanner play, GameBoard board) {
System.out.println("c'est à votre tour de jouer " + this.name +"!"); System.out.println("c'est à votre tour de jouer " + this.name +"!");
if (this.getScore() == 0) {
System.out.println("Vous avez " + this.getScore() + " point");
}else {
System.out.println("Vous avez " + this.getScore() + " points");
}
System.out.print("Quel tuile voulez-vous jouez ? "); System.out.print("Quel tuile voulez-vous jouez ? ");
this.rack.displayRack(); this.rack.displayRack();
String tileToPlay = play.next(); String tileToPlay = play.next();
@ -42,7 +51,7 @@ public class Player {
board.displayGameBoard(); board.displayGameBoard();
this.rack.updateRack(deck); this.rack.updateRack();
} }

View File

@ -12,19 +12,22 @@ import javafx.scene.text.Text;
public class Rack { public class Rack {
private ArrayList<Tile> listRackTile = new ArrayList<Tile>(); private ArrayList<Tile> listRackTile = new ArrayList<Tile>();
private ArrayList<Image> rackTileImage = new ArrayList<Image>(); private ArrayList<Image> rackTileImage = new ArrayList<Image>();
private Deck deck;
public Rack(Deck deck) { public Rack(Deck deck) {
this.deck = deck;
Tile tile; 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++) { for (int i = 0; i < 5; i++) {
int index = (int)(Math.random()*(((deck.getListTile()).size()-1)-0+1)+0); //(int)(Math.random()*(max-min+1)+min); int index = (int)(Math.random()*(((this.deck.getListTile()).size()-1)-0+1)+0); //(int)(Math.random()*(max-min+1)+min);
tile = (deck.getListTile()).get(index); tile = (this.deck.getListTile()).get(index);
this.listRackTile.add(tile); this.listRackTile.add(tile);
deck.getListTile().remove(index); this.deck.getListTile().remove(index);
@ -45,16 +48,16 @@ public class Rack {
} }
public void updateRack(Deck deck) { public void updateRack() {
Tile tile; Tile tile;
for (int i = 0; i < 5-this.listRackTile.size() ; i++) { for (int i = 0; i < 5-this.listRackTile.size() ; i++) {
int index = (int)(Math.random()*( ((deck.getListTile()).size()-1)-0+1)+0); //(int)(Math.random()*(max-min+1)+min); int index = (int)(Math.random()*( ((this.deck.getListTile()).size()-1)-0+1)+0); //(int)(Math.random()*(max-min+1)+min);
tile = (deck.getListTile()).get(index); tile = (this.deck.getListTile()).get(index);
this.listRackTile.add(tile); this.listRackTile.add(tile);
deck.getListTile().remove(index); this.deck.getListTile().remove(index);
} }