fix compilation errors and warnings
This commit is contained in:
parent
ba5171fd67
commit
d2a00d2044
2
go.mod
2
go.mod
@ -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
|
||||||
)
|
)
|
||||||
|
@ -9,7 +9,7 @@ import (
|
|||||||
var (
|
var (
|
||||||
ErrOptionNotEnabled = errors.New("option not enabled")
|
ErrOptionNotEnabled = errors.New("option not enabled")
|
||||||
ErrPolicyNotEnacted = errors.New("cannot unenact policy that is not enacted")
|
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
|
// ErrUnimplemented and ErrKeepMessaage are "non-errors". They are used
|
||||||
// as special signals that the result needs to be handled in a special way;
|
// 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.
|
// 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,15 +262,15 @@ 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
|
||||||
|
|
||||||
CurrentlyEnacted bool
|
CurrentlyEnacted 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
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package koboldsim
|
package koboldsim
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"git.chromaticdragon.app/kistaro/CardSimEngine/cardsim"
|
"git.chromaticdragon.app/kistaro/CardSimEngine/cardsim"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -168,19 +170,19 @@ func NewKoboldMine() *KoboldMine {
|
|||||||
type FieldLabel string
|
type FieldLabel string
|
||||||
|
|
||||||
const (
|
const (
|
||||||
BasePopulation FieldLabel = "BasePopulation"
|
BasePopulation FieldLabel = "BasePopulation"
|
||||||
Scavenging FieldLabel = "Scavenging"
|
Scavenging FieldLabel = "Scavenging"
|
||||||
Militarism FieldLabel = "Militarism"
|
Militarism FieldLabel = "Militarism"
|
||||||
FoodSupply FieldLabel = "FoodSupply"
|
FoodSupply FieldLabel = "FoodSupply"
|
||||||
ForeignRelations FieldLabel = "ForeignRelations"
|
ForeignRelations FieldLabel = "ForeignRelations"
|
||||||
Rebellion FieldLabel = "Rebellion"
|
Rebellion FieldLabel = "Rebellion"
|
||||||
Madness FieldLabel = "Madness"
|
Madness FieldLabel = "Madness"
|
||||||
Cruelty FieldLabel = "Cruelty"
|
Cruelty FieldLabel = "Cruelty"
|
||||||
Authoritarianism FieldLabel = "Authoritarianism"
|
Authoritarianism FieldLabel = "Authoritarianism"
|
||||||
)
|
)
|
||||||
|
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user