载入中...
搜索中...
未找到
WorldInteraction.cpp
浏览该文件的文档.
16eve::Result<int> interactionFailure(eve::DiagnosticCode code, std::string message, std::string path,
18 return eve::Result<int>::failure(eve::Diagnostic::error(code, std::move(message), std::move(path),
39eve::Result<int> WorldInteraction::collectLoot(GameState &gameState, Tracker &tracker, inventory::Bag &bag,
46 return interactionFailure(eve::DiagnosticCode::InvalidArgument, "world loot must contain at least one effect",
52 (request.attributeId.empty() || !std::isfinite(request.attributeAmount) || request.attributeAmount <= 0.0))
55 if (hasAttribute && !std::isfinite(gameState.getVariable(request.attributeId) + request.attributeAmount))
58 if (hasNotification && (request.notifyTopic.empty() || request.notifyTarget.empty() || request.notifyAmount <= 0))
75 return interactionFailure(eve::DiagnosticCode::Conflict, "world loot object was already consumed", "objectId",
82 auto prepared = inventory::InventorySystem::prepareAddBatch(&bag, {{request.itemId, request.itemQuantity}});
89 if (hasNotification) tracker.notify(request.notifyTopic, request.notifyTarget, request.notifyAmount);
99 return interactionFailure(eve::DiagnosticCode::Conflict, "world loot object changed before commit", "objectId",
151 eve::DiagnosticCode::InvalidArgument, "world-state IDs must be non-empty, bounded, and control-free",
155 eve::DiagnosticCode::InvalidArgument, "world-state IDs must be non-empty, bounded, and control-free",
166 eve::DiagnosticCode::InvalidArgument, "world-state IDs must be non-empty, bounded, and control-free",
170 eve::DiagnosticCode::InvalidArgument, "world-state IDs must be non-empty, bounded, and control-free",
全局游戏状态:开关(bool)、变量(数字)、独立变量(按作用域)。
目标追踪器运行时实例(玩家日志 / 成就 / 教程可各建一份)。
Atomic settlement of persistent world loot interactions.
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.cpp:21
bool ok() const noexcept
Whether this result represents a non-failure outcome.
Definition Result.h:514
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
static eve::Result< int > commitAddBatch(PreparedInventoryAdd prepared)
Commit one prepared addition and then publish its change events.
Definition InventorySystem.cpp:481
static eve::Result< PreparedInventoryAdd > prepareAddBatch(Bag *bag, const std::vector< InventoryItemGrant > &grants)
Validate a multi-item addition against a private candidate Bag.
Definition InventorySystem.cpp:437
eve::Result< void > restoreSnapshotJson(std::string_view json)
Validate and atomically restore a canonical RPG game-state JSON document.
Definition GameState.cpp:149
eve::Result< std::string > snapshotJson() const
Serialize this state as the canonical versioned RPG game-state JSON document.
Definition GameState.cpp:122
double getSelfVariable(const std::string &scope, const std::string &name) const
Returns the self variable.
Definition GameState.cpp:78
bool hasSelfVariable(const std::string &scope, const std::string &name) const
True when self variable.
Definition GameState.cpp:85
void setSelfVariable(const std::string &scope, const std::string &name, double value)
独立变量:scope(如 "map:1:event:3")下按名字存数字。
Definition GameState.cpp:74
std::unordered_map< std::string, QuestRuntime > entries
运行时条目(QuestSystem 读写;公开以便测试与脚本查询)。
Definition Tracker.h:148
void notify(const std::string &topic, const std::string &target, int amount)
Notify.
Definition Tracker.cpp:26
static eve::Result< int > collectLoot(GameState &gameState, Tracker &tracker, inventory::Bag &bag, const WorldLootRequest &request)
Atomically grant loot, notify quest progress, and consume one world object.
Definition WorldInteraction.cpp:39
Non-owning typed adapter for persistent per-map object lifecycle state.
Definition WorldState.h:19
eve::Result< void > resetObject(std::string_view mapId, std::string_view objectId)
Idempotently clear the consumed fact for one stable map object.
Definition WorldInteraction.cpp:163
bool isObjectConsumed(std::string_view mapId, std::string_view objectId) const
Query whether a stable object has been consumed in one map.
Definition WorldInteraction.cpp:140
eve::Result< void > consumeObject(std::string_view mapId, std::string_view objectId)
Idempotently publish the consumed fact for one stable map object.
Definition WorldInteraction.cpp:148
@ InvalidArgument
@ PreconditionViolation
@ InvariantViolation
@ Conflict
@ NoOp
@ Applied
Complete data needed to settle one persistent loot object.
Definition WorldInteraction.h:24