diff --git a/src/main/java/latice/application/LaticeApplicationConsole.java b/src/main/java/latice/application/LaticeApplicationConsole.java index 0f94fd5..9e84a85 100644 --- a/src/main/java/latice/application/LaticeApplicationConsole.java +++ b/src/main/java/latice/application/LaticeApplicationConsole.java @@ -14,25 +14,38 @@ public class LaticeApplicationConsole { Tile blueBird = new Tile(Color.BLUE, Shape.BIRD); Tile greenLeaf = new Tile(Color.GREEN, Shape.LEAF); Tile redFlower = new Tile(Color.RED, Shape.FLOWER); + ArrayList rackPlayer1 = new ArrayList(); + ArrayList rackPlayer2 = new ArrayList(); + int tilesNumber = 3; - ArrayList tiles =new ArrayList(Arrays.asList(redFlower, greenLeaf, redFlower)); + ArrayList tiles =new ArrayList(Arrays.asList(blueBird, greenLeaf, redFlower)); System.out.println("Hello Latice ! " + blueBird.getShape() + blueBird.getColor()); System.out.println("Hello Latice ! " + greenLeaf.getShape() + greenLeaf.getColor()); System.out.println("Hello Latice ! " + redFlower.getShape() + redFlower.getColor()); System.out.println("Hello Latice ! " + tiles.get(0).getShape() + tiles.get(0).getColor()); - //------------------------------Attribution des tuiles----------------------------------- + //------------------------------Tiles attribution----------------------------------- Random random = new Random(); - for(int i=0; i<2; i++) { - int randomNumber = random.nextInt(3); - Tile[] rackPlayer1 = {tiles.get(randomNumber), tiles.get(randomNumber)};; - } - for(int i=0; i<2; i++) { - int randomNumber = random.nextInt(3); - Tile[] rackPlayer2 = {tiles.get(randomNumber), tiles.get(randomNumber)}; + for(int i=0; i<=tilesNumber; i++) { + if(! tiles.isEmpty()) { + int randomNumber = random.nextInt(tiles.size()); + if(i%2 == 0) { + rackPlayer1.add(tiles.get(randomNumber)); + System.out.println(rackPlayer1.get(0).getColor().toString() + rackPlayer1.get(0).getShape().toString()); + } else { + rackPlayer2.add(tiles.get(randomNumber)); + System.out.println(rackPlayer2.get(0).getColor().toString() + rackPlayer2.get(0).getShape().toString()); + } + tiles.remove(randomNumber); + System.out.println(randomNumber); + System.out.println(rackPlayer1); + System.out.println(rackPlayer2); + } + } + } } diff --git a/src/main/java/latice/application/LaticeApplicationWindow.java b/src/main/java/latice/application/LaticeApplicationWindow.java index 03065ef..9c8afa6 100644 --- a/src/main/java/latice/application/LaticeApplicationWindow.java +++ b/src/main/java/latice/application/LaticeApplicationWindow.java @@ -3,19 +3,29 @@ package latice.application; import java.io.File; import javafx.application.Application; +import javafx.geometry.Insets; import javafx.geometry.Pos; import javafx.scene.Scene; import javafx.scene.image.Image; import javafx.scene.image.ImageView; import javafx.scene.layout.BorderPane; +import javafx.scene.layout.HBox; +import javafx.scene.layout.VBox; import javafx.scene.text.Font; import javafx.scene.text.Text; import javafx.stage.Stage; +import latice.model.Color; +import latice.model.Shape; +import latice.model.Tile; public class LaticeApplicationWindow extends Application{ Image image = new Image("C:/Users/cemal/saebut1/latice/src/main/resources/laticePlateau.png"); ImageView imageView = new ImageView(image); + + Tile blueBird = new Tile(Color.BLUE, Shape.BIRD); + Tile greenLeaf = new Tile(Color.GREEN, Shape.LEAF); + Tile redFlower = new Tile(Color.RED, Shape.FLOWER); public static void main(String[] args) { Application.launch(args); @@ -27,14 +37,33 @@ public class LaticeApplicationWindow extends Application{ BorderPane root = new BorderPane(); Text title = new Text("Latice"); - title.setFont(new Font(20)); + title.setFont(new Font(30)); root.setTop(title); root.setAlignment(title, Pos.CENTER); + + //Image root.setCenter(imageView); + //Rack + HBox rack = new HBox(); + + rack.setSpacing(10); + rack.setPadding(new Insets(15,20, 10,10)); + + Text rackTile1 = new Text(); + rackTile1.setText(blueBird.getShape().toString() + blueBird.getColor()); + Text rackTile2 = new Text(); + rackTile2.setText(greenLeaf.getShape().toString() + greenLeaf.getColor()); + Text rackTile3 = new Text(); + rackTile3.setText(redFlower.getShape().toString() + redFlower.getColor()); + + rack.getChildren().addAll(rackTile1, rackTile2, rackTile3); + rack.setAlignment(Pos.CENTER); + root.setBottom(rack); + + Scene scene = new Scene(root, 1280, 720); - primaryStage.setTitle("Latice"); primaryStage.setScene(scene); primaryStage.show();