Shuffle cards back by default.
If no After function is provided for a SwitchingCard, it uses ShuffleIntoBottomHalf. This also modifies Then to be callable with a nil `o`, which it recognizes as "nothing happened but we need cleanup anyway", in preparation for the incoming "make cards sometimes not drawable" feature.
This commit is contained in:
parent
95a30cb522
commit
d434e50897
@ -96,18 +96,24 @@ func (s *SwitchingCard) Options(player *Player) ([]CardOption, error) {
|
||||
|
||||
// Then implements Card.
|
||||
func (s *SwitchingCard) Then(p *Player, o CardOption) error {
|
||||
newPolicy := o.(Policy)
|
||||
var errs cardsim.ErrorCollector
|
||||
if s.lastPolicy != nil && !newPolicy.Is(s.lastPolicy) {
|
||||
err := s.lastPolicy.Unenact(p)
|
||||
if cardsim.IsSeriousError(err) {
|
||||
return err
|
||||
if o != nil {
|
||||
newPolicy := o.(Policy)
|
||||
if s.lastPolicy != nil && !newPolicy.Is(s.lastPolicy) {
|
||||
err := s.lastPolicy.Unenact(p)
|
||||
if cardsim.IsSeriousError(err) {
|
||||
return err
|
||||
}
|
||||
errs.Add(err)
|
||||
}
|
||||
errs.Add(err)
|
||||
s.lastPolicy = o.(Policy)
|
||||
}
|
||||
s.lastPolicy = o.(Policy)
|
||||
if s.After != nil {
|
||||
errs.Add(s.After(s, p, o))
|
||||
} else {
|
||||
// Fallback: Shuffle the card back into the bottom half of the deck.
|
||||
errs.Add(ShuffleIntoBottomHalf(s, p, o))
|
||||
|
||||
}
|
||||
return errs.Emit()
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user