diff --git a/class/application/Controller.class b/class/application/Controller.class index 3747acbe08a1f8d139621d7310cb271edd6a1480..693e15ae6cb6d6f6a9355d224d8a1c1b1c15623f 100644 Binary files a/class/application/Controller.class and b/class/application/Controller.class differ diff --git a/class/application/Main.class b/class/application/Main.class index 54a3483c65fb7d25c3387372cf37c101fc24da0a..1f8389d7ab360c6c97e78972a18cef74c369315b 100644 Binary files a/class/application/Main.class and b/class/application/Main.class differ diff --git a/class/application/MainGUI.fxml b/class/application/MainGUI.fxml new file mode 100644 index 0000000000000000000000000000000000000000..76578be43c1997bfc72174998074bee1130ecbc5 --- /dev/null +++ b/class/application/MainGUI.fxml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.scene.control.Label?> +<?import javafx.scene.layout.AnchorPane?> +<?import javafx.scene.layout.HBox?> +<?import javafx.scene.layout.StackPane?> +<?import javafx.scene.shape.Rectangle?> +<?import javafx.scene.text.Font?> + +<AnchorPane prefHeight="600.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.Controller"> + <children> + <Rectangle fx:id="iconLastCard" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="90.0" layoutX="326.0" layoutY="230.0" stroke="BLACK" strokeType="INSIDE" strokeWidth="2.0" width="57.0" /> + <Label fx:id="labelLastCard" alignment="CENTER" contentDisplay="CENTER" layoutX="326.0" layoutY="256.0" prefHeight="38.0" prefWidth="57.0" text="+4" textAlignment="CENTER" textFill="WHITE"> + <font> + <Font name="System Bold" size="26.0" /> + </font></Label> + <HBox fx:id="hboxPlayerDeck" layoutX="83.0" layoutY="450.0" prefHeight="107.0" prefWidth="634.0" /> + <StackPane fx:id="iconDeck" layoutX="458.0" layoutY="230.0" prefHeight="90.0" prefWidth="57.0" /> + </children> +</AnchorPane> diff --git a/class/application/_de.properties b/class/application/_de.properties index c412094f4bb7009585701e9b6b1106fbb8c12919..281e7a9d5be2f008e8d7b634a7df2b5dbabf08d0 100644 --- a/class/application/_de.properties +++ b/class/application/_de.properties @@ -1,4 +1,4 @@ -app.name=PlayCount -version.code=2 -version.name=1.1.0 -version.date=23.03.16 \ No newline at end of file +app.name=UNO +version.code=0 +version.name=0.0.0 +version.date=10.04.16 \ No newline at end of file diff --git a/class/images/card-back.png b/class/images/card-back.png new file mode 100644 index 0000000000000000000000000000000000000000..289e39dc286c259c5492a5653c97fd770e90da4c Binary files /dev/null and b/class/images/card-back.png differ diff --git a/src/application/icon.png b/class/images/icon.png similarity index 100% rename from src/application/icon.png rename to class/images/icon.png diff --git a/class/logic/Card.class b/class/logic/Card.class index 360393c94f623c1e06b98d4968e78a174d1bc3ea..e21b50bed056790848ca47787baacb679e226b56 100644 Binary files a/class/logic/Card.class and b/class/logic/Card.class differ diff --git a/class/logic/Game.class b/class/logic/Game.class index 4fb5ee7d10b44dfdcdddb12d39f9bfc04947f1d6..0e40b90d3e10a9ab79fae8f2d218fa8c628eb63c 100644 Binary files a/class/logic/Game.class and b/class/logic/Game.class differ diff --git a/class/logic/Player.class b/class/logic/Player.class index 2c3c3947fa1214bfed2714dbbd8c94cea195c36f..bd82c537dc81df483d302da92a725af1f010820f 100644 Binary files a/class/logic/Player.class and b/class/logic/Player.class differ diff --git a/src/application/Controller.java b/src/application/Controller.java index 454479b161e72babdb6b4f6d73c518cd4b1060f1..03864e4c0309411aa8a90d696fc7d30b94628f05 100644 --- a/src/application/Controller.java +++ b/src/application/Controller.java @@ -1,22 +1,46 @@ package application; +import java.util.ArrayList; import java.util.Locale; import java.util.ResourceBundle; +import javafx.fxml.FXML; +import javafx.geometry.Insets; import javafx.scene.control.Alert; import javafx.scene.control.Alert.AlertType; +import javafx.scene.control.Label; import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.scene.layout.HBox; +import javafx.scene.layout.StackPane; +import javafx.scene.paint.Color; +import javafx.scene.shape.Rectangle; import javafx.stage.Stage; +import logic.Card; +import logic.Game; public class Controller { + @FXML private Label labelLastCard; + @FXML private Rectangle iconLastCard; + @FXML private HBox hboxPlayerDeck; + @FXML private StackPane iconDeck; + + public Game game; + public Stage stage; - public Image icon = new Image("application/icon.png"); + public Image icon = new Image("images/icon.png"); private final ResourceBundle bundle = ResourceBundle.getBundle("application/", Locale.GERMANY); public void init() { + iconLastCard.setArcWidth(20); + iconLastCard.setArcHeight(20); + + iconDeck = createBackCard(); + game = new Game(this, 3); + game.newGame(5); } public void setStage(Stage stage) @@ -24,6 +48,77 @@ public class Controller this.stage = stage; } + public void setLastCard(String color, String text) + { + iconLastCard.setFill(Color.web(color)); + labelLastCard.setText(text); + } + + private StackPane createBackCard() + { + Rectangle newCard = new Rectangle(57.0, 90.0); + newCard.setStroke(Color.BLACK); + newCard.setStrokeWidth(2.0); + newCard.setArcWidth(20); + newCard.setArcHeight(20); + + ImageView imageView = new ImageView(new Image("images/card-back.png")); + imageView.setFitHeight(90.0); + imageView.setFitWidth(57.0); + + StackPane pane = new StackPane(); + pane.getChildren().add(newCard); + pane.getChildren().add(imageView); + + return pane; + } + + private StackPane createCard(Card card, boolean valid) + { + Rectangle newCard = new Rectangle(57.0, 90.0); + newCard.setStroke(Color.BLACK); + newCard.setStrokeWidth(2.0); + newCard.setArcWidth(20); + newCard.setArcHeight(20); + + ImageView imageView = new ImageView(new Image("images/" + card.getType() + "-" + card.getColor() + ".png")); + imageView.setFitHeight(90.0); + imageView.setFitWidth(57.0); + + StackPane pane = new StackPane(); + pane.getChildren().add(newCard); + pane.getChildren().add(imageView); + + return pane; + } + + public void setPlayerDeck(ArrayList<Card> deck) + { + hboxPlayerDeck.getChildren().clear(); + + for(Card currentCard : deck) + { + hboxPlayerDeck.getChildren().add(createCard(currentCard, true)); + HBox.setMargin(hboxPlayerDeck.getChildren().get(hboxPlayerDeck.getChildren().size() - 1), new Insets(0,15,0,0)); + } + } + + public void setValidPlayerDeck(ArrayList<Card> deck, ArrayList<Card> validDeck) + { + for(Card currentCard : deck) + { + if(validDeck.contains(currentCard)) + { + hboxPlayerDeck.getChildren().add(createCard(currentCard, true)); + } + else + { + hboxPlayerDeck.getChildren().add(createCard(currentCard, false)); + } + + HBox.setMargin(hboxPlayerDeck.getChildren().get(hboxPlayerDeck.getChildren().size() - 1), new Insets(0,15,0,0)); + } + } public void about() { diff --git a/src/application/Main.java b/src/application/Main.java index 9bc82570d498dd295703973518a68a7f3f47d6f6..3729b324f9cee3c7b7e936931d68a5655851a555 100644 --- a/src/application/Main.java +++ b/src/application/Main.java @@ -1,14 +1,11 @@ package application; import javafx.application.Application; -import javafx.concurrent.Worker; -import javafx.event.EventHandler; import javafx.fxml.FXMLLoader; import javafx.scene.Parent; import javafx.scene.Scene; import javafx.scene.image.Image; import javafx.stage.Stage; -import javafx.stage.WindowEvent; public class Main extends Application { @@ -23,16 +20,14 @@ public class Main extends Application Scene scene = new Scene(root, 800, 600); stage.setResizable(true); - stage.setTitle("PlayCount"); - stage.setScene(scene); - stage.setMinHeight(400); - stage.setMinWidth(750); + stage.setTitle("UNO"); + stage.setScene(scene); Controller controller = (Controller)loader.getController(); controller.setStage(stage); controller.init(); - stage.getIcons().add(new Image("application/icon.png")); + stage.getIcons().add(new Image("images/icon.png")); stage.show(); } catch(Exception e) diff --git a/src/application/MainGUI.fxml b/src/application/MainGUI.fxml new file mode 100644 index 0000000000000000000000000000000000000000..76578be43c1997bfc72174998074bee1130ecbc5 --- /dev/null +++ b/src/application/MainGUI.fxml @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="UTF-8"?> + +<?import javafx.scene.control.Label?> +<?import javafx.scene.layout.AnchorPane?> +<?import javafx.scene.layout.HBox?> +<?import javafx.scene.layout.StackPane?> +<?import javafx.scene.shape.Rectangle?> +<?import javafx.scene.text.Font?> + +<AnchorPane prefHeight="600.0" prefWidth="800.0" xmlns="http://javafx.com/javafx/8.0.65" xmlns:fx="http://javafx.com/fxml/1" fx:controller="application.Controller"> + <children> + <Rectangle fx:id="iconLastCard" arcHeight="5.0" arcWidth="5.0" fill="DODGERBLUE" height="90.0" layoutX="326.0" layoutY="230.0" stroke="BLACK" strokeType="INSIDE" strokeWidth="2.0" width="57.0" /> + <Label fx:id="labelLastCard" alignment="CENTER" contentDisplay="CENTER" layoutX="326.0" layoutY="256.0" prefHeight="38.0" prefWidth="57.0" text="+4" textAlignment="CENTER" textFill="WHITE"> + <font> + <Font name="System Bold" size="26.0" /> + </font></Label> + <HBox fx:id="hboxPlayerDeck" layoutX="83.0" layoutY="450.0" prefHeight="107.0" prefWidth="634.0" /> + <StackPane fx:id="iconDeck" layoutX="458.0" layoutY="230.0" prefHeight="90.0" prefWidth="57.0" /> + </children> +</AnchorPane> diff --git a/src/application/_de.properties b/src/application/_de.properties index c412094f4bb7009585701e9b6b1106fbb8c12919..281e7a9d5be2f008e8d7b634a7df2b5dbabf08d0 100644 --- a/src/application/_de.properties +++ b/src/application/_de.properties @@ -1,4 +1,4 @@ -app.name=PlayCount -version.code=2 -version.name=1.1.0 -version.date=23.03.16 \ No newline at end of file +app.name=UNO +version.code=0 +version.name=0.0.0 +version.date=10.04.16 \ No newline at end of file diff --git a/src/images/DRAW_FOUR-BLACK.png b/src/images/DRAW_FOUR-BLACK.png new file mode 100644 index 0000000000000000000000000000000000000000..b0f3d6927da39185e9233a0603aadc162dd61a6f Binary files /dev/null and b/src/images/DRAW_FOUR-BLACK.png differ diff --git a/src/images/ONE-BLUE.png b/src/images/ONE-BLUE.png new file mode 100644 index 0000000000000000000000000000000000000000..8a00d08a4bfcccf4e26b28b7e15f0638c6e2bd32 Binary files /dev/null and b/src/images/ONE-BLUE.png differ diff --git a/src/images/ONE-GREEN.png b/src/images/ONE-GREEN.png new file mode 100644 index 0000000000000000000000000000000000000000..8f22ea716a8d2479c91ac192a0f833fd94a0d0e2 Binary files /dev/null and b/src/images/ONE-GREEN.png differ diff --git a/src/images/ONE-RED.png b/src/images/ONE-RED.png new file mode 100644 index 0000000000000000000000000000000000000000..a33698a0202f6712835fc6966cb369d3b6a3bb58 Binary files /dev/null and b/src/images/ONE-RED.png differ diff --git a/src/images/ONE-YELLOW.png b/src/images/ONE-YELLOW.png new file mode 100644 index 0000000000000000000000000000000000000000..58a407c2a0e130d36651b261bc3db70a83cb79cf Binary files /dev/null and b/src/images/ONE-YELLOW.png differ diff --git a/src/images/THREE-BLUE.png b/src/images/THREE-BLUE.png new file mode 100644 index 0000000000000000000000000000000000000000..d23a1d0ee77957dbde8daa80f9b688dbebea480d Binary files /dev/null and b/src/images/THREE-BLUE.png differ diff --git a/src/images/THREE-GREEN.png b/src/images/THREE-GREEN.png new file mode 100644 index 0000000000000000000000000000000000000000..86c92450f31672815d8112b1f4b4496ea570bfc0 Binary files /dev/null and b/src/images/THREE-GREEN.png differ diff --git a/src/images/THREE-RED.png b/src/images/THREE-RED.png new file mode 100644 index 0000000000000000000000000000000000000000..92a536f1d7af28d0739e5ee49e998488a4e2d5d2 Binary files /dev/null and b/src/images/THREE-RED.png differ diff --git a/src/images/THREE-YELLOW.png b/src/images/THREE-YELLOW.png new file mode 100644 index 0000000000000000000000000000000000000000..1d8292006d17ad5920921860aeff3a8e9458422a Binary files /dev/null and b/src/images/THREE-YELLOW.png differ diff --git a/src/images/TWO-BLUE.png b/src/images/TWO-BLUE.png new file mode 100644 index 0000000000000000000000000000000000000000..a7fa9660d0464ecf63be4e13195b08f98f898ca0 Binary files /dev/null and b/src/images/TWO-BLUE.png differ diff --git a/src/images/TWO-GREEN.png b/src/images/TWO-GREEN.png new file mode 100644 index 0000000000000000000000000000000000000000..07214c4eae5220aac68456e9bdf0fddd57730eb5 Binary files /dev/null and b/src/images/TWO-GREEN.png differ diff --git a/src/images/TWO-RED.png b/src/images/TWO-RED.png new file mode 100644 index 0000000000000000000000000000000000000000..e684476c5ae448ae6e134bce97e4c11e34340691 Binary files /dev/null and b/src/images/TWO-RED.png differ diff --git a/src/images/TWO-YELLOW.png b/src/images/TWO-YELLOW.png new file mode 100644 index 0000000000000000000000000000000000000000..3b863a208f2695ddb6e0f15bcebb1d27ad19bdb8 Binary files /dev/null and b/src/images/TWO-YELLOW.png differ diff --git a/src/images/WILD-BLACK.png b/src/images/WILD-BLACK.png new file mode 100644 index 0000000000000000000000000000000000000000..409f5989b9098998ddf0ea6b3fa80de0a2d5965d Binary files /dev/null and b/src/images/WILD-BLACK.png differ diff --git a/src/images/ZERO-BLUE.png b/src/images/ZERO-BLUE.png new file mode 100644 index 0000000000000000000000000000000000000000..43014a8807081e664917a81406298e1c2e3e3606 Binary files /dev/null and b/src/images/ZERO-BLUE.png differ diff --git a/src/images/ZERO-GREEN.png b/src/images/ZERO-GREEN.png new file mode 100644 index 0000000000000000000000000000000000000000..f55ff27d2e26d055a276e52842903d4317a89b22 Binary files /dev/null and b/src/images/ZERO-GREEN.png differ diff --git a/src/images/ZERO-RED.png b/src/images/ZERO-RED.png new file mode 100644 index 0000000000000000000000000000000000000000..ae8af106c1c115df5bf2e1cadd44e7257706d439 Binary files /dev/null and b/src/images/ZERO-RED.png differ diff --git a/src/images/ZERO-YELLOW.png b/src/images/ZERO-YELLOW.png new file mode 100644 index 0000000000000000000000000000000000000000..7da61e3bff6e1f3c089d28b8e421a3aff475cf6a Binary files /dev/null and b/src/images/ZERO-YELLOW.png differ diff --git a/src/images/card-back.png b/src/images/card-back.png new file mode 100644 index 0000000000000000000000000000000000000000..289e39dc286c259c5492a5653c97fd770e90da4c Binary files /dev/null and b/src/images/card-back.png differ diff --git a/src/images/icon.png b/src/images/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..4b756db39463446f4151a2bfcdaca7d9661ca682 Binary files /dev/null and b/src/images/icon.png differ diff --git a/src/logic/Card.java b/src/logic/Card.java index 0359c52bc8077a891d2d6596aa8ce0ad7f3fc485..5c8a43b47f12f6325cd5fdeed751385066bd18a4 100644 --- a/src/logic/Card.java +++ b/src/logic/Card.java @@ -17,11 +17,47 @@ public class Card { return type; } + + public String getTypeBeautyfied() + { + switch(type) + { + case ZERO: return "0"; + case ONE: return "1"; + case TWO: return "2"; + case THREE: return "3"; + case FOUR: return "4"; + case FIVE: return "5"; + case SIX: return "6"; + case SEVEN: return "7"; + case EIGHT: return "8"; + case NINE: return "9"; + case REVERSE: return "<-->"; + case SKIP: return "X"; + case DRAW_TWO: return "+2"; + case WILD: return "*"; + case DRAW_FOUR: return "+4"; + default: return ""; + } + } public Color getColor() { return color; } + + public String getColorAsHex() + { + switch(color) + { + case YELLOW: return "#FFFF00"; + case RED: return "#FF0000"; + case BLUE: return "#0000FF"; + case GREEN: return "#00FF00"; + case BLACK: return "#000000"; + default: return "#000000"; + } + } public int getValue() { diff --git a/src/logic/Color.java b/src/logic/Color.java index 95a7ffdc27535b13edad0492253b1def1ff6db31..09818fb7cd669d3c8c5400282e10e7d4d27391b5 100644 --- a/src/logic/Color.java +++ b/src/logic/Color.java @@ -2,5 +2,5 @@ package logic; public enum Color { - YELLOW, RED, BLUE, GREEN, BLACK -} + YELLOW, RED, BLUE, GREEN, BLACK +} \ No newline at end of file diff --git a/src/logic/Game.java b/src/logic/Game.java index d2167c813c80ff2e56a4059ee838d5fe92ab080e..4989ec4f33325065dfe7dc80e6082fb81f400a45 100644 --- a/src/logic/Game.java +++ b/src/logic/Game.java @@ -3,6 +3,8 @@ package logic; import java.util.ArrayList; import java.util.Random; +import application.Controller; + public class Game { private Deck deck; @@ -16,9 +18,11 @@ public class Game private Color wishColor; private boolean challenge; private Direction direction; + private Controller controller; - public Game(int numberOfAIs) + public Game(Controller controller, int numberOfAIs) { + this.controller = controller; deck = new Deck(); deadDeck = new DeadDeck(); player = new Player("Spieler", this); @@ -55,8 +59,9 @@ public class Game } deadDeck.add(deck.drawCard(deadDeck)); - lastCard = deadDeck.getCards().get(deadDeck.getCards().size()-1); - System.out.println("lastCard: " + lastCard); + lastCard = deadDeck.getCards().get(deadDeck.getCards().size()-1); + + start(); } public int getGameCount() @@ -67,13 +72,10 @@ public class Game private void start() { Random random = new Random(); - currentPlayer = random.nextInt(ais.size() + 1) + 1; - - // DEBUG - currentPlayer = 1; - - while(true) - { + currentPlayer = random.nextInt(ais.size() + 1) + 1; + + //while(true) + //{ if(!lastCard.getType().equals(CardType.SKIP)) { if(lastCard.getType().equals(CardType.REVERSE)) @@ -86,30 +88,40 @@ public class Game { direction = Direction.RIGHT; } + //TODO show icon direction in UI } determineNextPlayer(); + //DEBUG + currentPlayer = 1; + //TODO mark currentPlayer in UI + if(currentPlayer == 1) - { - player.turn(lastCard, wishColor, challenge); + { + controller.setValidPlayerDeck(player.getDeck(), player.getValidCards(lastCard, wishColor, challenge)); + + //player.turn(lastCard, wishColor, challenge); +// controller.setPlayerDeck(player.getDeck()); + if(player.getDeckSize() == 0) { end(player.getName()); - break; - } +// break; + } } else - { - ais.get(currentPlayer - 2).turn(lastCard, wishColor, challenge); + { + ais.get(currentPlayer - 2).turn(lastCard, wishColor, challenge); + if(ais.get(currentPlayer - 2).getDeckSize() == 0) { end(ais.get(currentPlayer - 2).getName()); - break; +// break; } } } - } + //} } private void determineNextPlayer() @@ -140,6 +152,7 @@ public class Game private void end(String name) { + //TODO in UI System.out.println("Player " + name + " wins!"); } @@ -175,17 +188,11 @@ public class Game challengeCounter += 4; } + controller.setLastCard(lastCard.getColorAsHex(), lastCard.getTypeBeautyfied()); + System.out.println("new lastCard: " + lastCard); System.out.println("new wishColor: " + this.wishColor); System.out.println("new challenge: " + challenge); System.out.println("new challengeCounter: " + challengeCounter); } - - public static void main(String[] args) - { - Game game = new Game(3); - game.newGame(5); - game.start(); - } - } \ No newline at end of file diff --git a/src/logic/Player.java b/src/logic/Player.java index 064c659534be8785545d9f87e90727a65206218a..c20df037be54a926a46f1ebeb24b74c3422fb2f8 100644 --- a/src/logic/Player.java +++ b/src/logic/Player.java @@ -109,6 +109,11 @@ public class Player return name; } + public ArrayList<Card> getDeck() + { + return deck; + } + public void turn(Card lastCard, Color wishColor, boolean challenge) { System.out.println("All cards on hand: \n" + deck); @@ -135,7 +140,7 @@ public class Player //playerInput (draw or turnCard) //DEBUG - Card playedCard = null; + Card playedCard = new Card(CardType.EIGHT, Color.RED, 0); Color newWishColor = null; if(playedCard.getType().equals(CardType.WILD) || playedCard.getType().equals(CardType.DRAW_TWO))