KoboldSim/koboldsim/stats.go

89 lines
2.1 KiB
Go
Raw Normal View History

2023-04-03 06:24:47 +00:00
package koboldsim
import (
"git.chromaticdragon.app/kistaro/CardSimEngine/cardsim"
)
// KoboldMine is the state of a kobold mine.
type KoboldMine struct {
Kobolds cardsim.Stored[int64]
SectorMiningIncome cardsim.Stored[float64]
SectorScavengingIncome cardsim.Stored[float64]
2023-04-03 06:24:47 +00:00
GovBureaucracyExpense cardsim.Stored[float64]
GovWarExpense cardsim.Stored[float64]
2023-04-03 06:24:47 +00:00
}
func (k *KoboldMine) ProductivityFunc(s *cardsim.Stored[float64]) func() float64 {
return func() float64 {
return s.Value * float64(k.Kobolds.Value)
}
}
func (k *KoboldMine) TotalSectorProductivity() float64 {
return float64(k.Kobolds.Value) * (k.SectorMiningIncome.Value + k.SectorScavengingIncome.Value)
2023-04-03 06:24:47 +00:00
}
func (k *KoboldMine) TotalGovProductivity() float64 {
return float64(k.Kobolds.Value) * (k.GovBureaucracyExpense.Value + k.GovWarExpense.Value)
2023-04-03 06:24:47 +00:00
}
func (k *KoboldMine) Stats() []cardsim.Stat {
stats := cardsim.ExtractStats(k)
funcs := []cardsim.Stat{
cardsim.StatFunc(
"Total Sector Mining Income",
k.ProductivityFunc(&k.SectorMiningIncome),
2023-04-03 06:24:47 +00:00
),
cardsim.StatFunc(
"Total Sector Scavenging Income",
k.ProductivityFunc(&k.SectorScavengingIncome),
2023-04-03 06:24:47 +00:00
),
cardsim.StatFunc(
"Total Government Bureaucracy Expense",
k.ProductivityFunc(&k.GovBureaucracyExpense),
2023-04-03 06:24:47 +00:00
),
cardsim.StatFunc(
"Total Government War Expense",
k.ProductivityFunc(&k.GovWarExpense),
2023-04-03 06:24:47 +00:00
),
cardsim.StatFunc(
"Total Sector Income",
2023-04-03 06:24:47 +00:00
k.TotalSectorProductivity,
),
cardsim.StatFunc(
"Total Government Expense",
2023-04-03 06:24:47 +00:00
k.TotalGovProductivity,
),
}
stats = append(stats, funcs...)
cardsim.SortStats(stats)
return stats
}
func NewKoboldMine() *KoboldMine {
return &KoboldMine{
Kobolds: cardsim.Stored[int64]{
Name: "Kobolds",
Value: 1000,
},
SectorMiningIncome: cardsim.Stored[float64]{
Name: "Sector Mining Income",
2023-04-03 06:24:47 +00:00
Value: 0.15,
},
SectorScavengingIncome: cardsim.Stored[float64]{
Name: "Sector Scavening Income",
2023-04-03 06:24:47 +00:00
Value: 0.1,
},
GovBureaucracyExpense: cardsim.Stored[float64]{
Name: "Government Bureaucracy Expense",
2023-04-03 06:24:47 +00:00
Value: 0.05,
},
GovWarExpense: cardsim.Stored[float64]{
Name: "Government War Expense",
2023-04-03 06:24:47 +00:00
Value: 0.1,
},
}
}