载入中...
搜索中...
未找到
SettlementModule.cpp
浏览该文件的文档.
43bool isLedgerKind(std::string_view kind) noexcept { return isCreditKind(kind) || isDebitKind(kind); }
50 if (!(state_.current >= 0.0) || !(state_.current <= state_.maximum) || !(state_.maximum >= 0.0) ||
77 return Result<PreparedApply>::failure(Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,
130 Result<Value> upsertResource(const std::string& subject, const std::string& resource, double current,
137 if (resource.empty() || !std::isfinite(current) || !std::isfinite(maximum) || maximum < 0.0 || current < 0.0 ||
187 Result<Value> settle(const std::string& sourceText, const std::string& targetText, const std::string& kind,
200 if (kind.empty() || resource.empty() || !std::isfinite(magnitude) || magnitude < 0.0 || tick < 0)
204 if (!isLedgerKind(kind)) return Result<Value>::failure(Result<void>::failure(Diagnostic::error(DiagnosticCode::InvalidArgument,
275 auto object = script::makeOwnedSquirrelInstance<ScriptSettlementRuntime>(vm, std::move(runtime));
292 runtime.addFunc("configureRulesJson", [vm](ScriptSettlementRuntime* self, const std::string& json) {
295 runtime.addFunc("validateRulesJson", [vm](ScriptSettlementRuntime* self, const std::string& json) {
306 runtime.addFunc("upsertResource", [vm](ScriptSettlementRuntime* self, const std::string& subject,
308 return self ? project(vm, self->upsertResource(subject, resource, current, maximum)) : nullRuntime(vm);
314 runtime.addFunc("removeResource", [vm](ScriptSettlementRuntime* self, const std::string& subject,
321 runtime.addFunc("settle", [vm](ScriptSettlementRuntime* self, const std::string& source, const std::string& target,
324 return self ? project(vm, self->settle(source, target, kind, resource, magnitude, tagsCsv, contextJson, tick))
Strong identity values shared by persistence, content and logical-name APIs.
Script-facing factory for settlement rule + ledger runtimes.
Declarative, domain-neutral rules for buffs and gameplay effects.
Injectable content-digest provider for snapshots, with an honest default.
The single Squirrel projection for common Result, Status and Value.
Explicit Value/Owned/Borrowed semantics at the Squirrel boundary.
Stable reference to a runtime gameplay subject.
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
static SubjectRef fromPersistentId(PersistentId id) noexcept
Wrap a persistent identity without changing its bytes.
Definition SubjectRef.h:32
static Result< Value > fromJson(std::string_view json)
Parse one strict JSON value into an owning Value.
Definition Value.cpp:57
static std::optional< Id128 > parse(std::string_view text) noexcept
Parses canonical UUID text.
Definition Identity.h:151
static eve::Result< SettlementRuleSet > fromJson(std::string_view json)
Decode and compile a strict versioned JSON rule document without mutating an existing rule set.
Definition SettlementRuleJson.cpp:165
Factory module for script-owned settlement protocol runtimes.
Definition SettlementModule.h:18
std::variant< std::monostate, std::int64_t, double, std::string, bool > Value
Definition Database.h:26
ssq::Table project(HSQUIRRELVM vm, const eve::Result< void > &result)
Project a completed editing result that has no payload.
Definition EditorScriptProjection.h:28
ssq::Table projectStatusResult(HSQUIRRELVM vm, const Status &status)
Project a checked native status that carries no payload.
Definition SquirrelBinding.cpp:454
ssq::Table projectResult(HSQUIRRELVM vm, Result< void > &&result)
Consume and project a void native Result using the common schema.
Definition SquirrelBinding.cpp:470
Definition Settlement.cpp:10
const char * settlementDispositionName(SettlementDisposition disposition) noexcept
Return the stable lowercase spelling of a settlement disposition.
Definition Settlement.cpp:256
EVENGINE_API_FOUNDATION eve::Result< std::string > settlementResultCanonicalJson(const SettlementResult &result)
Serialize the stable semantic fields of a settlement result as canonical JSON.
Definition SettlementReplay.cpp:550
@ InvalidArgument
@ NotFound
@ InvariantViolation
@ Applied
SnapshotHashProvider snapshotContentHashProvider()
A SnapshotHashProvider backed by the active hasher.
Definition SnapshotHash.cpp:92
detail::StrongUint64< detail::SimulationTickTag > SimulationTick
Deterministic simulation time step; it is not wall-clock time.
Definition Time.h:31
Domain-neutral, deterministic settlement pipeline.