Skip to content

Commit

Permalink
Add kitchen_fridge and mage interaction to map_campus_house_1 (#140)
Browse files Browse the repository at this point in the history
Part of #130
  • Loading branch information
r4pt0s authored Oct 12, 2024
2 parents ddd169c + 2026e9b commit f58766b
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 9 deletions.
2 changes: 2 additions & 0 deletions src/interactions/map_campus_house_1/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { bedInteractions } from './bed.interaction';
import { computerInteractions } from './computer.interaction';
import { mageInteractions } from './mage.interaction';
import { bedroomVanityInteractions } from './bedroomVanity.interaction';
import { kitchenFridgeInteractions } from './kitchenFridge.interaction';

const interactions = [
// Add more interactions here
Expand All @@ -11,6 +12,7 @@ const interactions = [
computerInteractions,
mageInteractions,
bedroomVanityInteractions,
kitchenFridgeInteractions,
];

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

const butterBeerDialog = [
"You see a fresh mug of butterbeer in the fridge and take it. You're not thirsty at the moment, but perhaps someone else in the house might enjoy it.",
];

const emptyFridge = ['The refrigerator is now empty.'];

export const kitchenFridgeInteractions = (player, k, map) => {
player.onCollide('kitchen_fridge', async () => {
player.isInDialog = true;

if (player?.state?.hasButterBeer) {
await displayDialogue({
k,
player,
text: emptyFridge,
onDisplayEnd: () => {
player.isInDialog = false;
},
});
return;
}

displayDialogue({
k,
player,
text: butterBeerDialog,
onDisplayEnd: () => {
player.state.hasButterBeer = true;
player.isInDialog = false;
},
});
});
};
68 changes: 59 additions & 9 deletions src/interactions/map_campus_house_1/mage.interaction.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { displayDialogue, displayPermissionBox } from '../../utils';
import { updateEnergyState } from '../../utils/energyUpdate';

const alredyUnlockText = ['The challenge is waiting for you!'];

Expand All @@ -23,6 +24,16 @@ const noSpell = [
'It does not seem like thou art yet prepared for the challenge...',
];

const butterBeerDialog = {
ask: [
"Hey, is that a butterbeer you're carrying? That's my favorite drink! If you're not going to drink it, may I have it?",
],
thank: [
'Thank you so much! "Since this dev has been so great, his energy is now top rate!"',
],
denied: ['Oh, ok. I understand...'],
};

export const mageInteractions = async (player, k, map) => {
const [computer] = map.query({ include: 'computer' });
let mageInteractionCounter = 0;
Expand Down Expand Up @@ -89,17 +100,56 @@ export const mageInteractions = async (player, k, map) => {
}
}
} else {
player.isInDialog = true;
computer.play('on');

await displayDialogue({
k,
player,
text: alredyUnlockText,
onDisplayEnd: () => {
player.isInDialog = false;
},
});
if (player?.state?.hasButterBeer) {
// Mage asks if he can have the butterbeer
let giveButterBeer = await displayPermissionBox({
k,
player,
text: butterBeerDialog.ask,
characterName: 'Mage',
onDisplayEnd: () => {
player.isInDialog = false;
},
});

if (giveButterBeer) {
player.isInDialog = true;
await displayDialogue({
k,
player,
text: butterBeerDialog.thank,
characterName: 'Mage',
onDisplayEnd: () => {
player.isInDialog = false;
player.state.hasButterBeer = false;
updateEnergyState(player.state, 99);
},
});
} else {
player.isInDialog = true;
await displayDialogue({
k,
player,
text: butterBeerDialog.denied,
characterName: 'Mage',
onDisplayEnd: () => {
player.isInDialog = false;
},
});
}
} else {
player.isInDialog = true;
await displayDialogue({
k,
player,
text: alredyUnlockText,
onDisplayEnd: () => {
player.isInDialog = false;
},
});
}
}
});

Expand Down

0 comments on commit f58766b

Please sign in to comment.