@sharpee/character 0.9.106 → 0.9.107
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/apply.d.ts +29 -7
- package/apply.d.ts.map +1 -1
- package/apply.js +15 -7
- package/apply.js.map +1 -1
- package/character-builder.d.ts +67 -4
- package/character-builder.d.ts.map +1 -1
- package/character-builder.js +116 -7
- package/character-builder.js.map +1 -1
- package/conversation/acl.d.ts +62 -0
- package/conversation/acl.d.ts.map +1 -0
- package/conversation/acl.js +117 -0
- package/conversation/acl.js.map +1 -0
- package/conversation/builder.d.ts +247 -0
- package/conversation/builder.d.ts.map +1 -0
- package/conversation/builder.js +324 -0
- package/conversation/builder.js.map +1 -0
- package/conversation/constraint-evaluator.d.ts +147 -0
- package/conversation/constraint-evaluator.d.ts.map +1 -0
- package/conversation/constraint-evaluator.js +247 -0
- package/conversation/constraint-evaluator.js.map +1 -0
- package/conversation/conversation-messages.d.ts +56 -0
- package/conversation/conversation-messages.d.ts.map +1 -0
- package/conversation/conversation-messages.js +69 -0
- package/conversation/conversation-messages.js.map +1 -0
- package/conversation/dialogue-extension.d.ts +87 -0
- package/conversation/dialogue-extension.d.ts.map +1 -0
- package/conversation/dialogue-extension.js +302 -0
- package/conversation/dialogue-extension.js.map +1 -0
- package/conversation/dialogue-types.d.ts +71 -0
- package/conversation/dialogue-types.d.ts.map +1 -0
- package/conversation/dialogue-types.js +13 -0
- package/conversation/dialogue-types.js.map +1 -0
- package/conversation/index.d.ts +19 -0
- package/conversation/index.d.ts.map +1 -0
- package/conversation/index.js +37 -0
- package/conversation/index.js.map +1 -0
- package/conversation/lifecycle.d.ts +212 -0
- package/conversation/lifecycle.d.ts.map +1 -0
- package/conversation/lifecycle.js +348 -0
- package/conversation/lifecycle.js.map +1 -0
- package/conversation/response-types.d.ts +98 -0
- package/conversation/response-types.d.ts.map +1 -0
- package/conversation/response-types.js +30 -0
- package/conversation/response-types.js.map +1 -0
- package/conversation/topic-registry.d.ts +130 -0
- package/conversation/topic-registry.d.ts.map +1 -0
- package/conversation/topic-registry.js +187 -0
- package/conversation/topic-registry.js.map +1 -0
- package/goals/builder.d.ts +135 -0
- package/goals/builder.d.ts.map +1 -0
- package/goals/builder.js +193 -0
- package/goals/builder.js.map +1 -0
- package/goals/goal-activation.d.ts +99 -0
- package/goals/goal-activation.d.ts.map +1 -0
- package/goals/goal-activation.js +212 -0
- package/goals/goal-activation.js.map +1 -0
- package/goals/goal-types.d.ts +138 -0
- package/goals/goal-types.d.ts.map +1 -0
- package/goals/goal-types.js +20 -0
- package/goals/goal-types.js.map +1 -0
- package/goals/index.d.ts +15 -0
- package/goals/index.d.ts.map +1 -0
- package/goals/index.js +24 -0
- package/goals/index.js.map +1 -0
- package/goals/pathfinding.d.ts +67 -0
- package/goals/pathfinding.d.ts.map +1 -0
- package/goals/pathfinding.js +134 -0
- package/goals/pathfinding.js.map +1 -0
- package/goals/step-evaluator.d.ts +52 -0
- package/goals/step-evaluator.d.ts.map +1 -0
- package/goals/step-evaluator.js +153 -0
- package/goals/step-evaluator.js.map +1 -0
- package/index.d.ts +6 -1
- package/index.d.ts.map +1 -1
- package/index.js +60 -1
- package/index.js.map +1 -1
- package/influence/builder.d.ts +136 -0
- package/influence/builder.d.ts.map +1 -0
- package/influence/builder.js +198 -0
- package/influence/builder.js.map +1 -0
- package/influence/index.d.ts +16 -0
- package/influence/index.d.ts.map +1 -0
- package/influence/index.js +25 -0
- package/influence/index.js.map +1 -0
- package/influence/influence-duration.d.ts +82 -0
- package/influence/influence-duration.d.ts.map +1 -0
- package/influence/influence-duration.js +148 -0
- package/influence/influence-duration.js.map +1 -0
- package/influence/influence-evaluator.d.ts +55 -0
- package/influence/influence-evaluator.d.ts.map +1 -0
- package/influence/influence-evaluator.js +183 -0
- package/influence/influence-evaluator.js.map +1 -0
- package/influence/influence-messages.d.ts +30 -0
- package/influence/influence-messages.d.ts.map +1 -0
- package/influence/influence-messages.js +40 -0
- package/influence/influence-messages.js.map +1 -0
- package/influence/influence-types.d.ts +123 -0
- package/influence/influence-types.d.ts.map +1 -0
- package/influence/influence-types.js +12 -0
- package/influence/influence-types.js.map +1 -0
- package/influence/pc-influence.d.ts +38 -0
- package/influence/pc-influence.d.ts.map +1 -0
- package/influence/pc-influence.js +56 -0
- package/influence/pc-influence.js.map +1 -0
- package/package.json +4 -3
- package/propagation/builder.d.ts +47 -0
- package/propagation/builder.d.ts.map +1 -0
- package/propagation/builder.js +46 -0
- package/propagation/builder.js.map +1 -0
- package/propagation/fact-transfer.d.ts +47 -0
- package/propagation/fact-transfer.d.ts.map +1 -0
- package/propagation/fact-transfer.js +76 -0
- package/propagation/fact-transfer.js.map +1 -0
- package/propagation/index.d.ts +16 -0
- package/propagation/index.d.ts.map +1 -0
- package/propagation/index.js +28 -0
- package/propagation/index.js.map +1 -0
- package/propagation/propagation-evaluator.d.ts +53 -0
- package/propagation/propagation-evaluator.d.ts.map +1 -0
- package/propagation/propagation-evaluator.js +231 -0
- package/propagation/propagation-evaluator.js.map +1 -0
- package/propagation/propagation-messages.d.ts +30 -0
- package/propagation/propagation-messages.d.ts.map +1 -0
- package/propagation/propagation-messages.js +37 -0
- package/propagation/propagation-messages.js.map +1 -0
- package/propagation/propagation-types.d.ts +100 -0
- package/propagation/propagation-types.d.ts.map +1 -0
- package/propagation/propagation-types.js +68 -0
- package/propagation/propagation-types.js.map +1 -0
- package/propagation/visibility.d.ts +46 -0
- package/propagation/visibility.d.ts.map +1 -0
- package/propagation/visibility.js +79 -0
- package/propagation/visibility.js.map +1 -0
- package/tick-phases.d.ts +93 -0
- package/tick-phases.d.ts.map +1 -0
- package/tick-phases.js +433 -0
- package/tick-phases.js.map +1 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Information propagation types (ADR-144)
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for NPC-to-NPC information flow: propagation
|
|
5
|
+
* profiles, audience/tendency/pace/coloring vocabularies, per-fact
|
|
6
|
+
* overrides, and transfer records.
|
|
7
|
+
*
|
|
8
|
+
* Public interface: All exported types.
|
|
9
|
+
* Owner context: @sharpee/character / propagation
|
|
10
|
+
*/
|
|
11
|
+
/** How freely the NPC shares information. */
|
|
12
|
+
export type PropagationTendency = 'chatty' | 'selective' | 'mute';
|
|
13
|
+
/** Who the NPC shares with. */
|
|
14
|
+
export type PropagationAudience = 'trusted' | 'anyone' | 'allied';
|
|
15
|
+
/** How quickly the NPC shares when conditions are met. */
|
|
16
|
+
export type PropagationPace = 'eager' | 'gradual' | 'reluctant';
|
|
17
|
+
/** Tone of the telling — hint to the language layer for variant selection. */
|
|
18
|
+
export type PropagationColoring = 'neutral' | 'dramatic' | 'vague' | 'fearful' | 'conspiratorial';
|
|
19
|
+
/** How the NPC receives information from others. */
|
|
20
|
+
export type ReceivesAs = 'as fact' | 'as belief';
|
|
21
|
+
/** Which version of a fact the NPC spreads. */
|
|
22
|
+
export type SpreadsVersion = 'truth' | 'lie';
|
|
23
|
+
/** Per-fact override for propagation behavior. */
|
|
24
|
+
export interface FactOverride {
|
|
25
|
+
/** Override audience for this specific fact. */
|
|
26
|
+
to?: PropagationAudience;
|
|
27
|
+
/** Override which version to spread (truth or the lie told). */
|
|
28
|
+
spreadsVersion?: SpreadsVersion;
|
|
29
|
+
/** Override witnessed message for this fact when player is present. */
|
|
30
|
+
witnessed?: string;
|
|
31
|
+
}
|
|
32
|
+
/** When/where propagation happens. */
|
|
33
|
+
export interface PropagationSchedule {
|
|
34
|
+
/** Predicate conditions that must be satisfied. */
|
|
35
|
+
when: string[];
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Per-NPC propagation behavior definition.
|
|
39
|
+
* Controls who the NPC talks to, what they share, when, and how.
|
|
40
|
+
*/
|
|
41
|
+
export interface PropagationProfile {
|
|
42
|
+
/** How freely the NPC shares. */
|
|
43
|
+
tendency: PropagationTendency;
|
|
44
|
+
/** Who the NPC shares with (default: 'trusted'). */
|
|
45
|
+
audience?: PropagationAudience;
|
|
46
|
+
/** NPC IDs explicitly excluded from sharing. */
|
|
47
|
+
excludes?: string[];
|
|
48
|
+
/** Topics the chatty NPC withholds (blacklist for chatty tendency). */
|
|
49
|
+
withholds?: string[];
|
|
50
|
+
/** Topics the selective NPC will share (whitelist for selective tendency). */
|
|
51
|
+
spreads?: string[];
|
|
52
|
+
/** Per-fact overrides. */
|
|
53
|
+
overrides?: Record<string, FactOverride>;
|
|
54
|
+
/** How quickly facts are shared (default: 'eager'). */
|
|
55
|
+
pace?: PropagationPace;
|
|
56
|
+
/** Optional scheduling conditions. */
|
|
57
|
+
schedule?: PropagationSchedule;
|
|
58
|
+
/** Tone of the telling (default: 'neutral'). */
|
|
59
|
+
coloring?: PropagationColoring;
|
|
60
|
+
/** Whether the player can use this NPC as a messenger (default: false). */
|
|
61
|
+
playerCanLeverage?: boolean;
|
|
62
|
+
/** How the NPC treats received information (default: 'as fact'). */
|
|
63
|
+
receives?: ReceivesAs;
|
|
64
|
+
}
|
|
65
|
+
/** A single pending propagation transfer. */
|
|
66
|
+
export interface PropagationTransfer {
|
|
67
|
+
/** The speaking NPC's entity ID. */
|
|
68
|
+
speakerId: string;
|
|
69
|
+
/** The listening NPC's entity ID. */
|
|
70
|
+
listenerId: string;
|
|
71
|
+
/** The topic being shared. */
|
|
72
|
+
topic: string;
|
|
73
|
+
/** Which version is being shared. */
|
|
74
|
+
version: SpreadsVersion;
|
|
75
|
+
/** The speaker's coloring for this transfer. */
|
|
76
|
+
coloring: PropagationColoring;
|
|
77
|
+
/** Per-fact witnessed message override, if any. */
|
|
78
|
+
witnessedOverride?: string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Tracks which facts an NPC has already told to each listener.
|
|
82
|
+
* Prevents repeated sharing of the same fact to the same NPC.
|
|
83
|
+
*/
|
|
84
|
+
export declare class AlreadyToldRecord {
|
|
85
|
+
/** speakerId → listenerId → Set of topic names */
|
|
86
|
+
private readonly records;
|
|
87
|
+
/**
|
|
88
|
+
* Check if a speaker has already told a listener about a topic.
|
|
89
|
+
*/
|
|
90
|
+
hasTold(speakerId: string, listenerId: string, topic: string): boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Record that a speaker told a listener about a topic.
|
|
93
|
+
*/
|
|
94
|
+
record(speakerId: string, listenerId: string, topic: string): void;
|
|
95
|
+
/** Export for serialization. */
|
|
96
|
+
toJSON(): Record<string, Record<string, string[]>>;
|
|
97
|
+
/** Restore from serialized data. */
|
|
98
|
+
static fromJSON(data: Record<string, Record<string, string[]>>): AlreadyToldRecord;
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=propagation-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"propagation-types.d.ts","sourceRoot":"","sources":["../../../../../../repos/sharpee/packages/character/src/propagation/propagation-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAMH,6CAA6C;AAC7C,MAAM,MAAM,mBAAmB,GAAG,QAAQ,GAAG,WAAW,GAAG,MAAM,CAAC;AAElE,+BAA+B;AAC/B,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAElE,0DAA0D;AAC1D,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,SAAS,GAAG,WAAW,CAAC;AAEhE,8EAA8E;AAC9E,MAAM,MAAM,mBAAmB,GAC3B,SAAS,GACT,UAAU,GACV,OAAO,GACP,SAAS,GACT,gBAAgB,CAAC;AAErB,oDAAoD;AACpD,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,WAAW,CAAC;AAEjD,+CAA+C;AAC/C,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,KAAK,CAAC;AAM7C,kDAAkD;AAClD,MAAM,WAAW,YAAY;IAC3B,gDAAgD;IAChD,EAAE,CAAC,EAAE,mBAAmB,CAAC;IAEzB,gEAAgE;IAChE,cAAc,CAAC,EAAE,cAAc,CAAC;IAEhC,uEAAuE;IACvE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AAoD;IAE5E;;OAEG;IACH,OAAO,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO;IAItE;;OAEG;IACH,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAclE,gCAAgC;IAChC,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAWlD,oCAAoC;IACpC,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,GAAG,iBAAiB;CAWnF"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Information propagation types (ADR-144)
|
|
4
|
+
*
|
|
5
|
+
* Type definitions for NPC-to-NPC information flow: propagation
|
|
6
|
+
* profiles, audience/tendency/pace/coloring vocabularies, per-fact
|
|
7
|
+
* overrides, and transfer records.
|
|
8
|
+
*
|
|
9
|
+
* Public interface: All exported types.
|
|
10
|
+
* Owner context: @sharpee/character / propagation
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.AlreadyToldRecord = void 0;
|
|
14
|
+
/**
|
|
15
|
+
* Tracks which facts an NPC has already told to each listener.
|
|
16
|
+
* Prevents repeated sharing of the same fact to the same NPC.
|
|
17
|
+
*/
|
|
18
|
+
class AlreadyToldRecord {
|
|
19
|
+
/** speakerId → listenerId → Set of topic names */
|
|
20
|
+
records = new Map();
|
|
21
|
+
/**
|
|
22
|
+
* Check if a speaker has already told a listener about a topic.
|
|
23
|
+
*/
|
|
24
|
+
hasTold(speakerId, listenerId, topic) {
|
|
25
|
+
return this.records.get(speakerId)?.get(listenerId)?.has(topic) ?? false;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Record that a speaker told a listener about a topic.
|
|
29
|
+
*/
|
|
30
|
+
record(speakerId, listenerId, topic) {
|
|
31
|
+
let speakerRecord = this.records.get(speakerId);
|
|
32
|
+
if (!speakerRecord) {
|
|
33
|
+
speakerRecord = new Map();
|
|
34
|
+
this.records.set(speakerId, speakerRecord);
|
|
35
|
+
}
|
|
36
|
+
let listenerSet = speakerRecord.get(listenerId);
|
|
37
|
+
if (!listenerSet) {
|
|
38
|
+
listenerSet = new Set();
|
|
39
|
+
speakerRecord.set(listenerId, listenerSet);
|
|
40
|
+
}
|
|
41
|
+
listenerSet.add(topic);
|
|
42
|
+
}
|
|
43
|
+
/** Export for serialization. */
|
|
44
|
+
toJSON() {
|
|
45
|
+
const result = {};
|
|
46
|
+
for (const [speakerId, listenerMap] of this.records) {
|
|
47
|
+
result[speakerId] = {};
|
|
48
|
+
for (const [listenerId, topics] of listenerMap) {
|
|
49
|
+
result[speakerId][listenerId] = Array.from(topics);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return result;
|
|
53
|
+
}
|
|
54
|
+
/** Restore from serialized data. */
|
|
55
|
+
static fromJSON(data) {
|
|
56
|
+
const record = new AlreadyToldRecord();
|
|
57
|
+
for (const [speakerId, listeners] of Object.entries(data)) {
|
|
58
|
+
for (const [listenerId, topics] of Object.entries(listeners)) {
|
|
59
|
+
for (const topic of topics) {
|
|
60
|
+
record.record(speakerId, listenerId, topic);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return record;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.AlreadyToldRecord = AlreadyToldRecord;
|
|
68
|
+
//# sourceMappingURL=propagation-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"propagation-types.js","sourceRoot":"","sources":["../../../../../../../repos/sharpee/packages/character/src/propagation/propagation-types.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG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AAI,CAAC,MAAM,CAAC,CAAC;YACrD,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,oCAAoC;IACpC,MAAM,CAAC,QAAQ,CAAC,IAA8C;QAC5D,MAAM,MAAM,GAAG,IAAI,iBAAiB,EAAE,CAAC;QACvC,KAAK,MAAM,CAAC,SAAS,EAAE,SAAS,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1D,KAAK,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;gBAC7D,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;oBAC3B,MAAM,CAAC,MAAM,CAAC,SAAS,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC;gBAC9C,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AApDD,8CAoDC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Propagation visibility (ADR-144)
|
|
3
|
+
*
|
|
4
|
+
* Determines what the player sees when NPC-to-NPC information
|
|
5
|
+
* transfer occurs. Three modes: offscreen (absent), witnessed
|
|
6
|
+
* (present), eavesdropped (concealed).
|
|
7
|
+
*
|
|
8
|
+
* Public interface: PropagationVisibility, getVisibilityMessage.
|
|
9
|
+
* Owner context: @sharpee/character / propagation
|
|
10
|
+
*/
|
|
11
|
+
import { PropagationTransfer, PropagationColoring } from './propagation-types';
|
|
12
|
+
/** The player's presence state relative to the propagation event. */
|
|
13
|
+
export type PlayerPresence = 'absent' | 'present' | 'concealed';
|
|
14
|
+
/** The visibility output for a single propagation transfer. */
|
|
15
|
+
export interface PropagationVisibilityResult {
|
|
16
|
+
/** The transfer this result is for. */
|
|
17
|
+
transfer: PropagationTransfer;
|
|
18
|
+
/** The player's presence state. */
|
|
19
|
+
presence: PlayerPresence;
|
|
20
|
+
/** Message ID to emit (undefined if offscreen). */
|
|
21
|
+
messageId?: string;
|
|
22
|
+
/** Whether the player gains the fact with source 'overheard'. */
|
|
23
|
+
playerLearns: boolean;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Platform default witnessed message IDs per coloring.
|
|
27
|
+
* Authors override per fact via FactOverride.witnessed.
|
|
28
|
+
*/
|
|
29
|
+
export declare const PROPAGATION_WITNESSED_DEFAULTS: Record<PropagationColoring, string>;
|
|
30
|
+
/**
|
|
31
|
+
* Determine visibility output for a propagation transfer.
|
|
32
|
+
*
|
|
33
|
+
* @param transfer - The propagation transfer
|
|
34
|
+
* @param presence - The player's presence state
|
|
35
|
+
* @returns Visibility result with message ID and player-learns flag
|
|
36
|
+
*/
|
|
37
|
+
export declare function getVisibilityResult(transfer: PropagationTransfer, presence: PlayerPresence): PropagationVisibilityResult;
|
|
38
|
+
/**
|
|
39
|
+
* Evaluate visibility for multiple transfers.
|
|
40
|
+
*
|
|
41
|
+
* @param transfers - The transfers to evaluate
|
|
42
|
+
* @param presence - The player's presence state
|
|
43
|
+
* @returns Array of visibility results
|
|
44
|
+
*/
|
|
45
|
+
export declare function getVisibilityResults(transfers: PropagationTransfer[], presence: PlayerPresence): PropagationVisibilityResult[];
|
|
46
|
+
//# sourceMappingURL=visibility.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visibility.d.ts","sourceRoot":"","sources":["../../../../../../repos/sharpee/packages/character/src/propagation/visibility.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAM/E,qEAAqE;AACrE,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,SAAS,GAAG,WAAW,CAAC;AAMhE,+DAA+D;AAC/D,MAAM,WAAW,2BAA2B;IAC1C,uCAAuC;IACvC,QAAQ,EAAE,mBAAmB,CAAC;IAE9B,mCAAmC;IACnC,QAAQ,EAAE,cAAc,CAAC;IAEzB,mDAAmD;IACnD,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,iEAAiE;IACjE,YAAY,EAAE,OAAO,CAAC;CACvB;AAMD;;;GAGG;AACH,eAAO,MAAM,8BAA8B,EAAE,MAAM,CAAC,mBAAmB,EAAE,MAAM,CAM9E,CAAC;AAMF;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,mBAAmB,EAC7B,QAAQ,EAAE,cAAc,GACvB,2BAA2B,CA8B7B;AAED;;;;;;GAMG;AACH,wBAAgB,oBAAoB,CAClC,SAAS,EAAE,mBAAmB,EAAE,EAChC,QAAQ,EAAE,cAAc,GACvB,2BAA2B,EAAE,CAE/B"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Propagation visibility (ADR-144)
|
|
4
|
+
*
|
|
5
|
+
* Determines what the player sees when NPC-to-NPC information
|
|
6
|
+
* transfer occurs. Three modes: offscreen (absent), witnessed
|
|
7
|
+
* (present), eavesdropped (concealed).
|
|
8
|
+
*
|
|
9
|
+
* Public interface: PropagationVisibility, getVisibilityMessage.
|
|
10
|
+
* Owner context: @sharpee/character / propagation
|
|
11
|
+
*/
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.PROPAGATION_WITNESSED_DEFAULTS = void 0;
|
|
14
|
+
exports.getVisibilityResult = getVisibilityResult;
|
|
15
|
+
exports.getVisibilityResults = getVisibilityResults;
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
// Platform defaults per coloring
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
/**
|
|
20
|
+
* Platform default witnessed message IDs per coloring.
|
|
21
|
+
* Authors override per fact via FactOverride.witnessed.
|
|
22
|
+
*/
|
|
23
|
+
exports.PROPAGATION_WITNESSED_DEFAULTS = {
|
|
24
|
+
neutral: 'character.propagation.witnessed.neutral',
|
|
25
|
+
dramatic: 'character.propagation.witnessed.dramatic',
|
|
26
|
+
vague: 'character.propagation.witnessed.vague',
|
|
27
|
+
fearful: 'character.propagation.witnessed.fearful',
|
|
28
|
+
conspiratorial: 'character.propagation.witnessed.conspiratorial',
|
|
29
|
+
};
|
|
30
|
+
// ---------------------------------------------------------------------------
|
|
31
|
+
// Visibility evaluation
|
|
32
|
+
// ---------------------------------------------------------------------------
|
|
33
|
+
/**
|
|
34
|
+
* Determine visibility output for a propagation transfer.
|
|
35
|
+
*
|
|
36
|
+
* @param transfer - The propagation transfer
|
|
37
|
+
* @param presence - The player's presence state
|
|
38
|
+
* @returns Visibility result with message ID and player-learns flag
|
|
39
|
+
*/
|
|
40
|
+
function getVisibilityResult(transfer, presence) {
|
|
41
|
+
switch (presence) {
|
|
42
|
+
case 'absent':
|
|
43
|
+
// Offscreen — state mutation only, no message
|
|
44
|
+
return {
|
|
45
|
+
transfer,
|
|
46
|
+
presence,
|
|
47
|
+
playerLearns: false,
|
|
48
|
+
};
|
|
49
|
+
case 'present':
|
|
50
|
+
// Witnessed — player sees a summary message
|
|
51
|
+
return {
|
|
52
|
+
transfer,
|
|
53
|
+
presence,
|
|
54
|
+
messageId: transfer.witnessedOverride
|
|
55
|
+
?? exports.PROPAGATION_WITNESSED_DEFAULTS[transfer.coloring],
|
|
56
|
+
playerLearns: false,
|
|
57
|
+
};
|
|
58
|
+
case 'concealed':
|
|
59
|
+
// Eavesdropped — player sees full dialogue and learns the fact
|
|
60
|
+
return {
|
|
61
|
+
transfer,
|
|
62
|
+
presence,
|
|
63
|
+
messageId: transfer.witnessedOverride
|
|
64
|
+
?? exports.PROPAGATION_WITNESSED_DEFAULTS[transfer.coloring],
|
|
65
|
+
playerLearns: true,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Evaluate visibility for multiple transfers.
|
|
71
|
+
*
|
|
72
|
+
* @param transfers - The transfers to evaluate
|
|
73
|
+
* @param presence - The player's presence state
|
|
74
|
+
* @returns Array of visibility results
|
|
75
|
+
*/
|
|
76
|
+
function getVisibilityResults(transfers, presence) {
|
|
77
|
+
return transfers.map(t => getVisibilityResult(t, presence));
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=visibility.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visibility.js","sourceRoot":"","sources":["../../../../../../../repos/sharpee/packages/character/src/propagation/visibility.ts"],"names":[],"mappings":";AAAA;;;;;;;;;GASG;;;AAyDH,kDAiCC;AASD,oDAKC;AA1ED,8EAA8E;AAC9E,iCAAiC;AACjC,8EAA8E;AAE9E;;;GAGG;AACU,QAAA,8BAA8B,GAAwC;IACjF,OAAO,EAAS,yCAAyC;IACzD,QAAQ,EAAQ,0CAA0C;IAC1D,KAAK,EAAW,uCAAuC;IACvD,OAAO,EAAS,yCAAyC;IACzD,cAAc,EAAE,gDAAgD;CACjE,CAAC;AAEF,8EAA8E;AAC9E,wBAAwB;AACxB,8EAA8E;AAE9E;;;;;;GAMG;AACH,SAAgB,mBAAmB,CACjC,QAA6B,EAC7B,QAAwB;IAExB,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,QAAQ;YACX,8CAA8C;YAC9C,OAAO;gBACL,QAAQ;gBACR,QAAQ;gBACR,YAAY,EAAE,KAAK;aACpB,CAAC;QAEJ,KAAK,SAAS;YACZ,4CAA4C;YAC5C,OAAO;gBACL,QAAQ;gBACR,QAAQ;gBACR,SAAS,EAAE,QAAQ,CAAC,iBAAiB;uBAChC,sCAA8B,CAAC,QAAQ,CAAC,QAAQ,CAAC;gBACtD,YAAY,EAAE,KAAK;aACpB,CAAC;QAEJ,KAAK,WAAW;YACd,+DAA+D;YAC/D,OAAO;gBACL,QAAQ;gBACR,QAAQ;gBACR,SAAS,EAAE,QAAQ,CAAC,iBAAiB;uBAChC,sCAA8B,CAAC,QAAQ,CAAC,QAAQ,CAAC;gBACtD,YAAY,EAAE,IAAI;aACnB,CAAC;IACN,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,oBAAoB,CAClC,SAAgC,EAChC,QAAwB;IAExB,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,mBAAmB,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC;AAC9D,CAAC"}
|
package/tick-phases.d.ts
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* NPC tick phase implementations (ADR-144, 145, 146)
|
|
3
|
+
*
|
|
4
|
+
* Factory functions that create tick phase handlers for propagation,
|
|
5
|
+
* goal pursuit, and influence evaluation. Register these with
|
|
6
|
+
* NpcService.registerTickPhase() during story initialization.
|
|
7
|
+
*
|
|
8
|
+
* Public interface: createPropagationPhase, createGoalPhase,
|
|
9
|
+
* createInfluencePhase, CharacterPhaseConfig.
|
|
10
|
+
* Owner context: @sharpee/character
|
|
11
|
+
*/
|
|
12
|
+
import { ISemanticEvent, EntityId } from "../core/index";
|
|
13
|
+
import { IFEntity, WorldModel } from "../world-model/index";
|
|
14
|
+
import { PropagationProfile, AlreadyToldRecord } from './propagation';
|
|
15
|
+
import { GoalDef, MovementProfile, GoalManager } from './goals';
|
|
16
|
+
import { InfluenceDef, ResistanceDef, InfluenceTracker } from './influence';
|
|
17
|
+
/** Tick context — mirrors NpcTickContext from stdlib. */
|
|
18
|
+
interface TickContext {
|
|
19
|
+
world: WorldModel;
|
|
20
|
+
turn: number;
|
|
21
|
+
random: unknown;
|
|
22
|
+
playerLocation: EntityId;
|
|
23
|
+
playerId: EntityId;
|
|
24
|
+
}
|
|
25
|
+
/** Per-NPC character configuration for tick phases. */
|
|
26
|
+
export interface CharacterPhaseConfig {
|
|
27
|
+
propagationProfile?: PropagationProfile;
|
|
28
|
+
goalDefs?: GoalDef[];
|
|
29
|
+
movementProfile?: MovementProfile;
|
|
30
|
+
influenceDefs?: InfluenceDef[];
|
|
31
|
+
resistanceDefs?: ResistanceDef[];
|
|
32
|
+
}
|
|
33
|
+
/** Manages per-NPC configs and shared state for tick phases. */
|
|
34
|
+
export declare class CharacterPhaseRegistry {
|
|
35
|
+
private readonly configs;
|
|
36
|
+
private readonly goalManagers;
|
|
37
|
+
readonly influenceTracker: InfluenceTracker;
|
|
38
|
+
readonly alreadyToldRecord: AlreadyToldRecord;
|
|
39
|
+
/**
|
|
40
|
+
* Register character configuration for an NPC.
|
|
41
|
+
*
|
|
42
|
+
* @param entityId - NPC entity ID
|
|
43
|
+
* @param config - Configuration from AppliedCharacter
|
|
44
|
+
*/
|
|
45
|
+
register(entityId: string, config: CharacterPhaseConfig): void;
|
|
46
|
+
/** Get config for an NPC. */
|
|
47
|
+
getConfig(entityId: string): CharacterPhaseConfig | undefined;
|
|
48
|
+
/** Get goal manager for an NPC. */
|
|
49
|
+
getGoalManager(entityId: string): GoalManager | undefined;
|
|
50
|
+
/** Check if any NPCs have been registered. */
|
|
51
|
+
get hasConfigs(): boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Export serializable state for save/restore.
|
|
54
|
+
* Configs are authored (re-registered on load), so only mutable state is saved.
|
|
55
|
+
*/
|
|
56
|
+
toJSON(): {
|
|
57
|
+
goalStates: Record<string, ReturnType<GoalManager['toJSON']>>;
|
|
58
|
+
influenceEffects: ReturnType<InfluenceTracker['toJSON']>;
|
|
59
|
+
alreadyTold: ReturnType<AlreadyToldRecord['toJSON']>;
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Restore mutable state from saved data.
|
|
63
|
+
* Call after re-registering all NPC configs.
|
|
64
|
+
*/
|
|
65
|
+
restoreState(saved: {
|
|
66
|
+
goalStates?: Record<string, ReturnType<GoalManager['toJSON']>>;
|
|
67
|
+
influenceEffects?: ReturnType<InfluenceTracker['toJSON']>;
|
|
68
|
+
alreadyTold?: ReturnType<AlreadyToldRecord['toJSON']>;
|
|
69
|
+
}): void;
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Create a propagation tick phase handler.
|
|
73
|
+
*
|
|
74
|
+
* @param registry - The character phase registry
|
|
75
|
+
* @returns Tick phase handler function
|
|
76
|
+
*/
|
|
77
|
+
export declare function createPropagationPhase(registry: CharacterPhaseRegistry): (npcs: IFEntity[], ctx: TickContext) => ISemanticEvent[];
|
|
78
|
+
/**
|
|
79
|
+
* Create a goal pursuit tick phase handler.
|
|
80
|
+
*
|
|
81
|
+
* @param registry - The character phase registry
|
|
82
|
+
* @returns Tick phase handler function
|
|
83
|
+
*/
|
|
84
|
+
export declare function createGoalPhase(registry: CharacterPhaseRegistry): (npcs: IFEntity[], ctx: TickContext) => ISemanticEvent[];
|
|
85
|
+
/**
|
|
86
|
+
* Create an influence evaluation tick phase handler.
|
|
87
|
+
*
|
|
88
|
+
* @param registry - The character phase registry
|
|
89
|
+
* @returns Tick phase handler function
|
|
90
|
+
*/
|
|
91
|
+
export declare function createInfluencePhase(registry: CharacterPhaseRegistry): (npcs: IFEntity[], ctx: TickContext) => ISemanticEvent[];
|
|
92
|
+
export {};
|
|
93
|
+
//# sourceMappingURL=tick-phases.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tick-phases.d.ts","sourceRoot":"","sources":["../../../../../repos/sharpee/packages/character/src/tick-phases.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,EACL,QAAQ,EACR,UAAU,EAKX,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,kBAAkB,EAMlB,iBAAiB,EAClB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,OAAO,EACP,eAAe,EACf,WAAW,EAIZ,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,YAAY,EACZ,aAAa,EAIb,gBAAgB,EACjB,MAAM,aAAa,CAAC;AAMrB,yDAAyD;AACzD,UAAU,WAAW;IACnB,KAAK,EAAE,UAAU,CAAC;I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