From b0d4e94f2f089ae8f38dfa0efbd61766642d7599 Mon Sep 17 00:00:00 2001 From: selim Date: Tue, 30 Apr 2024 01:44:50 +0200 Subject: [PATCH] First final version --- bin/csv/highscores.csv | 1 - bin/domain/Box.class | Bin 10702 -> 10852 bytes bin/facade/YahtzeeGame.class | Bin 10731 -> 10622 bytes bin/ui/TUI.class | Bin 4840 -> 4881 bytes src/csv/highscores.csv | 1 - src/domain/Box.java | 36 +++++++++++++++++++++-------------- src/facade/YahtzeeGame.java | 29 ++++++++++++++++------------ src/ui/TUI.java | 1 + 8 files changed, 40 insertions(+), 28 deletions(-) diff --git a/bin/csv/highscores.csv b/bin/csv/highscores.csv index 8b13789..e69de29 100644 --- a/bin/csv/highscores.csv +++ b/bin/csv/highscores.csv @@ -1 +0,0 @@ - diff --git a/bin/domain/Box.class b/bin/domain/Box.class index bb0735ca700fa211be9765e1dab75468dd4eb419..6bf0fb6087bc9c8305c1c464032be5e372d25c39 100644 GIT binary patch delta 989 zcma))Nla5w6o&u56N4p|7J?g`APzK|K$!xF2q;=qWKf2JL5Kr`C?Kc|wn7y_SV)bA z=!V4T0uoKCNFX5*MIt7~;DV?-b)&?MA!>v~Pg`kSy6F49|Gsz5yM5=r%KudGpf)(9 z9V#dR{xGUWkvf9R0mM6O!KM{PwJ$$$WsNT@^pgF2Im4Cxec7%zX^lE>L4xDCK2{dI z6$y?2L#!jsU{>D6W=EeP%$kfnNWp$=Lm5(0FW!bUbYTa2k&au)z@kxhT>Wf=C+C?1a-rsDv!kjp~ku|~WZ1?<2xw7yoB#KjCcUY5a{|YNI;?_mmQTgA_&nq4h@%H1@orN~~Iz%view9oH*R+)MaN$&fuC%61l<>}z5@^sL+IyfW4u4zMG$d{1KV?hc` z`l%6251`XA5n+>GOn+pYby#jH5hqufw*1RNXjudki;*Nu7N!d`gl1v3Fi)7z5*bF3 z490>AVWqHISR-r@HVRvWtt>@{u#;uz5%#hiP9DLSa9lWI65oWb`MXDgg}?K6jYJJDqSrYZX;E0K;4jB2gtgeflSpKpZ2pv-pwp;h zJ#1`1KO1p}XE4krOvv$j&9m~Zb6DVcYS_Y6Y-JSNn8J2$=LP1{%1YYU#Ea}=2M5^6 wA=>HWB~I}&=VbLWuW*swil9LDDAw?*BAR`U+Z*cw98mGPZ0Uy6uxXrs0HCwl8UO$Q delta 935 zcma)(OGs2<7>3{XI8Hihj?-kd5G%37Lzb7kOs3_vM$@J-@0ej;GSe=mX5~zV6=X%8 z2xeyxh!jywWe`aeK@o}2LV`9)o1k4cFc*Di)R~rT&hz~5|9}7a&iTGnOgSHPL|N~{ zfFM8#R}D{*^8^JRWNGfG)a7G*uLcLANnbRq8UxY1FDg-&1tOb8FEptkfvC@t8aaly zs@Y#@(aTjtih#j~pyCcZMZRF#z_zM)^6$&whB78tGX0Z#uP()%k4X`s3CA6ZHaoEEQ z@jR5V5alj9u$Pr^um$_rFFph(FQbAtv7a7PavW8BF8&79e1{s&pq8Id$8V@tfLbLC z4bnc)0+ar4rS(i%>DDY65rJg1!UzRre!K2B*YuJy%5P4jER^t;-##uG+T`|dxp?6f zhsD|@v19E#%v`U`!8DJ^{}40dl({hdw9jDjezs0<%_!C-K0H3o;2zwz2Bp6goi5f$c>Ko()(9unHSljU?e_VY)Cw zm?O*;772@mWx{gS$P}t%3N>gD9uT$&TZNs%F4m$)*vmQ$2=!U`eh=J>vmk!L>x{2d zTn7=tCRlk08`z9YnYo>WhFr;#VPnkSja zZf5fobJ;@&d)dT3S)Jx3_S3^Nyvwun@*H1tfHQRQE8YCV^Gbw?gGwwfD9IesQW82t QufV`zY3Z7GJmDGt0$I|&kpKVy diff --git a/bin/facade/YahtzeeGame.class b/bin/facade/YahtzeeGame.class index 1b610c74047f48f545af8e561822bbbf4c2f89f5..6f05a14dd12a45dd57136185590e5f3402b31da5 100644 GIT binary patch delta 3952 zcmcgvd32Q36~Di4olL%L1CwnsSs@8YNJ0dJB%mOx5Vl}aq=*5=5Dl4_3?WGEfMOME zjrwXqiwbTj3PON0AXK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Z=;Spb`X3`U0q?XY$-k~0$L0;qxIKE;y3E%i0r;on#lg?J@ zi;SPVSo4(rCfHO`WyA@t6}7>jw<1&?tXu3Q8RGDLJ1XpPG_Vs$W}Vmtr}!wVkYrvJo?}p)Y^(z>@KW5k z&f4$_ufZ^j?Z+Fug^gU)f+3-kC^;2rc!x&VX%Q9t^YET;bI*u= 1 && counter[i + 1] >= 1 && counter[i + 2] >= 1) categorySmallStreet = 30; } for (int i = 0; i < 5; i++) { - if (counter[i] == 1 && counter[i + 1] == 1 && counter[i + 2] == 1 && counter[i + 3] == 1) + if (counter[i] >= 1 && counter[i + 1] >= 1 && counter[i + 2] >= 1 && counter[i + 3] >= 1) categoryBigStreet = 40; } @@ -340,11 +340,19 @@ public class Box { public int returnTotalPoints() { - return setCategoryOne + setCategoryTwo + setCategoryThree + setCategoryFour + setCategoryFive - + setCategorySix + setCategorySeven + setCategoryEight + setCategoryTripleMatch + setCategoryFourOfAKind - + setCategoryFullHouse + setCategorySmallStreet + setCategoryBigStreet + setCategoryYahtzee - + setCategoryChance - + setCategoryR2D2; + if (savedGamemode.equals("Special8")) + return setCategoryOne + setCategoryTwo + setCategoryThree + setCategoryFour + setCategoryFive + + setCategorySix + setCategorySeven + setCategoryEight + setCategoryTripleMatch + + setCategoryFourOfAKind + + setCategoryFullHouse + setCategorySmallStreet + setCategoryBigStreet + setCategoryYahtzee + + setCategoryChance + + setCategoryR2D2; + else + + return setCategoryOne + setCategoryTwo + setCategoryThree + setCategoryFour + setCategoryFive + + setCategorySix + setCategoryTripleMatch + setCategoryFourOfAKind + + setCategoryFullHouse + setCategorySmallStreet + setCategoryBigStreet + setCategoryYahtzee + + setCategoryChance; } diff --git a/src/facade/YahtzeeGame.java b/src/facade/YahtzeeGame.java index 3f1f7af..f44051b 100644 --- a/src/facade/YahtzeeGame.java +++ b/src/facade/YahtzeeGame.java @@ -100,9 +100,14 @@ public class YahtzeeGame { } - public ArrayList getAllOptionsEvaluated(int player) { + public void evaluateAllOptions(int player) { + + players.get(player).box.evaluateBoxOptions(players.get(player).hand.getLockedInDiceNumbers()); + + } + + public ArrayList getAllOptions(int player) { - players.get(player).box.evaluateBoxOptions(players.get(player).hand.getAllDiceNumbers()); return players.get(player).box.getAllOptions(); } @@ -119,9 +124,9 @@ public class YahtzeeGame { StringBuilder sb = new StringBuilder(); - for (int i = 0; i < getAllOptionsEvaluated(player).size(); i++) { + for (int i = 0; i < getAllOptions(player).size(); i++) { - sb.append(getAllOptionsEvaluated(player).get(i) + "\n"); + sb.append(getAllOptions(player).get(i) + "\n"); } @@ -173,7 +178,7 @@ public class YahtzeeGame { highscores[i][0] = mem[0]; highscores[i][1] = mem[1]; highscores[i][2] = mem[2]; - System.out.println("test"); + } else { highscores[i][0] = "___"; highscores[i][1] = "___"; @@ -398,10 +403,10 @@ public class YahtzeeGame { PrintWriter out = new PrintWriter(new FileWriter("src/csv/highscores.csv", false)); for (int i = 0; i < 10; i++) { - for (int s = 0; s < 3; s++) { - out.print((i + 1) + ": " + LocalDate.now() + ": " + players.get(player).name + ": " - + returnTotalPoints(player)); - } + + out.print(LocalDate.now() + ": " + players.get(player).name + ": " + + returnTotalPoints(player)); + out.println(); } @@ -426,8 +431,8 @@ public class YahtzeeGame { for (int i = 0; i < 10; i++) { sb.append((i + 1) + ": " + refreshHighscoreList()[i][0]); - sb.append(": " + refreshHighscoreList()[i][1]); - sb.append(": " + refreshHighscoreList()[i][2] + "\n"); + sb.append(" " + refreshHighscoreList()[i][1]); + sb.append(" " + refreshHighscoreList()[i][2] + "\n"); } @@ -439,7 +444,7 @@ public class YahtzeeGame { PrintWriter out = new PrintWriter(new FileWriter("src/csv/highscores.csv", false)); - out.println(""); + out.print(""); out.close(); diff --git a/src/ui/TUI.java b/src/ui/TUI.java index 7d452dd..b02bcb9 100644 --- a/src/ui/TUI.java +++ b/src/ui/TUI.java @@ -102,6 +102,7 @@ public class TUI { System.out.println("\n\nLocked in dices: " + game.getLockedInDiceNumbers(i)); System.out.println("Done locking in... Here are your options: "); + game.evaluateAllOptions(i); System.out.println(game.optionsPrinted(i)); System.out.println("Which option you want to select?: "); game.selectOption(i, sc.nextLine());