载入中...
搜索中...
未找到
GameplayTag.cpp
浏览该文件的文档.
25const Value* member(const Value& value, std::string_view key) { return value.find(std::string(key)); }
53bool gameplayTagMatches(std::string_view candidate, std::string_view query, GameplayTagMatch match) noexcept {
59Result<GameplayTagId> GameplayTagRegistry::registerTag(std::string name, std::string description) {
67 DiagnosticCode::AlreadyExists, "Gameplay tag is already registered with different metadata", name));
70 if (const auto collision = nameById_.find(id); collision != nameById_.end() && collision->second != name)
82 Diagnostic::error(DiagnosticCode::NotFound, "Gameplay tag is not registered", std::string(name)));
86bool GameplayTagRegistry::contains(std::string_view name) const { return definitionsByName_.contains(name); }
95std::vector<GameplayTagDefinition> GameplayTagRegistry::search(std::string_view text, std::string_view root) const {
99 if (!root.empty() && !gameplayTagMatches(name, root, GameplayTagMatch::IncludeDescendants)) continue;
100 if (!needle.empty() && lower(name + " " + definition.description).find(needle) == std::string::npos) continue;
111 Value::Object{{"description", definition.description}, {"id", idText(definition.id)}, {"name", name}});
114 Value(Value::Object{{"schema", "eve.gameplay-tags"}, {"tags", std::move(tags)}, {"version", 1}}));
120 Diagnostic::error(DiagnosticCode::InvalidArgument, "Gameplay-tag registry must be an object", "$"));
126 Diagnostic::error(DiagnosticCode::InvalidArgument, "Unsupported gameplay-tag schema", "schema"));
129 Diagnostic::error(DiagnosticCode::InvalidArgument, "Unsupported gameplay-tag schema version", "version"));
140 Diagnostic::error(DiagnosticCode::InvalidArgument, "Gameplay-tag entry must be an object", path));
149 DiagnosticCode::InvalidArgument, "Gameplay-tag description must be a string", path + ".description"));
152 DiagnosticCode::InvalidArgument, "Gameplay-tag id does not match its canonical name", path + ".id"));
Stable hierarchical gameplay-tag definitions and registry.
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
const std::string & asString() const
Return the string payload; the caller must have checked the kind.
Definition Value.cpp:87
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
Canonical owner of versioned gameplay-tag definitions.
Definition GameplayTag.h:49
Result< GameplayTagDefinition > find(std::string_view name) const
Find an exact definition and return an owning copy.
Definition GameplayTag.cpp:78
std::vector< GameplayTagDefinition > search(std::string_view text, std::string_view root={}) const
Return definitions matching a root and case-insensitive text filter.
Definition GameplayTag.cpp:95
Result< GameplayTagId > registerTag(std::string name, std::string description={})
Register a definition, returning NoOp for an identical definition.
Definition GameplayTag.cpp:59
Result< Value > toValue() const
Encode schema eve.gameplay-tags version 1. Unknown fields are ignored on load.
Definition GameplayTag.cpp:106
std::vector< GameplayTagDefinition > definitions() const
Return all definitions in lexical name order.
Definition GameplayTag.cpp:88
static Result< GameplayTagRegistry > fromValue(const Value &value)
Transactionally decode schema eve.gameplay-tags version 1.
Definition GameplayTag.cpp:117
bool contains(std::string_view name) const
Return whether an exact definition exists.
Definition GameplayTag.cpp:86
Definition GameplayTag.cpp:9
bool gameplayTagMatches(std::string_view candidate, std::string_view query, GameplayTagMatch match) noexcept
Tests exact or dot-boundary descendant membership.
Definition GameplayTag.cpp:53
bool isValidGameplayTagName(std::string_view name) noexcept
Returns whether a name is a canonical dot-separated gameplay tag.
Definition GameplayTag.cpp:29
@ IncludeDescendants
eve::detail::StrongUint64< GameplayTagIdTag > GameplayTagId
Stable FNV-1a identifier derived from a canonical gameplay-tag name.
Definition GameplayTag.h:20
GameplayTagId gameplayTagId(std::string_view name) noexcept
Computes the stable 64-bit FNV-1a identifier of a canonical name.
Definition GameplayTag.cpp:44
@ InvalidArgument
@ NotFound
@ AlreadyExists
@ Conflict
@ NoOp
@ Applied
An owning gameplay-tag definition shared by runtime and editor tools.
Definition GameplayTag.h:26