DisabledPolicy: a policy that doesn't

This commit is contained in:
Kistaro Windrider 2023-04-03 20:12:06 -07:00
parent 5af762474c
commit 140d7b6cbb
Signed by: kistaro
SSH Key Fingerprint: SHA256:TBE2ynfmJqsAf0CP6gsflA0q5X5wD5fVKWPsZ7eVUg8

View File

@ -398,6 +398,34 @@ func (f *FuncPolicy) Is(p Policy) bool {
return ok && (f == fp) return ok && (f == fp)
} }
// A DisabledPolicy is never enabled.
type DisabledPolicy struct {
Msg cardsim.Message
}
func (d *DisabledPolicy) OptionText(p *Player) (cardsim.Message, error) {
return d.Msg, nil
}
func (d *DisabledPolicy) Enact(*Player) (cardsim.Message, error) {
return nil, ErrOptionNotEnabled
}
func (d *DisabledPolicy) Enabled(*Player) bool {
return false
}
func (d *DisabledPolicy) Unenact(*Player) error {
return ErrPolicyNotEnacted
}
func (d *DisabledPolicy) LastEnacted(int, Policy) {}
func (d *DisabledPolicy) Is(p Policy) bool {
dp, ok := p.(*DisabledPolicy)
return ok && (dp == d)
}
// ShuffleIntoBottomHalf is a common "what to do with the card after?" behavior. // ShuffleIntoBottomHalf is a common "what to do with the card after?" behavior.
func ShuffleIntoBottomHalf(c Card, p *Player, _ CardOption) error { func ShuffleIntoBottomHalf(c Card, p *Player, _ CardOption) error {
p.Deck.InsertRandomBottom(0.5, c) p.Deck.InsertRandomBottom(0.5, c)