diff --git a/Partie_3_GUI/img/background.jpg b/Partie_3_GUI/img/background.jpg index 199af5b2fc2f8698b45bde41b05f093600cdaf8b..58ea9380a5deda902f6a6a5f93600507c8dd7571 100644 Binary files a/Partie_3_GUI/img/background.jpg and b/Partie_3_GUI/img/background.jpg differ diff --git a/Partie_3_GUI/img/bet.png b/Partie_3_GUI/img/bet.png new file mode 100644 index 0000000000000000000000000000000000000000..b98cd898d574f0ee7caad82112501d4fa7c20048 Binary files /dev/null and b/Partie_3_GUI/img/bet.png differ diff --git a/Partie_3_GUI/img/insurance.png b/Partie_3_GUI/img/insurance.png new file mode 100644 index 0000000000000000000000000000000000000000..9d112b0467a564309fc800fb2d9f60846497a654 Binary files /dev/null and b/Partie_3_GUI/img/insurance.png differ diff --git a/Partie_3_GUI/save.csv b/Partie_3_GUI/save.csv index aabf4d639bbbd3f6dba3520d462d164909530cf5..57bdae3c0fc2449cef4995bec9e036ca0e9a880a 100644 --- a/Partie_3_GUI/save.csv +++ b/Partie_3_GUI/save.csv @@ -1,3 +1,4 @@ Human,90.0,0,0 Player_1,180.0,1,false +Player_1,250.0,1,false Player_2,2.0,1,true \ No newline at end of file diff --git a/Partie_3_GUI/src/main/java/ch/hepia/GameManager.java b/Partie_3_GUI/src/main/java/ch/hepia/GameManager.java index ca8423b93c7c546390778afcdbe23953366e30de..e9cb84ef2e0119fa4e54d093e98e85b0664e1e88 100644 --- a/Partie_3_GUI/src/main/java/ch/hepia/GameManager.java +++ b/Partie_3_GUI/src/main/java/ch/hepia/GameManager.java @@ -22,7 +22,6 @@ import javafx.scene.text.Font; import javafx.scene.text.FontWeight; import javafx.scene.text.Text; import javafx.scene.text.TextAlignment; -import javafx.scene.transform.Rotate; import javafx.stage.Stage; import javafx.beans.value.*; @@ -236,6 +235,8 @@ public class GameManager { // Ask the player for all his interactions with this cards public void PlayTurn(Stage primaryStage) { + this.Step = 0; + Image backgroundImage = new Image("file:img/background.jpg"); BackgroundImage background = new BackgroundImage( backgroundImage, @@ -255,21 +256,11 @@ public class GameManager { Image playerCard1 = new Image("file:img/" + this.Players.get(0).GetCard(0, 0) + ".png"); ImageView playerCard1View = new ImageView(playerCard1); playerCard1View.setFitHeight(150); - Rotate rotate1 = new Rotate(); - rotate1.setPivotX(50); - rotate1.setPivotY(playerCard1View.getFitWidth() / 2); - playerCard1View.getTransforms().add(rotate1); - rotate1.setAngle(-20); playerCard1View.setPreserveRatio(true); Image playerCard2 = new Image("file:img/" + this.Players.get(0).GetCard(0, 1) + ".png"); ImageView playerCard2View = new ImageView(playerCard2); playerCard2View.setFitHeight(150); - Rotate rotate2 = new Rotate(); - rotate2.setPivotX(50); - rotate2.setPivotY(playerCard2View.getFitWidth() / 2); - playerCard2View.getTransforms().add(rotate2); - rotate2.setAngle(20); playerCard2View.setPreserveRatio(true); Image deckImage = new Image("file:img/deck.png"); @@ -282,6 +273,11 @@ public class GameManager { moneyView.setFitHeight(50); moneyView.setPreserveRatio(true); + Image insuranceImage = new Image("file:img/insurance.png"); + ImageView insuranceView = new ImageView(insuranceImage); + insuranceView.setFitHeight(50); + insuranceView.setPreserveRatio(true); + Text cardsInDeck = new Text(String.valueOf(this.Deck.GetNbCards())); cardsInDeck.setFill(Color.WHITE); cardsInDeck.setFont(Font.font("Courier New", FontWeight.BOLD, 20)); @@ -290,6 +286,10 @@ public class GameManager { moneyPlayer.setFill(Color.WHITE); moneyPlayer.setFont(Font.font("Courier New", FontWeight.BOLD, 20)); + Text insured = new Text(String.valueOf(this.Players.get(0).HasInsured())); + insured.setFill(Color.WHITE); + insured.setFont(Font.font("Courier New", FontWeight.BOLD, 20)); + HBox deckBox = new HBox(5); deckBox.getChildren().addAll(deckView, cardsInDeck); deckBox.setAlignment(Pos.CENTER_LEFT); @@ -298,11 +298,15 @@ public class GameManager { moneyBox.getChildren().addAll(moneyView, moneyPlayer); moneyBox.setAlignment(Pos.CENTER_LEFT); - VBox moneyDeckBox = new VBox(5); - moneyDeckBox.getChildren().addAll(deckBox, moneyBox); - moneyDeckBox.setAlignment(Pos.CENTER_LEFT); + HBox insuredBox = new HBox(5); + insuredBox.getChildren().addAll(insuranceView, insured); + insuredBox.setAlignment(Pos.CENTER_LEFT); + + VBox moneyDeckInsuredBox = new VBox(10); + moneyDeckInsuredBox.getChildren().addAll(deckBox, moneyBox, insuredBox); + moneyDeckInsuredBox.setAlignment(Pos.CENTER_LEFT); - HBox dealerCardsBox = new HBox(10); + HBox dealerCardsBox = new HBox(-70); dealerCardsBox.getChildren().add(dealerCardView); dealerCardsBox.setAlignment(Pos.TOP_CENTER); @@ -315,114 +319,79 @@ public class GameManager { dealerCardsStrengthBox.getChildren().addAll(dealerCardsBox, strengthDealer); dealerCardsStrengthBox.setAlignment(Pos.TOP_CENTER); - HBox playerCardsBox = new HBox(10); + HBox playerCardsBox = new HBox(-70); playerCardsBox.getChildren().addAll(playerCard1View, playerCard2View); playerCardsBox.setAlignment(Pos.TOP_CENTER); - Text strengthHand1 = new Text(String.valueOf(this.Players.get(0).GetStrength(0))); + Text strengthHand1 = new Text(); + if (this.Players.get(0).GetStrength(0) == 99) { + strengthHand1.setText("BlackJack"); + } else { + strengthHand1.setText(String.valueOf(this.Players.get(0).GetStrength(0))); + } strengthHand1.setFill(Color.WHITE); strengthHand1.setTextAlignment(TextAlignment.CENTER); strengthHand1.setFont(Font.font("Courier New", FontWeight.BOLD, 30)); + Text betHand1 = new Text(String.valueOf(this.Players.get(0).GetBet(0))); + betHand1.setFill(Color.WHITE); + betHand1.setTextAlignment(TextAlignment.CENTER); + betHand1.setFont(Font.font("Courier New", FontWeight.BOLD, 25)); + VBox playerCardsStrengthBox = new VBox(20); - playerCardsStrengthBox.getChildren().addAll(strengthHand1, playerCardsBox); + playerCardsStrengthBox.getChildren().addAll(strengthHand1, playerCardsBox, betHand1); playerCardsStrengthBox.setAlignment(Pos.TOP_CENTER); - HBox actions = new HBox(10); - actions.setAlignment(Pos.BOTTOM_CENTER); - - StackPane deckMoney = new StackPane(); - - StackPane dealer = new StackPane(); + VBox computers = new VBox(15); + computers.setAlignment(Pos.CENTER_RIGHT); - StackPane player = new StackPane(); + HBox[] computerBox = new HBox[this.ComputerPlayers]; + ImageView[][] computerImageBox = new ImageView[this.ComputerPlayers][2]; - dealer.getChildren().add(dealerCardsStrengthBox); - player.getChildren().addAll(playerCardsStrengthBox, actions); - deckMoney.getChildren().add(moneyDeckBox); + int y = 0; - deckMoney.setTranslateX(5); + for (int x = 1; x <= this.ComputerPlayers; x++) { + if (!this.Players.get(x).IsGameOver()) { + computerBox[y] = new HBox(-40); - dealer.setTranslateY(50); + Image ComputerCard1 = new Image("file:img/" + this.Players.get(x).GetCard(0, 0) + ".png"); + Image ComputerCard2 = new Image("file:img/" + this.Players.get(x).GetCard(0, 1) + ".png"); - player.setTranslateY(primaryStage.getHeight() - 175 - player.getBoundsInLocal().getHeight()); + computerImageBox[y][0] = new ImageView(ComputerCard1); + computerImageBox[y][1] = new ImageView(ComputerCard2); - root.getChildren().addAll(deckMoney, dealer, player); + computerImageBox[y][0].setFitHeight(90); + computerImageBox[y][1].setFitHeight(90); - Scene scene_4 = new Scene(root, 1400, 800); + computerImageBox[y][0].setPreserveRatio(true); + computerImageBox[y][1].setPreserveRatio(true); - primaryStage.setScene(scene_4); + computerBox[y].getChildren().addAll(computerImageBox[y][0], computerImageBox[y][1]); + computerBox[y].setAlignment(Pos.CENTER_RIGHT); - // Check if the player has put down an insurance - // if (this.Players.get(0).HasInsured()) { - // System.out.println("Insured : " + App.ANSI_BLUE + - // this.Players.get(0).GetInsured() + App.ANSI_RESET); - // } + computers.getChildren().add(computerBox[y]); - // Show the hand number of the player - // System.out.println("Bet on Hand " + App.ANSI_GREEN + (HandNb + 1) + - // App.ANSI_RESET + " : " + App.ANSI_BLUE+ this.Players.get(0).GetBet(HandNb) + - // App.ANSI_RESET); - - // Show the hand strength of the player - // 99 = BlackJack - // >21 = Busted - // <=21 = show the strength - // System.out.print("Strength of Hand " + App.ANSI_GREEN + (HandNb + 1) + - // App.ANSI_RESET + " : "+ App.ANSI_PURPLE); - // if (this.Players.get(0).GetStrength(HandNb) == 99) { - // System.out.println("BlackJack" + App.ANSI_RESET); - // } else if (this.Players.get(0).GetStrength(HandNb) > 21) { - // System.out.println(this.Players.get(0).GetStrength(HandNb) + App.ANSI_RED + " - // [BUSTED]" + App.ANSI_RESET); - // } else { - // System.out.println(this.Players.get(0).GetStrength(HandNb) + App.ANSI_RESET); - // } + y++; + } + } - // Show the player hand - // this.Players.get(0).ShowHand(HandNb); - - // Show Computer Players hands - /* - * for (int x = 1; x <= this.ComputerPlayers; x++) { - * for (int HandNbComputer = 0; HandNbComputer < - * this.Players.get(x).GetNbHands(); HandNbComputer++) { - * System.out - * .print("\nComputer " + App.ANSI_GREEN + x + App.ANSI_RESET + ", Money " + - * App.ANSI_BLUE - * + this.Players.get(x).GetMoney() + App.ANSI_RESET + ", Hand " - * + App.ANSI_GREEN + HandNbComputer + App.ANSI_RESET + ", Bet " + App.ANSI_BLUE - * + this.Players.get(x).GetBet(HandNbComputer) + App.ANSI_RESET + ", Strength " - * + App.ANSI_PURPLE); - * if (this.Players.get(x).GetStrength(HandNbComputer) == 99) { - * System.out.println("BlackJack" + App.ANSI_RESET + " :"); - * } else if (this.Players.get(x).GetStrength(HandNbComputer) > 21) { - * System.out.println( - * this.Players.get(x).GetStrength(HandNbComputer) + App.ANSI_RED + " [BUSTED]" - * + App.ANSI_RESET + " :"); - * } else { - * System.out.println(this.Players.get(x).GetStrength(HandNbComputer) + - * App.ANSI_RESET + " :"); - * } - * this.Players.get(x).ShowHand(HandNbComputer); - * } - * } - */ - - // Choices for player - // System.out.println("\n--- " + App.ANSI_GREEN + "Choices" + App.ANSI_RESET + " - // ---\n"); + HBox actions = new HBox(10); + actions.setAlignment(Pos.BOTTOM_CENTER); // Insurance // Can only insure if it's the first thing that the players does // AND // That he hasn't already insured during this round - // if (this.Step == 0 && this.Dealer.HasOnlyAs() - // && !this.Players.get(0).HasInsured()) { - // CanInsure = true; - // System.out.println(App.ANSI_BLUE + "[i]" + App.ANSI_RESET + " Insurance - // against Dealer"); - // } + if (this.Step == 0 && this.Dealer.HasOnlyAs() && !this.Players.get(0).HasInsured()) { + Button insureButton = createButtonWithText("Insure", "file:img/red_button.png", 175, 4.0); + actions.getChildren().add(insureButton); + + insureButton.setOnAction(event -> { + this.Players.get(0).Insure(); + insured.setText(String.valueOf(this.Players.get(0).HasInsured())); + actions.getChildren().remove(insureButton); + }); + } // Split // Can only split if this hand can be split (if it wasn't already split AND if @@ -431,30 +400,11 @@ public class GameManager { // if we have less that 3 hands already (Max 2 splits) // AND // if the player has enough money - // if (this.Players.get(0).CanSplit(HandNb) - // && this.Players.get(0).GetNbHands() < 3 - // && this.Players.get(0).GetBet(HandNb) <= this.Players.get(0).GetMoney()) { - // CanSplit = true; - // System.out.println(App.ANSI_BLUE + "[s]" + App.ANSI_RESET + " Split your - // Hand"); - // } - - // Double - // Can only double if this hand wasn't already doubled - // AND - // if the hand has only 2 cards - // AND - // if the hand is not a BlackJack - // AND - // if the player has enough money - // if (!this.Players.get(0).HasDoubled(HandNb) - // && this.Players.get(0).GetNbCards(HandNb) == 2 - // && this.Players.get(0).GetStrength(HandNb) != 99 - // && this.Players.get(0).GetBet(HandNb) <= this.Players.get(0).GetMoney()) { - // CanDouble = true; - // System.out.println(App.ANSI_BLUE + "[d]" + App.ANSI_RESET + " Double your - // Hand"); - // } + if (this.Players.get(0).CanSplit(0) && this.Players.get(0).GetNbHands() < 3 + && this.Players.get(0).GetBet(0) <= this.Players.get(0).GetMoney()) { + Button splitButton = createButtonWithText("Split", "file:img/red_button.png", 175, 4.0); + actions.getChildren().add(splitButton); + } // Draw a Card (Hit) // Can NOT draw if this hand was doubled AND has already 3 cards @@ -464,38 +414,52 @@ public class GameManager { // if the player has a BlackJack // AND // if the strength of the hand is more than 21 - // if (!(this.Players.get(0).HasDoubled(HandNb) && - // this.Players.get(0).GetNbCards(HandNb) == 3) - // && !(this.Players.get(0).HasSplit(HandNb) - // && this.Players.get(0).GetCardStrength(HandNb, 0) == 1) - // && this.Players.get(0).GetStrength(HandNb) < 21) { - // CanDraw = true; - // System.out.println(App.ANSI_BLUE + "[h]" + App.ANSI_RESET + " Hit"); - // } + if (!(this.Players.get(0).HasDoubled(0) && this.Players.get(0).GetNbCards(0) == 3) + && !(this.Players.get(0).HasSplit(0) && this.Players.get(0).GetCardStrength(0, 0) == 1) + && this.Players.get(0).GetStrength(0) < 21) { + Button hitButton = createButtonWithText("Hit", "file:img/light_green_button.png", 175, 4.0); + actions.getChildren().add(hitButton); + } // Keep (Stand) - // System.out.println(App.ANSI_BLUE + "[k]" + App.ANSI_RESET + " Keep current - // Hand"); - - // Ask for the player choice until a valide one is given - /* - * while (true) { - * System.out.print("> "); - * - * choice = App.in.next().charAt(0); - * - * // Choices are checked with available one for confirmation - * if ((choice == 'i' && CanInsure) || (choice == 's' && CanSplit) || (choice == - * 'd' && CanDouble) - * || (choice == 'h' && CanDraw) - * || choice == 'k') { - * break; - * } else { - * System.out.println(App.ANSI_YELLOW + "Please enter a valid choice." + - * App.ANSI_RESET); - * } - * } - */ + Button keepButton = createButtonWithText("Stand", "file:img/light_blue_button.png", 175, 4.0); + actions.getChildren().add(keepButton); + + StackPane deckMoney = new StackPane(); + + StackPane dealer = new StackPane(); + + StackPane player = new StackPane(); + + StackPane action = new StackPane(); + + StackPane computer = new StackPane(); + + keepButton.setOnAction(event -> { + if (this.Players.get(0).GetNbHands() == 1) { + actions.getChildren().clear(); + ResolveTurn(primaryStage, cardsInDeck, dealerCardsBox, strengthDealer, computers, actions, player, + moneyPlayer); + } + + }); + + dealer.getChildren().add(dealerCardsStrengthBox); + player.getChildren().addAll(playerCardsStrengthBox); + action.getChildren().addAll(actions); + deckMoney.getChildren().add(moneyDeckInsuredBox); + computer.getChildren().add(computers); + + deckMoney.setTranslateX(5); + + dealer.setTranslateY(50); + + computer.setTranslateX(-10); + + player.setTranslateY(primaryStage.getHeight() - 190 - player.getBoundsInLocal().getHeight()); + action.setTranslateY(-10); + + root.getChildren().addAll(deckMoney, dealer, player, computer, action); // Hit // if (choice == 'h') { @@ -529,220 +493,226 @@ public class GameManager { // EndTurn = true; // } + Scene scene_4 = new Scene(root, 1400, 800); + + primaryStage.setScene(scene_4); } // Phase 3 (ResolveTurn): // Make the Dealer pick cards // Do all the math for the player gains and losses // Check if the player can continue et prepare for the next round - public boolean ResolveTurn(Stage primaryStage) { + public void ResolveTurn(Stage primaryStage, Text cardsInDeck, HBox dealerCardsBox, Text strengthDealer, + VBox computers, HBox actions, StackPane player, Text moneyPlayer) { // Computer Players take turn to play for (int x = 1; x <= this.ComputerPlayers; x++) { - - // Check there strategy - /* - * 1 = Smart - * 2 = Stupid - */ - if (this.Players.get(x).GetStrategy() == 1) { - - char[][][] Choices_2Cards = { - { - { 'S', 'T', 'T', 'T', 'T', 'T', 'T', 'R', 'R', 'R' }, - { 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T' }, - { 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T' }, - { 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T' }, - { 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T' }, - { 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'R' }, - { 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'R', 'R' }, - { 'R', 'T', 'T', 'T', 'T', 'T', 'T', 'S', 'R', 'R' }, - { 'R', 'T', 'T', 'T', 'T', 'T', 'R', 'R', 'R', 'R' }, - { 'R', 'T', 'T', 'T', 'T', 'R', 'R', 'R', 'R', 'R' }, - }, - { - { 'S', 'T', 'T', 'T', 'T', 'T', 'R', 'R', 'R', 'R' }, - { 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T' }, - { 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'R' }, - { 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'R', 'R' }, - { 'T', 'T', 'T', 'T', 'D', 'T', 'T', 'R', 'R', 'R' }, - { 'T', 'T', 'T', 'T', 'T', 'T', 'R', 'R', 'R', 'R' }, - { 'R', 'T', 'T', 'T', 'T', 'R', 'S', 'R', 'R', 'R' }, - { 'R', 'T', 'T', 'T', 'R', 'R', 'R', 'S', 'R', 'R' }, - { 'R', 'T', 'T', 'R', 'R', 'R', 'R', 'R', 'S', 'R' }, - { 'R', 'T', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R' }, - }, - { - { 'S', 'T', 'T', 'T', 'T', 'D', 'D', 'R', 'R', 'R' }, - { 'T', 'T', 'T', 'T', 'T', 'T', 'D', 'D', 'D', 'T' }, - { 'T', 'T', 'T', 'T', 'T', 'D', 'D', 'D', 'T', 'R' }, - { 'T', 'T', 'T', 'T', 'D', 'D', 'D', 'T', 'R', 'R' }, - { 'T', 'T', 'T', 'D', 'D', 'D', 'T', 'R', 'R', 'R' }, - { 'D', 'T', 'D', 'D', 'D', 'S', 'R', 'R', 'R', 'R' }, - { 'D', 'D', 'D', 'D', 'T', 'R', 'S', 'R', 'R', 'R' }, - { 'R', 'D', 'D', 'T', 'R', 'R', 'R', 'S', 'R', 'R' }, - { 'R', 'D', 'T', 'R', 'R', 'R', 'R', 'R', 'S', 'R' }, - { 'R', 'T', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R' }, - }, - { - { 'S', 'T', 'T', 'D', 'D', 'D', 'D', 'R', 'R', 'R' }, - { 'T', 'S', 'T', 'T', 'T', 'T', 'D', 'D', 'D', 'R' }, - { 'T', 'T', 'S', 'T', 'T', 'D', 'D', 'D', 'R', 'R' }, - { 'D', 'T', 'T', 'T', 'D', 'D', 'D', 'R', 'R', 'R' }, - { 'D', 'T', 'T', 'D', 'D', 'D', 'R', 'R', 'R', 'R' }, - { 'D', 'T', 'D', 'D', 'D', 'S', 'R', 'R', 'R', 'R' }, - { 'D', 'D', 'D', 'D', 'R', 'R', 'S', 'R', 'R', 'R' }, - { 'R', 'D', 'D', 'R', 'R', 'R', 'R', 'S', 'R', 'R' }, - { 'R', 'D', 'R', 'R', 'R', 'R', 'R', 'R', 'S', 'R' }, - { 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R' }, - }, - { - { 'S', 'D', 'D', 'D', 'D', 'D', 'D', 'R', 'R', 'R' }, - { 'D', 'S', 'T', 'T', 'T', 'T', 'D', 'D', 'D', 'R' }, - { 'D', 'T', 'S', 'T', 'T', 'D', 'D', 'D', 'R', 'R' }, - { 'D', 'T', 'T', 'T', 'D', 'D', 'D', 'R', 'R', 'R' }, - { 'D', 'T', 'T', 'D', 'D', 'D', 'R', 'R', 'R', 'R' }, - { 'D', 'T', 'D', 'D', 'D', 'S', 'R', 'R', 'R', 'R' }, - { 'D', 'D', 'D', 'D', 'R', 'R', 'S', 'R', 'R', 'R' }, - { 'R', 'D', 'D', 'R', 'R', 'R', 'R', 'S', 'R', 'R' }, - { 'R', 'D', 'R', 'R', 'R', 'R', 'R', 'R', 'S', 'R' }, - { 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R' }, - }, - { - { 'S', 'D', 'D', 'D', 'D', 'D', 'D', 'R', 'R', 'R' }, - { 'D', 'S', 'T', 'T', 'T', 'T', 'D', 'D', 'D', 'R' }, - { 'D', 'T', 'S', 'T', 'T', 'D', 'D', 'D', 'R', 'R' }, - { 'D', 'T', 'T', 'T', 'D', 'D', 'D', 'R', 'R', 'R' }, - { 'D', 'T', 'T', 'D', 'D', 'D', 'R', 'R', 'R', 'R' }, - { 'D', 'T', 'D', 'D', 'D', 'S', 'R', 'R', 'R', 'R' }, - { 'D', 'D', 'D', 'D', 'R', 'R', 'S', 'R', 'R', 'R' }, - { 'R', 'D', 'D', 'R', 'R', 'R', 'R', 'S', 'R', 'R' }, - { 'R', 'D', 'R', 'R', 'R', 'R', 'R', 'R', 'S', 'R' }, - { 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R' }, - }, - { - { 'S', 'T', 'T', 'T', 'T', 'T', 'R', 'R', 'R', 'R' }, - { 'T', 'S', 'T', 'T', 'T', 'T', 'T', 'D', 'D', 'T' }, - { 'T', 'T', 'S', 'T', 'T', 'T', 'D', 'D', 'T', 'T' }, - { 'T', 'T', 'T', 'T', 'T', 'D', 'D', 'T', 'T', 'T' }, - { 'T', 'T', 'T', 'T', 'D', 'D', 'T', 'T', 'T', 'T' }, - { 'T', 'T', 'T', 'D', 'D', 'T', 'T', 'T', 'T', 'T' }, - { 'R', 'T', 'D', 'D', 'T', 'T', 'S', 'T', 'T', 'R' }, - { 'R', 'D', 'D', 'T', 'T', 'T', 'T', 'S', 'R', 'R' }, - { 'R', 'D', 'T', 'T', 'T', 'T', 'T', 'R', 'R', 'R' }, - { 'R', 'T', 'T', 'T', 'T', 'T', 'R', 'R', 'R', 'R' }, - }, - { - { 'S', 'T', 'T', 'T', 'T', 'T', 'R', 'R', 'R', 'R' }, - { 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'D', 'D', 'T' }, - { 'T', 'T', 'T', 'T', 'T', 'T', 'D', 'D', 'T', 'T' }, - { 'T', 'T', 'T', 'T', 'T', 'D', 'D', 'T', 'T', 'T' }, - { 'T', 'T', 'T', 'T', 'D', 'D', 'T', 'T', 'T', 'T' }, - { 'T', 'T', 'T', 'D', 'D', 'T', 'T', 'T', 'T', 'T' }, - { 'R', 'T', 'D', 'D', 'T', 'T', 'T', 'T', 'T', 'R' }, - { 'R', 'D', 'D', 'T', 'T', 'T', 'T', 'S', 'R', 'R' }, - { 'R', 'D', 'T', 'T', 'T', 'T', 'T', 'R', 'S', 'R' }, - { 'R', 'T', 'T', 'T', 'T', 'T', 'R', 'R', 'R', 'R' }, - }, - { - { 'S', 'T', 'T', 'T', 'T', 'T', 'T', 'R', 'R', 'R' }, - { 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'D', 'D', 'T' }, - { 'T', 'T', 'T', 'T', 'T', 'T', 'D', 'D', 'T', 'T' }, - { 'T', 'T', 'T', 'T', 'T', 'D', 'D', 'T', 'T', 'T' }, - { 'T', 'T', 'T', 'T', 'D', 'D', 'T', 'T', 'T', 'T' }, - { 'T', 'T', 'T', 'D', 'D', 'T', 'T', 'T', 'T', 'R' }, - { 'T', 'T', 'D', 'D', 'T', 'T', 'T', 'T', 'R', 'R' }, - { 'R', 'D', 'D', 'T', 'T', 'T', 'T', 'S', 'R', 'R' }, - { 'R', 'D', 'T', 'T', 'T', 'T', 'R', 'R', 'S', 'R' }, - { 'R', 'T', 'T', 'T', 'T', 'R', 'R', 'R', 'R', 'R' }, - }, - { - { 'S', 'T', 'T', 'T', 'T', 'T', 'T', 'R', 'R', 'R' }, - { 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'D', 'T' }, - { 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'D', 'T', 'T' }, - { 'T', 'T', 'T', 'T', 'T', 'T', 'D', 'T', 'T', 'T' }, - { 'T', 'T', 'T', 'T', 'T', 'D', 'T', 'T', 'T', 'R' }, - { 'T', 'T', 'T', 'T', 'D', 'T', 'T', 'T', 'R', 'R' }, - { 'T', 'T', 'T', 'D', 'T', 'T', 'T', 'R', 'R', 'R' }, - { 'R', 'T', 'D', 'T', 'T', 'T', 'R', 'S', 'R', 'R' }, - { 'R', 'D', 'T', 'T', 'T', 'R', 'R', 'R', 'R', 'R' }, - { 'R', 'T', 'T', 'T', 'R', 'R', 'R', 'R', 'R', 'R' }, + if (!this.Players.get(x).IsGameOver()) { + // Check there strategy + /* + * 1 = Smart + * 2 = Stupid + */ + if (this.Players.get(x).GetStrategy() == 1) { + + char[][][] Choices_2Cards = { + { + { 'S', 'T', 'T', 'T', 'T', 'T', 'T', 'R', 'R', 'R' }, + { 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T' }, + { 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T' }, + { 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T' }, + { 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T' }, + { 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'R' }, + { 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'R', 'R' }, + { 'R', 'T', 'T', 'T', 'T', 'T', 'T', 'S', 'R', 'R' }, + { 'R', 'T', 'T', 'T', 'T', 'T', 'R', 'R', 'R', 'R' }, + { 'R', 'T', 'T', 'T', 'T', 'R', 'R', 'R', 'R', 'R' }, + }, + { + { 'S', 'T', 'T', 'T', 'T', 'T', 'R', 'R', 'R', 'R' }, + { 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T' }, + { 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'R' }, + { 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'R', 'R' }, + { 'T', 'T', 'T', 'T', 'D', 'T', 'T', 'R', 'R', 'R' }, + { 'T', 'T', 'T', 'T', 'T', 'T', 'R', 'R', 'R', 'R' }, + { 'R', 'T', 'T', 'T', 'T', 'R', 'S', 'R', 'R', 'R' }, + { 'R', 'T', 'T', 'T', 'R', 'R', 'R', 'S', 'R', 'R' }, + { 'R', 'T', 'T', 'R', 'R', 'R', 'R', 'R', 'S', 'R' }, + { 'R', 'T', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R' }, + }, + { + { 'S', 'T', 'T', 'T', 'T', 'D', 'D', 'R', 'R', 'R' }, + { 'T', 'T', 'T', 'T', 'T', 'T', 'D', 'D', 'D', 'T' }, + { 'T', 'T', 'T', 'T', 'T', 'D', 'D', 'D', 'T', 'R' }, + { 'T', 'T', 'T', 'T', 'D', 'D', 'D', 'T', 'R', 'R' }, + { 'T', 'T', 'T', 'D', 'D', 'D', 'T', 'R', 'R', 'R' }, + { 'D', 'T', 'D', 'D', 'D', 'S', 'R', 'R', 'R', 'R' }, + { 'D', 'D', 'D', 'D', 'T', 'R', 'S', 'R', 'R', 'R' }, + { 'R', 'D', 'D', 'T', 'R', 'R', 'R', 'S', 'R', 'R' }, + { 'R', 'D', 'T', 'R', 'R', 'R', 'R', 'R', 'S', 'R' }, + { 'R', 'T', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R' }, + }, + { + { 'S', 'T', 'T', 'D', 'D', 'D', 'D', 'R', 'R', 'R' }, + { 'T', 'S', 'T', 'T', 'T', 'T', 'D', 'D', 'D', 'R' }, + { 'T', 'T', 'S', 'T', 'T', 'D', 'D', 'D', 'R', 'R' }, + { 'D', 'T', 'T', 'T', 'D', 'D', 'D', 'R', 'R', 'R' }, + { 'D', 'T', 'T', 'D', 'D', 'D', 'R', 'R', 'R', 'R' }, + { 'D', 'T', 'D', 'D', 'D', 'S', 'R', 'R', 'R', 'R' }, + { 'D', 'D', 'D', 'D', 'R', 'R', 'S', 'R', 'R', 'R' }, + { 'R', 'D', 'D', 'R', 'R', 'R', 'R', 'S', 'R', 'R' }, + { 'R', 'D', 'R', 'R', 'R', 'R', 'R', 'R', 'S', 'R' }, + { 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R' }, + }, + { + { 'S', 'D', 'D', 'D', 'D', 'D', 'D', 'R', 'R', 'R' }, + { 'D', 'S', 'T', 'T', 'T', 'T', 'D', 'D', 'D', 'R' }, + { 'D', 'T', 'S', 'T', 'T', 'D', 'D', 'D', 'R', 'R' }, + { 'D', 'T', 'T', 'T', 'D', 'D', 'D', 'R', 'R', 'R' }, + { 'D', 'T', 'T', 'D', 'D', 'D', 'R', 'R', 'R', 'R' }, + { 'D', 'T', 'D', 'D', 'D', 'S', 'R', 'R', 'R', 'R' }, + { 'D', 'D', 'D', 'D', 'R', 'R', 'S', 'R', 'R', 'R' }, + { 'R', 'D', 'D', 'R', 'R', 'R', 'R', 'S', 'R', 'R' }, + { 'R', 'D', 'R', 'R', 'R', 'R', 'R', 'R', 'S', 'R' }, + { 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R' }, + }, + { + { 'S', 'D', 'D', 'D', 'D', 'D', 'D', 'R', 'R', 'R' }, + { 'D', 'S', 'T', 'T', 'T', 'T', 'D', 'D', 'D', 'R' }, + { 'D', 'T', 'S', 'T', 'T', 'D', 'D', 'D', 'R', 'R' }, + { 'D', 'T', 'T', 'T', 'D', 'D', 'D', 'R', 'R', 'R' }, + { 'D', 'T', 'T', 'D', 'D', 'D', 'R', 'R', 'R', 'R' }, + { 'D', 'T', 'D', 'D', 'D', 'S', 'R', 'R', 'R', 'R' }, + { 'D', 'D', 'D', 'D', 'R', 'R', 'S', 'R', 'R', 'R' }, + { 'R', 'D', 'D', 'R', 'R', 'R', 'R', 'S', 'R', 'R' }, + { 'R', 'D', 'R', 'R', 'R', 'R', 'R', 'R', 'S', 'R' }, + { 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R', 'R' }, + }, + { + { 'S', 'T', 'T', 'T', 'T', 'T', 'R', 'R', 'R', 'R' }, + { 'T', 'S', 'T', 'T', 'T', 'T', 'T', 'D', 'D', 'T' }, + { 'T', 'T', 'S', 'T', 'T', 'T', 'D', 'D', 'T', 'T' }, + { 'T', 'T', 'T', 'T', 'T', 'D', 'D', 'T', 'T', 'T' }, + { 'T', 'T', 'T', 'T', 'D', 'D', 'T', 'T', 'T', 'T' }, + { 'T', 'T', 'T', 'D', 'D', 'T', 'T', 'T', 'T', 'T' }, + { 'R', 'T', 'D', 'D', 'T', 'T', 'S', 'T', 'T', 'R' }, + { 'R', 'D', 'D', 'T', 'T', 'T', 'T', 'S', 'R', 'R' }, + { 'R', 'D', 'T', 'T', 'T', 'T', 'T', 'R', 'R', 'R' }, + { 'R', 'T', 'T', 'T', 'T', 'T', 'R', 'R', 'R', 'R' }, + }, + { + { 'S', 'T', 'T', 'T', 'T', 'T', 'R', 'R', 'R', 'R' }, + { 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'D', 'D', 'T' }, + { 'T', 'T', 'T', 'T', 'T', 'T', 'D', 'D', 'T', 'T' }, + { 'T', 'T', 'T', 'T', 'T', 'D', 'D', 'T', 'T', 'T' }, + { 'T', 'T', 'T', 'T', 'D', 'D', 'T', 'T', 'T', 'T' }, + { 'T', 'T', 'T', 'D', 'D', 'T', 'T', 'T', 'T', 'T' }, + { 'R', 'T', 'D', 'D', 'T', 'T', 'T', 'T', 'T', 'R' }, + { 'R', 'D', 'D', 'T', 'T', 'T', 'T', 'S', 'R', 'R' }, + { 'R', 'D', 'T', 'T', 'T', 'T', 'T', 'R', 'S', 'R' }, + { 'R', 'T', 'T', 'T', 'T', 'T', 'R', 'R', 'R', 'R' }, + }, + { + { 'S', 'T', 'T', 'T', 'T', 'T', 'T', 'R', 'R', 'R' }, + { 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'D', 'D', 'T' }, + { 'T', 'T', 'T', 'T', 'T', 'T', 'D', 'D', 'T', 'T' }, + { 'T', 'T', 'T', 'T', 'T', 'D', 'D', 'T', 'T', 'T' }, + { 'T', 'T', 'T', 'T', 'D', 'D', 'T', 'T', 'T', 'T' }, + { 'T', 'T', 'T', 'D', 'D', 'T', 'T', 'T', 'T', 'R' }, + { 'T', 'T', 'D', 'D', 'T', 'T', 'T', 'T', 'R', 'R' }, + { 'R', 'D', 'D', 'T', 'T', 'T', 'T', 'S', 'R', 'R' }, + { 'R', 'D', 'T', 'T', 'T', 'T', 'R', 'R', 'S', 'R' }, + { 'R', 'T', 'T', 'T', 'T', 'R', 'R', 'R', 'R', 'R' }, + }, + { + { 'S', 'T', 'T', 'T', 'T', 'T', 'T', 'R', 'R', 'R' }, + { 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'D', 'T' }, + { 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'D', 'T', 'T' }, + { 'T', 'T', 'T', 'T', 'T', 'T', 'D', 'T', 'T', 'T' }, + { 'T', 'T', 'T', 'T', 'T', 'D', 'T', 'T', 'T', 'R' }, + { 'T', 'T', 'T', 'T', 'D', 'T', 'T', 'T', 'R', 'R' }, + { 'T', 'T', 'T', 'D', 'T', 'T', 'T', 'R', 'R', 'R' }, + { 'R', 'T', 'D', 'T', 'T', 'T', 'R', 'S', 'R', 'R' }, + { 'R', 'D', 'T', 'T', 'T', 'R', 'R', 'R', 'R', 'R' }, + { 'R', 'T', 'T', 'T', 'R', 'R', 'R', 'R', 'R', 'R' }, + } + }; + + char[][] Choices_MoreThan2Cards = { + { 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'R', 'R' }, + { 'T', 'T', 'D', 'D', 'T', 'R', 'R', 'R', 'R', 'R' }, + { 'T', 'D', 'D', 'D', 'T', 'R', 'R', 'R', 'R', 'R' }, + { 'T', 'D', 'D', 'D', 'R', 'R', 'R', 'R', 'R', 'R' }, + { 'T', 'D', 'D', 'D', 'R', 'R', 'R', 'R', 'R', 'R' }, + { 'T', 'D', 'D', 'D', 'R', 'R', 'R', 'R', 'R', 'R' }, + { 'T', 'T', 'D', 'D', 'T', 'T', 'T', 'T', 'T', 'R' }, + { 'T', 'T', 'D', 'D', 'T', 'T', 'T', 'T', 'T', 'R' }, + { 'T', 'T', 'D', 'D', 'T', 'T', 'T', 'T', 'R', 'R' }, + { 'T', 'T', 'T', 'D', 'T', 'T', 'T', 'R', 'R', 'R' } + }; + + char Choice = 'R'; + + // Go thew all the hands of the computer player + for (int HandNb = 0; HandNb < this.Players.get(x).GetNbHands(); HandNb++) { + + if (this.Players.get(x).GetNbCards(HandNb) == 2) { + Choice = Choices_2Cards[this.Dealer.GetCardStrength(0, 0) - 1][this.Players.get(x) + .GetCardStrength(HandNb, 0) - 1][this.Players.get(x).GetCardStrength(HandNb, 1) + - 1]; + } else { + if (this.Players.get(x).GetStrength(HandNb) <= 8) { + Choice = Choices_MoreThan2Cards[this.Dealer.GetCardStrength(0, 0) - 1][0]; + } else if (this.Players.get(x).GetStrength(HandNb) == 9) { + Choice = Choices_MoreThan2Cards[this.Dealer.GetCardStrength(0, 0) - 1][1]; + } else if (this.Players.get(x).GetStrength(HandNb) == 10) { + Choice = Choices_MoreThan2Cards[this.Dealer.GetCardStrength(0, 0) - 1][2]; + } else if (this.Players.get(x).GetStrength(HandNb) == 11) { + Choice = Choices_MoreThan2Cards[this.Dealer.GetCardStrength(0, 0) - 1][3]; + } else if (this.Players.get(x).GetStrength(HandNb) == 12) { + Choice = Choices_MoreThan2Cards[this.Dealer.GetCardStrength(0, 0) - 1][4]; + } else if (this.Players.get(x).GetStrength(HandNb) == 13) { + Choice = Choices_MoreThan2Cards[this.Dealer.GetCardStrength(0, 0) - 1][5]; + } else if (this.Players.get(x).GetStrength(HandNb) == 14) { + Choice = Choices_MoreThan2Cards[this.Dealer.GetCardStrength(0, 0) - 1][6]; + } else if (this.Players.get(x).GetStrength(HandNb) == 15) { + Choice = Choices_MoreThan2Cards[this.Dealer.GetCardStrength(0, 0) - 1][7]; + } else if (this.Players.get(x).GetStrength(HandNb) == 16) { + Choice = Choices_MoreThan2Cards[this.Dealer.GetCardStrength(0, 0) - 1][8]; + } else if (this.Players.get(x).GetStrength(HandNb) >= 17) { + Choice = Choices_MoreThan2Cards[this.Dealer.GetCardStrength(0, 0) - 1][9]; + } } - }; - - char[][] Choices_MoreThan2Cards = { - { 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'T', 'R', 'R' }, - { 'T', 'T', 'D', 'D', 'T', 'R', 'R', 'R', 'R', 'R' }, - { 'T', 'D', 'D', 'D', 'T', 'R', 'R', 'R', 'R', 'R' }, - { 'T', 'D', 'D', 'D', 'R', 'R', 'R', 'R', 'R', 'R' }, - { 'T', 'D', 'D', 'D', 'R', 'R', 'R', 'R', 'R', 'R' }, - { 'T', 'D', 'D', 'D', 'R', 'R', 'R', 'R', 'R', 'R' }, - { 'T', 'T', 'D', 'D', 'T', 'T', 'T', 'T', 'T', 'R' }, - { 'T', 'T', 'D', 'D', 'T', 'T', 'T', 'T', 'T', 'R' }, - { 'T', 'T', 'D', 'D', 'T', 'T', 'T', 'T', 'R', 'R' }, - { 'T', 'T', 'T', 'D', 'T', 'T', 'T', 'R', 'R', 'R' } - }; - - char Choice = 'R'; - - // Go thew all the hands of the computer player - for (int HandNb = 0; HandNb < this.Players.get(x).GetNbHands(); HandNb++) { - - if (this.Players.get(x).GetNbCards(HandNb) == 2) { - Choice = Choices_2Cards[this.Dealer.GetCardStrength(0, 0) - 1][this.Players.get(x) - .GetCardStrength(HandNb, 0) - 1][this.Players.get(x).GetCardStrength(HandNb, 1) - 1]; - } else { - if (this.Players.get(x).GetStrength(HandNb) <= 8) { - Choice = Choices_MoreThan2Cards[this.Dealer.GetCardStrength(0, 0) - 1][0]; - } else if (this.Players.get(x).GetStrength(HandNb) == 9) { - Choice = Choices_MoreThan2Cards[this.Dealer.GetCardStrength(0, 0) - 1][1]; - } else if (this.Players.get(x).GetStrength(HandNb) == 10) { - Choice = Choices_MoreThan2Cards[this.Dealer.GetCardStrength(0, 0) - 1][2]; - } else if (this.Players.get(x).GetStrength(HandNb) == 11) { - Choice = Choices_MoreThan2Cards[this.Dealer.GetCardStrength(0, 0) - 1][3]; - } else if (this.Players.get(x).GetStrength(HandNb) == 12) { - Choice = Choices_MoreThan2Cards[this.Dealer.GetCardStrength(0, 0) - 1][4]; - } else if (this.Players.get(x).GetStrength(HandNb) == 13) { - Choice = Choices_MoreThan2Cards[this.Dealer.GetCardStrength(0, 0) - 1][5]; - } else if (this.Players.get(x).GetStrength(HandNb) == 14) { - Choice = Choices_MoreThan2Cards[this.Dealer.GetCardStrength(0, 0) - 1][6]; - } else if (this.Players.get(x).GetStrength(HandNb) == 15) { - Choice = Choices_MoreThan2Cards[this.Dealer.GetCardStrength(0, 0) - 1][7]; - } else if (this.Players.get(x).GetStrength(HandNb) == 16) { - Choice = Choices_MoreThan2Cards[this.Dealer.GetCardStrength(0, 0) - 1][8]; - } else if (this.Players.get(x).GetStrength(HandNb) >= 17) { - Choice = Choices_MoreThan2Cards[this.Dealer.GetCardStrength(0, 0) - 1][9]; - } - } - if (Choice == 'T') { - // Draw + if (Choice == 'T' && !this.Players.get(x).HasDoubled(HandNb)) { + // Draw - this.Players.get(x).DrawCard(HandNb, this.Deck); - // Go back 1 hand to stay on the same hand in the for loop - HandNb--; + this.Players.get(x).DrawCard(HandNb, this.Deck); + // Go back 1 hand to stay on the same hand in the for loop + HandNb--; - } else if (Choice == 'R') { - // Stay + } else if (Choice == 'R') { + // Stay - } else if (Choice == 'D') { - // Double + } else if (Choice == 'D') { + // Double - this.Players.get(x).Double(HandNb, this.Deck); - // Go back 1 hand to stay on the same hand in the for loop - HandNb--; - } else if (Choice == 'S') { - // Split + this.Players.get(x).Double(HandNb, this.Deck); + // Go back 1 hand to stay on the same hand in the for loop + HandNb--; + } else if (Choice == 'S') { + // Split - this.Players.get(x).Split(HandNb, this.Deck); - // Go back 1 hand to stay on the same hand in the for loop - HandNb--; + this.Players.get(x).Split(HandNb, this.Deck); + // Go back 1 hand to stay on the same hand in the for loop + HandNb--; + } } - } - } else if (this.Players.get(x).GetStrategy() == 2) { - while (this.Players.get(x).GetStrength(0) <= 15) { - this.Players.get(x).DrawCard(0, this.Deck); + } else if (this.Players.get(x).GetStrategy() == 2) { + while (this.Players.get(x).GetStrength(0) <= 15) { + this.Players.get(x).DrawCard(0, this.Deck); + } } } } @@ -752,231 +722,196 @@ public class GameManager { this.Dealer.DrawCard(0, this.Deck); } - System.out.print("\033[H\033[2J"); - System.out.flush(); - - // System.out.println("*~-~* " + App.ANSI_RED + "BlackJack" + App.ANSI_RESET + " - // *~-~*\n"); - - // Show the remaining amount of cards in the deck - // System.out.println("Cards in Deck : " + App.ANSI_GREEN + - // this.Deck.GetNbCards() + App.ANSI_RESET + "\n"); + cardsInDeck.setText(String.valueOf(this.Deck.GetNbCards())); - // Show the hand strength of the dealer - // 99 = BlackJack - // >21 = Busted - // <=21 = show the strength - // System.out.print("Dealer Score : " + App.ANSI_PURPLE); if (this.Dealer.GetStrength(0) == 99) { - // System.out.println("BlackJack" + App.ANSI_RESET); - } else if (this.Dealer.GetStrength(0) > 21) { - // System.out.println(this.Dealer.GetStrength(0) + App.ANSI_RED + " [BUSTED]" + - // App.ANSI_RESET); + strengthDealer.setText("BlackJack"); } else { - // System.out.println(this.Dealer.GetStrength(0) + App.ANSI_RESET); + strengthDealer.setText(String.valueOf(this.Dealer.GetStrength(0))); } - // Show the dealers hand - this.Dealer.ShowHands(); + dealerCardsBox.getChildren().clear(); + computers.getChildren().clear(); - // Check if the player has put down an insurance - if (this.Players.get(0).HasInsured()) { - // System.out.println("Insured : " + App.ANSI_BLUE + - // this.Players.get(0).GetInsured() + App.ANSI_RESET); + ImageView[] dealerCardImageBox = new ImageView[this.Dealer.GetNbCards(0)]; + + for (int x = 0; x < this.Dealer.GetNbCards(0); x++) { + + Image dealerCard = new Image("file:img/" + this.Dealer.GetCard(0, x) + ".png"); + + dealerCardImageBox[x] = new ImageView(dealerCard); + dealerCardImageBox[x].setFitHeight(150); + dealerCardImageBox[x].setPreserveRatio(true); + + dealerCardsBox.getChildren().add(dealerCardImageBox[x]); } - // Apply Computer Players Loss/Win + HBox[] computer = new HBox[this.ComputerPlayers]; + int y = 0; + for (int x = 1; x <= this.ComputerPlayers; x++) { - for (int HandNbComputer = 0; HandNbComputer < this.Players.get(x).GetNbHands(); HandNbComputer++) { - // If the player is Busted (strength > 21 but not BlackJack (99)) - if (this.Players.get(x).GetStrength(HandNbComputer) > 21 - && this.Players.get(x).GetStrength(HandNbComputer) != 99) { - } - // If it's a Draw - else if (this.Dealer.GetStrength(0) == this.Players.get(x).GetStrength(HandNbComputer)) { - // Player get's back his bet - this.Players.get(x).AddMoney(this.Players.get(x).GetBet(HandNbComputer)); - } - // If the player has done a BlackJack - else if (this.Players.get(x).GetStrength(HandNbComputer) == 99) { - // Player gets payed 1.5 to 1 - this.Players.get(x).AddMoney(this.Players.get(x).GetBet(HandNbComputer) * 2.5); - } - // If the Dealer is Busted (strength > 21 but not BlackJack (99)) - else if (this.Dealer.GetStrength(0) > 21 && this.Dealer.GetStrength(0) != 99) { - // Player wins and get payed 1 to 1 - this.Players.get(x).AddMoney(this.Players.get(x).GetBet(HandNbComputer) * 2); - } - // If the Dealer has a better score - else if (this.Players.get(x).GetStrength(HandNbComputer) < this.Dealer.GetStrength(0)) { + if (!this.Players.get(x).IsGameOver()) { + + computer[y] = new HBox(10); + computer[y].setAlignment(Pos.CENTER_RIGHT); + + HBox[] cards = new HBox[this.Players.get(x).GetNbHands()]; + + for (int t = 0; t < this.Players.get(x).GetNbHands(); t++) { + + cards[t] = new HBox(-40); + ImageView[] computerCardImageBox = new ImageView[this.Players.get(x).GetNbCards(t)]; + + for (int z = 0; z < this.Players.get(x).GetNbCards(t); z++) { + + Image card = new Image("file:img/" + this.Players.get(x).GetCard(t, z) + ".png"); + + computerCardImageBox[z] = new ImageView(card); + computerCardImageBox[z].setFitHeight(90); + computerCardImageBox[z].setPreserveRatio(true); + + cards[t].getChildren().add(computerCardImageBox[z]); + + } + + computer[y].getChildren().add(cards[t]); + } - // If the Player has a better score - else if (this.Players.get(x).GetStrength(HandNbComputer) > this.Dealer.GetStrength(0)) { - // Player wins and get payed 1 to 1 - this.Players.get(x).AddMoney(this.Players.get(x).GetBet(HandNbComputer) * 2); + computers.getChildren().add(computer[y]); + y++; + } + } + + // Apply Computer Players Loss/Win + for (int x = 1; x <= this.ComputerPlayers; x++) { + if (!this.Players.get(x).IsGameOver()) { + for (int HandNbComputer = 0; HandNbComputer < this.Players.get(x).GetNbHands(); HandNbComputer++) { + // If the player is Busted (strength > 21 but not BlackJack (99)) + if (this.Players.get(x).GetStrength(HandNbComputer) > 21 + && this.Players.get(x).GetStrength(HandNbComputer) != 99) { + } + // If it's a Draw + else if (this.Dealer.GetStrength(0) == this.Players.get(x).GetStrength(HandNbComputer)) { + // Player get's back his bet + this.Players.get(x).AddMoney(this.Players.get(x).GetBet(HandNbComputer)); + } + // If the player has done a BlackJack + else if (this.Players.get(x).GetStrength(HandNbComputer) == 99) { + // Player gets payed 1.5 to 1 + this.Players.get(x).AddMoney(this.Players.get(x).GetBet(HandNbComputer) * 2.5); + } + // If the Dealer is Busted (strength > 21 but not BlackJack (99)) + else if (this.Dealer.GetStrength(0) > 21 && this.Dealer.GetStrength(0) != 99) { + // Player wins and get payed 1 to 1 + this.Players.get(x).AddMoney(this.Players.get(x).GetBet(HandNbComputer) * 2); + } + // If the Dealer has a better score + else if (this.Players.get(x).GetStrength(HandNbComputer) < this.Dealer.GetStrength(0)) { + } + // If the Player has a better score + else if (this.Players.get(x).GetStrength(HandNbComputer) > this.Dealer.GetStrength(0)) { + // Player wins and get payed 1 to 1 + this.Players.get(x).AddMoney(this.Players.get(x).GetBet(HandNbComputer) * 2); + } } } } - // Show Computer Players hands - /* - * for (int x = 1; x <= this.ComputerPlayers; x++) { - * for (int HandNbComputer = 0; HandNbComputer < - * this.Players.get(x).GetNbHands(); HandNbComputer++) { - * System.out - * .print("\nComputer " + App.ANSI_GREEN + x + App.ANSI_RESET + ", Money " + - * App.ANSI_BLUE - * + this.Players.get(x).GetMoney() + App.ANSI_RESET + ", Hand " - * + App.ANSI_GREEN + HandNbComputer + App.ANSI_RESET + ", Bet " + App.ANSI_BLUE - * + this.Players.get(x).GetBet(HandNbComputer) + App.ANSI_RESET + ", Strength " - * + App.ANSI_PURPLE); - * if (this.Players.get(x).GetStrength(HandNbComputer) == 99) { - * System.out.println("BlackJack" + App.ANSI_RESET + " :"); - * } else if (this.Players.get(x).GetStrength(HandNbComputer) > 21) { - * System.out.println( - * this.Players.get(x).GetStrength(HandNbComputer) + App.ANSI_RED + " [BUSTED]" - * + App.ANSI_RESET + " :"); - * } else { - * System.out.println(this.Players.get(x).GetStrength(HandNbComputer) + - * App.ANSI_RESET + " :"); - * } - * this.Players.get(x).ShowHand(HandNbComputer); - * } - * } - */ + HBox hands = new HBox(10); + hands.setAlignment(Pos.TOP_CENTER); + + VBox[] hand = new VBox[this.Players.get(0).GetNbHands()]; // Go thew all hands of the player - /* - * for (int HandNb = 0; HandNb < this.Players.get(0).GetNbHands(); HandNb++) { - * - * System.out.println("\nHand " + App.ANSI_GREEN + (HandNb + 1) + App.ANSI_RESET - * + " :"); - * - * // Show to bet amount of the hand - * System.out.println("\tBet : " + App.ANSI_BLUE + - * this.Players.get(0).GetBet(HandNb) + App.ANSI_RESET); - * - * // Show strength of the hand of the player - * // 99 = BlackJack - * // >21 = Busted - * // <=21 = show the strength - * System.out.print("\tStrength : " + App.ANSI_PURPLE); - * if (this.Players.get(0).GetStrength(HandNb) == 99) { - * System.out.println("BlackJack" + App.ANSI_RESET); - * } else if (this.Players.get(0).GetStrength(HandNb) > 21) { - * System.out.println( - * this.Players.get(0).GetStrength(HandNb) + App.ANSI_RED + " [BUSTED]" + - * App.ANSI_RESET); - * } else { - * System.out.println(this.Players.get(0).GetStrength(HandNb) + App.ANSI_RESET); - * } - * - * // Show and apply gains and losses - * System.out.print("\tResult : "); - * // If the player is Busted (strength > 21 but not BlackJack (99)) - * if (this.Players.get(0).GetStrength(HandNb) > 21 && - * this.Players.get(0).GetStrength(HandNb) != 99) { - * // Show player loss - * System.out.println(App.ANSI_RED + "-" + this.Players.get(0).GetBet(HandNb) + - * App.ANSI_RESET); - * } - * // If it's a Draw - * else if (this.Dealer.GetStrength(0) == - * this.Players.get(0).GetStrength(HandNb)) { - * // Player get's back his bet - * System.out.println(App.ANSI_BLUE + "±0" + App.ANSI_RESET); - * this.Players.get(0).AddMoney(this.Players.get(0).GetBet(HandNb)); - * } - * // If the player has done a BlackJack - * else if (this.Players.get(0).GetStrength(HandNb) == 99) { - * // Player gets payed 1.5 to 1 - * System.out.println(App.ANSI_GREEN + "+" + (this.Players.get(0).GetBet(HandNb) - * * 1.5) + App.ANSI_RESET); - * this.Players.get(0).AddMoney(this.Players.get(0).GetBet(HandNb) * 2.5); - * } - * // If the Dealer is Busted (strength > 21 but not BlackJack (99)) - * else if (this.Dealer.GetStrength(0) > 21 && this.Dealer.GetStrength(0) != 99) - * { - * // Player wins and get payed 1 to 1 - * System.out.println(App.ANSI_GREEN + "+" + this.Players.get(0).GetBet(HandNb) - * + App.ANSI_RESET); - * this.Players.get(0).AddMoney(this.Players.get(0).GetBet(HandNb) * 2); - * } - * // If the Dealer has a better score - * else if (this.Players.get(0).GetStrength(HandNb) < - * this.Dealer.GetStrength(0)) { - * // Show player loss - * System.out.println(App.ANSI_RED + "-" + this.Players.get(0).GetBet(HandNb) + - * App.ANSI_RESET); - * } - * // If the Player has a better score - * else if (this.Players.get(0).GetStrength(HandNb) > - * this.Dealer.GetStrength(0)) { - * // Player wins and get payed 1 to 1 - * System.out.println(App.ANSI_GREEN + "+" + this.Players.get(0).GetBet(HandNb) - * + App.ANSI_RESET); - * this.Players.get(0).AddMoney(this.Players.get(0).GetBet(HandNb) * 2); - * } - * - * } - */ + for (int HandNb = 0; HandNb < this.Players.get(0).GetNbHands(); HandNb++) { + + hand[HandNb] = new VBox(20); + hand[HandNb].setAlignment(Pos.TOP_CENTER); + + Text strengthHand = new Text(); + if (this.Players.get(0).GetStrength(HandNb) == 99) { + strengthHand.setText("BlackJack"); + } else { + strengthHand.setText(String.valueOf(this.Players.get(0).GetStrength(0))); + } + strengthHand.setFill(Color.WHITE); + strengthHand.setTextAlignment(TextAlignment.CENTER); + strengthHand.setFont(Font.font("Courier New", FontWeight.BOLD, 30)); + + Text betHand = new Text(); + betHand.setTextAlignment(TextAlignment.CENTER); + betHand.setFont(Font.font("Courier New", FontWeight.BOLD, 30)); + + // If the player is Busted (strength > 21 but not BlackJack (99)) + if (this.Players.get(0).GetStrength(HandNb) > 21 && this.Players.get(0).GetStrength(HandNb) != 99) { + // Player Loss + betHand.setText(String.valueOf(this.Players.get(0).GetBet(HandNb) * -1)); + betHand.setFill(Color.RED); + } + // If it's a Draw + else if (this.Dealer.GetStrength(0) == this.Players.get(0).GetStrength(HandNb)) { + // Player get's back his bet + this.Players.get(0).AddMoney(this.Players.get(0).GetBet(HandNb)); + + betHand.setText("±0"); + betHand.setFill(Color.AQUA); + } + // If the player has done a BlackJack + else if (this.Players.get(0).GetStrength(HandNb) == 99) { + // Player gets payed 1.5 to 1 + this.Players.get(0).AddMoney(this.Players.get(0).GetBet(HandNb) * 2.5); + + betHand.setText("+" + String.valueOf(this.Players.get(0).GetBet(HandNb) * 2.5)); + betHand.setFill(Color.LIGHTGREEN); + } + // If the Dealer is Busted (strength > 21 but not BlackJack (99)) + else if (this.Dealer.GetStrength(0) > 21 && this.Dealer.GetStrength(0) != 99) { + // Player wins and get payed 1 to 1 + this.Players.get(0).AddMoney(this.Players.get(0).GetBet(HandNb) * 2); + + betHand.setText("+" + String.valueOf(this.Players.get(0).GetBet(HandNb) * 2)); + betHand.setFill(Color.LIGHTGREEN); + } + // If the Dealer has a better score + else if (this.Players.get(0).GetStrength(HandNb) < this.Dealer.GetStrength(0)) { + // Player loss + betHand.setText(String.valueOf(this.Players.get(0).GetBet(HandNb) * -1)); + betHand.setFill(Color.RED); + } + // If the Player has a better score + else if (this.Players.get(0).GetStrength(HandNb) > this.Dealer.GetStrength(0)) { + // Player wins and get payed 1 to 1 + this.Players.get(0).AddMoney(this.Players.get(0).GetBet(HandNb) * 2); + + betHand.setText("+" + String.valueOf(this.Players.get(0).GetBet(HandNb) * 2)); + betHand.setFill(Color.LIGHTGREEN); + } + + hand[HandNb].getChildren().addAll(strengthHand, betHand); + + hands.getChildren().add(hand[HandNb]); + } + + player.getChildren().clear(); + player.getChildren().add(hands); // Check if the player had insurance if (this.Players.get(0).HasInsured()) { - System.out.print("Insurance : "); - // If the Dealer did a BackJack if (this.Dealer.GetStrength(0) == 99) { - // Player gets payed back 2 to 1 - // System.out.println(App.ANSI_GREEN + "+" + (this.Players.get(0).GetInsured() * - // 3) + App.ANSI_RESET); + this.Players.get(0).AddMoney(this.Players.get(0).GetInsured() * 3); - } else { - // Show player loss - // System.out.println(App.ANSI_RED + "-" + (this.Players.get(0).GetInsured()) + - // App.ANSI_RESET); } } - // Show the final player balance - // System.out.println("\nMoney : " + App.ANSI_BLUE + - // this.Players.get(0).GetMoney() + App.ANSI_RESET); - - // Show Choices - // System.out.println("\n--- " + App.ANSI_GREEN + "Choices" + App.ANSI_RESET + " - // ---\n"); - - // System.out.println(App.ANSI_BLUE + "[c]" + App.ANSI_RESET + " Continue"); - // System.out.println(App.ANSI_BLUE + "[s]" + App.ANSI_RESET + " Save & Quit"); - - char choice = 'x'; - - // Ask for the player choice until a valide one is given - /* - * while (true) { - * System.out.print("> "); - * - * choice = App.in.next().charAt(0); - * - * // Choices are checked with available one for confirmation - * if (choice == 'c' || choice == 's') { - * break; - * } else { - * System.out.println(App.ANSI_YELLOW + "Please enter a valid choice." + - * App.ANSI_RESET); - * } - * } - */ - - if (choice == 'c') { - // If the player has less than the minimum bid amount allowed - if (this.Players.get(0).GetMoney() <= 10) { - return true; - } + moneyPlayer.setText(String.valueOf(this.Players.get(0).GetMoney())); + + Button nextButton = createButtonWithText("Next", "file:img/light_blue_button.png", 175, 4.0); + actions.getChildren().add(nextButton); + + nextButton.setOnAction(event -> { - // If more thn 75% of the Deck has been used, reshuffle all cards. In our case: - // simply recreate a new deck if (this.Deck.GetNbCards() < 78) { this.Deck = new JeudeCarte(new Paquet(6, 52)); } @@ -986,15 +921,15 @@ public class GameManager { for (Joueur Player : this.Players) { Player.Reset(this.Deck); } - } else if (choice == 's') { - Save Game = new Save(); - Game.save(this.Players, this.ComputerPlayers); + // Check if player is Game Over + if (this.Players.get(0).GetMoney() < 10.0) { + this.GameOver = true; + } - return true; - } + StartTurn(primaryStage); - return false; + }); } private Button createButtonWithText(String buttonText, String imagePath, int size, double translateYValue) { @@ -1013,7 +948,7 @@ public class GameManager { buttonImageView.setTranslateY(translateYValue); - button.setStyle("-fx-background-color: transparent; -fx-border-color: transparent;"); + button.setStyle("-fx-background-color: transparent; -fx-border-color:transparent;"); button.setOnMouseEntered(e -> button.setStyle( "-fx-cursor: hand; -fx-background-color: transparent; -fx-border-color: transparent;")); diff --git a/Partie_3_GUI/target/classes/ch/hepia/BlackjackGUI$1.class b/Partie_3_GUI/target/classes/ch/hepia/BlackjackGUI$1.class index dfb5471cba8b04ad6653a41ecd555366c06feec5..9ff25729f7579aedf8ab30375c5973a07af7109e 100644 Binary files a/Partie_3_GUI/target/classes/ch/hepia/BlackjackGUI$1.class and b/Partie_3_GUI/target/classes/ch/hepia/BlackjackGUI$1.class differ diff --git a/Partie_3_GUI/target/classes/ch/hepia/BlackjackGUI.class b/Partie_3_GUI/target/classes/ch/hepia/BlackjackGUI.class index 6fe366d35383b346eafd305a8fc28ad162058b8a..8ee7e93d237978efad496f9ce73fb34732281f78 100644 Binary files a/Partie_3_GUI/target/classes/ch/hepia/BlackjackGUI.class and b/Partie_3_GUI/target/classes/ch/hepia/BlackjackGUI.class differ diff --git a/Partie_3_GUI/target/classes/ch/hepia/COULEUR.class b/Partie_3_GUI/target/classes/ch/hepia/COULEUR.class index c38a76f38b5f56aec3100849ad749e77c1255bcd..c582fd28bd308c74abcc31d7c543625ab96af75b 100644 Binary files a/Partie_3_GUI/target/classes/ch/hepia/COULEUR.class and b/Partie_3_GUI/target/classes/ch/hepia/COULEUR.class differ diff --git a/Partie_3_GUI/target/classes/ch/hepia/Carte.class b/Partie_3_GUI/target/classes/ch/hepia/Carte.class index bb77e1a2cf2b2c55d68d07f73a271f6ad870f1c6..f2e1b3556ab535a9579d8c800c12eb799aff3d01 100644 Binary files a/Partie_3_GUI/target/classes/ch/hepia/Carte.class and b/Partie_3_GUI/target/classes/ch/hepia/Carte.class differ diff --git a/Partie_3_GUI/target/classes/ch/hepia/GameManager$1.class b/Partie_3_GUI/target/classes/ch/hepia/GameManager$1.class index 82b531d2386cff7bfa2ecf229689f10a12ca232e..cf32a393bd62ad299b967bad90ea50167be45046 100644 Binary files a/Partie_3_GUI/target/classes/ch/hepia/GameManager$1.class and b/Partie_3_GUI/target/classes/ch/hepia/GameManager$1.class differ diff --git a/Partie_3_GUI/target/classes/ch/hepia/GameManager.class b/Partie_3_GUI/target/classes/ch/hepia/GameManager.class index 49bf11c8df1da0c4591bec6005fb9144658e718e..5e98dbb8e06ebf2f79381a08b225403e58f64803 100644 Binary files a/Partie_3_GUI/target/classes/ch/hepia/GameManager.class and b/Partie_3_GUI/target/classes/ch/hepia/GameManager.class differ diff --git a/Partie_3_GUI/target/classes/ch/hepia/Hand$1.class b/Partie_3_GUI/target/classes/ch/hepia/Hand$1.class index e2750c39ec1ee0ffda4f715b78a572443a2da898..2214bf48295c2e99569934bb083314370d6c1499 100644 Binary files a/Partie_3_GUI/target/classes/ch/hepia/Hand$1.class and b/Partie_3_GUI/target/classes/ch/hepia/Hand$1.class differ diff --git a/Partie_3_GUI/target/classes/ch/hepia/Hand.class b/Partie_3_GUI/target/classes/ch/hepia/Hand.class index a5d795896fe3549efa725a1873962850a6211e6f..6e99640898ba7d7dacac297d9754b15afd0dc13e 100644 Binary files a/Partie_3_GUI/target/classes/ch/hepia/Hand.class and b/Partie_3_GUI/target/classes/ch/hepia/Hand.class differ diff --git a/Partie_3_GUI/target/classes/ch/hepia/JeudeCarte$1.class b/Partie_3_GUI/target/classes/ch/hepia/JeudeCarte$1.class index e87f2ad85071fb1b622c4a955974eae6caf97a63..2735eb7c27de1aa52aa4584d2c1ef9d746a2b524 100644 Binary files a/Partie_3_GUI/target/classes/ch/hepia/JeudeCarte$1.class and b/Partie_3_GUI/target/classes/ch/hepia/JeudeCarte$1.class differ diff --git a/Partie_3_GUI/target/classes/ch/hepia/JeudeCarte.class b/Partie_3_GUI/target/classes/ch/hepia/JeudeCarte.class index 7c84a24a016f03fff7d97c2fd8eab208948f7fbf..ef19fe3892611f8ced9c139e6ced49f24319685c 100644 Binary files a/Partie_3_GUI/target/classes/ch/hepia/JeudeCarte.class and b/Partie_3_GUI/target/classes/ch/hepia/JeudeCarte.class differ diff --git a/Partie_3_GUI/target/classes/ch/hepia/JoueurCroupier.class b/Partie_3_GUI/target/classes/ch/hepia/JoueurCroupier.class index ee10f8ced66ab7b4ff9eb559374349b52fe989cf..bced7abc4fa7eaaf07b3ae2a304fea7e07a81fb0 100644 Binary files a/Partie_3_GUI/target/classes/ch/hepia/JoueurCroupier.class and b/Partie_3_GUI/target/classes/ch/hepia/JoueurCroupier.class differ diff --git a/Partie_3_GUI/target/classes/ch/hepia/JoueurHumain.class b/Partie_3_GUI/target/classes/ch/hepia/JoueurHumain.class index b347b0df66a226ff911963b22b6328f62b306db3..256df7376b54cddfbb9cad03d3838e6f83b6be8c 100644 Binary files a/Partie_3_GUI/target/classes/ch/hepia/JoueurHumain.class and b/Partie_3_GUI/target/classes/ch/hepia/JoueurHumain.class differ diff --git a/Partie_3_GUI/target/classes/ch/hepia/JoueurOrdinateur.class b/Partie_3_GUI/target/classes/ch/hepia/JoueurOrdinateur.class index 98bf239de9c4ba25f246d073e32bb3c8431c22e4..9cd0df4201c9b1a0d6f4256b077189a53670c159 100644 Binary files a/Partie_3_GUI/target/classes/ch/hepia/JoueurOrdinateur.class and b/Partie_3_GUI/target/classes/ch/hepia/JoueurOrdinateur.class differ diff --git a/Partie_3_GUI/target/classes/ch/hepia/Paquet.class b/Partie_3_GUI/target/classes/ch/hepia/Paquet.class index 79dc7afd66ab47cc77bb82fcf6c5682425eccc23..287773450d9a2e8fcd9120c796067e1f9f2a10cf 100644 Binary files a/Partie_3_GUI/target/classes/ch/hepia/Paquet.class and b/Partie_3_GUI/target/classes/ch/hepia/Paquet.class differ diff --git a/Partie_3_GUI/target/classes/ch/hepia/Save.class b/Partie_3_GUI/target/classes/ch/hepia/Save.class index 39aa445e9a2eb5d5b6624a59c5c69096c77c1227..711770a4f4854d765c593da4780ea626da3d3826 100644 Binary files a/Partie_3_GUI/target/classes/ch/hepia/Save.class and b/Partie_3_GUI/target/classes/ch/hepia/Save.class differ diff --git a/Partie_3_Terminal/src/main/java/ch/hepia/GameManager.java b/Partie_3_Terminal/src/main/java/ch/hepia/GameManager.java index 906a0f09dae72f6b781c4b3ebc8f255623bac09c..136668a9e3373306f75b13cc332a583ba72f6f64 100644 --- a/Partie_3_Terminal/src/main/java/ch/hepia/GameManager.java +++ b/Partie_3_Terminal/src/main/java/ch/hepia/GameManager.java @@ -512,7 +512,7 @@ public class GameManager { } } - if (Choice == 'T') { + if (Choice == 'T' && !this.Players.get(x).HasDoubled(HandNb)) { // Draw this.Players.get(x).DrawCard(HandNb, this.Deck); diff --git a/Partie_3_Terminal/target/classes/ch/hepia/GameManager.class b/Partie_3_Terminal/target/classes/ch/hepia/GameManager.class index ac24e886c079f40286ef1739cac91ca262db1410..5a80fa1952d433782dd603693d5b2d25e1ed7546 100644 Binary files a/Partie_3_Terminal/target/classes/ch/hepia/GameManager.class and b/Partie_3_Terminal/target/classes/ch/hepia/GameManager.class differ