Abaci
Statistics with Context

Introduction

Max stat is a way to track the maximum value of a stat. This is obvious for things like highscores, and also useful for recording your best streaks to name a few uses. Set Tutorial and Space Shooter example has a section on MaxStat if you want to see it in action.

Component

Streak can be added as a component (or game object) and requires a bundle, what stat to take the max of, and what the max stat will be called.

max_stat_component.png

Code

MaxStats can also be added (and removed) in code through the Abaci.Streak class.

MaxStat maxStat = new MaxStat();
maxStat.Register(bundle, "score", "highscore");
bundle.Set("score", 21);
Assert.AreEqual(bundle.Get("highscore"), 21);
bundle.Increment("score", 7);
Assert.AreEqual(bundle.Get("highscore"), 28);
bundle.Set("score", 3);
Assert.AreEqual(bundle.Get("highscore"), 28);

Context

As with most things in Abaci MaxStats also have context. So if you get a "highscore" with "tuesday" context active, it'll also be recorded under "highscore&tuesday" like regular stats.

MaxStat maxStat = new MaxStat();
maxStat.Register(bundle, "score", "highscore");
bundle.Set("score", 100);
bundle.AddContext("tuesday");
bundle.Set("score", 39);
Assert.AreEqual(bundle.Get("highscore"), 100);
Assert.AreEqual(bundle.Get("highscore&tuesday"), 39);


API

The full API for the bundle is available Abaci.MaxStat