[Game] Add Command Zone support with commander tax tracking

- Add CommandZone and CommandZoneLogic for commander
  - Add CommanderTaxCounter
  - Add counter active state protocol (show/hide tax counters)
  - Add "Enable Command Zone" option in game creation dialogs
  - Add context menu actions for command zone operations

Took 9 minutes

Took 11 minutes
This commit is contained in:
DawnFire42 2026-05-21 21:30:40 -04:00
parent 687e6644bc
commit 75d59e2d82
No known key found for this signature in database
GPG key ID: 24BB855EE2911B33
73 changed files with 1540 additions and 86 deletions

View file

@ -15,6 +15,7 @@ set(UTILITY_HEADERS
libcockatrice/utility/levenshtein.h
libcockatrice/utility/macros.h
libcockatrice/utility/passwordhasher.h
libcockatrice/utility/counter_ids.h
libcockatrice/utility/trice_limits.h
libcockatrice/utility/zone_names.h
)

View file

@ -0,0 +1,46 @@
/**
* @file counter_ids.h
* @ingroup GameLogic
* @brief Shared counter IDs and names for system counters (e.g. commander tax).
*/
#ifndef COCKATRICE_COUNTER_IDS_H
#define COCKATRICE_COUNTER_IDS_H
#include <QString>
/**
* Shared counter IDs used by both client and server.
* These must match between server_player.cpp and player_event_handler.cpp.
*
* Reserved counter IDs for system counters:
* IDs 0-7: Standard player counters (life, mana colors, storm)
* IDs 8-9: Commander tax counters
* IDs 10+: Available for user-created counters
*
* The server's newCounterId() starts from the highest existing ID + 1,
* so these reserved IDs won't conflict as long as they're created first
* during setupZones(). See server_player.cpp::setupZones() for the
* authoritative list of reserved IDs.
*
* To find all files referencing these IDs, grep for CounterIds::CommanderTax
* and CounterIds::PartnerTax across the codebase.
*/
namespace CounterIds
{
constexpr int CommanderTax = 8;
constexpr int PartnerTax = 9;
} // namespace CounterIds
namespace CounterNames
{
constexpr const char *CommanderTax = "commander_tax_counter";
constexpr const char *PartnerTax = "partner_tax_counter";
inline bool isTaxCounter(const QString &name)
{
return name == CommanderTax || name == PartnerTax;
}
} // namespace CounterNames
#endif // COCKATRICE_COUNTER_IDS_H

View file

@ -15,11 +15,11 @@ constexpr uint MAXIMUM_DIE_SIDES = 1000000;
constexpr uint MINIMUM_DICE_TO_ROLL = 1;
constexpr uint MAXIMUM_DICE_TO_ROLL = 100;
// Card counter value bounds [0, MAX_COUNTERS_ON_CARD].
// Counters on cards (e.g., +1/+1 counters, charge counters) are non-negative physical game objects.
// Counter value bounds [0, MAX_COUNTER_VALUE].
// Counters (on cards or players) are non-negative values.
// The max of 999 is a display constraint (3-digit rendering) and reasonable gameplay limit.
// Server enforces these bounds; client may also check for UX optimization.
constexpr int MAX_COUNTERS_ON_CARD = 999;
constexpr int MAX_COUNTER_VALUE = 999;
// optimized functions to get qstrings that are at most that long
static inline QString nameFromStdString(const std::string &_string)

View file

@ -14,6 +14,9 @@ constexpr const char *DECK = "deck";
constexpr const char *SIDEBOARD = "sb";
constexpr const char *STACK = "stack";
// Command zone (Commander format)
constexpr const char *COMMAND = "command";
} // namespace ZoneNames
#endif // ZONE_NAMES_H