@sharpee/event-processor 0.9.61-beta
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/LICENSE +21 -0
- package/README.md +43 -0
- package/dist-npm/effects/effect-processor.d.ts +50 -0
- package/dist-npm/effects/effect-processor.d.ts.map +1 -0
- package/dist-npm/effects/effect-processor.js +255 -0
- package/dist-npm/effects/effect-processor.js.map +1 -0
- package/dist-npm/effects/index.d.ts +10 -0
- package/dist-npm/effects/index.d.ts.map +1 -0
- package/dist-npm/effects/index.js +29 -0
- package/dist-npm/effects/index.js.map +1 -0
- package/dist-npm/effects/types.d.ts +119 -0
- package/dist-npm/effects/types.d.ts.map +1 -0
- package/dist-npm/effects/types.js +9 -0
- package/dist-npm/effects/types.js.map +1 -0
- package/dist-npm/effects/world-query.d.ts +70 -0
- package/dist-npm/effects/world-query.d.ts.map +1 -0
- package/dist-npm/effects/world-query.js +34 -0
- package/dist-npm/effects/world-query.js.map +1 -0
- package/dist-npm/handler-types.d.ts +67 -0
- package/dist-npm/handler-types.d.ts.map +1 -0
- package/dist-npm/handler-types.js +8 -0
- package/dist-npm/handler-types.js.map +1 -0
- package/dist-npm/handlers/complex-manipulation.d.ts +31 -0
- package/dist-npm/handlers/complex-manipulation.d.ts.map +1 -0
- package/dist-npm/handlers/complex-manipulation.js +87 -0
- package/dist-npm/handlers/complex-manipulation.js.map +1 -0
- package/dist-npm/handlers/device/index.d.ts +28 -0
- package/dist-npm/handlers/device/index.d.ts.map +1 -0
- package/dist-npm/handlers/device/index.js +172 -0
- package/dist-npm/handlers/device/index.js.map +1 -0
- package/dist-npm/handlers/index.d.ts +17 -0
- package/dist-npm/handlers/index.d.ts.map +1 -0
- package/dist-npm/handlers/index.js +48 -0
- package/dist-npm/handlers/index.js.map +1 -0
- package/dist-npm/handlers/meta.d.ts +59 -0
- package/dist-npm/handlers/meta.d.ts.map +1 -0
- package/dist-npm/handlers/meta.js +129 -0
- package/dist-npm/handlers/meta.js.map +1 -0
- package/dist-npm/handlers/movement.d.ts +51 -0
- package/dist-npm/handlers/movement.d.ts.map +1 -0
- package/dist-npm/handlers/movement.js +176 -0
- package/dist-npm/handlers/movement.js.map +1 -0
- package/dist-npm/handlers/observation/index.d.ts +6 -0
- package/dist-npm/handlers/observation/index.d.ts.map +1 -0
- package/dist-npm/handlers/observation/index.js +22 -0
- package/dist-npm/handlers/observation/index.js.map +1 -0
- package/dist-npm/handlers/observation/observation-handlers.d.ts +96 -0
- package/dist-npm/handlers/observation/observation-handlers.d.ts.map +1 -0
- package/dist-npm/handlers/observation/observation-handlers.js +162 -0
- package/dist-npm/handlers/observation/observation-handlers.js.map +1 -0
- package/dist-npm/handlers/observation/sensory.d.ts +29 -0
- package/dist-npm/handlers/observation/sensory.d.ts.map +1 -0
- package/dist-npm/handlers/observation/sensory.js +77 -0
- package/dist-npm/handlers/observation/sensory.js.map +1 -0
- package/dist-npm/handlers/state-change.d.ts +47 -0
- package/dist-npm/handlers/state-change.d.ts.map +1 -0
- package/dist-npm/handlers/state-change.js +166 -0
- package/dist-npm/handlers/state-change.js.map +1 -0
- package/dist-npm/index.d.ts +14 -0
- package/dist-npm/index.d.ts.map +1 -0
- package/dist-npm/index.js +32 -0
- package/dist-npm/index.js.map +1 -0
- package/dist-npm/processor.d.ts +62 -0
- package/dist-npm/processor.d.ts.map +1 -0
- package/dist-npm/processor.js +332 -0
- package/dist-npm/processor.js.map +1 -0
- package/dist-npm/types.d.ts +6 -0
- package/dist-npm/types.d.ts.map +1 -0
- package/dist-npm/types.js +6 -0
- package/dist-npm/types.js.map +1 -0
- package/package.json +48 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* WorldQuery: Read-only view of WorldModel for event handlers
|
|
4
|
+
*
|
|
5
|
+
* Per ADR-075, handlers receive a read-only query interface instead of
|
|
6
|
+
* full world access. This preserves stdlib as the gatekeeper for mutations.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.createWorldQuery = createWorldQuery;
|
|
10
|
+
/**
|
|
11
|
+
* Create a WorldQuery wrapper around a WorldModel
|
|
12
|
+
*
|
|
13
|
+
* This provides read-only access to the world model for event handlers.
|
|
14
|
+
*/
|
|
15
|
+
function createWorldQuery(world) {
|
|
16
|
+
return {
|
|
17
|
+
getEntity: (id) => world.getEntity(id),
|
|
18
|
+
hasEntity: (id) => world.hasEntity(id),
|
|
19
|
+
getPlayer: () => world.getPlayer(),
|
|
20
|
+
getCurrentRoom: () => {
|
|
21
|
+
const player = world.getPlayer();
|
|
22
|
+
return player ? world.getContainingRoom(player.id) : undefined;
|
|
23
|
+
},
|
|
24
|
+
getContainingRoom: (entityId) => world.getContainingRoom(entityId),
|
|
25
|
+
getLocation: (entityId) => world.getLocation(entityId),
|
|
26
|
+
getContents: (containerId) => world.getContents(containerId),
|
|
27
|
+
findByTrait: (traitType) => world.findByTrait(traitType),
|
|
28
|
+
findWhere: (predicate) => world.findWhere(predicate),
|
|
29
|
+
getStateValue: (key) => world.getStateValue(key),
|
|
30
|
+
getCapability: (name) => world.getCapability(name),
|
|
31
|
+
hasCapability: (name) => world.hasCapability(name),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=world-query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"world-query.js","sourceRoot":"","sources":["../../src/effects/world-query.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AA6EH,4CAkBC;AAvBD;;;;GAIG;AACH,SAAgB,gBAAgB,CAAC,KAAkB;IACjD,OAAO;QACL,SAAS,EAAE,CAAC,EAAU,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;QAC9C,SAAS,EAAE,CAAC,EAAU,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;QAC9C,SAAS,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,SAAS,EAAE;QAClC,cAAc,EAAE,GAAG,EAAE;YACnB,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,EAAE,CAAC;YACjC,OAAO,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC,iBAAiB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACjE,CAAC;QACD,iBAAiB,EAAE,CAAC,QAAgB,EAAE,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,QAAQ,CAAC;QAC1E,WAAW,EAAE,CAAC,QAAgB,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,QAAQ,CAAC;QAC9D,WAAW,EAAE,CAAC,WAAmB,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,WAAW,CAAC;QACpE,WAAW,EAAE,CAAC,SAAoB,EAAE,EAAE,CAAC,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC;QACnE,SAAS,EAAE,CAAC,SAAwC,EAAE,EAAE,CAAC,KAAK,CAAC,SAAS,CAAC,SAAS,CAAC;QACnF,aAAa,EAAE,CAAC,GAAW,EAAE,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC;QACxD,aAAa,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC;QAC1D,aAAa,EAAE,CAAC,IAAY,EAAE,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC;KAC3D,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event handler types for the event system
|
|
3
|
+
*
|
|
4
|
+
* ADR-075: Entity handlers receive read-only WorldQuery and return Effect[]
|
|
5
|
+
*/
|
|
6
|
+
import type { ISemanticEvent } from '@sharpee/core';
|
|
7
|
+
import type { WorldQuery } from './effects/world-query';
|
|
8
|
+
import type { Effect } from './effects/types';
|
|
9
|
+
/**
|
|
10
|
+
* Game event that can be handled by entities or the story
|
|
11
|
+
*/
|
|
12
|
+
export interface IGameEvent extends ISemanticEvent {
|
|
13
|
+
type: string;
|
|
14
|
+
data: Record<string, any>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Entity event handler function signature (ADR-075)
|
|
18
|
+
*
|
|
19
|
+
* Handlers receive:
|
|
20
|
+
* - event: The game event to handle
|
|
21
|
+
* - query: Read-only access to world state
|
|
22
|
+
*
|
|
23
|
+
* Handlers return Effect[] - intents that EffectProcessor validates and applies
|
|
24
|
+
*/
|
|
25
|
+
export type EntityEventHandler = (event: IGameEvent, query: WorldQuery) => Effect[];
|
|
26
|
+
/**
|
|
27
|
+
* Legacy handler signature for backward compatibility during migration
|
|
28
|
+
* These handlers directly mutate world state (old pattern) and return events.
|
|
29
|
+
* @deprecated Use EntityEventHandler with Effect[] return type
|
|
30
|
+
*/
|
|
31
|
+
export type LegacyEntityEventHandler = (event: IGameEvent, world?: any) => void | ISemanticEvent[];
|
|
32
|
+
/**
|
|
33
|
+
* Simple event handler that only receives the event (no world access)
|
|
34
|
+
* Used for story-level daemons and event listeners
|
|
35
|
+
* @deprecated Use StoryEventHandler instead
|
|
36
|
+
*/
|
|
37
|
+
export type SimpleEventHandler = (event: IGameEvent) => void | ISemanticEvent[];
|
|
38
|
+
/**
|
|
39
|
+
* Story-level event handler (ADR-075)
|
|
40
|
+
* Receives read-only WorldQuery and returns Effect[]
|
|
41
|
+
*/
|
|
42
|
+
export type StoryEventHandler = (event: IGameEvent, query: WorldQuery) => Effect[];
|
|
43
|
+
/**
|
|
44
|
+
* Any event handler type (for migration period)
|
|
45
|
+
* Supports both ADR-075 Effect-returning handlers and legacy handlers
|
|
46
|
+
*/
|
|
47
|
+
export type AnyEventHandler = EntityEventHandler | LegacyEntityEventHandler;
|
|
48
|
+
/**
|
|
49
|
+
* Collection of event handlers keyed by event type
|
|
50
|
+
* ADR-075: Supports multiple handlers per event type
|
|
51
|
+
* During migration, supports both Effect-returning and legacy handlers
|
|
52
|
+
*/
|
|
53
|
+
export interface IEventHandlers {
|
|
54
|
+
[eventType: string]: AnyEventHandler | AnyEventHandler[];
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Entity with event handling capability
|
|
58
|
+
*/
|
|
59
|
+
export interface IEventCapableEntity {
|
|
60
|
+
/**
|
|
61
|
+
* Event handlers for this entity
|
|
62
|
+
* Key is the event type (e.g., 'if.event.pushed')
|
|
63
|
+
* Value is a handler function or array of handlers
|
|
64
|
+
*/
|
|
65
|
+
on?: IEventHandlers;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=handler-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler-types.d.ts","sourceRoot":"","sources":["../src/handler-types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,UAAW,SAAQ,cAAc;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC3B;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,KAAK,MAAM,EAAE,CAAC;AAEpF;;;;GAIG;AACH,MAAM,MAAM,wBAAwB,GAAG,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,CAAC,EAAE,GAAG,KAAK,IAAI,GAAG,cAAc,EAAE,CAAC;AAEnG;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,GAAG,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,GAAG,cAAc,EAAE,CAAC;AAEhF;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,KAAK,MAAM,EAAE,CAAC;AAEnF;;;GAGG;AACH,MAAM,MAAM,eAAe,GAAG,kBAAkB,GAAG,wBAAwB,CAAC;AAE5E;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,CAAC,SAAS,EAAE,MAAM,GAAG,eAAe,GAAG,eAAe,EAAE,CAAC;CAC1D;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,EAAE,CAAC,EAAE,cAAc,CAAC;CACrB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handler-types.js","sourceRoot":"","sources":["../src/handler-types.ts"],"names":[],"mappings":";AAAA;;;;GAIG"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Complex manipulation event handlers
|
|
3
|
+
*
|
|
4
|
+
* These handlers process events for complex object interactions
|
|
5
|
+
* like giving, showing, and throwing.
|
|
6
|
+
*/
|
|
7
|
+
import { WorldModel, EventHandler } from '@sharpee/world-model';
|
|
8
|
+
/**
|
|
9
|
+
* Handle GIVEN event - transfer item to recipient or refuse
|
|
10
|
+
*/
|
|
11
|
+
export declare const handleGiven: EventHandler;
|
|
12
|
+
/**
|
|
13
|
+
* Handle SHOWN event - make NPC aware of item
|
|
14
|
+
*
|
|
15
|
+
* This event doesn't change item ownership but could trigger
|
|
16
|
+
* NPC reactions or update their knowledge/memory.
|
|
17
|
+
*/
|
|
18
|
+
export declare const handleShown: EventHandler;
|
|
19
|
+
/**
|
|
20
|
+
* Handle THROWN event - move item and possibly destroy it
|
|
21
|
+
*/
|
|
22
|
+
export declare const handleThrown: EventHandler;
|
|
23
|
+
/**
|
|
24
|
+
* Handle ITEM_DESTROYED event - remove item from world
|
|
25
|
+
*/
|
|
26
|
+
export declare const handleItemDestroyed: EventHandler;
|
|
27
|
+
/**
|
|
28
|
+
* Register all complex manipulation handlers
|
|
29
|
+
*/
|
|
30
|
+
export declare function registerComplexManipulationHandlers(world: WorldModel): void;
|
|
31
|
+
//# sourceMappingURL=complex-manipulation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"complex-manipulation.d.ts","sourceRoot":"","sources":["../../src/handlers/complex-manipulation.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,UAAU,EAAa,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAG3E;;GAEG;AACH,eAAO,MAAM,WAAW,EAAE,YAUzB,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,EAAE,YAazB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,YAgB1B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB,EAAE,YAQjC,CAAC;AAEF;;GAEG;AACH,wBAAgB,mCAAmC,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAK3E"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Complex manipulation event handlers
|
|
4
|
+
*
|
|
5
|
+
* These handlers process events for complex object interactions
|
|
6
|
+
* like giving, showing, and throwing.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.handleItemDestroyed = exports.handleThrown = exports.handleShown = exports.handleGiven = void 0;
|
|
10
|
+
exports.registerComplexManipulationHandlers = registerComplexManipulationHandlers;
|
|
11
|
+
const core_1 = require("@sharpee/core");
|
|
12
|
+
const if_domain_1 = require("@sharpee/if-domain");
|
|
13
|
+
/**
|
|
14
|
+
* Handle GIVEN event - transfer item to recipient or refuse
|
|
15
|
+
*/
|
|
16
|
+
const handleGiven = (event, world) => {
|
|
17
|
+
const { actor, target, instrument, location } = event.entities;
|
|
18
|
+
const data = (0, core_1.getUntypedEventData)(event);
|
|
19
|
+
const accepted = Boolean(data?.accepted);
|
|
20
|
+
if (target && location && accepted) {
|
|
21
|
+
// Transfer the item to the recipient
|
|
22
|
+
world.moveEntity(target, location);
|
|
23
|
+
}
|
|
24
|
+
// If not accepted, item stays with the giver (no action needed)
|
|
25
|
+
};
|
|
26
|
+
exports.handleGiven = handleGiven;
|
|
27
|
+
/**
|
|
28
|
+
* Handle SHOWN event - make NPC aware of item
|
|
29
|
+
*
|
|
30
|
+
* This event doesn't change item ownership but could trigger
|
|
31
|
+
* NPC reactions or update their knowledge/memory.
|
|
32
|
+
*/
|
|
33
|
+
const handleShown = (event, world) => {
|
|
34
|
+
const { actor, target, instrument } = event.entities;
|
|
35
|
+
// target is the item being shown, instrument is the viewer
|
|
36
|
+
// In a more complex system, this would update the NPC's knowledge
|
|
37
|
+
// or trigger a reaction. For now, we just record the event happened.
|
|
38
|
+
// Future implementations could:
|
|
39
|
+
// - Update an NPC memory/knowledge trait
|
|
40
|
+
// - Set flags for conversation topics
|
|
41
|
+
// - Trigger immediate reactions
|
|
42
|
+
// No world model changes for basic implementation
|
|
43
|
+
};
|
|
44
|
+
exports.handleShown = handleShown;
|
|
45
|
+
/**
|
|
46
|
+
* Handle THROWN event - move item and possibly destroy it
|
|
47
|
+
*/
|
|
48
|
+
const handleThrown = (event, world) => {
|
|
49
|
+
const { target, location } = event.entities;
|
|
50
|
+
const data = (0, core_1.getUntypedEventData)(event);
|
|
51
|
+
const willBreak = Boolean(data?.willBreak);
|
|
52
|
+
const finalLocation = typeof data?.finalLocation === 'string' ? data.finalLocation : undefined;
|
|
53
|
+
if (target) {
|
|
54
|
+
if (willBreak) {
|
|
55
|
+
// Item will be destroyed (handled by ITEM_DESTROYED event)
|
|
56
|
+
// For now, just move it to null location
|
|
57
|
+
world.removeEntity(target);
|
|
58
|
+
}
|
|
59
|
+
else if (finalLocation) {
|
|
60
|
+
// Move item to its final location
|
|
61
|
+
world.moveEntity(target, finalLocation);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
exports.handleThrown = handleThrown;
|
|
66
|
+
/**
|
|
67
|
+
* Handle ITEM_DESTROYED event - remove item from world
|
|
68
|
+
*/
|
|
69
|
+
const handleItemDestroyed = (event, world) => {
|
|
70
|
+
const data = (0, core_1.getUntypedEventData)(event);
|
|
71
|
+
const itemId = typeof data?.item === 'string' ? data.item : undefined;
|
|
72
|
+
if (itemId) {
|
|
73
|
+
// Remove the item from the world
|
|
74
|
+
world.removeEntity(itemId);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
exports.handleItemDestroyed = handleItemDestroyed;
|
|
78
|
+
/**
|
|
79
|
+
* Register all complex manipulation handlers
|
|
80
|
+
*/
|
|
81
|
+
function registerComplexManipulationHandlers(world) {
|
|
82
|
+
world.registerEventHandler(if_domain_1.IFEvents.GIVEN, exports.handleGiven);
|
|
83
|
+
world.registerEventHandler(if_domain_1.IFEvents.SHOWN, exports.handleShown);
|
|
84
|
+
world.registerEventHandler(if_domain_1.IFEvents.THROWN, exports.handleThrown);
|
|
85
|
+
world.registerEventHandler(if_domain_1.IFEvents.ITEM_DESTROYED, exports.handleItemDestroyed);
|
|
86
|
+
}
|
|
87
|
+
//# sourceMappingURL=complex-manipulation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"complex-manipulation.js","sourceRoot":"","sources":["../../src/handlers/complex-manipulation.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AA+EH,kFAKC;AAlFD,wCAAoE;AAEpE,kDAA8C;AAE9C;;GAEG;AACI,MAAM,WAAW,GAAiB,CAAC,KAAqB,EAAE,KAAU,EAAE,EAAE;IAC7E,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC,QAAQ,CAAC;IAC/D,MAAM,IAAI,GAAG,IAAA,0BAAmB,EAAC,KAAK,CAAC,CAAC;IACxC,MAAM,QAAQ,GAAG,OAAO,CAAC,IAAI,EAAE,QAAQ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H,CAAC,CAAC;AAhBW,QAAA,YAAY,gBAgBvB;AAEF;;GAEG;AACI,MAAM,mBAAmB,GAAiB,CAAC,KAAqB,EAAE,KAAU,EAAE,EAAE;IACrF,MAAM,IAAI,GAAG,IAAA,0BAAmB,EAAC,KAAK,CAAC,CAAC;IACxC,MAAM,MAAM,GAAG,OAAO,IAAI,EAAE,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;IAEtE,IAAI,MAAM,EAAE,CAAC;QACX,iCAAiC;QACjC,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IAC7B,CAAC;AACH,CAAC,CAAC;AARW,QAAA,mBAAmB,uBAQ9B;AAEF;;GAEG;AACH,SAAgB,mCAAmC,CAAC,KAAiB;IACnE,KAAK,CAAC,oBAAoB,CAAC,oBAAQ,CAAC,KAAK,EAAE,mBAAW,CAAC,CAAC;IACxD,KAAK,CAAC,oBAAoB,CAAC,oBAAQ,CAAC,KAAK,EAAE,mBAAW,CAAC,CAAC;IACxD,KAAK,CAAC,oBAAoB,CAAC,oBAAQ,CAAC,MAAM,EAAE,oBAAY,CAAC,CAAC;IAC1D,KAAK,CAAC,oBAAoB,CAAC,oBAAQ,CAAC,cAAc,EAAE,2BAAmB,CAAC,CAAC;AAC3E,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Device manipulation event handlers
|
|
3
|
+
*
|
|
4
|
+
* These handlers process events for device interactions like
|
|
5
|
+
* pushing, pulling, turning, and using objects.
|
|
6
|
+
*/
|
|
7
|
+
import { WorldModel, EventHandler } from '@sharpee/world-model';
|
|
8
|
+
/**
|
|
9
|
+
* Handle PUSHED event - process pushing objects/buttons
|
|
10
|
+
*/
|
|
11
|
+
export declare const handlePushed: EventHandler;
|
|
12
|
+
/**
|
|
13
|
+
* Handle PULLED event - process pulling objects
|
|
14
|
+
*/
|
|
15
|
+
export declare const handlePulled: EventHandler;
|
|
16
|
+
/**
|
|
17
|
+
* Handle TURNED event - process turning dials/knobs
|
|
18
|
+
*/
|
|
19
|
+
export declare const handleTurned: EventHandler;
|
|
20
|
+
/**
|
|
21
|
+
* Handle USED event - generic device usage
|
|
22
|
+
*/
|
|
23
|
+
export declare const handleUsed: EventHandler;
|
|
24
|
+
/**
|
|
25
|
+
* Register all device manipulation handlers
|
|
26
|
+
*/
|
|
27
|
+
export declare function registerDeviceHandlers(world: WorldModel): void;
|
|
28
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/handlers/device/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,UAAU,EAAa,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAG3E;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,YA0C1B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,YAmC1B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,YA+B1B,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,UAAU,EAAE,YAmCxB,CAAC;AAEF;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAK9D"}
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Device manipulation event handlers
|
|
4
|
+
*
|
|
5
|
+
* These handlers process events for device interactions like
|
|
6
|
+
* pushing, pulling, turning, and using objects.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.handleUsed = exports.handleTurned = exports.handlePulled = exports.handlePushed = void 0;
|
|
10
|
+
exports.registerDeviceHandlers = registerDeviceHandlers;
|
|
11
|
+
const core_1 = require("@sharpee/core");
|
|
12
|
+
const world_model_1 = require("@sharpee/world-model");
|
|
13
|
+
const if_domain_1 = require("@sharpee/if-domain");
|
|
14
|
+
/**
|
|
15
|
+
* Handle PUSHED event - process pushing objects/buttons
|
|
16
|
+
*/
|
|
17
|
+
const handlePushed = (event, world) => {
|
|
18
|
+
const { target, location } = event.entities;
|
|
19
|
+
const data = (0, core_1.getUntypedEventData)(event);
|
|
20
|
+
const pushType = String(data?.pushType || '');
|
|
21
|
+
if (!target)
|
|
22
|
+
return;
|
|
23
|
+
// Get the actual entity from the world model
|
|
24
|
+
const targetEntity = world.getEntity(target);
|
|
25
|
+
if (!targetEntity)
|
|
26
|
+
return;
|
|
27
|
+
switch (pushType) {
|
|
28
|
+
case 'button':
|
|
29
|
+
// If it's a switchable button, toggle its state
|
|
30
|
+
if (targetEntity.has(world_model_1.TraitType.SWITCHABLE) && data?.willToggle) {
|
|
31
|
+
const switchable = targetEntity.get(world_model_1.TraitType.SWITCHABLE);
|
|
32
|
+
switchable.isOn = data?.newState;
|
|
33
|
+
// This might trigger other device activations
|
|
34
|
+
// Future: Add support for linked devices
|
|
35
|
+
}
|
|
36
|
+
break;
|
|
37
|
+
case 'moveable':
|
|
38
|
+
case 'heavy':
|
|
39
|
+
// If the object moved in a direction
|
|
40
|
+
if (data?.moved && data?.moveDirection && location) {
|
|
41
|
+
// Future: Actually move the object to adjacent location
|
|
42
|
+
// For now, we just record that it moved
|
|
43
|
+
// If it reveals a passage
|
|
44
|
+
if (data?.revealsPassage) {
|
|
45
|
+
// Future: Add new exit to room or reveal hidden object
|
|
46
|
+
// This would require modifying room exits or revealing concealed items
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
break;
|
|
50
|
+
case 'fixed':
|
|
51
|
+
// No state changes for fixed objects
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
exports.handlePushed = handlePushed;
|
|
56
|
+
/**
|
|
57
|
+
* Handle PULLED event - process pulling objects
|
|
58
|
+
*/
|
|
59
|
+
const handlePulled = (event, world) => {
|
|
60
|
+
const { target } = event.entities;
|
|
61
|
+
const data = (0, core_1.getUntypedEventData)(event);
|
|
62
|
+
const pullType = String(data?.pullType || '');
|
|
63
|
+
if (!target)
|
|
64
|
+
return;
|
|
65
|
+
// Get the actual entity from the world model
|
|
66
|
+
const targetEntity = world.getEntity(target);
|
|
67
|
+
if (!targetEntity)
|
|
68
|
+
return;
|
|
69
|
+
switch (pullType) {
|
|
70
|
+
case 'lever':
|
|
71
|
+
case 'cord':
|
|
72
|
+
// Toggle switchable state if applicable
|
|
73
|
+
if (targetEntity.has(world_model_1.TraitType.SWITCHABLE) && data?.willToggle) {
|
|
74
|
+
const switchable = targetEntity.get(world_model_1.TraitType.SWITCHABLE);
|
|
75
|
+
switchable.isOn = data?.newState;
|
|
76
|
+
}
|
|
77
|
+
break;
|
|
78
|
+
case 'attached':
|
|
79
|
+
// Object is attached to something else
|
|
80
|
+
if (data?.willDetach) {
|
|
81
|
+
// Future: Handle detachment logic
|
|
82
|
+
}
|
|
83
|
+
break;
|
|
84
|
+
case 'moveable':
|
|
85
|
+
// Similar to pushing but in opposite direction
|
|
86
|
+
if (data?.moved && data?.moveDirection) {
|
|
87
|
+
// Future: Move object logic
|
|
88
|
+
}
|
|
89
|
+
break;
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
exports.handlePulled = handlePulled;
|
|
93
|
+
/**
|
|
94
|
+
* Handle TURNED event - process turning dials/knobs
|
|
95
|
+
*/
|
|
96
|
+
const handleTurned = (event, world) => {
|
|
97
|
+
const { target } = event.entities;
|
|
98
|
+
const data = (0, core_1.getUntypedEventData)(event);
|
|
99
|
+
const turnType = String(data?.turnType || '');
|
|
100
|
+
const newSetting = data?.newSetting;
|
|
101
|
+
if (!target)
|
|
102
|
+
return;
|
|
103
|
+
// Get the actual entity from the world model
|
|
104
|
+
const targetEntity = world.getEntity(target);
|
|
105
|
+
if (!targetEntity)
|
|
106
|
+
return;
|
|
107
|
+
switch (turnType) {
|
|
108
|
+
case 'dial':
|
|
109
|
+
case 'knob':
|
|
110
|
+
// Future: Add a TURNABLE trait with setting property
|
|
111
|
+
// For now, just handle basic switchable devices
|
|
112
|
+
if (targetEntity.has(world_model_1.TraitType.SWITCHABLE) && data?.willToggle) {
|
|
113
|
+
const switchable = targetEntity.get(world_model_1.TraitType.SWITCHABLE);
|
|
114
|
+
switchable.isOn = data?.newState;
|
|
115
|
+
}
|
|
116
|
+
break;
|
|
117
|
+
case 'wheel':
|
|
118
|
+
case 'crank':
|
|
119
|
+
// These might open/close things or activate mechanisms
|
|
120
|
+
if (data?.activatesMechanism) {
|
|
121
|
+
// Future: Trigger mechanism activation
|
|
122
|
+
}
|
|
123
|
+
break;
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
exports.handleTurned = handleTurned;
|
|
127
|
+
/**
|
|
128
|
+
* Handle USED event - generic device usage
|
|
129
|
+
*/
|
|
130
|
+
const handleUsed = (event, world) => {
|
|
131
|
+
const { target } = event.entities;
|
|
132
|
+
const data = (0, core_1.getUntypedEventData)(event);
|
|
133
|
+
const useType = String(data?.useType || '');
|
|
134
|
+
if (!target)
|
|
135
|
+
return;
|
|
136
|
+
// Get the actual entity from the world model
|
|
137
|
+
const targetEntity = world.getEntity(target);
|
|
138
|
+
if (!targetEntity)
|
|
139
|
+
return;
|
|
140
|
+
// Generic use often delegates to more specific actions
|
|
141
|
+
// or handles custom device behaviors
|
|
142
|
+
switch (useType) {
|
|
143
|
+
case 'device':
|
|
144
|
+
// Activate or deactivate device
|
|
145
|
+
if (targetEntity.has(world_model_1.TraitType.SWITCHABLE)) {
|
|
146
|
+
const switchable = targetEntity.get(world_model_1.TraitType.SWITCHABLE);
|
|
147
|
+
switchable.isOn = !switchable.isOn;
|
|
148
|
+
}
|
|
149
|
+
break;
|
|
150
|
+
case 'tool':
|
|
151
|
+
// Tools might be used with other objects
|
|
152
|
+
// This is handled by the action, not the handler
|
|
153
|
+
break;
|
|
154
|
+
case 'consumable':
|
|
155
|
+
// Some items are consumed when used
|
|
156
|
+
if (data?.consumed) {
|
|
157
|
+
world.removeEntity(target);
|
|
158
|
+
}
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
exports.handleUsed = handleUsed;
|
|
163
|
+
/**
|
|
164
|
+
* Register all device manipulation handlers
|
|
165
|
+
*/
|
|
166
|
+
function registerDeviceHandlers(world) {
|
|
167
|
+
world.registerEventHandler(if_domain_1.IFEvents.PUSHED, exports.handlePushed);
|
|
168
|
+
world.registerEventHandler(if_domain_1.IFEvents.PULLED, exports.handlePulled);
|
|
169
|
+
world.registerEventHandler(if_domain_1.IFEvents.TURNED, exports.handleTurned);
|
|
170
|
+
world.registerEventHandler(if_domain_1.IFEvents.USED, exports.handleUsed);
|
|
171
|
+
}
|
|
172
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/handlers/device/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AA4KH,wDAKC;AA/KD,wCAAoE;AACpE,sDAA2E;AAC3E,kDAA8C;AAE9C;;GAEG;AACI,MAAM,YAAY,GAAiB,CAAC,KAAqB,EAAE,KAAU,EAAE,EAAE;IAC9E,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC,QAAQ,CAAC;IAC5C,MAAM,IAAI,GAAG,IAAA,0BAAmB,EAAC,KAAK,CAAC,CAAC;IACxC,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,EAAE,QAAQ,IAAI,EAAE,CAAC,CAAC;IAE9C,IAAI,CAAC,MAAM;QAAE,OAAO;IAEpB,6CAA6C;IAC7C,MAAM,YAAY,GAAG,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC7C,IAAI,CAAC,YAAY;QAAE,OAAO;IAE1B,QAAQ,QAAQ,EAAE,CAAC;QACjB,KAAK,QAAQ;YACX,gDAAgD;YAChD,IAAI,YAAY,CAAC,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;gBACnB,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;YAC7B,CAAC;YACD,MAAM;IACV,CAAC;AACH,CAAC,CAAC;AAnCW,QAAA,UAAU,cAmCrB;AAEF;;GAEG;AACH,SAAgB,sBAAsB,CAAC,KAAiB;IACtD,KAAK,CAAC,oBAAoB,CAAC,oBAAQ,CAAC,MAAM,EAAE,oBAAY,CAAC,CAAC;IAC1D,KAAK,CAAC,oBAAoB,CAAC,oBAAQ,CAAC,MAAM,EAAE,oBAAY,CAAC,CAAC;IAC1D,KAAK,CAAC,oBAAoB,CAAC,oBAAQ,CAAC,MAAM,EAAE,oBAAY,CAAC,CAAC;IAC1D,KAAK,CAAC,oBAAoB,CAAC,oBAAQ,CAAC,IAAI,EAAE,kBAAU,CAAC,CAAC;AACxD,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Event handler registration
|
|
3
|
+
*
|
|
4
|
+
* Central module for registering all standard IF event handlers
|
|
5
|
+
*/
|
|
6
|
+
export * from './movement';
|
|
7
|
+
export * from './state-change';
|
|
8
|
+
export * from './observation';
|
|
9
|
+
export * from './meta';
|
|
10
|
+
export * from './complex-manipulation';
|
|
11
|
+
export * from './device';
|
|
12
|
+
import { WorldModel } from '@sharpee/world-model';
|
|
13
|
+
/**
|
|
14
|
+
* Register all standard IF event handlers with the world model
|
|
15
|
+
*/
|
|
16
|
+
export declare function registerStandardHandlers(world: WorldModel): void;
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/handlers/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,QAAQ,CAAC;AACvB,cAAc,wBAAwB,CAAC;AACvC,cAAc,UAAU,CAAC;AAEzB,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AASlD;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAQhE"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Event handler registration
|
|
4
|
+
*
|
|
5
|
+
* Central module for registering all standard IF event handlers
|
|
6
|
+
*/
|
|
7
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
+
if (k2 === undefined) k2 = k;
|
|
9
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
+
}
|
|
13
|
+
Object.defineProperty(o, k2, desc);
|
|
14
|
+
}) : (function(o, m, k, k2) {
|
|
15
|
+
if (k2 === undefined) k2 = k;
|
|
16
|
+
o[k2] = m[k];
|
|
17
|
+
}));
|
|
18
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
19
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
20
|
+
};
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.registerStandardHandlers = registerStandardHandlers;
|
|
23
|
+
__exportStar(require("./movement"), exports);
|
|
24
|
+
__exportStar(require("./state-change"), exports);
|
|
25
|
+
__exportStar(require("./observation"), exports);
|
|
26
|
+
__exportStar(require("./meta"), exports);
|
|
27
|
+
__exportStar(require("./complex-manipulation"), exports);
|
|
28
|
+
__exportStar(require("./device"), exports);
|
|
29
|
+
const movement_1 = require("./movement");
|
|
30
|
+
const state_change_1 = require("./state-change");
|
|
31
|
+
const observation_handlers_1 = require("./observation/observation-handlers");
|
|
32
|
+
const sensory_1 = require("./observation/sensory");
|
|
33
|
+
const meta_1 = require("./meta");
|
|
34
|
+
const complex_manipulation_1 = require("./complex-manipulation");
|
|
35
|
+
const device_1 = require("./device");
|
|
36
|
+
/**
|
|
37
|
+
* Register all standard IF event handlers with the world model
|
|
38
|
+
*/
|
|
39
|
+
function registerStandardHandlers(world) {
|
|
40
|
+
(0, movement_1.registerMovementHandlers)(world);
|
|
41
|
+
(0, state_change_1.registerStateChangeHandlers)(world);
|
|
42
|
+
(0, observation_handlers_1.registerObservationHandlers)(world);
|
|
43
|
+
(0, sensory_1.registerSensoryHandlers)(world);
|
|
44
|
+
(0, meta_1.registerMetaHandlers)(world);
|
|
45
|
+
(0, complex_manipulation_1.registerComplexManipulationHandlers)(world);
|
|
46
|
+
(0, device_1.registerDeviceHandlers)(world);
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/handlers/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;AAqBH,4DAQC;AA3BD,6CAA2B;AAC3B,iDAA+B;AAC/B,gDAA8B;AAC9B,yCAAuB;AACvB,yDAAuC;AACvC,2CAAyB;AAGzB,yCAAsD;AACtD,iDAA6D;AAC7D,6EAAiF;AACjF,mDAAgE;AAChE,iCAA8C;AAC9C,iEAA6E;AAC7E,qCAAkD;AAElD;;GAEG;AACH,SAAgB,wBAAwB,CAAC,KAAiB;IACxD,IAAA,mCAAwB,EAAC,KAAK,CAAC,CAAC;IAChC,IAAA,0CAA2B,EAAC,KAAK,CAAC,CAAC;IACnC,IAAA,kDAA2B,EAAC,KAAK,CAAC,CAAC;IACnC,IAAA,iCAAuB,EAAC,KAAK,CAAC,CAAC;IAC/B,IAAA,2BAAoB,EAAC,KAAK,CAAC,CAAC;IAC5B,IAAA,0DAAmC,EAAC,KAAK,CAAC,CAAC;IAC3C,IAAA,+BAAsB,EAAC,KAAK,CAAC,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Meta action event handlers
|
|
3
|
+
*
|
|
4
|
+
* Handles events for meta-game actions like waiting, scoring, help, etc.
|
|
5
|
+
*/
|
|
6
|
+
import { ISemanticEvent } from '@sharpee/core';
|
|
7
|
+
import { WorldModel } from '@sharpee/world-model';
|
|
8
|
+
/**
|
|
9
|
+
* Handle waited event
|
|
10
|
+
*
|
|
11
|
+
* This event is fired when a player waits/passes time.
|
|
12
|
+
* Default behavior: Increment turn counter in shared data
|
|
13
|
+
*
|
|
14
|
+
* Can be overridden to:
|
|
15
|
+
* - Trigger time-based events (e.g., NPC movements, timed puzzles)
|
|
16
|
+
* - Update atmospheric descriptions (e.g., sun setting)
|
|
17
|
+
* - Advance story-specific timers
|
|
18
|
+
*/
|
|
19
|
+
export declare function handleWaited(event: ISemanticEvent, world: any): void;
|
|
20
|
+
/**
|
|
21
|
+
* Handle score_displayed event
|
|
22
|
+
*
|
|
23
|
+
* This event is fired when a player checks their score.
|
|
24
|
+
* Default behavior: No world state changes (display only)
|
|
25
|
+
*
|
|
26
|
+
* Can be overridden to:
|
|
27
|
+
* - Track how often player checks score
|
|
28
|
+
* - Trigger achievements based on score milestones
|
|
29
|
+
* - Update NPC reactions based on player progress
|
|
30
|
+
*/
|
|
31
|
+
export declare function handleScoreDisplayed(event: ISemanticEvent, world: any): void;
|
|
32
|
+
/**
|
|
33
|
+
* Handle help_displayed event
|
|
34
|
+
*
|
|
35
|
+
* This event is fired when a player requests help.
|
|
36
|
+
* Default behavior: Mark help as requested in shared data
|
|
37
|
+
*
|
|
38
|
+
* Can be overridden to:
|
|
39
|
+
* - Track which help topics were viewed
|
|
40
|
+
* - Adjust difficulty based on help usage
|
|
41
|
+
* - Provide context-sensitive help
|
|
42
|
+
*/
|
|
43
|
+
export declare function handleHelpDisplayed(event: ISemanticEvent, world: any): void;
|
|
44
|
+
/**
|
|
45
|
+
* Handle about_displayed event
|
|
46
|
+
*
|
|
47
|
+
* This event is fired when a player requests game information.
|
|
48
|
+
* Default behavior: Track that about was viewed
|
|
49
|
+
*
|
|
50
|
+
* Can be overridden to:
|
|
51
|
+
* - Unlock easter eggs for viewing credits
|
|
52
|
+
* - Track completion statistics
|
|
53
|
+
*/
|
|
54
|
+
export declare function handleAboutDisplayed(event: ISemanticEvent, world: any): void;
|
|
55
|
+
/**
|
|
56
|
+
* Register all meta action event handlers
|
|
57
|
+
*/
|
|
58
|
+
export declare function registerMetaHandlers(world: WorldModel): void;
|
|
59
|
+
//# sourceMappingURL=meta.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../src/handlers/meta.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC/C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI,CAiBpE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI,CAqB5E;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI,CAiC3E;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,cAAc,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI,CAuB5E;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAK5D"}
|