Created
April 16, 2023 16:00
-
-
Save audhiaprilliant/93763a32c39e06fb6e832a344f15fec4 to your computer and use it in GitHub Desktop.
Creating a Monopoly Game Board Simulation with Python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Rounds on Monopoly board | |
def round_spaces( | |
dict_spaces: dict | |
): | |
# Latest round | |
latest_round = dict_spaces['round'] | |
# Update status | |
updated_status = False | |
# After-before spaces | |
before = dict_spaces['move']['before'] | |
after = dict_spaces['move']['after']['real'] | |
if dict_spaces['move']['after']['updated'] != None: | |
after = dict_spaces['move']['after']['updated'] | |
updated_status = True | |
# Create a list | |
l = list(range(before, after)) | |
# Dice roll | |
dices_roll = abs(before - after) | |
# Jail status | |
jail_status = dict_spaces['move']['jail']['status'] | |
# Chance card | |
chance_card = dict_spaces['move']['chance_card'] | |
# Community chest card | |
community_card = dict_spaces['move']['community_card'] | |
# If player(s) is on a 'Jail' | |
if jail_status == False: | |
if (chance_card != None) and (community_card != None): | |
# Check condition | |
if len(l) == 0: | |
# Move forward | |
if dices_roll > 12: | |
dict_spaces['round'] += 1 | |
# Stay | |
else: | |
pass | |
else: | |
# Move backward | |
if dices_roll > 12: | |
dict_spaces['round'] -= 1 | |
# Stay | |
else: | |
pass | |
else: | |
if (chance_card != None): | |
pass | |
else: | |
pass | |
return dict_spaces |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment