From 140d7b6cbb1734d582a53f4ff9e8bd20a40c6ad5 Mon Sep 17 00:00:00 2001 From: Kistaro Windrider Date: Mon, 3 Apr 2023 20:12:06 -0700 Subject: [PATCH] DisabledPolicy: a policy that doesn't --- koboldsim/cardtypes.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/koboldsim/cardtypes.go b/koboldsim/cardtypes.go index 5d4c3c3..e8485b9 100644 --- a/koboldsim/cardtypes.go +++ b/koboldsim/cardtypes.go @@ -398,6 +398,34 @@ func (f *FuncPolicy) Is(p Policy) bool { 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. func ShuffleIntoBottomHalf(c Card, p *Player, _ CardOption) error { p.Deck.InsertRandomBottom(0.5, c)