Wire command zone menu, harden counter command handling, and expand tests

- Connect aMoveToCommandZone to cmMoveToCommandZone; the menu item was
    added, shown, and shortcut-bound but never wired, so it did nothing
  - Extract evaluateModifyCounter() and route cmdIncCounter/cmdSetCounter
    through it, replacing isCommandZoneCounterBlocked; reject inc/set on
    an inactive tax counter so a hidden counter cannot accumulate value
  - Reject reserved tax counter names in cmdCreateCounter to prevent a
    client from spoofing a system tax counter via a user-created counter
  - Route AbstractCounter::valueChanged through the virtual setValue() so
    CommanderTaxCounter clamps and refreshes its tooltip on value changes
  - Deduplicate actPlayAndIncreaseTax/actPlayAndIncreasePartnerTax into a
    single playAndIncreaseTax(counterId) helper
  - Move MINIMUM_STACKING_HEIGHT from CommandZone to the PlayerGraphicsItem
    layout code, its only consumer
  - Remove unused AbstractCounter forward declaration from player_logic.h
  - Add EvaluateModifyCounter tests and PartnerTax cases for
    evaluateSetCounterActive
  - Pin the FirstUserId floor in new_counter_id_test using ids 3 and 5 so
    a naive "highest id + 1" regression fails the test
This commit is contained in:
DawnFire42 2026-06-28 21:43:42 -04:00
parent 0bfb0f4131
commit bc09a19b50
No known key found for this signature in database
GPG key ID: 24BB855EE2911B33
11 changed files with 172 additions and 47 deletions

View file

@ -41,13 +41,15 @@ TEST(NewCounterId, ReturnsFirstUserIdWhenNoCounters)
EXPECT_EQ(f.player.newCounterId(), CounterIds::FirstUserId);
}
// Reserved ids 0-9 (standard player counters and the commander tax counters) must
// not drag a new user counter down into the reserved range.
// Reserved ids must not drag a new user counter down into the reserved range. The
// ids here (3 and 5) are chosen so a naive "highest id + 1" implementation would
// return 6 (inside the reserved range) and fail this test; only the FirstUserId
// floor yields the correct 10, so this pins the floor against regression.
TEST(NewCounterId, SkipsReservedRangeWhenOnlyReservedCountersExist)
{
PlayerFixture f;
f.player.addCounter(new Server_Counter(3, "g", color(), 20, 0));
f.player.addCounter(new Server_Counter(CounterIds::PartnerTax, CounterNames::PartnerTax, color(), 20, 0));
f.player.addCounter(new Server_Counter(5, "h", color(), 20, 0));
EXPECT_EQ(f.player.newCounterId(), CounterIds::FirstUserId);
}