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

Play Monopoly #29

Merged
merged 2 commits into from
Oct 4, 2020
Merged

Play Monopoly #29

merged 2 commits into from
Oct 4, 2020

Conversation

dagarcia7
Copy link
Collaborator

No description provided.

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:
Copy link
Collaborator Author

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 🤷

Copy link
Owner

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):
Copy link
Collaborator Author

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():
Copy link
Collaborator Author

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)
Copy link
Owner

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
Copy link
Owner

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)
Copy link
Owner

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:
Copy link
Owner

Choose a reason for hiding this comment

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

Looks good to me.

@bcollazo bcollazo merged commit 0ae491b into master Oct 4, 2020
@bcollazo bcollazo deleted the feature/monopoly branch October 4, 2020 11:37
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.

2 participants