@maka/maka-cli 5.1.29 → 5.1.31
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/bundle/typescript/package.json +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/commands/command-registry.d.ts +9 -0
- package/bundle/typescript/src/commands/game/sideQuest/commands/command-registry.js +26 -0
- package/bundle/typescript/src/commands/game/sideQuest/commands/command-registry.js.map +1 -0
- package/bundle/typescript/src/commands/game/sideQuest/commands/command.d.ts +13 -7
- package/bundle/typescript/src/commands/game/sideQuest/commands/command.js +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/commands/command.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/commands/drop.d.ts +1 -2
- package/bundle/typescript/src/commands/game/sideQuest/commands/drop.js +2 -1
- package/bundle/typescript/src/commands/game/sideQuest/commands/drop.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/commands/equip.d.ts +1 -2
- package/bundle/typescript/src/commands/game/sideQuest/commands/equip.js +1 -0
- package/bundle/typescript/src/commands/game/sideQuest/commands/equip.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/commands/give.d.ts +7 -0
- package/bundle/typescript/src/commands/game/sideQuest/commands/give.js +51 -0
- package/bundle/typescript/src/commands/game/sideQuest/commands/give.js.map +1 -0
- package/bundle/typescript/src/commands/game/sideQuest/commands/go.d.ts +1 -2
- package/bundle/typescript/src/commands/game/sideQuest/commands/go.js +3 -0
- package/bundle/typescript/src/commands/game/sideQuest/commands/go.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/commands/lock.d.ts +1 -2
- package/bundle/typescript/src/commands/game/sideQuest/commands/lock.js +1 -0
- package/bundle/typescript/src/commands/game/sideQuest/commands/lock.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/commands/look.d.ts +1 -2
- package/bundle/typescript/src/commands/game/sideQuest/commands/look.js +2 -1
- package/bundle/typescript/src/commands/game/sideQuest/commands/look.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/commands/say.d.ts +3 -11
- package/bundle/typescript/src/commands/game/sideQuest/commands/say.js +7 -32
- package/bundle/typescript/src/commands/game/sideQuest/commands/say.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/commands/search.d.ts +1 -2
- package/bundle/typescript/src/commands/game/sideQuest/commands/search.js +1 -0
- package/bundle/typescript/src/commands/game/sideQuest/commands/search.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/commands/solve.d.ts +1 -2
- package/bundle/typescript/src/commands/game/sideQuest/commands/solve.js +1 -0
- package/bundle/typescript/src/commands/game/sideQuest/commands/solve.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/commands/store.d.ts +1 -2
- package/bundle/typescript/src/commands/game/sideQuest/commands/store.js +1 -0
- package/bundle/typescript/src/commands/game/sideQuest/commands/store.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/commands/take.d.ts +1 -2
- package/bundle/typescript/src/commands/game/sideQuest/commands/take.js +1 -0
- package/bundle/typescript/src/commands/game/sideQuest/commands/take.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/commands/talk.d.ts +3 -4
- package/bundle/typescript/src/commands/game/sideQuest/commands/talk.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/commands/unequip.d.ts +1 -2
- package/bundle/typescript/src/commands/game/sideQuest/commands/unequip.js +1 -0
- package/bundle/typescript/src/commands/game/sideQuest/commands/unequip.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/commands/unlock.d.ts +1 -2
- package/bundle/typescript/src/commands/game/sideQuest/commands/unlock.js +34 -24
- package/bundle/typescript/src/commands/game/sideQuest/commands/unlock.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/commands/use.d.ts +1 -2
- package/bundle/typescript/src/commands/game/sideQuest/commands/use.js +1 -0
- package/bundle/typescript/src/commands/game/sideQuest/commands/use.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/factories/command-factory.d.ts +9 -0
- package/bundle/typescript/src/commands/game/sideQuest/factories/{commandF.js → command-factory.js} +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/factories/command-factory.js.map +1 -0
- package/bundle/typescript/src/commands/game/sideQuest/factories/item-factory.d.ts +5 -0
- package/bundle/typescript/src/commands/game/sideQuest/factories/item-factory.js +24 -0
- package/bundle/typescript/src/commands/game/sideQuest/factories/item-factory.js.map +1 -0
- package/bundle/typescript/src/commands/game/sideQuest/factories/npc-factory.d.ts +10 -0
- package/bundle/typescript/src/commands/game/sideQuest/factories/npc-factory.js +36 -0
- package/bundle/typescript/src/commands/game/sideQuest/factories/npc-factory.js.map +1 -0
- package/bundle/typescript/src/commands/game/sideQuest/factories/puzzle-factory.d.ts +6 -0
- package/bundle/typescript/src/commands/game/sideQuest/factories/puzzle-factory.js +24 -0
- package/bundle/typescript/src/commands/game/sideQuest/factories/puzzle-factory.js.map +1 -0
- package/bundle/typescript/src/commands/game/sideQuest/factories/room-factory.d.ts +6 -0
- package/bundle/typescript/src/commands/game/sideQuest/factories/room-factory.js +19 -0
- package/bundle/typescript/src/commands/game/sideQuest/factories/room-factory.js.map +1 -0
- package/bundle/typescript/src/commands/game/sideQuest/factories/{sceneSynthesizer.d.ts → scene-factory.d.ts} +2 -2
- package/bundle/typescript/src/commands/game/sideQuest/factories/scene-factory.js +115 -0
- package/bundle/typescript/src/commands/game/sideQuest/factories/scene-factory.js.map +1 -0
- package/bundle/typescript/src/commands/game/sideQuest/game.d.ts +11 -5
- package/bundle/typescript/src/commands/game/sideQuest/game.js +102 -10
- package/bundle/typescript/src/commands/game/sideQuest/game.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/models/door.d.ts +7 -3
- package/bundle/typescript/src/commands/game/sideQuest/models/door.js +1 -2
- package/bundle/typescript/src/commands/game/sideQuest/models/door.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/models/inventory.d.ts +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/models/inventory.js +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/models/inventory.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/models/item.d.ts +26 -4
- package/bundle/typescript/src/commands/game/sideQuest/models/item.js +36 -4
- package/bundle/typescript/src/commands/game/sideQuest/models/item.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/models/npc.d.ts +22 -14
- package/bundle/typescript/src/commands/game/sideQuest/models/npc.js +141 -49
- package/bundle/typescript/src/commands/game/sideQuest/models/npc.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/models/player.d.ts +16 -4
- package/bundle/typescript/src/commands/game/sideQuest/models/player.js +85 -57
- package/bundle/typescript/src/commands/game/sideQuest/models/player.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/models/puzzle.d.ts +11 -2
- package/bundle/typescript/src/commands/game/sideQuest/models/puzzle.js +2 -2
- package/bundle/typescript/src/commands/game/sideQuest/models/puzzle.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/models/room.d.ts +29 -6
- package/bundle/typescript/src/commands/game/sideQuest/models/room.js +79 -7
- package/bundle/typescript/src/commands/game/sideQuest/models/room.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/models/scene.d.ts +29 -18
- package/bundle/typescript/src/commands/game/sideQuest/models/scene.js +82 -69
- package/bundle/typescript/src/commands/game/sideQuest/models/scene.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/scenes/scene1.json +93 -114
- package/bundle/typescript/src/commands/game/sideQuest/scenes/scene2.json +130 -151
- package/bundle/typescript/src/commands/game/sideQuest/types/enums.d.ts +13 -7
- package/bundle/typescript/src/commands/game/sideQuest/types/enums.js +12 -6
- package/bundle/typescript/src/commands/game/sideQuest/types/enums.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/types/{types.d.ts → player-equipment.d.ts} +8 -10
- package/bundle/typescript/src/commands/game/sideQuest/types/player-equipment.js +2 -0
- package/bundle/typescript/src/commands/game/sideQuest/types/player-equipment.js.map +1 -0
- package/bundle/typescript/src/commands/game/sideQuest/types/seed/exit-seed.d.ts +6 -0
- package/bundle/typescript/src/commands/game/sideQuest/types/seed/exit-seed.js +2 -0
- package/bundle/typescript/src/commands/game/sideQuest/types/seed/exit-seed.js.map +1 -0
- package/bundle/typescript/src/commands/game/sideQuest/types/seed/item-seed.d.ts +22 -0
- package/bundle/typescript/src/commands/game/sideQuest/types/seed/item-seed.js +2 -0
- package/bundle/typescript/src/commands/game/sideQuest/types/seed/item-seed.js.map +1 -0
- package/bundle/typescript/src/commands/game/sideQuest/types/seed/lifestyle-seed.d.ts +22 -0
- package/bundle/typescript/src/commands/game/sideQuest/types/seed/lifestyle-seed.js +2 -0
- package/bundle/typescript/src/commands/game/sideQuest/types/seed/lifestyle-seed.js.map +1 -0
- package/bundle/typescript/src/commands/game/sideQuest/types/seed/npc-seed.d.ts +6 -0
- package/bundle/typescript/src/commands/game/sideQuest/types/seed/npc-seed.js +2 -0
- package/bundle/typescript/src/commands/game/sideQuest/types/seed/npc-seed.js.map +1 -0
- package/bundle/typescript/src/commands/game/sideQuest/types/seed/player-seed.d.ts +6 -0
- package/bundle/typescript/src/commands/game/sideQuest/types/seed/player-seed.js +2 -0
- package/bundle/typescript/src/commands/game/sideQuest/types/seed/player-seed.js.map +1 -0
- package/bundle/typescript/src/commands/game/sideQuest/types/seed/puzzle-seed.d.ts +11 -0
- package/bundle/typescript/src/commands/game/sideQuest/types/seed/puzzle-seed.js +2 -0
- package/bundle/typescript/src/commands/game/sideQuest/types/seed/puzzle-seed.js.map +1 -0
- package/bundle/typescript/src/commands/game/sideQuest/types/seed/room-seed.d.ts +16 -0
- package/bundle/typescript/src/commands/game/sideQuest/types/seed/room-seed.js +2 -0
- package/bundle/typescript/src/commands/game/sideQuest/types/seed/room-seed.js.map +1 -0
- package/bundle/typescript/src/commands/game/sideQuest/types/seed/scene-seed.d.ts +16 -0
- package/bundle/typescript/src/commands/game/sideQuest/types/seed/scene-seed.js +2 -0
- package/bundle/typescript/src/commands/game/sideQuest/types/seed/scene-seed.js.map +1 -0
- package/bundle/typescript/src/commands/game/sideQuest/types/{abstracts.d.ts → shared/abstracts.d.ts} +12 -9
- package/bundle/typescript/src/commands/game/sideQuest/types/{abstracts.js → shared/abstracts.js} +7 -2
- package/bundle/typescript/src/commands/game/sideQuest/types/shared/abstracts.js.map +1 -0
- package/bundle/typescript/src/commands/game/sideQuest/types/shared/direction-enum.d.ts +8 -0
- package/bundle/typescript/src/commands/game/sideQuest/types/shared/direction-enum.js +10 -0
- package/bundle/typescript/src/commands/game/sideQuest/types/shared/direction-enum.js.map +1 -0
- package/bundle/typescript/src/commands/game/sideQuest/types/shared/equipment-enum.d.ts +25 -0
- package/bundle/typescript/src/commands/game/sideQuest/types/shared/equipment-enum.js +27 -0
- package/bundle/typescript/src/commands/game/sideQuest/types/shared/equipment-enum.js.map +1 -0
- package/bundle/typescript/src/commands/game/sideQuest/types/shared/item-enum.d.ts +34 -0
- package/bundle/typescript/src/commands/game/sideQuest/types/shared/item-enum.js +38 -0
- package/bundle/typescript/src/commands/game/sideQuest/types/shared/item-enum.js.map +1 -0
- package/bundle/typescript/src/commands/game/sideQuest/ui.d.ts +6 -2
- package/bundle/typescript/src/commands/game/sideQuest/ui.js +48 -79
- package/bundle/typescript/src/commands/game/sideQuest/ui.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/utilities/logger.d.ts +4 -2
- package/bundle/typescript/src/commands/game/sideQuest/utilities/logger.js +8 -4
- package/bundle/typescript/src/commands/game/sideQuest/utilities/logger.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest.sub.cmd.js +20 -13
- package/bundle/typescript/src/commands/game/sideQuest.sub.cmd.js.map +1 -1
- package/bundle/typescript/src/tools/https/https.class.d.ts +1 -0
- package/bundle/typescript/src/tools/https/https.class.js +49 -1
- package/bundle/typescript/src/tools/https/https.class.js.map +1 -1
- package/package.json +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/factories/commandF.d.ts +0 -10
- package/bundle/typescript/src/commands/game/sideQuest/factories/commandF.js.map +0 -1
- package/bundle/typescript/src/commands/game/sideQuest/factories/roomsF.d.ts +0 -6
- package/bundle/typescript/src/commands/game/sideQuest/factories/roomsF.js +0 -18
- package/bundle/typescript/src/commands/game/sideQuest/factories/roomsF.js.map +0 -1
- package/bundle/typescript/src/commands/game/sideQuest/factories/sceneSynthesizer.js +0 -77
- package/bundle/typescript/src/commands/game/sideQuest/factories/sceneSynthesizer.js.map +0 -1
- package/bundle/typescript/src/commands/game/sideQuest/scenes/scene3.json +0 -380
- package/bundle/typescript/src/commands/game/sideQuest/types/abstracts.js.map +0 -1
- package/bundle/typescript/src/commands/game/sideQuest/types/interfaces.d.ts +0 -197
- package/bundle/typescript/src/commands/game/sideQuest/types/interfaces.js +0 -2
- package/bundle/typescript/src/commands/game/sideQuest/types/interfaces.js.map +0 -1
- package/bundle/typescript/src/commands/game/sideQuest/types/types.js +0 -2
- package/bundle/typescript/src/commands/game/sideQuest/types/types.js.map +0 -1
|
@@ -11,33 +11,43 @@ export class UnlockCommand extends Command {
|
|
|
11
11
|
this.logger.error('UnlockCommand: No target specified.');
|
|
12
12
|
return 'Please specify which door you want to unlock.';
|
|
13
13
|
}
|
|
14
|
-
const target = args
|
|
14
|
+
const target = args.join(' ').toLowerCase(); // Support multi-word room names
|
|
15
15
|
const room = this.actor.currentLocation;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
if (
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
this.logger.write(`UnlockCommand: ${target} is not a valid exit in ${room.name}.`);
|
|
34
|
-
return `There's no door named "${target}" here.`;
|
|
35
|
-
}
|
|
16
|
+
// Try finding the door by direction
|
|
17
|
+
let doorEntry = [...room.exits.entries()].find(([direction, door]) => direction.toLowerCase() === target);
|
|
18
|
+
// If not found by direction, try matching by target room name
|
|
19
|
+
if (!doorEntry) {
|
|
20
|
+
doorEntry = [...room.exits.entries()].find(([_, d]) => {
|
|
21
|
+
if (!(d instanceof Door))
|
|
22
|
+
return false;
|
|
23
|
+
const otherRoomName = d.roomA.name.toLowerCase() === room.name.toLowerCase()
|
|
24
|
+
? d.roomB.name.toLowerCase()
|
|
25
|
+
: d.roomA.name.toLowerCase();
|
|
26
|
+
return otherRoomName === target;
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
if (!doorEntry) {
|
|
30
|
+
this.logger.write(`UnlockCommand: No door found for target "${target}" in ${room.name}.`);
|
|
31
|
+
return `There's no door named or leading to "${target}" here.`;
|
|
36
32
|
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
const [direction, door] = doorEntry;
|
|
34
|
+
if (!(door instanceof Door)) {
|
|
35
|
+
this.logger.write(`UnlockCommand: Exit found but is not a door: "${target}"`);
|
|
36
|
+
return `There's no door named or leading to "${target}" here.`;
|
|
37
|
+
}
|
|
38
|
+
const requiredKeyOrSolution = door.unlockItemOrSolution?.toLowerCase();
|
|
39
|
+
if (requiredKeyOrSolution && this.actor.inventory.hasItem(requiredKeyOrSolution)) {
|
|
40
|
+
const key = this.actor.inventory.getItem(requiredKeyOrSolution);
|
|
41
|
+
if (key) {
|
|
42
|
+
const unlockMessage = room.attemptUnlockExit(direction, key.name);
|
|
43
|
+
this.logger.write(`UnlockCommand: ${this.actor.name} attempted to unlock ${direction}. Result: ${unlockMessage}`);
|
|
44
|
+
this.actor.performAction('unlock', unlockMessage);
|
|
45
|
+
this.scene.updateExits(room);
|
|
46
|
+
return unlockMessage;
|
|
47
|
+
}
|
|
40
48
|
}
|
|
49
|
+
this.logger.write(`UnlockCommand: ${this.actor.name} does not have the required key (${requiredKeyOrSolution}) for "${target}".`);
|
|
50
|
+
return `You don't have the key or solution to unlock this door.`;
|
|
41
51
|
}
|
|
42
52
|
}
|
|
43
53
|
//# sourceMappingURL=unlock.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unlock.js","sourceRoot":"","sources":["../../../../../../../src/commands/game/sideQuest/commands/unlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"unlock.js","sourceRoot":"","sources":["../../../../../../../src/commands/game/sideQuest/commands/unlock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAY,MAAM,cAAc,CAAC;AAEjD,MAAM,OAAO,aAAc,SAAQ,OAAO;IAC9B,MAAM,CAAC,IAAI,GAAG,QAAQ,CAAC;IACvB,MAAM,CAAC,WAAW,GAAG,gBAAgB,CAAC;IAEhD,OAAO,CAAC,IAAc;QACpB,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC3B,CAAC;IAEO,MAAM,CAAC,IAAc;QAC3B,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACtB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAC;YACzD,OAAO,+CAA+C,CAAC;QACzD,CAAC;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,gCAAgC;QAC7E,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC;QAExC,oCAAoC;QACpC,IAAI,SAAS,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,IAAI,CAC5C,CAAC,CAAC,SAAS,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,SAAS,CAAC,WAAW,EAAE,KAAK,MAAM,CAC1D,CAAC;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AAC,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;YAEhE,IAAI,GAAG,EAAE,CAAC;gBACR,MAAM,aAAa,GAAG,IAAI,CAAC,iBAAiB,CAAC,SAAS,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;gBAClE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,kBAAkB,IAAI,CAAC,KAAK,CAAC,IAAI,wBAAwB,SAAS,aAAa,aAAa,EAAE,CAAC,CAAC;gBAClH,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC;gBAClD,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;gBAC7B,OAAO,aAAa,CAAC;YACvB,CAAC;QACH,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,kBAAkB,IAAI,CAAC,KAAK,CAAC,IAAI,oCAAoC,qBAAqB,UAAU,MAAM,IAAI,CAAC,CAAC;QAClI,OAAO,yDAAyD,CAAC;IACnE,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Command } from './command.js';
|
|
2
|
-
import { ICommand } from '../types/interfaces.js';
|
|
1
|
+
import { Command, ICommand } from './command.js';
|
|
3
2
|
export declare class UseCommand extends Command implements ICommand {
|
|
4
3
|
protected static verb: string;
|
|
5
4
|
protected static description: string;
|
|
@@ -22,6 +22,7 @@ export class UseCommand extends Command {
|
|
|
22
22
|
if (typeof itemToUse.use === 'function') {
|
|
23
23
|
const result = itemToUse.use();
|
|
24
24
|
this.logger.write(`UseCommand: ${this.actor.name} used ${itemName}.`);
|
|
25
|
+
this.actor.performAction('use', result);
|
|
25
26
|
return result;
|
|
26
27
|
}
|
|
27
28
|
else {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use.js","sourceRoot":"","sources":["../../../../../../../src/commands/game/sideQuest/commands/use.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,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I,CAAC,KAAK,CAAC,IAAI,SAAS,QAAQ,GAAG,CAAC,CAAC;YACtE,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;YACxC,OAAO,MAAM,CAAC;QAChB,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,eAAe,QAAQ,6BAA6B,CAAC,CAAC;YACxE,OAAO,qBAAqB,QAAQ,eAAe,CAAC;QACtD,CAAC;IACH,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Command, ICommandConstructor } from '../commands/command.js';
|
|
2
|
+
export declare class CommandFactory {
|
|
3
|
+
private static commandMap;
|
|
4
|
+
static registerCommand(verb: string, commandClass: new (context: ICommandConstructor) => Command): void;
|
|
5
|
+
static createCommand(verb: string, context: ICommandConstructor): Command | null;
|
|
6
|
+
static getAllRegisteredCommands(): {
|
|
7
|
+
[key: string]: new (context: ICommandConstructor) => Command;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-factory.js","sourceRoot":"","sources":["../../../../../../../src/commands/game/sideQuest/factories/command-factory.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,cAAc;IACjB,MAAM,CAAC,UAAU,GAAqE,EAAE,CAAC;IAE1F,MAAM,CAAC,eAAe,CAAC,IAAY,EAAE,YAA2D;QACrG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,YAAY,CAAC;IACvC,CAAC;IAEM,MAAM,CAAC,aAAa,CAAC,IAAY,EAAE,OAA4B;QACpE,MAAM,YAAY,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAC3C,IAAI,YAAY,EAAE,CAAC;YACjB,OAAO,IAAI,YAAY,CAAC,OAAO,CAAC,CAAC;QACnC,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,MAAM,CAAC,wBAAwB;QACpC,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Item } from '../models/item.js';
|
|
2
|
+
import { Size, Category, Rating } from '../types/shared/item-enum.js';
|
|
3
|
+
export class ItemFactory {
|
|
4
|
+
async createItemFromJson(json) {
|
|
5
|
+
const item = new Item({
|
|
6
|
+
name: json.name,
|
|
7
|
+
description: json.description,
|
|
8
|
+
size: Size[json.size],
|
|
9
|
+
category: Category[json.category],
|
|
10
|
+
shape: json.shape,
|
|
11
|
+
color: json.color,
|
|
12
|
+
texture: json.texture,
|
|
13
|
+
rating: Rating[json.rating],
|
|
14
|
+
weight: json.weight,
|
|
15
|
+
details: json.details,
|
|
16
|
+
satisfiesLifestyle: json.satisfiesLifestyle
|
|
17
|
+
});
|
|
18
|
+
if (json.currencyAmount && item.isCurrencyCarrier()) {
|
|
19
|
+
item.addCurrency(json.currencyAmount);
|
|
20
|
+
}
|
|
21
|
+
return item;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=item-factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"item-factory.js","sourceRoot":"","sources":["../../../../../../../src/commands/game/sideQuest/factories/item-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AAEzC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAEtE,MAAM,OAAO,WAAW;IACtB,KAAK,CAAC,kBAAkB,CAAC,IAAmB;QAC1C,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC;YACpB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;YACrB,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC;YACjC,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;YAC3B,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;SAC5C,CAAC,CAAC;QAEH,IAAI,IAAI,CAAC,cAAc,IAAI,IAAI,CAAC,iBAAiB,EAAE,EAAE,CAAC;YACpD,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QACxC,CAAC;QAED,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { NPC } from '../models/npc.js';
|
|
2
|
+
import { Scene } from '../models/scene.js';
|
|
3
|
+
import { INPCSeedJson } from '../types/seed/npc-seed.js';
|
|
4
|
+
export declare class NPCFactory {
|
|
5
|
+
private scene;
|
|
6
|
+
private commandRegistry;
|
|
7
|
+
constructor(scene: Scene);
|
|
8
|
+
createNPCFromJson(json: INPCSeedJson): Promise<NPC>;
|
|
9
|
+
private convertPlayerSeedToConstructorConfig;
|
|
10
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { NPC } from '../models/npc.js';
|
|
2
|
+
import { CommandRegistry } from '../commands/command-registry.js';
|
|
3
|
+
export class NPCFactory {
|
|
4
|
+
scene;
|
|
5
|
+
commandRegistry;
|
|
6
|
+
constructor(scene) {
|
|
7
|
+
this.scene = scene;
|
|
8
|
+
}
|
|
9
|
+
async createNPCFromJson(json) {
|
|
10
|
+
if (!json?.player?.name) {
|
|
11
|
+
throw new Error(`NPC missing name in player: ${JSON.stringify(json)}`);
|
|
12
|
+
}
|
|
13
|
+
const playerConstructorConfig = this.convertPlayerSeedToConstructorConfig(json.player);
|
|
14
|
+
this.commandRegistry = new CommandRegistry(this.scene);
|
|
15
|
+
return new NPC({
|
|
16
|
+
dialog: json.dialogue ?? ["..."],
|
|
17
|
+
description: json.description ?? "Not interesting",
|
|
18
|
+
playerConstructorConfig
|
|
19
|
+
}, this.commandRegistry);
|
|
20
|
+
}
|
|
21
|
+
convertPlayerSeedToConstructorConfig(seed) {
|
|
22
|
+
if (!seed.name) {
|
|
23
|
+
throw new Error(`Cannot create NPC without a name`);
|
|
24
|
+
}
|
|
25
|
+
if (!seed.startLocation) {
|
|
26
|
+
throw new Error(`Cannot create NPC with a start location`);
|
|
27
|
+
}
|
|
28
|
+
const startLocation = this.scene.getRoom(seed.startLocation);
|
|
29
|
+
return {
|
|
30
|
+
playerName: seed.name,
|
|
31
|
+
lifestyleChoices: seed.lifestyleChoices,
|
|
32
|
+
startLocation
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=npc-factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"npc-factory.js","sourceRoot":"","sources":["../../../../../../../src/commands/game/sideQuest/factories/npc-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAIvC,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAElE,MAAM,OAAO,UAAU;IACb,KAAK,CAAQ;IACb,eAAe,CAAkB;IAEzC,YAAY,KAAY;QACtB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,IAAkB;QACxC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,+BAA+B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACzE,CAAC;QACD,MAAM,uBAAuB,GAAG,IAAI,CAAC,oCAAoC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACvF,IAAI,CAAC,eAAe,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAEvD,OAAO,IAAI,GAAG,CAAC;YACb,MAAM,EAAE,IAAI,CAAC,QAAQ,IAAI,CAAC,KAAK,CAAC;YAChC,WAAW,EAAE,IAAI,CAAC,WAAW,IAAI,iBAAiB;YAClD,uBAAuB;SACxB,EAAE,IAAI,CAAC,eAAe,CAAC,CAAC;IAC3B,CAAC;IAEO,oCAAoC,CAAC,IAA4B;QACvE,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;YACf,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;QACtD,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;QAC7D,CAAC;QAED,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC7D,OAAO;YACL,UAAU,EAAE,IAAI,CAAC,IAAI;YACrB,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;YACvC,aAAa;SACd,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Puzzle } from '../models/puzzle.js';
|
|
2
|
+
import { IPuzzleSeedJson } from '../types/seed/puzzle-seed.js';
|
|
3
|
+
import { Item } from '../models/item.js';
|
|
4
|
+
export declare class PuzzleFactory {
|
|
5
|
+
createPuzzleFromJson(json: IPuzzleSeedJson, itemMap: Map<string, Item>): Promise<Puzzle>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Puzzle } from '../models/puzzle.js';
|
|
2
|
+
export class PuzzleFactory {
|
|
3
|
+
async createPuzzleFromJson(json, itemMap) {
|
|
4
|
+
const requiredItem = json.requiredItem ? itemMap.get(json.requiredItem) : undefined;
|
|
5
|
+
const rewardItem = json.rewardItem ? itemMap.get(json.rewardItem) : undefined;
|
|
6
|
+
if (json.requiredItem && !requiredItem) {
|
|
7
|
+
throw new Error(`Required item '${json.requiredItem}' not found for puzzle "${json.name}"`);
|
|
8
|
+
}
|
|
9
|
+
if (json.rewardItem && !rewardItem) {
|
|
10
|
+
throw new Error(`Reward item '${json.rewardItem}' not found for puzzle "${json.name}"`);
|
|
11
|
+
}
|
|
12
|
+
return new Puzzle({
|
|
13
|
+
name: json.name,
|
|
14
|
+
riddle: json.riddle,
|
|
15
|
+
requiredPhrase: json.requiredPhrase,
|
|
16
|
+
requiredItem,
|
|
17
|
+
rewardItem,
|
|
18
|
+
successMessage: json.successMessage,
|
|
19
|
+
failureMessage: json.failureMessage,
|
|
20
|
+
hobbyTags: json.hobbyTags
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=puzzle-factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"puzzle-factory.js","sourceRoot":"","sources":["../../../../../../../src/commands/game/sideQuest/factories/puzzle-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAI7C,MAAM,OAAO,aAAa;IACxB,KAAK,CAAC,oBAAoB,CAAC,IAAqB,EAAE,OAA0B;QAC1E,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QACpF,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;QAE9E,IAAI,IAAI,CAAC,YAAY,IAAI,CAAC,YAAY,EAAE,CAAC;YACvC,MAAM,IAAI,KAAK,CAAC,kBAAkB,IAAI,CAAC,YAAY,2BAA2B,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;QAC9F,CAAC;QAED,IAAI,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,EAAE,CAAC;YACnC,MAAM,IAAI,KAAK,CAAC,gBAAgB,IAAI,CAAC,UAAU,2BAA2B,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;QAC1F,CAAC;QAED,OAAO,IAAI,MAAM,CAAC;YAChB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,cAAc,EAAE,IAAI,CAAC,cAAc;YACnC,YAAY;YACZ,UAAU;YACV,cAAc,EAAE,IAAI,CAAC,cAAc;YACnC,cAAc,EAAE,IAAI,CAAC,cAAc;YACnC,SAAS,EAAE,IAAI,CAAC,SAAS;SAC1B,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Room } from '../models/_index.js';
|
|
2
|
+
export class RoomFactory {
|
|
3
|
+
async createRoomFromJson(config) {
|
|
4
|
+
const roomConfig = this.convertToRoomConfigFromJson(config);
|
|
5
|
+
const room = new Room(roomConfig);
|
|
6
|
+
return room;
|
|
7
|
+
}
|
|
8
|
+
convertToRoomConfigFromJson(roomJson) {
|
|
9
|
+
return {
|
|
10
|
+
name: roomJson.name,
|
|
11
|
+
description: roomJson.description,
|
|
12
|
+
isStartRoom: roomJson.isStartRoom,
|
|
13
|
+
roomType: roomJson.roomType,
|
|
14
|
+
tags: roomJson.tags ?? [],
|
|
15
|
+
supportedLifestyles: roomJson.supportedLifestyles
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=room-factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"room-factory.js","sourceRoot":"","sources":["../../../../../../../src/commands/game/sideQuest/factories/room-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAA0B,MAAM,qBAAqB,CAAC;AAGnE,MAAM,OAAO,WAAW;IACtB,KAAK,CAAC,kBAAkB,CAAC,MAAqB;QAC5C,MAAM,UAAU,GAA2B,IAAI,CAAC,2BAA2B,CAAC,MAAM,CAAC,CAAC;QACpF,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC,UAAU,CAAC,CAAC;QAClC,OAAO,IAAI,CAAC;IACd,CAAC;IAEO,2BAA2B,CAAC,QAAuB;QACzD,OAAO;YACL,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,WAAW,EAAE,QAAQ,CAAC,WAAW;YACjC,WAAW,EAAE,QAAQ,CAAC,WAAW;YACjC,QAAQ,EAAE,QAAQ,CAAC,QAAQ;YAC3B,IAAI,EAAE,QAAQ,CAAC,IAAI,IAAI,EAAE;YACzB,mBAAmB,EAAE,QAAQ,CAAC,mBAAmB;SAClD,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Scene } from '../models/scene.js';
|
|
2
2
|
import { Player } from '../models/player.js';
|
|
3
|
-
import { ISceneSeedJson } from '../types/
|
|
3
|
+
import { ISceneSeedJson } from '../types/seed/scene-seed.js';
|
|
4
4
|
export declare class SceneSynthesizer {
|
|
5
|
-
static synthesizeFromJson(json: ISceneSeedJson, player: Player): Scene
|
|
5
|
+
static synthesizeFromJson(json: ISceneSeedJson, player: Player, useAi: boolean): Promise<Scene>;
|
|
6
6
|
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { Scene } from '../models/scene.js';
|
|
2
|
+
import { RoomFactory } from './room-factory.js';
|
|
3
|
+
import { NPCFactory } from './npc-factory.js';
|
|
4
|
+
import { ItemFactory } from './item-factory.js';
|
|
5
|
+
import { PuzzleFactory } from './puzzle-factory.js';
|
|
6
|
+
import { Logger } from '../utilities/logger.js';
|
|
7
|
+
export class SceneSynthesizer {
|
|
8
|
+
static async synthesizeFromJson(json, player, useAi) {
|
|
9
|
+
const logger = Logger.getInstance();
|
|
10
|
+
// Step 1: Create the Scene using the JSON’s room configuration
|
|
11
|
+
logger.write(`Initilizing Scene`);
|
|
12
|
+
const scene = new Scene({
|
|
13
|
+
player,
|
|
14
|
+
currency: {
|
|
15
|
+
type: json.currency.type,
|
|
16
|
+
authorityRoomTags: json.currency.authorityRoomTags
|
|
17
|
+
},
|
|
18
|
+
residenceTiers: json.residenceTiers
|
|
19
|
+
});
|
|
20
|
+
// Step 2: Create and Register Rooms using RoomFactory
|
|
21
|
+
logger.write(`Creating Rooms`);
|
|
22
|
+
const roomFactory = new RoomFactory();
|
|
23
|
+
for (const roomJson of json.rooms) {
|
|
24
|
+
const room = await roomFactory.createRoomFromJson(roomJson);
|
|
25
|
+
scene.addRoom(room); // Assumes you have a method like this on Scene
|
|
26
|
+
}
|
|
27
|
+
// Step 2.5: Wire exits between rooms
|
|
28
|
+
logger.write(`Adding Exits`);
|
|
29
|
+
for (const roomJson of json.rooms) {
|
|
30
|
+
for (const exit of roomJson.exits ?? []) {
|
|
31
|
+
try {
|
|
32
|
+
scene.connectRooms(roomJson.name, exit.direction.toLowerCase(), exit.targetRoom, exit.keyRequired // Optional unlock item/solution
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
throw new Error(`Failed to connect exit from "${roomJson.name}" to "${exit.targetRoom}" via "${exit.direction}": ${err.message}`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
// Step 3: Add NPCs
|
|
41
|
+
logger.write(`Adding NPCs`);
|
|
42
|
+
const npcFactory = new NPCFactory(scene);
|
|
43
|
+
for (const npcJson of json.npcs ?? []) {
|
|
44
|
+
const npc = await npcFactory.createNPCFromJson(npcJson);
|
|
45
|
+
if (!npc) {
|
|
46
|
+
throw new Error(`NPC creation failed for: ${JSON.stringify(npcJson, null, 2)}`);
|
|
47
|
+
}
|
|
48
|
+
logger.write(`Adding ${npc?.name}`);
|
|
49
|
+
scene.addActor(npc);
|
|
50
|
+
scene.setCharacterLocation(npc, npcJson.player.startLocation);
|
|
51
|
+
npc.scene = scene;
|
|
52
|
+
}
|
|
53
|
+
// Step 4: Add Items
|
|
54
|
+
const itemFactory = new ItemFactory();
|
|
55
|
+
const itemMap = new Map();
|
|
56
|
+
for (const itemJson of json.items ?? []) {
|
|
57
|
+
const item = await itemFactory.createItemFromJson(itemJson);
|
|
58
|
+
itemMap.set(item.name, item);
|
|
59
|
+
// Step 4.5: Distribute Items
|
|
60
|
+
if (itemJson.heldBy) {
|
|
61
|
+
const actor = scene.getActor(itemJson.heldBy);
|
|
62
|
+
if (!actor) {
|
|
63
|
+
throw new Error(`No actor named "${itemJson.heldBy}" to receive item "${itemJson.name}"`);
|
|
64
|
+
}
|
|
65
|
+
actor.addInventory(item);
|
|
66
|
+
}
|
|
67
|
+
else if (itemJson.room) {
|
|
68
|
+
scene.addItemToRoom(item, itemJson.room);
|
|
69
|
+
// } else {
|
|
70
|
+
// throw new Error(`Item "${itemJson.name}" must have either 'room' or 'heldBy'.`);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
// Step 5: Add Puzzles
|
|
74
|
+
const puzzleFactory = new PuzzleFactory();
|
|
75
|
+
for (const puzzleJson of json.puzzles ?? []) {
|
|
76
|
+
const puzzle = await puzzleFactory.createPuzzleFromJson(puzzleJson, itemMap);
|
|
77
|
+
scene.addPuzzleToRoom(puzzle, puzzleJson.room);
|
|
78
|
+
}
|
|
79
|
+
// Step 6: Sync AI descriptions for all rooms
|
|
80
|
+
const sceneContext = `
|
|
81
|
+
Scene: ${scene.name}
|
|
82
|
+
Currency: ${json.currency.type}
|
|
83
|
+
Residence Tiers: ${json.residenceTiers.join(', ')}
|
|
84
|
+
Key Locations: ${json.rooms.map(r => r.name).join(', ')}
|
|
85
|
+
`;
|
|
86
|
+
for (const room of Object.values(scene.getRooms())) {
|
|
87
|
+
await room.ensureAIDescription(sceneContext);
|
|
88
|
+
}
|
|
89
|
+
// Step 7: Assign ownership to rooms and items
|
|
90
|
+
logger.write(`Assigning Ownership`);
|
|
91
|
+
for (const roomJson of json.rooms) {
|
|
92
|
+
if (roomJson.owner) {
|
|
93
|
+
const room = scene.getRoom(roomJson.name);
|
|
94
|
+
if (!room) {
|
|
95
|
+
throw new Error(`No room found with name "${roomJson.name}" for ownership assignment.`);
|
|
96
|
+
}
|
|
97
|
+
room.owner = roomJson.owner;
|
|
98
|
+
logger.write(`Room "${room.name}" now owned by "${room.owner}"`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
for (const itemJson of json.items ?? []) {
|
|
102
|
+
if (itemJson.owner) {
|
|
103
|
+
const item = itemMap.get(itemJson.name);
|
|
104
|
+
if (!item) {
|
|
105
|
+
throw new Error(`No item found with name "${itemJson.name}" for ownership assignment.`);
|
|
106
|
+
}
|
|
107
|
+
item.owner = itemJson.owner;
|
|
108
|
+
logger.write(`Item "${item.name}" now owned by "${item.owner}"`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
// Done: the scene is now ready
|
|
112
|
+
return scene;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
//# sourceMappingURL=scene-factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scene-factory.js","sourceRoot":"","sources":["../../../../../../../src/commands/game/sideQuest/factories/scene-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAI3C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAGpD,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAGhD,MAAM,OAAO,gBAAgB;IAC3B,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC,IAAoB,EAAE,MAAc,EAAE,KAAc;QAClF,MAAM,MAAM,G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AI,CAAC,KAAK,EAAE,CAAC;YAClC,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;gBACnB,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;gBAC1C,IAAI,CAAC,IAAI,EAAE,CAAC;oBACV,MAAM,IAAI,KAAK,CAAC,4BAA4B,QAAQ,CAAC,IAAI,6BAA6B,CAAC,CAAC;gBAC1F,CAAC;gBACD,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;gBAC5B,MAAM,CAAC,KAAK,CAAC,SAAS,IAAI,CAAC,IAAI,mBAAmB,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;YACnE,CAAC;QACH,CAAC;QAED,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,KAAK,IAAI,EAAE,EAAE,CAAC;YACxC,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;gBACnB,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;gBACxC,IAAI,CAAC,IAAI,EAAE,CAAC;oBACV,MAAM,IAAI,KAAK,CAAC,4BAA4B,QAAQ,CAAC,IAAI,6BAA6B,CAAC,CAAC;gBAC1F,CAAC;gBACD,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;gBAC5B,MAAM,CAAC,KAAK,CAAC,SAAS,IAAI,CAAC,IAAI,mBAAmB,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC;YACnE,CAAC;QACH,CAAC;QAGD,+BAA+B;QAC/B,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
|
|
@@ -1,19 +1,25 @@
|
|
|
1
|
-
import
|
|
1
|
+
import blessed from 'blessed';
|
|
2
|
+
import { ISceneSeedJson } from './types/seed/scene-seed.js';
|
|
2
3
|
import { Room } from './models/room.js';
|
|
3
4
|
import { Player } from './models/player.js';
|
|
4
5
|
import { Scene } from './models/scene.js';
|
|
5
|
-
import {
|
|
6
|
+
import { IMainGameConfig } from './ui.js';
|
|
6
7
|
export default class Game {
|
|
7
8
|
private static instance;
|
|
9
|
+
private sceneSeed;
|
|
8
10
|
scene: Scene;
|
|
9
11
|
player: Player;
|
|
10
12
|
currentRoom: Room;
|
|
11
|
-
rooms:
|
|
13
|
+
rooms: Room[];
|
|
14
|
+
private _screen;
|
|
15
|
+
private _exitsBox;
|
|
12
16
|
constructor(player: Player, sceneSeed: ISceneSeedJson);
|
|
13
17
|
private registerCommands;
|
|
14
18
|
private determineStartRoom;
|
|
15
|
-
|
|
16
|
-
|
|
19
|
+
init(options: IMainGameConfig, screen: blessed.Widgets.Screen): Promise<string>;
|
|
20
|
+
private initMap;
|
|
21
|
+
updateExits(room: Room): void;
|
|
22
|
+
static getInstance(player: Player, sceneSeed: ISceneSeedJson): Promise<Game>;
|
|
17
23
|
handleInput(input: string): string | null;
|
|
18
24
|
private getHelpMessage;
|
|
19
25
|
}
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import blessed from 'blessed';
|
|
2
|
+
import { capitalCase } from 'change-case';
|
|
3
|
+
import { Door } from './models/door.js';
|
|
1
4
|
import { LookCommand } from './commands/look.js';
|
|
2
5
|
import { TakeCommand } from './commands/take.js';
|
|
3
6
|
import { GoCommand } from './commands/go.js';
|
|
@@ -12,20 +15,21 @@ import { SearchCommand } from './commands/search.js';
|
|
|
12
15
|
import { SayCommand } from './commands/say.js';
|
|
13
16
|
import { TalkCommand } from './commands/talk.js';
|
|
14
17
|
import { StoreCommand } from './commands/store.js';
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
18
|
+
import { GiveCommand } from './commands/give.js';
|
|
19
|
+
import { CommandFactory } from './factories/command-factory.js';
|
|
20
|
+
import { SceneSynthesizer } from './factories/scene-factory.js';
|
|
17
21
|
export default class Game {
|
|
18
22
|
static instance;
|
|
23
|
+
sceneSeed;
|
|
19
24
|
scene;
|
|
20
25
|
player;
|
|
21
26
|
currentRoom;
|
|
22
27
|
rooms;
|
|
28
|
+
_screen;
|
|
29
|
+
_exitsBox;
|
|
23
30
|
constructor(player, sceneSeed) {
|
|
24
31
|
this.player = player;
|
|
25
|
-
this.
|
|
26
|
-
this.scene.initialize();
|
|
27
|
-
this.player.currentLocation = this.determineStartRoom();
|
|
28
|
-
this.registerCommands();
|
|
32
|
+
this.sceneSeed = sceneSeed;
|
|
29
33
|
}
|
|
30
34
|
registerCommands() {
|
|
31
35
|
CommandFactory.registerCommand('look', LookCommand);
|
|
@@ -42,15 +46,103 @@ export default class Game {
|
|
|
42
46
|
CommandFactory.registerCommand('say', SayCommand);
|
|
43
47
|
CommandFactory.registerCommand('store', StoreCommand);
|
|
44
48
|
CommandFactory.registerCommand('talk-to', TalkCommand);
|
|
49
|
+
CommandFactory.registerCommand('give', GiveCommand);
|
|
45
50
|
}
|
|
46
51
|
determineStartRoom() {
|
|
47
52
|
return this.scene.determineStartRoom();
|
|
48
53
|
}
|
|
49
|
-
|
|
50
|
-
|
|
54
|
+
async init(options, screen) {
|
|
55
|
+
this.initMap(screen);
|
|
56
|
+
// Create a loading box
|
|
57
|
+
const loadingBox = blessed.box({
|
|
58
|
+
parent: screen,
|
|
59
|
+
top: 'center',
|
|
60
|
+
left: 'center',
|
|
61
|
+
width: '50%',
|
|
62
|
+
height: 'shrink',
|
|
63
|
+
content: 'Generating Scene... Please wait.',
|
|
64
|
+
border: { type: 'line' },
|
|
65
|
+
style: {
|
|
66
|
+
fg: 'white',
|
|
67
|
+
bg: 'black',
|
|
68
|
+
border: { fg: 'cyan' },
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
screen.append(loadingBox);
|
|
72
|
+
screen.render();
|
|
73
|
+
try {
|
|
74
|
+
this.scene = await SceneSynthesizer.synthesizeFromJson(this.sceneSeed, this.player, options.useAi);
|
|
75
|
+
}
|
|
76
|
+
catch (err) {
|
|
77
|
+
throw new Error(`Scene generation failed: ${err.message}`);
|
|
78
|
+
}
|
|
79
|
+
// Remove loading box
|
|
80
|
+
screen.remove(loadingBox);
|
|
81
|
+
screen.render();
|
|
82
|
+
this.scene.initialize(this);
|
|
83
|
+
this.player.currentLocation = this.determineStartRoom();
|
|
84
|
+
this.registerCommands();
|
|
85
|
+
this._screen = screen;
|
|
86
|
+
return `Welcome, ${this.player.name}`;
|
|
87
|
+
}
|
|
88
|
+
initMap(screen) {
|
|
89
|
+
// Map
|
|
90
|
+
const exitsBox = blessed.box({
|
|
91
|
+
top: '70%',
|
|
92
|
+
left: '75%',
|
|
93
|
+
width: '25%',
|
|
94
|
+
height: '20%',
|
|
95
|
+
border: {
|
|
96
|
+
type: 'line'
|
|
97
|
+
},
|
|
98
|
+
label: ' Map ',
|
|
99
|
+
content: 'Available exits will be shown here...',
|
|
100
|
+
tags: true,
|
|
101
|
+
scrollable: true,
|
|
102
|
+
scrollbar: {
|
|
103
|
+
ch: ' ',
|
|
104
|
+
track: {
|
|
105
|
+
bg: 'yellow'
|
|
106
|
+
},
|
|
107
|
+
style: {
|
|
108
|
+
inverse: true
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
keys: true,
|
|
112
|
+
mouse: true,
|
|
113
|
+
});
|
|
114
|
+
screen.append(exitsBox);
|
|
115
|
+
this._exitsBox = exitsBox;
|
|
116
|
+
}
|
|
117
|
+
updateExits(room) {
|
|
118
|
+
let description = `Currently in: ${room.name}\n\n`;
|
|
119
|
+
description += `----- Exits ------\n`;
|
|
120
|
+
if (room.exits.size > 0) {
|
|
121
|
+
room.exits.forEach((exit, key) => {
|
|
122
|
+
if (exit instanceof Door) {
|
|
123
|
+
const nextRoom = exit.getOtherSideToName(room);
|
|
124
|
+
description += `${capitalCase(key)}: ${nextRoom}`;
|
|
125
|
+
if (exit.checkIfLocked()) {
|
|
126
|
+
description += " (Locked)";
|
|
127
|
+
}
|
|
128
|
+
else if (exit.checkIfLockable()) {
|
|
129
|
+
description += ' (Unlocked)';
|
|
130
|
+
}
|
|
131
|
+
description += '\n';
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
description += `${capitalCase(key)}\n`; // Example: "NORTH"
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
description += '\nThere are no exits here.';
|
|
140
|
+
}
|
|
141
|
+
this._exitsBox.setContent(description);
|
|
142
|
+
this._screen.render();
|
|
51
143
|
}
|
|
52
144
|
// Public method to get the instance of the Game class
|
|
53
|
-
static getInstance(player, sceneSeed) {
|
|
145
|
+
static async getInstance(player, sceneSeed) {
|
|
54
146
|
if (!Game.instance) {
|
|
55
147
|
Game.instance = new Game(player, sceneSeed);
|
|
56
148
|
}
|
|
@@ -75,7 +167,7 @@ export default class Game {
|
|
|
75
167
|
const context = {
|
|
76
168
|
actor: this.player,
|
|
77
169
|
rooms: this.scene.getRooms(),
|
|
78
|
-
scene: this.scene
|
|
170
|
+
scene: this.scene,
|
|
79
171
|
};
|
|
80
172
|
const command = CommandFactory.createCommand(verb, context);
|
|
81
173
|
if (command) {
|