mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-06-10 16:24:45 -07:00
Centralize counter API with server-side bounds and no-op filtering (#6879)
* Refactor server counter API to own overflow protection and filter no-op events Counter modifications now clamp to int bounds server-side and return change status, allowing command handlers to skip network broadcasts when values don't actually change. * Centralize MAX_COUNTERS_ON_CARD and enforce [0, 999] bounds on server - Move MAX_COUNTERS_ON_CARD to trice_limits.h - Server clamps values in setCounter() and incrementCounter() - Client uses clamped comparison to allow recovery from invalid states - Add tests for clamping behavior * move incrementCount() implementation from header to cpp
This commit is contained in:
parent
74102aa1ec
commit
8dca14933c
12 changed files with 432 additions and 32 deletions
|
|
@ -15,6 +15,12 @@ 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.
|
||||
// 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;
|
||||
|
||||
// optimized functions to get qstrings that are at most that long
|
||||
static inline QString nameFromStdString(const std::string &_string)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue