@ai-rpg-engine/modules 1.0.0
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/dist/belief-provenance.d.ts +41 -0
- package/dist/belief-provenance.d.ts.map +1 -0
- package/dist/belief-provenance.js +254 -0
- package/dist/belief-provenance.js.map +1 -0
- package/dist/belief-provenance.test.d.ts +2 -0
- package/dist/belief-provenance.test.d.ts.map +1 -0
- package/dist/belief-provenance.test.js +139 -0
- package/dist/belief-provenance.test.js.map +1 -0
- package/dist/cognition-core.d.ts +89 -0
- package/dist/cognition-core.d.ts.map +1 -0
- package/dist/cognition-core.js +370 -0
- package/dist/cognition-core.js.map +1 -0
- package/dist/cognition-core.test.d.ts +2 -0
- package/dist/cognition-core.test.d.ts.map +1 -0
- package/dist/cognition-core.test.js +215 -0
- package/dist/cognition-core.test.js.map +1 -0
- package/dist/combat-core.d.ts +11 -0
- package/dist/combat-core.d.ts.map +1 -0
- package/dist/combat-core.js +152 -0
- package/dist/combat-core.js.map +1 -0
- package/dist/dialogue-core.d.ts +10 -0
- package/dist/dialogue-core.d.ts.map +1 -0
- package/dist/dialogue-core.js +172 -0
- package/dist/dialogue-core.js.map +1 -0
- package/dist/district-core.d.ts +59 -0
- package/dist/district-core.d.ts.map +1 -0
- package/dist/district-core.js +224 -0
- package/dist/district-core.js.map +1 -0
- package/dist/district-core.test.d.ts +2 -0
- package/dist/district-core.test.d.ts.map +1 -0
- package/dist/district-core.test.js +157 -0
- package/dist/district-core.test.js.map +1 -0
- package/dist/environment-core.d.ts +78 -0
- package/dist/environment-core.d.ts.map +1 -0
- package/dist/environment-core.js +229 -0
- package/dist/environment-core.js.map +1 -0
- package/dist/environment-core.test.d.ts +2 -0
- package/dist/environment-core.test.d.ts.map +1 -0
- package/dist/environment-core.test.js +252 -0
- package/dist/environment-core.test.js.map +1 -0
- package/dist/faction-cognition.d.ts +39 -0
- package/dist/faction-cognition.d.ts.map +1 -0
- package/dist/faction-cognition.js +139 -0
- package/dist/faction-cognition.js.map +1 -0
- package/dist/faction-cognition.test.d.ts +2 -0
- package/dist/faction-cognition.test.d.ts.map +1 -0
- package/dist/faction-cognition.test.js +166 -0
- package/dist/faction-cognition.test.js.map +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -0
- package/dist/inventory-core.d.ts +10 -0
- package/dist/inventory-core.d.ts.map +1 -0
- package/dist/inventory-core.js +69 -0
- package/dist/inventory-core.js.map +1 -0
- package/dist/knowledge-decay.test.d.ts +2 -0
- package/dist/knowledge-decay.test.d.ts.map +1 -0
- package/dist/knowledge-decay.test.js +143 -0
- package/dist/knowledge-decay.test.js.map +1 -0
- package/dist/narrative-authority.d.ts +40 -0
- package/dist/narrative-authority.d.ts.map +1 -0
- package/dist/narrative-authority.js +89 -0
- package/dist/narrative-authority.js.map +1 -0
- package/dist/narrative-authority.test.d.ts +2 -0
- package/dist/narrative-authority.test.d.ts.map +1 -0
- package/dist/narrative-authority.test.js +237 -0
- package/dist/narrative-authority.test.js.map +1 -0
- package/dist/observer-presentation.d.ts +74 -0
- package/dist/observer-presentation.d.ts.map +1 -0
- package/dist/observer-presentation.js +277 -0
- package/dist/observer-presentation.js.map +1 -0
- package/dist/observer-presentation.test.d.ts +2 -0
- package/dist/observer-presentation.test.d.ts.map +1 -0
- package/dist/observer-presentation.test.js +156 -0
- package/dist/observer-presentation.test.js.map +1 -0
- package/dist/perception-filter.d.ts +46 -0
- package/dist/perception-filter.d.ts.map +1 -0
- package/dist/perception-filter.js +281 -0
- package/dist/perception-filter.js.map +1 -0
- package/dist/perception-filter.test.d.ts +2 -0
- package/dist/perception-filter.test.d.ts.map +1 -0
- package/dist/perception-filter.test.js +308 -0
- package/dist/perception-filter.test.js.map +1 -0
- package/dist/progression-core.d.ts +63 -0
- package/dist/progression-core.d.ts.map +1 -0
- package/dist/progression-core.js +232 -0
- package/dist/progression-core.js.map +1 -0
- package/dist/progression-core.test.d.ts +2 -0
- package/dist/progression-core.test.d.ts.map +1 -0
- package/dist/progression-core.test.js +328 -0
- package/dist/progression-core.test.js.map +1 -0
- package/dist/rumor-propagation.d.ts +31 -0
- package/dist/rumor-propagation.d.ts.map +1 -0
- package/dist/rumor-propagation.js +180 -0
- package/dist/rumor-propagation.js.map +1 -0
- package/dist/rumor-propagation.test.d.ts +2 -0
- package/dist/rumor-propagation.test.d.ts.map +1 -0
- package/dist/rumor-propagation.test.js +176 -0
- package/dist/rumor-propagation.test.js.map +1 -0
- package/dist/simulation-inspector.d.ts +78 -0
- package/dist/simulation-inspector.d.ts.map +1 -0
- package/dist/simulation-inspector.js +263 -0
- package/dist/simulation-inspector.js.map +1 -0
- package/dist/simulation-inspector.test.d.ts +2 -0
- package/dist/simulation-inspector.test.d.ts.map +1 -0
- package/dist/simulation-inspector.test.js +152 -0
- package/dist/simulation-inspector.test.js.map +1 -0
- package/dist/status-core.d.ts +17 -0
- package/dist/status-core.d.ts.map +1 -0
- package/dist/status-core.js +106 -0
- package/dist/status-core.js.map +1 -0
- package/dist/traversal-core.d.ts +3 -0
- package/dist/traversal-core.d.ts.map +1 -0
- package/dist/traversal-core.js +93 -0
- package/dist/traversal-core.js.map +1 -0
- package/package.json +34 -0
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
import { describe, it, expect } from 'vitest';
|
|
2
|
+
import { createTestEngine } from '@ai-rpg-engine/core';
|
|
3
|
+
import { createCognitionCore, getCognition, setBelief, believes, getMemories, } from './cognition-core.js';
|
|
4
|
+
import { createPerceptionFilter, getPerceptionLog, didPerceive, whoPerceived, } from './perception-filter.js';
|
|
5
|
+
import { traversalCore } from './traversal-core.js';
|
|
6
|
+
import { combatCore } from './combat-core.js';
|
|
7
|
+
// Helper: AI entity with configurable perception stat
|
|
8
|
+
const makeAI = (id, name, zoneId, instinct = 5, overrides) => ({
|
|
9
|
+
id,
|
|
10
|
+
blueprintId: id,
|
|
11
|
+
type: 'enemy',
|
|
12
|
+
name,
|
|
13
|
+
tags: ['enemy'],
|
|
14
|
+
stats: { vigor: 5, instinct },
|
|
15
|
+
resources: { hp: 20, stamina: 5 },
|
|
16
|
+
statuses: [],
|
|
17
|
+
zoneId,
|
|
18
|
+
ai: { profileId: 'aggressive', goals: ['guard'], fears: [], alertLevel: 0, knowledge: {} },
|
|
19
|
+
...overrides,
|
|
20
|
+
});
|
|
21
|
+
const makePlayer = (zoneId, overrides) => ({
|
|
22
|
+
id: 'player',
|
|
23
|
+
blueprintId: 'player',
|
|
24
|
+
type: 'player',
|
|
25
|
+
name: 'Hero',
|
|
26
|
+
tags: ['player'],
|
|
27
|
+
stats: { vigor: 5, instinct: 5 },
|
|
28
|
+
resources: { hp: 20, stamina: 5 },
|
|
29
|
+
statuses: [],
|
|
30
|
+
zoneId,
|
|
31
|
+
...overrides,
|
|
32
|
+
});
|
|
33
|
+
describe('Perception filter — bright zone detection', () => {
|
|
34
|
+
it('guard with high perception detects player entering bright zone', () => {
|
|
35
|
+
const engine = createTestEngine({
|
|
36
|
+
modules: [traversalCore, createCognitionCore(), createPerceptionFilter()],
|
|
37
|
+
entities: [
|
|
38
|
+
makePlayer('a'),
|
|
39
|
+
makeAI('guard', 'Guard', 'b', 10), // High perception
|
|
40
|
+
],
|
|
41
|
+
zones: [
|
|
42
|
+
{ id: 'a', roomId: 'test', name: 'A', tags: [], neighbors: ['b'] },
|
|
43
|
+
{ id: 'b', roomId: 'test', name: 'B', tags: [], neighbors: ['a'], light: 10 },
|
|
44
|
+
],
|
|
45
|
+
});
|
|
46
|
+
engine.submitAction('move', { targetIds: ['b'] });
|
|
47
|
+
const cog = getCognition(engine.world, 'guard');
|
|
48
|
+
// High perception + bright zone = detected
|
|
49
|
+
expect(believes(cog, 'player', 'present', true)).toBe(true);
|
|
50
|
+
expect(getMemories(cog, 'saw-entity').length).toBeGreaterThan(0);
|
|
51
|
+
});
|
|
52
|
+
it('guard with low perception in dark zone fails to detect hidden intruder', () => {
|
|
53
|
+
const engine = createTestEngine({
|
|
54
|
+
modules: [traversalCore, createCognitionCore(), createPerceptionFilter()],
|
|
55
|
+
entities: [
|
|
56
|
+
makePlayer('a', { visibility: { hidden: true } }),
|
|
57
|
+
makeAI('guard', 'Guard', 'b', 1), // Very low perception
|
|
58
|
+
],
|
|
59
|
+
zones: [
|
|
60
|
+
{ id: 'a', roomId: 'test', name: 'A', tags: [], neighbors: ['b'] },
|
|
61
|
+
{ id: 'b', roomId: 'test', name: 'B', tags: [], neighbors: ['a'], light: 0 }, // Pitch dark
|
|
62
|
+
],
|
|
63
|
+
});
|
|
64
|
+
engine.submitAction('move', { targetIds: ['b'] });
|
|
65
|
+
const cog = getCognition(engine.world, 'guard');
|
|
66
|
+
// Low perception + dark + hidden = guaranteed failure
|
|
67
|
+
// instinct=1 → score = 7 + roll(1-50) = 8-57
|
|
68
|
+
// threshold = 30 + 10 (dark) + 20 (hidden) = 60
|
|
69
|
+
// max score 57 < 60 → always fails
|
|
70
|
+
expect(believes(cog, 'player', 'present', true)).toBe(false);
|
|
71
|
+
expect(getMemories(cog, 'saw-entity')).toHaveLength(0);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
describe('Perception filter — perception log', () => {
|
|
75
|
+
it('logs perception attempts for each entity', () => {
|
|
76
|
+
const engine = createTestEngine({
|
|
77
|
+
modules: [traversalCore, createCognitionCore(), createPerceptionFilter()],
|
|
78
|
+
entities: [
|
|
79
|
+
makePlayer('a'),
|
|
80
|
+
makeAI('guard1', 'Guard 1', 'b', 10),
|
|
81
|
+
makeAI('guard2', 'Guard 2', 'b', 10),
|
|
82
|
+
],
|
|
83
|
+
zones: [
|
|
84
|
+
{ id: 'a', roomId: 'test', name: 'A', tags: [], neighbors: ['b'] },
|
|
85
|
+
{ id: 'b', roomId: 'test', name: 'B', tags: [], neighbors: ['a'], light: 10 },
|
|
86
|
+
],
|
|
87
|
+
});
|
|
88
|
+
engine.submitAction('move', { targetIds: ['b'] });
|
|
89
|
+
// Both guards should have perception log entries
|
|
90
|
+
const log1 = getPerceptionLog(engine.world, 'guard1');
|
|
91
|
+
const log2 = getPerceptionLog(engine.world, 'guard2');
|
|
92
|
+
expect(log1.length).toBeGreaterThan(0);
|
|
93
|
+
expect(log2.length).toBeGreaterThan(0);
|
|
94
|
+
expect(log1[0].sense).toBe('sight');
|
|
95
|
+
expect(log2[0].sense).toBe('sight');
|
|
96
|
+
});
|
|
97
|
+
it('didPerceive returns entry for specific event', () => {
|
|
98
|
+
const engine = createTestEngine({
|
|
99
|
+
modules: [traversalCore, createCognitionCore(), createPerceptionFilter()],
|
|
100
|
+
entities: [
|
|
101
|
+
makePlayer('a'),
|
|
102
|
+
makeAI('guard', 'Guard', 'b', 10),
|
|
103
|
+
],
|
|
104
|
+
zones: [
|
|
105
|
+
{ id: 'a', roomId: 'test', name: 'A', tags: [], neighbors: ['b'] },
|
|
106
|
+
{ id: 'b', roomId: 'test', name: 'B', tags: [], neighbors: ['a'], light: 10 },
|
|
107
|
+
],
|
|
108
|
+
});
|
|
109
|
+
const events = engine.submitAction('move', { targetIds: ['b'] });
|
|
110
|
+
const moveEvent = events.find((e) => e.type === 'world.zone.entered');
|
|
111
|
+
expect(moveEvent).toBeDefined();
|
|
112
|
+
const perceived = didPerceive(engine.world, 'guard', moveEvent.id);
|
|
113
|
+
expect(perceived).toBeDefined();
|
|
114
|
+
expect(perceived.detected).toBe(true);
|
|
115
|
+
});
|
|
116
|
+
it('whoPerceived returns all entities that perceived an event', () => {
|
|
117
|
+
const engine = createTestEngine({
|
|
118
|
+
modules: [traversalCore, createCognitionCore(), createPerceptionFilter()],
|
|
119
|
+
entities: [
|
|
120
|
+
makePlayer('a'),
|
|
121
|
+
makeAI('guard1', 'Guard 1', 'b', 10),
|
|
122
|
+
makeAI('guard2', 'Guard 2', 'b', 10),
|
|
123
|
+
],
|
|
124
|
+
zones: [
|
|
125
|
+
{ id: 'a', roomId: 'test', name: 'A', tags: [], neighbors: ['b'] },
|
|
126
|
+
{ id: 'b', roomId: 'test', name: 'B', tags: [], neighbors: ['a'], light: 10 },
|
|
127
|
+
],
|
|
128
|
+
});
|
|
129
|
+
const events = engine.submitAction('move', { targetIds: ['b'] });
|
|
130
|
+
const moveEvent = events.find((e) => e.type === 'world.zone.entered');
|
|
131
|
+
const perceivers = whoPerceived(engine.world, moveEvent.id);
|
|
132
|
+
expect(perceivers.length).toBe(2);
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
describe('Perception filter — combat awareness', () => {
|
|
136
|
+
it('direct attack target always knows attacker (no perception needed)', () => {
|
|
137
|
+
const engine = createTestEngine({
|
|
138
|
+
modules: [traversalCore, combatCore, createCognitionCore(), createPerceptionFilter()],
|
|
139
|
+
entities: [
|
|
140
|
+
makePlayer('a'),
|
|
141
|
+
makeAI('guard', 'Guard', 'a', 1), // Even with terrible perception
|
|
142
|
+
],
|
|
143
|
+
zones: [
|
|
144
|
+
{ id: 'a', roomId: 'test', name: 'A', tags: [], neighbors: [], light: 0 }, // Pitch dark
|
|
145
|
+
],
|
|
146
|
+
});
|
|
147
|
+
engine.submitAction('attack', { targetIds: ['guard'] });
|
|
148
|
+
const cog = getCognition(engine.world, 'guard');
|
|
149
|
+
// Direct target ALWAYS knows (handled by cognition-core, not perception-filter)
|
|
150
|
+
expect(believes(cog, 'player', 'hostile', true)).toBe(true);
|
|
151
|
+
expect(cog.morale).toBeLessThan(70);
|
|
152
|
+
});
|
|
153
|
+
it('bystander with high perception sees combat details', () => {
|
|
154
|
+
const engine = createTestEngine({
|
|
155
|
+
modules: [traversalCore, combatCore, createCognitionCore(), createPerceptionFilter()],
|
|
156
|
+
entities: [
|
|
157
|
+
makePlayer('a'),
|
|
158
|
+
makeAI('target', 'Target', 'a', 5),
|
|
159
|
+
makeAI('bystander', 'Bystander', 'a', 10), // High perception
|
|
160
|
+
],
|
|
161
|
+
zones: [
|
|
162
|
+
{ id: 'a', roomId: 'test', name: 'A', tags: [], neighbors: [], light: 10 }, // Bright
|
|
163
|
+
],
|
|
164
|
+
});
|
|
165
|
+
engine.submitAction('attack', { targetIds: ['target'] });
|
|
166
|
+
const bystanderCog = getCognition(engine.world, 'bystander');
|
|
167
|
+
// High perception in bright room → should see combat
|
|
168
|
+
const combatMemories = getMemories(bystanderCog, 'saw-combat');
|
|
169
|
+
const dangerMemories = getMemories(bystanderCog, 'sensed-danger');
|
|
170
|
+
// Should have either saw-combat (high clarity) or sensed-danger (low clarity)
|
|
171
|
+
expect(combatMemories.length + dangerMemories.length).toBeGreaterThan(0);
|
|
172
|
+
expect(bystanderCog.suspicion).toBeGreaterThan(0);
|
|
173
|
+
});
|
|
174
|
+
it('bystander with low perception in dark zone misses combat', () => {
|
|
175
|
+
const engine = createTestEngine({
|
|
176
|
+
modules: [traversalCore, combatCore, createCognitionCore(), createPerceptionFilter()],
|
|
177
|
+
entities: [
|
|
178
|
+
makePlayer('a'),
|
|
179
|
+
makeAI('target', 'Target', 'a', 5),
|
|
180
|
+
makeAI('bystander', 'Bystander', 'a', 1), // Terrible perception
|
|
181
|
+
],
|
|
182
|
+
zones: [
|
|
183
|
+
{ id: 'a', roomId: 'test', name: 'A', tags: [], neighbors: [], light: 0 }, // Pitch dark
|
|
184
|
+
],
|
|
185
|
+
});
|
|
186
|
+
engine.submitAction('attack', { targetIds: ['target'] });
|
|
187
|
+
// Check bystander perception log
|
|
188
|
+
const log = getPerceptionLog(engine.world, 'bystander');
|
|
189
|
+
const visualEntries = log.filter((p) => p.sense === 'sight');
|
|
190
|
+
// In darkness with instinct=1:
|
|
191
|
+
// score = 7 + roll(1-50) = 8-57
|
|
192
|
+
// threshold for visual-combat = 20 + 10 (dark) = 30
|
|
193
|
+
// Some rolls may pass, some may fail
|
|
194
|
+
// But all entries should be logged
|
|
195
|
+
expect(log.length).toBeGreaterThan(0);
|
|
196
|
+
});
|
|
197
|
+
});
|
|
198
|
+
describe('Perception filter — cross-zone hearing', () => {
|
|
199
|
+
it('entity in adjacent zone hears combat', () => {
|
|
200
|
+
const engine = createTestEngine({
|
|
201
|
+
modules: [traversalCore, combatCore, createCognitionCore(), createPerceptionFilter()],
|
|
202
|
+
entities: [
|
|
203
|
+
makePlayer('a'),
|
|
204
|
+
makeAI('target', 'Target', 'a', 5),
|
|
205
|
+
makeAI('listener', 'Listener', 'b', 10), // High perception, adjacent zone
|
|
206
|
+
],
|
|
207
|
+
zones: [
|
|
208
|
+
{ id: 'a', roomId: 'test', name: 'A', tags: [], neighbors: ['b'], light: 5 },
|
|
209
|
+
{ id: 'b', roomId: 'test', name: 'B', tags: [], neighbors: ['a'], light: 5 },
|
|
210
|
+
],
|
|
211
|
+
});
|
|
212
|
+
engine.submitAction('attack', { targetIds: ['target'] });
|
|
213
|
+
const listenerCog = getCognition(engine.world, 'listener');
|
|
214
|
+
// Adjacent zone → auditory-combat layer (crossZone: true)
|
|
215
|
+
const heardCombat = getMemories(listenerCog, 'heard-combat');
|
|
216
|
+
const heardNoise = getMemories(listenerCog, 'heard-noise');
|
|
217
|
+
// Should have heard something from adjacent zone
|
|
218
|
+
expect(heardCombat.length + heardNoise.length).toBeGreaterThan(0);
|
|
219
|
+
});
|
|
220
|
+
it('entity in non-adjacent zone hears nothing', () => {
|
|
221
|
+
const engine = createTestEngine({
|
|
222
|
+
modules: [traversalCore, combatCore, createCognitionCore(), createPerceptionFilter()],
|
|
223
|
+
entities: [
|
|
224
|
+
makePlayer('a'),
|
|
225
|
+
makeAI('target', 'Target', 'a', 5),
|
|
226
|
+
makeAI('faraway', 'Far Away', 'c', 10), // Not adjacent to zone A
|
|
227
|
+
],
|
|
228
|
+
zones: [
|
|
229
|
+
{ id: 'a', roomId: 'test', name: 'A', tags: [], neighbors: ['b'], light: 5 },
|
|
230
|
+
{ id: 'b', roomId: 'test', name: 'B', tags: [], neighbors: ['a', 'c'], light: 5 },
|
|
231
|
+
{ id: 'c', roomId: 'test', name: 'C', tags: [], neighbors: ['b'], light: 5 },
|
|
232
|
+
],
|
|
233
|
+
});
|
|
234
|
+
engine.submitAction('attack', { targetIds: ['target'] });
|
|
235
|
+
const farawayCog = getCognition(engine.world, 'faraway');
|
|
236
|
+
// Zone C is NOT adjacent to zone A → no perception at all
|
|
237
|
+
expect(getMemories(farawayCog).length).toBe(0);
|
|
238
|
+
expect(getPerceptionLog(engine.world, 'faraway').length).toBe(0);
|
|
239
|
+
});
|
|
240
|
+
});
|
|
241
|
+
describe('Perception filter — custom layers', () => {
|
|
242
|
+
it('custom network sense layer detects digital events', () => {
|
|
243
|
+
const engine = createTestEngine({
|
|
244
|
+
modules: [
|
|
245
|
+
traversalCore,
|
|
246
|
+
createCognitionCore(),
|
|
247
|
+
createPerceptionFilter({
|
|
248
|
+
layers: [{
|
|
249
|
+
id: 'network-breach',
|
|
250
|
+
eventPatterns: ['netrunning.ice.breached'],
|
|
251
|
+
sense: 'network',
|
|
252
|
+
baseDifficulty: 20,
|
|
253
|
+
crossZone: true,
|
|
254
|
+
onPerceived(event, entity, clarity, world) {
|
|
255
|
+
const cog = getCognition(world, entity.id);
|
|
256
|
+
setBelief(cog, event.actorId, 'intruder', true, clarity, 'observed', event.tick);
|
|
257
|
+
},
|
|
258
|
+
}],
|
|
259
|
+
senseStats: { network: 'instinct' },
|
|
260
|
+
}),
|
|
261
|
+
],
|
|
262
|
+
entities: [
|
|
263
|
+
makePlayer('a'),
|
|
264
|
+
makeAI('ice', 'ICE Sentry', 'b', 8),
|
|
265
|
+
],
|
|
266
|
+
zones: [
|
|
267
|
+
{ id: 'a', roomId: 'test', name: 'A', tags: [], neighbors: ['b'] },
|
|
268
|
+
{ id: 'b', roomId: 'test', name: 'B', tags: [], neighbors: ['a'] },
|
|
269
|
+
],
|
|
270
|
+
});
|
|
271
|
+
// Manually emit a netrunning event (actorId must be top-level, not just in payload)
|
|
272
|
+
engine.store.emitEvent('netrunning.ice.breached', {
|
|
273
|
+
targetId: 'ice',
|
|
274
|
+
zoneId: 'b',
|
|
275
|
+
iceRemoved: 8,
|
|
276
|
+
}, { actorId: 'player' });
|
|
277
|
+
const iceCog = getCognition(engine.world, 'ice');
|
|
278
|
+
// ICE with instinct=8 in adjacent zone with crossZone=true should detect
|
|
279
|
+
// score = 8*7 + roll = 56 + roll(1-50) = 57-106
|
|
280
|
+
// threshold = 20 + 15 (adjacent) = 35
|
|
281
|
+
// Always detects
|
|
282
|
+
expect(believes(iceCog, 'player', 'intruder', true)).toBe(true);
|
|
283
|
+
});
|
|
284
|
+
});
|
|
285
|
+
describe('Perception filter — interpretation levels', () => {
|
|
286
|
+
it('high clarity perception gives full interpretation', () => {
|
|
287
|
+
const engine = createTestEngine({
|
|
288
|
+
modules: [traversalCore, createCognitionCore(), createPerceptionFilter()],
|
|
289
|
+
entities: [
|
|
290
|
+
makePlayer('a'),
|
|
291
|
+
makeAI('eagle', 'Eagle Eye', 'b', 10), // Maximum perception
|
|
292
|
+
],
|
|
293
|
+
zones: [
|
|
294
|
+
{ id: 'a', roomId: 'test', name: 'A', tags: [], neighbors: ['b'] },
|
|
295
|
+
{ id: 'b', roomId: 'test', name: 'B', tags: [], neighbors: ['a'], light: 10 },
|
|
296
|
+
],
|
|
297
|
+
});
|
|
298
|
+
engine.submitAction('move', { targetIds: ['b'] });
|
|
299
|
+
const log = getPerceptionLog(engine.world, 'eagle');
|
|
300
|
+
const visualEntry = log.find((p) => p.sense === 'sight');
|
|
301
|
+
expect(visualEntry).toBeDefined();
|
|
302
|
+
expect(visualEntry.detected).toBe(true);
|
|
303
|
+
// instinct=10, light=10 → score = 70 + roll, threshold = 30 - 10 = 20
|
|
304
|
+
// margin >= 50 → clarity = min(1, 0.5 + 50/30) = 1.0 → full
|
|
305
|
+
expect(visualEntry.interpretation).toBe('full');
|
|
306
|
+
});
|
|
307
|
+
});
|
|
308
|
+
//# sourceMappingURL=perception-filter.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"perception-filter.test.js","sourceRoot":"","sources":["../src/perception-filter.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,E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pD,MAAM,WAAW,GAAG,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,OAAO,CAAC,CAAC;QACzD,MAAM,CAAC,WAAW,CAAC,CAAC,WAAW,EAAE,CAAC;QAClC,MAAM,CAAC,WAAY,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzC,sEAAsE;QACtE,4DAA4D;QAC5D,MAAM,CAAC,WAAY,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACnD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { EngineModule, WorldState, ResolvedEvent, EntityState } from '@ai-rpg-engine/core';
|
|
2
|
+
import type { ProgressionTreeDefinition, ProgressionNode, EffectDefinition } from '@ai-rpg-engine/content-schema';
|
|
3
|
+
export type ProgressionState = {
|
|
4
|
+
/** Currency balances: entityId → currencyId → amount */
|
|
5
|
+
currencies: Record<string, Record<string, number>>;
|
|
6
|
+
/** Unlocked nodes: entityId → treeId → nodeId[] */
|
|
7
|
+
unlocked: Record<string, Record<string, string[]>>;
|
|
8
|
+
};
|
|
9
|
+
export type ProgressionEvent = {
|
|
10
|
+
entityId: string;
|
|
11
|
+
type: 'currency-gained' | 'currency-spent' | 'node-unlocked';
|
|
12
|
+
treeId?: string;
|
|
13
|
+
nodeId?: string;
|
|
14
|
+
currencyId?: string;
|
|
15
|
+
amount?: number;
|
|
16
|
+
tick: number;
|
|
17
|
+
};
|
|
18
|
+
export type CurrencyReward = {
|
|
19
|
+
/** Event pattern to listen for (e.g. 'combat.entity.defeated') */
|
|
20
|
+
eventPattern: string;
|
|
21
|
+
/** Which currency to grant */
|
|
22
|
+
currencyId: string;
|
|
23
|
+
/** Amount to grant (or function of event payload) */
|
|
24
|
+
amount: number | ((event: ResolvedEvent, world: WorldState) => number);
|
|
25
|
+
/** Who receives the reward: 'actor' (event.actorId) or custom function */
|
|
26
|
+
recipient?: 'actor' | ((event: ResolvedEvent, world: WorldState) => string | undefined);
|
|
27
|
+
};
|
|
28
|
+
export type ProgressionCoreConfig = {
|
|
29
|
+
/** Progression trees (content definitions) */
|
|
30
|
+
trees?: ProgressionTreeDefinition[];
|
|
31
|
+
/** Automatic currency rewards from events */
|
|
32
|
+
rewards?: CurrencyReward[];
|
|
33
|
+
/** Effect handlers for progression node effects */
|
|
34
|
+
effectHandlers?: Record<string, EffectHandler>;
|
|
35
|
+
};
|
|
36
|
+
export type EffectHandler = (effect: EffectDefinition, entity: EntityState, world: WorldState) => void;
|
|
37
|
+
export type UnlockResult = {
|
|
38
|
+
success: boolean;
|
|
39
|
+
reason?: string;
|
|
40
|
+
event?: ProgressionEvent;
|
|
41
|
+
effects?: EffectDefinition[];
|
|
42
|
+
};
|
|
43
|
+
export declare function createProgressionCore(config?: ProgressionCoreConfig): EngineModule;
|
|
44
|
+
/** Get an entity's balance in a currency */
|
|
45
|
+
export declare function getCurrency(world: WorldState, entityId: string, currencyId: string): number;
|
|
46
|
+
/** Add currency to an entity */
|
|
47
|
+
export declare function addCurrency(world: WorldState, entityId: string, currencyId: string, amount: number, tick: number): void;
|
|
48
|
+
/** Spend currency (returns false if insufficient) */
|
|
49
|
+
export declare function spendCurrency(world: WorldState, entityId: string, currencyId: string, amount: number): boolean;
|
|
50
|
+
/** Get all unlocked nodes for an entity in a tree */
|
|
51
|
+
export declare function getUnlockedNodes(world: WorldState, entityId: string, treeId: string): string[];
|
|
52
|
+
/** Check if a specific node is unlocked */
|
|
53
|
+
export declare function isNodeUnlocked(world: WorldState, entityId: string, treeId: string, nodeId: string): boolean;
|
|
54
|
+
/** Check if a node can be unlocked (prerequisites met, currency available) */
|
|
55
|
+
export declare function canUnlock(world: WorldState, entityId: string, treeId: string, nodeId: string, trees: Map<string, ProgressionTreeDefinition>): {
|
|
56
|
+
can: boolean;
|
|
57
|
+
reason?: string;
|
|
58
|
+
};
|
|
59
|
+
/** Unlock a node: pay cost, record unlock, apply effects */
|
|
60
|
+
export declare function unlockNode(world: WorldState, entityId: string, treeId: string, nodeId: string, trees: Map<string, ProgressionTreeDefinition>, effectHandlers: Record<string, EffectHandler>, tick: number): UnlockResult;
|
|
61
|
+
/** Get all nodes available for unlock (prerequisites met, enough currency) */
|
|
62
|
+
export declare function getAvailableNodes(world: WorldState, entityId: string, treeId: string, trees: Map<string, ProgressionTreeDefinition>): ProgressionNode[];
|
|
63
|
+
//# sourceMappingURL=progression-core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progression-core.d.ts","sourceRoot":"","sources":["../src/progression-core.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EACV,YAAY,EACZ,UAAU,EACV,aAAa,EACb,WAAW,EAEZ,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAE,yBAAyB,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AAIlH,MAAM,MAAM,gBAAgB,GAAG;IAC7B,wDAAwD;IACxD,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IACnD,mDAAmD;IACnD,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;CACpD,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,iBAAiB,GAAG,gBAAgB,GAAG,eAAe,CAAC;IAC7D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B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C,eAAe,EAAE,CAQnB"}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
// progression-core — flexible progression framework
|
|
2
|
+
// Supports XP/levels, milestones, reputation, skill-use growth, item upgrades.
|
|
3
|
+
// All models reduce to: earn currency → spend on tree nodes → get effects.
|
|
4
|
+
import { nextId } from '@ai-rpg-engine/core';
|
|
5
|
+
// --- Module ---
|
|
6
|
+
export function createProgressionCore(config) {
|
|
7
|
+
const trees = new Map();
|
|
8
|
+
for (const tree of config?.trees ?? []) {
|
|
9
|
+
trees.set(tree.id, tree);
|
|
10
|
+
}
|
|
11
|
+
const rewards = config?.rewards ?? [];
|
|
12
|
+
const effectHandlers = {
|
|
13
|
+
'stat-boost': defaultStatBoost,
|
|
14
|
+
'resource-boost': defaultResourceBoost,
|
|
15
|
+
'grant-tag': defaultGrantTag,
|
|
16
|
+
'set-global': defaultSetGlobal,
|
|
17
|
+
...config?.effectHandlers,
|
|
18
|
+
};
|
|
19
|
+
return {
|
|
20
|
+
id: 'progression-core',
|
|
21
|
+
version: '0.1.0',
|
|
22
|
+
register(ctx) {
|
|
23
|
+
ctx.persistence.registerNamespace('progression-core', {
|
|
24
|
+
currencies: {},
|
|
25
|
+
unlocked: {},
|
|
26
|
+
});
|
|
27
|
+
// Register 'unlock' verb for spending currency on tree nodes
|
|
28
|
+
ctx.actions.registerVerb('unlock', (action, world) => {
|
|
29
|
+
const treeId = action.parameters?.treeId;
|
|
30
|
+
const nodeId = action.parameters?.nodeId;
|
|
31
|
+
if (!treeId || !nodeId) {
|
|
32
|
+
return [{
|
|
33
|
+
id: nextId('evt'),
|
|
34
|
+
tick: action.issuedAtTick,
|
|
35
|
+
type: 'progression.unlock.rejected',
|
|
36
|
+
actorId: action.actorId,
|
|
37
|
+
payload: { reason: 'missing treeId or nodeId' },
|
|
38
|
+
}];
|
|
39
|
+
}
|
|
40
|
+
const result = unlockNode(world, action.actorId, treeId, nodeId, trees, effectHandlers, action.issuedAtTick);
|
|
41
|
+
if (!result.success) {
|
|
42
|
+
return [{
|
|
43
|
+
id: nextId('evt'),
|
|
44
|
+
tick: action.issuedAtTick,
|
|
45
|
+
type: 'progression.unlock.rejected',
|
|
46
|
+
actorId: action.actorId,
|
|
47
|
+
payload: { treeId, nodeId, reason: result.reason },
|
|
48
|
+
}];
|
|
49
|
+
}
|
|
50
|
+
return [{
|
|
51
|
+
id: nextId('evt'),
|
|
52
|
+
tick: action.issuedAtTick,
|
|
53
|
+
type: 'progression.node.unlocked',
|
|
54
|
+
actorId: action.actorId,
|
|
55
|
+
payload: {
|
|
56
|
+
treeId,
|
|
57
|
+
nodeId,
|
|
58
|
+
effects: result.effects?.map((e) => e.type) ?? [],
|
|
59
|
+
},
|
|
60
|
+
}];
|
|
61
|
+
});
|
|
62
|
+
// Set up automatic currency rewards from events
|
|
63
|
+
for (const reward of rewards) {
|
|
64
|
+
ctx.events.on(reward.eventPattern, (event, world) => {
|
|
65
|
+
const recipientId = getRecipientId(reward, event, world);
|
|
66
|
+
if (!recipientId)
|
|
67
|
+
return;
|
|
68
|
+
const amount = typeof reward.amount === 'function'
|
|
69
|
+
? reward.amount(event, world)
|
|
70
|
+
: reward.amount;
|
|
71
|
+
if (amount <= 0)
|
|
72
|
+
return;
|
|
73
|
+
addCurrency(world, recipientId, reward.currencyId, amount, event.tick);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
// --- Currency Operations ---
|
|
80
|
+
function getProgressionState(world) {
|
|
81
|
+
return (world.modules['progression-core'] ?? { currencies: {}, unlocked: {} });
|
|
82
|
+
}
|
|
83
|
+
/** Get an entity's balance in a currency */
|
|
84
|
+
export function getCurrency(world, entityId, currencyId) {
|
|
85
|
+
const state = getProgressionState(world);
|
|
86
|
+
return state.currencies[entityId]?.[currencyId] ?? 0;
|
|
87
|
+
}
|
|
88
|
+
/** Add currency to an entity */
|
|
89
|
+
export function addCurrency(world, entityId, currencyId, amount, tick) {
|
|
90
|
+
const state = getProgressionState(world);
|
|
91
|
+
if (!state.currencies[entityId]) {
|
|
92
|
+
state.currencies[entityId] = {};
|
|
93
|
+
}
|
|
94
|
+
state.currencies[entityId][currencyId] = (state.currencies[entityId][currencyId] ?? 0) + amount;
|
|
95
|
+
}
|
|
96
|
+
/** Spend currency (returns false if insufficient) */
|
|
97
|
+
export function spendCurrency(world, entityId, currencyId, amount) {
|
|
98
|
+
const balance = getCurrency(world, entityId, currencyId);
|
|
99
|
+
if (balance < amount)
|
|
100
|
+
return false;
|
|
101
|
+
const state = getProgressionState(world);
|
|
102
|
+
state.currencies[entityId][currencyId] = balance - amount;
|
|
103
|
+
return true;
|
|
104
|
+
}
|
|
105
|
+
// --- Node Operations ---
|
|
106
|
+
/** Get all unlocked nodes for an entity in a tree */
|
|
107
|
+
export function getUnlockedNodes(world, entityId, treeId) {
|
|
108
|
+
const state = getProgressionState(world);
|
|
109
|
+
return state.unlocked[entityId]?.[treeId] ?? [];
|
|
110
|
+
}
|
|
111
|
+
/** Check if a specific node is unlocked */
|
|
112
|
+
export function isNodeUnlocked(world, entityId, treeId, nodeId) {
|
|
113
|
+
return getUnlockedNodes(world, entityId, treeId).includes(nodeId);
|
|
114
|
+
}
|
|
115
|
+
/** Check if a node can be unlocked (prerequisites met, currency available) */
|
|
116
|
+
export function canUnlock(world, entityId, treeId, nodeId, trees) {
|
|
117
|
+
const tree = trees.get(treeId);
|
|
118
|
+
if (!tree)
|
|
119
|
+
return { can: false, reason: `tree not found: ${treeId}` };
|
|
120
|
+
const node = tree.nodes.find((n) => n.id === nodeId);
|
|
121
|
+
if (!node)
|
|
122
|
+
return { can: false, reason: `node not found: ${nodeId}` };
|
|
123
|
+
// Already unlocked?
|
|
124
|
+
if (isNodeUnlocked(world, entityId, treeId, nodeId)) {
|
|
125
|
+
return { can: false, reason: 'already unlocked' };
|
|
126
|
+
}
|
|
127
|
+
// Check prerequisites
|
|
128
|
+
const unlocked = getUnlockedNodes(world, entityId, treeId);
|
|
129
|
+
if (node.requires?.length) {
|
|
130
|
+
const missing = node.requires.filter((r) => !unlocked.includes(r));
|
|
131
|
+
if (missing.length > 0) {
|
|
132
|
+
return { can: false, reason: `missing prerequisites: ${missing.join(', ')}` };
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
// Check currency
|
|
136
|
+
const balance = getCurrency(world, entityId, tree.currency);
|
|
137
|
+
if (balance < node.cost) {
|
|
138
|
+
return { can: false, reason: `insufficient ${tree.currency}: have ${balance}, need ${node.cost}` };
|
|
139
|
+
}
|
|
140
|
+
return { can: true };
|
|
141
|
+
}
|
|
142
|
+
/** Unlock a node: pay cost, record unlock, apply effects */
|
|
143
|
+
export function unlockNode(world, entityId, treeId, nodeId, trees, effectHandlers, tick) {
|
|
144
|
+
const check = canUnlock(world, entityId, treeId, nodeId, trees);
|
|
145
|
+
if (!check.can) {
|
|
146
|
+
return { success: false, reason: check.reason };
|
|
147
|
+
}
|
|
148
|
+
const tree = trees.get(treeId);
|
|
149
|
+
const node = tree.nodes.find((n) => n.id === nodeId);
|
|
150
|
+
// Pay the cost
|
|
151
|
+
if (!spendCurrency(world, entityId, tree.currency, node.cost)) {
|
|
152
|
+
return { success: false, reason: 'currency spend failed' };
|
|
153
|
+
}
|
|
154
|
+
// Record the unlock
|
|
155
|
+
const state = getProgressionState(world);
|
|
156
|
+
if (!state.unlocked[entityId]) {
|
|
157
|
+
state.unlocked[entityId] = {};
|
|
158
|
+
}
|
|
159
|
+
if (!state.unlocked[entityId][treeId]) {
|
|
160
|
+
state.unlocked[entityId][treeId] = [];
|
|
161
|
+
}
|
|
162
|
+
state.unlocked[entityId][treeId].push(nodeId);
|
|
163
|
+
// Apply effects
|
|
164
|
+
const entity = world.entities[entityId];
|
|
165
|
+
if (entity && node.effects.length > 0) {
|
|
166
|
+
for (const effect of node.effects) {
|
|
167
|
+
const handler = effectHandlers[effect.type];
|
|
168
|
+
if (handler) {
|
|
169
|
+
handler(effect, entity, world);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
return {
|
|
174
|
+
success: true,
|
|
175
|
+
event: {
|
|
176
|
+
entityId,
|
|
177
|
+
type: 'node-unlocked',
|
|
178
|
+
treeId,
|
|
179
|
+
nodeId,
|
|
180
|
+
currencyId: tree.currency,
|
|
181
|
+
amount: node.cost,
|
|
182
|
+
tick,
|
|
183
|
+
},
|
|
184
|
+
effects: node.effects,
|
|
185
|
+
};
|
|
186
|
+
}
|
|
187
|
+
/** Get all nodes available for unlock (prerequisites met, enough currency) */
|
|
188
|
+
export function getAvailableNodes(world, entityId, treeId, trees) {
|
|
189
|
+
const tree = trees.get(treeId);
|
|
190
|
+
if (!tree)
|
|
191
|
+
return [];
|
|
192
|
+
return tree.nodes.filter((node) => {
|
|
193
|
+
const check = canUnlock(world, entityId, treeId, node.id, trees);
|
|
194
|
+
return check.can;
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
// --- Default Effect Handlers ---
|
|
198
|
+
function defaultStatBoost(effect, entity) {
|
|
199
|
+
const statId = effect.params.stat;
|
|
200
|
+
const amount = effect.params.amount;
|
|
201
|
+
if (statId && amount) {
|
|
202
|
+
entity.stats[statId] = (entity.stats[statId] ?? 0) + amount;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
function defaultResourceBoost(effect, entity) {
|
|
206
|
+
const resourceId = effect.params.resource;
|
|
207
|
+
const amount = effect.params.amount;
|
|
208
|
+
if (resourceId && amount) {
|
|
209
|
+
entity.resources[resourceId] = (entity.resources[resourceId] ?? 0) + amount;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
function defaultGrantTag(effect, entity) {
|
|
213
|
+
const tag = effect.params.tag;
|
|
214
|
+
if (tag && !entity.tags.includes(tag)) {
|
|
215
|
+
entity.tags.push(tag);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
function defaultSetGlobal(effect, _entity, world) {
|
|
219
|
+
const key = effect.params.key;
|
|
220
|
+
const value = effect.params.value;
|
|
221
|
+
if (key && value !== undefined) {
|
|
222
|
+
world.globals[key] = value;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
// --- Helpers ---
|
|
226
|
+
function getRecipientId(reward, event, world) {
|
|
227
|
+
if (!reward.recipient || reward.recipient === 'actor') {
|
|
228
|
+
return event.actorId;
|
|
229
|
+
}
|
|
230
|
+
return reward.recipient(event, world);
|
|
231
|
+
}
|
|
232
|
+
//# sourceMappingURL=progression-core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"progression-core.js","sourceRoot":"","sources":["../src/progression-core.ts"],"names":[],"mappings":"AAAA,oDAAoD;AACpD,+EAA+E;AAC/E,2EAA2E;AAS3E,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAuD7C,iBAAiB;AAEjB,MAAM,UAAU,qBAAqB,CAAC,MAA8B;IAClE,MAAM,KAAK,GAAG,IAAI,GAAG,EAAqC,CAAC;IAC3D,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE,KAAK,IAAI,EAAE,EAAE,CAAC;QACvC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;IAC3B,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,EAAE,OAAO,IAAI,EAAE,CAAC;IACtC,MAAM,cAAc,GAAkC;QACpD,YAAY,EAAE,gBAAgB;QAC9B,gBAAgB,EAAE,oBAAoB;QACtC,WAAW,EAAE,eAAe;QAC5B,YAAY,EAAE,gBAAgB;QAC9B,GAAG,MAAM,EAAE,cAAc;KAC1B,CAAC;IAEF,OAAO;QACL,EAAE,EAAE,kBAAkB;QACtB,OAAO,EAAE,OAAO;QAEhB,QAAQ,CAAC,GAAG;YACV,GAAG,CAAC,WAAW,CAAC,iBAAiB,CAAC,kBAAkB,EAAE;gBACpD,UAAU,EAAE,EAAE;gBACd,QAAQ,EAAE,EAAE;aACO,CAAC,CAAC;YAEvB,6DAA6D;YA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