@maka/maka-cli 5.1.30 → 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 +3 -3
- package/bundle/typescript/src/commands/game/sideQuest/commands/command.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/say.js +3 -1
- package/bundle/typescript/src/commands/game/sideQuest/commands/say.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/commands/unlock.js +34 -25
- package/bundle/typescript/src/commands/game/sideQuest/commands/unlock.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/factories/npc-factory.d.ts +1 -0
- package/bundle/typescript/src/commands/game/sideQuest/factories/npc-factory.js +4 -1
- package/bundle/typescript/src/commands/game/sideQuest/factories/npc-factory.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/factories/scene-factory.js +2 -3
- package/bundle/typescript/src/commands/game/sideQuest/factories/scene-factory.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/game.d.ts +4 -0
- package/bundle/typescript/src/commands/game/sideQuest/game.js +65 -1
- package/bundle/typescript/src/commands/game/sideQuest/game.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/models/item.d.ts +1 -0
- package/bundle/typescript/src/commands/game/sideQuest/models/item.js +30 -12
- package/bundle/typescript/src/commands/game/sideQuest/models/item.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/models/npc.d.ts +8 -1
- package/bundle/typescript/src/commands/game/sideQuest/models/npc.js +111 -19
- package/bundle/typescript/src/commands/game/sideQuest/models/npc.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/models/player.js +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/models/player.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/models/room.js +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/models/room.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/models/scene.d.ts +4 -1
- package/bundle/typescript/src/commands/game/sideQuest/models/scene.js +6 -1
- package/bundle/typescript/src/commands/game/sideQuest/models/scene.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/scenes/scene1.json +41 -9
- package/bundle/typescript/src/commands/game/sideQuest/scenes/scene2.json +0 -1
- package/bundle/typescript/src/commands/game/sideQuest/ui.js +3 -56
- package/bundle/typescript/src/commands/game/sideQuest/ui.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest.sub.cmd.js +1 -1
- package/bundle/typescript/src/commands/game/sideQuest.sub.cmd.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maka/maka-cli",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.31",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"summary": "A command line tool for scaffolding Meteor 2.x applications using either React.",
|
|
6
6
|
"description": "A command line tool for scaffolding Meteor 2.x applications using React.",
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Command } from './command.js';
|
|
2
|
+
import { Player } from '../models/player.js';
|
|
3
|
+
import { NPC } from '../models/npc.js';
|
|
4
|
+
import { Scene } from '../models/scene.js';
|
|
5
|
+
export declare class CommandRegistry {
|
|
6
|
+
private scene;
|
|
7
|
+
constructor(scene: Scene);
|
|
8
|
+
parse(commandString: string, actor: Player | NPC): Command | null;
|
|
9
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// src/commands/command-registry.ts
|
|
2
|
+
import { CommandFactory } from '../factories/command-factory.js';
|
|
3
|
+
export class CommandRegistry {
|
|
4
|
+
scene;
|
|
5
|
+
constructor(scene) {
|
|
6
|
+
this.scene = scene;
|
|
7
|
+
}
|
|
8
|
+
parse(commandString, actor) {
|
|
9
|
+
const parts = commandString.trim().split(' ');
|
|
10
|
+
const verb = parts[0].toLowerCase();
|
|
11
|
+
const args = parts.slice(1);
|
|
12
|
+
const context = {
|
|
13
|
+
actor,
|
|
14
|
+
rooms: this.scene.getRooms(),
|
|
15
|
+
scene: this.scene,
|
|
16
|
+
args, // optional, not all commands use this at construction time
|
|
17
|
+
};
|
|
18
|
+
const command = CommandFactory.createCommand(verb, context);
|
|
19
|
+
if (!command)
|
|
20
|
+
return null;
|
|
21
|
+
// Wrap the command with the args pre-bound (if needed)
|
|
22
|
+
command.execute(args); // only if you have such a method
|
|
23
|
+
return command;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=command-registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-registry.js","sourceRoot":"","sources":["../../../../../../../src/commands/game/sideQuest/commands/command-registry.ts"],"names":[],"mappings":"AAAA,mCAAmC;AAEnC,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAMjE,MAAM,OAAO,eAAe;IAClB,KAAK,CAAQ;IAErB,YAAY,KAAY;QACtB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,aAAqB,EAAE,KAAmB;QAC9C,MAAM,KAAK,GAAG,aAAa,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC9C,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;QACpC,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAE5B,MAAM,OAAO,GAAG;YACd,KAAK;YACL,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE;YAC5B,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,IAAI,EAAE,2DAA2D;SAClE,CAAC;QAEF,MAAM,OAAO,GAAG,cAAc,CAAC,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QAE5D,IAAI,CAAC,OAAO;YAAE,OAAO,IAAI,CAAC;QAE1B,uDAAuD;QACvD,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,iCAAiC;QAExD,OAAO,OAAO,CAAC;IACjB,CAAC;CACF"}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { Direction } from '../types/shared/direction-enum.js';
|
|
2
|
-
import { Player, Scene, Room } from '../models/_index.js';
|
|
2
|
+
import { Player, Scene, Room, NPC } from '../models/_index.js';
|
|
3
3
|
import { Logger } from '../utilities/logger.js';
|
|
4
4
|
export interface ICommand {
|
|
5
5
|
execute(args: string[]): string;
|
|
6
6
|
}
|
|
7
7
|
export interface ICommandConstructor {
|
|
8
|
-
actor: Player;
|
|
8
|
+
actor: Player | NPC;
|
|
9
9
|
scene: Scene;
|
|
10
10
|
rooms?: Record<string, Room>;
|
|
11
11
|
}
|
|
12
12
|
export declare abstract class Command {
|
|
13
13
|
protected static verb: string;
|
|
14
14
|
protected static description: string;
|
|
15
|
-
protected actor: Player;
|
|
15
|
+
protected actor: Player | NPC;
|
|
16
16
|
protected rooms?: Record<string, Room>;
|
|
17
17
|
protected logger: Logger;
|
|
18
18
|
protected scene: Scene;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../../../../../../src/commands/game/sideQuest/commands/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAE9D,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAYhD,MAAM,OAAgB,OAAO;IACjB,MAAM,CAAC,IAAI,CAAS;IACpB,MAAM,CAAC,WAAW,CAAS,CAAE,mBAAmB;IAChD,KAAK,
|
|
1
|
+
{"version":3,"file":"command.js","sourceRoot":"","sources":["../../../../../../../src/commands/game/sideQuest/commands/command.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,mCAAmC,CAAC;AAE9D,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAYhD,MAAM,OAAgB,OAAO;IACjB,MAAM,CAAC,IAAI,CAAS;IACpB,MAAM,CAAC,WAAW,CAAS,CAAE,mBAAmB;IAChD,KAAK,CAAe;IACpB,KAAK,CAAwB;IAC7B,MAAM,CAAS;IACf,KAAK,CAAQ;IAEvB,YAAY,OAA4B;QACtC,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC;QACnC,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;IAC7B,CAAC;IAIS,gBAAgB,CAAC,KAAa;QACtC,OAAO,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,KAAkB,CAAC,CAAC;IAC/D,CAAC;IAED,gDAAgD;IAChD,MAAM,CAAC,cAAc;QACnB,OAAO,IAAI,CAAC,WAAW,IAAI,2BAA2B,CAAC,CAAE,yDAAyD;IACpH,CAAC;CACF"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { Command } from './command.js';
|
|
2
|
+
export class GiveCommand extends Command {
|
|
3
|
+
static verb = 'give';
|
|
4
|
+
static description = 'Give an item or money to someone.';
|
|
5
|
+
execute(args) {
|
|
6
|
+
this.logger.write(`Attempting 'Give' command with input: ${args.join(' ')}`);
|
|
7
|
+
return this.give(args);
|
|
8
|
+
}
|
|
9
|
+
give(args) {
|
|
10
|
+
const argString = args.join(' ');
|
|
11
|
+
const match = argString.match(/^(.+?) to (.+)$/i);
|
|
12
|
+
if (!match) {
|
|
13
|
+
this.logger.write(`Invalid syntax for 'Give' command: ${argString}`);
|
|
14
|
+
return `Usage: give <item|amount> to <actor>`;
|
|
15
|
+
}
|
|
16
|
+
const [, itemOrAmount, recipientName] = match;
|
|
17
|
+
const room = this.actor.currentLocation;
|
|
18
|
+
const recipient = room.getActors().find(a => a.name.toLowerCase() === recipientName.toLowerCase());
|
|
19
|
+
if (!recipient) {
|
|
20
|
+
this.logger.write(`Recipient "${recipientName}" not found in room ${room.name}`);
|
|
21
|
+
return `You don’t see anyone named "${recipientName}" here.`;
|
|
22
|
+
}
|
|
23
|
+
// === Try to give currency ===
|
|
24
|
+
const currencyMatch = itemOrAmount.match(/^(\d+)\s*(nuyen|¥)?$/i);
|
|
25
|
+
if (currencyMatch) {
|
|
26
|
+
const amount = parseInt(currencyMatch[1], 10);
|
|
27
|
+
const currencyType = this.scene.currency?.type || 'currency';
|
|
28
|
+
if (this.actor.currency < amount) {
|
|
29
|
+
this.logger.write(`${this.actor.name} tried to give ${amount} ${currencyType} but lacks funds.`);
|
|
30
|
+
return `You don’t have ${amount} ${currencyType}.`;
|
|
31
|
+
}
|
|
32
|
+
this.actor.adjustCurrency(-amount);
|
|
33
|
+
recipient.adjustCurrency(amount);
|
|
34
|
+
this.actor.performAction('give', `${amount} ${currencyType} to ${recipient.name}`);
|
|
35
|
+
this.logger.write(`${this.actor.name} gave ${amount} ${currencyType} to ${recipient.name}`);
|
|
36
|
+
return `You gave ${amount} ${currencyType} to ${recipient.name}.`;
|
|
37
|
+
}
|
|
38
|
+
// === Try to give an item ===
|
|
39
|
+
const item = this.actor.inventory.getItem(itemOrAmount);
|
|
40
|
+
if (!item) {
|
|
41
|
+
this.logger.write(`${this.actor.name} tried to give item "${itemOrAmount}" but does not have it.`);
|
|
42
|
+
return `You don’t have "${itemOrAmount}".`;
|
|
43
|
+
}
|
|
44
|
+
this.actor.removeInventory(item);
|
|
45
|
+
recipient.addInventory(item);
|
|
46
|
+
this.actor.performAction('give', `${item.name} to ${recipient.name}`);
|
|
47
|
+
this.logger.write(`${this.actor.name} gave item "${item.name}" to ${recipient.name}`);
|
|
48
|
+
return `You gave ${item.name} to ${recipient.name}.`;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=give.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"give.js","sourceRoot":"","sources":["../../../../../../../src/commands/game/sideQuest/commands/give.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAY,MAAM,cAAc,CAAC;AAGjD,MAAM,OAAO,WAAY,SAAQ,OAAO;IAC5B,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC;IACrB,MAAM,CAAC,WAAW,GAAG,mCAAmC,CAAC;IAEnE,OAAO,CAAC,IAAc;QACpB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,yCAAyC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAC7E,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IAEO,IAAI,CAAC,IAAc;QACzB,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACjC,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;QAElD,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,sCAAsC,SAAS,EAAE,CAAC,CAAC;YACrE,OAAO,sCAAsC,CAAC;QAChD,CAAC;QAED,MAAM,CAAC,EAAE,YAAY,EAAE,aAAa,CAAC,GAAG,KAAK,CAAC;QAC9C,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC;QACxC,MAAM,SAAS,GAAG,IAAI,CAAC,SAAS,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AC;YAE5F,OAAO,YAAY,MAAM,IAAI,YAAY,OAAO,SAAS,CAAC,IAAI,GAAG,CAAC;QACpE,CAAC;QAED,8BAA8B;QAC9B,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QACxD,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,wBAAwB,YAAY,yBAAyB,CAAC,CAAC;YACnG,OAAO,mBAAmB,YAAY,IAAI,CAAC;QAC7C,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;QACjC,SAAS,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QAE7B,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,IAAI,OAAO,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC;QACtE,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,eAAe,IAAI,CAAC,IAAI,QAAQ,SAAS,CAAC,IAAI,EAAE,CAAC,CAAC;QAEtF,OAAO,YAAY,IAAI,CAAC,IAAI,OAAO,SAAS,CAAC,IAAI,GAAG,CAAC;IACvD,CAAC"}
|
|
@@ -20,11 +20,13 @@ export class SayCommand extends Command {
|
|
|
20
20
|
return "An error occurred.";
|
|
21
21
|
}
|
|
22
22
|
const roomActors = scene.allActors.filter(actor => actor.currentLocation === currentPlayer.currentLocation);
|
|
23
|
-
this.logger.logWithColor(`${currentPlayer.name} says "${message}"`, 'yellow');
|
|
24
23
|
for (const actor of roomActors) {
|
|
25
24
|
if (actor == currentPlayer) {
|
|
26
25
|
this.actor.currentLocation.say(actor, message);
|
|
27
26
|
}
|
|
27
|
+
else {
|
|
28
|
+
this.logger.logWithColor(`${currentPlayer.name} says "${message}"`, 'yellow');
|
|
29
|
+
}
|
|
28
30
|
actor.hear(currentPlayer, message);
|
|
29
31
|
}
|
|
30
32
|
return ``;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"say.js","sourceRoot":"","sources":["../../../../../../../src/commands/game/sideQuest/commands/say.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAuB,MAAM,cAAc,CAAC;AAE5D,MAAM,OAAO,UAAW,SAAQ,OAAO;IACrC,6DAA6D;IACnD,MAAM,CAAC,IAAI,GAAG,KAAK,CAAC;IACpB,MAAM,CAAC,WAAW,GAAG,sDAAsD,CAAC;IAC5E,OAAO,CAAsB;IAEvC,YAAY,OAA4B;QACtC,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,OAAO,CAAC,IAAc;QACpB,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACtB,OAAO,0BAA0B,CAAC;QACpC,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC/B,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC;QACjC,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,6CAA6C;QAE/E,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC,CAAC,mCAAmC;YACtF,OAAO,oBAAoB,CAAC;QAC9B,CAAC;QAED,MAAM,UAAU,GAAG,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,eAAe,KAAK,aAAa,CAAC,eAAe,CAAC,CAAC;QAE5G,
|
|
1
|
+
{"version":3,"file":"say.js","sourceRoot":"","sources":["../../../../../../../src/commands/game/sideQuest/commands/say.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO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C,IAAI,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;QACrC,CAAC;QAED,OAAO,EAAE,CAAC;IACZ,CAAC"}
|
|
@@ -11,34 +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
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
this.logger.write(`UnlockCommand: ${target} is not a valid exit in ${room.name}.`);
|
|
35
|
-
return `There's no door named "${target}" here.`;
|
|
36
|
-
}
|
|
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.`;
|
|
37
32
|
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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
|
+
}
|
|
41
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.`;
|
|
42
51
|
}
|
|
43
52
|
}
|
|
44
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;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,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,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"}
|
|
@@ -3,6 +3,7 @@ import { Scene } from '../models/scene.js';
|
|
|
3
3
|
import { INPCSeedJson } from '../types/seed/npc-seed.js';
|
|
4
4
|
export declare class NPCFactory {
|
|
5
5
|
private scene;
|
|
6
|
+
private commandRegistry;
|
|
6
7
|
constructor(scene: Scene);
|
|
7
8
|
createNPCFromJson(json: INPCSeedJson): Promise<NPC>;
|
|
8
9
|
private convertPlayerSeedToConstructorConfig;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { NPC } from '../models/npc.js';
|
|
2
|
+
import { CommandRegistry } from '../commands/command-registry.js';
|
|
2
3
|
export class NPCFactory {
|
|
3
4
|
scene;
|
|
5
|
+
commandRegistry;
|
|
4
6
|
constructor(scene) {
|
|
5
7
|
this.scene = scene;
|
|
6
8
|
}
|
|
@@ -9,11 +11,12 @@ export class NPCFactory {
|
|
|
9
11
|
throw new Error(`NPC missing name in player: ${JSON.stringify(json)}`);
|
|
10
12
|
}
|
|
11
13
|
const playerConstructorConfig = this.convertPlayerSeedToConstructorConfig(json.player);
|
|
14
|
+
this.commandRegistry = new CommandRegistry(this.scene);
|
|
12
15
|
return new NPC({
|
|
13
16
|
dialog: json.dialogue ?? ["..."],
|
|
14
17
|
description: json.description ?? "Not interesting",
|
|
15
18
|
playerConstructorConfig
|
|
16
|
-
});
|
|
19
|
+
}, this.commandRegistry);
|
|
17
20
|
}
|
|
18
21
|
convertPlayerSeedToConstructorConfig(seed) {
|
|
19
22
|
if (!seed.name) {
|
|
@@ -1 +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;
|
|
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"}
|
|
@@ -66,9 +66,8 @@ export class SceneSynthesizer {
|
|
|
66
66
|
}
|
|
67
67
|
else if (itemJson.room) {
|
|
68
68
|
scene.addItemToRoom(item, itemJson.room);
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
throw new Error(`Item "${itemJson.name}" must have either 'room' or 'heldBy'.`);
|
|
69
|
+
// } else {
|
|
70
|
+
// throw new Error(`Item "${itemJson.name}" must have either 'room' or 'heldBy'.`);
|
|
72
71
|
}
|
|
73
72
|
}
|
|
74
73
|
// Step 5: Add Puzzles
|
|
@@ -1 +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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AM,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"}
|
|
@@ -11,10 +11,14 @@ export default class Game {
|
|
|
11
11
|
player: Player;
|
|
12
12
|
currentRoom: Room;
|
|
13
13
|
rooms: Room[];
|
|
14
|
+
private _screen;
|
|
15
|
+
private _exitsBox;
|
|
14
16
|
constructor(player: Player, sceneSeed: ISceneSeedJson);
|
|
15
17
|
private registerCommands;
|
|
16
18
|
private determineStartRoom;
|
|
17
19
|
init(options: IMainGameConfig, screen: blessed.Widgets.Screen): Promise<string>;
|
|
20
|
+
private initMap;
|
|
21
|
+
updateExits(room: Room): void;
|
|
18
22
|
static getInstance(player: Player, sceneSeed: ISceneSeedJson): Promise<Game>;
|
|
19
23
|
handleInput(input: string): string | null;
|
|
20
24
|
private getHelpMessage;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import blessed from 'blessed';
|
|
2
|
+
import { capitalCase } from 'change-case';
|
|
3
|
+
import { Door } from './models/door.js';
|
|
2
4
|
import { LookCommand } from './commands/look.js';
|
|
3
5
|
import { TakeCommand } from './commands/take.js';
|
|
4
6
|
import { GoCommand } from './commands/go.js';
|
|
@@ -13,6 +15,7 @@ import { SearchCommand } from './commands/search.js';
|
|
|
13
15
|
import { SayCommand } from './commands/say.js';
|
|
14
16
|
import { TalkCommand } from './commands/talk.js';
|
|
15
17
|
import { StoreCommand } from './commands/store.js';
|
|
18
|
+
import { GiveCommand } from './commands/give.js';
|
|
16
19
|
import { CommandFactory } from './factories/command-factory.js';
|
|
17
20
|
import { SceneSynthesizer } from './factories/scene-factory.js';
|
|
18
21
|
export default class Game {
|
|
@@ -22,6 +25,8 @@ export default class Game {
|
|
|
22
25
|
player;
|
|
23
26
|
currentRoom;
|
|
24
27
|
rooms;
|
|
28
|
+
_screen;
|
|
29
|
+
_exitsBox;
|
|
25
30
|
constructor(player, sceneSeed) {
|
|
26
31
|
this.player = player;
|
|
27
32
|
this.sceneSeed = sceneSeed;
|
|
@@ -41,11 +46,13 @@ export default class Game {
|
|
|
41
46
|
CommandFactory.registerCommand('say', SayCommand);
|
|
42
47
|
CommandFactory.registerCommand('store', StoreCommand);
|
|
43
48
|
CommandFactory.registerCommand('talk-to', TalkCommand);
|
|
49
|
+
CommandFactory.registerCommand('give', GiveCommand);
|
|
44
50
|
}
|
|
45
51
|
determineStartRoom() {
|
|
46
52
|
return this.scene.determineStartRoom();
|
|
47
53
|
}
|
|
48
54
|
async init(options, screen) {
|
|
55
|
+
this.initMap(screen);
|
|
49
56
|
// Create a loading box
|
|
50
57
|
const loadingBox = blessed.box({
|
|
51
58
|
parent: screen,
|
|
@@ -72,11 +79,68 @@ export default class Game {
|
|
|
72
79
|
// Remove loading box
|
|
73
80
|
screen.remove(loadingBox);
|
|
74
81
|
screen.render();
|
|
75
|
-
this.scene.initialize();
|
|
82
|
+
this.scene.initialize(this);
|
|
76
83
|
this.player.currentLocation = this.determineStartRoom();
|
|
77
84
|
this.registerCommands();
|
|
85
|
+
this._screen = screen;
|
|
78
86
|
return `Welcome, ${this.player.name}`;
|
|
79
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();
|
|
143
|
+
}
|
|
80
144
|
// Public method to get the instance of the Game class
|
|
81
145
|
static async getInstance(player, sceneSeed) {
|
|
82
146
|
if (!Game.instance) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"game.js","sourceRoot":"","sources":["../../../../../../src/commands/game/sideQuest/game.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"game.js","sourceRoot":"","sources":["../../../../../../src/commands/game/sideQuest/game.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAK1C,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAKxC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAA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I,CAAC,EAAE,CAAC;gBAClC,MAAM,YAAY,GAAG,QAAQ,CAAC,IAAI,CAA8B,CAAC;gBACjE,QAAQ,IAAI,KAAK,IAAI,KAAK,YAAY,CAAC,cAAc,EAAE,IAAI,CAAC;YAC9D,CAAC;QACH,CAAC;QAED,QAAQ,IAAI,8BAA8B,CAAC;QAC3C,QAAQ,IAAI,0BAA0B,CAAC;QAEvC,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Size, Category } from '../types/shared/item-enum.js';
|
|
1
|
+
import { Size, Category, Rating } from '../types/shared/item-enum.js';
|
|
2
2
|
import { v4 as uuidv4 } from 'uuid';
|
|
3
3
|
import { AbstractItem } from '../types/shared/abstracts.js';
|
|
4
4
|
export class Item extends AbstractItem {
|
|
@@ -22,17 +22,15 @@ export class Item extends AbstractItem {
|
|
|
22
22
|
constructor(options) {
|
|
23
23
|
super();
|
|
24
24
|
// Validate enum values
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
// throw new Error(`Invalid rating value for ${options.name}: ${options.rating}`);
|
|
35
|
-
// }
|
|
25
|
+
if (!Object.values(Size).includes(options.size)) {
|
|
26
|
+
throw new Error(`Invalid size value for ${options.name}: ${options.size}`);
|
|
27
|
+
}
|
|
28
|
+
if (!Object.values(Category).includes(options.category)) {
|
|
29
|
+
throw new Error(`Invalid category value for ${options.name}: ${options.category}`);
|
|
30
|
+
}
|
|
31
|
+
if (!Object.values(Rating).includes(options.rating)) {
|
|
32
|
+
throw new Error(`Invalid rating value for ${options.name}: ${options.rating}`);
|
|
33
|
+
}
|
|
36
34
|
this.name = options.name;
|
|
37
35
|
this.description = options.description;
|
|
38
36
|
this.size = options.size;
|
|
@@ -103,5 +101,25 @@ export class Item extends AbstractItem {
|
|
|
103
101
|
this._currencyAmount -= deducted;
|
|
104
102
|
return deducted;
|
|
105
103
|
}
|
|
104
|
+
getCharacteristics() {
|
|
105
|
+
return {
|
|
106
|
+
id: this._id,
|
|
107
|
+
name: this.name,
|
|
108
|
+
description: this.description,
|
|
109
|
+
size: this.size,
|
|
110
|
+
category: this.category,
|
|
111
|
+
shape: this.shape,
|
|
112
|
+
color: this.color,
|
|
113
|
+
texture: this.texture,
|
|
114
|
+
rating: this.rating,
|
|
115
|
+
weight: this.weight,
|
|
116
|
+
content: this.content,
|
|
117
|
+
details: this.details,
|
|
118
|
+
addictionTypes: this.satisfiesLifestyle?.addictionTypes,
|
|
119
|
+
habitTags: this.satisfiesLifestyle?.habitTags,
|
|
120
|
+
currencyAmount: this.isCurrencyCarrier() ? this._currencyAmount : undefined,
|
|
121
|
+
currencyCapacity: this.isCurrencyCarrier() ? this._currencyCapacity : undefined,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
106
124
|
}
|
|
107
125
|
//# sourceMappingURL=item.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item.js","sourceRoot":"","sources":["../../../../../../../src/commands/game/sideQuest/models/item.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,
|
|
1
|
+
{"version":3,"file":"item.js","sourceRoot":"","sources":["../../../../../../../src/commands/game/sideQuest/models/item.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AACtE,OAAO,EAAE,EAAE,IAAI,MAAM,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAoB5D,MAAM,OAAO,IAAK,SAAQ,YAAY;IAC5B,GAAG,CAAS;IACZ,MAAM,CAAsB;IAC7B,IAAI,CAAS;IACb,WAAW,CAAS;IACpB,IAAI,CAAO;IACX,QAAQ,CAAW;IACnB,KAAK,CAAS;IACd,KAAK,CAAS;IACd,O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,EAAE,IAAI,CAAC,KAAK;YACjB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,cAAc,EAAE,IAAI,CAAC,kBAAkB,EAAE,cAAc;YACvD,SAAS,EAAE,IAAI,CAAC,kBAAkB,EAAE,SAAS;YAC7C,cAAc,EAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,CAAC,SAAS;YAC3E,gBAAgB,EAAE,IAAI,CAAC,iBAAiB,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS;SAChF,CAAC;IACJ,CAAC;CAEF"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Player } from './player.js';
|
|
2
2
|
import { Scene } from './scene.js';
|
|
3
3
|
import { IPlayerConstructorConfig } from '../models/player.js';
|
|
4
|
+
import { CommandRegistry } from '../commands/command-registry.js';
|
|
4
5
|
export interface INPCConstructorConfig {
|
|
5
6
|
dialog: string[];
|
|
6
7
|
description: string;
|
|
@@ -10,11 +11,17 @@ export declare class NPC extends Player {
|
|
|
10
11
|
private _dialogue;
|
|
11
12
|
private _description;
|
|
12
13
|
private _scene;
|
|
13
|
-
|
|
14
|
+
private _history;
|
|
15
|
+
private readonly _maxHistory;
|
|
16
|
+
private commandRegistry;
|
|
17
|
+
constructor(npcConfig: INPCConstructorConfig, commandRegistry: CommandRegistry);
|
|
14
18
|
set scene(scene: Scene);
|
|
15
19
|
get description(): string;
|
|
20
|
+
act(commandString: string): void;
|
|
16
21
|
hear(actor: Player, message: string): Promise<void>;
|
|
17
22
|
see(actor: Player, verb: string, details?: string): Promise<void>;
|
|
23
|
+
private _addToHistory;
|
|
24
|
+
private getHistorySummary;
|
|
18
25
|
speak(): string;
|
|
19
26
|
respondTo(actor: Player, message: string): Promise<void>;
|
|
20
27
|
}
|