Prototype for TablePolicy

This commit is contained in:
2024-09-29 10:19:19 -07:00
parent e018bd0ad6
commit ba5171fd67
3 changed files with 164 additions and 1 deletions

View File

@@ -164,3 +164,50 @@ func NewKoboldMine() *KoboldMine {
Secrecy: 95,
}
}
type FieldLabel string
const (
BasePopulation FieldLabel = "BasePopulation"
Scavenging FieldLabel = "Scavenging"
Militarism FieldLabel = "Militarism"
FoodSupply FieldLabel = "FoodSupply"
ForeignRelations FieldLabel = "ForeignRelations"
Rebellion FieldLabel = "Rebellion"
Madness FieldLabel = "Madness"
Cruelty FieldLabel = "Cruelty"
Authoritarianism FieldLabel = "Authoritarianism"
)
func (k *KoboldMine) Add(which FieldLabel, amount float64) error {
switch(which) {
case BasePopulation:
k.BasePopulation += amount
return nil
case Scavenging:
k.Scavenging += amount
return nil
case Militarism:
k.Militarism += amount
return nil
case FoodSupply:
k.FoodSupply += amount
return nil
case ForeignRelations:
k.ForeignRelations += amount
return nil
case Rebellion:
k.Rebellion += amount
return nil
case Madness:
k.Madness += amount
return nil
case Cruelty:
k.Cruelty += amount
return nil
case Authoritarianism:
k.Authoritarianism += amount
return nil
}
return fmt.Errorf("cannot add %d to %q: %w", amount, which, ErrNoFieldLabel)
}