Monopoly — Portage moderne 0.1.0
Portage moderne C/C++23 du Monopoly de 1999
Loading...
Searching...
No Matches
RuleTypes.hpp
Go to the documentation of this file.
1#include "CardTypes.hpp"
2#pragma once
3
4#include <array>
5#include <cstddef>
6#include <cstdint>
7#include <string>
8#include <memory>
9
10namespace monopoly::rules
11{
12 using PlayerNumber = std::uint8_t;
13
14 inline constexpr PlayerNumber MaxPlayers = 6;
16 inline constexpr PlayerNumber NobodyPlayer = MaxPlayers + 1;
18
19 inline constexpr PlayerNumber EscrowPlayer =
20 static_cast<PlayerNumber>(MaxPlayers + 2);
21
22 inline constexpr PlayerNumber SpectatorPlayer =
23 static_cast<PlayerNumber>(MaxPlayers + 3);
24 inline constexpr std::size_t SquareCount = 42;
25
26 inline constexpr std::size_t MaxPlayerNameLength = 39;
27
28 // Rule.h :
29 // TK_GUN ... TK_MONEYBAG, MAX_TOKENS
30 inline constexpr std::size_t MaxTokens = 11;
31
32 // PC_RED ... PC_ORANGE, MAX_PLAYER_COLOURS
33 inline constexpr std::size_t MaxPlayerColours = 6;
34
35 enum class TradeItemKind : std::uint8_t
36 {
37 Cash = 0,
38 Square,
42 };
43
44
45 enum class CountHitType : std::uint8_t
46 {
47 Nothing = 0,
50 };
51
52
53 inline constexpr std::size_t MaxCountHitSets =
54 MaxPlayers * 10;
55
56
58 {
59 std::uint32_t properties = 0;
60
63
66
69
70 bool tradedItem = false;
71
72 std::int32_t hitCount = 0;
73
74 bool operator==(const CountHitRecord&) const = default;
75 };
76
110
111 // RULE_MAX_PENDING_PHASES :
112 // (6 * 6) + (2 * 6) + 6 = 54
113 inline constexpr std::size_t MaxPendingPhases =
115 (2 * MaxPlayers) +
116 6;
117
127
129 {
130 int recordingHz = 11025;
132 std::wstring compressorName = L"GSM 6.10";
133
134 bool operator==(const VoiceChatOptions&) const = default;
135 };
136
138 {
142
143 int interestRate = 10;
144 int initialCash = 1500;
146
148 int taxRate = 10;
149 int flatTaxFee = 200;
150
151 bool hideCash = false;
152 bool evenBuildRule = true;
154
155 bool cheatingAllowed = false;
157
160
162
165
169
172
174 bool freeParkingPot = false;
175
176 bool doubleSalaryOnGo = false;
178
181
183
185
186 bool operator==(const GameOptions&) const = default;
187 };
188
190 {
192
195
196 std::uint8_t houses = 0;
197
198 bool mortgaged = false;
199
200 std::int64_t gameEarnings = 0;
201
202 bool operator==(const SquareState&) const = default;
203 };
204
206 {
207 std::wstring name;
208
209 std::uint8_t token = 0;
210 std::uint8_t colour = 0;
211 std::uint8_t aiPlayerLevel = 0;
212
213 std::int64_t cash = 0;
214
215 std::uint32_t timeOfLastActivity = 0;
216
217 // RULE_SquareType.
218 // 0 = SQ_GO, 40 = SQ_IN_JAIL, 41 = SQ_OFF_BOARD.
219 std::uint8_t currentSquare = 0;
220
221 bool firstMoveMade = false;
222
223 std::uint8_t turnsInJail = 0;
224 std::uint8_t inactivityCount = 0;
225
226 // phaseDependentUnion.starting
228
229 // phaseDependentUnion.ordering
230 std::uint32_t diceRollHistory = 0;
231
232 // shared.trading du RULE_PlayerInfoRecord original.
233 std::array<std::int64_t, MaxPlayers>
235
236 bool tradeAccepted = false;
237
238 bool operator==(const PlayerState&) const = default;
239 };
240
242 {
243 std::uint8_t tickCount = 0;
244 std::uint8_t goingCount = 0;
245
247
248 std::int64_t highestBid = 0;
249
250 // Square 0..39 pour une propriété.
251 // 40 == SQ_AUCTION_HOUSE.
252 // 41 == SQ_AUCTION_HOTEL.
253 std::uint8_t propertyBeingAuctioned = 0;
254
255 bool operator==(const AuctionState&) const = default;
256 };
257
259 {
261
262 std::array<PlayerState, MaxPlayers> players{};
263 std::array<SquareState, SquareCount> squares{};
264
265 std::array<
266 CardDeck,
267 static_cast<std::size_t>(DeckType::Count)
268 > cards{};
269
270 // RULE_GameStateStruct :
271 // Dice / NextDice / UtilityDice.
272 std::array<std::uint8_t, 2> dice{};
273 std::array<std::uint8_t, 2> nextDice{};
274 std::array<std::uint8_t, 2> utilityDice{};
275
276 std::uint8_t numberOfDoublesRolled = 0;
277
279
281
282 std::uint64_t gameDurationInSeconds = 0;
283
284 std::int64_t freeParkingJackpotAmount = 0;
285
286 // TRUE depuis ACTION_START_TRADE_EDITING jusqu'à la
287 // résolution complète des dettes et escrow.
288 bool tradeInProgress = false;
289
290 std::array<CountHitRecord, MaxCountHitSets>
292
294
297
300
301 std::array<PendingPhase, MaxPendingPhases> phaseStack{};
302 std::uint8_t numberOfPendingPhases = 0;
303
304 // Transient phase undo records: deliberately omitted from RuleArchive.
305 // Saved records contain value state only, never further undo records.
306 std::array<std::shared_ptr<const GameState>, MaxPendingPhases> phaseUndo{};
307 };
308}
309
310
311
312
313
314
315
316
317
318
unsigned index
constexpr std::size_t MaxPlayerColours
Definition RuleTypes.hpp:33
constexpr PlayerNumber BankPlayer
Definition RuleTypes.hpp:15
std::uint8_t PlayerNumber
Definition RuleTypes.hpp:12
constexpr PlayerNumber SpectatorPlayer
Definition RuleTypes.hpp:22
constexpr std::size_t MaxPlayerNameLength
Definition RuleTypes.hpp:26
constexpr std::size_t MaxCountHitSets
Definition RuleTypes.hpp:53
constexpr std::size_t MaxTokens
Definition RuleTypes.hpp:30
constexpr PlayerNumber EscrowPlayer
Definition RuleTypes.hpp:19
constexpr std::size_t SquareCount
Definition RuleTypes.hpp:24
constexpr std::size_t MaxPendingPhases
constexpr PlayerNumber MaxPlayers
Definition RuleTypes.hpp:14
constexpr PlayerNumber NobodyPlayer
Definition RuleTypes.hpp:16
constexpr PlayerNumber AllPlayers
Definition RuleTypes.hpp:17
bool operator==(const AuctionState &) const =default
bool operator==(const CountHitRecord &) const =default
bool operator==(const GameOptions &) const =default
std::array< std::shared_ptr< const GameState >, MaxPendingPhases > phaseUndo
std::array< std::uint8_t, 2 > dice
std::array< CardDeck, static_cast< std::size_t >(DeckType::Count) > cards
std::uint8_t numberOfDoublesRolled
std::array< CountHitRecord, MaxCountHitSets > countHits
PlayerNumber configurationProposer
std::int64_t freeParkingJackpotAmount
std::array< SquareState, SquareCount > squares
std::array< std::uint8_t, 2 > utilityDice
std::uint64_t gameDurationInSeconds
std::array< PendingPhase, MaxPendingPhases > phaseStack
std::array< std::uint8_t, 2 > nextDice
std::uint8_t numberOfPendingPhases
std::array< PlayerState, MaxPlayers > players
bool operator==(const PendingPhase &) const =default
bool operator==(const PlayerState &) const =default
std::array< std::int64_t, MaxPlayers > cashGivenInTrade
bool operator==(const SquareState &) const =default
bool operator==(const VoiceChatOptions &) const =default