Fix nil deref and identity failure.
Also updates deps to pick up a message display fix.
This commit is contained in:
@ -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) {
|
||||
|
Reference in New Issue
Block a user