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

Add the possibility to keep the cards of some players #203

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ sphinx-rtd-theme = "^1.2.0"
black = "^23.7.0"
coverage = "^7.1.0"

[tool.poetry.group.dev.dependencies]
pytest = "^7.4.0"

[tool.pylint.master]
disable = ["import-error", "missing-module-docstring", "unknown-option-value"]

Expand Down
6 changes: 4 additions & 2 deletions texasholdem/game/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -1284,10 +1284,11 @@ def _import_history(history: History) -> Iterator[TexasHoldEm]:
game.take_action(action, total=total)
yield game

def copy(self, shuffle: bool = True):
def copy(self, shuffle: bool = True, cards_players_to_keep: List = None):
"""
Arguments:
shuffle (bool): Shuffle the deck, defaults to true.
cards_players_to_keep (List): List of player ids to keep cards for.
Returns:
TexasHoldEm: A copy of the game.

Expand Down Expand Up @@ -1349,7 +1350,8 @@ def copy(self, shuffle: bool = True):
game.start_hand()

for i, cards in self.hands.items():
game.hands[i] = cards.copy()
if cards_players_to_keep and i in cards_players_to_keep:
game.hands[i] = cards.copy()
Comment on lines +1353 to +1354
Copy link
Owner

Choose a reason for hiding this comment

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

I think I would prefer to have the default be that all the player cards are the same. Here, it's that all the cards are different.

Copy link
Owner

Choose a reason for hiding this comment

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

@LucasColas Did your latest change do anything for this?


# swap decks
game._deck = deck
Expand Down