Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/interactions/map_city/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { enterMapExtendedCampusTop } from './enterMapExtendCampusTop.interaction
import { interactionWithBin } from './bin.interaction';
import { jessicaInteraction } from './jessica.interation';
import { interactionWithSoccerBall } from './soccerBall.interaction';
import { interactionWithMailbox } from './mailbox.interaction';

const interactions = [
enterMapArcadeInteraction,
Expand All @@ -40,6 +41,7 @@ const interactions = [
interactionWithBin,
jessicaInteraction,
interactionWithSoccerBall,
interactionWithMailbox,
];

export default interactions;
28 changes: 28 additions & 0 deletions src/interactions/map_city/mailbox.interaction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { displayDialogue } from '../../utils';

const getRandomMessage = (min, max) => {
return Math.floor(Math.random() * (max - min + 1)) + min;
};

const messages = [
['The mailbox is empty... Maybe check back later?'],
['You found a flyer for a coding bootcamp!'],
['Looks like someone forgot to pick up their mail.'],
['A postcard from a fellow developer: "Debugging in paradise!"'],
['Just some junk mail and pizza coupons.'],
['There\'s a letter addressed to "Future Tech Lead" - maybe that\'s you!'],
['Empty! The mail carrier must have already been here.'],
['You see an envelope with "URGENT: Your code is deploying!" on it.'],
];

export const interactionWithMailbox = (player, k, map) => {
player.onCollide('mailbox', () => {
const randomMessage = getRandomMessage(0, messages.length - 1);

displayDialogue({
k,
player,
text: messages[randomMessage],
});
});
};
81 changes: 81 additions & 0 deletions src/interactions/map_start/dining_table.interaction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
import { time } from '../../kplayCtx';
import { displayDialogue, showCustomPrompt } from '../../utils';
import { purchaseItem } from '../../utils/coinsUpdate';

let abort;

export const interactionWithDiningTable = (player, k, map) => {
const handleTableInteraction = () => {
time.paused = true;
player.state.isInDialog = true;
abort = new AbortController();

showCustomPrompt(
'Welcome to the Dining Table! What would you like to eat?',
[
'Pizza Slice (15 coins)',
'Sandwich (12 coins)',
'Salad (10 coins)',
'Pasta (18 coins)',
'Nothing, thanks',
],
(selectedOption) => {
const foodData = {
'Pizza Slice (15 coins)': {
text: [
'Mmm! Delicious pizza slice! The cheese is perfectly melted.',
],
cost: 15,
energy: 35,
},
'Sandwich (12 coins)': {
text: [
'A fresh sandwich with crispy lettuce and juicy tomatoes. Yum!',
],
cost: 12,
energy: 28,
},
'Salad (10 coins)': {
text: [
'A healthy salad! You feel refreshed and energized.',
],
cost: 10,
energy: 22,
},
'Pasta (18 coins)': {
text: [
'Delicious pasta with rich tomato sauce! That hit the spot!',
],
cost: 18,
energy: 40,
},
'Nothing, thanks': {
text: ['Maybe next time when you\'re hungry!'],
cost: 0,
energy: 0,
},
};

const selectedFood = foodData[selectedOption];

displayDialogue({
k,
player,
text: selectedFood.text,
onDisplayEnd: () => {
if (selectedFood.cost > 0) {
purchaseItem(k, selectedFood.cost, selectedFood.energy);
}
},
});
},
player,
k,
abort
);
};

player.onCollide('table_mainArea', handleTableInteraction);
player.onCollide('table_room_1', handleTableInteraction);
player.onCollide('table_lobby', handleTableInteraction);
};
2 changes: 2 additions & 0 deletions src/interactions/map_start/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { interactionWithLibrary } from './library.interaction';
import { interactionWithPuff } from './puff.interaction';
import { interactionWithDog } from './dog.interaction';
import { interactionWithFruitBowl } from './fruit_bowl.interactions';
import { interactionWithDiningTable } from './dining_table.interaction';

const interactions = [
restroomInteractions,
Expand All @@ -38,6 +39,7 @@ const interactions = [
interactionWithPuff,
interactionWithDog,
interactionWithFruitBowl,
interactionWithDiningTable,
];

export default interactions;