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

kitchen counter Interaction #188

Closed
wants to merge 2 commits into from
Closed
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 @@ -9,6 +9,7 @@ import { livingRoomCouchInteractions } from './livingRoomCouch.interaction';
import { bedroomTableInteractions } from './bedroom_table.interaction';
import { bedroomPlantInteractions } from './bedroom_plant.interaction';
import { diningTableInteractions } from './diningtableinteraction';
import { KitchencounterInteractions} from './KitchencounterInteractions'

const interactions = [
// Add more interactions here
Expand All @@ -25,6 +26,7 @@ const interactions = [
livingroomcouchInteractions,
bedroomPlantInteractions,
restroomToiletInteractions,
KitchencounterInteractions,
];

export default interactions;
36 changes: 36 additions & 0 deletions src/interactions/map_campus_house_1/kitchen_counter.interaction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { time } from '../../kplayCtx';
import { displayDialogue, displayPermissionBox } from '../../utils';
import { updateEnergyState } from '../../utils/energyUpdate';

export const KitchencounterInteractions = (player, k, map) => {
player.onCollide('kitchen_counter', async () => {
let wantCook = await displayPermissionBox({
k,
player,
text: [
'Are you hungry? Would you like to cook something? (Cooking will take 2 hours)',
],
});

const dialogue = [];

if (wantCook) {
time.minutes += 2;
dialogue.push('You prepared a delicious meal!');
dialogue.push('Your hunger is satisfied.');
updateEnergyState(player.state, Math.min(player.state.energy + 20, 100));
} else {
if (player.state.hunger > 70) {
dialogue.push('You should really consider cooking something to eat!');
} else {
dialogue.push('Maybe next time you’ll feel like cooking.');
}
}

displayDialogue({
k,
player,
text: [dialogue.join(' ')],
});
});
};