Skip to content

Commit

Permalink
Defining a function for the sleeping action.
Browse files Browse the repository at this point in the history
  • Loading branch information
Eduardo-J-Morales committed Nov 20, 2024
1 parent 0153e73 commit 3aebc04
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ const play = () => {
setMessage('So fun!');
}

const sleep = () => {
if (!isAlive()) return;
setEnergy(prev => Math.min(100, prev + 30));
setHunger(prev => Math.min(100, prev + 10));
setBoredom(prev => Math.min(100, prev + 15));
setMessage('Sweet dreams!');
}


return (
<div >
Expand Down

0 comments on commit 3aebc04

Please sign in to comment.