Tally class base

Things counted by name, and kept.

Extracted on the second consumer, which is the rule and took a while. This was the platformer's Purse — coins and stars — and an audit left it there on the grounds that the shooter's Inventory is a different idea entirely, which it is: health, armour, ammunition by type and a set of weapons. What arrived second was not an inventory but a tally: how many monsters a level had and how many are dead, how many secrets and how many found. Same machinery, different word.

Deliberately thin. It counts, it says what it holds, and it survives a save; anything about what the names mean belongs to whoever chose them.

Constructors

Tally()
An empty tally.

Properties

counts → UnmodifiableMapView<String, int>
Everything held, for a readout that wants to list it.
no setter
hashCode → int
The hash code for this object.
no setterinherited
isEmpty → bool
Whether nothing has been added since the last clear.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

add(String what, {int howMany = 1}) → bool
Adds howMany of what and answers whether anything was added.
clear() → void
Forgets every count.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
restore(Map<String, Object?> from) → void
Replaces the counts with those from holds; an entry that is not a number is skipped.
save() → Map<String, Object?>
Every count by name, for a save.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited
operator [](String what) → int
How many of what are held; nought for a name never added.