Cockatrice 2026-06-01-Development-3.1.0-beta.3
A virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
trice_limits.h
Go to the documentation of this file.
1#ifndef TRICE_LIMITS_H
2#define TRICE_LIMITS_H
3
4#include <QString>
5
6// max size for short strings, like names and things that are generally a single phrase
7constexpr int MAX_NAME_LENGTH = 0xff;
8// max size for chat messages and text contents
9constexpr int MAX_TEXT_LENGTH = 0xfff;
10// max size for deck files and pictures
11constexpr int MAX_FILE_LENGTH = 0x1fffff; // about 2 megabytes
12
13constexpr uint MINIMUM_DIE_SIDES = 2;
14constexpr uint MAXIMUM_DIE_SIDES = 1000000;
15constexpr uint MINIMUM_DICE_TO_ROLL = 1;
16constexpr uint MAXIMUM_DICE_TO_ROLL = 100;
17
18// Card counter value bounds [0, MAX_COUNTERS_ON_CARD].
19// Counters on cards (e.g., +1/+1 counters, charge counters) are non-negative physical game objects.
20// The max of 999 is a display constraint (3-digit rendering) and reasonable gameplay limit.
21// Server enforces these bounds; client may also check for UX optimization.
22constexpr int MAX_COUNTERS_ON_CARD = 999;
23
24// optimized functions to get qstrings that are at most that long
25static inline QString nameFromStdString(const std::string &_string)
26{
27 return QString::fromUtf8(_string.data(), std::min(int(_string.size()), MAX_NAME_LENGTH));
28}
29static inline QString textFromStdString(const std::string &_string)
30{
31 return QString::fromUtf8(_string.data(), std::min(int(_string.size()), MAX_TEXT_LENGTH));
32}
33static inline QString fileFromStdString(const std::string &_string)
34{
35 return QString::fromUtf8(_string.data(), std::min(int(_string.size()), MAX_FILE_LENGTH));
36}
37
38#endif // TRICE_LIMITS_H
constexpr uint MINIMUM_DIE_SIDES
Definition trice_limits.h:13
constexpr int MAX_COUNTERS_ON_CARD
Definition trice_limits.h:22
constexpr uint MAXIMUM_DICE_TO_ROLL
Definition trice_limits.h:16
constexpr int MAX_NAME_LENGTH
Definition trice_limits.h:7
constexpr uint MAXIMUM_DIE_SIDES
Definition trice_limits.h:14
constexpr uint MINIMUM_DICE_TO_ROLL
Definition trice_limits.h:15
static QString textFromStdString(const std::string &_string)
Definition trice_limits.h:29
static QString nameFromStdString(const std::string &_string)
Definition trice_limits.h:25
constexpr int MAX_TEXT_LENGTH
Definition trice_limits.h:9
constexpr int MAX_FILE_LENGTH
Definition trice_limits.h:11
static QString fileFromStdString(const std::string &_string)
Definition trice_limits.h:33