add method

bool add(
  1. String what, [
  2. int howMany = 1
])
inherited

Adds howMany of what and answers whether anything was added.

The boolean is not decoration: a collectible that cannot be taken must stay where it is, the same rule a medkit at full health depends on. Nothing is refused here, and the answer is still reported rather than assumed, so the day a cap arrives the callers already do the right thing.

Implementation

bool add(String what, [int howMany = 1]) {
  if (howMany <= 0) return false;
  _counts[what] = this[what] + howMany;
  return true;
}