载入中...
搜索中...
未找到
SettlementRules.h
浏览该文件的文档.
1#pragma once
2
9
10#include <cstdint>
11#include <functional>
12#include <string>
13#include <vector>
14
15namespace eve::effects {
16class EffectContainer;
17}
18
19namespace eve::settlement {
20
22enum class RuleOperation : std::uint8_t {
23 Add,
30 Immune,
32 Reflect,
33};
34
42 std::vector<std::string> kinds;
43 std::vector<std::string> requiredTags;
44 std::vector<std::string> excludedTags;
45};
46
55 std::string id;
56 std::string source;
57 StageKind stage = StageKind::SourceModifiers;
58 int priority = 0;
59 RuleOperation operation = RuleOperation::Add;
60 double value = 0.0;
61 double valuePerExtraStack = 0.0;
62 std::uint32_t stacks = 1;
65 std::string when;
66};
67
78public:
80 [[nodiscard]] static constexpr std::uint32_t schemaVersion() noexcept { return 1; }
81
83 [[nodiscard]] eve::Result<void> configure(std::vector<SettlementRule> rules);
84
91 [[nodiscard]] static eve::Result<SettlementRuleSet> fromJson(std::string_view json);
92
99 [[nodiscard]] eve::Result<void> configureJson(std::string_view json);
100
107 [[nodiscard]] eve::Result<void> install(SettlementPipeline& pipeline) const;
108
110 [[nodiscard]] std::size_t size() const noexcept { return rules_.size(); }
111
117 [[nodiscard]] eve::Result<std::string> canonicalJson() const;
118
125 [[nodiscard]] eve::Result<eve::ContentId> digest(const eve::SnapshotHashProvider& hashProvider) const;
126
127private:
128 using ConditionFunction = std::function<eve::Result<bool>(const SettlementRequest&)>;
129
130 std::vector<SettlementRule> rules_;
131 std::vector<ConditionFunction> conditions_;
132 std::vector<std::string> conditionDigests_;
133};
134
145 const effects::EffectContainer& effects, std::string_view scope);
146
147} // namespace eve::settlement
ActionParameterOperation operation
double value
int priority
#define EVENGINE_API_FOUNDATION
每个链接组(link group)各自的导出宏。
Definition Export.h:106
JobScope scope
std::string digest
Move-only operation result carrying either a value or Status.
Definition Result.h:155
Owns active effect instances and their deterministic lifecycle events.
Deterministically ordered, composable settlement pipeline.
Definition Settlement.h:542
Validated immutable-style rule collection installable into pipelines.
static constexpr std::uint32_t schemaVersion() noexcept
Stable schema version used by canonical rule-set identity.
std::size_t size() const noexcept
Return the number of validated rules in this collection.
RuleOperation
Supported deterministic mutations of a settlement calculation.
StageKind
Kind of ordered calculation stage in a settlement pipeline.
Definition Settlement.h:36
eve::Result< SettlementRuleSet > projectEffectRules(const effects::EffectContainer &effects, std::string_view scope)
Project active effect payloads into an owning settlement rule snapshot.
std::function< Result< ContentId >(std::string_view canonicalInput)> SnapshotHashProvider
Injected content-digest implementation used by snapshots.
Definition Snapshot.h:36
Domain-neutral, deterministic settlement pipeline.
Predicate selecting requests to which a rule applies.
std::vector< std::string > requiredTags
std::vector< std::string > kinds
std::vector< std::string > excludedTags
Domain-neutral input to one settlement operation.
Definition Settlement.h:107
One owning, serializable projection of a buff/effect contribution.
std::string when
Optional side-effect-free expression compiled by configure().