From 0081a61c118c2a2ff343a54e75bc53656c8c65ed Mon Sep 17 00:00:00 2001 From: selim Date: Sun, 28 Apr 2024 15:17:13 +0200 Subject: [PATCH] Initial commit of tui --- bin/domain/Box.class | Bin 8667 -> 8667 bytes bin/domain/Player.class | Bin 1502 -> 705 bytes bin/facade/YahtzeeGame.class | Bin 924 -> 2799 bytes bin/ui/TUI.class | Bin 0 -> 240 bytes src/domain/Box.java | 4 +-- src/domain/Player.java | 18 +++------- src/facade/YahtzeeGame.java | 64 +++++++++++++++++++++++++++++++++++ src/ui/TUI.java | 5 +++ 8 files changed, 75 insertions(+), 16 deletions(-) create mode 100644 bin/ui/TUI.class create mode 100644 src/ui/TUI.java diff --git a/bin/domain/Box.class b/bin/domain/Box.class index 536567613e6d2f3815faf50ab32a916a2b529272..8ebf2b505eaa9a373e991646f5151c0e273770cc 100644 GIT binary patch delta 21 bcmccZeA{`$G+sug&C_`gGXtq;!3F^UUeO0) delta 21 bcmccZeA{`$G+su=&C_`gGXtq;!3F^UUcLul diff --git a/bin/domain/Player.class b/bin/domain/Player.class index ced470127d78665ff4f2fe83fdc2533aa6536830..e97c8034e7633a7df7a7201685418f157a34f967 100644 GIT binary patch delta 132 zcmcb|eUO#w)W2Q(7#J9A8MHQXO=X;XiAhq2L6L!xff*>s0;E|P*nliX26hGxFwM!p z1*W;d;!KmvSbRjefGT+yI2m{uL>c&iy7?K@7z8I@XNgu61+v8%lz}>UfMzf-2r#HH NsDkxt07)hWO#t}Z4fOy3 literal 1502 zcmaJ=>uwuG7(Ek*th?FV+ys-91_#_Gc0*0ewRLGBE@=YJrF9ep{6G_XWN%~dM7xu; zc@ubxB9Rsqi3i}J5NCF`#E~t2?Ckf=obP=1zyEpt7l1F(a4;e;(b7HX2bJBfJXN8C zQGw~F@2B&w%O8&r9nInd7qyf?RN z`Z+HrB6*@(k4V`G65|CA4zdp36>w8yM(pAW@|OEO50~ItY01Ml#ssG7exSCG zdj~4qlLy_nIJzmj`!e*co?eccjvra{g)*}e+4g@$aNEjkt7o=uEEtsyzuk$NIwa}r zN@=hRHmn;SR`FrVvvZ=txDY?OsNj}^k64blRmShBO5FzbP#WdoHa;dW(9Z<&Z>TR~ zs+QtY51*k#cB7L%TbEyWxP!X_GodoaVX&u-?CxqmFien5*vxUP?s=Rn_A}p;hpMK7 zrZnICrb8(*GDhAR(u2ViH;1I1#a9As!9>Hz=HZq+N^9&k^l{i!>%Q&6crwU0ZT1}H zHLXo#LV2{MOh>mO7wgz?@JOI|KFWS@q7PLi$utRiT{evlPi;1v0>AXfoT3v#+qABV zigm3IkB_Q@iS*rEFx)#mQbXWB_2HA{tM*qSrKrhnx8WOAof^Y8S=2c;Ew=Y=LAZhk z)y*JKVXZ5pNJS2I1g;IFJ1hYQj|CS0AIhywvc(dckzvzE`Em7l!fsLg=eopyE(`w| zB0Ws-oTPS23v0Jreub&>jWguRe`5BB)mM1?4D*z)So!K17R#$=DEvm~2;S$p5R-W{ zpX5GHVGh#_Vg}c786WVykkF!tYt-l<4vRxW={jvk7{D^|Nf`IZW8bD@@8#c7NCG(b z=h6bm)6;y+?MW9HU#g{1miiJOL^Cdo^o=fgNe~l{eBKP10IWuuS vlX1LPS*k_mQRwqgOnrPEW5p7IYZOON!$bbFbo(v8@32M9rL>J*Ji+|G4GUW8 diff --git a/bin/facade/YahtzeeGame.class b/bin/facade/YahtzeeGame.class index afacad4ac749f17b8e2da357fa10b8c91b7079e8..ad2bd07918f7f5f56e391f7b996a63ed10e718b5 100644 GIT binary patch literal 2799 zcmb7FT~iZR7=BK&uo4!Pkf;>#tF4AKN^7lBKr5n1Gzt|&k$$)&$FLf9akD|OA2W9P zCwked-gwc@Xqc%ponCkPBl=5fpR>EhutBUh*>m1=&htL+^M2&7e}Df2z-fH1BPNi% zV;0Sl9Go|oyhl=AG?%3gOSF61SI$`M8NA4TKNuVDG6#PMfBbinnt(Ji~ z<>_4m@8Nw?GD{_j+x#-f#>l`efgJ_QmRD=bi_)Dn7c0I}PSLE)nXaYwp;7aeET$+` zXiYVB+@^F4bZ)b`I1v*S9I%6Y4(;IvFW zi0TsqCvl2Vl~vNxG&jW`#??W^J~c25Qqz`9o8fo8ERjiWM-nXE&vY=^ouSmqY~Z*` zVS7-J0^M{m7BC0|B9A={hb?7#^fgDLO$76{C(F`hg(?ac42)qyV0R`Aq6ITa3KOoB zN`;VvdYCtGQ9azne&Ur|oZevl0DUb+rMXP}#=qD*dpEQLmREh$@BVwxZxs5vp z%1V~54bFhL=>}DQOVNH{zyp=xcwx_WyOPt;o^?F4GVNHlNA%nH#=x4& zO=8BWxkWi)sb=2UG?S01k%WVsHE|AajbDx)t~i6SjlUgS$B^KPgUGjc`QJ`F=JeS? z`%YT_=BqY-$Fu9`&OS$KejU4>VRyFg8G5t1XXuNc)P6yK_9=EhNB{iMw04~9zIE)c zG&tL;|1_jqZ2QO$y!UMGy8P&35m>Iqbm^-Z&AsMg{}i zk%S+D@K;%qjrpq&kR$G1A|GXd8jjJLM(hRQ+H?q^V^GIOeAUaCj^pDnvH~9|fRv)% zr6D|6y?u^nfvV%ac9XC7aQ@eZ z2lZM>q5^(B`o*_FpNyhs-hh7TZO|`A(T{D3{+NU3YN+`QDx#_}9o0Nn$5d4G6ReAq zKJvm$tP6F>SMmkLb(V!T*2H7D5$ABDxRzjr(ftrgI21*ugm>R5TDa*~mN z|12p?(t94KaJfnCp$3bghT21@`dueDo@#GUn~|)W2Q(7#J9A8B8{E#V}2t%NoeYIQc#6eO3krCI({w;Ux;B diff --git a/bin/ui/TUI.class b/bin/ui/TUI.class new file mode 100644 index 0000000000000000000000000000000000000000..3727185a5d183bb0976aa03e5dc61ee0e2338758 GIT binary patch literal 240 zcmXX=I}UD?9@UI;HNP$F(F#0^b2lu2||M4y{t?uJb;HXzEzuvc=f;Ksmr=*yhbCj|dt1zHR)h|tf$j%fcq+XB literal 0 HcmV?d00001 diff --git a/src/domain/Box.java b/src/domain/Box.java index 280d65a..3e7afda 100644 --- a/src/domain/Box.java +++ b/src/domain/Box.java @@ -49,7 +49,7 @@ public class Box { this.savedGamemode = gamemode; } - public void evaluateUpperBoxOptions(ArrayList diceNumbers) { + private void evaluateUpperBoxOptions(ArrayList diceNumbers) { if (diceNumbers.contains(1)) for (int i = 0; i < diceNumbers.size(); i++) { @@ -93,7 +93,7 @@ public class Box { } } - public void evaluateLowerBoxOptions(ArrayList diceNumbers) { + private void evaluateLowerBoxOptions(ArrayList diceNumbers) { int sumOfAllNumbers = 0; for (int i = 0; i < diceNumbers.size(); i++) { diff --git a/src/domain/Player.java b/src/domain/Player.java index b23f4b9..96bfdac 100644 --- a/src/domain/Player.java +++ b/src/domain/Player.java @@ -1,13 +1,11 @@ package domain; -import java.time.LocalDate; - public class Player { - String name; - Hand hand; - Box box; - String savedGamemode; + public String name; + public Hand hand; + public Box box; + public String savedGamemode; public Player(String name, String gamemode) { @@ -24,12 +22,4 @@ public class Player { } - public String getHighscore() { - - if (box.gameOver()) - return "date: " + LocalDate.now().toString() + "\n" + name + ": " + box.returnTotalPoints(); - else - return ""; - - } } diff --git a/src/facade/YahtzeeGame.java b/src/facade/YahtzeeGame.java index f3b32b5..95ca70a 100644 --- a/src/facade/YahtzeeGame.java +++ b/src/facade/YahtzeeGame.java @@ -23,4 +23,68 @@ public class YahtzeeGame { } } + public void rollDices(int player) { + + players.get(player - 1).hand.rollDices(); + + } + + public ArrayList getAllDiceNumbers(int player) { + + return players.get(player - 1).hand.getAllDiceNumbers(); + + } + + public ArrayList getFreeDiceNumbers(int player) { + + return players.get(player - 1).hand.getFreeDiceNumbers(); + + } + + public ArrayList getLockedInDiceNumbers(int player) { + + return players.get(player - 1).hand.getLockedInDiceNumbers(); + + } + + public void lockInDices(int player, int... dices) { + + players.get(player - 1).hand.lockInDices(dices); + + } + + public int getLeftRolls(int player) { + + return players.get(player - 1).hand.getLeftRolls(); + + } + + public ArrayList getAllOptionsEvaluated(int player) { + + players.get(player - 1).box.evaluateBoxOptions(players.get(player - 1).hand.getAllDiceNumbers()); + return players.get(player - 1).box.getAllOptions(); + + } + + public void selectOption(int player, String selectedOption) { + + players.get(player - 1).box.selectOption(selectedOption); + players.get(player - 1).box.resetOptions(); + players.get(player - 1).getNewHand(); + + } + + public boolean gameOver(int player) { + + return players.get(player - 1).box.gameOver(); + + } + + public int returnTotalPoints(int player) { + + if (players.get(player - 1).box.gameOver()) + return players.get(player - 1).box.returnTotalPoints(); + else + return 0; + } } diff --git a/src/ui/TUI.java b/src/ui/TUI.java new file mode 100644 index 0000000..d9ecb19 --- /dev/null +++ b/src/ui/TUI.java @@ -0,0 +1,5 @@ +package ui; + +public class TUI { + +}