fix compilation errors and warnings

This commit is contained in:
Kistaro Windrider 2024-09-29 10:27:15 -07:00
parent ba5171fd67
commit d2a00d2044
Signed by: kistaro
SSH Key Fingerprint: SHA256:TBE2ynfmJqsAf0CP6gsflA0q5X5wD5fVKWPsZ7eVUg8
3 changed files with 23 additions and 17 deletions

2
go.mod
View File

@ -8,5 +8,5 @@ require (
github.com/kr/pretty v0.3.1 // indirect github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect github.com/kr/text v0.2.0 // indirect
github.com/rogpeppe/go-internal v1.9.0 // indirect github.com/rogpeppe/go-internal v1.9.0 // indirect
golang.org/x/exp v0.0.0-20230321023759-10a507213a29 // indirect golang.org/x/exp v0.0.0-20230321023759-10a507213a29
) )

View File

@ -191,7 +191,7 @@ type BasicPolicy struct {
} }
// YesWeCan returns true. It's the default value for BasicPolicy.CanDo / BasicPolicy.CanUndo. // 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 return true
} }
@ -262,14 +262,14 @@ func (b *BasicPolicy) Is(p Policy) bool {
} }
// TablePolicy is a Policy where all numerical changes are defined by // 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 // and subtracting it back out when de-enacting. If the currently
// enacted option is re-enacted, it refunds the player's action point. // enacted option is re-enacted, it refunds the player's action point.
type TablePolicy struct { type TablePolicy struct {
Desc cardsim.Message Desc cardsim.Message
UnenactedDesc cardsim.Message UnenactedDesc cardsim.Message
EnactedDesc cardsim.Message EnactedDesc cardsim.Message
NothingChanged cardsim.message NothingChanged cardsim.Message
EffectsTable map[FieldLabel]float64 EffectsTable map[FieldLabel]float64
CanDo func(*TablePolicy, *Player) bool CanDo func(*TablePolicy, *Player) bool
@ -278,6 +278,10 @@ type TablePolicy struct {
LastEnactedIdx int LastEnactedIdx int
} }
func YesWeAlsoCan(*TablePolicy, *Player) bool {
return true
}
// LastEnacted notifies t about the last-enacted policy in its group. It updates // LastEnacted notifies t about the last-enacted policy in its group. It updates
// t.currentlyEnacted accordingly. // t.currentlyEnacted accordingly.
func (t *TablePolicy) LastEnacted(i int, p Policy) { func (t *TablePolicy) LastEnacted(i int, p Policy) {
@ -326,7 +330,7 @@ func (t *TablePolicy) Unenact(p *Player) error {
} }
var errs cardsim.ErrorCollector var errs cardsim.ErrorCollector
for label, amount := range t.EffectsTable { for label, amount := range t.EffectsTable {
errs.Add(p.Stats.Add(label, -amount) errs.Add(p.Stats.Add(label, -amount))
} }
return errs.Emit() return errs.Emit()
} }
@ -344,7 +348,7 @@ func (t *TablePolicy) Enabled(p *Player) bool {
func (t *TablePolicy) Is(p Policy) bool { func (t *TablePolicy) Is(p Policy) bool {
if o, ok := p.(*TablePolicy); ok { if o, ok := p.(*TablePolicy); ok {
return o == b return o == t
} }
return false return false
} }

View File

@ -1,6 +1,8 @@
package koboldsim package koboldsim
import ( import (
"fmt"
"git.chromaticdragon.app/kistaro/CardSimEngine/cardsim" "git.chromaticdragon.app/kistaro/CardSimEngine/cardsim"
) )
@ -180,7 +182,7 @@ const (
) )
func (k *KoboldMine) Add(which FieldLabel, amount float64) error { func (k *KoboldMine) Add(which FieldLabel, amount float64) error {
switch(which) { switch which {
case BasePopulation: case BasePopulation:
k.BasePopulation += amount k.BasePopulation += amount
return nil return nil
@ -209,5 +211,5 @@ func (k *KoboldMine) Add(which FieldLabel, amount float64) error {
k.Authoritarianism += amount k.Authoritarianism += amount
return nil return nil
} }
return fmt.Errorf("cannot add %d to %q: %w", amount, which, ErrNoFieldLabel) return fmt.Errorf("cannot add %f to %q: %w", amount, which, ErrNoFieldLabel)
} }