feat: implement scoped stat system with player/global support
Introduces a scoping mechanism for statistics, allowing properties to be defined as either "player" (prefixed with player name) or "global". - Adds `scope` property to StatDef - Implements key resolution to handle bare keys vs full keys - Updates `canModifyStat` to enforce player-specific permissions - Enhances `makeStatLookup` to resolve scoped references in formulas - Adds documentation for the new stat system
This commit is contained in:
@@ -43,6 +43,7 @@ export interface StatDef {
|
||||
key: string;
|
||||
label: string;
|
||||
type: "number" | "string" | "enum" | "modifier" | "derived";
|
||||
scope: "player" | "global";
|
||||
default?: string;
|
||||
target?: string;
|
||||
options?: string[];
|
||||
@@ -204,10 +205,12 @@ function parseStatYaml(yaml: string, source: string): StatDef[] {
|
||||
function flushCurrent() {
|
||||
if (!current || !current.key) return;
|
||||
const type = (current.type || "number") as StatDef["type"];
|
||||
const scope = (current.scope || "global") as StatDef["scope"];
|
||||
defs.push({
|
||||
key: current.key,
|
||||
label: current.label || current.key,
|
||||
type,
|
||||
scope,
|
||||
default: current.default,
|
||||
target: current.target,
|
||||
options:
|
||||
|
||||
Reference in New Issue
Block a user