forked from zero-to-mastery/ZTM-Quest
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackpack.interaction.js
More file actions
33 lines (28 loc) · 943 Bytes
/
backpack.interaction.js
File metadata and controls
33 lines (28 loc) · 943 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { Backpack } from '../../backpack';
import { displayPermissionBox, displayDialogue } from '../../utils';
export const backpackInteractions = (player, k, map) => {
player.onCollide('backpack', async (backpack) => {
const wantBackpack = await displayPermissionBox({
k,
player,
text: [
'Got a lot to carry? No problem—grab a backpack and load up.',
],
});
const dialog = [];
if (wantBackpack) {
k.destroy(backpack);
// show backpack on side right panel
Backpack.initState();
Backpack.init();
dialog.push('Aye, a trusty pack for a worthy traveler.');
} else {
dialog.push('Oh, going minimalist this time? Bold choice.');
}
displayDialogue({
k,
player,
text: [dialog.join(' ')],
});
});
};