diff --git a/src/interactions/map_campus_house_1/index.js b/src/interactions/map_campus_house_1/index.js index 5468fb2f..109ef79a 100644 --- a/src/interactions/map_campus_house_1/index.js +++ b/src/interactions/map_campus_house_1/index.js @@ -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 @@ -11,6 +12,7 @@ const interactions = [ computerInteractions, mageInteractions, bedroomVanityInteractions, + kitchenFridgeInteractions, ]; export default interactions; diff --git a/src/interactions/map_campus_house_1/kitchenFridge.interaction.js b/src/interactions/map_campus_house_1/kitchenFridge.interaction.js new file mode 100644 index 00000000..04e7418f --- /dev/null +++ b/src/interactions/map_campus_house_1/kitchenFridge.interaction.js @@ -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; + }, + }); + }); +}; diff --git a/src/interactions/map_campus_house_1/mage.interaction.js b/src/interactions/map_campus_house_1/mage.interaction.js index 48e4f350..aafb8ab3 100644 --- a/src/interactions/map_campus_house_1/mage.interaction.js +++ b/src/interactions/map_campus_house_1/mage.interaction.js @@ -1,4 +1,5 @@ import { displayDialogue, displayPermissionBox } from '../../utils'; +import { updateEnergyState } from '../../utils/energyUpdate'; const alredyUnlockText = ['The challenge is waiting for you!']; @@ -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; @@ -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; + }, + }); + } } });