Monopoly — Portage moderne 0.1.0
Portage moderne C/C++23 du Monopoly de 1999
Loading...
Searching...
No Matches
PieceMovePlan.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "Actions.hpp"
4#include "DataBanks.hpp"
5#include "PieceCamera.hpp"
6
7#include <cstdint>
8#include <expected>
9#include <optional>
10#include <span>
11#include <vector>
12
13namespace monopoly::pieces
14{
15 inline constexpr std::size_t TokenAnimationItemLimit = 12;
16 inline constexpr data::DataTag TokenCornerAnimationBaseTag = 0x00F6;
17 inline constexpr data::DataTag TokenMoveAnimationBaseTag = 0x010D;
19 inline constexpr data::DataTag AnimationsPerToken = 0x0063;
20
21 enum class PieceMoveSpecial : std::uint8_t
22 {
23 None,
29 };
30
31 enum class OffBoardOutcome : std::uint8_t
32 {
35 };
36
46
48 {
49 bool cameraOnly{};
50 std::uint32_t cameraDelay{};
53 std::int32_t startSquare{};
54 std::optional<std::int32_t> landingSquare;
55 std::optional<bool> corner;
56 };
57
59 {
61 std::uint8_t token{};
62 std::int32_t sourceSquare{};
63 std::int32_t destinationSquare{};
64 std::vector<PieceMoveInstruction> instructions;
65 std::optional<std::size_t> loopBegin;
66 std::optional<std::size_t> loopEnd; // exclusive, mirrors TokenLoopAnimEnd
67 std::size_t randomChoicesUsed{};
68 };
69
70 // Pure equivalent of UDPIECES_PlanMoveAnim's stack construction.
71 // Each random byte supplies one source rand()%2 result via (byte & 1).
72 [[nodiscard]] std::expected<PieceMovePlan, PieceMovePlanError> planTokenMove(
74 std::uint8_t token,
75 std::int32_t before,
76 std::int32_t after,
77 bool animationsEnabled,
78 std::span<const std::uint8_t> randomChoices = {});
79
80 // Pure off-board branch once the caller has decided bankrupt vs victory.
81 [[nodiscard]] std::expected<PieceMovePlan, PieceMovePlanError> planOffBoardMove(
82 std::uint8_t token,
83 std::int32_t before,
85}
unsigned index
int token
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 AnimationsPerToken
std::expected< PieceMovePlan, PieceMovePlanError > planTokenMove(actions::Type notification, std::uint8_t token, std::int32_t before, std::int32_t after, bool animationsEnabled, std::span< const std::uint8_t > randomChoices)
std::expected< PieceMovePlan, PieceMovePlanError > planOffBoardMove(std::uint8_t token, std::int32_t before, OffBoardOutcome outcome)
constexpr data::DataTag TokenCornerAnimationBaseTag
constexpr data::DataTag TokenBackThreeAnimationBaseTag
constexpr data::DataTag TokenMoveAnimationBaseTag
constexpr std::size_t TokenAnimationItemLimit
std::optional< std::int32_t > landingSquare
std::vector< PieceMoveInstruction > instructions
std::optional< std::size_t > loopEnd
std::optional< std::size_t > loopBegin