diff --git a/flowchart_v1.xopp b/flowchart_v1.xopp new file mode 100644 index 0000000000000000000000000000000000000000..05d9e86b1d2631c98eecdd6f3039249083f6b152 Binary files /dev/null and b/flowchart_v1.xopp differ diff --git a/hello.java b/hello.java new file mode 100644 index 0000000000000000000000000000000000000000..079e883a3d0b21ba4cb786465d38026c57a752d6 --- /dev/null +++ b/hello.java @@ -0,0 +1,23 @@ +import javafx.application.Application; +import javafx.scene.Scene; +import javafx.scene.control.Label; +import javafx.scene.layout.StackPane; +import javafx.stage.Stage; + +public class HelloFX extends Application { + + @Override + public void start(Stage stage) { + String javaVersion = System.getProperty("java.version"); + String javafxVersion = System.getProperty("javafx.version"); + Label l = new Label("Hello, JavaFX " + javafxVersion + ", running on Java " + javaVersion + "."); + Scene scene = new Scene(new StackPane(l), 640, 480); + stage.setScene(scene); + stage.show(); + } + + public static void main(String[] args) { + launch(); + } + +} diff --git a/maven-template-jdk17/src/main/java/ch/hepia/Cpu.java b/maven-template-jdk17/src/main/java/ch/hepia/Cpu.java new file mode 100644 index 0000000000000000000000000000000000000000..de1cdd88d8b40af3185a056080ae3fd84d789377 --- /dev/null +++ b/maven-template-jdk17/src/main/java/ch/hepia/Cpu.java @@ -0,0 +1,216 @@ +package ch.hepia; + +import java.util.ArrayList; +import java.util.Scanner; + +public class Cpu implements Player { + private int money; + private int initialBet; + private int insurance; + private boolean insured; + private boolean doubled; + private int maxNumberOfHands; + private int currentHand; + private ArrayList<BlackJackHand> hands; + private boolean finishedTurn; + + // ---------------------------------------------------------------------------------------------------------- + // consturctor + + Cpu() { + this.money = 0; + this.initialBet = 0; + this.insurance = 0; + this.insured = false; + this.hands = new ArrayList<BlackJackHand>(); + this.addHand(); + this.maxNumberOfHands = 3; + this.doubled = false; + this.currentHand = 0; + this.finishedTurn = false; + } + + Cpu(int amount) { + this(); + // check amount positif + this.money = amount; + } + + // ---------------------------------------------------------------------------------------------------------- + // get/info + + public boolean getInsured() { + return this.insured; + } + + public int getMoney(){ + return this.money; + } + + public int getInsurance(){ + return this.insurance; + } + + public boolean getDoubled() { + return this.doubled; + } + + public int getInitialBet(){ + return this.initialBet; + } + + public ArrayList<BlackJackHand> getHands() { + return this.hands; + } + + public ArrayList<Card> giveCardsBack() { + ArrayList<Card> cards = new ArrayList<Card>(); + for (BlackJackHand hand : hands) { + cards.addAll(hand.getCards()); + } + this.hands = new ArrayList<BlackJackHand>(); + return cards; + } + + public int getNunmberOfHands() { + return this.hands.size(); + } + + public boolean getFinishedTurn(){ + return this.finishedTurn; + } + + // ---------------------------------------------------------------------------------------------------------- + // utilities + + public void addHand() { + BlackJackHand newHand = new BlackJackHand(); + this.hands.add(newHand); + } + + public void addMoney(int amount) { + // check amount positif + if (amount < 0) { + System.out.println("amount given for addMoney is negativ"); + System.exit(0); + } + this.money += amount; + } + + public void initialBet(int amount) { + this.money -= amount; + this.initialBet = amount; + this.hands.get(0).addBet(amount); + } + + public void bet(int amount) { + this.money -= amount; + this.hands.get(this.currentHand).addBet(amount); + } + + public void reset() { + this.initialBet = 0; + this.doubled = false; + this.insurance = 0; + this.insured = false; + this.hands = new ArrayList<BlackJackHand>(); + this.addHand(); + this.currentHand = 0; + this.finishedTurn = false; + } + + public void printCurrentHand() { + this.hands.get(this.currentHand).print(); + } + + public void printAllHands() { + for (int i = 0; i < this.hands.size(); i++) { + if (i == this.currentHand) { // si main courrante + System.out.println("Main " + (i + 1) + " (courrante) :"); + this.hands.get(i).print(); + } else { // si main pas courrante + System.out.println("Main " + (i + 1) + " :"); + this.hands.get(i).print(); + } + } + } + + public void printAllHandsAndScores() { + for (int i = 0; i < this.hands.size(); i++) { + System.out.println("--- Main " + (i + 1) + " ---"); + this.hands.get(i).print(); + System.out.println("score :" + this.hands.get(i).score()); + } + } + + public boolean canSplitCurrentHand() { + // check si main valide + // check si on a pas atteint le max de mains + // check si on a assez d'argent pour + return (this.hands.get(this.currentHand).canSplit() && this.hands.size() <= this.maxNumberOfHands) && this.money >= this.initialBet; + } + + public int scoreCurrentHand() { + return this.hands.get(this.currentHand).score(); + } + + public void nextHand() { + if (this.currentHand + 1 >= this.hands.size()) { + this.finishedTurn = true; + } else { + this.currentHand ++; + } + } + + public boolean isCurrentHandAceSplited(){ + return this.hands.get(currentHand).getAceSplited(); + } + + // ---------------------------------------------------------------------------------------------------------- + // game action + + public void insure() { + this.insured = true; + this.insurance = initialBet / 2; + this.bet(initialBet / 2); + } + + public void doubleDown() { + this.doubled = true; + bet(this.initialBet); + } + + public void split(Card cardL, Card cardR) { + // cree la nouvelle main + BlackJackHand newHand = new BlackJackHand(); + //indique que les mains sont split + newHand.isSplit(); + this.hands.get(this.currentHand).isSplit(); + //indique si les mains sont split depuis une pair d'as + if (this.hands.get(currentHand).cards.get(0).getRank() == 1) { + this.hands.get(currentHand).isAceSplit(); + newHand.isAceSplit(); + } + // copie la la carte 0 de la main courrante a al nouvelle + Card card = this.hands.get(this.currentHand).cards.get(0); + newHand.addCard(card); + // enleve la carte 0 de la main courante + this.hands.get(this.currentHand).cards.remove(0); + // ajoute une carte a chaque main + this.hands.get(this.currentHand).addCard(cardL); + newHand.addCard(cardR); + //bet sur la nouvelle main + this.money -= this.initialBet; + newHand.addBet(this.initialBet); + // ajoute la nouvelle main au joueur + this.hands.add(newHand); + } + + public void drawForCurrentHand(Card card) { + this.hands.get(this.currentHand).addCard(card); + } + + public void stayCurrentHand() { + this.hands.get(this.currentHand).stay(); + } +} diff --git a/maven-template-jdk17/src/main/java/ch/hepia/GameManager.java b/maven-template-jdk17/src/main/java/ch/hepia/GameManager.java deleted file mode 100644 index 19ffa7d7b8b9e22f4e2e53cb2f861696f2cea664..0000000000000000000000000000000000000000 --- a/maven-template-jdk17/src/main/java/ch/hepia/GameManager.java +++ /dev/null @@ -1,291 +0,0 @@ -package ch.hepia; - -import java.util.ArrayList; -import java.util.Scanner; - -public class GameManager { - - private Deck deck; - private Deck reserve; - private Human human; - private Dealer dealer; - - GameManager() { - this.deck = new Deck(); - this.dealer = new Dealer(); - this.reserve = new Deck(); - this.human = new Human(); - } - - GameManager(int amount, int number, int type) { - this.deck = new Deck(number, type); - this.dealer = new Dealer(); - this.reserve = new Deck(); - this.human = new Human(amount); - } - - public Card draw() { - if (this.deck.size() > 0) { - return this.deck.drawFromDeck(); - } else { - return this.reserve.drawFromDeck(); - } - } - - public void initDecks() { - // shuffle les cartes - this.deck.shuffleDeck(); - // split les carte deriere le sabot - this.reserve = this.deck.splitDeck(52); - } - - public void playTable() { - System.out.println("--------------------\nNouveau tour !\n--------------------"); - // dealer pioche sa carte - this.dealer.draw(this.draw()); - // check si joueur a assez d'argent pour jouer - if (this.human.getMoney() < 10) { - System.out.println("Vous n'avez plus assez d'argent. *dealer starts calling security*"); - System.exit(0); - } else { - // joueur pioche ses cartes - this.human.drawForCurrentHand(this.draw()); - this.human.drawForCurrentHand(this.draw()); - // demande la mise initial - System.out.println("Mise minimal de 10, combien misez vous ?"); - int input = App.scan.nextInt(); - while (input < 10) { - System.out.println("Pas assez, réessayez"); - input = App.scan.nextInt(); - } - System.out.println(); - this.human.initialBet(input); - } - // affiche la carte du croupier - System.out.println("--------------------\ncarte du croupier :"); - this.dealer.print(); - System.out.println("--------------------\n"); - playHumanTurn(); - playDealerTurn(); - moveMoney(); - } - - public void playHumanTurn() { - // presente main de depart - System.out.println("--------------------\nVoicit votre main de départ :"); - this.human.printCurrentHand(); - System.out.println("score :" + this.human.scoreCurrentHand()); - System.out.println("--------------------\n"); - - // propose assurance si dealer a as et si assez d'argent - if (this.dealer.getFirstCard().getRank() == 1 && this.human.getMoney() > this.human.getInitialBet() / 2) { - askInsurance(); - } - // regarde si assez d'argent pour doubler - // si pas assez on ne peut pas split non plus - // double ? sinon split ? sinon aucun des deux - if (this.human.getMoney() >= this.human.getInitialBet()) { - if (!this.human.getInsured()) { - // propose double down - this.askDoubleDown(); - if (this.human.getDoubled()) { - // decide si il prend un carte en plus - this.askCard(); - } else { - // joue sur chaque mains - while (!this.human.getFinishedTurn()) { - // propose split tant que c'est possible - while (this.human.canSplitCurrentHand()) { - this.askSplit(); - } - //peux recevoir des cartes que si la main n'est pas split de 2 aces - if (!this.human.isCurrentHandAceSplited()) { - // joue la main - humanPlayCurrentHand(); - } - this.human.nextHand(); - } - } - } - } else { - // joue une seul main, sans split ou double possible - humanPlayCurrentHand(); - } - // fin du tour et calcul - System.out.println("--------------------\nFin du tour, voici votre/vos mains et scores :"); - this.human.printAllHandsAndScores(); - System.out.println("--------------------\n"); - } - - public void humanPlayCurrentHand() { - boolean stayed = false; - // si score plus grand que 20 on stop, car soit 21 soit bust - while (this.human.scoreCurrentHand() < 21 && !stayed) { - stayed = this.askCard(); - } - System.out.println("Fin de cette main, score : " + this.human.scoreCurrentHand()); - } - - public void playDealerTurn() { - while (this.dealer.score() < 17) { - this.dealer.draw(this.draw()); - } - System.out.println("--------------------\nDEALER"); - this.dealer.print(); - System.out.println("score :" + this.dealer.score()); - System.out.println("--------------------\n"); - } - - public void askInsurance() { - // demande si assurance - System.out.println("--------------------\nVoulez-vous vous assurer\n1.oui\n2.non\n--------------------"); - int humanChoice = App.scan.nextInt(); - // boucle jusqu'a avoir un choix correcte - while (humanChoice != 1 && humanChoice != 2) { - System.out.println("Option inconnue, réessayez"); - humanChoice = App.scan.nextInt(); - } - // traite le choix - if (humanChoice == 1) { - human.insure(); - } - } - - public void askDoubleDown() { - // demande si double down - System.out.println("--------------------\nVoulez-vous doubler ?\n1. oui\n2. non\n--------------------"); - int humanChoice = App.scan.nextInt(); - // boucle jusqu'a avoir un choix correcte - while (humanChoice != 1 && humanChoice != 2) { - System.out.println("Option inconnue, réessayez"); - humanChoice = App.scan.nextInt(); - } - // traite le choix - if (humanChoice == 1) { - human.doubleDown(); - } - } - - public boolean askCard() { - // demande si veur une carte - System.out.println( - "--------------------\nVoulez-vous une carte ?\n1. oui et hit\n2. non et stay\n3. voir ma/mes mains\n--------------------"); - int humanChoice = App.scan.nextInt(); - // boucle jusqu'a avoir un choix correcte - while (humanChoice != 1 && humanChoice != 2 && humanChoice != 3) { - System.out.println("Option inconnue, réessayez"); - humanChoice = App.scan.nextInt(); - } - // tant qu'on demande ses mains - while (humanChoice == 3) { - human.printAllHandsAndScores(); - System.out.println( - "--------------------\nVoulez-vous une carte ?\n1. oui et hit\n2. non et stay\n3. voir ma/mes mains\n--------------------"); - humanChoice = App.scan.nextInt(); - } - // traite le choix - if (humanChoice == 1) { - human.drawForCurrentHand(this.draw()); - System.out.println("--------------------\nVotre main :"); - human.printCurrentHand(); - System.out.println("score :" + human.scoreCurrentHand()); - System.out.println("--------------------"); - return false; - } else { - human.stayCurrentHand(); - System.out.println("--------------------\nVous avez décider de stay avec cette main :"); - human.printCurrentHand(); - System.out.println("score :" + human.scoreCurrentHand()); - System.out.println("--------------------"); - return true; - } - } - - public void askSplit() { - System.out.println("--------------------\nVoulez-vous split ?\n1. oui \n2. non \n--------------------"); - int humanChoice = App.scan.nextInt(); - // boucle jusqu'a avoir un choix correcte - while (humanChoice != 1 && humanChoice != 2) { - System.out.println("Option inconnue, réessayez"); - humanChoice = App.scan.nextInt(); - } - // traite le choix - if (humanChoice == 1) { - // split - this.human.split(this.draw(), this.draw()); - human.printAllHandsAndScores(); - } - } - - public void moveMoney() { - int oldMoney = human.getMoney(); - // pour chaque mains du joueur - for (BlackJackHand hand : this.human.getHands()) { - // si main bust ou pas - if (hand.score() < 22) { - // si dealer a bust - if (dealer.score() < 22) { - // compare les mains - switch (dealer.compareHand(hand)) { - case 1: // dealer win - System.out.println("Vous avez perdu"); - // check if black jack and insured - if (this.dealer.score() == 999 && this.human.getInsured()) { - this.human.addMoney(this.human.getInsurance() * 3); - System.out.println("Assuré !"); - } - break; - case 0: // draw - System.out.println("Draw"); - // give back money - this.human.addMoney(hand.getBet()); - // check if black jack and insured - if (this.dealer.score() == 999 && this.human.getInsured()) { - this.human.addMoney(this.human.getInsurance() * 3); - System.out.println("Assuré !"); - } - break; - case -1: // dealer lose - System.out.println("Vous avez gagné"); - // if player black jack - if (hand.score() == 999) { // black jack pay - this.human.addMoney((hand.getBet() * 2) + (hand.getBet() / 2)); - System.out.println("Black Jack !"); - } else { // normal pay - this.human.addMoney(hand.getBet() * 2); - } - break; - default: - break; - } - } else { - // dealer bust, auto win - System.out.println("Vous avez gagné"); - // if player black jack - if (hand.score() == 999) { // black jack pay - this.human.addMoney((hand.getBet() * 2) + (hand.getBet() / 2)); - System.out.println("Black Jack !"); - } else { // normal pay - this.human.addMoney(hand.getBet() * 2); - } - } - } else { - // bust - System.out.println("Bust"); - } - } - System.out.println("Gain du tour : " + (this.human.getMoney() - oldMoney)); - System.out.println("Votre nouveau total : " + human.getMoney() + "\n"); - // reset player once money was given - this.human.reset(); - } - - public void endTurn() { - // reset dealer - dealer.reset(); - // check need of new decks - if (this.reserve.size() < 52) { - this.initDecks(); - } - } -} diff --git a/maven-template-jdk17/target/classes/ch/hepia/App.class b/maven-template-jdk17/target/classes/ch/hepia/App.class index 2caa64e880800c71ab8aba1a8cb48f1547d993e2..37a044733044d5e6a2d6f8c7d5fdca19830ae5f1 100644 Binary files a/maven-template-jdk17/target/classes/ch/hepia/App.class and b/maven-template-jdk17/target/classes/ch/hepia/App.class differ diff --git a/maven-template-jdk17/target/classes/ch/hepia/COLOR.class b/maven-template-jdk17/target/classes/ch/hepia/COLOR.class index d5ff0f4bbb760b2b3ae5ebd2d9e173c61e415f2d..46fb2582cd6654978e9b61539b00283e198d55d1 100644 Binary files a/maven-template-jdk17/target/classes/ch/hepia/COLOR.class and b/maven-template-jdk17/target/classes/ch/hepia/COLOR.class differ diff --git a/maven-template-jdk17/target/classes/ch/hepia/Card.class b/maven-template-jdk17/target/classes/ch/hepia/Card.class index 9c06c45bd8602a312c2a0b05d25b1cd5b3dc3e10..4f1f973798d513da18cafa6aabbff0be4c255e0a 100644 Binary files a/maven-template-jdk17/target/classes/ch/hepia/Card.class and b/maven-template-jdk17/target/classes/ch/hepia/Card.class differ diff --git a/maven-template-jdk17/target/classes/ch/hepia/CardSet.class b/maven-template-jdk17/target/classes/ch/hepia/CardSet.class index 379471b2549d1aa6d6a2c4c439f8b560f8755d85..5dcd43f2efc74c85de20e8f0b48f97943bd55fc2 100644 Binary files a/maven-template-jdk17/target/classes/ch/hepia/CardSet.class and b/maven-template-jdk17/target/classes/ch/hepia/CardSet.class differ diff --git a/maven-template-jdk17/target/classes/ch/hepia/Cpu.class b/maven-template-jdk17/target/classes/ch/hepia/Cpu.class new file mode 100644 index 0000000000000000000000000000000000000000..e4e96203748d088b5334499744af0c752fca5385 Binary files /dev/null and b/maven-template-jdk17/target/classes/ch/hepia/Cpu.class differ diff --git a/maven-template-jdk17/target/classes/ch/hepia/Deck.class b/maven-template-jdk17/target/classes/ch/hepia/Deck.class index f6b5dff692a0f06bd5c4208c203c1a4cb58a646b..30d9b92baeee99415fe9076cabb4f3de48e19651 100644 Binary files a/maven-template-jdk17/target/classes/ch/hepia/Deck.class and b/maven-template-jdk17/target/classes/ch/hepia/Deck.class differ diff --git a/maven-template-jdk17/target/classes/ch/hepia/GameManager.class b/maven-template-jdk17/target/classes/ch/hepia/GameManager.class deleted file mode 100644 index 223d6913fbd9d33291b907bcdbbb9d18d35ac8d3..0000000000000000000000000000000000000000 Binary files a/maven-template-jdk17/target/classes/ch/hepia/GameManager.class and /dev/null differ diff --git a/maven-template-jdk17/target/classes/ch/hepia/Hand.class b/maven-template-jdk17/target/classes/ch/hepia/Hand.class index 69c656b73cde02efa9e988bcab307cbdc6a0b5b4..b35bc42c3f705b00c9c7b15f6a158f59e7af884e 100644 Binary files a/maven-template-jdk17/target/classes/ch/hepia/Hand.class and b/maven-template-jdk17/target/classes/ch/hepia/Hand.class differ diff --git a/maven-template-jdk17/target/classes/ch/hepia/Human.class b/maven-template-jdk17/target/classes/ch/hepia/Human.class index 1e948435146b0a80524654e7309a716fcb78b270..42c05de239c0dd24285da983f1cf88313878e770 100644 Binary files a/maven-template-jdk17/target/classes/ch/hepia/Human.class and b/maven-template-jdk17/target/classes/ch/hepia/Human.class differ diff --git a/maven-template-jdk17/target/test-classes/ch/hepia/AppTest.class b/maven-template-jdk17/target/test-classes/ch/hepia/AppTest.class new file mode 100644 index 0000000000000000000000000000000000000000..284a6e254353ee9d50f05b3041636523cb395cec Binary files /dev/null and b/maven-template-jdk17/target/test-classes/ch/hepia/AppTest.class differ diff --git a/part_3/pom.xml b/part_3/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..79f3ce6f3c0b7a7331c1691ff9f6f86d7577b024 --- /dev/null +++ b/part_3/pom.xml @@ -0,0 +1,49 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>org.openjfx</groupId> + <artifactId>sample</artifactId> + <version>1.0.0</version> + <properties> + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> + <maven.compiler.source>11</maven.compiler.source> + <maven.compiler.target>11</maven.compiler.target> + </properties> + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>4.11</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.openjfx</groupId> + <artifactId>javafx-controls</artifactId> + <version>21.0.2</version> + </dependency> + </dependencies> + <build> + <plugins> + <plugin> + <artifactId>maven-surefire-plugin</artifactId> + <version>2.22.1</version> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>3.8.0</version> + <configuration> + <release>11</release> + </configuration> + </plugin> + <plugin> + <groupId>org.openjfx</groupId> + <artifactId>javafx-maven-plugin</artifactId> + <version>0.0.3</version> + <configuration> + <mainClass>org.openjfx.App</mainClass> + </configuration> + </plugin> + </plugins> + </build> +</project> diff --git a/part_3/src/main/java/module-info.java b/part_3/src/main/java/module-info.java new file mode 100644 index 0000000000000000000000000000000000000000..1bef042c6f982a27941bf31d500bce327c3b5ff7 --- /dev/null +++ b/part_3/src/main/java/module-info.java @@ -0,0 +1,4 @@ +module org.openjfx { + requires javafx.controls; + exports org.openjfx; +} \ No newline at end of file diff --git a/part_3/src/main/java/org/openjfx/App.java b/part_3/src/main/java/org/openjfx/App.java new file mode 100644 index 0000000000000000000000000000000000000000..188501a8dbfe12e60d5f4c0286e09ad9a47e46c9 --- /dev/null +++ b/part_3/src/main/java/org/openjfx/App.java @@ -0,0 +1,425 @@ +package org.openjfx; + +import java.io.FileInputStream; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.Scanner; +import java.util.stream.Stream; + +import javafx.application.Application; +import javafx.beans.value.ObservableValue; +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.scene.Group; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.control.CheckBox; +import javafx.scene.control.Label; +import javafx.scene.control.RadioButton; +import javafx.scene.control.TextField; +import javafx.scene.control.ToggleGroup; +import javafx.scene.control.skin.LabeledSkinBase; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.scene.layout.Background; +import javafx.scene.layout.BackgroundFill; +import javafx.scene.layout.BackgroundImage; +import javafx.scene.layout.BackgroundPosition; +import javafx.scene.layout.BackgroundRepeat; +import javafx.scene.layout.BackgroundSize; +import javafx.scene.layout.ColumnConstraints; +import javafx.scene.layout.GridPane; +import javafx.scene.layout.HBox; +import javafx.scene.layout.RowConstraints; +import javafx.scene.layout.StackPane; +import javafx.scene.layout.VBox; +import javafx.scene.paint.Color; +import javafx.stage.Stage; +import java.io.File; + +/** + * JavaFX App + */ +public class App extends Application { + + // number of cpu + int numberOfCpu = 0; + boolean dumb = true; + GameManager gameManager = new GameManager(1000, 6, 52); + public static Scanner scan = new Scanner(System.in); + + @Override + public void start(Stage stage) { + /* + * var javaVersion = SystemInfo.javaVersion(); + * var javafxVersion = SystemInfo.javafxVersion(); + * + * var label = new Label("Hello, JavaFX " + javafxVersion + ", running on Java " + * + javaVersion + "."); + * var scene = new Scene(new StackPane(label), 640, 480); + * stage.setScene(scene); + */ + stage.setTitle("Blackjack Rampf");// nom du stage + GridPane inGameGrid = new GridPane(); + Scene sceneInGame = new Scene(inGameGrid, 1150, 500); + GridPane menuGrid = new GridPane(); + Scene sceneMenu = new Scene(menuGrid, 300, 300); + + // *************************************************************************************************************** + // start menu + menuGrid.setHgap(10); + menuGrid.setVgap(10); + + // label + Label numberOfCpuLabel = new Label("Number of Cpu"); + menuGrid.add(numberOfCpuLabel, 0, 0); + // radio group + ToggleGroup numberOfCpuGroup = new ToggleGroup(); + // button 1 + RadioButton button1 = new RadioButton("1"); + button1.setToggleGroup(numberOfCpuGroup); + button1.setOnAction(e -> numberOfCpu = 1); + menuGrid.add(button1, 0, 1); + // button 2 + RadioButton button2 = new RadioButton("2"); + button2.setToggleGroup(numberOfCpuGroup); + button2.setOnAction(e -> numberOfCpu = 2); + menuGrid.add(button2, 0, 2); + // button 3 + RadioButton button3 = new RadioButton("3"); + menuGrid.add(button3, 0, 3); + button3.setOnAction(e -> numberOfCpu = 3); + button3.setToggleGroup(numberOfCpuGroup); + + // ai label + Label smartLabel = new Label("Smart ai ?"); + menuGrid.add(smartLabel, 1, 0); + // checkbox + CheckBox smartCheckBox = new CheckBox(); + smartCheckBox.setText("make theme smart !"); + smartCheckBox.setOnAction(e -> { + if (smartCheckBox.isSelected()) { + dumb = false; + } else { + dumb = true; + } + }); + menuGrid.add(smartCheckBox, 1, 1); + + // start button + Button button_start = new Button(); + button_start.setText("start game"); + menuGrid.add(button_start, 0, 4); + button_start.setOnAction(e -> { + if (numberOfCpu != 0) { + gameManager.addCpu(numberOfCpu, dumb); + gameManager.shuffleDeck(); + System.out.println(smartCheckBox.isSelected()); + stage.setScene(sceneInGame); + } + }); + + // ****************************************************************************************************************************************** + // in game scene + + inGameGrid.setHgap(10); + inGameGrid.setVgap(10); + BackgroundFill background = new BackgroundFill(Color.GREEN, null, null); + inGameGrid.setBackground(new Background(background)); + + Image voidPng = new Image("void.png"); + // images view + + ArrayList<ImageView> imgViews = new ArrayList<ImageView>(); + // 0-9 dealer, 10-19 hand1, 20-29 hand2, 30-39 hand3 + for (int i = 0; i < 40; i++) { + ImageView imageView = new ImageView(); + imageView.setFitHeight(75); + imageView.setFitWidth(75); + imgViews.add(imageView); + if (i < 10) { + inGameGrid.add(imageView, 2 + i, 0); + } else if (i < 20) { + inGameGrid.add(imageView, 2 + i - 10, 3); + } else if (i < 30) { + inGameGrid.add(imageView, 2 + i - 20, 4); + } else { + inGameGrid.add(imageView, 2 + i - 30, 5); + } + imageView.setImage(voidPng); + } + + // labels + Label carteDealer = new Label("Carte du dealer"); + inGameGrid.add(carteDealer, 0, 0); + Label argent = new Label("Argent"); + inGameGrid.add(argent, 0, 1); + Label argentValue = new Label("1000"); + inGameGrid.add(argentValue, 1, 1); + Label mise = new Label("mise"); + inGameGrid.add(mise, 0, 2); + Label miseValue = new Label("0"); + inGameGrid.add(miseValue, 1, 2); + Label main1 = new Label("main 1"); + inGameGrid.add(main1, 0, 3); + Label main2 = new Label("main 2"); + inGameGrid.add(main2, 0, 4); + Label main3 = new Label("main 3"); + inGameGrid.add(main3, 0, 5); + + main1.setBackground(new Background(new BackgroundFill(Color.BLUEVIOLET, null, null))); + main2.setBackground(new Background(new BackgroundFill(Color.BEIGE, null, null))); + main3.setBackground(new Background(new BackgroundFill(Color.BEIGE, null, null))); + + Label scoreDealer = new Label(); + inGameGrid.add(scoreDealer, 1, 0); + Label score1 = new Label(); + inGameGrid.add(score1, 1, 3); + Label score2 = new Label(); + inGameGrid.add(score2, 1, 4); + Label score3 = new Label(); + inGameGrid.add(score3, 1, 5); + + // textfields + TextField betAmount = new TextField("0"); + // only accepts numbers + betAmount.textProperty() + .addListener((ObservableValue<? extends String> observable, String oldValue, String newValue) -> { + if (!newValue.matches("\\d*")) { + betAmount.setText(newValue.replaceAll("[^\\d]", "")); + } + }); + inGameGrid.add(betAmount, 6, 7); + + // #################################### + // action buttons + + // END TURN + Button btnEndTurn = new Button("End Turn"); + btnEndTurn.setOnAction(e -> { + // human must not be playing, either ended a turn or can't place initial bet + // can still use this action to get cpus to play + if (!gameManager.human.getPlaying()) { + // if dealer has no cards because we didn't went the initial bet route + if (gameManager.getDealerHandSize() == 0) { + Card card = gameManager.draw(); + imgViews.get(0).setImage(new Image(card.getPngName())); + gameManager.giveDealerOneCard(card); + } + // play cpus + gameManager.playCpus(); + // play dealer + while (gameManager.getDealerScore() < 17) { + // dealer draw + Card card = gameManager.draw(); + imgViews.get(gameManager.getDealerHandSize()).setImage(new Image(card.getPngName())); + gameManager.giveDealerOneCard(card); + // maj dealer score + scoreDealer.setText(String.valueOf(gameManager.getDealerScore())); + } + // clacul argent + if (gameManager.human.getInitialBet() != 0) {// human was in the turn + gameManager.moveMoneyHuman(); + } + gameManager.moveMoneyCpus(); + // maj label mise et argent + argentValue.setText(String.valueOf(gameManager.human.getMoney())); + miseValue.setText(String.valueOf(gameManager.human.getTotalBet())); + } + }); + inGameGrid.add(btnEndTurn, 0, 6); + // DRAW + Button btnDraw = new Button("Draw"); + btnDraw.setOnAction(e -> { + // human must be playing, aka made an initial bet + if (gameManager.human.getPlaying()) { + // draw the card + Card card = gameManager.draw(); + gameManager.giveHumanOneCard(card); + imgViews.get(9 + (gameManager.human.getCurrentHandValue() * 10) + + gameManager.human.getCurrentHand().getNunmberOfCards()) + .setImage(new Image(card.getPngName())); + // update scores + switch (gameManager.human.getCurrentHandValue()) { + case 0: + score1.setText(String.valueOf(gameManager.human.scoreCurrentHand())); + break; + case 1: + score2.setText(String.valueOf(gameManager.human.scoreCurrentHand())); + break; + default: + score3.setText(String.valueOf(gameManager.human.scoreCurrentHand())); + break; + } + // next hand if is doubled, because human drew his only card allowed + if (gameManager.human.getDoubled()) { + gameManager.human.stayCurrentHand(); + gameManager.human.nextHand(); + // no maj current hand indicator, only one hand when double + } + // next hand if burst or 21 + if (gameManager.human.getCurrentHand().score() > 20) { + gameManager.human.stayCurrentHand(); + gameManager.human.nextHand(); + // maj current hand color indicator + switch (gameManager.human.getCurrentHandValue()) { + case 0: + main1.setBackground(new Background(new BackgroundFill(Color.BLUEVIOLET, null, null))); + main2.setBackground(new Background(new BackgroundFill(Color.BEIGE, null, null))); + main3.setBackground(new Background(new BackgroundFill(Color.BEIGE, null, null))); + break; + case 1: + main1.setBackground(new Background(new BackgroundFill(Color.BEIGE, null, null))); + main2.setBackground(new Background(new BackgroundFill(Color.BLUEVIOLET, null, null))); + main3.setBackground(new Background(new BackgroundFill(Color.BEIGE, null, null))); + break; + default: + main1.setBackground(new Background(new BackgroundFill(Color.BEIGE, null, null))); + main2.setBackground(new Background(new BackgroundFill(Color.BEIGE, null, null))); + main3.setBackground(new Background(new BackgroundFill(Color.BLUEVIOLET, null, null))); + break; + } + + } + } + }); + inGameGrid.add(btnDraw, 1, 6); + // SPLIT + Button btnSplit = new Button("Split"); + btnSplit.setOnAction(e -> { + // human must be playing, aka made an initial bet + if (gameManager.human.getPlaying()) { + // action only of human can split hand, and has not doubled + if (gameManager.human.canSplitCurrentHand() && !gameManager.human.getDoubled()) { + Card newL = gameManager.draw(); + Card newR = gameManager.draw(); + Card cardR = gameManager.human.getCurrentHand().cards.get(1); + // remplace carte de droite par newL + imgViews.get(9 + gameManager.human.getCurrentHandValue() * 10 + 2) + .setImage(new Image(newL.getPngName())); + // ajouter carte de droite a la bonne main + imgViews.get(9 + gameManager.human.getNunmberOfHands() * 10 + 1) + .setImage(new Image(cardR.getPngName())); + // ajouter new R a la bonne main + imgViews.get(9 + gameManager.human.getNunmberOfHands() * 10 + 2) + .setImage(new Image(newR.getPngName())); + // split + gameManager.human.split(newL, newR); + // maj label mise et argent + argentValue.setText(String.valueOf(gameManager.human.getMoney())); + miseValue.setText(String.valueOf(gameManager.human.getTotalBet())); + } + } + }); + inGameGrid.add(btnSplit, 2, 6); + // DOUBLE + Button btnDouble = new Button("Double"); + btnDouble.setOnAction(e -> { + // human must be playing, aka made an initial bet + if (gameManager.human.getPlaying()) { + // can double only if has one hand, aka no previous split, and enougth money, + // and has not already doubled, and is not insured + if (gameManager.human.getNunmberOfHands() == 1 + && gameManager.human.getMoney() >= gameManager.human.getInitialBet() + && !gameManager.human.getDoubled() && !gameManager.human.getInsured()) { + gameManager.human.doubleDown(); + // maj label mise et argent + argentValue.setText(String.valueOf(gameManager.human.getMoney())); + miseValue.setText(String.valueOf(gameManager.human.getTotalBet())); + } + } + }); + inGameGrid.add(btnDouble, 3, 6); + // INSURE + Button btnInsure = new Button("Insure"); + btnInsure.setOnAction(e -> { + // human must be playing, aka made an initial bet + if (gameManager.human.getPlaying()) { + // if dealer ace, only 1 hand (no split), not doubled down, and enough money, + // and not have already insured + if (gameManager.getDealerFirstCard().getRank() == 1 && gameManager.human.getNunmberOfHands() == 1 + && !gameManager.human.getDoubled() + && gameManager.human.getMoney() >= gameManager.human.getInitialBet() / 2 + && !gameManager.human.getInsured()) { + gameManager.human.insure(); + // maj label mise et argent + argentValue.setText(String.valueOf(gameManager.human.getMoney())); + miseValue.setText(String.valueOf(gameManager.human.getTotalBet())); + } + } + }); + inGameGrid.add(btnInsure, 4, 6); + // STAY + Button btnStay = new Button("Stay"); + btnStay.setOnAction(e -> { + // human must be playing + if (gameManager.human.getPlaying()) { + gameManager.human.stayCurrentHand(); + gameManager.human.nextHand(); + // maj current hand color indicator + switch (gameManager.human.getCurrentHandValue()) { + case 0: + main1.setBackground(new Background(new BackgroundFill(Color.BLUEVIOLET, null, null))); + main2.setBackground(new Background(new BackgroundFill(Color.BEIGE, null, null))); + main3.setBackground(new Background(new BackgroundFill(Color.BEIGE, null, null))); + break; + case 1: + main1.setBackground(new Background(new BackgroundFill(Color.BEIGE, null, null))); + main2.setBackground(new Background(new BackgroundFill(Color.BLUEVIOLET, null, null))); + main3.setBackground(new Background(new BackgroundFill(Color.BEIGE, null, null))); + break; + default: + main1.setBackground(new Background(new BackgroundFill(Color.BEIGE, null, null))); + main2.setBackground(new Background(new BackgroundFill(Color.BEIGE, null, null))); + main3.setBackground(new Background(new BackgroundFill(Color.BLUEVIOLET, null, null))); + break; + } + } + }); + inGameGrid.add(btnStay, 5, 6); + // BET + Button btnBet = new Button("Bet initial amount"); + btnBet.setOnAction(e -> { + // action only if human has no initial bet, amount bet always positiv because of + // textfield implementation + if (gameManager.human.getInitialBet() == 0) { + gameManager.human.initialBet(Integer.parseInt(betAmount.getText())); + // maj label mise et argent + argentValue.setText(String.valueOf(gameManager.human.getMoney())); + miseValue.setText(String.valueOf(gameManager.human.getTotalBet())); + // dealer draw 1 + view + Card card = gameManager.draw(); + imgViews.get(0).setImage(new Image(card.getPngName())); + gameManager.giveDealerOneCard(card); + // human draw 2 + view + Card card1 = gameManager.draw(); + Card card2 = gameManager.draw(); + imgViews.get(10).setImage(new Image(card1.getPngName())); + imgViews.get(11).setImage(new Image(card2.getPngName())); + gameManager.giveHumanOneCard(card1); + gameManager.giveHumanOneCard(card2); + } + }); + inGameGrid.add(btnBet, 6, 6); + // NEW TURN + Button btnNewTurn = new Button("New Turn"); + + inGameGrid.add(btnNewTurn, 7, 6); + + // stage.setScene(sceneMenu); + stage.setScene(sceneMenu); + stage.show(); + } + + /* + * public void cleanView(GridPane gridPane, ArrayList<ImageView> imageViews){ + * for (ImageView imageView : imageViews) { + * gridPane.getChildren().remove(imageView); + * } + * } + */ + + public static void main(String[] args) { + launch(); + } +} \ No newline at end of file diff --git a/part_3/src/main/java/org/openjfx/BlackJackHand.java b/part_3/src/main/java/org/openjfx/BlackJackHand.java new file mode 100644 index 0000000000000000000000000000000000000000..281b8fe0160c6c372207aff4d79d25210d1011a1 --- /dev/null +++ b/part_3/src/main/java/org/openjfx/BlackJackHand.java @@ -0,0 +1,111 @@ +package org.openjfx; +import java.util.ArrayList; + +public class BlackJackHand extends Hand { + + private int bet; + private boolean stayed; + private boolean splited; + private boolean aceSplited; + + BlackJackHand() { + super(); + this.bet = 0; + this.stayed = false; + this.splited = false; + this.aceSplited = false; + } + + public int getBet() { + return this.bet; + } + + public boolean getAceSplited(){ + return this.aceSplited; + } + + public ArrayList<Card> getCards() { + return this.cards; + } + + public int getNunmberOfCards(){ + return this.cards.size(); + } + + public boolean getStayed(){ + return this.stayed; + } + + public void addBet(int amount) { + this.bet += amount; + } + + public void stay() { + this.stayed = true; + } + + public void isSplit() { + this.splited = true; + } + + public void isAceSplit() { + this.aceSplited = true; + } + + public int score() { + int score = 0; + // score normal + // force toutes les forces au rang et calcul le premier score + for (Card card : this.cards) { + if (card.getRank() < 10) { + // force de as a 9 + card.setStrength(card.getRank()); + } else { + // force de 10 a roi + card.setStrength(10); + } + score += card.getStrength(); + } + // bust ou pas + if (score < 21) { // safe + // check combien d'aces il y a + int smolAce = 0; + for (Card card : this.cards) { + if (card.getStrength() == 1) { + smolAce++; + } + } + // check le score max legal + for (int i = 0; i < smolAce; i++) { + if (score + 10 < 22) { + score += 10; + } + } + } + // check si black jack: 2 cards, no split, 21 + if (this.cards.size() == 2 && !this.splited && score == 21) { + score = 999; + } + return score; + } + + public void print() { + for (Card card : this.cards) { + System.out.println(card.getFullName()); + } + } + + public boolean canSplit() { + return (this.cards.get(0).getRank() == this.cards.get(1).getRank() && this.cards.size() == 2); + } + + public int compareTo(BlackJackHand handToCampare) { + if (this.score() > handToCampare.score()) { + return 1; + } else if (this.score() < handToCampare.score()) { + return -1; + } else { + return 0; + } + } +} diff --git a/part_3/src/main/java/org/openjfx/COLOR.java b/part_3/src/main/java/org/openjfx/COLOR.java new file mode 100644 index 0000000000000000000000000000000000000000..ea937636d00b5bd53f51ae494de2064c252cfd89 --- /dev/null +++ b/part_3/src/main/java/org/openjfx/COLOR.java @@ -0,0 +1,10 @@ +package org.openjfx; + +public enum COLOR { + aucune, + carreau, + coeur, + pique, + trefle, +} + diff --git a/part_3/src/main/java/org/openjfx/Card.java b/part_3/src/main/java/org/openjfx/Card.java new file mode 100644 index 0000000000000000000000000000000000000000..79df8b479ffd1652a5ec2562b9b8de71dcd6551f --- /dev/null +++ b/part_3/src/main/java/org/openjfx/Card.java @@ -0,0 +1,100 @@ +package org.openjfx; + +import javafx.scene.paint.Color; + +public class Card { + private final COLOR color; + private final int rank; + private int strength; + + String[] NAMES_COLORS = { "aucune", "carreau", "coeur", "pique", "trefle" }; + String[] NAMES_RANK = { "Joker", "As", "2", "3", "4", "5", "6", "7", "8", "9", "10", "Valet", "Dame", "Roi" }; + + // -------------------------------------------------------------------------------------- + // constructor + + public Card(COLOR color, int rank) { + if (rank < 0 || rank > 13) { + throw new RuntimeException("rang doit être compris dans [0;13]"); + } + if (strength < 0) { + throw new RuntimeException("force doit être positive"); + } + this.color = color; + this.rank = rank; + } + + // -------------------------------------------------------------------------------------- + // get + + public Card(COLOR color, int rank, int strength) { + this(color, rank); + this.strength = strength; + } + + public COLOR getColor() { + return this.color; + } + + public String getColorName() { + return this.color.toString(); + } + + public int getRank() { + return this.rank; + } + + public String getRankName() { + return NAMES_RANK[this.rank]; + } + + public int getStrength() { + return this.strength; + } + + public int getBjStrength() { + if (this.strength == 1) { + return 11; + } else if (this.strength > 9) { + return 10; + } else { + return this.strength; + } + } + + public void setStrength(int strength) { + this.strength = strength; + } + + public String getFullName() { + if (this.rank == 0) { + return this.getRankName(); + } else { + return getRankName() + " de " + getColorName(); + } + } + + public String getPngName() { + String pngName = new String(); + + switch (this.color) { + case carreau: + pngName = new String(String.valueOf(this.rank) + "diamonds.png"); + break; + case coeur: + pngName = new String(String.valueOf(this.rank) + "hearts.png"); + break; + case trefle: + pngName = new String(String.valueOf(this.rank) + "clubs.png"); + break; + case pique: + pngName = new String(String.valueOf(this.rank) + "spades.png"); + break; + default: + System.out.println("FAILED_NAME"); + break; + } + + return pngName; + } +} \ No newline at end of file diff --git a/part_3/src/main/java/org/openjfx/Cpu.java b/part_3/src/main/java/org/openjfx/Cpu.java new file mode 100644 index 0000000000000000000000000000000000000000..f598e7f7fad3a96bf665398a7287dae190ecc9f6 --- /dev/null +++ b/part_3/src/main/java/org/openjfx/Cpu.java @@ -0,0 +1,335 @@ +package org.openjfx; +import java.util.ArrayList; +import java.util.Scanner; + +public class Cpu implements Player { + private int money; + private int initialBet; + private int insurance; + private boolean insured; + private boolean doubled; + private int maxNumberOfHands; + private int currentHand; + private ArrayList<BlackJackHand> hands; + private boolean finishedTurn; + private boolean isDumb; + public boolean dead; + + // ---------------------------------------------------------------------------------------------------------- + // strat arrays + + /* + * draw = 1 + * stay = 2 + * double = 3 + * split = 4 + * forfeit = 5 + */ + + private static int valueArray[][] = { + {1, 1, 1, 1, 1, 1, 1, 1, 1, 1},//8 or less + {1, 3, 3, 3, 3, 1, 1, 1, 1, 1},//9 + {3, 3, 3, 3, 3, 3, 3, 3, 1, 1},//10 + {3, 3, 3, 3, 3, 3, 3, 3, 3, 1},//11 + {1, 1, 2, 2, 2, 1, 1, 1, 1, 1},//12 + {2, 2, 2, 2, 2, 1, 1, 1, 1, 1},//13 + {2, 2, 2, 2, 2, 1, 1, 1, 1, 1},//14 + {2, 2, 2, 2, 2, 1, 1, 1, 5, 1},//15 + {2, 2, 2, 2, 2, 1, 1, 5, 5, 5},//16 + {2, 2, 2, 2, 2, 2, 2, 2, 2, 2},//17 or more + }; + + private static int asArray[][] = { + {1, 1, 1, 3, 3, 1, 1, 1, 1, 1},//2 + {1, 1, 1, 3, 3, 1, 1, 1, 1, 1},//3 + {1, 1, 3, 3, 3, 1, 1, 1, 1, 1},//4 + {1, 1, 3, 3, 3, 1, 1, 1, 1, 1},//5 + {1, 3, 3, 3, 3, 1, 1, 1, 1, 1},//6 + {2, 3, 3, 3, 3, 2, 2, 1, 1, 1},//7 + {2, 2, 2, 2, 2, 2, 2, 2, 2, 2},//8 9 10 + }; + + private static int pairArray[][] = { + {1, 1, 4, 4, 4, 4, 1, 1, 1, 1},//2 + {1, 1, 4, 4, 4, 4, 1, 1, 1, 1},//3 + {1, 1, 1, 1, 1, 1, 1, 1, 1, 1},//4 + {3, 3, 3, 3, 3, 3, 3, 3, 1, 1},//5 + {1, 4, 4, 4, 4, 1, 1, 1, 1, 1},//6 + {4, 4, 4, 4, 4, 4, 1, 1, 1, 1},//7 + {4, 4, 4, 4, 4, 4, 4, 4, 4, 4},//8 + {4, 4, 4, 4, 4, 2, 4, 4, 2, 2},//9 + {2, 2, 2, 2, 2, 2, 2, 2, 2, 2},//10 + {4, 4, 4, 4, 4, 4, 4, 4, 4, 4},//as +}; + + // ---------------------------------------------------------------------------------------------------------- + // consturctor + + Cpu() { + this.money = 0; + this.initialBet = 0; + this.insurance = 0; + this.insured = false; + this.hands = new ArrayList<BlackJackHand>(); + this.addHand(); + this.maxNumberOfHands = 3; + this.doubled = false; + this.currentHand = 0; + this.finishedTurn = false; + this.isDumb = true; + this.dead = false; + } + Cpu(int amount, boolean isDumb) { + this(); + // check amount positif + this.money = amount; + this.isDumb = isDumb; + } + + // ---------------------------------------------------------------------------------------------------------- + // get/info + + public boolean getInsured() { + return this.insured; + } + + public int getMoney(){ + return this.money; + } + + public int getInsurance(){ + return this.insurance; + } + + public boolean getDoubled() { + return this.doubled; + } + + public int getInitialBet(){ + return this.initialBet; + } + + public ArrayList<BlackJackHand> getHands() { + return this.hands; + } + + public ArrayList<Card> giveCardsBack() { + ArrayList<Card> cards = new ArrayList<Card>(); + for (BlackJackHand hand : hands) { + cards.addAll(hand.getCards()); + } + this.hands = new ArrayList<BlackJackHand>(); + return cards; + } + + public int getNunmberOfHands() { + return this.hands.size(); + } + + public boolean getDumb(){ + return this.isDumb; + } + + public boolean getFinishedTurn(){ + return this.finishedTurn; + } + + public BlackJackHand getCurrentHand(){ + return this.hands.get(currentHand); + } + + public boolean getDead(){ + return this.dead; + } + + // ---------------------------------------------------------------------------------------------------------- + // utilities + + public void addHand() { + BlackJackHand newHand = new BlackJackHand(); + this.hands.add(newHand); + } + + public void addMoney(int amount) { + // check amount positif + if (amount < 0) { + System.out.println("amount given for addMoney is negativ"); + System.exit(0); + } + this.money += amount; + } + + public void initialBet(int amount) { + this.money -= amount; + this.initialBet = amount; + this.hands.get(0).addBet(amount); + } + + public void bet(int amount) { + this.money -= amount; + this.hands.get(this.currentHand).addBet(amount); + } + + public void reset() { + this.initialBet = 0; + this.doubled = false; + this.insurance = 0; + this.insured = false; + this.hands = new ArrayList<BlackJackHand>(); + this.addHand(); + this.currentHand = 0; + this.finishedTurn = false; + } + + public void printCurrentHand() { + this.hands.get(this.currentHand).print(); + } + + public void printAllHands() { + for (int i = 0; i < this.hands.size(); i++) { + if (i == this.currentHand) { // si main courrante + System.out.println("Main " + (i + 1) + " (courrante) :"); + this.hands.get(i).print(); + } else { // si main pas courrante + System.out.println("Main " + (i + 1) + " :"); + this.hands.get(i).print(); + } + } + } + + public void printAllHandsAndScores() { + for (int i = 0; i < this.hands.size(); i++) { + System.out.println("--- Main " + (i + 1) + " ---"); + this.hands.get(i).print(); + System.out.println("score :" + this.hands.get(i).score()); + } + } + + public boolean canSplitCurrentHand() { + // check si main valide + // check si on a pas atteint le max de mains + // check si on a assez d'argent pour + return (this.hands.get(this.currentHand).canSplit() && this.hands.size() <= this.maxNumberOfHands) && this.money >= this.initialBet; + } + + public int scoreCurrentHand() { + return this.hands.get(this.currentHand).score(); + } + + public void nextHand() { + if (this.currentHand + 1 >= this.hands.size()) { + this.finishedTurn = true; + } else { + this.currentHand ++; + } + } + + public boolean isCurrentHandAceSplited(){ + return this.hands.get(currentHand).getAceSplited(); + } + + public void died(){ + this.dead = true; + } + + // ---------------------------------------------------------------------------------------------------------- + // game action + + public void insure() { + this.insured = true; + this.insurance = initialBet / 2; + this.bet(initialBet / 2); + } + + public void doubleDown() { + this.doubled = true; + bet(this.initialBet); + } + + public void split(Card cardL, Card cardR) { + // cree la nouvelle main + BlackJackHand newHand = new BlackJackHand(); + //indique que les mains sont split + newHand.isSplit(); + this.hands.get(this.currentHand).isSplit(); + //indique si les mains sont split depuis une pair d'as + if (this.hands.get(currentHand).cards.get(0).getRank() == 1) { + this.hands.get(currentHand).isAceSplit(); + newHand.isAceSplit(); + } + // copie la la carte 0 de la main courrante a al nouvelle + Card card = this.hands.get(this.currentHand).cards.get(0); + newHand.addCard(card); + // enleve la carte 0 de la main courante + this.hands.get(this.currentHand).cards.remove(0); + // ajoute une carte a chaque main + this.hands.get(this.currentHand).addCard(cardL); + newHand.addCard(cardR); + //bet sur la nouvelle main + this.money -= this.initialBet; + newHand.addBet(this.initialBet); + // ajoute la nouvelle main au joueur + this.hands.add(newHand); + } + + public void drawForCurrentHand(Card card) { + this.hands.get(this.currentHand).addCard(card); + } + + public void stayCurrentHand() { + this.hands.get(this.currentHand).stay(); + } + + public void forfeit(){ + this.finishedTurn = true; + } + + //-------------------------------------------------------------------------------------- + //AI + + public int chooseAction(Card card){ + if (this.isDumb) { + return dumbAction(); + } else { + return smartAction(card); + } + } + + public int dumbAction(){ + if (this.scoreCurrentHand() < 17) { + return 2; + }else{ + return 1; + } + } + + public int smartAction(Card card){ + if (this.hands.get(currentHand).getSize() < 3) { + if (this.hands.get(currentHand).cards.get(0) == this.hands.get(currentHand).cards.get(1)) { + return pairChoose(card); + } else{ + return asChoose(card); + } + } else { + return valueChoose(card); + } + } + + public int valueChoose(Card card){ + if (this.scoreCurrentHand() < 8) { + return valueArray[0][card.getBjStrength()-2]; + } else if (this.scoreCurrentHand() > 16) { + return valueArray[9][card.getBjStrength()-2]; + } else { + return valueArray[this.scoreCurrentHand()-8][card.getBjStrength()-2]; + } + } + + public int pairChoose(Card card){ + return pairArray[this.hands.get(currentHand).cards.get(0).getBjStrength() - 2][card.getBjStrength()-2]; + } + + public int asChoose(Card card){ + return asArray[Math.min(this.hands.get(currentHand).cards.get(0).getBjStrength(), this.hands.get(currentHand).cards.get(1).getBjStrength())-2][card.getBjStrength()-2]; + } +} diff --git a/part_3/src/main/java/org/openjfx/Dealer.java b/part_3/src/main/java/org/openjfx/Dealer.java new file mode 100644 index 0000000000000000000000000000000000000000..8d347cf4f9893b9ed84173a5013eb7f7d4aaa301 --- /dev/null +++ b/part_3/src/main/java/org/openjfx/Dealer.java @@ -0,0 +1,59 @@ +package org.openjfx; +import java.util.ArrayList; + +public class Dealer implements Player{ + private BlackJackHand hand; + + Dealer(){ + this.hand = new BlackJackHand(); + } + + public Card getFirstCard(){ + return this.hand.cards.get(0); + } + + public BlackJackHand getHand(){ + return this.hand; + } + + public void draw(Card card){ + this.hand.addCard(card); + } + + public void print(){ + for (Card card : this.hand.getCards()) { + System.out.println(card.getFullName()); + } + } + + public int compareHand(BlackJackHand handToCompare){ + return this.hand.compareTo(handToCompare); + } + + public int score(){ + return this.hand.score(); + } + + public void reset(){ + this.hand = new BlackJackHand(); + } + + public void addMoney(int amount){ + + } + public void bet(int amount){ + + } + public void stayCurrentHand(){ + + } + public void doubleDown(){ + + } + public void split(Card cardL, Card cardR){ + + } + public void insure(){ + + } +} diff --git a/part_3/src/main/java/org/openjfx/Deck.java b/part_3/src/main/java/org/openjfx/Deck.java new file mode 100644 index 0000000000000000000000000000000000000000..16b844c7e6cb664c393a496a303f643e6ecbf9a1 --- /dev/null +++ b/part_3/src/main/java/org/openjfx/Deck.java @@ -0,0 +1,133 @@ +package org.openjfx; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Random; + +public class Deck { + private ArrayList<Card> deck; + + public Deck(){ + this.deck = new ArrayList<Card>(); + } + + public Deck(int type){ + this.deck = new ArrayList<Card>(); + switch (type) { + case 32: + addDeck32(this.deck); + break; + case 52: + addDeck52(this.deck); + break; + case 54: + addDeck54(this.deck); + break; + default: + break; + } + } + + public Deck(int number, int type){ + this.deck = new ArrayList<Card>(); + switch (type) { + case 32: + for (int i = 0; i < number; i++) { + addDeck32(this.deck); + } + break; + case 52: + for (int i = 0; i < number; i++) { + addDeck52(this.deck); + } + break; + case 54: + for (int i = 0; i < number; i++) { + addDeck54(this.deck); + } + break; + default: + break; + } + } + + public void addDeck32(ArrayList<Card> deck){ + //cartes 7 à roi + for (int j = 7; j < 14; j++) { + deck.add(new Card(COLOR.carreau, j)); + deck.add(new Card(COLOR.coeur, j)); + deck.add(new Card(COLOR.pique, j)); + deck.add(new Card(COLOR.trefle, j)); + } + + //les as + deck.add(new Card(COLOR.carreau, 1)); + deck.add(new Card(COLOR.coeur, 1)); + deck.add(new Card(COLOR.pique, 1)); + deck.add(new Card(COLOR.trefle, 1)); + } + + public void addDeck52(ArrayList<Card> deck){ + //cartes as à roi + for (int j = 1; j < 14; j++) { + deck.add(new Card(COLOR.carreau, j)); + deck.add(new Card(COLOR.coeur, j)); + deck.add(new Card(COLOR.pique, j)); + deck.add(new Card(COLOR.trefle, j)); + } + } + + public void addDeck54(ArrayList<Card> deck){ + //cartes as à roi + for (int j = 1; j < 14; j++) { + deck.add(new Card(COLOR.carreau, j)); + deck.add(new Card(COLOR.coeur, j)); + deck.add(new Card(COLOR.pique, j)); + deck.add(new Card(COLOR.trefle, j)); + } + //2 jokers + deck.add(new Card(COLOR.aucune, 0)); + deck.add(new Card(COLOR.aucune, 0)); + } + + public void addCard(Card cards){ + this.deck.add(cards); + } + + public void addCards(ArrayList<Card> cards){ + this.deck.addAll(cards); + } + + public void shuffleDeck(){ + Random rand = new Random(); + for (int i = 0; i < this.deck.size(); i++) { + int randomIndex = rand.nextInt(this.deck.size() - i) + i; + Card temp = this.deck.get(i); + this.deck.set(i, this.deck.get(randomIndex)); + this.deck.set(randomIndex, temp); + } + } + + public Card drawFromDeck(){ + Card card = this.deck.get(0); + this.deck.remove(0); + return card; + } + + public Deck splitDeck(int splitIndex){ + Deck secondDeck = new Deck(); + for (int i = 0; i < splitIndex; i++) { + secondDeck.addCard(this.drawFromDeck()); + } + return secondDeck; + } + + public int size(){ + return this.deck.size(); + } + + public void print(){ + for (Card card : this.deck) { + System.out.println(card.getFullName()); + } + } +} diff --git a/part_3/src/main/java/org/openjfx/GameManager.java b/part_3/src/main/java/org/openjfx/GameManager.java new file mode 100644 index 0000000000000000000000000000000000000000..e23e92cf4072372c8096920a7232bbddaf1b2033 --- /dev/null +++ b/part_3/src/main/java/org/openjfx/GameManager.java @@ -0,0 +1,503 @@ +package org.openjfx; + +import java.util.ArrayList; +import java.util.Scanner; + +public class GameManager { + + private Deck deck; + private Deck reserve; + public Human human; + private ArrayList<Cpu> cpuArray; + public Dealer dealer; + + GameManager() { + this.deck = new Deck(); + this.dealer = new Dealer(); + this.reserve = new Deck(); + this.human = new Human(); + this.cpuArray = new ArrayList<Cpu>(); + } + + GameManager(int amount, int number, int type) { + this(); + this.human.addMoney(amount); + this.deck = new Deck(number, type); + } + + public void addCpu(int numberOfCpu, boolean isDumb) { + for (int i = 0; i < numberOfCpu; i++) { + this.cpuArray.add(new Cpu(250, isDumb)); + } + } + + public Card draw() { + if (this.deck.size() > 0) { + return this.deck.drawFromDeck(); + } else { + return this.reserve.drawFromDeck(); + } + } + + public void initDecks() { + // shuffle les cartes + this.deck.shuffleDeck(); + // split les carte deriere le sabot + this.reserve = this.deck.splitDeck(52); + } + + public Card getDealerFirstCard(){ + return this.dealer.getFirstCard(); + } + + public int getDealerHandSize(){ + return this.dealer.getHand().getSize(); + } + + public int getDealerScore(){ + return this.dealer.getHand().score(); + } + + /* + * public void playTable() { + * System.out. + * println("--------------------\nNouveau tour !\n--------------------"); + * // dealer pioche sa carte + * this.dealer.draw(this.draw()); + * // check si joueur a assez d'argent pour jouer + * if (this.human.getMoney() < 10) { + * System.out. + * println("Vous n'avez plus assez d'argent. *dealer starts calling security*"); + * System.exit(0); + * } else { + * // joueur pioche ses cartes + * this.human.drawForCurrentHand(this.draw()); + * this.human.drawForCurrentHand(this.draw()); + * // demande la mise initial + * System.out.println("Mise minimal de 10, combien misez vous ?"); + * int input = App.scan.nextInt(); + * while (input < 10) { + * System.out.println("Pas assez, réessayez"); + * input = App.scan.nextInt(); + * } + * System.out.println(); + * this.human.initialBet(input); + * } + * // affiche la carte du croupier + * System.out.println("--------------------\ncarte du croupier :"); + * this.dealer.print(); + * System.out.println("--------------------\n"); + * playHumanTurn(); + * playDealerTurn(); + * moveMoney(); + * } + */ + + public void shuffleDeck(){ + this.deck.shuffleDeck(); + } + + public void playTable() { + playHumanTurn(human); + for (Cpu cpu : cpuArray) { + playCpuTurn(cpu, this.dealer.getFirstCard()); + } + } + + public void playHumanTurn(Human human) { + // presente main de depart + System.out.println("--------------------\nVoicit votre main de départ :"); + human.printCurrentHand(); + System.out.println("score :" + human.scoreCurrentHand()); + System.out.println("--------------------\n"); + + // propose assurance si dealer a as et si assez d'argent + if (this.dealer.getFirstCard().getRank() == 1 && human.getMoney() > human.getInitialBet() / 2) { + askInsurance(); + } + // regarde si assez d'argent pour doubler + // si pas assez on ne peut pas split non plus + // double ? sinon split ? sinon aucun des deux + if (human.getMoney() >= human.getInitialBet()) { + if (!human.getInsured()) { + // propose double down + askDoubleDown(); + if (human.getDoubled()) { + // decide si il prend un carte en plus + askCard(); + } else { + // joue sur chaque mains + while (!human.getFinishedTurn()) { + // propose split tant que c'est possible + while (human.canSplitCurrentHand()) { + askSplit(); + } + // peux recevoir des cartes que si la main n'est pas split de 2 aces + if (!human.isCurrentHandAceSplited()) { + // joue la main + humanPlayCurrentHand(); + } + human.nextHand(); + } + } + } + } else { + // joue une seul main, sans split ou double possible + humanPlayCurrentHand(); + } + // fin du tour et calcul + System.out.println("--------------------\nFin du tour, voici votre/vos mains et scores :"); + human.printAllHandsAndScores(); + System.out.println("--------------------\n"); + } + + public void humanPlayCurrentHand() { + boolean stayed = false; + // si score plus grand que 20 on stop, car soit 21 soit bust + while (this.human.scoreCurrentHand() < 21 && !stayed) { + stayed = this.askCard(); + } + System.out.println("Fin de cette main, score : " + this.human.scoreCurrentHand()); + } + + public void playDealerTurn() { + while (this.dealer.score() < 17) { + this.dealer.draw(this.draw()); + } + System.out.println("--------------------\nDEALER"); + this.dealer.print(); + System.out.println("score :" + this.dealer.score()); + System.out.println("--------------------\n"); + } + + public void askInsurance() { + // demande si assurance + System.out.println("--------------------\nVoulez-vous vous assurer\n1.oui\n2.non\n--------------------"); + int humanChoice = App.scan.nextInt(); + // boucle jusqu'a avoir un choix correcte + while (humanChoice != 1 && humanChoice != 2) { + System.out.println("Option inconnue, réessayez"); + humanChoice = App.scan.nextInt(); + } + // traite le choix + if (humanChoice == 1) { + human.insure(); + } + } + + public void askDoubleDown() { + // demande si double down + System.out.println("--------------------\nVoulez-vous doubler ?\n1. oui\n2. non\n--------------------"); + int humanChoice = App.scan.nextInt(); + // boucle jusqu'a avoir un choix correcte + while (humanChoice != 1 && humanChoice != 2) { + System.out.println("Option inconnue, réessayez"); + humanChoice = App.scan.nextInt(); + } + // traite le choix + if (humanChoice == 1) { + human.doubleDown(); + } + } + + public boolean askCard() { + // demande si veur une carte + System.out.println( + "--------------------\nVoulez-vous une carte ?\n1. oui et hit\n2. non et stay\n3. voir ma/mes mains\n--------------------"); + int humanChoice = App.scan.nextInt(); + // boucle jusqu'a avoir un choix correcte + while (humanChoice != 1 && humanChoice != 2 && humanChoice != 3) { + System.out.println("Option inconnue, réessayez"); + humanChoice = App.scan.nextInt(); + } + // tant qu'on demande ses mains + while (humanChoice == 3) { + human.printAllHandsAndScores(); + System.out.println( + "--------------------\nVoulez-vous une carte ?\n1. oui et hit\n2. non et stay\n3. voir ma/mes mains\n--------------------"); + humanChoice = App.scan.nextInt(); + } + // traite le choix + if (humanChoice == 1) { + human.drawForCurrentHand(this.draw()); + System.out.println("--------------------\nVotre main :"); + human.printCurrentHand(); + System.out.println("score :" + human.scoreCurrentHand()); + System.out.println("--------------------"); + return false; + } else { + human.stayCurrentHand(); + System.out.println("--------------------\nVous avez décider de stay avec cette main :"); + human.printCurrentHand(); + System.out.println("score :" + human.scoreCurrentHand()); + System.out.println("--------------------"); + return true; + } + } + + public void askSplit() { + System.out.println("--------------------\nVoulez-vous split ?\n1. oui \n2. non \n--------------------"); + int humanChoice = App.scan.nextInt(); + // boucle jusqu'a avoir un choix correcte + while (humanChoice != 1 && humanChoice != 2) { + System.out.println("Option inconnue, réessayez"); + humanChoice = App.scan.nextInt(); + } + // traite le choix + if (humanChoice == 1) { + // split + this.human.split(this.draw(), this.draw()); + human.printAllHandsAndScores(); + } + } + + /* public void moveMoney() { + int oldMoney = human.getMoney(); + // pour chaque mains du joueur + for (BlackJackHand hand : this.human.getHands()) { + // si main bust ou pas + if (hand.score() < 22) { + // si dealer a bust + if (dealer.score() < 22) { + // compare les mains + switch (dealer.compareHand(hand)) { + case 1: // dealer win + System.out.println("Vous avez perdu"); + // check if black jack and insured + if (this.dealer.score() == 999 && this.human.getInsured()) { + this.human.addMoney(this.human.getInsurance() * 3); + System.out.println("Assuré !"); + } + break; + case 0: // draw + System.out.println("Draw"); + // give back money + this.human.addMoney(hand.getBet()); + // check if black jack and insured + if (this.dealer.score() == 999 && this.human.getInsured()) { + this.human.addMoney(this.human.getInsurance() * 3); + System.out.println("Assuré !"); + } + break; + case -1: // dealer lose + System.out.println("Vous avez gagné"); + // if player black jack + if (hand.score() == 999) { // black jack pay + this.human.addMoney((hand.getBet() * 2) + (hand.getBet() / 2)); + System.out.println("Black Jack !"); + } else { // normal pay + this.human.addMoney(hand.getBet() * 2); + } + break; + default: + break; + } + } else { + // dealer bust, auto win + System.out.println("Vous avez gagné"); + // if player black jack + if (hand.score() == 999) { // black jack pay + this.human.addMoney((hand.getBet() * 2) + (hand.getBet() / 2)); + System.out.println("Black Jack !"); + } else { // normal pay + this.human.addMoney(hand.getBet() * 2); + } + } + } else { + // bust + System.out.println("Bust"); + } + } + System.out.println("Gain du tour : " + (this.human.getMoney() - oldMoney)); + System.out.println("Votre nouveau total : " + human.getMoney() + "\n"); + // reset player once money was given + this.human.reset(); + } */ + + public void moveMoneyHuman() { + int oldMoney = human.getMoney(); + // pour chaque mains du joueur + for (BlackJackHand hand : this.human.getHands()) { + // si main bust ou pas + if (hand.score() < 22) { + // si dealer a bust + if (dealer.score() < 22) { + // compare les mains + switch (dealer.compareHand(hand)) { + case 1: // dealer win + // check if black jack and insured + if (this.dealer.score() == 999 && this.human.getInsured()) { + this.human.addMoney(this.human.getInsurance() * 3); + } + break; + case 0: // draw + // give back money + this.human.addMoney(hand.getBet()); + // check if black jack and insured + if (this.dealer.score() == 999 && this.human.getInsured()) { + this.human.addMoney(this.human.getInsurance() * 3); + } + break; + case -1: // dealer lose + // if player black jack + if (hand.score() == 999) { // black jack pay + this.human.addMoney((hand.getBet() * 2) + (hand.getBet() / 2)); + } else { // normal pay + this.human.addMoney(hand.getBet() * 2); + } + break; + default: + break; + } + } else { + // dealer bust, auto win + // if player black jack + if (hand.score() == 999) { // black jack pay + this.human.addMoney((hand.getBet() * 2) + (hand.getBet() / 2)); + } else { // normal pay + this.human.addMoney(hand.getBet() * 2); + } + } + } else { + // bust + } + } + // reset player once money was given + this.human.reset(); + } + + public void moveMoneyCpu(Cpu cpu) { + if (cpu.dead) { + + } + // pour chaque mains du joueur + for (BlackJackHand hand : cpu.getHands()) { + // si main bust ou pas + if (hand.score() < 22) { + // si dealer a bust + if (dealer.score() < 22) { + // compare les mains + switch (dealer.compareHand(hand)) { + case 1: // dealer win + // check if black jack and insured + if (this.dealer.score() == 999 && cpu.getInsured()) { + cpu.addMoney(cpu.getInsurance() * 3); + } + break; + case 0: // draw + // give back money + cpu.addMoney(hand.getBet()); + // check if black jack and insured + if (this.dealer.score() == 999 && cpu.getInsured()) { + cpu.addMoney(cpu.getInsurance() * 3); + } + break; + case -1: // dealer lose + // if player black jack + if (hand.score() == 999) { // black jack pay + cpu.addMoney((hand.getBet() * 2) + (hand.getBet() / 2)); + } else { // normal pay + cpu.addMoney(hand.getBet() * 2); + } + break; + default: + break; + } + } else { + // dealer bust, auto win + // if player black jack + if (hand.score() == 999) { // black jack pay + cpu.addMoney((hand.getBet() * 2) + (hand.getBet() / 2)); + } else { // normal pay + cpu.addMoney(hand.getBet() * 2); + } + } + } else { + // bust + } + } + // reset player once money was given + cpu.reset(); + } + + public void moveMoneyCpus(){ + for (Cpu cpu : cpuArray) { + if (!cpu.getDead()) { + moveMoneyCpu(cpu); + } + } + } + + public void endTurn() { + // reset dealer + dealer.reset(); + // reset human + this.human.reset(); + //reset cpus + for (Cpu cpu : cpuArray) { + cpu.reset(); + } + // check need of new decks + if (this.reserve.size() < 52) { + this.initDecks(); + } + } + + public void playCpuTurn(Cpu cpu, Card dealerCard){ + //check si cpu peut encore jouer + if (cpu.getMoney()< 50) { + cpu.died(); + } else{ + //initial bet + cpu.initialBet(50); + cpu.drawForCurrentHand(this.draw()); + cpu.drawForCurrentHand(this.draw()); + //game action loop + while (!cpu.getFinishedTurn()) { + //check if current hand bust or stayed + if (cpu.getCurrentHand().getStayed() || cpu.getCurrentHand().score() > 21) { + cpu.nextHand(); + } else { + //choose action + int action = cpu.chooseAction(dealerCard); + switch (action) { + case 1: + cpu.drawForCurrentHand(this.draw()); + break; + case 2: + cpu.stayCurrentHand(); + break; + case 3: + cpu.doubleDown(); + break; + case 4: + cpu.split(this.draw(), this.draw()); + break; + case 5: + cpu.forfeit(); + break; + default: + break; + } + } + } + } + } + + public void playCpus(){ + for (Cpu cpu : cpuArray) { + playCpuTurn(cpu, dealer.getFirstCard()); + } + } + + // ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- + // part 3 + + public void giveDealerOneCard(Card card) { + dealer.draw(card); + } + + public void giveHumanOneCard(Card card) { + human.drawForCurrentHand(card); + } +} diff --git a/part_3/src/main/java/org/openjfx/Hand.java b/part_3/src/main/java/org/openjfx/Hand.java new file mode 100644 index 0000000000000000000000000000000000000000..ab8b0bd077da34677887057381cb85e50fbffd0e --- /dev/null +++ b/part_3/src/main/java/org/openjfx/Hand.java @@ -0,0 +1,43 @@ +package org.openjfx; +import java.util.ArrayList; + +public class Hand { + protected ArrayList<Card> cards; + + Hand(){ + this.cards = new ArrayList<Card>(); + } + + public int getSize(){ + return cards.size(); + } + + public void addCard(Card card){ + this.cards.add(card); + } + + public int totalRank(){ + int total = 0; + for (Card card : cards) { + total += card.getRank(); + } + return total; + } + + public int compareTo(Hand cards){ + int diff = this.totalRank() - cards.totalRank(); + if (diff > 0) { + return 1; + } else if (diff < 0) { + return -1; + } else { + return 0; + } + } + + public void print(){ + for (Card card : cards) { + System.out.println(card.getFullName()); + } + } +} diff --git a/part_3/src/main/java/org/openjfx/Human.java b/part_3/src/main/java/org/openjfx/Human.java new file mode 100644 index 0000000000000000000000000000000000000000..fae96327e12a100d5637045ae78c7fe238437ba9 --- /dev/null +++ b/part_3/src/main/java/org/openjfx/Human.java @@ -0,0 +1,253 @@ +package org.openjfx; +import java.util.ArrayList; +import java.util.Scanner; + +public class Human implements Player { + private int money; + private int initialBet; + private int totalBet; + private int insurance; + private boolean insured; + private boolean doubled; + private boolean doubledDrew; + private int maxNumberOfHands; + private int currentHand; + private ArrayList<BlackJackHand> hands; + private boolean finishedTurn; + private boolean playing; + + // ---------------------------------------------------------------------------------------------------------- + // consturctor + + Human() { + this.money = 0; + this.initialBet = 0; + this.totalBet = 0; + this.insurance = 0; + this.insured = false; + this.hands = new ArrayList<BlackJackHand>(); + this.addHand(); + this.maxNumberOfHands = 3; + this.doubled = false; + this.doubledDrew = false; + this.currentHand = 0; + this.finishedTurn = false; + this.playing = false; + } + + Human(int amount) { + this(); + // check amount positif + this.money = amount; + } + + // ---------------------------------------------------------------------------------------------------------- + // get/info + + public boolean getInsured() { + return this.insured; + } + + public int getMoney(){ + return this.money; + } + + public int getInsurance(){ + return this.insurance; + } + + public boolean getDoubled() { + return this.doubled; + } + + public boolean getDoubledDrew() { + return this.doubledDrew; + } + + public int getInitialBet(){ + return this.initialBet; + } + + public int getTotalBet(){ + return this.totalBet; + } + + public boolean getPlaying(){ + return this.playing; + } + + public ArrayList<BlackJackHand> getHands() { + return this.hands; + } + + public ArrayList<Card> giveCardsBack() { + ArrayList<Card> cards = new ArrayList<Card>(); + for (BlackJackHand hand : hands) { + cards.addAll(hand.getCards()); + } + this.hands = new ArrayList<BlackJackHand>(); + return cards; + } + + public int getNunmberOfHands() { + return this.hands.size(); + } + + public boolean getFinishedTurn(){ + return this.finishedTurn; + } + + public BlackJackHand getCurrentHand(){ + return this.hands.get(this.currentHand); + } + + public int getCurrentHandValue(){ + return this.currentHand; + } + + // ---------------------------------------------------------------------------------------------------------- + // utilities + + public void addHand() { + BlackJackHand newHand = new BlackJackHand(); + this.hands.add(newHand); + } + + public void addMoney(int amount) { + // check amount positif + if (amount < 0) { + System.out.println("amount given for addMoney is negativ"); + System.exit(0); + } + this.money += amount; + } + + public void initialBet(int amount) { + this.money -= amount; + this.initialBet = amount; + this.totalBet = amount; + this.hands.get(0).addBet(amount); + this.playing = true; + } + + public void bet(int amount) { + this.money -= amount; + this.totalBet += amount; + this.hands.get(this.currentHand).addBet(amount); + } + + public void doubledDrew(){ + this.doubledDrew = true; + } + + public void reset() { + this.initialBet = 0; + this.totalBet = 0; + this.doubled = false; + this.doubledDrew = false; + this.insurance = 0; + this.insured = false; + this.hands = new ArrayList<BlackJackHand>(); + this.addHand(); + this.currentHand = 0; + this.finishedTurn = false; + this.playing = false; + } + + public void printCurrentHand() { + this.hands.get(this.currentHand).print(); + } + + public void printAllHands() { + for (int i = 0; i < this.hands.size(); i++) { + if (i == this.currentHand) { // si main courrante + System.out.println("Main " + (i + 1) + " (courrante) :"); + this.hands.get(i).print(); + } else { // si main pas courrante + System.out.println("Main " + (i + 1) + " :"); + this.hands.get(i).print(); + } + } + } + + public void printAllHandsAndScores() { + for (int i = 0; i < this.hands.size(); i++) { + System.out.println("--- Main " + (i + 1) + " ---"); + this.hands.get(i).print(); + System.out.println("score :" + this.hands.get(i).score()); + } + } + + public boolean canSplitCurrentHand() { + // check si main valide + // check si on a pas atteint le max de mains + // check si on a assez d'argent pour + return (this.hands.get(this.currentHand).canSplit() && this.hands.size() <= this.maxNumberOfHands) && this.money >= this.initialBet; + } + + public int scoreCurrentHand() { + return this.hands.get(this.currentHand).score(); + } + + public void nextHand() { + if (this.currentHand + 1 >= this.hands.size()) { + this.finishedTurn = true; + this.playing = false; + } else { + this.currentHand ++; + } + } + + public boolean isCurrentHandAceSplited(){ + return this.hands.get(currentHand).getAceSplited(); + } + + // ---------------------------------------------------------------------------------------------------------- + // game action + + public void insure() { + this.insured = true; + this.insurance = initialBet / 2; + this.bet(initialBet / 2); + } + + public void doubleDown() { + this.doubled = true; + bet(this.initialBet); + } + + public void split(Card cardL, Card cardR) { + // cree la nouvelle main + BlackJackHand newHand = new BlackJackHand(); + //indique que les mains sont split + newHand.isSplit(); + this.hands.get(this.currentHand).isSplit(); + //indique si les mains sont split depuis une pair d'as + if (this.hands.get(currentHand).cards.get(0).getRank() == 1) { + this.hands.get(currentHand).isAceSplit(); + newHand.isAceSplit(); + } + // copie la la carte 0 de la main courrante a al nouvelle + Card card = this.hands.get(this.currentHand).cards.get(0); + newHand.addCard(card); + // enleve la carte 0 de la main courante + this.hands.get(this.currentHand).cards.remove(0); + // ajoute une carte a chaque main + this.hands.get(this.currentHand).addCard(cardL); + newHand.addCard(cardR); + //bet sur la nouvelle main + this.money -= this.initialBet; + this.totalBet+=this.initialBet; + newHand.addBet(this.initialBet); + // ajoute la nouvelle main au joueur + this.hands.add(newHand); + } + + public void drawForCurrentHand(Card card) { + this.hands.get(this.currentHand).addCard(card); + } + + public void stayCurrentHand() { + this.hands.get(this.currentHand).stay(); + } +} diff --git a/part_3/src/main/java/org/openjfx/Player.java b/part_3/src/main/java/org/openjfx/Player.java new file mode 100644 index 0000000000000000000000000000000000000000..2e8f52d06ac80940709ffc06eb5e4e815977b863 --- /dev/null +++ b/part_3/src/main/java/org/openjfx/Player.java @@ -0,0 +1,11 @@ +package org.openjfx; +import java.util.ArrayList; + +public interface Player { + public void addMoney(int amount); + public void bet(int amount); + public void stayCurrentHand(); + public void doubleDown(); + public void split(Card cardL, Card cardR); + public void insure(); +} diff --git a/part_3/src/main/java/org/openjfx/SystemInfo.java b/part_3/src/main/java/org/openjfx/SystemInfo.java new file mode 100644 index 0000000000000000000000000000000000000000..1a9130f92484e4b0fdec6f9d5a60e8cb7923e949 --- /dev/null +++ b/part_3/src/main/java/org/openjfx/SystemInfo.java @@ -0,0 +1,13 @@ +package org.openjfx; + +public class SystemInfo { + + public static String javaVersion() { + return System.getProperty("java.version"); + } + + public static String javafxVersion() { + return System.getProperty("javafx.version"); + } + +} \ No newline at end of file diff --git a/part_3/src/main/java/org/openjfx/two_of_clubs.png b/part_3/src/main/java/org/openjfx/two_of_clubs.png new file mode 100644 index 0000000000000000000000000000000000000000..291ed975f29d7873765c9f3259ebad8fd8a9d040 Binary files /dev/null and b/part_3/src/main/java/org/openjfx/two_of_clubs.png differ diff --git a/part_3/src/main/resources/10clubs.png b/part_3/src/main/resources/10clubs.png new file mode 100644 index 0000000000000000000000000000000000000000..18af741dbd2d8eb0f8ac494065d50ee8b7bc326a Binary files /dev/null and b/part_3/src/main/resources/10clubs.png differ diff --git a/part_3/src/main/resources/10diamonds.png b/part_3/src/main/resources/10diamonds.png new file mode 100644 index 0000000000000000000000000000000000000000..3bbc4e06bc6042f026761c8c1437a07ad8977c1b Binary files /dev/null and b/part_3/src/main/resources/10diamonds.png differ diff --git a/part_3/src/main/resources/10hearts.png b/part_3/src/main/resources/10hearts.png new file mode 100644 index 0000000000000000000000000000000000000000..3eb83d72c894aaa7490268239c14244f883a61e8 Binary files /dev/null and b/part_3/src/main/resources/10hearts.png differ diff --git a/part_3/src/main/resources/10spades.png b/part_3/src/main/resources/10spades.png new file mode 100644 index 0000000000000000000000000000000000000000..0b3d29475d9caa3291a68324e87af4790244500c Binary files /dev/null and b/part_3/src/main/resources/10spades.png differ diff --git a/part_3/src/main/resources/11clubs.png b/part_3/src/main/resources/11clubs.png new file mode 100644 index 0000000000000000000000000000000000000000..8bad6105ae106948ae5192677c2627394c442b89 Binary files /dev/null and b/part_3/src/main/resources/11clubs.png differ diff --git a/part_3/src/main/resources/11diamonds.png b/part_3/src/main/resources/11diamonds.png new file mode 100644 index 0000000000000000000000000000000000000000..0494785163ee9ee0c4ae2fce8f766893123f2290 Binary files /dev/null and b/part_3/src/main/resources/11diamonds.png differ diff --git a/part_3/src/main/resources/11hearts.png b/part_3/src/main/resources/11hearts.png new file mode 100644 index 0000000000000000000000000000000000000000..03cdfd473cf24c4924f8923548f674a136dee003 Binary files /dev/null and b/part_3/src/main/resources/11hearts.png differ diff --git a/part_3/src/main/resources/11spades.png b/part_3/src/main/resources/11spades.png new file mode 100644 index 0000000000000000000000000000000000000000..734e4b173698421021feba0737ff420bd5957a8c Binary files /dev/null and b/part_3/src/main/resources/11spades.png differ diff --git a/part_3/src/main/resources/12clubs.png b/part_3/src/main/resources/12clubs.png new file mode 100644 index 0000000000000000000000000000000000000000..949839c1b7b479c9e4cbd8ca83eb74cae235bb77 Binary files /dev/null and b/part_3/src/main/resources/12clubs.png differ diff --git a/part_3/src/main/resources/12diamonds.png b/part_3/src/main/resources/12diamonds.png new file mode 100644 index 0000000000000000000000000000000000000000..791b273df3aac02ed9e6e425933bab267b51d4f6 Binary files /dev/null and b/part_3/src/main/resources/12diamonds.png differ diff --git a/part_3/src/main/resources/12hearts.png b/part_3/src/main/resources/12hearts.png new file mode 100644 index 0000000000000000000000000000000000000000..c95e2df0b305416ad7e9a34d6d411d3e9edf1ad1 Binary files /dev/null and b/part_3/src/main/resources/12hearts.png differ diff --git a/part_3/src/main/resources/12spades.png b/part_3/src/main/resources/12spades.png new file mode 100644 index 0000000000000000000000000000000000000000..c6c69cac15e3bd155e497bf77c2498d9f4568c26 Binary files /dev/null and b/part_3/src/main/resources/12spades.png differ diff --git a/part_3/src/main/resources/13clubs.png b/part_3/src/main/resources/13clubs.png new file mode 100644 index 0000000000000000000000000000000000000000..ebde974ab422c88e324cee3dd98f996c86075561 Binary files /dev/null and b/part_3/src/main/resources/13clubs.png differ diff --git a/part_3/src/main/resources/13diamonds.png b/part_3/src/main/resources/13diamonds.png new file mode 100644 index 0000000000000000000000000000000000000000..4c9aaf20daf0d9e6f3e47a3f07d7c31f8b0f5725 Binary files /dev/null and b/part_3/src/main/resources/13diamonds.png differ diff --git a/part_3/src/main/resources/13hearts.png b/part_3/src/main/resources/13hearts.png new file mode 100644 index 0000000000000000000000000000000000000000..27d235a34f8be3f00973dbc2758d44028cfb15d1 Binary files /dev/null and b/part_3/src/main/resources/13hearts.png differ diff --git a/part_3/src/main/resources/13spades.png b/part_3/src/main/resources/13spades.png new file mode 100644 index 0000000000000000000000000000000000000000..b7abc52ac0ba5ac0e0d40b04a8bdc2898f6e7889 Binary files /dev/null and b/part_3/src/main/resources/13spades.png differ diff --git a/part_3/src/main/resources/1clubs.png b/part_3/src/main/resources/1clubs.png new file mode 100644 index 0000000000000000000000000000000000000000..42bf5ec94d627831e095c53dd5480521f771f97d Binary files /dev/null and b/part_3/src/main/resources/1clubs.png differ diff --git a/part_3/src/main/resources/1diamonds.png b/part_3/src/main/resources/1diamonds.png new file mode 100644 index 0000000000000000000000000000000000000000..79cd3b8a8054644e23619008b58f7b89601a2ec6 Binary files /dev/null and b/part_3/src/main/resources/1diamonds.png differ diff --git a/part_3/src/main/resources/1hearts.png b/part_3/src/main/resources/1hearts.png new file mode 100644 index 0000000000000000000000000000000000000000..b42212405c18f1f72a451f91b354c145089c103f Binary files /dev/null and b/part_3/src/main/resources/1hearts.png differ diff --git a/part_3/src/main/resources/1spades.png b/part_3/src/main/resources/1spades.png new file mode 100644 index 0000000000000000000000000000000000000000..103f56d1a807b12e284d5a73ad01b983f25b879b Binary files /dev/null and b/part_3/src/main/resources/1spades.png differ diff --git a/part_3/src/main/resources/2clubs.png b/part_3/src/main/resources/2clubs.png new file mode 100644 index 0000000000000000000000000000000000000000..291ed975f29d7873765c9f3259ebad8fd8a9d040 Binary files /dev/null and b/part_3/src/main/resources/2clubs.png differ diff --git a/part_3/src/main/resources/2diamonds.png b/part_3/src/main/resources/2diamonds.png new file mode 100644 index 0000000000000000000000000000000000000000..4deee7cc848386b049cafd105cb9a92c8ce2cbcd Binary files /dev/null and b/part_3/src/main/resources/2diamonds.png differ diff --git a/part_3/src/main/resources/2hearts.png b/part_3/src/main/resources/2hearts.png new file mode 100644 index 0000000000000000000000000000000000000000..75a014f364dbbdc00fb4bb8f3f808370f37907b8 Binary files /dev/null and b/part_3/src/main/resources/2hearts.png differ diff --git a/part_3/src/main/resources/2spades.png b/part_3/src/main/resources/2spades.png new file mode 100644 index 0000000000000000000000000000000000000000..1ce0ffe8b82efc672d92c53d1a0261defc1c8824 Binary files /dev/null and b/part_3/src/main/resources/2spades.png differ diff --git a/part_3/src/main/resources/3clubs.png b/part_3/src/main/resources/3clubs.png new file mode 100644 index 0000000000000000000000000000000000000000..076ab318aa596a64e8d3d52c2f53f2d3b32999be Binary files /dev/null and b/part_3/src/main/resources/3clubs.png differ diff --git a/part_3/src/main/resources/3diamonds.png b/part_3/src/main/resources/3diamonds.png new file mode 100644 index 0000000000000000000000000000000000000000..8ee0b4b902d308d64b51ec880a0389a34f836dd3 Binary files /dev/null and b/part_3/src/main/resources/3diamonds.png differ diff --git a/part_3/src/main/resources/3hearts.png b/part_3/src/main/resources/3hearts.png new file mode 100644 index 0000000000000000000000000000000000000000..8e74673f8222007b4b8a8c82d00d10a782ec7031 Binary files /dev/null and b/part_3/src/main/resources/3hearts.png differ diff --git a/part_3/src/main/resources/3spades.png b/part_3/src/main/resources/3spades.png new file mode 100644 index 0000000000000000000000000000000000000000..f9e06b4f019efca9dc2011b755404453b5928349 Binary files /dev/null and b/part_3/src/main/resources/3spades.png differ diff --git a/part_3/src/main/resources/4clubs.png b/part_3/src/main/resources/4clubs.png new file mode 100644 index 0000000000000000000000000000000000000000..8be9e089225fdf93c7be1b51031819fc85054c73 Binary files /dev/null and b/part_3/src/main/resources/4clubs.png differ diff --git a/part_3/src/main/resources/4diamonds.png b/part_3/src/main/resources/4diamonds.png new file mode 100644 index 0000000000000000000000000000000000000000..70e82e839b4e29647a5e2fefd7b08f4ca30829f1 Binary files /dev/null and b/part_3/src/main/resources/4diamonds.png differ diff --git a/part_3/src/main/resources/4hearts.png b/part_3/src/main/resources/4hearts.png new file mode 100644 index 0000000000000000000000000000000000000000..ceecbfe02f2e1e0af4a64dc457ed46940f954c81 Binary files /dev/null and b/part_3/src/main/resources/4hearts.png differ diff --git a/part_3/src/main/resources/4spades.png b/part_3/src/main/resources/4spades.png new file mode 100644 index 0000000000000000000000000000000000000000..95abe3e737c3675286b81da0af0d83033ee9d4ff Binary files /dev/null and b/part_3/src/main/resources/4spades.png differ diff --git a/part_3/src/main/resources/5clubs.png b/part_3/src/main/resources/5clubs.png new file mode 100644 index 0000000000000000000000000000000000000000..bde9777696e8e8d42402bdeeb6058b7d6605d0a0 Binary files /dev/null and b/part_3/src/main/resources/5clubs.png differ diff --git a/part_3/src/main/resources/5diamonds.png b/part_3/src/main/resources/5diamonds.png new file mode 100644 index 0000000000000000000000000000000000000000..bb9252558a0c6a0b3f6b4756e9d1a1c54c43fdb4 Binary files /dev/null and b/part_3/src/main/resources/5diamonds.png differ diff --git a/part_3/src/main/resources/5hearts.png b/part_3/src/main/resources/5hearts.png new file mode 100644 index 0000000000000000000000000000000000000000..d923456fe88b17c1ab8d45f11b8d947957732a6c Binary files /dev/null and b/part_3/src/main/resources/5hearts.png differ diff --git a/part_3/src/main/resources/5spades.png b/part_3/src/main/resources/5spades.png new file mode 100644 index 0000000000000000000000000000000000000000..53a1aad26c9990b695ed24c1241843eef0a704f0 Binary files /dev/null and b/part_3/src/main/resources/5spades.png differ diff --git a/part_3/src/main/resources/6clubs.png b/part_3/src/main/resources/6clubs.png new file mode 100644 index 0000000000000000000000000000000000000000..a9660a037257ac7d6ab05604fe896b2e51ac4171 Binary files /dev/null and b/part_3/src/main/resources/6clubs.png differ diff --git a/part_3/src/main/resources/6diamonds.png b/part_3/src/main/resources/6diamonds.png new file mode 100644 index 0000000000000000000000000000000000000000..78a80ad06a3705f9035bf3b96a1f047c428ac877 Binary files /dev/null and b/part_3/src/main/resources/6diamonds.png differ diff --git a/part_3/src/main/resources/6hearts.png b/part_3/src/main/resources/6hearts.png new file mode 100644 index 0000000000000000000000000000000000000000..361643efc36ed607f3834a502840b858dc0498d9 Binary files /dev/null and b/part_3/src/main/resources/6hearts.png differ diff --git a/part_3/src/main/resources/6spades.png b/part_3/src/main/resources/6spades.png new file mode 100644 index 0000000000000000000000000000000000000000..40242a718bfbec2252610f21196eaacdb9446884 Binary files /dev/null and b/part_3/src/main/resources/6spades.png differ diff --git a/part_3/src/main/resources/7clubs.png b/part_3/src/main/resources/7clubs.png new file mode 100644 index 0000000000000000000000000000000000000000..9d6b54554f5792e0bbef4c2fa3fd898cb6354b6f Binary files /dev/null and b/part_3/src/main/resources/7clubs.png differ diff --git a/part_3/src/main/resources/7diamonds.png b/part_3/src/main/resources/7diamonds.png new file mode 100644 index 0000000000000000000000000000000000000000..6ad5f15b51e7b949c825f6ecf1d70a6ba6c8f9ec Binary files /dev/null and b/part_3/src/main/resources/7diamonds.png differ diff --git a/part_3/src/main/resources/7hearts.png b/part_3/src/main/resources/7hearts.png new file mode 100644 index 0000000000000000000000000000000000000000..19b89a2e7e8511b44f824f19172059a0b0bae7a4 Binary files /dev/null and b/part_3/src/main/resources/7hearts.png differ diff --git a/part_3/src/main/resources/7spades.png b/part_3/src/main/resources/7spades.png new file mode 100644 index 0000000000000000000000000000000000000000..b9f1b93d33e8c81a441df99c3da822631d202c50 Binary files /dev/null and b/part_3/src/main/resources/7spades.png differ diff --git a/part_3/src/main/resources/8clubs.png b/part_3/src/main/resources/8clubs.png new file mode 100644 index 0000000000000000000000000000000000000000..cec743cbcd188453a8c14edde55147683ae24859 Binary files /dev/null and b/part_3/src/main/resources/8clubs.png differ diff --git a/part_3/src/main/resources/8diamonds.png b/part_3/src/main/resources/8diamonds.png new file mode 100644 index 0000000000000000000000000000000000000000..ed1295121de438df71dfed44026046a34ec959ba Binary files /dev/null and b/part_3/src/main/resources/8diamonds.png differ diff --git a/part_3/src/main/resources/8hearts.png b/part_3/src/main/resources/8hearts.png new file mode 100644 index 0000000000000000000000000000000000000000..fb39723cb19cff1271bee430875a3c0d6d570e99 Binary files /dev/null and b/part_3/src/main/resources/8hearts.png differ diff --git a/part_3/src/main/resources/8spades.png b/part_3/src/main/resources/8spades.png new file mode 100644 index 0000000000000000000000000000000000000000..b6b3b3813dce1260129d482550dbfdd465fca085 Binary files /dev/null and b/part_3/src/main/resources/8spades.png differ diff --git a/part_3/src/main/resources/9clubs.png b/part_3/src/main/resources/9clubs.png new file mode 100644 index 0000000000000000000000000000000000000000..2174db58e12a0cef03c8f68cfdad9e296f5b31b9 Binary files /dev/null and b/part_3/src/main/resources/9clubs.png differ diff --git a/part_3/src/main/resources/9diamonds.png b/part_3/src/main/resources/9diamonds.png new file mode 100644 index 0000000000000000000000000000000000000000..0b933fb0e664b980d3f2668443922062eb083cec Binary files /dev/null and b/part_3/src/main/resources/9diamonds.png differ diff --git a/part_3/src/main/resources/9hearts.png b/part_3/src/main/resources/9hearts.png new file mode 100644 index 0000000000000000000000000000000000000000..7b196d6dc080409b1e7ae97f6bf1e651742fb0ff Binary files /dev/null and b/part_3/src/main/resources/9hearts.png differ diff --git a/part_3/src/main/resources/9spades.png b/part_3/src/main/resources/9spades.png new file mode 100644 index 0000000000000000000000000000000000000000..3c3b5ffbc6429e64c97e1f218ca1814e29e1d989 Binary files /dev/null and b/part_3/src/main/resources/9spades.png differ diff --git a/part_3/src/main/resources/void.png b/part_3/src/main/resources/void.png new file mode 100644 index 0000000000000000000000000000000000000000..4b54f614f0b7a74cd08663a0863ca512182d85a4 Binary files /dev/null and b/part_3/src/main/resources/void.png differ diff --git a/part_3/src/test/java/org/openjfx/DealetTest.java b/part_3/src/test/java/org/openjfx/DealetTest.java new file mode 100644 index 0000000000000000000000000000000000000000..29311cc85fd9d7959755191793c5865b1ce8cc9f --- /dev/null +++ b/part_3/src/test/java/org/openjfx/DealetTest.java @@ -0,0 +1,133 @@ +package org.openjfx; + +import org.openjfx.Dealer; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; + +import org.junit.Test; +import org.junit.experimental.theories.suppliers.TestedOn; + +public class DealetTest { + @Test + public void ConstructorTest() { + Dealer dealer = new Dealer(); + // a dealer is returned + assertNotNull("returned Dealer is NULL", dealer); + // returned object is a dealer + assertEquals("didn't return a dealer", Dealer.class, dealer.getClass()); + } + + @Test + public void drawTest() { + Dealer dealer = new Dealer(); + Card card = new Card(COLOR.carreau, 2); + + dealer.draw(card); + + // dealer has 1 card + assertEquals("Dealer has no cards", 1, dealer.getHand().cards.size()); + // dealer recieved the good card + assertEquals("not the same card as given card", card, dealer.getHand().cards.get(0)); + } + + @Test + public void getHandTest() { + Dealer dealer = new Dealer(); + Card cardDealer = new Card(COLOR.carreau, 2); + dealer.draw(cardDealer); + BlackJackHand testHand = dealer.getHand(); + + // return not null + assertNotNull("returned BlackJackHand id NULL", testHand); + // returned object is a BlackJackHand + assertEquals("didn't return a BlackJackHand", BlackJackHand.class, testHand.getClass()); + } + + @Test + public void getFirstCardTest(){ + Dealer dealer = new Dealer(); + Card card1 = new Card(COLOR.carreau, 2); + dealer.draw(card1); + Card card2 = new Card(COLOR.carreau, 3); + dealer.draw(card2); + + Card testCard = dealer.getFirstCard(); + // return not null + assertNotNull("returned card id NULL", testCard); + // returned object is a Card + assertEquals("didn't return a Card", Card.class, testCard.getClass()); + //returned the good card + assertEquals("didn't return the good card", card1, testCard); + } + + @Test + public void scoreTest(){ + Dealer dealer = new Dealer(); + Card card1 = new Card(COLOR.carreau, 1); + dealer.draw(card1); + Card card2 = new Card(COLOR.carreau, 7); + dealer.draw(card2); + Card card3 = new Card(COLOR.coeur, 5); + dealer.draw(card3); + + int score = dealer.score(); + + // return not null + assertNotNull("returned score is NULL", score); + // returned the good score + assertEquals("didn't return the good score", 13, score); + } + + @Test + public void resetTest(){ + Dealer dealer = new Dealer(); + Card card1 = new Card(COLOR.carreau, 1); + dealer.draw(card1); + Card card2 = new Card(COLOR.carreau, 7); + dealer.draw(card2); + Card card3 = new Card(COLOR.coeur, 5); + dealer.draw(card3); + + dealer.reset(); + + //dealer still has a hand + assertNotNull(dealer.getHand()); + // dealer hand is now empty + assertEquals("Dealer hand is not empty", 0, dealer.getHand().cards.size()); + } + + @Test + public void compareHandTest(){ + Dealer dealer = new Dealer(); + Card card1 = new Card(COLOR.carreau, 2); + dealer.draw(card1); + Card card2 = new Card(COLOR.carreau, 7); + dealer.draw(card2); + + Card card3 = new Card(COLOR.coeur, 7); + Card card4 = new Card(COLOR.coeur, 10); + BlackJackHand hand = new BlackJackHand(); + hand.cards.add(card3); + hand.cards.add(card4); + + int result = dealer.compareHand(hand); + + // return not null + assertNotNull("returned compare value is NULL", result); + // returned the good score + assertEquals("didn't return the good score", -1, result); + } + + /* + the other functions are print and functions that do nothing + public void print() + public void addMoney(int amount) + public void bet(int amount) + public void stayCurrentHand() + public void doubleDown() + public void split(Card cardL, Card cardR) + public void insure() + */ +} \ No newline at end of file diff --git a/part_3/target/classes/10clubs.png b/part_3/target/classes/10clubs.png new file mode 100644 index 0000000000000000000000000000000000000000..18af741dbd2d8eb0f8ac494065d50ee8b7bc326a Binary files /dev/null and b/part_3/target/classes/10clubs.png differ diff --git a/part_3/target/classes/10diamonds.png b/part_3/target/classes/10diamonds.png new file mode 100644 index 0000000000000000000000000000000000000000..3bbc4e06bc6042f026761c8c1437a07ad8977c1b Binary files /dev/null and b/part_3/target/classes/10diamonds.png differ diff --git a/part_3/target/classes/10hearts.png b/part_3/target/classes/10hearts.png new file mode 100644 index 0000000000000000000000000000000000000000..3eb83d72c894aaa7490268239c14244f883a61e8 Binary files /dev/null and b/part_3/target/classes/10hearts.png differ diff --git a/part_3/target/classes/10spades.png b/part_3/target/classes/10spades.png new file mode 100644 index 0000000000000000000000000000000000000000..0b3d29475d9caa3291a68324e87af4790244500c Binary files /dev/null and b/part_3/target/classes/10spades.png differ diff --git a/part_3/target/classes/11clubs.png b/part_3/target/classes/11clubs.png new file mode 100644 index 0000000000000000000000000000000000000000..8bad6105ae106948ae5192677c2627394c442b89 Binary files /dev/null and b/part_3/target/classes/11clubs.png differ diff --git a/part_3/target/classes/11diamonds.png b/part_3/target/classes/11diamonds.png new file mode 100644 index 0000000000000000000000000000000000000000..0494785163ee9ee0c4ae2fce8f766893123f2290 Binary files /dev/null and b/part_3/target/classes/11diamonds.png differ diff --git a/part_3/target/classes/11hearts.png b/part_3/target/classes/11hearts.png new file mode 100644 index 0000000000000000000000000000000000000000..03cdfd473cf24c4924f8923548f674a136dee003 Binary files /dev/null and b/part_3/target/classes/11hearts.png differ diff --git a/part_3/target/classes/11spades.png b/part_3/target/classes/11spades.png new file mode 100644 index 0000000000000000000000000000000000000000..734e4b173698421021feba0737ff420bd5957a8c Binary files /dev/null and b/part_3/target/classes/11spades.png differ diff --git a/part_3/target/classes/12clubs.png b/part_3/target/classes/12clubs.png new file mode 100644 index 0000000000000000000000000000000000000000..949839c1b7b479c9e4cbd8ca83eb74cae235bb77 Binary files /dev/null and b/part_3/target/classes/12clubs.png differ diff --git a/part_3/target/classes/12diamonds.png b/part_3/target/classes/12diamonds.png new file mode 100644 index 0000000000000000000000000000000000000000..791b273df3aac02ed9e6e425933bab267b51d4f6 Binary files /dev/null and b/part_3/target/classes/12diamonds.png differ diff --git a/part_3/target/classes/12hearts.png b/part_3/target/classes/12hearts.png new file mode 100644 index 0000000000000000000000000000000000000000..c95e2df0b305416ad7e9a34d6d411d3e9edf1ad1 Binary files /dev/null and b/part_3/target/classes/12hearts.png differ diff --git a/part_3/target/classes/12spades.png b/part_3/target/classes/12spades.png new file mode 100644 index 0000000000000000000000000000000000000000..c6c69cac15e3bd155e497bf77c2498d9f4568c26 Binary files /dev/null and b/part_3/target/classes/12spades.png differ diff --git a/part_3/target/classes/13clubs.png b/part_3/target/classes/13clubs.png new file mode 100644 index 0000000000000000000000000000000000000000..ebde974ab422c88e324cee3dd98f996c86075561 Binary files /dev/null and b/part_3/target/classes/13clubs.png differ diff --git a/part_3/target/classes/13diamonds.png b/part_3/target/classes/13diamonds.png new file mode 100644 index 0000000000000000000000000000000000000000..4c9aaf20daf0d9e6f3e47a3f07d7c31f8b0f5725 Binary files /dev/null and b/part_3/target/classes/13diamonds.png differ diff --git a/part_3/target/classes/13hearts.png b/part_3/target/classes/13hearts.png new file mode 100644 index 0000000000000000000000000000000000000000..27d235a34f8be3f00973dbc2758d44028cfb15d1 Binary files /dev/null and b/part_3/target/classes/13hearts.png differ diff --git a/part_3/target/classes/13spades.png b/part_3/target/classes/13spades.png new file mode 100644 index 0000000000000000000000000000000000000000..b7abc52ac0ba5ac0e0d40b04a8bdc2898f6e7889 Binary files /dev/null and b/part_3/target/classes/13spades.png differ diff --git a/part_3/target/classes/1clubs.png b/part_3/target/classes/1clubs.png new file mode 100644 index 0000000000000000000000000000000000000000..42bf5ec94d627831e095c53dd5480521f771f97d Binary files /dev/null and b/part_3/target/classes/1clubs.png differ diff --git a/part_3/target/classes/1diamonds.png b/part_3/target/classes/1diamonds.png new file mode 100644 index 0000000000000000000000000000000000000000..79cd3b8a8054644e23619008b58f7b89601a2ec6 Binary files /dev/null and b/part_3/target/classes/1diamonds.png differ diff --git a/part_3/target/classes/1hearts.png b/part_3/target/classes/1hearts.png new file mode 100644 index 0000000000000000000000000000000000000000..b42212405c18f1f72a451f91b354c145089c103f Binary files /dev/null and b/part_3/target/classes/1hearts.png differ diff --git a/part_3/target/classes/1spades.png b/part_3/target/classes/1spades.png new file mode 100644 index 0000000000000000000000000000000000000000..103f56d1a807b12e284d5a73ad01b983f25b879b Binary files /dev/null and b/part_3/target/classes/1spades.png differ diff --git a/part_3/target/classes/2clubs.png b/part_3/target/classes/2clubs.png new file mode 100644 index 0000000000000000000000000000000000000000..291ed975f29d7873765c9f3259ebad8fd8a9d040 Binary files /dev/null and b/part_3/target/classes/2clubs.png differ diff --git a/part_3/target/classes/2diamonds.png b/part_3/target/classes/2diamonds.png new file mode 100644 index 0000000000000000000000000000000000000000..4deee7cc848386b049cafd105cb9a92c8ce2cbcd Binary files /dev/null and b/part_3/target/classes/2diamonds.png differ diff --git a/part_3/target/classes/2hearts.png b/part_3/target/classes/2hearts.png new file mode 100644 index 0000000000000000000000000000000000000000..75a014f364dbbdc00fb4bb8f3f808370f37907b8 Binary files /dev/null and b/part_3/target/classes/2hearts.png differ diff --git a/part_3/target/classes/2spades.png b/part_3/target/classes/2spades.png new file mode 100644 index 0000000000000000000000000000000000000000..1ce0ffe8b82efc672d92c53d1a0261defc1c8824 Binary files /dev/null and b/part_3/target/classes/2spades.png differ diff --git a/part_3/target/classes/3clubs.png b/part_3/target/classes/3clubs.png new file mode 100644 index 0000000000000000000000000000000000000000..076ab318aa596a64e8d3d52c2f53f2d3b32999be Binary files /dev/null and b/part_3/target/classes/3clubs.png differ diff --git a/part_3/target/classes/3diamonds.png b/part_3/target/classes/3diamonds.png new file mode 100644 index 0000000000000000000000000000000000000000..8ee0b4b902d308d64b51ec880a0389a34f836dd3 Binary files /dev/null and b/part_3/target/classes/3diamonds.png differ diff --git a/part_3/target/classes/3hearts.png b/part_3/target/classes/3hearts.png new file mode 100644 index 0000000000000000000000000000000000000000..8e74673f8222007b4b8a8c82d00d10a782ec7031 Binary files /dev/null and b/part_3/target/classes/3hearts.png differ diff --git a/part_3/target/classes/3spades.png b/part_3/target/classes/3spades.png new file mode 100644 index 0000000000000000000000000000000000000000..f9e06b4f019efca9dc2011b755404453b5928349 Binary files /dev/null and b/part_3/target/classes/3spades.png differ diff --git a/part_3/target/classes/4clubs.png b/part_3/target/classes/4clubs.png new file mode 100644 index 0000000000000000000000000000000000000000..8be9e089225fdf93c7be1b51031819fc85054c73 Binary files /dev/null and b/part_3/target/classes/4clubs.png differ diff --git a/part_3/target/classes/4diamonds.png b/part_3/target/classes/4diamonds.png new file mode 100644 index 0000000000000000000000000000000000000000..70e82e839b4e29647a5e2fefd7b08f4ca30829f1 Binary files /dev/null and b/part_3/target/classes/4diamonds.png differ diff --git a/part_3/target/classes/4hearts.png b/part_3/target/classes/4hearts.png new file mode 100644 index 0000000000000000000000000000000000000000..ceecbfe02f2e1e0af4a64dc457ed46940f954c81 Binary files /dev/null and b/part_3/target/classes/4hearts.png differ diff --git a/part_3/target/classes/4spades.png b/part_3/target/classes/4spades.png new file mode 100644 index 0000000000000000000000000000000000000000..95abe3e737c3675286b81da0af0d83033ee9d4ff Binary files /dev/null and b/part_3/target/classes/4spades.png differ diff --git a/part_3/target/classes/5clubs.png b/part_3/target/classes/5clubs.png new file mode 100644 index 0000000000000000000000000000000000000000..bde9777696e8e8d42402bdeeb6058b7d6605d0a0 Binary files /dev/null and b/part_3/target/classes/5clubs.png differ diff --git a/part_3/target/classes/5diamonds.png b/part_3/target/classes/5diamonds.png new file mode 100644 index 0000000000000000000000000000000000000000..bb9252558a0c6a0b3f6b4756e9d1a1c54c43fdb4 Binary files /dev/null and b/part_3/target/classes/5diamonds.png differ diff --git a/part_3/target/classes/5hearts.png b/part_3/target/classes/5hearts.png new file mode 100644 index 0000000000000000000000000000000000000000..d923456fe88b17c1ab8d45f11b8d947957732a6c Binary files /dev/null and b/part_3/target/classes/5hearts.png differ diff --git a/part_3/target/classes/5spades.png b/part_3/target/classes/5spades.png new file mode 100644 index 0000000000000000000000000000000000000000..53a1aad26c9990b695ed24c1241843eef0a704f0 Binary files /dev/null and b/part_3/target/classes/5spades.png differ diff --git a/part_3/target/classes/6clubs.png b/part_3/target/classes/6clubs.png new file mode 100644 index 0000000000000000000000000000000000000000..a9660a037257ac7d6ab05604fe896b2e51ac4171 Binary files /dev/null and b/part_3/target/classes/6clubs.png differ diff --git a/part_3/target/classes/6diamonds.png b/part_3/target/classes/6diamonds.png new file mode 100644 index 0000000000000000000000000000000000000000..78a80ad06a3705f9035bf3b96a1f047c428ac877 Binary files /dev/null and b/part_3/target/classes/6diamonds.png differ diff --git a/part_3/target/classes/6hearts.png b/part_3/target/classes/6hearts.png new file mode 100644 index 0000000000000000000000000000000000000000..361643efc36ed607f3834a502840b858dc0498d9 Binary files /dev/null and b/part_3/target/classes/6hearts.png differ diff --git a/part_3/target/classes/6spades.png b/part_3/target/classes/6spades.png new file mode 100644 index 0000000000000000000000000000000000000000..40242a718bfbec2252610f21196eaacdb9446884 Binary files /dev/null and b/part_3/target/classes/6spades.png differ diff --git a/part_3/target/classes/7clubs.png b/part_3/target/classes/7clubs.png new file mode 100644 index 0000000000000000000000000000000000000000..9d6b54554f5792e0bbef4c2fa3fd898cb6354b6f Binary files /dev/null and b/part_3/target/classes/7clubs.png differ diff --git a/part_3/target/classes/7diamonds.png b/part_3/target/classes/7diamonds.png new file mode 100644 index 0000000000000000000000000000000000000000..6ad5f15b51e7b949c825f6ecf1d70a6ba6c8f9ec Binary files /dev/null and b/part_3/target/classes/7diamonds.png differ diff --git a/part_3/target/classes/7hearts.png b/part_3/target/classes/7hearts.png new file mode 100644 index 0000000000000000000000000000000000000000..19b89a2e7e8511b44f824f19172059a0b0bae7a4 Binary files /dev/null and b/part_3/target/classes/7hearts.png differ diff --git a/part_3/target/classes/7spades.png b/part_3/target/classes/7spades.png new file mode 100644 index 0000000000000000000000000000000000000000..b9f1b93d33e8c81a441df99c3da822631d202c50 Binary files /dev/null and b/part_3/target/classes/7spades.png differ diff --git a/part_3/target/classes/8clubs.png b/part_3/target/classes/8clubs.png new file mode 100644 index 0000000000000000000000000000000000000000..cec743cbcd188453a8c14edde55147683ae24859 Binary files /dev/null and b/part_3/target/classes/8clubs.png differ diff --git a/part_3/target/classes/8diamonds.png b/part_3/target/classes/8diamonds.png new file mode 100644 index 0000000000000000000000000000000000000000..ed1295121de438df71dfed44026046a34ec959ba Binary files /dev/null and b/part_3/target/classes/8diamonds.png differ diff --git a/part_3/target/classes/8hearts.png b/part_3/target/classes/8hearts.png new file mode 100644 index 0000000000000000000000000000000000000000..fb39723cb19cff1271bee430875a3c0d6d570e99 Binary files /dev/null and b/part_3/target/classes/8hearts.png differ diff --git a/part_3/target/classes/8spades.png b/part_3/target/classes/8spades.png new file mode 100644 index 0000000000000000000000000000000000000000..b6b3b3813dce1260129d482550dbfdd465fca085 Binary files /dev/null and b/part_3/target/classes/8spades.png differ diff --git a/part_3/target/classes/9clubs.png b/part_3/target/classes/9clubs.png new file mode 100644 index 0000000000000000000000000000000000000000..2174db58e12a0cef03c8f68cfdad9e296f5b31b9 Binary files /dev/null and b/part_3/target/classes/9clubs.png differ diff --git a/part_3/target/classes/9diamonds.png b/part_3/target/classes/9diamonds.png new file mode 100644 index 0000000000000000000000000000000000000000..0b933fb0e664b980d3f2668443922062eb083cec Binary files /dev/null and b/part_3/target/classes/9diamonds.png differ diff --git a/part_3/target/classes/9hearts.png b/part_3/target/classes/9hearts.png new file mode 100644 index 0000000000000000000000000000000000000000..7b196d6dc080409b1e7ae97f6bf1e651742fb0ff Binary files /dev/null and b/part_3/target/classes/9hearts.png differ diff --git a/part_3/target/classes/9spades.png b/part_3/target/classes/9spades.png new file mode 100644 index 0000000000000000000000000000000000000000..3c3b5ffbc6429e64c97e1f218ca1814e29e1d989 Binary files /dev/null and b/part_3/target/classes/9spades.png differ diff --git a/part_3/target/classes/module-info.class b/part_3/target/classes/module-info.class new file mode 100644 index 0000000000000000000000000000000000000000..428c517750201b188865e259bd28cd6d1c3e6adc Binary files /dev/null and b/part_3/target/classes/module-info.class differ diff --git a/part_3/target/classes/org/openjfx/App.class b/part_3/target/classes/org/openjfx/App.class new file mode 100644 index 0000000000000000000000000000000000000000..fe06500d2c6ef2015ba623eebe7ddbd65e7506db Binary files /dev/null and b/part_3/target/classes/org/openjfx/App.class differ diff --git a/part_3/target/classes/org/openjfx/BlackJackHand.class b/part_3/target/classes/org/openjfx/BlackJackHand.class new file mode 100644 index 0000000000000000000000000000000000000000..b8b840b97a0f68b1c638e1165329ec26354638e7 Binary files /dev/null and b/part_3/target/classes/org/openjfx/BlackJackHand.class differ diff --git a/part_3/target/classes/org/openjfx/COLOR.class b/part_3/target/classes/org/openjfx/COLOR.class new file mode 100644 index 0000000000000000000000000000000000000000..98d2b05c0fbd0997800500d8be3e3dde04c00647 Binary files /dev/null and b/part_3/target/classes/org/openjfx/COLOR.class differ diff --git a/part_3/target/classes/org/openjfx/Card$1.class b/part_3/target/classes/org/openjfx/Card$1.class new file mode 100644 index 0000000000000000000000000000000000000000..9a1a9832876e3120a41af2c8c12b20d79d931d26 Binary files /dev/null and b/part_3/target/classes/org/openjfx/Card$1.class differ diff --git a/part_3/target/classes/org/openjfx/Card.class b/part_3/target/classes/org/openjfx/Card.class new file mode 100644 index 0000000000000000000000000000000000000000..f2ace949a38c451d887f5a3b23ad32becd274a3f Binary files /dev/null and b/part_3/target/classes/org/openjfx/Card.class differ diff --git a/part_3/target/classes/org/openjfx/Cpu.class b/part_3/target/classes/org/openjfx/Cpu.class new file mode 100644 index 0000000000000000000000000000000000000000..f14600bdcb2840e79a20d7665839b700b4e14bc6 Binary files /dev/null and b/part_3/target/classes/org/openjfx/Cpu.class differ diff --git a/part_3/target/classes/org/openjfx/Dealer.class b/part_3/target/classes/org/openjfx/Dealer.class new file mode 100644 index 0000000000000000000000000000000000000000..52d951652e2cabf4ff29f3dd5bb4cefc5f141861 Binary files /dev/null and b/part_3/target/classes/org/openjfx/Dealer.class differ diff --git a/part_3/target/classes/org/openjfx/Deck.class b/part_3/target/classes/org/openjfx/Deck.class new file mode 100644 index 0000000000000000000000000000000000000000..878e874abd35b066f7aeb2f2602dbc40fdf7d4a2 Binary files /dev/null and b/part_3/target/classes/org/openjfx/Deck.class differ diff --git a/part_3/target/classes/org/openjfx/GameManager.class b/part_3/target/classes/org/openjfx/GameManager.class new file mode 100644 index 0000000000000000000000000000000000000000..04bd98fc8e1ff5dc559c44da5559a05e5ef12f8b Binary files /dev/null and b/part_3/target/classes/org/openjfx/GameManager.class differ diff --git a/part_3/target/classes/org/openjfx/Hand.class b/part_3/target/classes/org/openjfx/Hand.class new file mode 100644 index 0000000000000000000000000000000000000000..19031e6eaba027b4224a295e14c141917bb23678 Binary files /dev/null and b/part_3/target/classes/org/openjfx/Hand.class differ diff --git a/part_3/target/classes/org/openjfx/Human.class b/part_3/target/classes/org/openjfx/Human.class new file mode 100644 index 0000000000000000000000000000000000000000..5465bb6b4de52ea67184566008079bc3ef4adb21 Binary files /dev/null and b/part_3/target/classes/org/openjfx/Human.class differ diff --git a/part_3/target/classes/org/openjfx/Player.class b/part_3/target/classes/org/openjfx/Player.class new file mode 100644 index 0000000000000000000000000000000000000000..651477d272c4f5afc4a586ab08c57a8a00228add Binary files /dev/null and b/part_3/target/classes/org/openjfx/Player.class differ diff --git a/part_3/target/classes/org/openjfx/SystemInfo.class b/part_3/target/classes/org/openjfx/SystemInfo.class new file mode 100644 index 0000000000000000000000000000000000000000..ce0729589f5addb6382db817d2da742688869c2b Binary files /dev/null and b/part_3/target/classes/org/openjfx/SystemInfo.class differ diff --git a/part_3/target/classes/void.png b/part_3/target/classes/void.png new file mode 100644 index 0000000000000000000000000000000000000000..4b54f614f0b7a74cd08663a0863ca512182d85a4 Binary files /dev/null and b/part_3/target/classes/void.png differ diff --git a/part_3/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/part_3/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000000000000000000000000000000000000..41713b33029f2f84d759eb7fdee6ea6d0c700af2 --- /dev/null +++ b/part_3/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst @@ -0,0 +1,14 @@ +org/openjfx/Human.class +org/openjfx/Cpu.class +org/openjfx/COLOR.class +org/openjfx/SystemInfo.class +org/openjfx/Card$1.class +org/openjfx/Deck.class +org/openjfx/Player.class +org/openjfx/App.class +module-info.class +org/openjfx/Dealer.class +org/openjfx/BlackJackHand.class +org/openjfx/Card.class +org/openjfx/GameManager.class +org/openjfx/Hand.class diff --git a/part_3/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/part_3/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000000000000000000000000000000000000..4a9f31fd1dc297ecaf6d57509c5c1318c8175112 --- /dev/null +++ b/part_3/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1,13 @@ +/home/rampfun/hepia/2eme/1_poo/project_object/part_3/src/main/java/org/openjfx/BlackJackHand.java +/home/rampfun/hepia/2eme/1_poo/project_object/part_3/src/main/java/org/openjfx/Hand.java +/home/rampfun/hepia/2eme/1_poo/project_object/part_3/src/main/java/module-info.java +/home/rampfun/hepia/2eme/1_poo/project_object/part_3/src/main/java/org/openjfx/COLOR.java +/home/rampfun/hepia/2eme/1_poo/project_object/part_3/src/main/java/org/openjfx/SystemInfo.java +/home/rampfun/hepia/2eme/1_poo/project_object/part_3/src/main/java/org/openjfx/App.java +/home/rampfun/hepia/2eme/1_poo/project_object/part_3/src/main/java/org/openjfx/GameManager.java +/home/rampfun/hepia/2eme/1_poo/project_object/part_3/src/main/java/org/openjfx/Cpu.java +/home/rampfun/hepia/2eme/1_poo/project_object/part_3/src/main/java/org/openjfx/Human.java +/home/rampfun/hepia/2eme/1_poo/project_object/part_3/src/main/java/org/openjfx/Deck.java +/home/rampfun/hepia/2eme/1_poo/project_object/part_3/src/main/java/org/openjfx/Card.java +/home/rampfun/hepia/2eme/1_poo/project_object/part_3/src/main/java/org/openjfx/Dealer.java +/home/rampfun/hepia/2eme/1_poo/project_object/part_3/src/main/java/org/openjfx/Player.java