Monopoly — Portage moderne 0.1.0
Portage moderne C/C++23 du Monopoly de 1999
Loading...
Searching...
No Matches
PlayerSetupFlow.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "DataBanks.hpp"
4#include "RuleOptions.hpp"
5#include "RuleTypes.hpp"
6
7#include <array>
8#include <cstddef>
9#include <cstdint>
10#include <span>
11#include <string>
12#include <string_view>
13
15{
16 // UDPSEL_SetupPhase exact de UDPsel.h.
17 enum class Phase : std::uint8_t
18 {
19 None = 0,
20 HiScore,
31 Max
32 };
33
34
97
98
99 struct Rect
100 {
101 int left = 0;
102 int top = 0;
103 int right = 0;
104 int bottom = 0;
105
106
107 [[nodiscard]]
109 int x,
110 int y
111 ) const noexcept
112 {
113 return
114 x >= left &&
115 x < right &&
116 y >= top &&
117 y < bottom;
118 }
119 };
120
121
137
138
139 struct Command
140 {
143
144
145 std::wstring name{};
146
147
148 std::uint8_t token = 0;
149
150 std::uint8_t colour = 0;
151
152 std::uint8_t aiLevel = 0;
153
154 int city = 0;
155 int system = 13; // NOTW_MONA_US
156
159
160 std::uint8_t ruleChoice = 0;
161
162
165 };
166
167
168 inline constexpr std::size_t PlayerHistoryMaximumEntries = 100;
169 inline constexpr std::size_t PlayerHistoryPageSize = 8;
170
171
172 struct State
173 {
176
177
180
181
182 std::wstring name =
183 L"_";
184
185
186 std::uint8_t token = 0;
187
188 std::uint8_t aiLevel = 0;
189
191
194 std::array<int, 3> currencySelection{{13, 13, 12}};
196
197
199 false;
200
201
203 false;
204
205
207 true;
208
209
211 false;
212
213 std::array<std::wstring, PlayerHistoryMaximumEntries>
215
216 std::size_t playerLogCount = 0;
217 std::size_t playerLogPageStart = 0;
218
219
220 std::array<
221 std::wstring,
224 };
225
226
227 inline constexpr std::size_t
229
230 inline constexpr int MonetarySystemEuro = 12;
231 inline constexpr int MonetarySystemUs = 13;
232
233
234 // Exact ordre RULE_TokenKindEnum.
235 inline constexpr std::uint8_t TokenGun = 0;
236 inline constexpr std::uint8_t TokenCar = 1;
237 inline constexpr std::uint8_t TokenDog = 2;
238 inline constexpr std::uint8_t TokenHat = 3;
239 inline constexpr std::uint8_t TokenIron = 4;
240 inline constexpr std::uint8_t TokenHorse = 5;
241 inline constexpr std::uint8_t TokenShip = 6;
242 inline constexpr std::uint8_t TokenShoe = 7;
243 inline constexpr std::uint8_t TokenThimble = 8;
244 inline constexpr std::uint8_t TokenBarrow = 9;
245 inline constexpr std::uint8_t TokenMoneyBag = 10;
246
247
248 void initialize(
249 State& state,
250 bool serverMode
251 );
252
253
254 void setTokenName(
255 State& state,
256 std::uint8_t token,
257 std::wstring_view name
258 );
259
260
262 State& state,
263 bool available
264 );
265
266
268 State& state,
270 std::span<const std::wstring> entries
271 );
272
273
274 void setEnteredName(
275 State& state,
276 std::wstring_view name
277 );
278
279
281 State& state,
283 Phase phase
284 );
285
286
287 [[nodiscard]]
290 std::uint8_t token
291 );
292
293
294 [[nodiscard]]
295 std::uint8_t nextAvailableToken(
297 std::uint8_t currentToken
298 );
299
300
301 [[nodiscard]]
302 std::uint8_t tokenFromName(
303 const State& state,
305 std::wstring_view name
306 );
307
308
309 [[nodiscard]]
312 std::uint8_t currentColour
313 );
314
315
316 [[nodiscard]]
318 Phase phase,
319 int x,
320 int y,
322 );
323
324
325 [[nodiscard]]
327 State& state,
330 );
331
332
333 [[nodiscard]]
335 State& state,
337 int x,
338 int y
339 );
340
341
342 [[nodiscard]]
344 State& state,
347 std::uint8_t choice
348 );
349
350
351 [[nodiscard]]
353 State& state,
355 );
356}
const char * name
unsigned state
unsigned index
int token
Button button
std::uint8_t PlayerNumber
Definition RuleTypes.hpp:12
constexpr std::size_t MaxTokens
Definition RuleTypes.hpp:30
constexpr PlayerNumber NobodyPlayer
Definition RuleTypes.hpp:16
constexpr std::uint8_t TokenCar
constexpr std::uint8_t TokenThimble
void setPlayerLogEntries(State &state, const rules::GameState &uiState, std::span< const std::wstring > entries)
constexpr std::uint8_t TokenHat
Command playerBarClicked(State &state, rules::PlayerNumber player)
std::uint8_t tokenFromName(const State &state, const GameState &uiState, std::wstring_view name)
constexpr std::uint8_t TokenShoe
void setPlayerLogAvailable(State &state, bool available)
Command clickButton(State &state, const GameState &uiState, Button button)
Command clickAt(State &state, const GameState &uiState, int x, int y)
std::uint8_t nextAvailableColour(const GameState &uiState, std::uint8_t currentColour)
constexpr std::uint8_t TokenIron
bool tokenAvailable(const GameState &uiState, std::uint8_t token)
constexpr std::uint8_t TokenGun
constexpr std::size_t PlayerHistoryPageSize
std::uint8_t nextAvailableToken(const GameState &uiState, std::uint8_t currentToken)
void setEnteredName(State &state, std::wstring_view name)
constexpr std::uint8_t TokenBarrow
void initialize(State &state, bool serverMode)
Command customRuleChoice(State &state, const GameState &, rules::options::SetupRule rule, std::uint8_t choice)
void requestPhase(State &state, const GameState &uiState, Phase requested)
constexpr std::uint8_t TokenHorse
constexpr std::size_t MaximumEnteredNameLength
constexpr std::uint8_t TokenShip
constexpr std::uint8_t TokenDog
void setTokenName(State &state, std::uint8_t token, std::wstring_view name)
constexpr std::uint8_t TokenMoneyBag
Button buttonAt(Phase phase, int x, int y, data::BoardEdition edition)
constexpr std::size_t PlayerHistoryMaximumEntries
rules::options::SetupRule setupRule
bool contains(int x, int y) const noexcept
std::array< std::wstring, rules::MaxTokens > tokenNames
std::array< std::wstring, PlayerHistoryMaximumEntries > playerLog