载入中...
搜索中...
未找到
TurnPolicy.h
浏览该文件的文档.
1#pragma once
2
13#include "common/Result.h"
15
16#include <map>
17#include <memory>
18#include <string>
19#include <string_view>
20#include <vector>
21
22namespace eve::tactics {
23
24// The built-in policy ids live in TacticsTypes.h, because they are part of the
25// persisted protocol (snapshots and replay commands carry these exact strings).
26
35struct UnitOrder {
37 int initiative = 0;
39 std::size_t sideIndex = 0;
46 int charge = 0;
47};
48
67 int cost = 0;
69 int threshold = 0;
70
72 [[nodiscard]] constexpr bool isChargeBased() const noexcept { return threshold > 0; }
73};
74
83enum class TurnOrder : std::uint8_t {
90};
91
104public:
106 virtual ~ITurnPolicy() = default;
107
109 [[nodiscard]] virtual std::string_view id() const noexcept = 0;
110
120 [[nodiscard]] virtual TurnOrder order(const Battle& battle, const UnitOrder& left,
121 const UnitOrder& right) const = 0;
122
135 [[nodiscard]] virtual ChargeModel chargeModel(const Battle& battle) const;
136};
137
146public:
152 [[nodiscard]] Result<void> add(std::shared_ptr<const ITurnPolicy> policy);
154 [[nodiscard]] Result<const ITurnPolicy*> find(std::string_view id) const;
156 [[nodiscard]] std::vector<std::string> ids() const;
158 [[nodiscard]] bool contains(std::string_view id) const;
159
165 [[nodiscard]] static TurnPolicyRegistry& builtins();
166
167private:
168 std::map<std::string, std::shared_ptr<const ITurnPolicy>, std::less<>> policies_;
169};
170
171} // namespace eve::tactics
#define EVENGINE_API_DOMAINS
Definition Export.h:110
glm::uvec4 ids
HexVec3 left
HexVec3 right
std::vector< std::int32_t > order
Move-only, checked operation results for the common layer.
Deterministic board values and short-root ECS entities for tactics.
Move-only operation result carrying either a value or Status.
Definition Result.h:155
Battle short-root and authoritative owner of board and turn state.
One deterministic unit-activation ordering strategy.
Definition TurnPolicy.h:103
virtual std::string_view id() const noexcept=0
Return the stable protocol id this policy is registered under.
virtual ~ITurnPolicy()=default
I turn policy.
Registry of turn policies keyed by stable id.
Definition TurnPolicy.h:145
TurnOrder
The total order a policy reports for one pair of units.
Definition TurnPolicy.h:83
@ RightFirst
The right unit acts first.
@ Equivalent
Both compare equal; the caller decides by canonical order.
@ LeftFirst
The left unit acts first.
The charge rule a policy declares for round scheduling.
Definition TurnPolicy.h:63
int threshold
Charge a unit must reach to be scheduled; 0 means "always ready".
Definition TurnPolicy.h:69
constexpr bool isChargeBased() const noexcept
Whether this model schedules by charge at all.
Definition TurnPolicy.h:72
int cost
Charge a unit spends when it activates.
Definition TurnPolicy.h:67
int initiativeGain
Multiplier applied to a unit's initiative to get its per-round charge gain.
Definition TurnPolicy.h:65
The scheduling projection a policy is allowed to compare.
Definition TurnPolicy.h:35
std::size_t sideIndex
Index of the unit's side inside the battle's side list.
Definition TurnPolicy.h:39
int charge
Charge accumulated by this unit under a charge-time policy.
Definition TurnPolicy.h:46
int initiative
Per-turn initiative declared by the unit's turn resources.
Definition TurnPolicy.h:37