Skip to content

Commit

Permalink
Dining table interaction (#186)
Browse files Browse the repository at this point in the history
  • Loading branch information
r4pt0s authored Oct 28, 2024
2 parents ae237da + e2bf55c commit 7d7860f
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
37 changes: 37 additions & 0 deletions src/interactions/map_campus_house_1/diningtableinteraction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { time } from '../../kplayCtx';
import { displayDialogue, displayPermissionBox } from '../../utils';
import { updateEnergyState } from '../../utils/energyUpdate';

export const diningTableInteractions = (player, k, map) => {
player.onCollide('diningTable', async () => {
let wantEat = await displayPermissionBox({
k,
player,
text: [
'Are you hungry? Would you like to have a meal? (Time advances 1 hour)',
],
});

const dialogue = [];

if (wantEat) {
time.minutes += 60;
dialogue.push('You enjoyed a delicious meal!');
dialogue.push('You feel more energized now.');
updateEnergyState(player.state, 75);
} else {
if (player.state.energy < 50) {
dialogue.push('You look a bit weak.');
dialogue.push('It might be time for a meal!');
} else {
dialogue.push('No worries, maybe later!');
}
}

displayDialogue({
k,
player,
text: [dialogue.join(' ')],
});
});
};
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 @@ -8,6 +8,7 @@ import { bedroomShelfInteractions } from './bedroomShelf.interaction';
import { livingRoomCouchInteractions } from './livingRoomCouch.interaction';
import { bedroomTableInteractions } from './bedroom_table.interaction';
import { bedroomPlantInteractions } from './bedroom_plant.interaction';
import { diningTableInteractions } from './diningtableinteraction';

const interactions = [
// Add more interactions here
Expand All @@ -20,6 +21,7 @@ const interactions = [
bedroomShelfInteractions,
livingRoomCouchInteractions,
bedroomTableInteractions,
diningTableInteractions,
livingroomcouchInteractions,
bedroomPlantInteractions,
];
Expand Down

0 comments on commit 7d7860f

Please sign in to comment.