RunStats class final
What a run came to, counted off the events it produced.
The results screen every game wrote by hand. Three applications counted kills, coins and laps, each in its own field, each cleared in its own place and each wrong in its own way — a count that carried between levels, a count reset by a restart that should have survived, a count nothing ever showed. What they had in common was that every one of them was reading the same thing: how many of a kind of moment happened.
So this counts events. A genre hands it what a step reported and it adds up
what it recognises — which is nothing until a game says what to recognise,
because a template that knew ShotFired would be a template that knew about
weapons.
Named counters rather than fields, which is the same reading Tally takes: a game that counts something this package never heard of adds a line rather than a class.
Properties
- elapsed ↔ double
-
How long the run has been going, in simulated seconds.
getter/setter pair
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- tally → Tally
-
The counts themselves, which are also what a results screen reads.
final
Methods
-
advance(
double dt, List< GameEvent> events) → void -
Adds up
eventsand advances the clock bydt. -
clear(
) → void - Forgets the counts and the clock, for a run starting over.
-
count(
String name, bool matches(GameEvent)) → void -
Starts counting
namewhenevermatchesanswers yes. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
restore(
Map< String, Object?> from) → void -
save(
) → Map< String, Object?> -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited