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,8 +96,9 @@ func (s *SwitchingCard) Options(player *Player) ([]CardOption, error) {
|
|||||||
|
|
||||||
// Then implements Card.
|
// Then implements Card.
|
||||||
func (s *SwitchingCard) Then(p *Player, o CardOption) error {
|
func (s *SwitchingCard) Then(p *Player, o CardOption) error {
|
||||||
newPolicy := o.(Policy)
|
|
||||||
var errs cardsim.ErrorCollector
|
var errs cardsim.ErrorCollector
|
||||||
|
if o != nil {
|
||||||
|
newPolicy := o.(Policy)
|
||||||
if s.lastPolicy != nil && !newPolicy.Is(s.lastPolicy) {
|
if s.lastPolicy != nil && !newPolicy.Is(s.lastPolicy) {
|
||||||
err := s.lastPolicy.Unenact(p)
|
err := s.lastPolicy.Unenact(p)
|
||||||
if cardsim.IsSeriousError(err) {
|
if cardsim.IsSeriousError(err) {
|
||||||
@ -106,8 +107,13 @@ func (s *SwitchingCard) Then(p *Player, o CardOption) error {
|
|||||||
errs.Add(err)
|
errs.Add(err)
|
||||||
}
|
}
|
||||||
s.lastPolicy = o.(Policy)
|
s.lastPolicy = o.(Policy)
|
||||||
|
}
|
||||||
if s.After != nil {
|
if s.After != nil {
|
||||||
errs.Add(s.After(s, p, o))
|
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()
|
return errs.Emit()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user