载入中...
搜索中...
未找到
RPGActorPersistence.cpp
浏览该文件的文档.
49 for (const auto &[name, value] : vitalRef->current) vitalsValue.emplace(name, eve::Value(value));
85eve::Result<RPGActor::CheckpointCandidate> RPGActor::prepareCheckpointJson(std::string_view json) const {
102 eve::Diagnostic::error(eve::DiagnosticCode::ParseError, "actor checkpoint root must be an object", "$"));
118 if (!encodedClass || !encodedClass->isObject() || !encodedTraits || !encodedTraits->isArray() ||
119 !encodedAttributes || !encodedAttributes->isArray() || !encodedProgression || !encodedProgression->isObject() ||
122 eve::DiagnosticCode::ParseError, "actor checkpoint participant fields have invalid types", "$"));
129 eve::DiagnosticCode::Conflict, "actor checkpoint class does not match its destination", "$.class"));
132 eve::DiagnosticCode::Conflict, "actor checkpoint traits do not match its destination", "$.traits"));
138 traitId->asString() != traitRef->active[index].traitId || source->asString() != traitRef->active[index].source)
145 if (encodedAttributes->arraySize() != static_cast<std::size_t>(candidate.attributes.values.attributeCount()))
147 eve::DiagnosticCode::Conflict, "actor checkpoint attribute layout does not match", "$.baseAttributes"));
153 if (!id || !id->isString() || !value || !value->isNumeric() || !std::isfinite(numericValue(*value)))
156 if (!seenAttributes.emplace(id->asString()).second || !candidate.attributes.values.has(id->asString()))
158 eve::DiagnosticCode::Conflict, "actor base attribute layout does not match", "$.baseAttributes"));
170 eve::DiagnosticCode::InvalidArgument, "actor checkpoint progression is invalid", "$.progression"));
171 candidate.progression = {static_cast<int>(level->asInt()), numericValue(*xp), numericValue(*xpToNext)};
175 if (!value || !value->isNumeric() || !std::isfinite(numericValue(*value)) || numericValue(*value) < 0.0 ||
189 eve::DiagnosticCode::NotFound, "actor checkpoint skill is missing or invalid", "$.learnedSkills"));
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
static Status success(StatusCode code=StatusCode::Ok)
Construct a successful status with an explicit non-error outcome.
Definition Status.h:81
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::int64_t asInt() const
Return the Int64 payload; the caller must have checked the kind.
Definition Value.cpp:69
Value * find(const std::string &key) noexcept
Return an object member, or nullptr when absent.
Definition Value.cpp:124
eve::Result< std::string > checkpointJson() const
Capture this actor at a persistent safe checkpoint.
Definition RPGActorPersistence.cpp:20
eve::Result< void > restoreCheckpointJson(std::string_view json)
Validate and atomically restore a safe checkpoint into this preconfigured actor.
Definition RPGActorPersistence.cpp:204
static const SkillDefinition * find(const std::string &id)
Find a registered skill definition by id.
Definition Skill.cpp:90
@ InvalidArgument
@ NotFound
@ UnknownVersion
@ PreconditionViolation
@ ParseError
@ Conflict
@ Applied