From 963dbaccdb28068d7be835015dc45f885261ec0e Mon Sep 17 00:00:00 2001 From: Mathis Date: Tue, 17 May 2022 09:09:48 +0200 Subject: [PATCH 1/8] ADD Rules --- src/main/java/latice/model/Rules.java | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/main/java/latice/model/Rules.java diff --git a/src/main/java/latice/model/Rules.java b/src/main/java/latice/model/Rules.java new file mode 100644 index 0000000..152c2bf --- /dev/null +++ b/src/main/java/latice/model/Rules.java @@ -0,0 +1,11 @@ +package latice.model; + +public class Rules { + private static boolean START = true; + + public Rules() { + // TODO Auto-generated constructor stub + } + + +} From b5e88140004ec9091a1a1c39bc64a32d444641ad Mon Sep 17 00:00:00 2001 From: Mathis Date: Tue, 17 May 2022 09:13:03 +0200 Subject: [PATCH 2/8] Step2 : ADD GameBoard --- src/main/java/latice/model/GameBoard.java | 85 +++++++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 src/main/java/latice/model/GameBoard.java diff --git a/src/main/java/latice/model/GameBoard.java b/src/main/java/latice/model/GameBoard.java new file mode 100644 index 0000000..92d0161 --- /dev/null +++ b/src/main/java/latice/model/GameBoard.java @@ -0,0 +1,85 @@ +package latice.model; + +public class GameBoard { + private Integer DIMENSION = 9; + private final String SUN = " SU "; + private final String MOON = " MO "; + private String[][] gridBoard; + + public GameBoard() { + this.gridBoard = new String[DIMENSION][DIMENSION]; + + 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; + + + }else if (i == j && (i <= 2 || i >= 6)) { //Affiche la diagonale ('\') de soleil + + this.gridBoard[i][j] = SUN; + + }else if (i == DIMENSION-1-j && (i <= 2 || i >= 6)) { //Affiche la diagonale ('/') de soleil + + this.gridBoard[i][j] = SUN; + + }else if ( ((i == 0 || i == 8)&& j == 4) || (i== 4 && (j == 0 || j == 8)) ) {//Affiche les soleils au mileu de chaque coté ('+') + + this.gridBoard[i][j] = SUN; + + }else { + this.gridBoard[i][j] = " "; + } + + if (j == 8) { + System.out.println("|"); + } + } + } + } + + public void displayGameBoard() { + + 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 + + System.out.print(this.gridBoard[i][j]); + + }else if (i == j && (i <= 2 || i >= 6)) { //Affiche la diagonale ('\') de soleil + + System.out.print(this.gridBoard[i][j]); + + }else if (i == DIMENSION-1-j && (i <= 2 || i >= 6)) { //Affiche la diagonale ('/') de soleil + + System.out.print(this.gridBoard[i][j]); + + }else if ( ((i == 0 || i == 8)&& j == 4) || (i== 4 && (j == 0 || j == 8)) ) {//Affiche les soleils au mileu de chaque coté ('+') + + System.out.print(this.gridBoard[i][j]); + + }else { + System.out.print(this.gridBoard[i][j]); + } + + if (j == 8) { + System.out.println("|"); + } + } + } + } + + public String[][] getGridBoard() { + return gridBoard; + } + + public void setGridBoard(String value, Integer x, Integer y) { + this.gridBoard[x][y] = value; + } + + + +} From a1f81b0d1505050d1afaecd78aa91a5487a639b7 Mon Sep 17 00:00:00 2001 From: Mathis Date: Tue, 17 May 2022 09:14:16 +0200 Subject: [PATCH 3/8] ADD Player and Score --- src/main/java/latice/model/Player.java | 24 ++++++++++++++++++++++++ src/main/java/latice/model/Score.java | 19 +++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 src/main/java/latice/model/Player.java create mode 100644 src/main/java/latice/model/Score.java diff --git a/src/main/java/latice/model/Player.java b/src/main/java/latice/model/Player.java new file mode 100644 index 0000000..0279cdc --- /dev/null +++ b/src/main/java/latice/model/Player.java @@ -0,0 +1,24 @@ +package latice.model; + +import java.util.Scanner; + +public class Player { + private final String name; + private Score score; + + public Player(String name, Score score) { + //Demande le nom du joueur + Scanner enterPlayerName = new Scanner(System.in); + System.out.println("Veuilez entrer votre nom " + name + " :"); + String namePlayer = enterPlayerName.next(); + + this.name = namePlayer; + this.score = score; + } + + public String getName() { + return name; + } + + +} diff --git a/src/main/java/latice/model/Score.java b/src/main/java/latice/model/Score.java new file mode 100644 index 0000000..e9267f2 --- /dev/null +++ b/src/main/java/latice/model/Score.java @@ -0,0 +1,19 @@ +package latice.model; + +public class Score { + private Integer score; + + public Score() { + this.score = 0; + } + + public Integer getScore() { + return score; + } + + public void setScore(Integer score) { + this.score = score; + } + + +} From bc278df80419ebbedaae95702406b0556400cd0d Mon Sep 17 00:00:00 2001 From: Mathis Date: Tue, 17 May 2022 09:17:09 +0200 Subject: [PATCH 4/8] ADD Position | ADD attribute 'position' to Tile --- src/main/java/latice/model/Position.java | 21 +++++++++++++++++++++ src/main/java/latice/model/Tile.java | 9 +++++++++ 2 files changed, 30 insertions(+) create mode 100644 src/main/java/latice/model/Position.java diff --git a/src/main/java/latice/model/Position.java b/src/main/java/latice/model/Position.java new file mode 100644 index 0000000..d92c44a --- /dev/null +++ b/src/main/java/latice/model/Position.java @@ -0,0 +1,21 @@ +package latice.model; + +public class Position { + private final Integer row; + private final Integer column; + + public Position(Integer row, Integer column) { + this.row = row; + this.column = column; + } + + public Integer getRow() { + return row; + } + + public Integer getColumn() { + return column; + } + + +} diff --git a/src/main/java/latice/model/Tile.java b/src/main/java/latice/model/Tile.java index b2ff117..5ded38a 100644 --- a/src/main/java/latice/model/Tile.java +++ b/src/main/java/latice/model/Tile.java @@ -3,12 +3,17 @@ package latice.model; public class Tile { private final Color color; private final Shape shape; + private Position position; public Tile(Color color, Shape shape) { this.color = color; this.shape = shape; } + public void setPosition(Position position) { + this.position = position; + } + public Color getColor() { return this.color; } @@ -16,4 +21,8 @@ public class Tile { public Shape getShape() { return this.shape; } + + public Position getPosition() { + return this.position; + } } From bea07979aa1785af337dbf6b922985310c9e9c67 Mon Sep 17 00:00:00 2001 From: Mathis Date: Tue, 17 May 2022 10:09:24 +0200 Subject: [PATCH 5/8] UPDATE Color, Rack, Shape --- src/main/java/latice/model/Color.java | 20 +++++++++++------- src/main/java/latice/model/Rack.java | 30 +++++++++++++++++++-------- src/main/java/latice/model/Shape.java | 20 +++++++++++------- 3 files changed, 47 insertions(+), 23 deletions(-) diff --git a/src/main/java/latice/model/Color.java b/src/main/java/latice/model/Color.java index 7c3fe17..bf0a682 100644 --- a/src/main/java/latice/model/Color.java +++ b/src/main/java/latice/model/Color.java @@ -1,20 +1,26 @@ package latice.model; public enum Color { - YELLOW("y"), - NAVYBLUE("n"), - RED("r"), - MAGENTA("m"), - GREEN("g"), - TURQUOISE("t"); //TODO find what is the color turchese, and write it's color code + YELLOW("y", "Y"), + NAVYBLUE("n", "N"), + RED("r", "R"), + MAGENTA("m", "M"), + GREEN("g", "G"), + TURQUOISE("t", "T"); private String stringColor; + private String stringColorConsole; - Color(String stringColor) { + Color(String stringColor, String stringColorConsole) { this.stringColor = stringColor; + this.stringColorConsole = stringColorConsole; } public String getStringColor() { return this.stringColor; } + + public String getStringColorConsole() { + return this.stringColorConsole; + } } diff --git a/src/main/java/latice/model/Rack.java b/src/main/java/latice/model/Rack.java index d55b768..1bb35a7 100644 --- a/src/main/java/latice/model/Rack.java +++ b/src/main/java/latice/model/Rack.java @@ -10,13 +10,11 @@ import javafx.scene.layout.HBox; import javafx.scene.text.Text; public class Rack { - private static ArrayList listRackTile = new ArrayList(); - private static ArrayList rackTileImage = new ArrayList(); + private ArrayList listRackTile = new ArrayList(); + private ArrayList rackTileImage = new ArrayList(); public Rack(Deck deck) { - Image image = new Image("laticePlateau.png"); - ImageView imageView = new ImageView(image); Tile tile; System.out.println("Il y a dans le rack : " + listRackTile.size() + " valeurs"); @@ -26,7 +24,7 @@ public class Rack { tile = (deck.getListTile()).get(index); - listRackTile.add(tile); + this.listRackTile.add(tile); // root.setCenter(imageView); @@ -34,16 +32,30 @@ public class Rack { } - System.out.println("Il y a dans le rack : " + listRackTile.size() + " valeurs"); + System.out.println("Il y a dans le rack : " + this.listRackTile.size() + " valeurs"); } - public static ArrayList getListRackTile() { - return listRackTile; + public ArrayList getListRackTile() { + return this.listRackTile; } public void setListRackTile(ArrayList listRackTile) { this.listRackTile = listRackTile; } + + public void displayRack() { + boolean success = false; + System.out.print("rack : "); + for (Tile tile : this.listRackTile) { + if (success) { + System.out.print(", " + tile.getShape().getStringShapeConsole() + tile.getColor().getStringColorConsole()); + }else { + System.out.print(tile.getShape().getStringShapeConsole() + tile.getColor().getStringColorConsole()); + success = true; + } + } + System.out.println(); + } @@ -77,7 +89,7 @@ public class Rack { } - public static ArrayList getRackTileImage() { + public ArrayList getRackTileImage() { return rackTileImage; } diff --git a/src/main/java/latice/model/Shape.java b/src/main/java/latice/model/Shape.java index e6d7da5..442ef31 100644 --- a/src/main/java/latice/model/Shape.java +++ b/src/main/java/latice/model/Shape.java @@ -1,20 +1,26 @@ package latice.model; public enum Shape { - BIRD("bird"), - DOLPHIN("dolphin"), - FLOWER("flower"), - FEATHER("feather"), - GECKO("gecko"), - TURTLE("turtle"); + BIRD("bird", "B"), + DOLPHIN("dolphin", "D"), + FLOWER("flower", "Fl"), + FEATHER("feather", "F"), + GECKO("gecko", "G"), + TURTLE("turtle", "T"); private String stringShape; + private String stringShapeConsole; - Shape(String stringShape) { + Shape(String stringShape, String stringShapeConsole) { this.stringShape = stringShape; + this.stringShapeConsole = stringShapeConsole; } public String getStringShape() { return this.stringShape; } + + public String getStringShapeConsole() { + return this.stringShapeConsole; + } } From cf6049a4fe6f85dc8883215208fe84806c1e9619 Mon Sep 17 00:00:00 2001 From: Mathis Date: Tue, 17 May 2022 10:09:48 +0200 Subject: [PATCH 6/8] UPDATE LaticeApplicationConsole --- .../application/LaticeApplicationConsole.java | 61 +++++++++++++++++-- 1 file changed, 55 insertions(+), 6 deletions(-) diff --git a/src/main/java/latice/application/LaticeApplicationConsole.java b/src/main/java/latice/application/LaticeApplicationConsole.java index 0c981c6..eb17cd3 100644 --- a/src/main/java/latice/application/LaticeApplicationConsole.java +++ b/src/main/java/latice/application/LaticeApplicationConsole.java @@ -1,13 +1,13 @@ package latice.application; -import java.nio.file.Path; -import java.nio.file.Paths; import java.util.ArrayList; -import javafx.scene.image.Image; import latice.model.Color; import latice.model.Deck; +import latice.model.GameBoard; +import latice.model.Player; import latice.model.Rack; +import latice.model.Score; import latice.model.Shape; import latice.model.Tile; @@ -18,7 +18,7 @@ public class LaticeApplicationConsole { System.out.println("Hello Latice !"); - + /* for (Color color : Color.values()) { for (Shape shape : Shape.values()) { Tile tile = new Tile(color, shape); @@ -39,9 +39,58 @@ public class LaticeApplicationConsole { Rack rack = new Rack(deck); System.out.println("-----------------"); deck.displayListTile(); + + System.out.println("-----------------"); + GameBoard board = new GameBoard(); + board.displayGameBoard(); + System.out.println("-----------------"); + board.setGridBoard(" NV ", 4, 4); + board.displayGameBoard(); + System.out.println("-----------------"); + Score scorePlayer1 = new Score(); + Score scorePlayer2 = new Score(); + Player player1 = new Player("player1", scorePlayer1); + Player player2 = new Player("player2", scorePlayer2); + + System.out.println(player1.getName() + " a " + scorePlayer1.getScore() +" points"); + System.out.println(player2.getName() + " a " + scorePlayer2.getScore() +" points"); + + rack.displayRack(); + + */ + + 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); + + } + } + + System.out.println("-----------------"); + System.out.println("Notre Deck :"); + Deck deck1 = new Deck(listOfTile); + Deck deck2 = new Deck(listOfTile); + deck1.displayListTile(); + System.out.println("-----------------"); + Rack rack1 = new Rack(deck1); + Rack rack2 = new Rack(deck2); + Score scorePlayer1 = new Score(); + Score scorePlayer2 = new Score(); + Player player1 = new Player("player1", scorePlayer1); + Player player2 = new Player("player2", scorePlayer2); + + System.out.println("-----------------"); + GameBoard board = new GameBoard(); + board.displayGameBoard(); + System.out.println("-----------------"); + + System.out.println(player1.getName() + " a " + scorePlayer1.getScore() +" points"); + System.out.println(player2.getName() + " a " + scorePlayer2.getScore() +" points"); + rack1.displayRack(); - - } } From 0124b6b3b0f90a0ef50ed46a29cf53b449df3f33 Mon Sep 17 00:00:00 2001 From: Mathis Date: Thu, 19 May 2022 20:45:30 +0200 Subject: [PATCH 7/8] ADD method removeTile and updateRack in Rack | ADD Player | UPDATE LaticeApplicationConsole --- .../application/LaticeApplicationConsole.java | 52 +++++++++++++++---- src/main/java/latice/model/Player.java | 31 ++++++++++- src/main/java/latice/model/Rack.java | 52 ++++++++++++++++--- src/main/java/latice/model/Tile.java | 8 +++ 4 files changed, 123 insertions(+), 20 deletions(-) diff --git a/src/main/java/latice/application/LaticeApplicationConsole.java b/src/main/java/latice/application/LaticeApplicationConsole.java index eb17cd3..5c2291b 100644 --- a/src/main/java/latice/application/LaticeApplicationConsole.java +++ b/src/main/java/latice/application/LaticeApplicationConsole.java @@ -1,6 +1,7 @@ package latice.application; import java.util.ArrayList; +import java.util.Scanner; import latice.model.Color; import latice.model.Deck; @@ -16,7 +17,7 @@ public class LaticeApplicationConsole { ArrayList listOfTile = new ArrayList(); - System.out.println("Hello Latice !"); + //System.out.println("Hello Latice !"); /* for (Color color : Color.values()) { @@ -70,27 +71,56 @@ public class LaticeApplicationConsole { } System.out.println("-----------------"); - System.out.println("Notre Deck :"); + //System.out.println("Notre Deck :"); + //Deck deck1 = new Deck(listOfTile); + //Deck deck2 = new Deck(listOfTile); + //deck1.displayListTile(); + System.out.println("-----------------"); + //Rack rack1 = new Rack(deck1); + //Rack rack2 = new Rack(deck2); + //Score scorePlayer1 = new Score(); + //Score scorePlayer2 = new Score(); + //Player player1 = new Player("player1", scorePlayer1); + //Player player2 = new Player("player2", scorePlayer2); + + System.out.println("-----------------"); + //GameBoard board = new GameBoard(); + //board.displayGameBoard(); + System.out.println("-----------------"); + + //System.out.println(player1.getName() + " a " + scorePlayer1.getScore() +" points"); + //System.out.println(player2.getName() + " a " + scorePlayer2.getScore() +" points"); + //rack1.displayRack(); + + + System.out.println("Hello Latice !"); + System.out.println("-----------------"); + Deck deck1 = new Deck(listOfTile); Deck deck2 = new Deck(listOfTile); - deck1.displayListTile(); - System.out.println("-----------------"); Rack rack1 = new Rack(deck1); Rack rack2 = new Rack(deck2); + Score scorePlayer1 = new Score(); Score scorePlayer2 = new Score(); - Player player1 = new Player("player1", scorePlayer1); - Player player2 = new Player("player2", scorePlayer2); + Player player1 = new Player("player1", scorePlayer1, deck1, rack1); + Player player2 = new Player("player2", scorePlayer2, deck2, rack2); System.out.println("-----------------"); GameBoard board = new GameBoard(); board.displayGameBoard(); - System.out.println("-----------------"); - System.out.println(player1.getName() + " a " + scorePlayer1.getScore() +" points"); - System.out.println(player2.getName() + " a " + scorePlayer2.getScore() +" points"); - rack1.displayRack(); - + + Scanner play = new Scanner(System.in); + + for(int i = 0; i < 10; i++) { + + player1.Play(play,board); + player2.Play(play,board); + + + + } } } diff --git a/src/main/java/latice/model/Player.java b/src/main/java/latice/model/Player.java index 0279cdc..60d7441 100644 --- a/src/main/java/latice/model/Player.java +++ b/src/main/java/latice/model/Player.java @@ -5,8 +5,10 @@ import java.util.Scanner; public class Player { private final String name; private Score score; + private Rack rack; + private Deck deck; - public Player(String name, Score score) { + public Player(String name, Score score, Deck deck, Rack rack) { //Demande le nom du joueur Scanner enterPlayerName = new Scanner(System.in); System.out.println("Veuilez entrer votre nom " + name + " :"); @@ -14,10 +16,35 @@ public class Player { this.name = namePlayer; this.score = score; + this.deck = deck; + this.rack = rack; } public String getName() { - return name; + return this.name; + } + + public Integer getScore() { + return this.score.getScore(); + } + + public void Play(Scanner play, GameBoard board) { + System.out.println("c'est à votre tour de jouer " + this.name +"!"); + System.out.print("Quel tuile voulez-vous jouez ? "); + this.rack.displayRack(); + String tileToPlay = play.next(); + System.out.print("Sur quelle ligne, voulez-vous placer la tuile ?"); + int row = Integer.parseInt(play.next()); + System.out.print("Sur quelle colonne, voulez-vous placer la tuile ?"); + int column = Integer.parseInt(play.next()); + board.setGridBoard(" "+tileToPlay+" ", row, column); + this.rack.removeTile(tileToPlay); + + board.displayGameBoard(); + + this.rack.updateRack(deck); + + } diff --git a/src/main/java/latice/model/Rack.java b/src/main/java/latice/model/Rack.java index 1bb35a7..3063828 100644 --- a/src/main/java/latice/model/Rack.java +++ b/src/main/java/latice/model/Rack.java @@ -20,16 +20,17 @@ public class Rack { System.out.println("Il y a dans le rack : " + listRackTile.size() + " valeurs"); for (int i = 0; i < 5; i++) { - int index = (int)(Math.random()*((deck.getListTile()).size()-0+1)+0); //(int)(Math.random()*(max-min+1)+min); + int index = (int)(Math.random()*(((deck.getListTile()).size()-1)-0+1)+0); //(int)(Math.random()*(max-min+1)+min); tile = (deck.getListTile()).get(index); - this.listRackTile.add(tile); - - // root.setCenter(imageView); - deck.getListTile().remove(index); + + + + + } System.out.println("Il y a dans le rack : " + this.listRackTile.size() + " valeurs"); @@ -43,14 +44,51 @@ public class Rack { this.listRackTile = listRackTile; } + + public void updateRack(Deck deck) { + + Tile tile; + + 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); + + tile = (deck.getListTile()).get(index); + this.listRackTile.add(tile); + deck.getListTile().remove(index); + + } + + } + + public void removeTile(String stringTile) { + int count = 0; + int index = -1; + System.out.println("taille : " + this.listRackTile.size()); + for (Tile tile : this.listRackTile) { + System.out.println(count++); + if (stringTile.equals(tile.getShapeConsole() + tile.getColorConsole())) { + index = this.listRackTile.indexOf(tile); + System.out.println(index); + System.out.println("tuile supprimé avec succès"); + } + + } + + if (index != -1) { + this.listRackTile.remove(index); + } + System.out.println("taille : " + this.listRackTile.size()); + + } + public void displayRack() { boolean success = false; System.out.print("rack : "); for (Tile tile : this.listRackTile) { if (success) { - System.out.print(", " + tile.getShape().getStringShapeConsole() + tile.getColor().getStringColorConsole()); + System.out.print(", " + tile.getShapeConsole() + tile.getColorConsole()); }else { - System.out.print(tile.getShape().getStringShapeConsole() + tile.getColor().getStringColorConsole()); + System.out.print(tile.getShapeConsole() + tile.getColorConsole()); success = true; } } diff --git a/src/main/java/latice/model/Tile.java b/src/main/java/latice/model/Tile.java index 5ded38a..0c98546 100644 --- a/src/main/java/latice/model/Tile.java +++ b/src/main/java/latice/model/Tile.java @@ -18,10 +18,18 @@ public class Tile { return this.color; } + public String getColorConsole() { + return this.color.getStringColorConsole(); + } + public Shape getShape() { return this.shape; } + public String getShapeConsole() { + return this.shape.getStringShapeConsole(); + } + public Position getPosition() { return this.position; } From 61280da595b12c2b09b842d5dda2a4e6c1bb4b9c Mon Sep 17 00:00:00 2001 From: Mathis Date: Fri, 20 May 2022 23:31:45 +0200 Subject: [PATCH 8/8] UPDATE method removeTile in Rack, attributes in GameBoard --- src/main/java/latice/model/GameBoard.java | 4 ++-- src/main/java/latice/model/Player.java | 11 ++++++++++- src/main/java/latice/model/Rack.java | 19 +++++++++++-------- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/main/java/latice/model/GameBoard.java b/src/main/java/latice/model/GameBoard.java index 92d0161..9da6f67 100644 --- a/src/main/java/latice/model/GameBoard.java +++ b/src/main/java/latice/model/GameBoard.java @@ -2,8 +2,8 @@ package latice.model; public class GameBoard { private Integer DIMENSION = 9; - private final String SUN = " SU "; - private final String MOON = " MO "; + public static final String SUN = " SU "; + public static final String MOON = " MO "; private String[][] gridBoard; public GameBoard() { diff --git a/src/main/java/latice/model/Player.java b/src/main/java/latice/model/Player.java index 60d7441..11dfacd 100644 --- a/src/main/java/latice/model/Player.java +++ b/src/main/java/latice/model/Player.java @@ -30,6 +30,15 @@ public class Player { public void Play(Scanner play, GameBoard board) { 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 ? "); this.rack.displayRack(); String tileToPlay = play.next(); @@ -42,7 +51,7 @@ public class Player { board.displayGameBoard(); - this.rack.updateRack(deck); + this.rack.updateRack(); } diff --git a/src/main/java/latice/model/Rack.java b/src/main/java/latice/model/Rack.java index 3063828..02dd78f 100644 --- a/src/main/java/latice/model/Rack.java +++ b/src/main/java/latice/model/Rack.java @@ -12,19 +12,22 @@ import javafx.scene.text.Text; public class Rack { private ArrayList listRackTile = new ArrayList(); private ArrayList rackTileImage = new ArrayList(); + private Deck deck; public Rack(Deck deck) { + this.deck = deck; Tile tile; System.out.println("Il y a dans le rack : " + listRackTile.size() + " valeurs"); 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); - deck.getListTile().remove(index); + this.deck.getListTile().remove(index); + @@ -45,17 +48,17 @@ public class Rack { } - public void updateRack(Deck deck) { + public void updateRack() { Tile tile; 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); - deck.getListTile().remove(index); - + this.deck.getListTile().remove(index); + } }