package koboldsim import ( "fmt" "git.chromaticdragon.app/kistaro/CardSimEngine/cardsim" ) // KoboldMine is the state of a kobold mine. type KoboldMine struct { BasePopulation float64 `cardsim:"stathidden"` DragonCount float64 `cardsim:"stat" cardsim_name:"Dragon Population"` Mining float64 `cardsim:"stathidden" cardsim_name:"Mining"` Scavenging float64 `cardsim:"stathidden" cardsim_name:"Scavenging"` Alchemy float64 `cardsim:"stathidden" cardsim_name:"Alchemy"` Hospitality float64 `cardsim:"stathidden" cardsim_name:"Hospitality"` Agriculture float64 `cardsim:"stathidden" cardsim_name:"Agriculture"` Manufacturing float64 `cardsim:"stathidden" cardsim_name:"Manufacturing"` PlanarConnections float64 `cardsim:"stathidden" cardsim_name:"Planar Connections"` Publishing float64 `cardsim:"stathidden" cardsim_name:"Publishing"` Forestry float64 `cardsim:"stathidden" cardsim_name:"Forestry"` Finance float64 `cardsim:"stathidden" cardsim_name:"Finance"` Gadgetry float64 `cardsim:"stathidden" cardsim_name:"Gadgetry"` Fishing float64 `cardsim:"stathidden" cardsim_name:"Fishing"` Construction float64 `cardsim:"stathidden" cardsim_name:"Construction"` Propaganda float64 `cardsim:"stathidden" cardsim_name:"Propaganda"` Bureaucracy float64 `cardsim:"stathidden" cardsim_name:"Bureaucracy"` Militarism float64 `cardsim:"stathidden" cardsim_name:"Militarism"` Welfare float64 `cardsim:"stathidden" cardsim_name:"Social Safety Net"` Logistics float64 `cardsim:"stathidden" cardsim_name:"Logistics"` DragonSubs float64 `cardsim:"stathidden" cardsim_name:"Dragon Subsidies"` ResearchSubs float64 `cardsim:"stathidden" cardsim_name:"Research"` Education float64 `cardsim:"stathidden" cardsim_name:"Education"` Healthcare float64 `cardsim:"stathidden" cardsim_name:"Healthcare"` ForeignRelExpense float64 `cardsim:"stathidden" cardsim_name:"Diplomatic Investment"` ParksExpense float64 `cardsim:"stathidden" cardsim_name:"City Beautification"` Faith float64 `cardsim:"stathidden" cardsim_name:"Faith"` FoodSupply float64 `cardsim:"stathidden"` ForeignRelations float64 `cardsim:"stathidden"` HiddenRelPenalty float64 `cardsim:"stathidden"` // Lower is better. Secrecy float64 `cardsim:"stathidden"` Rebellion float64 `cardsim:"stathidden"` Madness float64 `cardsim:"stathidden"` Cruelty float64 `cardsim:"stat"` Greed float64 `cardsim:"stathidden"` Gullibility float64 `cardsim:"stathidden"` Authoritarianism float64 `cardsim:"stat"` Taxation float64 `cardsim:"stat"` TaxEvasion float64 `cardsim:"stat"` Squalor float64 `cardsim:"stat"` // Idea for tax evasion. The corruption stat should increase tax evasion, while the squalor stat should reduce it. The link with corruption should be obvious, but for squalor: when the economy improves, more people have resources with which to attempt to protect their income. This is part of why rich people can evade taxes more effectively than poor people. It's not ALL lobbying advantage. } func (k *KoboldMine) Kobolds() int64 { return int64((k.BasePopulation * (k.Healthcare + 1)) * (k.FoodSupply / 10) * (1 + k.TrueForeignRelations()/100)) } const ( MinFoodSupply = 18 MaxFoodSupply = 37 MinForeignRelations = -11 MaxForeignRelations = 9 ) func (k *KoboldMine) DisplayedFoodSupply() float64 { return 100 * (k.FoodSupply - MinFoodSupply) / (MaxFoodSupply - MinFoodSupply) //This returns a Policy Implementation Percentage, so that the player can see how good they are at capturing food supply. When it becomes possible for Food Supply to hit 0 and end the game in famine, the minimum survivable food supply PIP should be calculated and returned to the player as a warned-against failure threshold. } //func (k *KoboldMine) StatObesity() float64 { //return (100 / (2.3 + math.Exp(-0.04*(k.DisplayedFoodSupply()-37)))) + 100/(2.3+math.Exp(-0.04*(k.StatObesogenicity()-37))) //} func (k *KoboldMine) TrueForeignRelations() float64 { openness := 100 - clamp(k.Secrecy, 0, 100) effectiveRel := clamp(k.ForeignRelations, -100, 100) - k.HiddenRelPenalty return openness / 100 * effectiveRel } func (k *KoboldMine) DisplayedForeignRelations() float64 { return 100 * (k.ForeignRelations - MinForeignRelations) / (MaxForeignRelations - MinForeignRelations) } func (k *KoboldMine) DisplayedSecrecy() float64 { return k.Secrecy } func (k *KoboldMine) StatChaos() float64 { return Mean(k.Rebellion, k.Madness, k.Cruelty) } // This is the "crimes of chaos" stat for my crime calculations. It will also be displayed to the player as just Chaos. The player can see Cruelty, but not Madness or Rebellion. I'm concerned some players may think, "Oh, chaos is a good thing, I want more of that as long as it's not cruel!" In that case, they'll have mad, rebellious colonies that commit crimes against those perceived to be cruel... func (k *KoboldMine) StatCorruption() float64 { return Mean(k.Greed, k.Gullibility, k.Authoritarianism) } // This is the "crimes of cunning" stat for my crime calculations. It will also be displayed to the player as just Corruption. The player can see Authoritarianism, but they'll have to infer the importance of Greed and Gullibility. func (k *KoboldMine) Stats() []cardsim.Stat { stats := cardsim.ExtractStats(k) funcs := []cardsim.Stat{ cardsim.StatFunc( "Foreign Relations", k.DisplayedForeignRelations, ), cardsim.StatFunc( "Secrecy", k.DisplayedSecrecy, ), cardsim.StatFunc( "Food Supply", k.DisplayedFoodSupply, ), cardsim.StatFunc( "Kobolds", k.Kobolds, ), } stats = append(stats, funcs...) // cardsim.SortStats(stats) return stats } func NewKoboldMine() *KoboldMine { return &KoboldMine{ BasePopulation: 1025, Mining: 0, Scavenging: 0, Alchemy: 0, Hospitality: 0, Agriculture: 0, Manufacturing: 0, PlanarConnections: 0, Publishing: 0, Forestry: 0, Finance: 0, Gadgetry: 0, Fishing: 0, Construction: 0, Propaganda: 0, Bureaucracy: 0, Militarism: 0, Welfare: 0, Logistics: 0, DragonSubs: 0, ResearchSubs: 0, Education: 0, Healthcare: 0, ForeignRelExpense: 0, ParksExpense: 0, Faith: 0, FoodSupply: 20, ForeignRelations: 0, HiddenRelPenalty: 0, Rebellion: 0, Madness: 0, Cruelty: 0, Greed: 0, Gullibility: 0, Authoritarianism: 0, Secrecy: 95, } } type FieldLabel string const ( Alchemy FieldLabel = "Alchemy" Authoritarianism FieldLabel = "Authoritarianism" BasePopulation FieldLabel = "BasePopulation" Bureaucracy FieldLabel = "Bureaucracy" Construction FieldLabel = "Construction" Cruelty FieldLabel = "Cruelty" Education FieldLabel = "Education" FoodSupply FieldLabel = "FoodSupply" ForeignRelations FieldLabel = "ForeignRelations" ForeignRelExpense FieldLabel = "ForeignRelExpense" Gadgetry FieldLabel = "Gadgetry" Greed FieldLabel = "Greed" Gullibility FieldLabel = "Gullibility" Healthcare FieldLabel = "Healthcare" HiddenRelPenalty FieldLabel = "HiddenRelPenalty" Hospitality FieldLabel = "Hospitality" Logistics FieldLabel = "Logistics" Madness FieldLabel = "Madness" Manufacturing FieldLabel = "Manufacturing" Militarism FieldLabel = "Militarism" Mining FieldLabel = "Mining" ParksExpense FieldLabel = "ParksExpense" Publishing FieldLabel = "Publishing" Rebellion FieldLabel = "Rebellion" Scavenging FieldLabel = "Scavenging" Secrecy FieldLabel = "Secrecy" Welfare FieldLabel = "Welfare" ) func (k *KoboldMine) Add(which FieldLabel, amount float64) error { switch which { case Alchemy: k.Alchemy += amount return nil case Authoritarianism: k.Authoritarianism += amount return nil case BasePopulation: k.BasePopulation += amount return nil case Bureaucracy: k.Bureaucracy += amount return nil case Construction: k.Construction += amount return nil case Cruelty: k.Cruelty += amount return nil case Education: k.Education += amount return nil case FoodSupply: k.FoodSupply += amount return nil case ForeignRelations: k.ForeignRelations += amount return nil case ForeignRelExpense: k.ForeignRelExpense += amount return nil case Gadgetry: k.Gadgetry += amount return nil case Greed: k.Greed += amount return nil case Gullibility: k.Gullibility += amount return nil case Healthcare: k.Healthcare += amount return nil case HiddenRelPenalty: k.HiddenRelPenalty += amount return nil case Hospitality: k.Hospitality += amount return nil case Logistics: k.Logistics += amount return nil case Madness: k.Madness += amount return nil case Manufacturing: k.Manufacturing += amount return nil case Militarism: k.Militarism += amount return nil case Mining: k.Mining += amount return nil case ParksExpense: k.ParksExpense += amount return nil case Publishing: k.Publishing += amount return nil case Rebellion: k.Rebellion += amount return nil case Scavenging: k.Scavenging += amount return nil case Secrecy: k.Secrecy += amount return nil case Welfare: k.Welfare += amount return nil } return fmt.Errorf("cannot add %f to %q: %w", amount, which, ErrNoFieldLabel) }