Fix nil deref and identity failure.
Also updates deps to pick up a message display fix.
This commit is contained in:
parent
c798ba31e1
commit
4e983bd0f0
2
go.mod
2
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
|
||||
|
6
go.sum
6
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=
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user