Skip to content

Commit 02540f9

Browse files
committed
Merge branch 'main' of github.com:zero-to-mastery/ZTM-Quest into contrib2
2 parents aeea049 + 166e428 commit 02540f9

9 files changed

Lines changed: 100 additions & 66 deletions

File tree

public/maps/map_city.json

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2762,7 +2762,7 @@
27622762
"y":591.594703333333
27632763
},
27642764
{
2765-
"height":6.47251215874179,
2765+
"height":9.14406044557266,
27662766
"id":400,
27672767
"name":"campus_house_door_1",
27682768
"rotation":0,
@@ -2819,7 +2819,7 @@
28192819
{
28202820
"height":21.1875,
28212821
"id":405,
2822-
"name":"snack_bar_green",
2822+
"name":"snack_bar_green_1",
28232823
"rotation":0,
28242824
"type":"",
28252825
"visible":true,
@@ -2841,7 +2841,7 @@
28412841
{
28422842
"height":25,
28432843
"id":407,
2844-
"name":"snack_bar_green",
2844+
"name":"snack_bar_green_2",
28452845
"rotation":0,
28462846
"type":"",
28472847
"visible":true,
@@ -3477,28 +3477,6 @@
34773477
"x":923,
34783478
"y":295.466
34793479
},
3480-
{
3481-
"height":24.1818,
3482-
"id":434,
3483-
"name":"boundary_park_bench",
3484-
"rotation":0,
3485-
"type":"",
3486-
"visible":true,
3487-
"width":3.81818,
3488-
"x":594.432,
3489-
"y":215.534
3490-
},
3491-
{
3492-
"height":23.6364,
3493-
"id":435,
3494-
"name":"boundary_park_bench",
3495-
"rotation":0,
3496-
"type":"",
3497-
"visible":true,
3498-
"width":3.27273,
3499-
"x":634.614,
3500-
"y":215.898
3501-
},
35023480
{
35033481
"height":14.25,
35043482
"id":436,

src/gameObjects/map_city/npcsOnmap_city.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,17 @@ export const npcsInCityMap = (k, map, spawnpoints) => {
3939
// Define patterns and their corresponding adjustments
4040
const npcPatterns = [
4141
{
42-
patterns: [/stall_/],
42+
patterns: [/stall_1/],
4343
adjustments: { xAdjust: 12, yAdjust: 18 },
4444
direction: 'idle-down',
4545
},
4646
{
47-
patterns: [/snack_bar_/],
47+
patterns: [/stall_2/],
48+
adjustments: { xAdjust: 12, yAdjust: 18 },
49+
direction: 'idle-down',
50+
},
51+
{
52+
patterns: [/snack_bar_green_1/],
4853
adjustments: { xAdjust: 12, yAdjust: 18 },
4954
direction: 'idle-down',
5055
},

src/interactions/map_city/boundaryBurgerBar.interaction.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@ export const boundaryBurgerBarInteraction = (player, k) => {
88
k,
99
player,
1010
text: ['Hello! Would you like a burger?'],
11+
purchaseCost: 25,
1112
});
1213

1314
if (wantBurger) {
14-
k.debug.log('Enjoy your burger!'); //testing purposes you may uncomment it or add displayPermission box your wish
1515
const purchaseStatus = purchaseItem(k, 25, 40);
1616
if (purchaseStatus === 'purchased') {
17+
k.debug.log('Enjoy your burger!'); //testing purposes you may uncomment it or add displayPermission box your wish
1718
updateAchievements('Food enthusiast', 'Burger Store');
1819
}
1920
} else {

src/interactions/map_city/index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { enterMapExtendedCampus } from './enterMapExtendedCampus.interactions';
1717
import { enterMapExtendedCampusTop } from './enterMapExtendCampusTop.interactions';
1818
import { interactionWithBin } from './bin.interaction';
1919
import { jessicaInteraction } from './jessica.interation';
20+
import { interactionWithSoccerBall } from './soccerBall.interaction';
2021

2122
const interactions = [
2223
enterMapArcadeInteraction,
@@ -37,7 +38,8 @@ const interactions = [
3738
// Add more interactions here
3839
enterMapCampusHouse1Interaction,
3940
interactionWithBin,
40-
jessicaInteraction
41+
jessicaInteraction,
42+
interactionWithSoccerBall,
4143
];
4244

4345
export default interactions;

src/interactions/map_city/snackBars.interactions.js

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,22 @@ import { purchaseItem } from '../../utils/coinsUpdate';
44
import { interactionHandler } from '../handler.interactions';
55

66
export const snackBarGreenInteraction = (player, k) => {
7-
interactionHandler(player, 'snack_bar_green', k, async () => {
7+
interactionHandler(player, 'snack_bar_green_1', k, async () => {
88
let ztmSnackDecision = await displayPermissionBox({
99
k,
1010
player,
1111
text: [
1212
'Welcome to Snack Bar Green! Ready to go from zero to snack mastery?',
1313
],
14+
purchaseCost: 15,
1415
});
1516

1617
if (ztmSnackDecision) {
17-
k.debug.log(
18-
'Congratulations! You’ve mastered the art of snacking, ZTM style!'
19-
);
2018
const purchaseStatus = purchaseItem(k, 15, 25);
2119
if (purchaseStatus === 'purchased') {
20+
k.debug.log(
21+
'Congratulations! You’ve mastered the art of snacking, ZTM style!'
22+
);
2223
updateAchievements('Food enthusiast', 'Snack Bar Green');
2324
}
2425
} else {
@@ -28,14 +29,15 @@ export const snackBarGreenInteraction = (player, k) => {
2829
text: [
2930
'Are you sure? The path to snack mastery is only one bite away...',
3031
],
32+
purchaseCost: 15,
3133
});
3234

3335
if (secondSnackChance) {
34-
k.debug.log(
35-
'Great choice! You’re on your way to becoming a Snack Sensei!'
36-
);
3736
const purchaseStatus = purchaseItem(k, 15, 25);
3837
if (purchaseStatus === 'purchased') {
38+
k.debug.log(
39+
'Great choice! You’re on your way to becoming a Snack Sensei!'
40+
);
3941
updateAchievements('Food enthusiast', 'Snack Bar Green');
4042
}
4143
} else {
@@ -55,14 +57,15 @@ export const snackBarRedInteraction = (player, k) => {
5557
text: [
5658
'Welcome to Snack Bar Red! The *real* masters of snacking... Unlike *ahem* some green wannabes across the street. Ready for the best snack experience?',
5759
],
60+
purchaseCost: 15,
5861
});
5962

6063
if (snackOffer) {
61-
k.debug.log(
62-
'Excellent choice! You clearly have superior taste. Snack Bar Green can’t compete!'
63-
);
6464
const purchaseStatus = purchaseItem(k, 15, 24);
6565
if (purchaseStatus === 'purchased') {
66+
k.debug.log(
67+
'Excellent choice! You clearly have superior taste. Snack Bar Green can’t compete!'
68+
);
6669
updateAchievements('Food enthusiast', 'Snack Bar Red');
6770
}
6871
} else {
@@ -72,14 +75,15 @@ export const snackBarRedInteraction = (player, k) => {
7275
text: [
7376
'Are you sure? Don’t tell me you’re thinking of going to *that* green place... Their snacks are... well, let’s just say "unimpressive."',
7477
],
78+
purchaseCost: 15,
7579
});
7680

7781
if (changeMind) {
78-
k.debug.log(
79-
'Wise move! Snack Bar Red – where the real snack mastery happens!'
80-
);
8182
const purchaseStatus = purchaseItem(k, 15, 24);
8283
if (purchaseStatus === 'purchased') {
84+
k.debug.log(
85+
'Wise move! Snack Bar Red – where the real snack mastery happens!'
86+
);
8387
updateAchievements('Food enthusiast', 'Snack Bar Red');
8488
}
8589
} else {
@@ -99,14 +103,15 @@ export const snackBarStreetInteraction = (player, k) => {
99103
text: [
100104
'Psst! You look hungry! How about a snack? It’s a secret recipe!',
101105
],
106+
purchaseCost: 15,
102107
});
103108

104109
if (snackDecision) {
105-
k.debug.log(
106-
'Yum! You just ate the best mystery snack of your life!'
107-
);
108110
const purchaseStatus = purchaseItem(k, 15, 24);
109111
if (purchaseStatus === 'purchased') {
112+
k.debug.log(
113+
'Yum! You just ate the best mystery snack of your life!'
114+
);
110115
updateAchievements('Food enthusiast', 'Snack Bar Street');
111116
}
112117
} else {
@@ -116,14 +121,15 @@ export const snackBarStreetInteraction = (player, k) => {
116121
text: [
117122
'Are you sure? It’s low calorie and totally NOT haunted! Still no?',
118123
],
124+
purchaseCost: 15,
119125
});
120126

121127
if (secondChance) {
122-
k.debug.log(
123-
'Ah, there we go! Enjoy your... totally normal snack.'
124-
);
125128
const purchaseStatus = purchaseItem(k, 15, 24);
126129
if (purchaseStatus === 'purchased') {
130+
k.debug.log(
131+
'Ah, there we go! Enjoy your... totally normal snack.'
132+
);
127133
updateAchievements('Food enthusiast', 'Snack Bar Street');
128134
}
129135
} else {
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { displayDialogue } from '../../utils';
2+
3+
const getRandomMessage = (min, max) => {
4+
return Math.floor(Math.random() * (max - min + 1)) + min;
5+
};
6+
7+
const messages = [
8+
["Hey! Watch where you're kicking!"],
9+
['Goal vibes only!'],
10+
['You think you can bend it like Beckham?'],
11+
['Ouch! That tickled!'],
12+
['Keep me rolling, champ!'],
13+
["I'm ready for the World Cup!"],
14+
['Nice touch! Want to try a trick shot?'],
15+
['You’ve got good footwork!'],
16+
["Don't leave me sitting here, let's play! 🏃‍♂️💨"],
17+
];
18+
19+
export const interactionWithSoccerBall = (player, k, map) => {
20+
player.onCollide('soccerBall', () => {
21+
const randomMessage = getRandomMessage(0, messages.length - 1);
22+
23+
displayDialogue({
24+
k,
25+
player,
26+
text: messages[randomMessage],
27+
});
28+
});
29+
};

src/interactions/map_city/stalls.interaction.js

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@ export const stall1Interaction = (player, k) => {
1111
text: [
1212
'🎉 Welcome to Stall 1! Our secret ingredient is... a sprinkle of **joy**! Ready to snack like a champ?',
1313
],
14+
purchaseCost: 20,
1415
});
1516

1617
if (stall1Offer) {
17-
k.debug.log(
18-
'🚀 Awesome choice! Here’s your snack – made with love and just a hint of magic!'
19-
);
2018
const purchaseStatus = purchaseItem(k, 20, 30);
2119
if (purchaseStatus === 'purchased') {
20+
k.debug.log(
21+
'🚀 Awesome choice! Here’s your snack – made with love and just a hint of magic!'
22+
);
2223
updateAchievements('Food enthusiast', 'Snack Stall 1');
2324
}
2425
} else {
@@ -28,14 +29,15 @@ export const stall1Interaction = (player, k) => {
2829
text: [
2930
'🤔 Are you absolutely sure? Our snacks are scientifically proven to elevate your happiness levels! Or do you prefer sadness-flavored snacks?',
3031
],
32+
purchaseCost: 20,
3133
});
3234

3335
if (secondChance) {
34-
k.debug.log(
35-
'😋 Yass! You’re now part of the snack elite! Enjoy your crispy delight!'
36-
);
3736
const purchaseStatus = purchaseItem(k, 20, 30);
3837
if (purchaseStatus === 'purchased') {
38+
k.debug.log(
39+
'😋 Yass! You’re now part of the snack elite! Enjoy your crispy delight!'
40+
);
3941
updateAchievements('Food enthusiast', 'Snack Stall 1');
4042
}
4143
} else {
@@ -55,14 +57,15 @@ export const stall2Interaction = (player, k) => {
5557
text: [
5658
'🎊 Ahoy! Welcome to Stall 2! We don’t just sell snacks; we sell **memories**! Care to join the flavor revolution?',
5759
],
60+
purchaseCost: 20,
5861
});
5962

6063
if (stall2Offer) {
61-
k.debug.log(
62-
'🌈 Fantastic! Here’s a snack that might just change your life! Or at least your lunch!'
63-
);
6464
const purchaseStatus = purchaseItem(k, 20, 28);
6565
if (purchaseStatus === 'purchased') {
66+
k.debug.log(
67+
'🌈 Fantastic! Here’s a snack that might just change your life! Or at least your lunch!'
68+
);
6669
updateAchievements('Food enthusiast', 'Snack Stall 2');
6770
}
6871
} else {
@@ -72,14 +75,15 @@ export const stall2Interaction = (player, k) => {
7275
text: [
7376
'🚫 Wait a minute! Are you really about to miss the chance to munch on greatness? Don’t you want to be a snack legend?',
7477
],
78+
purchaseCost: 20,
7579
});
7680

7781
if (secondThoughts) {
78-
k.debug.log(
79-
'🌟 You’ve made the right call! Enjoy the epic flavors of Stall 2! Snack on, my friend!'
80-
);
8182
const purchaseStatus = purchaseItem(k, 20, 28);
8283
if (purchaseStatus === 'purchased') {
84+
k.debug.log(
85+
'🌟 You’ve made the right call! Enjoy the epic flavors of Stall 2! Snack on, my friend!'
86+
);
8387
updateAchievements('Food enthusiast', 'Snack Stall 2');
8488
}
8589
} else {

src/interactions/map_start/drink_machine.interaction.js

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,26 @@ export const interactionWithDrinksMachine = (player, k, map) => {
99
// Trigger the custom prompt when the player collides with the drinks machine
1010
showCustomPrompt(
1111
'What would you like to drink?', // Prompt message
12-
['Coke', 'Soda', 'Water', 'Sprite'], // Options
12+
[
13+
'Coke (8 coins)',
14+
'Soda (8 coins)',
15+
'Water (5 coins)',
16+
'Sprite (8 coins)',
17+
], // Options
1318
(selectedOption) => {
1419
// Callback when an option is selected
1520
// Logic based on the selected option
1621
const texts = {
17-
Coke: [
22+
'Coke (8 coins)': [
1823
'Coke - "Taste the Feeling!" A cold refreshment is coming your way!',
1924
],
20-
Soda: [
25+
'Soda (8 coins)': [
2126
'Soda - "Fizz up your life!" Time for some sparkling fun!',
2227
],
23-
Water: [
28+
'Water (5 coins)': [
2429
'Water - "Pure as the mountain stream." Stay hydrated and fresh!',
2530
],
26-
Sprite: [
31+
'Sprite (8 coins)': [
2732
'Sprite - "Obey Your Thirst!" Crisp and refreshing as ever!',
2833
],
2934
};

src/utils.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ export async function displayPermissionBox({
122122
player,
123123
text,
124124
onDisplayEnd = () => {},
125+
purchaseCost,
125126
}) {
126127
time.paused = true;
127128
player.state.isInDialog = true;
@@ -132,7 +133,10 @@ export async function displayPermissionBox({
132133
const statsUI = document.getElementById('stats-container');
133134
const miniMapUI = document.getElementById('minimap');
134135
closeBtn.innerHTML = 'No';
135-
nextBtn.innerHTML = 'Yes';
136+
nextBtn.innerHTML =
137+
purchaseCost !== undefined
138+
? `Yes (${purchaseCost} coin${purchaseCost !== 1 ? 's' : ''})`
139+
: 'Yes';
136140
statsUI.style.display = 'none';
137141
miniMapUI.style.display = 'none';
138142
dialogUI.style.display = 'block';

0 commit comments

Comments
 (0)