Description:
A bug in the js-game where the health and happiness values can exceed the maximum limit of 100. The game should cap these values at 100 to maintain balance and prevent unrealistic stats for the pet.
Steps to Reproduce:
Continuously perform actions that increase the pet's health or happiness (e.g., feeding, playing).
Observe that the health and happiness values can exceed 100.
Expected Behavior:
The health and happiness values should stop increasing once they reach 100.
Proposed Solution:
Implement logic to check the health and happiness values before increasing them. If they are already at 100, do not allow further increments.
Target Code Blocks can be found in the script.js file:
//increase health by clicking on "feed" button and update the display
function increaseHealth() {
if (petHealth < 100 && petHealth != 0) {
petHealth += 3;
updateDisplay();
}
}
//increase happiness by clicking on "play" button and update the display
function increaseHappiness() {
if (petHappiness < 100 && petHappiness != 0) {
petHappiness += 3;
updateDisplay();
}
}
//increase both stats by cliking on "clean" button and update display
function increaseBothbyCleaning() {
if ((petHappiness < 100 && petHappiness != 0) || (petHealth < 100 && petHealth != 0)) {
petHappiness += 1;
petHealth += 1;
updateDisplay();
}
}
Installation Steps
Fork then Clone the Repository:
Description: A bug in the js-game where the health and happiness values can exceed the maximum limit of 100. The game should cap these values at 100 to maintain balance and prevent unrealistic stats for the pet.
Steps to Reproduce: Continuously perform actions that increase the pet's health or happiness (e.g., feeding, playing). Observe that the health and happiness values can exceed 100.
Expected Behavior: The health and happiness values should stop increasing once they reach 100.
Proposed Solution: Implement logic to check the health and happiness values before increasing them. If they are already at 100, do not allow further increments.
Target Code Blocks can be found in the script.js file:
Installation Steps Fork then Clone the Repository:
bash/zsh Copy code git@github.com:MBHunter88/-techtonica-assignments.git
Navigate to the Project Directory:
bash/zsh Copy code
cd techtonica-projects/js-game/script.js
Install Dependencies:
Run the following command to install all necessary dependencies listed in package.json: bash/zsh Copy code
npm install