Monopoly — Portage moderne
0.1.0
Portage moderne C/C++23 du Monopoly de 1999
Loading...
Searching...
No Matches
RuleRejections.hpp
Go to the documentation of this file.
1
#pragma once
2
3
#include "
LegacyTextIds.hpp
"
4
#include "
Messaging.hpp
"
5
#include "
PhaseStack.hpp
"
6
7
#include <cstdint>
8
9
namespace
monopoly::rules::rejections
10
{
11
// Source Rule.cpp ErrorWrongPhase/ErrorWrongPlayer: rejected action,
12
// targeted explanation, then one phase refresh for a non-bank sender.
13
inline
void
send
(
const
GameState
&
state
,
const
actions::Message
& message,
14
std::int64_t
error
)
15
{
16
messaging::sendAction
(
actions::Type::NotifyActionCompleted
,
17
BankPlayer
,
AllPlayers
,
static_cast<
std::int64_t
>
(message.
action
),
18
0, message.
fromPlayer
, 0);
19
if
(message.
fromPlayer
==
BankPlayer
)
return
;
20
21
const
PlayerNumber
destination
= message.
fromPlayer
<
MaxPlayers
22
? message.
fromPlayer
:
AllPlayers
;
23
const
auto
phase =
state
.
numberOfPendingPhases
> 0
24
?
static_cast<
std::int64_t
>
(
phases::current
(
state
).
phase
) : 0;
25
messaging::sendAction
(
actions::Type::NotifyErrorMessage
,
26
BankPlayer
,
destination
,
error
,
27
static_cast<
std::int64_t
>
(message.
action
), message.
fromPlayer
, phase);
28
messaging::sendAction
(
actions::Type::RestartPhase
,
BankPlayer
,
BankPlayer
);
29
}
30
31
inline
void
wrongPhase
(
const
GameState
&
state
,
const
actions::Message
& message)
32
{
send
(
state
, message,
legacy_text::ErrorWrongPhase
); }
33
34
inline
void
wrongPlayer
(
const
GameState
&
state
,
const
actions::Message
& message)
35
{
send
(
state
, message,
legacy_text::ErrorWrongPlayer
); }
36
}
LegacyTextIds.hpp
Messaging.hpp
index
unsigned index
Definition
ModernIBarSkin.cpp:25
PhaseStack.hpp
error
std::string error
Definition
StartupResources.cpp:25
monopoly::actions::Type::RestartPhase
@ RestartPhase
monopoly::actions::Type::NotifyErrorMessage
@ NotifyErrorMessage
monopoly::actions::Type::NotifyActionCompleted
@ NotifyActionCompleted
monopoly::legacy_text::ErrorWrongPlayer
constexpr std::int64_t ErrorWrongPlayer
Definition
LegacyTextIds.hpp:16
monopoly::legacy_text::ErrorWrongPhase
constexpr std::int64_t ErrorWrongPhase
Definition
LegacyTextIds.hpp:15
monopoly::messaging::sendAction
bool sendAction(const actions::Message &message)
Definition
Messaging.cpp:234
monopoly::rules::phases::current
const PendingPhase & current(const GameState &state)
Definition
PhaseStack.cpp:168
monopoly::rules::rejections
Definition
RuleRejections.hpp:10
monopoly::rules::rejections::send
void send(const GameState &state, const actions::Message &message, std::int64_t error)
Definition
RuleRejections.hpp:13
monopoly::rules::rejections::wrongPlayer
void wrongPlayer(const GameState &state, const actions::Message &message)
Definition
RuleRejections.hpp:34
monopoly::rules::rejections::wrongPhase
void wrongPhase(const GameState &state, const actions::Message &message)
Definition
RuleRejections.hpp:31
monopoly::rules::BankPlayer
constexpr PlayerNumber BankPlayer
Definition
RuleTypes.hpp:15
monopoly::rules::PlayerNumber
std::uint8_t PlayerNumber
Definition
RuleTypes.hpp:12
monopoly::rules::state
const GameState & state()
Definition
RulesEngine.cpp:662
monopoly::rules::MaxPlayers
constexpr PlayerNumber MaxPlayers
Definition
RuleTypes.hpp:14
monopoly::rules::AllPlayers
constexpr PlayerNumber AllPlayers
Definition
RuleTypes.hpp:17
monopoly::actions::Message
Definition
Actions.hpp:125
monopoly::actions::Message::fromPlayer
rules::PlayerNumber fromPlayer
Definition
Actions.hpp:128
monopoly::actions::Message::action
Type action
Definition
Actions.hpp:126
monopoly::rules::GameState
Definition
RuleTypes.hpp:259
monopoly::rules::GameState::numberOfPendingPhases
std::uint8_t numberOfPendingPhases
Definition
RuleTypes.hpp:302
monopoly::rules::PendingPhase::phase
GamePhase phase
Definition
RuleTypes.hpp:120
RuleRejections.hpp
Generated by
1.9.8