-
Notifications
You must be signed in to change notification settings - Fork 64
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
Play Monopoly #29
Play Monopoly #29
Conversation
if not player_to_act.has_monopoly_card(): | ||
raise ValueError("Player doesn't have monopoly card") | ||
for player in self.players: | ||
if not player_to_act.color == player.color: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thought this was easier than looping with indexes and checking against the current_player_index
🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
@@ -42,6 +42,9 @@ def has_knight_card(self): | |||
def has_year_of_plenty_card(self): | |||
return self.development_deck.count(DevelopmentCard.YEAR_OF_PLENTY) > 0 | |||
|
|||
def has_monopoly_card(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think eventually we can make a more generic (has_dev_card(card_type)) method to replace these
game.execute(action_to_execute) | ||
|
||
|
||
def test_play_monopoly_player_steals_cards(): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this test, I wanted to show that player_to_act
stole the ORE and left the other resources intact (in this case just WHEAT). I was too lazy to add some other resources in there, but can make this test stronger if necessary
@@ -36,6 +37,11 @@ def test_year_of_plenty_possible_actions_not_enough_cards(): | |||
assert len(year_of_plenty_possible_actions(player, bank_resource_deck)) == 1 | |||
|
|||
|
|||
def test_monopoly_possible_actions(): | |||
player = SimplePlayer(Color.RED) | |||
assert len(monopoly_possible_actions(player)) == len(Resource) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥
assert player_to_steal_from_1.resource_deck.count(Resource.ORE) == 0 | ||
assert player_to_steal_from_1.resource_deck.count(Resource.WHEAT) == 1 | ||
assert player_to_steal_from_2.resource_deck.count(Resource.ORE) == 0 | ||
assert player_to_steal_from_2.resource_deck.count(Resource.WHEAT) == 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥 🔥
|
||
players = [player_to_act, player_to_steal_from_1, player_to_steal_from_2] | ||
game = Game(players) | ||
action_to_execute = Action(player_to_act, ActionType.PLAY_MONOPOLY, Resource.ORE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mono Ore. RIP 💔 😂
if not player_to_act.has_monopoly_card(): | ||
raise ValueError("Player doesn't have monopoly card") | ||
for player in self.players: | ||
if not player_to_act.color == player.color: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
No description provided.