From a272ef3459dd6ced49d0c28375a79f7eba1c84fc Mon Sep 17 00:00:00 2001 From: Thomas Naber Date: Thu, 22 Feb 2024 12:32:29 -0500 Subject: [PATCH] Will complete this when it's done. --- __pycache__/yahtzee.cpython-311.pyc | Bin 7892 -> 7976 bytes __pycache__/yahtzee_goals.cpython-311.pyc | Bin 2181 -> 11963 bytes play.py | 14 ++ yahtzee_goals.py | 235 ++++++++++++++++++++++ 4 files changed, 249 insertions(+) diff --git a/__pycache__/yahtzee.cpython-311.pyc b/__pycache__/yahtzee.cpython-311.pyc index 1af0e209d50ae50772477301228c7b0985ef9253..ac8e7054be47b3267ae1eb924318a5d0e290e717 100644 GIT binary patch delta 585 zcmZ|Nze~eF6u|L&*S!2_^Q*P~qP4gvEx0HS1 zO;@?e*};FnsV<6(i*SN24(dxRhlpnQe#pCAE<W+ zVo@>`H`$Ch7|(k7p6OVUOvO(=#)!{U$r7pP#bV(mQGK)SLV3y2bK!%tjBMeE25t+Y!$~h3~cjt&htPi{% zKuxV?&!Bn}bU6&^UiijgO5f+Z05j^U?*kT8Cw_)SecZ1Amh{-bK0rfX4z@U~t5UfQ zEBc}waoA9|l~ZWy0DMV>J?MvTCSJVx&6udOm606<%&ip38uwj4u@-=_`XS*%wWuJ$r BbVvXI diff --git a/__pycache__/yahtzee_goals.cpython-311.pyc b/__pycache__/yahtzee_goals.cpython-311.pyc index e53a6a07c0a243da1c02ce32532d53839349b16b..417cfcad9dbe5b2d7560d55537ba1037f5f7a5ed 100644 GIT binary patch literal 11963 zcmdT~U2NOd6(%K0rYtG4EIYQ9IA(sj#EuikiQS(xO`0Wf<1|ar*~MBTgQ|*jtVWg+ zQeF~4*#fMAfQ07VGqF`=D>L<@-Xb2 zLy8hfS(Y1XSSj&{y65un+;h+U?m74JcV2HZ1IJ%>{#CjfWSD>8pVGl;7b~x`40D^Y zF)uM9^A01jcWn&w8Jy}dp>k}%v70z7-NOOLVdB_`;{;BViDM@Y4;+_?!x5($IBpZi zK^zZoye5v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FS5Et zAj7OXCpF8!KEzPGY}N4xA{0G1h~+e$*ktTkb-BHIyyz`ikpRMr1{{T3C{nz2?B=m7 zYy${OZUJ6$bG3guesBDf^SSe|^q)CY@cM6sZices3*H?|-W`<6eww_O{3M-AuREnB zHLFcTmr;KtkKwdTL>1crcE^5Dp+uT_3@CNd=ERiNO4NW7#h>f-((8Zp{ujN_L+@SC z{yJ^e(q;jz|51ibK`zaZgn^`@DII^zA5q^(JSty>C*TlNI>8N=?JUbKb6yryvXX~b z_NdI*X01ZEeeddR!}eOqLo9n#X1vI5!HQP$5X&Bw8HYQto|QbrvPWgcP#4y-l80FK gsLVKQtwOh%>pks3c~h($ delta 121 zcmdlT+bYPnoR^o20SE-N52W5_p2#P`6v8l3BZw`9Eto-*eewi0`^|?L&#*EUZ=S$z z!f5WN$y~$?R9>VABGf>HJc!^25j;TR7l%!5eoARhs$G#5kjn_f#qA7}=jb#{zOBQ_ H3RVaJpkNyI diff --git a/play.py b/play.py index a8e683c..df547b9 100644 --- a/play.py +++ b/play.py @@ -3,12 +3,26 @@ from yahtzee_goals import ( GoalOnes, GoalTwos, GoalThrees, + ThreeOfAKind, + FourOfAKind, + FullHouse, + SmallStraight, + LargeStraight, + Yahtzee, + Chance ) goals = [ GoalOnes(), GoalTwos(), GoalThrees(), + ThreeOfAKind(), + FourOfAKind(), + FullHouse(), + SmallStraight(), + LargeStraight(), + Yahtzee(), + Chance() ] game = Yachtzee(goals) diff --git a/yahtzee_goals.py b/yahtzee_goals.py index fce4e5a..cdce267 100644 --- a/yahtzee_goals.py +++ b/yahtzee_goals.py @@ -43,3 +43,238 @@ class GoalThrees: if die.face == 3: total += 3 return total + +class GoalFours: + "Four points for each four" + used = False + + def prompt(self,dice): + potential_score = self.score(dice) + return f"Fours ({potential_score})" + + def score(self,dice): + total = 0 + for die in dice: + if die.face == 4: + total+= 4 + return total + +class GoalFives: + "Five points for each five" + used = False + + def prompt(self,dice): + potential_score = self.score(dice) + return f"Fives ({potential_score})" + + def score(self,dice): + total = 0 + for die in dice: + if die.face == 5: + total+= 5 + return total + +class GoalSixes: + "Six points for each Six" + used = False + + def prompt(self,dice): + potential_score = self.score(dice) + return f"Sixes ({potential_score})" + + def score(self,dice): + total = 0 + for die in dice: + if die.face == 6: + total+= 6 + return total + +class ThreeOfAKind: + "Total of all six dice, if there are at least three of one number" + used = False + + def prompt(self,dice): + potential_score = self.score(dice) + return f"Three of a Kind ({potential_score})" + + def is_three_of_a_kind(self,dice): + facesList = [] + for die in dice: + facesList += die.face() + facesList.sort() + if facesList[0]==facesList[2]: + return True + elif facesList[1]==facesList[3]: + return True + elif facesList[3]==facesList[5]: + return True + else: + return False + + def score(self,dice): + if self.is_three_of_a_kind(dice): + total = 0 + for die in dice: + if die.face == 6: + total+= 6 + return total + else: + return 0 + +class FourOfAKind: + "Total of all six dice, if there are at least four of one number" + used = False + + def prompt(self,dice): + potential_score = self.score(dice) + return f"Four of a Kind ({potential_score})" + + def is_four_of_a_kind(self, dice): + facesList = [] + for die in dice: + facesList += die.face() + if facesList[0]==facesList[3]: + return True + elif facesList[1]==facesList[4]: + return True + else: + return False + + def score(self,dice): + if self.is_four_of_a_kind(dice): + total = 0 + for die in dice: + if die.face == 6: + total+= 6 + return total + else: + return 0 + +class FullHouse: + "If there are two of one number and three of another, earn 25 points" + used = False + + def prompt(self,dice): + potential_score = self.score(dice) + return f"Full House ({potential_score})" + + def is_full_house(self, dice): + facesList = [] + for die in dice: + facesList += die.face() + if facesList[0] == facesList[1] and facesList[2] == facesList[4]: + return True + elif facesList[0] == facesList[2] and facesList[3] == facesList[4]: + return True + else: + return False + + def score(self, dice): + if self.is_full_house(dice): + return 25 + else: + return 0 + + +class SmallStraight: + "If there is any sequence of four numbers, earn 30 points" + used = False + + def prompt(self, dice): + potential_score = self.score(dice) + return f"Small Straight ({potential_score})" + + def is_small_straight(self,dice): + facesList = [] + for die in dice: + facesList += die.face() + count = 0 + for i in range(0,3): + if facesList[i] == facesList[i+1] - 1: + count += 1 + if count >= 4: + return True + else: + return False + + def score(self,dice): + if self.is_small_straight(dice): + return 30 + else: + return 0 + + + +class LargeStraight: + "If there is any sequence of 5 numbers, earn 40 points" + used = False + + def prompt(self,dice): + potential_score = self.score(dice) + return f"Large Straignt ({potential_score})" + + def is_Large_Straight(self,dice): + facesList = [] + for die in dice: + facesList += die.face() + count = 0 + for i in range(0,3): + if facesList[i] != facesList[i+1] - 1: + count += 1 + if count == 5: + return True + else: + return False + + def score(self,dice): + if self.is_Large_straight(dice): + return 40 + else: + return 0 + +class Chance: + "Total of all 5 dice" + used = False + + def prompt(self,dice): + potential_score = self.score(dice) + return f"Chance ({potential_score})" + + def score(self,dice): + total = 0 + for die in dice: + total += die.face + return total + + +class Yahtzee: + "Six of a Kind 50 points, 100 points for yahtzees after the first" + used = False + + def prompt(self,dice): + + potential_score = self.score(dice) + return f"Yahtzee ({potential_score})" + + def is_yahtzee(self): + facesList = [] + for die in dice: + facesList += die.face() + + if facesList[0] == facesList[4]: + return True + else: + return False + + def score(self,dice): + if self.is_yahtzee(dice) and used == True: + return 100 + elif self.is_yahtzee(dice) and used != True: + return 50 + else: + return 0 + + + + + \ No newline at end of file