Represents a player counter with overflow-safe increment arithmetic.
More...
#include <server_counter.h>
Represents a player counter with overflow-safe increment arithmetic.
All value modifications return whether the value actually changed, enabling callers to skip unnecessary network events.
- Note
- Direct assignment via setCount() does not clamp; only incrementCount() enforces int boundary saturation.
-
Unlike card counters, player counters are never auto-removed when they reach zero - they persist with value 0.
◆ Server_Counter()
| Server_Counter::Server_Counter |
( |
int | _id, |
|
|
const QString & | _name, |
|
|
const color & | _counterColor, |
|
|
int | _radius, |
|
|
int | _count = 0 ) |
◆ ~Server_Counter()
| Server_Counter::~Server_Counter |
( |
| ) |
|
|
inline |
◆ getColor()
| const color & Server_Counter::getColor |
( |
| ) |
const |
|
inline |
◆ getCount()
| int Server_Counter::getCount |
( |
| ) |
const |
|
inline |
◆ getId()
| int Server_Counter::getId |
( |
| ) |
const |
|
inline |
◆ getInfo()
Populates info with this counter's current state for network serialization.
- Parameters
-
| info | The protobuf message to populate. |
◆ getName()
| QString Server_Counter::getName |
( |
| ) |
const |
|
inline |
◆ getRadius()
| int Server_Counter::getRadius |
( |
| ) |
const |
|
inline |
◆ incrementCount()
| bool Server_Counter::incrementCount |
( |
int | delta | ) |
|
|
inlinenodiscard |
Increments the counter by delta with overflow-safe arithmetic.
- Parameters
-
| delta | The amount to add (may be negative for decrement). |
- Returns
- true if the value changed, false otherwise.
- Note
- Clamps result to [INT_MIN, INT_MAX] to prevent overflow.
◆ setCount()
| bool Server_Counter::setCount |
( |
int | _count | ) |
|
|
inlinenodiscard |
Sets the counter to an exact value.
- Parameters
-
| _count | The new value (assigned directly without clamping). |
- Returns
- true if the value changed, false otherwise.
- Warning
- This performs raw assignment. For overflow-safe incrementing, use incrementCount().
◆ count
| int Server_Counter::count |
|
protected |
◆ counterColor
| color Server_Counter::counterColor |
|
protected |
◆ id
◆ name
| QString Server_Counter::name |
|
protected |
◆ radius
| int Server_Counter::radius |
|
protected |
The documentation for this class was generated from the following files: