fix compilation errors and warnings
This commit is contained in:
@ -9,7 +9,7 @@ import (
|
||||
var (
|
||||
ErrOptionNotEnabled = errors.New("option not enabled")
|
||||
ErrPolicyNotEnacted = errors.New("cannot unenact policy that is not enacted")
|
||||
ErrNoFieldLabel = errors.New("field does not exist")
|
||||
ErrNoFieldLabel = errors.New("field does not exist")
|
||||
|
||||
// ErrUnimplemented and ErrKeepMessaage are "non-errors". They are used
|
||||
// as special signals that the result needs to be handled in a special way;
|
||||
@ -191,7 +191,7 @@ type BasicPolicy struct {
|
||||
}
|
||||
|
||||
// YesWeCan returns true. It's the default value for BasicPolicy.CanDo / BasicPolicy.CanUndo.
|
||||
func YesWeCan[T any](T, *Player) bool {
|
||||
func YesWeCan(*BasicPolicy, *Player) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
@ -262,15 +262,15 @@ func (b *BasicPolicy) Is(p Policy) bool {
|
||||
}
|
||||
|
||||
// TablePolicy is a Policy where all numerical changes are defined by
|
||||
// adding a constant to some set of fields (defined by `EffectsTable``)
|
||||
// adding a constant to some set of fields (defined by `EffectsTable“)
|
||||
// and subtracting it back out when de-enacting. If the currently
|
||||
// enacted option is re-enacted, it refunds the player's action point.
|
||||
type TablePolicy struct {
|
||||
Desc cardsim.Message
|
||||
UnenactedDesc cardsim.Message
|
||||
EnactedDesc cardsim.Message
|
||||
NothingChanged cardsim.message
|
||||
EffectsTable map[FieldLabel]float64
|
||||
NothingChanged cardsim.Message
|
||||
EffectsTable map[FieldLabel]float64
|
||||
CanDo func(*TablePolicy, *Player) bool
|
||||
|
||||
CurrentlyEnacted bool
|
||||
@ -278,6 +278,10 @@ type TablePolicy struct {
|
||||
LastEnactedIdx int
|
||||
}
|
||||
|
||||
func YesWeAlsoCan(*TablePolicy, *Player) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
// LastEnacted notifies t about the last-enacted policy in its group. It updates
|
||||
// t.currentlyEnacted accordingly.
|
||||
func (t *TablePolicy) LastEnacted(i int, p Policy) {
|
||||
@ -326,7 +330,7 @@ func (t *TablePolicy) Unenact(p *Player) error {
|
||||
}
|
||||
var errs cardsim.ErrorCollector
|
||||
for label, amount := range t.EffectsTable {
|
||||
errs.Add(p.Stats.Add(label, -amount)
|
||||
errs.Add(p.Stats.Add(label, -amount))
|
||||
}
|
||||
return errs.Emit()
|
||||
}
|
||||
@ -344,7 +348,7 @@ func (t *TablePolicy) Enabled(p *Player) bool {
|
||||
|
||||
func (t *TablePolicy) Is(p Policy) bool {
|
||||
if o, ok := p.(*TablePolicy); ok {
|
||||
return o == b
|
||||
return o == t
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
Reference in New Issue
Block a user