diff --git a/koboldsim/cardtypes.go b/koboldsim/cardtypes.go index d2b04d0..c35f7b0 100644 --- a/koboldsim/cardtypes.go +++ b/koboldsim/cardtypes.go @@ -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() }