Kistaro Windrider
3e34e25f54
StatLiteral: just emit a stat in the obvious way. Plus helper functions. Can also identify stats via struct tags, no more Stored type! Can also identify stat methods via name (with compatible types).
34 lines
853 B
Go
34 lines
853 B
Go
package main
|
|
|
|
import (
|
|
"git.chromaticdragon.app/kistaro/CardSimEngine/cardsim"
|
|
)
|
|
|
|
// SmokeTestCollection is a stats collection for the simple test sim.
|
|
type SmokeTestCollection struct {
|
|
Number cardsim.Stored[int]
|
|
Total cardsim.Stored[int64]
|
|
Turns cardsim.Invisible[int]
|
|
|
|
Flavor cardsim.Stored[string]
|
|
|
|
Things int `cardsim:"stat"`
|
|
MoreThings int `cardsim:"hidden"`
|
|
FloatyThings float64 `cardsim:"round1"`
|
|
}
|
|
|
|
func (c *SmokeTestCollection) Average() float64 {
|
|
return float64(c.Total.Value) / float64(c.Turns.Value)
|
|
}
|
|
|
|
func (c *SmokeTestCollection) Stats() []cardsim.Stat {
|
|
stats := cardsim.ExtractStats(c)
|
|
stats = append(stats, cardsim.StatFunc("Average", c.Average))
|
|
cardsim.SortStats(stats)
|
|
return stats
|
|
}
|
|
|
|
func (c *SmokeTestCollection) StatTotalThings() float64 {
|
|
return float64(c.Things+c.MoreThings) + c.FloatyThings
|
|
}
|