feat(npc-dialogue): opt-in public visibility for event node effects
Dialogue-emitted game events default to restricted (npc:dialogue policy) so narrative branches stay spoilable-free, which also hid announcements authors intended for everyone. Event nodes can now mark their effect's log entry public: NpcDialogueEffect gains an optional eventVisibility field, runEffect threads it into every emitGameEvent call (emit, reward, flag), and the node editor exposes a "Show this event to everyone" checkbox for those effect types. Omitted eventVisibility keeps today's behavior exactly: resolveEventVisibility falls back to the per-type restricted policy. The separate restricted flag:set audit written by the PlayerFlags hooks is untouched. Verified live on dev: two injected event nodes (with and without the flag) stored visibility "public" and "restricted" respectively; flow and probe rows cleaned up afterward.
This commit is contained in:
parent
95a2412206
commit
59f01610ca
3 changed files with 26 additions and 0 deletions
|
|
@ -107,6 +107,9 @@ async function runEffect(
|
||||||
targetCollection: "game-npcs",
|
targetCollection: "game-npcs",
|
||||||
targetId: npcId,
|
targetId: npcId,
|
||||||
data: { effect: "emit" },
|
data: { effect: "emit" },
|
||||||
|
// Author override: "public" puts the entry in every member's feed;
|
||||||
|
// undefined keeps the restricted narrative default (see visibility.ts).
|
||||||
|
visibility: effect.eventVisibility,
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -119,6 +122,7 @@ async function runEffect(
|
||||||
targetCollection: "game-npcs",
|
targetCollection: "game-npcs",
|
||||||
targetId: npcId,
|
targetId: npcId,
|
||||||
data: { effect: "reward", unconfigured: true },
|
data: { effect: "reward", unconfigured: true },
|
||||||
|
visibility: effect.eventVisibility,
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -146,6 +150,7 @@ async function runEffect(
|
||||||
targetCollection: "game-npcs",
|
targetCollection: "game-npcs",
|
||||||
targetId: npcId,
|
targetId: npcId,
|
||||||
data: { effect: "flag", key, op, amount },
|
data: { effect: "flag", key, op, amount },
|
||||||
|
visibility: effect.eventVisibility,
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -663,6 +663,20 @@ export function NodeEditDialog({ node, allNodes, open, onOpenChange, onSave }: N
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
{draft.effect && draft.effect.type !== "notify" && (
|
||||||
|
<label className="flex items-center gap-2 text-xs text-white/60">
|
||||||
|
<Checkbox
|
||||||
|
checked={draft.effect.eventVisibility === "public"}
|
||||||
|
onCheckedChange={(checked) =>
|
||||||
|
// Unset, not "restricted": leaving the key absent keeps the
|
||||||
|
// event on the restricted narrative default in visibility.ts.
|
||||||
|
patchEffect({ eventVisibility: checked === true ? "public" : undefined })
|
||||||
|
}
|
||||||
|
className="border-white/30 data-[state=checked]:border-emerald-500 data-[state=checked]:bg-emerald-500"
|
||||||
|
/>
|
||||||
|
Show this event to everyone (normally staff only)
|
||||||
|
</label>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,13 @@ export interface NpcDialogueEffect {
|
||||||
title?: string;
|
title?: string;
|
||||||
/** Notification / event-log body (notify, emit). */
|
/** Notification / event-log body (notify, emit). */
|
||||||
message?: string;
|
message?: string;
|
||||||
|
/**
|
||||||
|
* Visibility of the game-event-log entry this effect writes (emit, reward,
|
||||||
|
* flag). Dialogue events default to restricted (narrative spoilers), gated
|
||||||
|
* to dialogue/flag staff; set "public" for announcements that should appear
|
||||||
|
* in every member's event feed. Omitted means "use the default policy".
|
||||||
|
*/
|
||||||
|
eventVisibility?: "public" | "restricted";
|
||||||
/** Flag key to write (flag). */
|
/** Flag key to write (flag). */
|
||||||
flagKey?: string;
|
flagKey?: string;
|
||||||
/** Write mode (flag). */
|
/** Write mode (flag). */
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue