1 /*****************************************************************************
2  * PokerTH - The open source texas holdem engine                             *
3  * Copyright (C) 2006-2012 Felix Hammer, Florian Thauer, Lothar May          *
4  *                                                                           *
5  * This program is free software: you can redistribute it and/or modify      *
6  * it under the terms of the GNU Affero General Public License as            *
7  * published by the Free Software Foundation, either version 3 of the        *
8  * License, or (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 Affero General Public License for more details.                       *
14  *                                                                           *
15  * You should have received a copy of the GNU Affero General Public License  *
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.     *
17  *                                                                           *
18  *                                                                           *
19  * Additional permission under GNU AGPL version 3 section 7                  *
20  *                                                                           *
21  * If you modify this program, or any covered work, by linking or            *
22  * combining it with the OpenSSL project's OpenSSL library (or a             *
23  * modified version of that library), containing parts covered by the        *
24  * terms of the OpenSSL or SSLeay licenses, the authors of PokerTH           *
25  * (Felix Hammer, Florian Thauer, Lothar May) grant you additional           *
26  * permission to convey the resulting work.                                  *
27  * Corresponding Source for a non-source form of such a combination          *
28  * shall include the source code for the parts of OpenSSL used as well       *
29  * as that of the covered work.                                              *
30  *****************************************************************************/
31 /* Game data. */
32 
33 #ifndef _GAMEDATA_H_
34 #define _GAMEDATA_H_
35 
36 #include <list>
37 #include <string>
38 #ifndef Q_MOC_RUN
39 #include <third_party/boost/timers.hpp>
40 #endif
41 
42 typedef std::list<unsigned> PlayerIdList;
43 
44 enum GameMode {
45 	GAME_MODE_CREATED = 1,
46 	GAME_MODE_STARTED,
47 	GAME_MODE_CLOSED
48 };
49 
50 enum GameType {
51 	GAME_TYPE_NORMAL = 1,
52 	GAME_TYPE_REGISTERED_ONLY,
53 	GAME_TYPE_INVITE_ONLY,
54 	GAME_TYPE_RANKING
55 };
56 
57 enum RaiseIntervalMode {
58 	RAISE_ON_HANDNUMBER = 1,
59 	RAISE_ON_MINUTES
60 };
61 
62 enum RaiseMode {
63 	DOUBLE_BLINDS = 1,
64 	MANUAL_BLINDS_ORDER
65 };
66 
67 enum AfterManualBlindsMode {
68 	AFTERMB_DOUBLE_BLINDS = 1,
69 	AFTERMB_RAISE_ABOUT,
70 	AFTERMB_STAY_AT_LAST_BLIND
71 };
72 
73 // For the sake of simplicity, this is a struct.
74 struct GameData {
GameDataGameData75 	GameData() : gameType(GAME_TYPE_NORMAL), allowSpectators(true),
76 		maxNumberOfPlayers(0), startMoney(0), firstSmallBlind(0),
77 		raiseIntervalMode(RAISE_ON_HANDNUMBER), raiseSmallBlindEveryHandsValue(8),
78 		raiseSmallBlindEveryMinutesValue(1), raiseMode(DOUBLE_BLINDS),
79 		afterManualBlindsMode(AFTERMB_DOUBLE_BLINDS), afterMBAlwaysRaiseValue(0),
80 		guiSpeed(4), delayBetweenHandsSec(6), playerActionTimeoutSec(20) {}
81 	GameType gameType;
82 	bool allowSpectators;
83 	int maxNumberOfPlayers;
84 	int startMoney;
85 	int firstSmallBlind;
86 	RaiseIntervalMode raiseIntervalMode;
87 	int raiseSmallBlindEveryHandsValue;
88 	int raiseSmallBlindEveryMinutesValue;
89 	RaiseMode raiseMode;
90 	std::list<int> manualBlindsList;
91 	AfterManualBlindsMode afterManualBlindsMode;
92 	int afterMBAlwaysRaiseValue;
93 	int guiSpeed;
94 	int delayBetweenHandsSec;
95 	int playerActionTimeoutSec;
96 };
97 
98 struct GameInfo {
GameInfoGameInfo99 	GameInfo() : mode(GAME_MODE_CREATED), adminPlayerId(0), isPasswordProtected(false) {}
100 	std::string name;
101 	GameData data;
102 	GameMode mode;
103 	unsigned adminPlayerId;
104 	PlayerIdList players;
105 	PlayerIdList spectators;
106 	PlayerIdList spectatorsDuringGame;
107 	bool isPasswordProtected;
108 };
109 
110 struct StartData {
StartDataStartData111 	StartData() : startDealerPlayerId(0), numberOfPlayers(0) {}
112 	unsigned startDealerPlayerId;
113 	int numberOfPlayers;
114 };
115 
116 struct VoteKickData {
VoteKickDataVoteKickData117 	VoteKickData()
118 		: petitionId(0), kickPlayerId(0), numVotesToKick(0),
119 		  numVotesInFavourOfKicking(0), numVotesAgainstKicking(0), timeLimitSec(0),
120 		  voteTimer(boost::posix_time::time_duration(0, 0, 0), boost::timers::portable::microsec_timer::auto_start) {}
121 	unsigned petitionId;
122 	unsigned kickPlayerId;
123 	int numVotesToKick;
124 	int numVotesInFavourOfKicking;
125 	int numVotesAgainstKicking;
126 	int timeLimitSec;
127 	boost::timers::portable::microsec_timer voteTimer;
128 	PlayerIdList votedPlayerIds;
129 };
130 
131 #endif
132 
133