Monopoly — Portage moderne 0.1.0
Portage moderne C/C++23 du Monopoly de 1999
Loading...
Searching...
No Matches
PieceIdleTransition.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "DataBanks.hpp"
4#include "PiecePlacement.hpp"
5#include "RuleTypes.hpp"
6
7#include <array>
8#include <cstdint>
9#include <expected>
10#include <optional>
11
12namespace monopoly::pieces
13{
14 inline constexpr data::DataTag IdleToRestBaseTag = 0x011B;
15 inline constexpr data::DataTag RestToCenterBaseTag = 0x011C;
16 inline constexpr data::DataTag IdleAnimationsPerToken = 0x0063;
17
18 enum class PieceIdleTransitionError : std::uint8_t
19 {
24 };
25
33
35 {
36 std::optional<PieceIdleAnimation> movingOut;
37 std::optional<PieceIdleAnimation> movingIn;
39 };
40
42 {
43 public:
44 using Slot = std::optional<rules::PlayerNumber>;
45 using SquareSlots = std::array<Slot, RestingPositionCount>;
46 using Occupancy = std::array<SquareSlots, BoardSquareCountWithSpecials>;
47
48 void reset() noexcept;
50 const rules::GameState& state) noexcept;
51 [[nodiscard]] std::expected<void, PieceIdleTransitionError> initialize(
52 const rules::GameState& state,
53 std::optional<rules::PlayerNumber> center = std::nullopt) noexcept;
55 planTurnChange(const rules::GameState& state,
56 rules::PlayerNumber newCurrent) noexcept;
57
58 [[nodiscard]] const Occupancy& occupancy() const noexcept { return occupancy_; }
59 [[nodiscard]] std::optional<rules::PlayerNumber> center() const noexcept { return center_; }
60 [[nodiscard]] bool initialized() const noexcept { return initialized_; }
61
62 private:
63 Occupancy occupancy_{};
64 std::optional<rules::PlayerNumber> center_;
65 bool initialized_{};
66 };
67}
unsigned state
unsigned index
std::expected< void, PieceIdleTransitionError > initialize(const rules::GameState &state, std::optional< rules::PlayerNumber > center=std::nullopt) noexcept
std::optional< rules::PlayerNumber > Slot
const Occupancy & occupancy() const noexcept
std::array< Slot, RestingPositionCount > SquareSlots
std::expected< void, PieceIdleTransitionError > initializeNewGame(const rules::GameState &state) noexcept
std::optional< rules::PlayerNumber > center() const noexcept
std::array< SquareSlots, BoardSquareCountWithSpecials > Occupancy
std::expected< PieceIdleTransitionPlan, PieceIdleTransitionError > planTurnChange(const rules::GameState &state, rules::PlayerNumber newCurrent) noexcept
std::uint32_t DataId
Definition DataBanks.hpp:10
constexpr DataId EmptyDataId
Definition DataBanks.hpp:13
std::uint16_t DataTag
Definition DataBanks.hpp:11
constexpr data::DataTag IdleToRestBaseTag
constexpr data::DataTag IdleAnimationsPerToken
constexpr data::DataTag RestToCenterBaseTag
std::uint8_t PlayerNumber
Definition RuleTypes.hpp:12
constexpr PlayerNumber NobodyPlayer
Definition RuleTypes.hpp:16
std::optional< PieceIdleAnimation > movingOut
std::optional< PieceIdleAnimation > movingIn