From 0dc39592db7c26f8d4ba6bc06250b35981cbe5ea Mon Sep 17 00:00:00 2001 From: selim Date: Mon, 29 Apr 2024 16:18:10 +0200 Subject: [PATCH] nearly done --- bin/domain/Box.class | Bin 8667 -> 10484 bytes bin/domain/Dice.class | Bin 1036 -> 1036 bytes bin/domain/Hand.class | Bin 2512 -> 2512 bytes bin/domain/Player.class | Bin 705 -> 705 bytes bin/facade/YahtzeeGame.class | Bin 8731 -> 9853 bytes bin/ui/TUI.class | Bin 526 -> 548 bytes src/domain/Box.java | 49 ++++++++++++ src/domain/Hand.java | 11 ++- src/facade/YahtzeeGame.java | 121 +++++++++++++++++++--------- src/ui/TUI.java | 150 +++++++++++++++++++++-------------- 10 files changed, 232 insertions(+), 99 deletions(-) diff --git a/bin/domain/Box.class b/bin/domain/Box.class index a173d93f2e8071d43dd428fc945e3d6122f24f72..29b6b8bebafe77d6d05096955b149e4048ddfa83 100644 GIT binary patch delta 2399 zcmcJQTTC2f6vxkhXng3uNU6xbHZrEKj53TC}@lKbs2V-Zg-d61qxoK z-r_@zG1=IpNvny`XkyYxYLV1LpQ^?OW8#AkKAHHyo5m7)JeR5%t*4kW@+KFXorKqce; zDZe-3j|RO%DfYpx$#7&;PiVA6UX8w>Kk}%HZh&gi1FMSC6`IE|>wE=NNy~Y3mTvK2 z?a{yY@zt$V+!T}tzy-?o$K!f*6x4V}=VmU8XEmy5xqvn)Y*yH!P_0m-u$7kG@PNv- z#(({2S^?Fn;yQ(Tg>4EA3XKX)3SNcn3Of{<6Zp71|Wq6*?4lDRe6M6n4|H zTJxqnY{nLlI~6m-0~OW&Lq42JJmR0x6ChXeNl@vE2swt;>h}23dvhCd(14~KG^P`| z^)7hRZ{%Jyu+5ET(At1Mr3Yh)nf|EWSqV3GI^6JdOk5jiy;V0HO6X=~2WXvTdt;Lc zDeZL1@RV7(+tG6bk-~PEyy+K1b6No)Y7JP`)+Z9r8y5=2Z?jF8x^ZfoAD@ z%puK)G&hDF(#(kEgO09NNUTpd7G$Pmfb~O8ZRW)G5l3S)D3*^o8e2iJe!`)xq*(KA zD6tkdoCwDwdY?ZP2=QWgkpD#`f%eQDS65?4$fIMR4c4i>laa`w*kn>g!$ToHF}=rA zZ1C@KN0~ET9*TeptqvppP-<4T3J*j<1=hgr$l1poF=R5=_@93`8r2is5q~nNCv%Vl zRcD?W>90JMn7sU>rw7n3x30NXXn=mDSBM`EM6RF6MOpk^`Y|nyd_=$Z)qhAW1=r^3 z^Yf@^;DeVJ==xQbBBH<+3nB_l@h&ai z4hKbckr~bgTbSV#+v41Uq4F!SjhW6}wlKpf&4?9CzuT@fmtJNIbLksxVJ^Mg7IWtO z6}B;#evd88rB`OeJgPq6H(nM$l!;#D7X!ghZUm?Zqf`x@+Au~35u_6cQ5a#G#WhvYOs}e z_&941xo*OnLrcaD`hl`gt4dLadR|bRU+CKj*dc5YwhG&YyM#WWS-Dq!?-zCpdxQst zhlNLkeZqdB^f&PTO)x0a3<)0)9v6-X9~K&q%GcvUzc3)wg+XChcv5&u7!%&f1pm>q SIMZ~3Z-B<3CwLo7QR!cGS!Txo delta 595 zcmb`DyG{a85Qb+!U04>DyCR5qDGY`}8WJlFLNqZk2#wLitmFhp*4=~!j5I!jIgPcY zouRX^FtM?-_8qLeU(jVX8+ibm@0|Se&p&g{Q|Tcu-u17p0bmv9FU6djr#)!_-r-Y# z557CNe<7SLZ1R0M$uB(J47|DE2fZakZpHS zZ#StV42zA9mEq>6QYhm=@Z0_}>oAQPyhCcCQLDE|mHEAtzyN=g;<*q)*zPN~Rdro& z8&+-vA!=93hl;9}TTRBSgmJ#&ja6a@LEEvT)LUIN#`vnQ{kFfv% diff --git a/bin/domain/Dice.class b/bin/domain/Dice.class index abcd61ad2e4fa84f8c004acd792fbd99ef503c76..4a4ca3c5738aa7af0ef8cb5edd118ae32230cf3b 100644 GIT binary patch delta 17 YcmeC-=;7cv^>5cc1_lP(jT|g206A6#ZvX%Q delta 17 YcmeC-=;7cv^>5cc1_lPljT|g206A&}a{v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R{1Vm`9_HV> z_eGy{dYnzBG&a_{KqDs4h09C6py0?*X?$izIqP(IXM>p$|0R&KVqdeR?tb@>hQS2B zVH=2Nw>%E=Y%T+P3e&9kKhzpcbm~a3q0reoiItu*b$*&)S^CzY1QX#E;S{TAh*FdJ g01MI6?`WR2TCZq-idumdT#QaTCRAis*o@xRFOxbu!~g&Q diff --git a/src/domain/Box.java b/src/domain/Box.java index 3e7afda..2712887 100644 --- a/src/domain/Box.java +++ b/src/domain/Box.java @@ -348,4 +348,53 @@ public class Box { } + public String selectedOptionsPrinted(int player) { + + StringBuilder sb = new StringBuilder(); + + if (savedGamemode.equals("Special8")) { + sb.append("categoryOne: " + nullCheck(setCategoryOne) + "\n"); + sb.append("categoryTwo: " + nullCheck(setCategoryTwo) + "\n"); + sb.append("categoryThree: " + nullCheck(setCategoryThree) + "\n"); + sb.append("categoryFour: " + nullCheck(setCategoryFour) + "\n"); + sb.append("categoryFive: " + nullCheck(setCategoryFive) + "\n"); + sb.append("categorySix: " + nullCheck(setCategorySix) + "\n"); + sb.append("categorySeven: " + nullCheck(setCategorySeven) + "\n"); + sb.append("categoryEight: " + nullCheck(setCategoryEight) + "\n"); + sb.append("\n--------------------------\n\n"); + sb.append("categoryTripleMatch: " + nullCheck(setCategoryTripleMatch) + "\n"); + sb.append("categoryFourOfAKind: " + nullCheck(setCategoryFourOfAKind) + "\n"); + sb.append("categoryFullHouse: " + nullCheck(setCategoryFullHouse) + "\n"); + sb.append("categorySmallStreet: " + nullCheck(setCategorySmallStreet) + "\n"); + sb.append("categoryBigStreet: " + nullCheck(setCategoryBigStreet) + "\n"); + sb.append("categoryYahtzee: " + nullCheck(setCategoryYahtzee) + "\n"); + sb.append("categoryChance: " + nullCheck(setCategoryChance) + "\n"); + sb.append("categoryR2D2: " + nullCheck(setCategoryR2D2) + "\n"); + } else { + sb.append("categoryOne: " + nullCheck(setCategoryOne) + "\n"); + sb.append("categoryTwo: " + nullCheck(setCategoryTwo) + "\n"); + sb.append("categoryThree: " + nullCheck(setCategoryThree) + "\n"); + sb.append("categoryFour: " + nullCheck(setCategoryFour) + "\n"); + sb.append("categoryFive: " + nullCheck(setCategoryFive) + "\n"); + sb.append("categorySix: " + nullCheck(setCategorySix) + "\n"); + sb.append("\n--------------------------\n\n"); + sb.append("categoryTripleMatch: " + nullCheck(setCategoryTripleMatch) + "\n"); + sb.append("categoryFourOfAKind: " + nullCheck(setCategoryFourOfAKind) + "\n"); + sb.append("categoryFullHouse: " + nullCheck(setCategoryFullHouse) + "\n"); + sb.append("categorySmallStreet: " + nullCheck(setCategorySmallStreet) + "\n"); + sb.append("categoryBigStreet: " + nullCheck(setCategoryBigStreet) + "\n"); + sb.append("categoryYahtzee: " + nullCheck(setCategoryYahtzee) + "\n"); + sb.append("categoryChance: " + nullCheck(setCategoryChance) + "\n"); + } + return sb.toString(); + + } + + public String nullCheck(Integer i) { + + if (i == null) + return "___"; + else + return "" + i; + } } diff --git a/src/domain/Hand.java b/src/domain/Hand.java index 89fa2d4..f0526ab 100644 --- a/src/domain/Hand.java +++ b/src/domain/Hand.java @@ -33,13 +33,19 @@ public class Hand { } - public void lockInDices(int... dices) { + public void lockInDices(String... dices) { for (int i = 0; i < dices.length; i++) { - lockInDice(dices[i]); + lockInDice(Integer.parseInt(dices[i])); } } + public int getLockedInDiceAmount() { + + return lockedInDices.size(); + + } + public void rollDices() { if (this.leftRolls > 0) @@ -96,4 +102,5 @@ public class Hand { return this.leftRolls; } + } diff --git a/src/facade/YahtzeeGame.java b/src/facade/YahtzeeGame.java index 369c3b1..af2dde1 100644 --- a/src/facade/YahtzeeGame.java +++ b/src/facade/YahtzeeGame.java @@ -9,42 +9,39 @@ import java.util.Scanner; import domain.Player; - - public class YahtzeeGame { public int playerCount; public ArrayList players = new ArrayList<>(); public String savedGamemode; - public YahtzeeGame() { } - public void setPlayercount(int playerCount){ + public void setPlayercount(int playerCount) { this.playerCount = playerCount; - + } - public void setPlayerNames(String... names){ + public void setPlayerNames(String... names) { for (int i = 0; i < this.playerCount; i++) { this.players.add(new Player(names[i], this.savedGamemode)); } - + } - - public String getPlayerName(int player){ + + public String getPlayerName(int player) { return players.get(player).name; } - - public void setGamemode(String gamemode){ + + public void setGamemode(String gamemode) { this.savedGamemode = gamemode; - + } - + public void rollDices(int player) { players.get(player).hand.rollDices(); @@ -69,21 +66,35 @@ public class YahtzeeGame { } - public void lockInDices(int player, int... dices) { + public void lockInDices(int player, String... dices) { + if (dices[0].equals("none")) + return; players.get(player).hand.lockInDices(dices); } + public boolean allDicesLockedIn(int player) { + + return players.get(player).hand.getLockedInDiceAmount() == 5; + + } + public int getLeftRolls(int player) { return players.get(player).hand.getLeftRolls(); } + public boolean noMoreRolls(int player) { + + return 0 == getLeftRolls(player); + + } + public ArrayList getAllOptionsEvaluated(int player) { - players.get(player).box.evaluateBoxOptions(players.get(player - 1).hand.getAllDiceNumbers()); + players.get(player).box.evaluateBoxOptions(players.get(player).hand.getAllDiceNumbers()); return players.get(player).box.getAllOptions(); } @@ -96,23 +107,42 @@ public class YahtzeeGame { } + public String optionsPrinted(int player) { + + StringBuilder sb = new StringBuilder(); + + for (int i = 0; i < getAllOptionsEvaluated(player).size(); i++) { + + sb.append(getAllOptionsEvaluated(player).get(i) + "\n"); + + } + + return sb.toString(); + + } + + public String selectedOptionsPrinted(int player) { + + return players.get(player).box.selectedOptionsPrinted(player); + } + public boolean gameOver(int player) { return players.get(player).box.gameOver(); } - public boolean gameOverAll(){ + public boolean gameOverAll() { int counter = 0; - - for(int i = 0; iPlay"); - System.out.println(">Highscores"); + + System.out.println("Main menu:\n"); + System.out.println(">Play"); + System.out.println(">Highscores"); + choice = sc.nextLine(); + + if (choice.equals("Highscores")) { + System.out.println(game.showHighscores()); + System.out.println(">Return"); + System.out.println(">Delete"); choice = sc.nextLine(); - - if(choice.equals("Highscores")){ - System.out.println(game.showHighscores()); - System.out.println(">Return"); - System.out.println(">Delete"); + if (choice.equals("Return")) + break; + else if (choice.equals("Delete")) { + System.out.println( + "Are you sure you want to delete the Highscore file?\nAs a confirmation type: 'I AM SURE': "); choice = sc.nextLine(); - if(choice.equals("Return")) - break; - else if(choice.equals("Delete")){ - System.out.println("Are you sure you want to delete the Highscore file?\nAs a confirmation type: 'I AM SURE': "); - choice = sc.nextLine(); - if(choice.equals("I AM SURE")){ - game.deleteHighscores(); - System.out.println("Highscore file got deleted...\nReturning to the main menu..."); - } - else{ - System.out.println("Highscore file not deleted...\nReturning to the main menu..."); - } - + if (choice.equals("I AM SURE")) { + game.deleteHighscores(); + System.out.println("Highscore file got deleted...\nReturning to the main menu..."); + } else { + System.out.println("Highscore file not deleted...\nReturning to the main menu..."); } } - - else if(choice.equals("Play")){ - - System.out.println("Choose your gamemode: "); - System.out.println(">Normal"); - System.out.println(">StarWarsDay"); - System.out.println(">Special8"); - game.setGamemode(sc.nextLine()); - System.out.println("Amount of players: "); - System.out.println(">1-6"); - game.setPlayercount(sc.nextInt()); - System.out.println("Type in the player names, lock in each name with Enter: "); - System.out.println(">ex. Lucas [Enter] William [Enter] Lena [Enter]"); - - String playerNames[] = new String[game.playerCount]; - for(int i = 0; i < game.playerCount; i++){ - playerNames[i] = sc.nextLine(); - } - - game.setPlayerNames(playerNames); - - while (!game.gameOverAll()) { - - for(int i = 0; iNormal"); + System.out.println(">StarWarsDay"); + System.out.println(">Special8"); + game.setGamemode(sc.nextLine()); + System.out.println("Amount of players: "); + System.out.println(">1-6"); + game.setPlayercount(sc.nextInt()); + System.out.println("Type in the player names, lock in each name with Enter: "); + System.out.println(">ex. Lucas [Enter] William [Enter] Lena [Enter]"); + + String playerNames[] = new String[game.playerCount]; + for (int i = 0; i < game.playerCount; i++) { + playerNames[i] = sc.nextLine(); + } + + game.setPlayerNames(playerNames); + + while (!game.gameOverAll()) { + + for (int i = 0; i < game.playerCount; i++) { + + if (game.gameOver(i)) + continue; + + System.out.println("Its your turn " + game.getPlayerName(i)); + System.out.println("This is your Yahtzee Box: "); + System.out.println(game.selectedOptionsPrinted(i) + "\n"); + + while (!game.allDicesLockedIn(i) || !game.noMoreRolls(i)) { + + System.out.println("Your dices: "); + System.out.println("Free dices: " + game.getFreeDiceNumbers(i)); + System.out.println("Locked in dices: " + game.getLockedInDiceNumbers(i)); + System.out.println( + "Type in which free dices you want to keep \n(seperated by space, type 'none' if you dont want to keep any): "); + choice = sc.nextLine(); + game.lockInDices(i, choice.split(" ")); + game.rollDices(i); + System.out.println(game.getLeftRolls(i) + " rolls left"); + System.out.println("Rerolling dices... "); + + } + + System.out.println("Done locking in... Here are your options: "); + System.out.println(game.optionsPrinted(i)); + System.out.println("Which option you want to select?: "); + game.selectOption(i, sc.nextLine()); + + if (game.gameOver(i)) { + System.out.println( + "Your game is over, here is your total score: " + game.returnTotalPoints(i)); + } + } + } + + System.out.println("The game is over, saving all highscores to the highscore table..."); + game.saveAllPlayersHighscores(); + + } + } } }