diff --git a/go.mod b/go.mod index 778a1c5..e192de5 100644 --- a/go.mod +++ b/go.mod @@ -2,4 +2,4 @@ module git.chromaticdragon.app/kistaro/KoboldSim go 1.20 -require git.chromaticdragon.app/kistaro/CardSimEngine v0.1.1 +require git.chromaticdragon.app/kistaro/CardSimEngine v0.1.3 diff --git a/go.sum b/go.sum index 124f905..0eada35 100644 --- a/go.sum +++ b/go.sum @@ -1,2 +1,4 @@ -git.chromaticdragon.app/kistaro/CardSimEngine v0.1.1 h1:nPp8ymzfnwzrzfzjkuvDAb4X73BUgUNBGKHhDp6Iz3c= -git.chromaticdragon.app/kistaro/CardSimEngine v0.1.1/go.mod h1:VFaOagdbtM6gH87ioHent8v76nDh9PddpymMqWdrLfI= +git.chromaticdragon.app/kistaro/CardSimEngine v0.1.2 h1:+8KVFhSxXbQO7CPzmL89sJ+qjgU4J42Z5OinGuDMR0U= +git.chromaticdragon.app/kistaro/CardSimEngine v0.1.2/go.mod h1:VFaOagdbtM6gH87ioHent8v76nDh9PddpymMqWdrLfI= +git.chromaticdragon.app/kistaro/CardSimEngine v0.1.3 h1:rNaDDXnPVoMpavpx4vR9k30sl0nO0BnCe32nZbAF2IM= +git.chromaticdragon.app/kistaro/CardSimEngine v0.1.3/go.mod h1:VFaOagdbtM6gH87ioHent8v76nDh9PddpymMqWdrLfI= diff --git a/koboldsim/cardtypes.go b/koboldsim/cardtypes.go index f4e7f4f..41aeb96 100644 --- a/koboldsim/cardtypes.go +++ b/koboldsim/cardtypes.go @@ -115,18 +115,10 @@ func YesWeCan(*Player) bool { return true } -// lastEnacted notifies b about the last-enacted policy in its group. It updates -// b.currentlyEnacted accordingly and returns itself. -// -// It also installs placeholders if CanDo or CanUndo is unspecified. +// LastEnacted notifies b about the last-enacted policy in its group. It updates +// b.currentlyEnacted accordingly. func (b *BasicPolicy) LastEnacted(_ int, p Policy) { - b.currentlyEnacted = false - if o, ok := p.(*BasicPolicy); ok && o == b { - b.currentlyEnacted = true - } - if b.CanDo == nil { - b.CanDo = YesWeCan - } + b.currentlyEnacted = b.Is(p) } // OptionText implements CardOption. @@ -146,7 +138,7 @@ func (b *BasicPolicy) Enact(p *Player) (cardsim.Message, error) { } return b.NothingChanged, nil } - if !b.CanDo(p) { + if b.CanDo != nil && !b.CanDo(p) { return nil, ErrOptionNotEnabled } return b.Do(p) @@ -197,7 +189,7 @@ type VerbosePolicy struct { func (v *VerbosePolicy) LastEnacted(i int, p Policy) { v.lastIdx = i - v.BasicPolicy.LastEnacted(i, p) + v.BasicPolicy.currentlyEnacted = v.Is(p) } func (v *VerbosePolicy) OptionText(*Player) (cardsim.Message, error) {