Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added jail functionality fixes#10 #30

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

Ossedda
Copy link

@Ossedda Ossedda commented Oct 3, 2024

Added jail functionality to the game. Players that land in jail are given a choice to roll for doubles or pay a $50 fine to get out of jail. Players that roll doubles get out of jail and move that amount of spaces according to their roll. Players that do not roll doubles three times in a row while in jail are forced to pay the $50 fine. Players that pay the fine are also not able to move the turn they pay, voluntary or not. Changes were made in player_class.py in order to accommodate players being in a jailed state.

@@ -20,7 +23,7 @@ def __init__(self, num_players) -> None:
7: Property(0, "Chance", -4, (32,23), COLORS.CHANCE, 0, 0, 0, 0, 0, 0, 0, 0, 0),
8: Property(0, "Vermont Avenue", -1, (32,16), COLORS.LIGHTBLUE, 100, 50, 6, 30, 90, 270, 400, 550, 50),
9: Property(0, "Connecticut Avenue", -1, (32,9), COLORS.LIGHTBLUE, 120, 50, 8, 40, 100, 300, 450, 600, 60),
10: Property(0, "Jail", -7, (32,23), COLORS.LIGHTGRAY, 0, 0, 0, 0, 0, 0, 0, 0, 0),
10: Property(0, "Jail", -6, (32,2), COLORS.LIGHTGRAY, 0, 0, 0, 0, 0, 0, 0, 0, 0),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

printing bug fixed

@@ -30,7 +33,7 @@ def __init__(self, num_players) -> None:
17: Property(0, "Community Chest", -3, (11,2), COLORS.COMMUNITY, 0, 0, 0, 0, 0, 0, 0, 0, 0),
18: Property(0, "Tennessee Avenue", -1, (8,2), COLORS.ORANGE, 180, 100, 14, 70, 200, 550, 750, 950, 90),
19: Property(0, "New York Avenue", -1, (5,2), COLORS.ORANGE, 200, 100, 16, 80, 220, 600, 800, 1000, 100),
20: Property(0, "Free Parking", -1, (2,2), COLORS.LIGHTGRAY, 0, 0, 0, 0, 0, 0, 0, 0, 0),
20: Property(0, "Free Parking", -8, (2,2), COLORS.LIGHTGRAY, 0, 0, 0, 0, 0, 0, 0, 0, 0),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be identified as special code -8

@@ -52,7 +55,7 @@ def __init__(self, num_players) -> None:
39: Property(0, "Boardwalk", -1, (29,72), COLORS.BLUE, 400, 200, 50, 200, 600, 1400, 1700, 2000, 200),
}

def update_location(self, player:Player, roll: int, update_history, new = None) -> None:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed this definition because update_history is used exclusively once.. makes more sense to hardcode in monopoly.py (see change there)

update_history(f"{players[turn].name} cannot roll after paying the fine.")
return # End the turn after paying the fine
update_history(f"{players[turn].name} paid $50 to post bail.")
break
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed terminology and allow player to move after paying fine. this is typical monopoly gameplay


if players[turn].jail:
left_jail, reason = players[turn].attempt_jail_roll(dice)
if left_jail:
if reason == "doubles":
update_history(f"{players[turn].name} rolled doubles and got out of jail!")
elif reason == "third_turn":
update_history(f"{players[turn].name} didn't roll doubles on their third turn. They paid $50 and left jail.")
update_history(f"{players[turn].name} didn't roll doubles on their third turn. They paid $50 to post bail.")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

terminology changes

players[turn].go_to_jail()
# board.locations[players[turn].location].players.remove(turn)
board.locations[10].players.append(turn)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

relocated this to properly print after movement. looks better

@adamgulde
Copy link
Collaborator

@Ossedda The last change I would like you to add is allowing a player to use a "get out of jail free" card. This is located in player_class and should be easy to implement. Test all cases sufficiently. Great work!

Copy link
Collaborator

@adamgulde adamgulde left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see earlier comments :)

@Ossedda
Copy link
Author

Ossedda commented Oct 4, 2024

see earlier comments :)

Apologies on the initial jail logic. Second guessed myself on it last second :)
Will look into the changes and adding Get Out of Jail Free Card usage

@adamgulde adamgulde linked an issue Oct 5, 2024 that may be closed by this pull request
@adamgulde adamgulde mentioned this pull request Sep 30, 2024
@adamgulde
Copy link
Collaborator

@Ossedda update on this?

@adamgulde adamgulde self-assigned this Oct 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Jail doesn't do anything
2 participants