@maka/maka-cli 5.1.31 → 5.1.33

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.
Files changed (97) hide show
  1. package/bundle/typescript/package.json +1 -1
  2. package/bundle/typescript/src/commands/game/sideQuest/commands/command-registry.d.ts +1 -1
  3. package/bundle/typescript/src/commands/game/sideQuest/commands/command-registry.js +2 -2
  4. package/bundle/typescript/src/commands/game/sideQuest/commands/command-registry.js.map +1 -1
  5. package/bundle/typescript/src/commands/game/sideQuest/commands/command.d.ts +2 -2
  6. package/bundle/typescript/src/commands/game/sideQuest/commands/drop.d.ts +1 -1
  7. package/bundle/typescript/src/commands/game/sideQuest/commands/drop.js +8 -5
  8. package/bundle/typescript/src/commands/game/sideQuest/commands/drop.js.map +1 -1
  9. package/bundle/typescript/src/commands/game/sideQuest/commands/equip.d.ts +1 -1
  10. package/bundle/typescript/src/commands/game/sideQuest/commands/equip.js +44 -9
  11. package/bundle/typescript/src/commands/game/sideQuest/commands/equip.js.map +1 -1
  12. package/bundle/typescript/src/commands/game/sideQuest/commands/give.d.ts +1 -1
  13. package/bundle/typescript/src/commands/game/sideQuest/commands/give.js +10 -3
  14. package/bundle/typescript/src/commands/game/sideQuest/commands/give.js.map +1 -1
  15. package/bundle/typescript/src/commands/game/sideQuest/commands/go.d.ts +1 -1
  16. package/bundle/typescript/src/commands/game/sideQuest/commands/go.js +5 -2
  17. package/bundle/typescript/src/commands/game/sideQuest/commands/go.js.map +1 -1
  18. package/bundle/typescript/src/commands/game/sideQuest/commands/kill.d.ts +6 -0
  19. package/bundle/typescript/src/commands/game/sideQuest/commands/kill.js +36 -0
  20. package/bundle/typescript/src/commands/game/sideQuest/commands/kill.js.map +1 -0
  21. package/bundle/typescript/src/commands/game/sideQuest/commands/lock.d.ts +2 -1
  22. package/bundle/typescript/src/commands/game/sideQuest/commands/lock.js +54 -18
  23. package/bundle/typescript/src/commands/game/sideQuest/commands/lock.js.map +1 -1
  24. package/bundle/typescript/src/commands/game/sideQuest/commands/look.d.ts +2 -1
  25. package/bundle/typescript/src/commands/game/sideQuest/commands/look.js +58 -6
  26. package/bundle/typescript/src/commands/game/sideQuest/commands/look.js.map +1 -1
  27. package/bundle/typescript/src/commands/game/sideQuest/commands/read.d.ts +6 -0
  28. package/bundle/typescript/src/commands/game/sideQuest/commands/read.js +26 -0
  29. package/bundle/typescript/src/commands/game/sideQuest/commands/read.js.map +1 -0
  30. package/bundle/typescript/src/commands/game/sideQuest/commands/say.d.ts +1 -1
  31. package/bundle/typescript/src/commands/game/sideQuest/commands/say.js +12 -16
  32. package/bundle/typescript/src/commands/game/sideQuest/commands/say.js.map +1 -1
  33. package/bundle/typescript/src/commands/game/sideQuest/commands/search.d.ts +1 -1
  34. package/bundle/typescript/src/commands/game/sideQuest/commands/search.js +15 -11
  35. package/bundle/typescript/src/commands/game/sideQuest/commands/search.js.map +1 -1
  36. package/bundle/typescript/src/commands/game/sideQuest/commands/solve.d.ts +1 -1
  37. package/bundle/typescript/src/commands/game/sideQuest/commands/solve.js +1 -1
  38. package/bundle/typescript/src/commands/game/sideQuest/commands/solve.js.map +1 -1
  39. package/bundle/typescript/src/commands/game/sideQuest/commands/store.d.ts +1 -1
  40. package/bundle/typescript/src/commands/game/sideQuest/commands/store.js +1 -1
  41. package/bundle/typescript/src/commands/game/sideQuest/commands/store.js.map +1 -1
  42. package/bundle/typescript/src/commands/game/sideQuest/commands/take.d.ts +1 -1
  43. package/bundle/typescript/src/commands/game/sideQuest/commands/take.js +6 -4
  44. package/bundle/typescript/src/commands/game/sideQuest/commands/take.js.map +1 -1
  45. package/bundle/typescript/src/commands/game/sideQuest/commands/talk.d.ts +1 -1
  46. package/bundle/typescript/src/commands/game/sideQuest/commands/talk.js +4 -2
  47. package/bundle/typescript/src/commands/game/sideQuest/commands/talk.js.map +1 -1
  48. package/bundle/typescript/src/commands/game/sideQuest/commands/unequip.d.ts +1 -1
  49. package/bundle/typescript/src/commands/game/sideQuest/commands/unequip.js +1 -1
  50. package/bundle/typescript/src/commands/game/sideQuest/commands/unequip.js.map +1 -1
  51. package/bundle/typescript/src/commands/game/sideQuest/commands/unlock.d.ts +1 -1
  52. package/bundle/typescript/src/commands/game/sideQuest/commands/unlock.js +2 -2
  53. package/bundle/typescript/src/commands/game/sideQuest/commands/unlock.js.map +1 -1
  54. package/bundle/typescript/src/commands/game/sideQuest/commands/use.d.ts +1 -1
  55. package/bundle/typescript/src/commands/game/sideQuest/commands/use.js +1 -1
  56. package/bundle/typescript/src/commands/game/sideQuest/commands/use.js.map +1 -1
  57. package/bundle/typescript/src/commands/game/sideQuest/factories/item-factory.js +2 -1
  58. package/bundle/typescript/src/commands/game/sideQuest/factories/item-factory.js.map +1 -1
  59. package/bundle/typescript/src/commands/game/sideQuest/factories/scene-factory.js +22 -11
  60. package/bundle/typescript/src/commands/game/sideQuest/factories/scene-factory.js.map +1 -1
  61. package/bundle/typescript/src/commands/game/sideQuest/game.d.ts +17 -4
  62. package/bundle/typescript/src/commands/game/sideQuest/game.js +195 -4
  63. package/bundle/typescript/src/commands/game/sideQuest/game.js.map +1 -1
  64. package/bundle/typescript/src/commands/game/sideQuest/models/inventory.d.ts +1 -0
  65. package/bundle/typescript/src/commands/game/sideQuest/models/inventory.js +19 -6
  66. package/bundle/typescript/src/commands/game/sideQuest/models/inventory.js.map +1 -1
  67. package/bundle/typescript/src/commands/game/sideQuest/models/item.d.ts +5 -1
  68. package/bundle/typescript/src/commands/game/sideQuest/models/item.js +20 -0
  69. package/bundle/typescript/src/commands/game/sideQuest/models/item.js.map +1 -1
  70. package/bundle/typescript/src/commands/game/sideQuest/models/npc.d.ts +11 -2
  71. package/bundle/typescript/src/commands/game/sideQuest/models/npc.js +302 -96
  72. package/bundle/typescript/src/commands/game/sideQuest/models/npc.js.map +1 -1
  73. package/bundle/typescript/src/commands/game/sideQuest/models/player.d.ts +6 -2
  74. package/bundle/typescript/src/commands/game/sideQuest/models/player.js +142 -19
  75. package/bundle/typescript/src/commands/game/sideQuest/models/player.js.map +1 -1
  76. package/bundle/typescript/src/commands/game/sideQuest/models/room.d.ts +2 -1
  77. package/bundle/typescript/src/commands/game/sideQuest/models/room.js +24 -18
  78. package/bundle/typescript/src/commands/game/sideQuest/models/room.js.map +1 -1
  79. package/bundle/typescript/src/commands/game/sideQuest/models/scene.d.ts +6 -1
  80. package/bundle/typescript/src/commands/game/sideQuest/models/scene.js +28 -2
  81. package/bundle/typescript/src/commands/game/sideQuest/models/scene.js.map +1 -1
  82. package/bundle/typescript/src/commands/game/sideQuest/scenes/scene1.json +114 -0
  83. package/bundle/typescript/src/commands/game/sideQuest/scenes/scene2.json +323 -116
  84. package/bundle/typescript/src/commands/game/sideQuest/types/player-equipment.d.ts +16 -5
  85. package/bundle/typescript/src/commands/game/sideQuest/types/seed/item-seed.d.ts +1 -0
  86. package/bundle/typescript/src/commands/game/sideQuest/types/seed/player-seed.d.ts +2 -0
  87. package/bundle/typescript/src/commands/game/sideQuest/types/seed/scene-seed.d.ts +4 -0
  88. package/bundle/typescript/src/commands/game/sideQuest/types/shared/item-enum.d.ts +47 -12
  89. package/bundle/typescript/src/commands/game/sideQuest/types/shared/item-enum.js +53 -11
  90. package/bundle/typescript/src/commands/game/sideQuest/types/shared/item-enum.js.map +1 -1
  91. package/bundle/typescript/src/commands/game/sideQuest/ui.js +17 -161
  92. package/bundle/typescript/src/commands/game/sideQuest/ui.js.map +1 -1
  93. package/bundle/typescript/src/commands/game/sideQuest.sub.cmd.js +5 -2
  94. package/bundle/typescript/src/commands/game/sideQuest.sub.cmd.js.map +1 -1
  95. package/bundle/typescript/src/templates/meteor/api/api.js +1 -1
  96. package/bundle/typescript/src/templates/meteor/api/api.js.ts +1 -1
  97. package/package.json +1 -1
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maka/maka-cli",
3
- "version": "5.1.31",
3
+ "version": "5.1.33",
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.",
@@ -5,5 +5,5 @@ import { Scene } from '../models/scene.js';
5
5
  export declare class CommandRegistry {
6
6
  private scene;
7
7
  constructor(scene: Scene);
8
- parse(commandString: string, actor: Player | NPC): Command | null;
8
+ parse(commandString: string, actor: Player | NPC): Promise<Command | null>;
9
9
  }
@@ -5,7 +5,7 @@ export class CommandRegistry {
5
5
  constructor(scene) {
6
6
  this.scene = scene;
7
7
  }
8
- parse(commandString, actor) {
8
+ async parse(commandString, actor) {
9
9
  const parts = commandString.trim().split(' ');
10
10
  const verb = parts[0].toLowerCase();
11
11
  const args = parts.slice(1);
@@ -19,7 +19,7 @@ export class CommandRegistry {
19
19
  if (!command)
20
20
  return null;
21
21
  // Wrap the command with the args pre-bound (if needed)
22
- command.execute(args); // only if you have such a method
22
+ await command.execute(args); // only if you have such a method
23
23
  return command;
24
24
  }
25
25
  }
@@ -1 +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
+ {"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,KAAK,CAAC,aAAqB,EAAE,KAAmB;QACpD,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,MAAM,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,iCAAiC;QAE9D,OAAO,OAAO,CAAC;IACjB,CAAC;CACF"}
@@ -2,7 +2,7 @@ import { Direction } from '../types/shared/direction-enum.js';
2
2
  import { Player, Scene, Room, NPC } from '../models/_index.js';
3
3
  import { Logger } from '../utilities/logger.js';
4
4
  export interface ICommand {
5
- execute(args: string[]): string;
5
+ execute(args: string[]): Promise<string>;
6
6
  }
7
7
  export interface ICommandConstructor {
8
8
  actor: Player | NPC;
@@ -17,7 +17,7 @@ export declare abstract class Command {
17
17
  protected logger: Logger;
18
18
  protected scene: Scene;
19
19
  constructor(context: ICommandConstructor);
20
- abstract execute(args?: string[]): string;
20
+ abstract execute(args?: string[]): Promise<string>;
21
21
  protected isValidDirection(value: string): value is Direction;
22
22
  static getDescription(): string;
23
23
  }
@@ -2,6 +2,6 @@ import { Command, ICommand } from './command.js';
2
2
  export declare class DropCommand extends Command implements ICommand {
3
3
  protected static verb: string;
4
4
  protected static description: string;
5
- execute(args: string[]): string;
5
+ execute(args: string[]): Promise<string>;
6
6
  private drop;
7
7
  }
@@ -2,11 +2,11 @@ import { Command } from './command.js';
2
2
  export class DropCommand extends Command {
3
3
  static verb = 'drop';
4
4
  static description = 'Drop an item from your inventory.';
5
- execute(args) {
5
+ async execute(args) {
6
6
  this.logger.write(`${this.actor.name} is Attempting 'Drop' command with item: ${args.join(' ')}`);
7
- return this.drop(args);
7
+ return await this.drop(args);
8
8
  }
9
- drop(args) {
9
+ async drop(args) {
10
10
  const itemName = args.join(' ').toLowerCase(); // Assuming the item name may contain spaces
11
11
  // Check if the item exists in the player's inventory
12
12
  if (!this.actor.inventory.hasItem(itemName)) {
@@ -20,8 +20,11 @@ export class DropCommand extends Command {
20
20
  return `You don't have ${itemName} in your inventory.`;
21
21
  }
22
22
  // Remove the item from player's inventory and add it to the current room's inventory
23
- this.actor.inventory.removeItem(itemName);
24
- this.actor.currentLocation.inventory.addItem(itemToDrop);
23
+ const didDrop = this.actor.inventory.transferItemTo(itemName, this.actor.currentLocation.inventory);
24
+ if (!didDrop) {
25
+ this.logger.write(`${this.actor.name} could not drop the ${itemName}. It is no droppable`);
26
+ return `You cannot drop ${itemName}`;
27
+ }
25
28
  this.logger.write(`${this.actor.name} has successfully dropped "${itemName}" from inventory to ${this.actor.currentLocation.name} during 'Drop' command.`);
26
29
  this.actor.performAction('drop', itemName);
27
30
  return `You dropped ${itemName}.`;
@@ -1 +1 @@
1
- {"version":3,"file":"drop.js","sourceRoot":"","sources":["../../../../../../../src/commands/game/sideQuest/commands/drop.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAY,MAAM,cAAc,CAAC;AAEjD,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,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,4CAA4C,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QAClG,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IAEO,IAAI,CAAC,IAAc;QACzB,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC,CAAE,4CAA4C;QAE5F,qDAAqD;QACrD,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC5C,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,QAAQ,kBAAkB,IAAI,CAAC,KAAK,CAAC,IAAI,qCAAqC,CAAC,CAAC;YAC3G,OAAO,kBAAkB,QAAQ,qBAAqB,CAAC;QACzD,CAAC;QAED,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAE1D,oD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C,aAAa,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;QAC3C,OAAO,eAAe,QAAQ,GAAG,CAAC;IACpC,CAAC"}
@@ -2,6 +2,6 @@ import { Command, ICommand } from './command.js';
2
2
  export declare class EquipCommand extends Command implements ICommand {
3
3
  protected static verb: string;
4
4
  protected static description: string;
5
- execute(args: string[]): string;
5
+ execute(args: string[]): Promise<string>;
6
6
  private equip;
7
7
  }
@@ -1,28 +1,63 @@
1
1
  import { Command } from './command.js';
2
+ import { Category } from '../types/shared/item-enum.js';
2
3
  export class EquipCommand extends Command {
3
4
  static verb = 'equip';
4
- static description = 'Equip an item.';
5
- execute(args) {
5
+ static description = 'Equip an item or everything in your inventory.';
6
+ async execute(args) {
7
+ if (!args)
8
+ return '';
6
9
  return this.equip(args);
7
10
  }
8
11
  equip(args) {
9
- const itemName = args.join(' ').toLowerCase();
10
- // Using the getItem method from the Inventory class to retrieve the item from the player's inventory
12
+ if (!args)
13
+ return '';
14
+ const input = args?.join(' ').trim().toLowerCase();
15
+ // EQUIP ALL
16
+ if (input === 'all') {
17
+ const items = this.actor.inventory.getAllItems();
18
+ if (items.length === 0) {
19
+ return `You have nothing to equip.`;
20
+ }
21
+ const results = [];
22
+ for (const item of items) {
23
+ if (this.actor.canEquip(item)) {
24
+ const slotInfo = this.actor.determineEquipmentSlot(item.category);
25
+ if (slotInfo) {
26
+ const { group, slot } = slotInfo;
27
+ const groupRef = this.actor.equipment[group];
28
+ if (groupRef !== null && !groupRef[slot]) {
29
+ groupRef[slot] = item;
30
+ this.actor.inventory.removeItem(item.name);
31
+ results.push(`Equipped ${item.name} in ${group}.${slot}`);
32
+ if (item.category === Category.Weapon) {
33
+ this.actor.performAction('equipped weapon', item.name);
34
+ }
35
+ continue;
36
+ }
37
+ }
38
+ results.push(`Could not equip ${item.name}: slot unavailable or unknown.`);
39
+ }
40
+ else {
41
+ results.push(`Cannot equip ${item.name}.`);
42
+ }
43
+ }
44
+ return results?.join('\n');
45
+ }
46
+ // EQUIP ONE
47
+ const itemName = input;
11
48
  let itemToEquip = this.actor.inventory.getItem(itemName);
49
+ // If not in inventory, try to grab from the room (single-item only)
12
50
  if (!itemToEquip) {
13
51
  const room = this.actor.currentLocation;
14
- // Using the getItem method from the Inventory class to retrieve the item from the room's inventory
15
52
  itemToEquip = room.inventory.getItem(itemName);
16
53
  if (itemToEquip) {
17
- // Using the addItem method from the Inventory class to add the item to the player's inventory
18
54
  this.actor.inventory.addItem(itemToEquip);
19
- // Using the removeItem method from the Inventory class to remove the item from the room's inventory
20
55
  room.inventory.removeItem(itemName);
21
56
  this.logger.write(`EquipCommand: ${itemName} taken from room and added to ${this.actor.name}'s inventory.`);
22
57
  }
23
58
  else {
24
- this.logger.error(`EquipCommand: ${itemName} not found in ${this.actor.name} inventory or ${this.actor.currentLocation.name} room.`);
25
- return `You don't have ${itemName} in your inventory, and it's not in this room.`;
59
+ this.logger.error(`EquipCommand: ${itemName} not found in ${this.actor.name}'s inventory or the room.`);
60
+ return `You don't have "${itemName}" and it's not in the room either.`;
26
61
  }
27
62
  }
28
63
  this.actor.performAction('equip', itemToEquip.name);
@@ -1 +1 @@
1
- {"version":3,"file":"equip.js","sourceRoot":"","sources":["../../../../../../../src/commands/game/sideQuest/commands/equip.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAY,MAAM,cAAc,CAAC;AAEjD,MAAM,OAAO,YAAa,SAAQ,OAAO;IAC7B,MAAM,CAAC,IAAI,GAAG,OAAO,CAAC;IACtB,MAAM,CAAC,WAAW,GAAG,gBAAgB,CAAC;IAEhD,OAAO,CAAC,IAAc;QACpB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAEO,KAAK,CAAC,IAAc;QAC1B,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;QAE9C,qGAAqG;QACrG,IAAI,WAAW,GAAG,IAAI,CAAC,KAA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C,MAAM,CAAC,KAAK,CAAC,iBAAiB,QAAQ,iCAAiC,IAAI,CAAC,KAAK,CAAC,IAAI,eAAe,CAAC,CAAC;YAC9G,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,QAAQ,iBAAiB,IAAI,CAAC,KAAK,CAAC,IAAI,2BAA2B,CAAC,CAAC;gBACxG,OAAO,mBAAmB,QAAQ,oCAAoC,CAAC;YACzE,CAAC;QACH,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC;QACpD,MAAM,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QACpD,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,iBAAiB,aAAa,EAAE,CAAC,CAAC;QAEpD,OAAO,aAAa,CAAC;IACvB,CAAC"}
@@ -2,6 +2,6 @@ import { Command, ICommand } from './command.js';
2
2
  export declare class GiveCommand extends Command implements ICommand {
3
3
  protected static verb: string;
4
4
  protected static description: string;
5
- execute(args: string[]): string;
5
+ execute(args: string[]): Promise<string>;
6
6
  private give;
7
7
  }
@@ -2,7 +2,9 @@ import { Command } from './command.js';
2
2
  export class GiveCommand extends Command {
3
3
  static verb = 'give';
4
4
  static description = 'Give an item or money to someone.';
5
- execute(args) {
5
+ async execute(args) {
6
+ if (!args)
7
+ return '';
6
8
  this.logger.write(`Attempting 'Give' command with input: ${args.join(' ')}`);
7
9
  return this.give(args);
8
10
  }
@@ -41,8 +43,13 @@ export class GiveCommand extends Command {
41
43
  this.logger.write(`${this.actor.name} tried to give item "${itemOrAmount}" but does not have it.`);
42
44
  return `You don’t have "${itemOrAmount}".`;
43
45
  }
44
- this.actor.removeInventory(item);
45
- recipient.addInventory(item);
46
+ const didTransfer = this.actor.inventory.transferItemTo(item.name, recipient.inventory);
47
+ if (!didTransfer) {
48
+ this.logger.write(`Item "${item.name}" is not transferable.`);
49
+ this.actor.performAction('did not give', `item cannot be given`);
50
+ return `You cannot give that item away`;
51
+ }
52
+ this.scene.updateInventory(recipient.inventory);
46
53
  this.actor.performAction('give', `${item.name} to ${recipient.name}`);
47
54
  this.logger.write(`${this.actor.name} gave item "${item.name}" to ${recipient.name}`);
48
55
  return `You gave ${item.name} to ${recipient.name}.`;
@@ -1 +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,EAAE,CAAC,IAAI,CACrC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,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AAa,CAAC,cAAc,EAAE,sBAAsB,CAAC,CAAC;YACjE,OAAO,gCAAgC,CAAC;QAC1C,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAChD,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"}
@@ -2,6 +2,6 @@ import { Command, ICommand } from './command.js';
2
2
  export declare class GoCommand extends Command implements ICommand {
3
3
  protected static verb: string;
4
4
  protected static description: string;
5
- execute(args: string[]): string;
5
+ execute(args: string[]): Promise<string>;
6
6
  private go;
7
7
  }
@@ -3,8 +3,10 @@ import { Command } from './command.js';
3
3
  export class GoCommand extends Command {
4
4
  static verb = 'go';
5
5
  static description = 'Move in the specified direction.';
6
- execute(args) {
7
- this.logger.write(`${this.actor.name} is attempting 'Go' command with direction: ${args.join(' ')}`);
6
+ async execute(args) {
7
+ if (!args)
8
+ return '';
9
+ this.logger.write(`${this.actor.name} is attempting 'Go' command with direction: ${args?.join(' ')}`);
8
10
  return this.go(args);
9
11
  }
10
12
  go(args) {
@@ -39,6 +41,7 @@ export class GoCommand extends Command {
39
41
  this.logger.error(`${this.actor.name} 'Go' command failed: Unable to determine the other side of the door.`);
40
42
  return 'There seems to be an error with the door you\'re trying to go through.';
41
43
  }
44
+ this.actor.performAction('exits', `${this.actor.currentLocation.name} to ${targetRoom.name}`);
42
45
  this.actor.currentLocation = targetRoom; // Update player's location
43
46
  this.actor.performAction('enters', targetRoom.name);
44
47
  }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AAC,KAAK,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,uEAAuE,CAAC,CAAC;gBAC7G,OAAO,wEAAwE,CAAC;YAClF,CAAC;YAED,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,IAAI,OAAO,UAAU,CAAC,IAAI,EAAE,CAAC,CAAC;YAC9F,IAAI,CAAC,KAAK,CAAC,eAAe,GAAG,UAAU,CAAC,CAAE,2BAA2B;YACrE,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,QAAQ,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC;QACtD,CAAC;aAAM,CAAC;YACN,+BAA+B;YAC/B,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAE,+BAA+B;YACjF,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,+BAA+B,IAAI,cAAc,CAAC,CAAC;gBACvF,OAAO,mEAAmE,CAAC;YAC7E,CAAC;YACD,IAAI,CAAC,KAAK,CAAC,eAAe,GAAG,QAAQ,CAAC;YACtC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;QACpD,CAAC;QAED,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,mBAAmB,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,IAAI,IAAI,cAAc,GAAG,CAAC,CAAC;QAE7G,6DAA6D;QAC7D,OAAO,IAAI,CAAC,KAAK,CAAC,eAAe,CAAC,WAAW,CAAC;IAChD,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { Command, ICommand } from './command.js';
2
+ export declare class KillCommand extends Command implements ICommand {
3
+ protected static verb: string;
4
+ protected static description: string;
5
+ execute(args?: string[]): Promise<string>;
6
+ }
@@ -0,0 +1,36 @@
1
+ import { Command } from './command.js';
2
+ export class KillCommand extends Command {
3
+ static verb = 'kill';
4
+ static description = 'Attempt to kill another character in the room.';
5
+ async execute(args = []) {
6
+ if (!args)
7
+ return '';
8
+ if (args.length === 0) {
9
+ return 'Who do you want to kill? Try: `kill [character name]`';
10
+ }
11
+ const targetName = args.join(' ').toLowerCase();
12
+ const currentRoom = this.actor.currentLocation;
13
+ const scene = this.scene;
14
+ if (!currentRoom || !scene) {
15
+ return 'You are not in a valid location to perform this action.';
16
+ }
17
+ const possibleTargets = scene.getActorsInRoom(currentRoom).filter(actor => actor !== this.actor);
18
+ const target = possibleTargets.find(actor => actor.name.toLowerCase() === targetName);
19
+ const possibleTargetNames = possibleTargets.map(a => a.name).join(', ');
20
+ this.logger.write(`KillCommand: Possible targets in ${currentRoom.name}: ${possibleTargetNames}`);
21
+ if (!target) {
22
+ return `You don’t see anyone named "${targetName}" here.`;
23
+ }
24
+ const isPlayer = target === scene.getPlayer();
25
+ scene.removeActor(target.name);
26
+ this.logger.write(`KillCommand: ${this.actor.name} killed ${target.name} in ${currentRoom.name}`);
27
+ this.actor.performAction('kills', target.name);
28
+ if (isPlayer) {
29
+ this.scene.endGame();
30
+ this.logger.logWithColor(`Game Over: ${target.name} (the player) was killed by ${this.actor.name}.`, 'red');
31
+ this.logger.logWithColor(`Press ctrl-c to quit`, 'red');
32
+ }
33
+ return `You swiftly end ${target.name}'s life. Their body collapses in ${currentRoom.name}.`;
34
+ }
35
+ }
36
+ //# sourceMappingURL=kill.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"kill.js","sourceRoot":"","sources":["../../../../../../../src/commands/game/sideQuest/commands/kill.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAY,MAAM,cAAc,CAAC;AAGjD,MAAM,OAAO,WAAY,SAAQ,OAAO;IAC5B,MAAM,CAAC,IAAI,GAA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AM,CAAC,IAAI,CAAC,CAAC;QAE/B,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,gBAAgB,IAAI,CAAC,KAAK,CAAC,IAAI,WAAW,MAAM,CAAC,IAAI,OAAO,WAAW,CAAC,IAAI,EAAE,CAAC,CAAC;QAClG,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC;QAE/C,IAAI,QAAQ,EAAE,CAAC;YACb,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC;YACrB,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,cAAc,MAAM,CAAC,IAAI,+BAA+B,IAAI,CAAC,KAAK,CAAC,IAAI,GAAG,EAAE,KAAK,CAAC,CAAC;YAC5G,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAC;QAC1D,CAAC;QAED,OAAO,mBAAmB,MAAM,CAAC,IAAI,oCAAoC,WAAW,CAAC,IAAI,GAAG,CAAC;IAC/F,CAAC"}
@@ -2,6 +2,7 @@ import { Command, ICommand } from './command.js';
2
2
  export declare class LockCommand extends Command implements ICommand {
3
3
  protected static verb: string;
4
4
  protected static description: string;
5
- execute(args: string[]): string;
5
+ execute(args: string[]): Promise<string>;
6
6
  private lock;
7
+ private attemptToLockDoor;
7
8
  }
@@ -1,8 +1,11 @@
1
+ import { Door } from '../models/door.js';
1
2
  import { Command } from './command.js';
2
3
  export class LockCommand extends Command {
3
4
  static verb = 'lock';
4
5
  static description = 'Lock a door.';
5
- execute(args) {
6
+ async execute(args) {
7
+ if (!args)
8
+ return '';
6
9
  return this.lock(args);
7
10
  }
8
11
  lock(args) {
@@ -10,28 +13,61 @@ export class LockCommand extends Command {
10
13
  this.logger.error('LockCommand: No target specified.');
11
14
  return 'Please specify which door you want to lock.';
12
15
  }
13
- const target = args[0].toLowerCase();
16
+ const target = args.join(' ').toLowerCase();
14
17
  const room = this.actor.currentLocation;
15
- if (this.isValidDirection(target) && room.exits.has(target)) {
16
- const door = room.exits.get(target);
17
- if (door.isLocked) {
18
- return `The door named "${target}" is already locked.`;
19
- }
20
- const requiredKeyOrSolution = door.unlockItemOrSolution?.toLowerCase();
21
- if (requiredKeyOrSolution && this.actor.inventory.hasItem(requiredKeyOrSolution)) {
18
+ // 1. Try finding the door by direction
19
+ let doorEntry = [...room.exits.entries()].find(entry => entry[0].toLowerCase() === target);
20
+ // 2. If not found by direction, try matching the connected room name
21
+ if (!doorEntry) {
22
+ doorEntry = [...room.exits.entries()].find(([_, d]) => {
23
+ if (!(d instanceof Door))
24
+ return false;
25
+ const otherRoomName = d.roomA.name.toLowerCase() === room.name.toLowerCase()
26
+ ? d.roomB.name.toLowerCase()
27
+ : d.roomA.name.toLowerCase();
28
+ return otherRoomName === target;
29
+ });
30
+ }
31
+ if (!doorEntry) {
32
+ this.logger.write(`LockCommand: No door found for target "${target}" in ${room.name}.`);
33
+ return `There's no door named or leading to "${target}" here.`;
34
+ }
35
+ const [direction, door] = doorEntry;
36
+ if (!(door instanceof Door)) {
37
+ this.logger.write(`LockCommand: Exit found but is not a door: "${target}"`);
38
+ return `There's no door named or leading to "${target}" here.`;
39
+ }
40
+ if (door.checkIfLocked()) {
41
+ return `The door leading to "${door.getOtherSideToName(room)}" is already locked.`;
42
+ }
43
+ const requiredKeyOrSolution = door.unlockItemOrSolution?.toLowerCase();
44
+ if (requiredKeyOrSolution && this.actor.inventory.hasItem(requiredKeyOrSolution)) {
45
+ const key = this.actor.inventory.getItem(requiredKeyOrSolution);
46
+ if (key) {
22
47
  door.isLocked = true;
23
- this.logger.write(`LockCommand: ${this.actor.name} Locked the ${target} door.`);
24
- this.actor.performAction('lock', target);
25
- return `You locked the door named "${target}".`;
26
- }
27
- else {
28
- this.logger.write(`LockCommand: ${this.actor.name} does not have the necessary key for ${target}.`);
29
- return `You don't have the key to lock this door.`;
48
+ this.logger.write(`LockCommand: ${this.actor.name} locked the door to ${door.getOtherSideToName(room)}.`);
49
+ this.actor.performAction('locked', `the door to ${door.getOtherSideToName(room)}`);
50
+ this.scene.updateExits(room);
51
+ return `You locked the door leading to ${door.getOtherSideToName(room)}.`;
30
52
  }
31
53
  }
54
+ this.logger.write(`LockCommand: ${this.actor.name} does not have the required key (${requiredKeyOrSolution}) for "${target}".`);
55
+ return `You don't have the key to lock this door.`;
56
+ }
57
+ attemptToLockDoor(door, label) {
58
+ if (door.checkIfLocked()) {
59
+ return `The door "${label}" is already locked.`;
60
+ }
61
+ const requiredKeyOrSolution = door.unlockItemOrSolution?.toLowerCase();
62
+ if (requiredKeyOrSolution && this.actor.inventory.hasItem(requiredKeyOrSolution)) {
63
+ door.isLocked = true;
64
+ this.logger.write(`LockCommand: ${this.actor.name} locked the door: ${label}`);
65
+ this.actor.performAction('lock', label);
66
+ return `You locked the door "${label}".`;
67
+ }
32
68
  else {
33
- this.logger.write(`LockCommand: ${target} is not a valid exit in this room.`);
34
- return `There's no door named "${target}" here.`;
69
+ this.logger.write(`LockCommand: ${this.actor.name} does not have the required key for door "${label}".`);
70
+ return `You don't have the key to lock this door.`;
35
71
  }
36
72
  }
37
73
  }
@@ -1 +1 @@
1
- {"version":3,"file":"lock.js","sourceRoot":"","sources":["../../../../../../../src/commands/game/sideQuest/commands/lock.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAY,MAAM,cAAc,CAAC;AAEjD,MAAM,OAAO,WAAY,SAAQ,OAAO;IAC5B,MAAM,CAAC,IAAI,GAAG,MAAM,CAAC;IACrB,MAAM,CAAC,WAAW,GAAG,cAAc,CAAC;IAE9C,OAAO,CAAC,IAAc;QACpB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;IAEO,IAAI,CAAC,IAAc;QACzB,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACtB,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,mCAAmC,CAAC,CAAC;YACvD,OAAO,6CAA6C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MAAM,CAAC,KAAK,CAAC,gBAAgB,IAAI,CAAC,KAAK,CAAC,IAAI,6CAA6C,KAAK,IAAI,CAAC,CAAC;YACzG,OAAO,2CAA2C,CAAC;QACrD,CAAC;IACH,CAAC"}
@@ -2,8 +2,9 @@ import { Command, ICommand } from './command.js';
2
2
  export declare class LookCommand extends Command implements ICommand {
3
3
  protected static verb: string;
4
4
  protected static description: string;
5
- execute(args?: string[]): string;
5
+ execute(args: string[]): Promise<string>;
6
6
  private look;
7
7
  private lookOutside;
8
8
  private inspectItem;
9
+ private inspectActor;
9
10
  }
@@ -1,11 +1,15 @@
1
1
  import { Door } from '../models/door.js';
2
+ import { Category } from '../types/shared/item-enum.js';
2
3
  import { Command } from './command.js';
3
4
  export class LookCommand extends Command {
4
5
  static verb = 'look';
5
6
  static description = 'Examine your surroundings';
6
- execute(args = []) {
7
+ async execute(args) {
7
8
  this.logger.write("Executing 'Look' command.");
8
- const target = args.join(' ');
9
+ let words = Array.isArray(args) ? args.map(w => w.toLowerCase()) : [];
10
+ if (words[0] === 'at')
11
+ words.shift();
12
+ const target = words?.join(' ');
9
13
  if (target) {
10
14
  if (this.actor.inventory.hasItem(target)) {
11
15
  this.logger.write(`Looking at item '${target}' in ${this.actor.name} inventory.`);
@@ -20,12 +24,18 @@ export class LookCommand extends Command {
20
24
  return this.lookOutside(target);
21
25
  }
22
26
  else {
27
+ // Check if it's another player or NPC in the room
28
+ const actorMatch = this.scene
29
+ .getActorsInRoom(this.actor.currentLocation)
30
+ .find(a => a.name.toLowerCase() === target.toLowerCase());
31
+ if (actorMatch) {
32
+ return this.inspectActor(actorMatch.name);
33
+ }
23
34
  return `You cannot see ${target}`;
24
35
  }
25
36
  }
26
37
  else {
27
38
  this.logger.write(`${this.actor.name} is looking around the current room.`);
28
- this.actor.performAction('looks', `around ${this.actor.currentLocation.name}`);
29
39
  return this.look();
30
40
  }
31
41
  }
@@ -38,13 +48,28 @@ export class LookCommand extends Command {
38
48
  let description = (room.details) ? room.details : room.description;
39
49
  const otherActors = this.scene
40
50
  .getActorsInRoom(room)
41
- .filter(a => a !== this.actor);
51
+ .filter(a => a.name !== this.actor.name);
42
52
  if (otherActors.length > 0) {
43
53
  const actorList = otherActors.map(a => `• ${a.name}`).join('\n');
44
54
  description += `\n\nYou see:\n${actorList}`;
45
55
  }
46
- if (room.puzzle && !room.puzzle.isSolved()) {
47
- description += `\n\nPuzzle here: ${room.puzzle.riddle}`;
56
+ // --- Add exits here ---
57
+ const exits = Array.from(room.exits.entries())
58
+ .map(([direction, exit]) => {
59
+ if (typeof exit === 'string') {
60
+ return `• ${direction}: ${exit}`;
61
+ }
62
+ else if (exit instanceof Door) {
63
+ const targetRoom = exit.getOtherSideToName(room);
64
+ const lockedStr = exit.checkIfLocked() ? ' (locked)' : '';
65
+ return `• ${direction}: ${targetRoom}${lockedStr}`;
66
+ }
67
+ else {
68
+ return `• ${direction}: Unknown`;
69
+ }
70
+ });
71
+ if (exits.length > 0) {
72
+ description += `\n\nExits:\n${exits?.join('\n')}`;
48
73
  }
49
74
  return description;
50
75
  }
@@ -78,8 +103,35 @@ export class LookCommand extends Command {
78
103
  if (!item) {
79
104
  return `You don't see any ${itemName} here.`;
80
105
  }
106
+ if (item.category == Category.Book) {
107
+ return `${item.description} is readable.`;
108
+ }
81
109
  // Assuming that the `Item` class has a `details` property that provides a more detailed description.
82
110
  return item.details || item.description || `It's just a regular ${itemName}.`;
83
111
  }
112
+ inspectActor(targetName) {
113
+ const target = this.scene.getActor(targetName);
114
+ if (!target) {
115
+ return `You don't see anyone named ${targetName}.`;
116
+ }
117
+ const lines = [];
118
+ lines.push(`${target.name} is here.`);
119
+ const equipment = target.equipment;
120
+ for (const groupKey of Object.keys(equipment)) {
121
+ const group = equipment[groupKey];
122
+ if (!group)
123
+ continue;
124
+ for (const slotKey of Object.keys(group)) {
125
+ const item = group[slotKey];
126
+ if (item) {
127
+ lines.push(`• ${groupKey}.${slotKey}: ${item.name}`);
128
+ }
129
+ }
130
+ }
131
+ if (lines.length === 1) {
132
+ lines.push(`${target.name} doesn't appear to be wearing anything.`);
133
+ }
134
+ return lines?.join('\n');
135
+ }
84
136
  }
85
137
  //# sourceMappingURL=look.js.map