-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add sleep beed interaction (#128)
Part of #130
- Loading branch information
Showing
2 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}, | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters