From 3b7a8524bb33bf168d20f8892b2f232aed360890 Mon Sep 17 00:00:00 2001 From: kapish9741 Date: Mon, 28 Oct 2024 03:54:29 +0530 Subject: [PATCH] add restroom_toilet interaction --- src/interactions/map_campus_house_1/index.js | 1 + .../restroom_toilet.interaction.js | 37 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 src/interactions/map_campus_house_1/restroom_toilet.interaction.js diff --git a/src/interactions/map_campus_house_1/index.js b/src/interactions/map_campus_house_1/index.js index 22d471e..e811dd8 100644 --- a/src/interactions/map_campus_house_1/index.js +++ b/src/interactions/map_campus_house_1/index.js @@ -22,6 +22,7 @@ const interactions = [ bedroomTableInteractions, livingroomcouchInteractions, bedroomPlantInteractions, + restroomToiletInteractions, ]; export default interactions; diff --git a/src/interactions/map_campus_house_1/restroom_toilet.interaction.js b/src/interactions/map_campus_house_1/restroom_toilet.interaction.js new file mode 100644 index 0000000..06a10b7 --- /dev/null +++ b/src/interactions/map_campus_house_1/restroom_toilet.interaction.js @@ -0,0 +1,37 @@ +import { time } from '../../kplayCtx'; +import { displayDialogue, displayPermissionBox } from '../../utils'; +import { updateEnergyState } from '../../utils/energyUpdate'; + +export const restroomToiletInteractions = (player, k, map) => { + player.onCollide('restroom_toilet', async () => { + let wantUseToilet = await displayPermissionBox({ + k, + player, + text: [ + 'Do you need to use the restroom? (Time advances 15 minutes)', + ], + }); + + const dialogue = []; + + if (wantUseToilet) { + time.minutes += 15; + dialogue.push('You feel relieved!'); + dialogue.push('Ready to continue your journey.'); + updateEnergyState(player.state, player.state.energy + 10); // Optional small energy boost + } else { + if (player.state.energy < 50) { + dialogue.push('Maybe you should take a break.'); + dialogue.push('It could help you feel more comfortable.'); + } else { + dialogue.push('You decide to keep going for now.'); + } + } + + displayDialogue({ + k, + player, + text: [dialogue.join(' ')], + }); + }); +};