@maka/maka-cli 5.1.24 → 5.1.26
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 +2 -2
- package/bundle/typescript/src/commands/game/sideQuest/commands/command.js +1 -0
- package/bundle/typescript/src/commands/game/sideQuest/commands/command.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/commands/look.js +8 -2
- package/bundle/typescript/src/commands/game/sideQuest/commands/look.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/commands/store.d.ts +8 -0
- package/bundle/typescript/src/commands/game/sideQuest/commands/store.js +32 -0
- package/bundle/typescript/src/commands/game/sideQuest/commands/store.js.map +1 -0
- package/bundle/typescript/src/commands/game/sideQuest/factories/roomsF.js +3 -1
- package/bundle/typescript/src/commands/game/sideQuest/factories/roomsF.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/factories/sceneSynthesizer.d.ts +6 -0
- package/bundle/typescript/src/commands/game/sideQuest/factories/sceneSynthesizer.js +65 -0
- package/bundle/typescript/src/commands/game/sideQuest/factories/sceneSynthesizer.js.map +1 -0
- package/bundle/typescript/src/commands/game/sideQuest/game.d.ts +5 -4
- package/bundle/typescript/src/commands/game/sideQuest/game.js +7 -5
- package/bundle/typescript/src/commands/game/sideQuest/game.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/models/inventory.d.ts +3 -0
- package/bundle/typescript/src/commands/game/sideQuest/models/inventory.js +10 -0
- package/bundle/typescript/src/commands/game/sideQuest/models/inventory.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/models/item.d.ts +12 -0
- package/bundle/typescript/src/commands/game/sideQuest/models/item.js +51 -1
- package/bundle/typescript/src/commands/game/sideQuest/models/item.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/models/player.d.ts +8 -1
- package/bundle/typescript/src/commands/game/sideQuest/models/player.js +61 -70
- package/bundle/typescript/src/commands/game/sideQuest/models/player.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/models/puzzle.d.ts +1 -0
- package/bundle/typescript/src/commands/game/sideQuest/models/puzzle.js +2 -0
- package/bundle/typescript/src/commands/game/sideQuest/models/puzzle.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/models/room.d.ts +17 -0
- package/bundle/typescript/src/commands/game/sideQuest/models/room.js +76 -21
- package/bundle/typescript/src/commands/game/sideQuest/models/room.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/models/scene.d.ts +21 -1
- package/bundle/typescript/src/commands/game/sideQuest/models/scene.js +104 -15
- package/bundle/typescript/src/commands/game/sideQuest/models/scene.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/scenes/items.d.ts +3 -0
- package/bundle/typescript/src/commands/game/sideQuest/scenes/items.js +15 -0
- package/bundle/typescript/src/commands/game/sideQuest/scenes/items.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/scenes/rooms.js +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/scenes/scene1.json +143 -0
- package/bundle/typescript/src/commands/game/sideQuest/types/enums.d.ts +6 -3
- package/bundle/typescript/src/commands/game/sideQuest/types/enums.js +3 -0
- package/bundle/typescript/src/commands/game/sideQuest/types/enums.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest/types/interfaces.d.ts +84 -0
- package/bundle/typescript/src/commands/game/sideQuest/ui.d.ts +2 -2
- package/bundle/typescript/src/commands/game/sideQuest/ui.js +19 -8
- package/bundle/typescript/src/commands/game/sideQuest/ui.js.map +1 -1
- package/bundle/typescript/src/commands/game/sideQuest.sub.cmd.js +3 -2
- package/bundle/typescript/src/commands/game/sideQuest.sub.cmd.js.map +1 -1
- package/package.json +2 -2
|
@@ -9,34 +9,30 @@ export class Player extends AbstractPlayer {
|
|
|
9
9
|
_currentLocation;
|
|
10
10
|
_inventory;
|
|
11
11
|
_equipment;
|
|
12
|
-
_maxCarryingWeight = 50;
|
|
12
|
+
_maxCarryingWeight = 50;
|
|
13
|
+
_lifestyleChoices = [];
|
|
13
14
|
logger;
|
|
15
|
+
_currency = 0; // for seeding/debug only
|
|
14
16
|
constructor(config) {
|
|
15
17
|
super();
|
|
16
18
|
this._playerName = config.playerName;
|
|
17
19
|
this._currentLocation = config.startLocation || new Room({ name: 'Nexus', description: 'A featureless room' });
|
|
18
20
|
this._inventory = new Inventory();
|
|
19
|
-
this.logger = Logger.getInstance();
|
|
21
|
+
this.logger = Logger.getInstance();
|
|
22
|
+
this._lifestyleChoices = config.lifestyleChoices ?? [];
|
|
20
23
|
if (config?.inventoryItems) {
|
|
21
24
|
for (const item of config.inventoryItems) {
|
|
22
25
|
this._inventory.addItem(item);
|
|
23
26
|
}
|
|
24
27
|
}
|
|
25
28
|
this._equipment = config?.initialEquipment || {
|
|
26
|
-
head: null,
|
|
27
|
-
|
|
28
|
-
legs: null,
|
|
29
|
-
feet: null,
|
|
30
|
-
arms: null,
|
|
31
|
-
gloves: null,
|
|
32
|
-
leftHand: null,
|
|
33
|
-
rightHand: null,
|
|
29
|
+
head: null, torso: null, legs: null, feet: null,
|
|
30
|
+
arms: null, gloves: null, leftHand: null, rightHand: null
|
|
34
31
|
};
|
|
35
32
|
}
|
|
36
33
|
get name() {
|
|
37
34
|
return this._playerName;
|
|
38
35
|
}
|
|
39
|
-
// Accessor for currentLocation
|
|
40
36
|
get currentLocation() {
|
|
41
37
|
return this._currentLocation;
|
|
42
38
|
}
|
|
@@ -47,23 +43,20 @@ export class Player extends AbstractPlayer {
|
|
|
47
43
|
}
|
|
48
44
|
this._currentLocation = room;
|
|
49
45
|
}
|
|
50
|
-
// Accessor for inventory
|
|
51
46
|
get inventory() {
|
|
52
47
|
return this._inventory;
|
|
53
48
|
}
|
|
54
|
-
// Accessor for equipment
|
|
55
49
|
get equipment() {
|
|
56
50
|
return this._equipment;
|
|
57
51
|
}
|
|
58
52
|
set equipment(newEquipment) {
|
|
59
53
|
this._equipment = newEquipment;
|
|
60
54
|
}
|
|
61
|
-
// Accessor for maxCarryingWeight
|
|
62
55
|
get maxCarryingWeight() {
|
|
63
56
|
return this._maxCarryingWeight;
|
|
64
57
|
}
|
|
65
58
|
set maxCarryingWeight(weight) {
|
|
66
|
-
if (weight > 0) {
|
|
59
|
+
if (weight > 0) {
|
|
67
60
|
this._maxCarryingWeight = weight;
|
|
68
61
|
}
|
|
69
62
|
else {
|
|
@@ -71,9 +64,7 @@ export class Player extends AbstractPlayer {
|
|
|
71
64
|
}
|
|
72
65
|
}
|
|
73
66
|
get currentWeight() {
|
|
74
|
-
// Calculate using the items in Inventory and equipped items
|
|
75
67
|
let totalWeight = this._inventory.getWeight();
|
|
76
|
-
// Sum up weights of equipped items
|
|
77
68
|
for (const slot in this._equipment) {
|
|
78
69
|
const equippedItem = this._equipment[slot];
|
|
79
70
|
if (equippedItem) {
|
|
@@ -82,9 +73,7 @@ export class Player extends AbstractPlayer {
|
|
|
82
73
|
}
|
|
83
74
|
return totalWeight;
|
|
84
75
|
}
|
|
85
|
-
// Add an item to the player's inventory
|
|
86
76
|
addInventory(item) {
|
|
87
|
-
// Check if adding the item exceeds the max weight the player can carry
|
|
88
77
|
if (this.currentWeight + item.weight > this.maxCarryingWeight) {
|
|
89
78
|
this.logger.write("Failed to add item to inventory due to weight limits.");
|
|
90
79
|
throw new Error("The item is too heavy to add to your inventory.");
|
|
@@ -92,7 +81,6 @@ export class Player extends AbstractPlayer {
|
|
|
92
81
|
this._inventory.addItem(item);
|
|
93
82
|
this.logger.write(`Added ${item.name} to player's inventory.`);
|
|
94
83
|
}
|
|
95
|
-
// Remove an item from the player's inventory
|
|
96
84
|
removeInventory(item) {
|
|
97
85
|
if (this._inventory.removeItem(item.name)) {
|
|
98
86
|
this.logger.write(`Removed ${item.name} from player's inventory.`);
|
|
@@ -116,99 +104,102 @@ export class Player extends AbstractPlayer {
|
|
|
116
104
|
return `You are already wearing something on your ${slot}. You must unequip it first.`;
|
|
117
105
|
}
|
|
118
106
|
this.equipment[slot] = item;
|
|
119
|
-
this.removeInventory(item);
|
|
107
|
+
this.removeInventory(item);
|
|
120
108
|
return `You equipped ${item.name}.`;
|
|
121
109
|
}
|
|
122
110
|
unequip(input) {
|
|
123
|
-
// First, try to interpret the input as an equipment slot
|
|
124
111
|
let slot = input;
|
|
125
|
-
// If the input is not a recognized slot, try to interpret it as a category and get the corresponding slot
|
|
126
112
|
if (!this.equipment[camelCase(slot)]) {
|
|
127
113
|
slot = this.determineEquipmentSlot(input);
|
|
128
|
-
if (!slot)
|
|
114
|
+
if (!slot)
|
|
129
115
|
return `Invalid category or slot: ${input}.`;
|
|
130
|
-
}
|
|
131
116
|
}
|
|
132
117
|
return this.unequipBySlot(slot);
|
|
133
118
|
}
|
|
134
119
|
determineEquipmentSlot(input) {
|
|
135
120
|
switch (input.toLowerCase()) {
|
|
136
|
-
|
|
137
|
-
case Category.
|
|
138
|
-
|
|
139
|
-
case Category.Shield.toLowerCase():
|
|
140
|
-
return 'leftHand';
|
|
141
|
-
case Category.Gloves.toLowerCase():
|
|
142
|
-
return 'gloves';
|
|
121
|
+
case Category.Weapon.toLowerCase(): return 'rightHand';
|
|
122
|
+
case Category.Shield.toLowerCase(): return 'leftHand';
|
|
123
|
+
case Category.Gloves.toLowerCase(): return 'gloves';
|
|
143
124
|
case Category.Helmet.toLowerCase():
|
|
144
|
-
case Category.Hat.toLowerCase():
|
|
145
|
-
|
|
146
|
-
case Category.
|
|
147
|
-
|
|
148
|
-
case Category.
|
|
149
|
-
|
|
150
|
-
case
|
|
151
|
-
return 'arms';
|
|
152
|
-
case Category.BodyArmor.toLowerCase():
|
|
153
|
-
return 'torso';
|
|
154
|
-
// For UnequipCommand: Based on slot name
|
|
155
|
-
case 'weapon':
|
|
156
|
-
return 'rightHand'; // Again, assuming a weapon goes in the right hand by default
|
|
157
|
-
case 'shield':
|
|
158
|
-
return 'leftHand';
|
|
159
|
-
case 'gloves':
|
|
160
|
-
return 'gloves';
|
|
125
|
+
case Category.Hat.toLowerCase(): return 'head';
|
|
126
|
+
case Category.Boots.toLowerCase(): return 'feet';
|
|
127
|
+
case Category.LegArmor.toLowerCase(): return 'legs';
|
|
128
|
+
case Category.ArmArmor.toLowerCase(): return 'arms';
|
|
129
|
+
case Category.BodyArmor.toLowerCase(): return 'torso';
|
|
130
|
+
case 'weapon': return 'rightHand';
|
|
131
|
+
case 'shield': return 'leftHand';
|
|
161
132
|
case 'helmet':
|
|
162
|
-
case 'hat':
|
|
163
|
-
|
|
164
|
-
case '
|
|
165
|
-
return 'feet';
|
|
133
|
+
case 'hat': return 'head';
|
|
134
|
+
case 'boots': return 'feet';
|
|
135
|
+
case 'gloves': return 'gloves';
|
|
166
136
|
case 'leg armor':
|
|
167
|
-
case 'legarmor':
|
|
168
|
-
return 'legs';
|
|
137
|
+
case 'legarmor': return 'legs';
|
|
169
138
|
case 'arm armor':
|
|
170
|
-
case 'armarmor':
|
|
171
|
-
return 'arms';
|
|
139
|
+
case 'armarmor': return 'arms';
|
|
172
140
|
case 'body armor':
|
|
173
141
|
case 'bodyarmor':
|
|
174
|
-
case 'torso':
|
|
175
|
-
|
|
176
|
-
default:
|
|
177
|
-
return null;
|
|
142
|
+
case 'torso': return 'torso';
|
|
143
|
+
default: return null;
|
|
178
144
|
}
|
|
179
145
|
}
|
|
180
146
|
canEquip(item) {
|
|
181
|
-
// Logic to determine if the item can be equipped
|
|
182
147
|
return Object.values(Category).includes(item.category);
|
|
183
148
|
}
|
|
184
|
-
// Helper method to unequip by slot
|
|
185
149
|
unequipBySlot(slot) {
|
|
186
150
|
const itemToUnequip = this.equipment[slot];
|
|
187
151
|
if (!itemToUnequip) {
|
|
188
152
|
return `You don't have anything equipped in the ${slot} slot.`;
|
|
189
153
|
}
|
|
190
|
-
|
|
191
|
-
this.addInventory(itemToUnequip); // Using the modified addInventory method
|
|
192
|
-
// Clear the slot in the equipment
|
|
154
|
+
this.addInventory(itemToUnequip);
|
|
193
155
|
this.equipment[slot] = null;
|
|
194
156
|
return `You unequipped ${itemToUnequip.name}.`;
|
|
195
157
|
}
|
|
196
158
|
hear(actor, message) {
|
|
197
|
-
if (actor !== this) {
|
|
159
|
+
if (actor !== this) {
|
|
198
160
|
this.logger.log(`${actor.name} says: "${message}"`);
|
|
199
161
|
}
|
|
200
162
|
}
|
|
201
163
|
enterRoom(room) {
|
|
202
164
|
this._currentLocation = room;
|
|
203
|
-
// Start listening to the room's speak events
|
|
204
165
|
room.on('speak', this.hear.bind(this));
|
|
205
166
|
this.logger.write(`${this.name} is now listening in room ${room.name}`);
|
|
206
167
|
}
|
|
207
168
|
leaveRoom() {
|
|
208
169
|
if (this._currentLocation) {
|
|
209
|
-
this._currentLocation.off('speak', this.hear.bind(this));
|
|
210
|
-
this.logger.write(`${this.name} is no longer
|
|
170
|
+
this._currentLocation.off('speak', this.hear.bind(this));
|
|
171
|
+
this.logger.write(`${this.name} is no longer listening in ${this._currentLocation.name}`);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
get lifestyleChoices() {
|
|
175
|
+
return this._lifestyleChoices;
|
|
176
|
+
}
|
|
177
|
+
set lifestyleChoices(choices) {
|
|
178
|
+
this._lifestyleChoices = choices;
|
|
179
|
+
}
|
|
180
|
+
get currency() {
|
|
181
|
+
const items = this._inventory.getAllItems();
|
|
182
|
+
return items.reduce((sum, item) => {
|
|
183
|
+
return item.isCurrencyCarrier() ? sum + (item.currencyAmount || 0) : sum;
|
|
184
|
+
}, 0);
|
|
185
|
+
}
|
|
186
|
+
set currency(amount) {
|
|
187
|
+
this._currency = Math.max(0, amount); // retained for legacy/debug seeding only
|
|
188
|
+
}
|
|
189
|
+
adjustCurrency(delta) {
|
|
190
|
+
const carriers = this._inventory.getAllItems().filter(i => i.isCurrencyCarrier());
|
|
191
|
+
let remaining = delta;
|
|
192
|
+
for (const carrier of carriers) {
|
|
193
|
+
if (remaining > 0) {
|
|
194
|
+
remaining -= carrier.addCurrency(remaining);
|
|
195
|
+
}
|
|
196
|
+
else if (remaining < 0) {
|
|
197
|
+
remaining += carrier.deductCurrency(-remaining);
|
|
198
|
+
}
|
|
199
|
+
if (remaining === 0)
|
|
200
|
+
break;
|
|
211
201
|
}
|
|
202
|
+
this._currency += remaining;
|
|
212
203
|
}
|
|
213
204
|
}
|
|
214
205
|
//# sourceMappingURL=player.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"player.js","sourceRoot":"","sources":["../../../../../../../src/commands/game/sideQuest/models/player.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACV,MAAM,aAAa,CAAC;AAIrB,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAEhD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGvD,MAAM,OAAO,MAAO,SAAQ,cAAc;IAC/B,WAAW,CAAS;IACnB,gBAAgB,CAAO;IACvB,UAAU,CAAY;IACtB,UAAU,CAAkB;IAC5B,kBAAkB,GAAG,EAAE,CAAC,
|
|
1
|
+
{"version":3,"file":"player.js","sourceRoot":"","sources":["../../../../../../../src/commands/game/sideQuest/models/player.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACV,MAAM,aAAa,CAAC;AAIrB,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAEhD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE3C,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAGvD,MAAM,OAAO,MAAO,SAAQ,cAAc;IAC/B,WAAW,CAAS;IACnB,gBAAgB,CAAO;IACvB,UAAU,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AAM,CAAC,CAAC,CAAC,yCAAyC;IACjF,CAAC;IAED,cAAc,CAAC,KAAa;QAC1B,MAAM,QAAQ,GAAG,IAAI,CAAC,UAAU,CAAC,WAAW,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,iBAAiB,EAAE,CAAC,CAAC;QAClF,IAAI,SAAS,GAAG,KAAK,CAAC;QAEtB,KAAK,MAAM,OAAO,IAAI,QAAQ,EAAE,CAAC;YAC/B,IAAI,SAAS,GAAG,CAAC,EAAE,CAAC;gBAClB,SAAS,IAAI,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;YAC9C,CAAC;iBAAM,IAAI,SAAS,GAAG,CAAC,EAAE,CAAC;gBACzB,SAAS,IAAI,OAAO,CAAC,cAAc,CAAC,CAAC,SAAS,CAAC,CAAC;YAClD,CAAC;YAED,IAAI,SAAS,KAAK,CAAC;gBAAE,MAAM;QAC7B,CAAC;QAED,IAAI,CAAC,SAAS,IAAI,SAAS,CAAC;IAC9B,CAAC;CACF"}
|
|
@@ -12,6 +12,7 @@ export declare class Puzzle extends AbstractPuzzle {
|
|
|
12
12
|
rewardItem?: Item;
|
|
13
13
|
successMessage: string;
|
|
14
14
|
failureMessage: string;
|
|
15
|
+
hobbyTags?: string[];
|
|
15
16
|
constructor(config: IPuzzleConstructorConfig);
|
|
16
17
|
hasRequiredItem(playerInventory: Inventory): boolean;
|
|
17
18
|
matchesRequiredPhrase(inputPhrase: string): boolean;
|
|
@@ -9,6 +9,7 @@ export class Puzzle extends AbstractPuzzle {
|
|
|
9
9
|
rewardItem;
|
|
10
10
|
successMessage;
|
|
11
11
|
failureMessage;
|
|
12
|
+
hobbyTags;
|
|
12
13
|
constructor(config) {
|
|
13
14
|
super();
|
|
14
15
|
this.requiredItem = config.requiredItem;
|
|
@@ -17,6 +18,7 @@ export class Puzzle extends AbstractPuzzle {
|
|
|
17
18
|
this.rewardItem = config.rewardItem;
|
|
18
19
|
this.successMessage = config.successMessage || 'You solved the puzzle!';
|
|
19
20
|
this.failureMessage = config.failureMessage || `You don't have the necessary item or the correct phrase to solve the puzzle.`;
|
|
21
|
+
this.hobbyTags = config.hobbyTags ?? [];
|
|
20
22
|
}
|
|
21
23
|
hasRequiredItem(playerInventory) {
|
|
22
24
|
if (this.requiredItem) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"puzzle.js","sourceRoot":"","sources":["../../../../../../../src/commands/game/sideQuest/models/puzzle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAKhD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,MAAM,OAAO,MAAO,SAAQ,cAAc;IAC9B,MAAM,GAAW,MAAM,CAAC,WAAW,EAAE,CAAC;IACtC,MAAM,GAAG,KAAK,CAAC;IAElB,YAAY,CAAU;IACtB,cAAc,CAAU;IACxB,MAAM,CAAU;IAChB,UAAU,CAAQ;IAClB,cAAc,CAAS;IACvB,cAAc,CAAS;
|
|
1
|
+
{"version":3,"file":"puzzle.js","sourceRoot":"","sources":["../../../../../../../src/commands/game/sideQuest/models/puzzle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAKhD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,MAAM,OAAO,MAAO,SAAQ,cAAc;IAC9B,MAAM,GAAW,MAAM,CAAC,WAAW,EAAE,CAAC;IACtC,MAAM,GAAG,KAAK,CAAC;IAElB,YAAY,CAAU;IACtB,cAAc,CAAU;IACxB,MAAM,CAAU;IAChB,UAAU,CAAQ;IAClB,cAAc,CAAS;IACvB,cAAc,CAAS;IACvB,SAAS,CAAY;IAE5B,YAAY,MAAgC;QAC1C,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;QACxC,IAAI,CAAC,cAAc,GAAG,MAA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AAO;gBACL,OAAO,EAAE,KAAK;gBACd,OAAO,EAAE,IAAI,CAAC,cAAc;aAC7B,CAAC;QACJ,CAAC;IACH,CAAC;CACF"}
|
|
@@ -14,6 +14,14 @@ export declare class Room extends AbstractRoom {
|
|
|
14
14
|
roomType: RoomType;
|
|
15
15
|
isStartRoom: boolean;
|
|
16
16
|
inventory: Inventory;
|
|
17
|
+
supportedLifestyles?: {
|
|
18
|
+
residenceTypes?: string[];
|
|
19
|
+
employmentRoles?: string[];
|
|
20
|
+
habitTags?: string[];
|
|
21
|
+
};
|
|
22
|
+
governsCurrency: boolean;
|
|
23
|
+
tags?: string[];
|
|
24
|
+
private _currencyLedger;
|
|
17
25
|
constructor(config: IRoomConfig);
|
|
18
26
|
say(actor: Player, message: string): void;
|
|
19
27
|
addExit(direction: Direction, targetRoom: Room, keyItemOrSolution?: string): void;
|
|
@@ -25,4 +33,13 @@ export declare class Room extends AbstractRoom {
|
|
|
25
33
|
setPuzzle(puzzle: Puzzle): void;
|
|
26
34
|
getOppositeDirection(direction: Direction): Direction;
|
|
27
35
|
findExistingDoor(targetRoom: Room): Door | undefined;
|
|
36
|
+
supportsResidence(type: string): boolean;
|
|
37
|
+
supportsEmployment(role: string): boolean;
|
|
38
|
+
supportsHabit(habit: string): boolean;
|
|
39
|
+
depositCurrencyCarrier(player: Player, item: Item): boolean;
|
|
40
|
+
getPlayerCurrency(player: Player): number;
|
|
41
|
+
withdrawCurrencyCarrier(player: Player, itemName: string): Item | null;
|
|
42
|
+
get currencyLedger(): ReadonlyMap<string, Item[]>;
|
|
43
|
+
storeItemFromActor(actor: Player, item: Item): boolean;
|
|
44
|
+
getItemsForActor(actor: Player): Item[];
|
|
28
45
|
}
|
|
@@ -10,30 +10,28 @@ export class Room extends AbstractRoom {
|
|
|
10
10
|
exits = new Map();
|
|
11
11
|
roomType;
|
|
12
12
|
isStartRoom;
|
|
13
|
-
inventory = new Inventory();
|
|
13
|
+
inventory = new Inventory();
|
|
14
|
+
supportedLifestyles;
|
|
15
|
+
governsCurrency = false;
|
|
16
|
+
tags;
|
|
17
|
+
_currencyLedger = new Map(); // playerName → currency carrier items
|
|
14
18
|
constructor(config) {
|
|
15
19
|
super();
|
|
16
20
|
this.name = config.name;
|
|
17
21
|
this.description = config.description;
|
|
18
22
|
this.roomType = config.roomType || RoomType.INSIDE;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
if (config.inventory) {
|
|
23
|
-
this.inventory = config.inventory;
|
|
24
|
-
}
|
|
25
|
-
if (config.puzzle) {
|
|
26
|
-
this.puzzle = config.puzzle;
|
|
27
|
-
}
|
|
23
|
+
this.exits = config.exits || new Map();
|
|
24
|
+
this.inventory = config.inventory || new Inventory();
|
|
25
|
+
this.puzzle = config.puzzle;
|
|
28
26
|
this.isStartRoom = config.isStartRoom || false;
|
|
27
|
+
this.supportedLifestyles = config.supportedLifestyles;
|
|
29
28
|
this.logger.write(`Room created: ${this.name}`);
|
|
29
|
+
this.tags = config.tags;
|
|
30
30
|
}
|
|
31
31
|
say(actor, message) {
|
|
32
|
-
// some logic for the actor saying the message
|
|
33
32
|
this.emit('speak', actor, message);
|
|
34
33
|
}
|
|
35
34
|
addExit(direction, targetRoom, keyItemOrSolution) {
|
|
36
|
-
// Check if a door already exists between these two rooms
|
|
37
35
|
let door = this.findExistingDoor(targetRoom);
|
|
38
36
|
if (!door) {
|
|
39
37
|
door = new Door({
|
|
@@ -51,12 +49,7 @@ export class Room extends AbstractRoom {
|
|
|
51
49
|
if (exit instanceof Door) {
|
|
52
50
|
const result = exit.attemptUnlock(itemOrSolution);
|
|
53
51
|
this.logger.write(`Attempted to unlock exit in direction ${direction}. Success: ${result}`);
|
|
54
|
-
|
|
55
|
-
return `The ${exit.name} unlocked!`;
|
|
56
|
-
}
|
|
57
|
-
else {
|
|
58
|
-
return `The ${exit.name} remains locked.`;
|
|
59
|
-
}
|
|
52
|
+
return result ? `The ${exit.name} unlocked!` : `The ${exit.name} remains locked.`;
|
|
60
53
|
}
|
|
61
54
|
this.logger.write(`No locked exit found in direction ${direction}`);
|
|
62
55
|
return `There's no locked exit in that direction.`;
|
|
@@ -72,12 +65,12 @@ export class Room extends AbstractRoom {
|
|
|
72
65
|
return isLocked;
|
|
73
66
|
}
|
|
74
67
|
addItem(item) {
|
|
75
|
-
this.inventory.addItem(item);
|
|
68
|
+
this.inventory.addItem(item);
|
|
76
69
|
this.logger.write(`Item added to room ${this.name}: ${item.name}`);
|
|
77
70
|
}
|
|
78
71
|
removeItem(item) {
|
|
79
|
-
if (this.inventory.hasItem(item.name)) {
|
|
80
|
-
this.inventory.removeItem(item.name);
|
|
72
|
+
if (this.inventory.hasItem(item.name)) {
|
|
73
|
+
this.inventory.removeItem(item.name);
|
|
81
74
|
this.logger.write(`Item removed from room ${this.name}: ${item.name}`);
|
|
82
75
|
}
|
|
83
76
|
else {
|
|
@@ -109,5 +102,67 @@ export class Room extends AbstractRoom {
|
|
|
109
102
|
}
|
|
110
103
|
return undefined;
|
|
111
104
|
}
|
|
105
|
+
supportsResidence(type) {
|
|
106
|
+
return this.supportedLifestyles?.residenceTypes?.includes(type) ?? false;
|
|
107
|
+
}
|
|
108
|
+
supportsEmployment(role) {
|
|
109
|
+
return this.supportedLifestyles?.employmentRoles?.includes(role) ?? false;
|
|
110
|
+
}
|
|
111
|
+
supportsHabit(habit) {
|
|
112
|
+
return this.supportedLifestyles?.habitTags?.includes(habit) ?? false;
|
|
113
|
+
}
|
|
114
|
+
depositCurrencyCarrier(player, item) {
|
|
115
|
+
if (!this.governsCurrency || !item.isCurrencyCarrier())
|
|
116
|
+
return false;
|
|
117
|
+
if (!this._currencyLedger.has(player.name)) {
|
|
118
|
+
this._currencyLedger.set(player.name, []);
|
|
119
|
+
}
|
|
120
|
+
this._currencyLedger.get(player.name).push(item);
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
getPlayerCurrency(player) {
|
|
124
|
+
const items = this._currencyLedger.get(player.name);
|
|
125
|
+
if (!items)
|
|
126
|
+
return 0;
|
|
127
|
+
return items.reduce((sum, item) => sum + item.currencyAmount, 0);
|
|
128
|
+
}
|
|
129
|
+
withdrawCurrencyCarrier(player, itemName) {
|
|
130
|
+
const items = this._currencyLedger.get(player.name);
|
|
131
|
+
if (!items)
|
|
132
|
+
return null;
|
|
133
|
+
const index = items.findIndex(i => i.name === itemName);
|
|
134
|
+
if (index === -1)
|
|
135
|
+
return null;
|
|
136
|
+
const [removed] = items.splice(index, 1);
|
|
137
|
+
return removed;
|
|
138
|
+
}
|
|
139
|
+
get currencyLedger() {
|
|
140
|
+
return this._currencyLedger;
|
|
141
|
+
}
|
|
142
|
+
storeItemFromActor(actor, item) {
|
|
143
|
+
if (this.governsCurrency && item.isCurrencyCarrier()) {
|
|
144
|
+
if (this.depositCurrencyCarrier(actor, item)) {
|
|
145
|
+
this.logger.write(`Stored currency carrier from ${actor.name} in ${this.name}`);
|
|
146
|
+
return true;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
const rawResidence = actor.lifestyleChoices?.find(l => l.type === 'residence')?.metadata;
|
|
150
|
+
const residenceLifestyle = typeof rawResidence === 'object' && rawResidence !== null && 'lifestyle' in rawResidence
|
|
151
|
+
? rawResidence
|
|
152
|
+
: undefined;
|
|
153
|
+
const actorResidence = residenceLifestyle?.lifestyle;
|
|
154
|
+
if (actorResidence && this.supportsResidence(actorResidence)) {
|
|
155
|
+
this.inventory.addSecureItem?.(actor.name, item); // assumes secure storage per actor
|
|
156
|
+
this.logger.write(`Item securely stored for ${actor.name} in their residence: ${this.name}`);
|
|
157
|
+
return true;
|
|
158
|
+
}
|
|
159
|
+
this.logger.write(`${item} cannot be sstored by ${actor.name} in room ${this.name}`);
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
getItemsForActor(actor) {
|
|
163
|
+
const visibleItems = this.inventory.getAllItems();
|
|
164
|
+
const secureItems = this.inventory.getSecureItemsFor(actor.name);
|
|
165
|
+
return [...visibleItems, ...secureItems];
|
|
166
|
+
}
|
|
112
167
|
}
|
|
113
168
|
//# sourceMappingURL=room.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"room.js","sourceRoot":"","sources":["../../../../../../../src/commands/game/sideQuest/models/room.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAIxD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"room.js","sourceRoot":"","sources":["../../../../../../../src/commands/game/sideQuest/models/room.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAIxD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3C,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAErD,MAAM,OAAO,IAAK,SAAQ,YAAY;IAC5B,MAAM,GAAW,MAAM,CAAC,WAAW,EAAE,CAAC;IACvC,IAAI,CAAS;IACb,WAAW,CAAS;IACpB,KAAK,GAAkC,IAAI,GAAG,EAAE,CAAC;IACjD,QAAQ,CAAW;IACnB,WAAW,CAAU;IACrB,SAAS,GAAc,IAAI,SAAS,EAAE,CAAC;IACvC,mBAAmB,CAIxB;IACK,eAAe,GAAY,KAAK,CAAC;IACjC,IAAI,CAAY;IACf,eAAe,GAAwB,IAAI,GAAG,EAAE,CAAC,CAAC,sCAAsC;IAEhG,YAAY,MAAmB;QAC7B,KAAK,EAAE,CAAC;QACR,IAAI,CAAC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import { NPC } from './npc.js';
|
|
6
6
|
import { Logger } from '../utilities/logger.js';
|
|
7
7
|
import { ISceneConstructorConfig, IRooms } from '../types/interfaces.js';
|
|
8
|
-
import { Direction } from '../types/enums.js';
|
|
8
|
+
import { Direction, Size } from '../types/enums.js';
|
|
9
9
|
import { AbstractScene } from '../types/abstracts.js';
|
|
10
10
|
export declare class Scene extends AbstractScene {
|
|
11
11
|
protected rooms: IRooms;
|
|
@@ -14,6 +14,12 @@ export declare class Scene extends AbstractScene {
|
|
|
14
14
|
protected actors: Map<string, (Player | NPC)>;
|
|
15
15
|
protected characterLocations: Map<string, Room>;
|
|
16
16
|
private roomFactory;
|
|
17
|
+
private _residenceTiers;
|
|
18
|
+
currency: {
|
|
19
|
+
type: string;
|
|
20
|
+
carrierItemSizes: Size[];
|
|
21
|
+
authorityRoomTags: string[];
|
|
22
|
+
};
|
|
17
23
|
constructor(config: ISceneConstructorConfig);
|
|
18
24
|
initialize(): void;
|
|
19
25
|
private generateRoomsFromConfig;
|
|
@@ -22,6 +28,7 @@ export declare class Scene extends AbstractScene {
|
|
|
22
28
|
removeActor(name: string): void;
|
|
23
29
|
getActor(name: string): Player | NPC | undefined;
|
|
24
30
|
get allActors(): (Player | NPC)[];
|
|
31
|
+
getActorsInRoom(room: Room): (Player | NPC)[];
|
|
25
32
|
addRoom(room: Room): void;
|
|
26
33
|
removeRoom(roomName: string): boolean;
|
|
27
34
|
addItemToRoom(item: Item, roomName: string): void;
|
|
@@ -32,4 +39,17 @@ export declare class Scene extends AbstractScene {
|
|
|
32
39
|
getPlayer(): Player;
|
|
33
40
|
getRooms(): IRooms;
|
|
34
41
|
connectRooms(roomNameA: string, direction: Direction, roomNameB: string, keyItemOrSolution?: string): void;
|
|
42
|
+
private hasRoomSupportingResidence;
|
|
43
|
+
private hasRoomSupportingEmployment;
|
|
44
|
+
private hasRoomSupportingHabit;
|
|
45
|
+
private hasItemSupportingAddiction;
|
|
46
|
+
private hasItemSupportingHabit;
|
|
47
|
+
private hasPuzzleSupportingHobby;
|
|
48
|
+
validateLifestyleSupport(): void;
|
|
49
|
+
getCurrencyType(): string;
|
|
50
|
+
isValidCurrencyCarrier(item: Item): boolean;
|
|
51
|
+
getCurrencyAggregationByTag(): Record<string, Record<string, number>>;
|
|
52
|
+
get residenceTiers(): string[];
|
|
53
|
+
set residenceTiers(tiers: string[]);
|
|
54
|
+
isValidResidenceTier(tier: string): boolean;
|
|
35
55
|
}
|