Question: Enforcing Game Rules ( 1 5 pts ) Game rules require the player to choose one, and only one, score category every round even if
Enforcing Game Rules pts
Game rules require the player to choose one, and only one, score category every round even if the
category is not achieved. The result is for the selected category. Track which categories have been
selected using a python dictionary. Each key is a category name and the corresponding value is
TrueFalse For example:
selected ind:False,traight:False
scratchhighestcategoryselectedthis function is passed a dictionary that
contains TrueFalse for each scoring category. Step through the dictionary from left to
right highest to lowest score and change the first category marked False to True. This
prevents the category from being selected a second time called a scratch For example, if
fiveofkind has not yet been rolled then it will be first to be scratched since it is the highest
remaining category.
scoredice dice update this function. Create a dictionary that holds a pair for the
eight score categories see above For each scoring category, only update the game score if the
category is achieved and it has not been selected. Also, mark the category as selected. If no
category is achieved after checking all eight possibiliteis, call
scratchhighestcategory selected
elif fourofkinddice and not selected.getfourofkind":
score FOUR OF KIND
selectedfourofkind" True
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
