Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add kitchen_fridge and mage interaction to map_campus_house_1 #140

Merged
merged 2 commits into from
Oct 12, 2024
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_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