2023-04-03 06:24:47 +00:00
package koboldsim
import (
"git.chromaticdragon.app/kistaro/CardSimEngine/cardsim"
)
2024-09-27 23:04:17 +00:00
// KoboldMine is the state of a kobold mine.
2023-04-03 06:24:47 +00:00
type KoboldMine struct {
2023-04-05 03:23:32 +00:00
BasePopulation float64 ` cardsim:"stathidden" `
2024-09-29 16:29:50 +00:00
DragonCount float64 ` cardsim:"stat" cardsim_name:"Dragon Population" `
2023-04-03 06:24:47 +00:00
2024-09-28 04:56:13 +00:00
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" `
2024-09-29 16:29:50 +00:00
Greed float64 ` cardsim:"stathidden" `
2024-09-28 04:56:13 +00:00
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.
2023-05-23 18:30:09 +00:00
2023-04-03 06:24:47 +00:00
}
2023-04-05 03:23:32 +00:00
func ( k * KoboldMine ) Kobolds ( ) int64 {
2024-09-29 16:29:50 +00:00
return int64 ( ( k . BasePopulation * ( k . Healthcare + 1 ) ) * ( k . FoodSupply / 10 ) * ( 1 + k . TrueForeignRelations ( ) / 100 ) )
2023-04-05 03:23:32 +00:00
}
2024-09-28 04:56:13 +00:00
const (
2024-09-29 16:29:50 +00:00
MinFoodSupply = 18
MaxFoodSupply = 37
MinForeignRelations = - 11
MaxForeignRelations = 9
2024-09-28 04:56:13 +00:00
)
2023-04-05 03:23:32 +00:00
2024-09-28 04:56:13 +00:00
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.
2023-04-19 18:37:40 +00:00
}
2024-09-28 04:56:13 +00:00
//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)))
//}
2023-04-06 03:26:57 +00:00
func ( k * KoboldMine ) TrueForeignRelations ( ) float64 {
2024-09-28 04:56:13 +00:00
openness := 100 - clamp ( k . Secrecy , 0 , 100 )
effectiveRel := clamp ( k . ForeignRelations , - 100 , 100 ) - k . HiddenRelPenalty
return openness / 100 * effectiveRel
2023-04-06 03:26:57 +00:00
}
func ( k * KoboldMine ) DisplayedForeignRelations ( ) float64 {
2024-09-28 04:56:13 +00:00
return 100 * ( k . ForeignRelations - MinForeignRelations ) / ( MaxForeignRelations - MinForeignRelations )
2023-04-06 03:26:57 +00:00
}
func ( k * KoboldMine ) DisplayedSecrecy ( ) float64 {
2024-09-29 16:29:50 +00:00
return k . Secrecy
2023-04-05 19:29:23 +00:00
}
2023-05-14 03:05:07 +00:00
func ( k * KoboldMine ) StatChaos ( ) float64 {
2023-05-14 03:15:57 +00:00
return Mean ( k . Rebellion , k . Madness , k . Cruelty )
2023-05-14 03:05:07 +00:00
}
2023-05-23 18:30:09 +00:00
// 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 )
}
2024-09-29 16:29:50 +00:00
// 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.
2023-05-23 18:30:09 +00:00
2023-04-03 06:24:47 +00:00
func ( k * KoboldMine ) Stats ( ) [ ] cardsim . Stat {
stats := cardsim . ExtractStats ( k )
funcs := [ ] cardsim . Stat {
2023-04-06 03:26:57 +00:00
cardsim . StatFunc (
"Foreign Relations" ,
k . DisplayedForeignRelations ,
) ,
cardsim . StatFunc (
"Secrecy" ,
k . DisplayedSecrecy ,
) ,
2023-04-05 03:23:32 +00:00
cardsim . StatFunc (
"Food Supply" ,
k . DisplayedFoodSupply ,
) ,
cardsim . StatFunc (
"Kobolds" ,
k . Kobolds ,
) ,
2023-04-03 06:24:47 +00:00
}
stats = append ( stats , funcs ... )
2023-04-04 17:33:14 +00:00
// cardsim.SortStats(stats)
2023-04-03 06:24:47 +00:00
return stats
}
func NewKoboldMine ( ) * KoboldMine {
return & KoboldMine {
2024-09-28 04:56:13 +00:00
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 ,
2023-04-03 06:24:47 +00:00
}
}
2024-09-29 17:19:19 +00:00
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 )
}