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

Feature/disallow immediate dev card #290

Closed

Conversation

zarns
Copy link
Contributor

@zarns zarns commented Nov 5, 2024

closes #149

Players should be able to,

  • Play any development cards before rolling
  • Play development cards they purchased on previous turns

Players should not be able to,

  • Play dev cards purchased on the same turn (excluding victory points)
  • Play more than one dev card (of any type excluding victory points) in a turn

Copy link

netlify bot commented Nov 5, 2024

👷 Deploy request for catanatron-staging pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit b8e9b9b

? proceedAction
: isMoveRobber
? setIsMovingRobber
: isPlayingYearOfPlenty || isPlayingMonopoly
? handleOpenResourceSelector
: isRoll
? rollAction
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved isRoll to later in the ternary statements because if a dev card is played before rolling, we want to see the ResourceSelector button for monopoly/yearOfPlenty

menuListId="trade-menu-list"
icon={<AccountBalanceIcon />}
items={tradeItems}
>
Trade
</OptionsButton>
<Button
disabled={gameState.is_initial_build_phase}
disabled={gameState.is_initial_build_phase || isRoadBuilding}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Still need to see ResourceSelector "Select" button for Monopoly/YOP, hide other buttons while playing dev cards

@zarns zarns force-pushed the feature/disallow_immediate_dev_card branch from e48f827 to b8e9b9b Compare November 5, 2024 18:43
@coveralls
Copy link

Pull Request Test Coverage Report for Build 11690556474

Details

  • 19 of 19 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.02%) to 95.992%

Totals Coverage Status
Change from base Build 10864300657: 0.02%
Covered Lines: 1389
Relevant Lines: 1447

💛 - Coveralls

Copy link
Owner

@bcollazo bcollazo left a comment

Choose a reason for hiding this comment

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

Similar to the other PR, do you mind running many games before and after this change to keep in mind performance? Doing something like catanatron-play -n 1000 is probably good enough for some rough numbers. 👍

Thanks again for this. Great contributions left and right. 💪

and len(road_building_possibilities(state, color, False)) > 0
):
actions.append(Action(color, ActionType.PLAY_ROAD_BUILDING, None))

if state.is_road_building:
actions = road_building_possibilities(state, color, False)
Copy link
Owner

Choose a reason for hiding this comment

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

In the scenario they are road building, I think I'd like the game state to stay focused on that what do you think? Feels a bit off to: Play Road Building, Place a Road, Play Knight, ... It might lead to subtle bugs of states we are not thinking about.

Could you keep this branch of state.is_road_building to only return those options? Thanks!

Copy link
Owner

Choose a reason for hiding this comment

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

Maybe then the final structure is something like:

if state.is_road_building:
   return road_building_possibilities...
else:
  # Allow playing dev cards before and after rolling
  ...
  if not player_has_rolled(state, color):
    actions.append(ROLL)
   else:
      build houses, roads, cities...
  return actions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great catch! Didn't realize this testing thru the UI because is_road_building prevents the UI player from doing anything else

"KNIGHT_PURCHASED_THIS_TURN": 0,
"MONOPOLY_PURCHASED_THIS_TURN": 0,
"YEAR_OF_PLENTY_PURCHASED_THIS_TURN": 0,
"ROAD_BUILDING_PURCHASED_THIS_TURN": 0,
Copy link
Owner

Choose a reason for hiding this comment

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

Can you share more about the motivation of these? I believe this is what the _HAS_PLAYED_DEVELOPMENT_CARD_IN_TURN state flag is going after (to know if player can play again). Could we use the existing _HAS_PLAYED_DEVELOPMENT_CARD_IN_TURN instead?

Copy link
Contributor Author

@zarns zarns Nov 12, 2024

Choose a reason for hiding this comment

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

If a player has a knight card at the start of their turn, then purchases 2 knight cards, they should still be able to play the one knight card.
If a player has no knight card at the start of their turn, then purchases 2 knight cards, they should not be able to play them in the same turn.
This is to disallow them from purchasing/using on the same turn. The other way to handle it would be to track which dev cards they started with, but this seemed more intuitive to me at the time.

Alternatively, we could have something like KNIGHT_OWNED_AT_START_OF_TURN, and check in player_can_play_dev() for:
{ KNIGHT_OWNED_AT_START_OF_TURN && !HAS_PLAYED_DEVELOPMENT_CARD_IN_TURN }

Looking back, maybe that approach is more straightforward

menuListId="build-menu-list"
icon={<BuildIcon />}
items={buildItems}
>
Buy
</OptionsButton>
<OptionsButton
disabled={tradeItems.length === 0 || isPlayingYearOfPlenty}
disabled={tradeItems.length === 0 || isPlayingMonopoly || isPlayingYearOfPlenty || isRoadBuilding}
Copy link
Owner

Choose a reason for hiding this comment

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

NIT: I'd be awesome if we can give the isPlayingMonopoly || isPlayingYearOfPlenty || isRoadBuilding expression a name. Can you think of one? I can't 😅 . If not, that's ok, we don't have to force it, as is its good.

@zarns
Copy link
Contributor Author

zarns commented Nov 12, 2024

Superseded by #292

@zarns zarns closed this Nov 12, 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.

[React][UI] Disallow player to play development in the same turn it was bought
3 participants