Cockatrice 2026-06-01-Development-3.1.0-beta.3
A virtual tabletop for multiplayer card games
Loading...
Searching...
No Matches
server_counter.h
Go to the documentation of this file.
1/***************************************************************************
2 * Copyright (C) 2008 by Max-Wilhelm Bruker *
3 * brukie@laptop *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 * You should have received a copy of the GNU General Public License *
16 * along with this program; if not, write to the *
17 * Free Software Foundation, Inc., *
18 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
20#ifndef SERVER_COUNTER_H
21#define SERVER_COUNTER_H
22
23#include <QString>
24#include <libcockatrice/protocol/pb/color.pb.h>
25
26class ServerInfo_Counter;
27
41{
42protected:
43 int id;
44 QString name;
46 int radius;
47 int count;
48
49public:
50 Server_Counter(int _id, const QString &_name, const color &_counterColor, int _radius, int _count = 0);
52 {
53 }
54 int getId() const
55 {
56 return id;
57 }
58 QString getName() const
59 {
60 return name;
61 }
62 const color &getColor() const
63 {
64 return counterColor;
65 }
66 int getRadius() const
67 {
68 return radius;
69 }
70 int getCount() const
71 {
72 return count;
73 }
74
82 [[nodiscard]] bool setCount(int _count)
83 {
84 const int oldCount = count;
85 count = _count;
86 return count != oldCount;
87 }
88
95 [[nodiscard]] bool incrementCount(int delta);
96
101 void getInfo(ServerInfo_Counter *info);
102};
103
104#endif
~Server_Counter()
Definition server_counter.h:51
int id
Definition server_counter.h:43
bool incrementCount(int delta)
Increments the counter by delta with overflow-safe arithmetic.
Definition server_counter.cpp:13
int radius
Definition server_counter.h:46
int getRadius() const
Definition server_counter.h:66
color counterColor
Definition server_counter.h:45
QString getName() const
Definition server_counter.h:58
Server_Counter(int _id, const QString &_name, const color &_counterColor, int _radius, int _count=0)
Definition server_counter.cpp:6
void getInfo(ServerInfo_Counter *info)
Populates info with this counter's current state for network serialization.
Definition server_counter.cpp:22
bool setCount(int _count)
Sets the counter to an exact value.
Definition server_counter.h:82
int getCount() const
Definition server_counter.h:70
const color & getColor() const
Definition server_counter.h:62
int count
Definition server_counter.h:47
int getId() const
Definition server_counter.h:54
QString name
Definition server_counter.h:44