载入中...
搜索中...
未找到
DialogueControl.cpp
浏览该文件的文档.
24 return failure<const Value::Object*>(DiagnosticCode::InvalidArgument, "dialogue parameters must be an object",
29Result<std::string> text(const Value::Object& value, std::string_view name, std::string fallback = {}) {
33 return failure<std::string>(DiagnosticCode::InvalidArgument, "dialogue parameter must be a string",
57 DiagnosticCode::InvalidArgument, "dialogue publication needs valid instance and owner ids", "instance"));
72 Diagnostic::error(DiagnosticCode::NotFound, "that dialogue instance is not published", "instance"));
94 std::find(session.controlledSubjects.begin(), session.controlledSubjects.end(), entry_->owner) !=
125 return failure<GameplayObservation>(DiagnosticCode::NotFound, "dialogue gameplay instance was not found",
139Result<std::vector<GameplayActionDescriptor>> DialogueControl::availableGameplayActions(const GameplaySession& session,
143 if (!observed) return Result<std::vector<GameplayActionDescriptor>>::failure(observed.status());
159void DialogueControl::record(Entry& entry, const GameplayCommand& command, std::string type, std::string detail,
174 {"nodeKind", Value(flow_ != nullptr && flow_->isActive() ? flow_->getNodeKind() : std::string{})}});
178Result<GameplayCommandReceipt> DialogueControl::submitGameplay(const GameplaySession& session, SubjectRef instance,
181 return failure<GameplayCommandReceipt>(DiagnosticCode::NotFound, "dialogue gameplay instance was not found",
187 return failure<GameplayCommandReceipt>(DiagnosticCode::InvalidArgument, "command id must not be empty",
191 DiagnosticCode::Conflict, "dialogue command was based on a stale observation", "command.expectedRevision");
217 return failure<GameplayCommandReceipt>(DiagnosticCode::PreconditionViolation, "no conversation is active",
221 detail = flow_->isActive() ? "advanced to " + flow_->getNodeId() : std::string("conversation finished");
228 return failure<GameplayCommandReceipt>(DiagnosticCode::InvalidArgument, "dialogue:select needs a route id",
231 return failure<GameplayCommandReceipt>(DiagnosticCode::PreconditionViolation, "no conversation is active",
239 return failure<GameplayCommandReceipt>(DiagnosticCode::Unsupported, "unsupported dialogue action",
256 return Result<GameplayCommandReceipt>::success(std::move(receipt), Status::success(StatusCode::Applied));
259Result<GameplayObservation> DialogueControl::advanceGameplay(const GameplaySession& session, SubjectRef instance,
262 return failure<GameplayObservation>(DiagnosticCode::NotFound, "dialogue gameplay instance was not found",
265 return failure<GameplayObservation>(DiagnosticCode::Conflict, "dialogue simulation tick must increase",
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
const std::string & format() const noexcept
Returns the canonical namespace:name representation.
Definition Identity.h:436
static std::optional< LogicalId > parse(std::string_view text)
Parses a scoped logical name.
Definition Identity.cpp:36
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
bool isValid() const noexcept
Return whether this reference is valid and non-nil.
Definition SubjectRef.h:38
Result< std::vector< GameplayEvent > > gameplayEvents(const GameplaySession &session, SubjectRef instance, std::uint64_t afterSequence) const override
Return events strictly newer than an instance-local sequence cursor.
Definition DialogueControl.cpp:273
Result< GameplayCommandReceipt > submitGameplay(const GameplaySession &session, SubjectRef instance, const GameplayCommand &command) override
Validate authority and atomically submit one domain command.
Definition DialogueControl.cpp:178
std::string_view gameplayDomain() const noexcept override
Stable provider domain used for discovery and routing.
Definition DialogueControl.cpp:87
~DialogueControl() override
Unpublish without touching the borrowed runner.
Definition DialogueControl.cpp:49
Result< GameplayObservation > observeGameplay(const GameplaySession &session, SubjectRef instance) const override
Observe one provider-owned gameplay instance without mutation.
Definition DialogueControl.cpp:122
Result< void > publish(SubjectRef instance, SubjectRef owner)
Publish the conversation runner under a stable instance identity.
Definition DialogueControl.cpp:54
std::vector< SubjectRef > instances() const
Published instance identities, in publication order.
Definition DialogueControl.cpp:81
Result< void > unpublish(SubjectRef instance)
Drop the publication; NotFound when that instance is not published.
Definition DialogueControl.cpp:69
std::vector< SubjectRef > gameplayInstances() const override
Instances currently served, in publication order.
Definition DialogueControl.cpp:89
Result< GameplayObservation > advanceGameplay(const GameplaySession &session, SubjectRef instance, const SimulationStep &step) override
Advance one provider-owned instance using injected deterministic time.
Definition DialogueControl.cpp:259
DialogueControl(DialogueFlow &flow)
Create an adapter for one borrowed conversation runner.
Definition DialogueControl.cpp:44
Result< std::vector< GameplayActionDescriptor > > availableGameplayActions(const GameplaySession &session, SubjectRef instance, SubjectRef subject) const override
Discover currently legal player-semantic actions for one subject.
Definition DialogueControl.cpp:139
Script-facing registry and runner for compiled .dnut conversations.
Definition DialogueFlow.h:42
std::string getI18nKey() const
std::string getSpeaker() const
std::string getConversationId(int index) const
Definition DialogueFlow.cpp:742
eve::Result< void > select(const std::string &routeId)
Select a route, atomically applying configured payment/state effects.
Definition DialogueFlow.cpp:891
eve::Result< void > advanceChecked()
Advance the active conversation with a structured runner diagnostic.
Definition DialogueFlow.cpp:881
eve::Result< void > startChecked(const std::string &id, ssq::Object bindings)
Start a conversation after validating script bindings.
Definition DialogueFlow.cpp:859
std::string getRouteId(int index) const
Definition DialogueFlow.cpp:1063
std::string getPool() const
std::string getNodeKind() const
Definition DialogueFlow.cpp:1009
std::variant< std::monostate, std::int64_t, double, std::string, bool > Value
Definition Database.h:26
Definition ConversationAuthoring.cpp:12
@ InvalidArgument
@ NotFound
@ PreconditionViolation
@ Unsupported
@ Conflict
@ NoOp
@ Applied
@ PlayerEquivalent
Definition Container.h:602
Owning evidence that a gameplay authority accepted one command.
Definition GameplayControl.h:62
std::uint64_t resultingRevision
Definition GameplayControl.h:66
One player-semantic command submitted to a domain authority.
Definition GameplayControl.h:52
Owning event projection safe across frames and process boundaries.
Definition GameplayControl.h:71
Immutable owning observation of one authoritative gameplay instance.
Definition GameplayControl.h:43
Owning authorization context shared by player, script and automation adapters.
Definition GameplayControl.h:30