endplay.interact.interactivedeal
Main class of the interact module, which derives from Deal
but keeps track
of changes to its state.
Classes:
|
A Deal which keeps track of changes made to it allowing actions to be undone. |
- class endplay.interact.interactivedeal.InteractiveDeal(pbn: Optional[str] = None, first: Player = Player.north, trump: Denom = Denom.nt)
Bases:
Deal
A Deal which keeps track of changes made to it allowing actions to be undone. This is the basis of the various frontends to the interact package.
Methods:
_undo_first
(player)_undo_play
(arg)_undo_set
(player, pbn)_undo_trump
(denom)_undo_unplay
(player, card, toHand)Clear undo history so that reset will bring the deal back to this state
play
(card[, fromHand])Play a card to the current trick.
reset
()Undo all actions in the undo history
undo
()Undo the previous action, if it changed the current deal
unplay
([toHand])Unplay the last card played to the current trick.
Attributes:
The player to lead the first card to the current trick
The trump suit the deal is being played in
- _undo_first(player)
- _undo_play(arg)
- _undo_set(player, pbn)
- _undo_trump(denom)
- _undo_unplay(player, card, toHand)
- checkpoint()
Clear undo history so that reset will bring the deal back to this state
- play(card, fromHand: bool = True) None
Play a card to the current trick. If the played card completes the trick then the entire trick is cleared and first is set to the played who won the trick using trump as the trumps suit
- Parameters:
card – The cad to be played
fromHand – If true then the card will be removed from the hand of the player who is to play to the trick next and throw a RuntimeError if they do not hold this card.
- reset()
Undo all actions in the undo history
- undo()
Undo the previous action, if it changed the current deal