Skip to content

Commit

Permalink
feat: add sleep beed interaction (#128)
Browse files Browse the repository at this point in the history
Part of #130
  • Loading branch information
r4pt0s authored Oct 10, 2024
2 parents a818757 + f988884 commit 2c84b64
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
42 changes: 42 additions & 0 deletions src/interactions/map_campus_house_1/bed.interaction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { displayDialogue, displayPermissionBox } from '../../utils';
import { updateEnergyState } from '../../utils/energyUpdate';

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

let wantSleep = await displayPermissionBox({
k,
player,
text: ['Are you feeling tired?, Would you like to take a nap?'],
onDisplayEnd: () => {
player.isInDialog = false;
},
});

const dialogue = [];

if (wantSleep) {
dialogue.push('It was a good nap!');
dialogue.push('You feel refreshed now.');
updateEnergyState(player.state, 99);
} else {
if (player.state.energy < 70) {
dialogue.push('You look tired');
dialogue.push('You should take a nap!');
}else{
dialogue.push('Maybe next time!');
}
}

//player.isInDialog = true;
displayDialogue({
k,
player,
text: [dialogue.join(' ')],
onDisplayEnd: () => {
player.isInDialog = false;
},
});
});
};
2 changes: 2 additions & 0 deletions src/interactions/map_campus_house_1/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { enterMapCityInteraction } from './enterMapCity.interactions';
import { bedInteractions } from './bed.interaction';

const interactions = [
// Add more interactions here
enterMapCityInteraction,
bedInteractions,
];

export const attachInteractions = (gameObj, k) => {
Expand Down

0 comments on commit 2c84b64

Please sign in to comment.