载入中...
搜索中...
未找到
SettlementAdapter.cpp
浏览该文件的文档.
25bool isHealingKind(std::string_view kind) noexcept { return kind == "heal" || kind == "healing"; }
30 eve::DiagnosticCode::InvariantViolation, std::string(name) + " must be finite", std::string(name)));
34eve::Result<settlement::SettlementRequest> requestFailure(eve::DiagnosticCode code, std::string message,
52 const StatusTickEvent& tick, SubjectRef source, SubjectRef target, SimulationTick simulationTick) {
54 return requestFailure(eve::DiagnosticCode::InvalidArgument, "RPG status tick identity is invalid", "tick");
56 return requestFailure(eve::DiagnosticCode::InvalidArgument, "RPG status tick target must be valid", "target");
63 return requestFailure(eve::DiagnosticCode::NotFound, "RPG effect has no settlement.tick configuration",
69 return requestFailure(eve::DiagnosticCode::InvalidArgument, "settlement.tick must be a JSON object",
71 static const std::set<std::string> fields = {"context", "kind", "magnitude", "resource", "tags"};
83 if (kind == nullptr || kind->empty() || resource == nullptr || resource->empty() || magnitudeValue == nullptr)
93 return requestFailure(eve::DiagnosticCode::InvalidArgument, "settlement.tick magnitude must be a number",
113 return requestFailure(eve::DiagnosticCode::InvalidArgument, "settlement.tick tags must be an array",
130 return requestFailure(eve::DiagnosticCode::InvalidArgument, "settlement.tick context must be an object",
144RPGSettlementAdapter::RPGSettlementAdapter(RPGActor& target, SubjectRef targetRef, Config config)
155bool RPGSettlementAdapter::isDamage(const settlement::SettlementContext& context) const noexcept {
159bool RPGSettlementAdapter::isHealing(const settlement::SettlementContext& context) const noexcept {
163const eve::Value* RPGSettlementAdapter::contextValue(const settlement::SettlementContext& context,
193 eve::DiagnosticCode::InvalidArgument, "RPG settlement attribute name must not be empty", "attribute"));
201eve::Result<double> RPGSettlementAdapter::readFinal(std::string_view name, double fallback) const {
208eve::Result<double> RPGSettlementAdapter::readSourceFinal(std::string_view name, double fallback) const {
218 eve::DiagnosticCode::Conflict, "RPG settlement request target does not match adapter target", "target"));
224 eve::DiagnosticCode::Unsupported, "RPG settlement adapter supports damage, healing and trigger kinds only",
236 eve::Diagnostic::error(eve::DiagnosticCode::InvariantViolation, "RPG health exceeds max health", "health"));
244eve::Result<void> RPGSettlementAdapter::sourceModifiers(settlement::SettlementContext& context) {
300 eve::DiagnosticCode::InvalidArgument, "RPG critical multiplier must be finite and at least one",
355 const double penetration = std::max(0.0, numberValue(contextValue(context, "penetration")).value_or(0.0));
430 const double nextHealth = isDamage(context) ? health - context.magnitude() : health + context.magnitude();
483 return eve::Result<std::vector<settlement::SettlementRequest>>::success(std::move(transitions));
498 if (shield.ok() && shield.value() > 0.0 && result.absorbed >= shield.value()) append("shield_break");
506 if (context.request().source.isValid() && context.request().source != context.request().target) append("kill");
508 return eve::Result<std::vector<settlement::SettlementRequest>>::success(std::move(transitions));
RPG's thin compatibility facade over the attributes module.
当前资源(hp/mana...)的受伤 / 治疗 / 复活 / 死亡。
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.cpp:21
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:196
static Status success(StatusCode code=StatusCode::Ok)
Construct a successful status with an explicit non-error outcome.
Definition Status.cpp:19
bool isValid() const noexcept
Return whether this reference is valid and non-nil.
Definition SubjectRef.h:38
static Result< Value > fromJson(std::string_view json)
Parse one strict JSON value into an owning Value.
Definition Value.cpp:177
const T * getIf() const noexcept
Return a typed pointer, or nullptr when the kind differs.
Definition Value.h:209
Value * find(const std::string &key) noexcept
Return an object member, or nullptr when absent.
Definition Value.cpp:244
Generic owning collection of canonical attributes and modifiers.
Definition AttributeSet.h:160
static const EffectDefinition * find(const std::string &id)
Find a registered effect definition by id.
Definition Effect.cpp:30
Settles damage/healing against one RPG actor's Vitals and AttributeSet.
Definition SettlementAdapter.h:48
eve::Result< void > sourceModifiers(settlement::SettlementContext &context) override
Apply source-side modifiers such as critical or elemental power.
Definition SettlementAdapter.cpp:244
eve::Result< settlement::PreparedApply > prepareApply(const settlement::SettlementContext &context) override
Build an atomic candidate mutation without publishing it.
Definition SettlementAdapter.cpp:419
eve::Result< void > clamp(settlement::SettlementContext &context) override
Configure policy-specific amount bounds for the generic clamp.
Definition SettlementAdapter.cpp:400
eve::Result< void > armorShield(settlement::SettlementContext &context) override
Apply armor and shield policy, recording absorbed amount.
Definition SettlementAdapter.cpp:346
eve::Result< std::vector< settlement::SettlementRequest > > prepareTrigger(const settlement::SettlementContext &context, const settlement::SettlementResult &result) override
Produce owning derived requests without mutating domain state.
Definition SettlementAdapter.cpp:479
eve::Result< void > validate(settlement::SettlementContext &context) override
Validate request and target-owned state without mutating it.
Definition SettlementAdapter.cpp:215
RPGSettlementAdapter(RPGActor &target, SubjectRef targetRef)
Bind a target actor with default RPG attribute names.
Definition SettlementAdapter.cpp:141
eve::Result< void > targetMitigation(settlement::SettlementContext &context) override
Apply target mitigation such as resistance or penetration rules.
Definition SettlementAdapter.cpp:316
static double getCurrent(RPGActor *actor, const std::string &resource)
当前值(无 vitals/资源时 0)。
Definition VitalsSystem.cpp:28
Prepared domain mutation used to make settlement application atomic.
Definition Settlement.h:281
Mutable calculation frame visible to policy and custom stage code.
Definition Settlement.h:338
eve::Result< settlement::SettlementRequest > makeStatusTickSettlementRequest(const StatusTickEvent &tick, SubjectRef source, SubjectRef target, SimulationTick simulationTick)
Project one configured RPG status tick into the canonical settlement request.
Definition SettlementAdapter.cpp:51
@ InvalidArgument
@ NotFound
@ Unsupported
@ InvariantViolation
@ Conflict
@ Pending
@ NotFound
@ Applied
Definition Container.h:602
RPG vitals and attribute policy adapter for the common settlement pipeline.
Attribute names used by the RPG policy.
Definition SettlementAdapter.h:51
std::string shieldAttribute
Definition SettlementAdapter.h:56
std::string maxHealthAttribute
Final attribute supplying the resource maximum.
Definition SettlementAdapter.h:55
std::string armorAttribute
Definition SettlementAdapter.h:57
std::string sourceMultiplierAttribute
Definition SettlementAdapter.h:61
std::string criticalMultiplierAttribute
Definition SettlementAdapter.h:60
bool emitLifeTransitions
Emit death/kill transitions when this resource crosses zero.
Definition SettlementAdapter.h:63
std::string criticalChanceAttribute
Definition SettlementAdapter.h:59
std::string resistancePrefix
Definition SettlementAdapter.h:58
std::string healthAttribute
Vitals resource holding authoritative current health.
Definition SettlementAdapter.h:53
周期性状态触发的 tick 事件。周期效果(period > 0)不会自动修改属性, 而是每个周期产生一个 tick 事件交给上层(脚本或 C++ 结算系统)处理—— 这样伤害/治疗类周期效果可以完整地...
Definition StatusTypes.h:70
Domain-neutral input to one settlement operation.
Definition Settlement.h:107
std::string resource
Optional domain resource/channel key, for example hp, mana, armor, or fire.
Definition Settlement.h:113
std::string trigger
Stable re-entry key for a derived request; empty only for a root request.
Definition Settlement.h:119
std::vector< SettlementRandomDecision > decisions
Definition Settlement.h:117
Complete observable outcome of one successful settlement.
Definition Settlement.h:163