KoboldSim/koboldsim/stats.go

89 lines
2.3 KiB
Go

package koboldsim
import (
"git.chromaticdragon.app/kistaro/CardSimEngine/cardsim"
)
// KoboldMine is the state of a kobold mine.
type KoboldMine struct {
Kobolds cardsim.Stored[int64]
SectorMiningProductivity cardsim.Stored[float64]
SectorScavengingProductivity cardsim.Stored[float64]
GovBureaucracyProductivity cardsim.Stored[float64]
GovWarProductivity cardsim.Stored[float64]
}
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.SectorMiningProductivity.Value + k.SectorScavengingProductivity.Value)
}
func (k *KoboldMine) TotalGovProductivity() float64 {
return float64(k.Kobolds.Value) * (k.GovBureaucracyProductivity.Value + k.GovWarProductivity.Value)
}
func (k *KoboldMine) Stats() []cardsim.Stat {
stats := cardsim.ExtractStats(k)
funcs := []cardsim.Stat{
cardsim.StatFunc(
"Total Sector Mining Productivity",
k.ProductivityFunc(&k.SectorMiningProductivity),
),
cardsim.StatFunc(
"Total Sector Scavenging Productivity",
k.ProductivityFunc(&k.SectorScavengingProductivity),
),
cardsim.StatFunc(
"Total Government Bureaucracy Productivity",
k.ProductivityFunc(&k.GovBureaucracyProductivity),
),
cardsim.StatFunc(
"Total Government War Productivity",
k.ProductivityFunc(&k.GovBureaucracyProductivity),
),
cardsim.StatFunc(
"Total Sector Productivity",
k.TotalSectorProductivity,
),
cardsim.StatFunc(
"Total Government Productivity",
k.TotalGovProductivity,
),
}
stats = append(stats, funcs...)
cardsim.SortStats(stats)
return stats
}
func NewKoboldMine() *KoboldMine {
return &KoboldMine{
Kobolds: cardsim.Stored[int64]{
Name: "Kobolds",
Value: 1000,
},
SectorMiningProductivity: cardsim.Stored[float64]{
Name: "Sector Mining Productivity",
Value: 0.15,
},
SectorScavengingProductivity: cardsim.Stored[float64]{
Name: "Sector Scavening Productivity",
Value: 0.1,
},
GovBureaucracyProductivity: cardsim.Stored[float64]{
Name: "Government Bureaucracy Productivity",
Value: 0.05,
},
GovWarProductivity: cardsim.Stored[float64]{
Name: "Government War Productivity",
Value: 0.1,
},
}
}