载入中...
搜索中...
未找到
GameState.cpp
浏览该文件的文档.
13 eve::Diagnostic::error(eve::DiagnosticCode::ParseError, "game state field must be an object", path));
33 eve::Diagnostic::error(eve::DiagnosticCode::ParseError, "game state field must be an object", path));
38 return eve::Result<std::unordered_map<std::string, std::string>>::failure(eve::Diagnostic::error(
71void GameState::setSelfVariable(const std::string &scope, const std::string &name, double value) {
88void GameState::setSelfString(const std::string &scope, const std::string &name, std::string value) {
152 eve::Diagnostic::error(eve::DiagnosticCode::ParseError, "game state root must be an object", "$."));
156 eve::DiagnosticCode::InvalidArgument, "snapshot does not belong to RPG GameState", "$.schema"));
160 eve::DiagnosticCode::UnknownVersion, "unsupported RPG GameState snapshot version", "$.version"));
180 eve::DiagnosticCode::ParseError, "game state selfVariables must be an object", "$.selfVariables"));
全局游戏状态:开关(bool)、变量(数字)、独立变量(按作用域)。
Owning, renderer-independent dynamic values.
static Diagnostic error(DiagnosticCode code, std::string message, std::string path={}, DiagnosticDetails details={}, std::string source={})
Construct an error diagnostic with the standard error severity.
Definition Diagnostic.h:125
static Result failure(Status status)
Construct a failed result from a structured status.
Definition Result.h:175
Result< std::string > toJson() const
Serialize this value as deterministic compact JSON.
Definition Value.cpp:67
const std::string & asString() const
Return the string payload; the caller must have checked the kind.
Definition Value.cpp:87
static Result< Value > fromJson(std::string_view json)
Parse one strict JSON value into an owning Value.
Definition Value.cpp:57
bool isNumeric() const noexcept
Return whether this value is an integer or finite number.
Definition Value.h:159
std::vector< std::string > keys() const
Return object member names in deterministic order.
Definition Value.cpp:138
std::int64_t asInt() const
Return the Int64 payload; the caller must have checked the kind.
Definition Value.cpp:69
bool asBool() const
Return the boolean payload; the caller must have checked the kind.
Definition Value.cpp:81
Value * find(const std::string &key) noexcept
Return an object member, or nullptr when absent.
Definition Value.cpp:124
void clearSelfString(const std::string &scope, const std::string &name)
Remove one scoped string fact; no-op when absent.
Definition GameState.cpp:105
eve::Result< void > restoreSnapshotJson(std::string_view json)
Validate and atomically restore a canonical RPG game-state JSON document.
Definition GameState.cpp:146
eve::Result< std::string > snapshotJson() const
Serialize this state as the canonical versioned RPG game-state JSON document.
Definition GameState.cpp:119
double getSelfVariable(const std::string &scope, const std::string &name) const
Returns the self variable.
Definition GameState.cpp:75
void setSelfString(const std::string &scope, const std::string &name, std::string value)
Scoped string facts (for example a .dnut story cursor JSON blob).
Definition GameState.cpp:88
bool hasSelfVariable(const std::string &scope, const std::string &name) const
True when self variable.
Definition GameState.cpp:82
std::string getSelfString(const std::string &scope, const std::string &name) const
Return a scoped string fact, or an empty string when absent.
Definition GameState.cpp:92
bool hasSelfString(const std::string &scope, const std::string &name) const
Whether a scoped string fact is present.
Definition GameState.cpp:99
void setSelfVariable(const std::string &scope, const std::string &name, double value)
独立变量:scope(如 "map:1:event:3")下按名字存数字。
Definition GameState.cpp:71
@ InvalidArgument
@ UnknownVersion
@ ParseError