Monopoly — Portage moderne 0.1.0
Portage moderne C/C++23 du Monopoly de 1999
Loading...
Searching...
No Matches
DiceDisplay.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "DataBanks.hpp"
4#include "DiceIngress.hpp"
6
7#include <array>
8#include <cstdint>
9#include <expected>
10#include <optional>
11#include <string>
12
13namespace monopoly::dice
14{
15 inline constexpr data::DataTag Fixed2DBaseTag = 0x0096;
16 inline constexpr data::DataTag Bobbing2DTag = 0x009C;
17 inline constexpr data::DataTag Roll3DBaseTag = 0x0537;
18 inline constexpr data::DataTag Idle3DBaseTag = 0x057F;
19 inline constexpr std::uint16_t Generic3DPriority = 100;
20 inline constexpr std::uint16_t IBarGeneralPriority = 256;
21
22 struct TwoDItem
23 {
25 std::uint16_t priority{};
26 std::int32_t x{};
27 std::int32_t y{};
28 bool dropFrames{};
29 bool loop{};
30 };
31
32 struct TwoDPlan
33 {
34 std::array<std::optional<TwoDItem>, 2> dice;
35 bool bobbing{};
36 };
37
38 [[nodiscard]] bool validValues(
39 const std::array<std::uint8_t, 2>& values) noexcept;
41 const std::array<std::uint8_t, 2>& values) noexcept;
43 const std::array<std::uint8_t, 2>& values) noexcept;
44 [[nodiscard]] TwoDPlan plan2D(
45 const std::array<std::uint8_t, 2>& values,
47 bool iBarVisible) noexcept;
48
49 // UDPieces.cpp:333-390. Fixed and bobbing identities are distinct even
50 // when they occupy the same two priorities. Notification is consumed
51 // after the left fixed die, exactly as in the original loop.
53 {
54 public:
55 [[nodiscard]] std::expected<void, std::string> sync(
56 const std::array<std::uint8_t, 2>& values,
58 bool& diceRollNotification, engine::SequencePlayback& playback);
59 void reset() noexcept { currentDiceID_ = {}; currentBobDice_ = data::EmptyDataId; }
60 [[nodiscard]] const auto& currentDiceID() const noexcept { return currentDiceID_; }
61 [[nodiscard]] data::DataId currentBobDice() const noexcept { return currentBobDice_; }
62 private:
63 std::array<data::DataId, 2> currentDiceID_{};
64 data::DataId currentBobDice_{data::EmptyDataId};
65 };
66
68 {
69 bool activeRoll{};
76 };
77
79 {
80 public:
81 [[nodiscard]] std::expected<void, std::string> begin(RollRequest request);
82 [[nodiscard]] std::expected<PlaybackUpdate, std::string> tick(
83 std::uint64_t tick,
84 bool boardVisible,
85 bool iBarVisible,
88
89 [[nodiscard]] bool active() const noexcept { return request_.has_value(); }
91 void reset() noexcept;
92
93 private:
94 [[nodiscard]] std::expected<bool, std::string> syncIdle(
95 bool boardVisible,
96 const rules::GameState& state,
97 engine::SequencePlayback& playback);
98
99 std::optional<RollRequest> request_;
100 data::DataId current3D_{data::EmptyDataId};
101 std::uint64_t cameraSetTime_{};
102 bool prepared_{};
103 bool rollStarted_{};
104 bool cameraReleased_{};
105 };
106}
unsigned state
unsigned index
data::DataId current3DSequence() const noexcept
std::expected< PlaybackUpdate, std::string > tick(std::uint64_t tick, bool boardVisible, bool iBarVisible, const rules::GameState &state, engine::SequencePlayback &playback)
bool active() const noexcept
std::expected< void, std::string > begin(RollRequest request)
const auto & currentDiceID() const noexcept
data::DataId currentBobDice() const noexcept
std::expected< void, std::string > sync(const std::array< std::uint8_t, 2 > &values, bool rollAnimationDesired, bool iBarVisible, bool &diceRollNotification, engine::SequencePlayback &playback)
std::uint32_t DataId
Definition DataBanks.hpp:10
constexpr DataId EmptyDataId
Definition DataBanks.hpp:13
std::uint16_t DataTag
Definition DataBanks.hpp:11
data::DataId idle3DSequence(const std::array< std::uint8_t, 2 > &values) noexcept
constexpr data::DataTag Idle3DBaseTag
constexpr data::DataTag Roll3DBaseTag
data::DataId roll3DSequence(const std::array< std::uint8_t, 2 > &values) noexcept
constexpr std::uint16_t IBarGeneralPriority
bool validValues(const std::array< std::uint8_t, 2 > &values) noexcept
constexpr data::DataTag Bobbing2DTag
constexpr data::DataTag Fixed2DBaseTag
constexpr std::uint16_t Generic3DPriority
TwoDPlan plan2D(const std::array< std::uint8_t, 2 > &values, bool rollAnimationDesired, bool iBarVisible) noexcept
std::array< std::optional< TwoDItem >, 2 > dice