载入中...
搜索中...
未找到
ActionKillReward.cpp
浏览该文件的文档.
2
6#include "rpg/RPGActor.h"
7#include "rpg/WorldState.h"
8
9#include <cmath>
10#include <string>
11
12namespace eve::rpg {
14 Tracker& tracker, const RPGActionDamageReceipt& death,
15 std::string_view encounterId) {
16 if (!death.killed || !std::isfinite(death.applied) || death.applied <= 0.0 || !death.source.isValid() ||
17 !death.target.isValid() || death.source == death.target || !recipient.subject.isValid() ||
18 recipient.subject != death.source)
20 DiagnosticCode::InvalidArgument, "Reward requires a committed kill credited to the recipient"));
21 auto* actor = dynamic_cast<RPGActor*>(ecs::try_get(recipient.actor));
22 if (!actor)
24 Diagnostic::error(DiagnosticCode::StaleHandle, "Reward recipient is no longer a live RPG actor"));
25
26 constexpr auto scope = "rpg.action-kill.v1";
27 const auto victim = death.target.format();
28 WorldState world(gameState);
29 if (world.isObjectConsumed(scope, victim))
31 const auto* definition = EncounterCatalogue::find(std::string(encounterId));
32 if (!definition)
34 Diagnostic::error(DiagnosticCode::NotFound, "Action kill reward template is not registered"));
35 if (definition->members.size() != 1)
37 Diagnostic::error(DiagnosticCode::Unsupported, "One kill cannot settle a multi-member encounter"));
38
39 const auto request = detail::encounterVictoryRequest(*definition, scope, victim);
40 return BattleVictory::settle(*actor, gameState, tracker, request);
41}
42} // namespace eve::rpg
Strict RPG encounter definitions and settlement projection.
const GltfImportRequest & request
JobScope scope
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
Move-only operation result carrying either a value or Status.
Definition Result.h:176
static Result success(T value)
Construct a successful result owning value.
Definition Result.h:185
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
std::string format() const
Return the canonical lower-case UUID spelling.
Definition SubjectRef.h:44
bool isValid() const noexcept
Return whether this reference is valid and non-nil.
Definition SubjectRef.h:38
static Result< BattleVictoryReceipt > settle(const RPGDamageTarget &recipient, GameState &gameState, Tracker &tracker, const RPGActionDamageReceipt &death, std::string_view encounterId)
Grant XP, class skills, gold and quest progress once for a committed death.
static eve::Result< BattleVictoryReceipt > settle(RPGActor &actor, GameState &gameState, Tracker &tracker, const BattleVictoryRequest &request)
Atomically settle XP, derived class skills, attributes, quest progress, and encounter consumption.
static const EncounterDefinition * find(const std::string &id)
Finds .
一份游戏状态(开关/变量/独立变量)。
Definition GameState.h:26
属性 / 状态 / 技能三表合一的 ECS 实体。
Definition RPGActor.h:34
一份任务进度 + 本实例事件队列。
Definition Tracker.h:26
Non-owning typed adapter for persistent per-map object lifecycle state.
Definition WorldState.h:19
BattleVictoryRequest encounterVictoryRequest(const EncounterDefinition &definition, std::string_view mapId, std::string_view objectId)
Project catalogue reward fields into the canonical victory transaction.
RPG 模块的基础实体:把属性 / 状态 / 技能三张表挂到一个 ECS 实体上。
Owning post-commit observation; no actor pointers survive dispatch.
Owning identity projection; the host owns the mapping, ECS owns the actor.