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
|
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.2 h1:+8KVFhSxXbQO7CPzmL89sJ+qjgU4J42Z5OinGuDMR0U=
|
||||||
git.chromaticdragon.app/kistaro/CardSimEngine v0.1.1/go.mod h1:VFaOagdbtM6gH87ioHent8v76nDh9PddpymMqWdrLfI=
|
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
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
// lastEnacted notifies b about the last-enacted policy in its group. It updates
|
// LastEnacted notifies b about the last-enacted policy in its group. It updates
|
||||||
// b.currentlyEnacted accordingly and returns itself.
|
// b.currentlyEnacted accordingly.
|
||||||
//
|
|
||||||
// It also installs placeholders if CanDo or CanUndo is unspecified.
|
|
||||||
func (b *BasicPolicy) LastEnacted(_ int, p Policy) {
|
func (b *BasicPolicy) LastEnacted(_ int, p Policy) {
|
||||||
b.currentlyEnacted = false
|
b.currentlyEnacted = b.Is(p)
|
||||||
if o, ok := p.(*BasicPolicy); ok && o == b {
|
|
||||||
b.currentlyEnacted = true
|
|
||||||
}
|
|
||||||
if b.CanDo == nil {
|
|
||||||
b.CanDo = YesWeCan
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// OptionText implements CardOption.
|
// OptionText implements CardOption.
|
||||||
@ -146,7 +138,7 @@ func (b *BasicPolicy) Enact(p *Player) (cardsim.Message, error) {
|
|||||||
}
|
}
|
||||||
return b.NothingChanged, nil
|
return b.NothingChanged, nil
|
||||||
}
|
}
|
||||||
if !b.CanDo(p) {
|
if b.CanDo != nil && !b.CanDo(p) {
|
||||||
return nil, ErrOptionNotEnabled
|
return nil, ErrOptionNotEnabled
|
||||||
}
|
}
|
||||||
return b.Do(p)
|
return b.Do(p)
|
||||||
@ -197,7 +189,7 @@ type VerbosePolicy struct {
|
|||||||
|
|
||||||
func (v *VerbosePolicy) LastEnacted(i int, p Policy) {
|
func (v *VerbosePolicy) LastEnacted(i int, p Policy) {
|
||||||
v.lastIdx = i
|
v.lastIdx = i
|
||||||
v.BasicPolicy.LastEnacted(i, p)
|
v.BasicPolicy.currentlyEnacted = v.Is(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *VerbosePolicy) OptionText(*Player) (cardsim.Message, error) {
|
func (v *VerbosePolicy) OptionText(*Player) (cardsim.Message, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user