forked from zero-to-mastery/ZTM-Quest
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtrashBinLobby.interactions.js
More file actions
37 lines (32 loc) · 1010 Bytes
/
Copy pathtrashBinLobby.interactions.js
File metadata and controls
37 lines (32 loc) · 1010 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
34
35
36
37
import { displayDialogue } from '../../utils';
import { addCoins } from '../../utils/coinsUpdate';
// random index of trash items
const getRndTrash = (min, max) => {
return Math.floor(Math.random() * (max - min + 1)) + min;
};
// trash items
const trash = [
['Nothing special here... Just wasted items.'],
['A stinky socket...'],
['You found a rare Pokémon card here!'],
['You found a coin! You have one more now!'],
['Empty buttle.'],
['Crumpled paper...'],
];
// player can find funny item in trash bin
// if hit a coin, he can collect one!
export const interactionWithTrashBin = (player, k, map) => {
player.onCollide('trash_bin_lobby', () => {
const randomTrash = getRndTrash(0, trash.length - 1);
displayDialogue({
k,
player,
text: trash[randomTrash],
});
if (
trash[randomTrash][0] == 'You found a coin! You have one more now!'
) {
addCoins(1);
}
});
};