Major stats upgrade.

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).
This commit is contained in:
2023-04-04 11:12:07 -07:00
parent 1464070339
commit 3e34e25f54
4 changed files with 224 additions and 8 deletions

View File

@ -11,6 +11,10 @@ type SmokeTestCollection struct {
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 {
@ -23,3 +27,7 @@ func (c *SmokeTestCollection) Stats() []cardsim.Stat {
cardsim.SortStats(stats)
return stats
}
func (c *SmokeTestCollection) StatTotalThings() float64 {
return float64(c.Things+c.MoreThings) + c.FloatyThings
}