KoboldSim/koboldsim/stats.go

89 lines
2.1 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]
SectorMiningIncome cardsim.Stored[float64]
SectorScavengingIncome cardsim.Stored[float64]
GovBureaucracyExpense cardsim.Stored[float64]
GovWarExpense 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) TotalSectorIncome() float64 {
return float64(k.Kobolds.Value) * (k.SectorMiningIncome.Value + k.SectorScavengingIncome.Value)
}
func (k *KoboldMine) TotalGovExpense() float64 {
return float64(k.Kobolds.Value) * (k.GovBureaucracyExpense.Value + k.GovWarExpense.Value)
}
func (k *KoboldMine) Stats() []cardsim.Stat {
stats := cardsim.ExtractStats(k)
funcs := []cardsim.Stat{
cardsim.StatFunc(
"Total Sector Mining Income",
k.ProductivityFunc(&k.SectorMiningIncome),
),
cardsim.StatFunc(
"Total Sector Scavenging Income",
k.ProductivityFunc(&k.SectorScavengingIncome),
),
cardsim.StatFunc(
"Total Government Bureaucracy Expense",
k.ProductivityFunc(&k.GovBureaucracyExpense),
),
cardsim.StatFunc(
"Total Government War Expense",
k.ProductivityFunc(&k.GovWarExpense),
),
cardsim.StatFunc(
"Total Sector Income",
k.TotalSectorIncome,
),
cardsim.StatFunc(
"Total Government Expense",
k.TotalGovExpense,
),
}
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",
Value: 0.15,
},
SectorScavengingIncome: cardsim.Stored[float64]{
Name: "Sector Scavenging Income",
Value: 0.1,
},
GovBureaucracyExpense: cardsim.Stored[float64]{
Name: "Government Bureaucracy Expense",
Value: 0.05,
},
GovWarExpense: cardsim.Stored[float64]{
Name: "Government War Expense",
Value: 0.1,
},
}
}