Bug Description
When the boss HP reaches zero, the score increment and end screen logic runs twice due to duplicated code in the handleKeyPress function. The player receives +100 score twice (total +200) and showEndScreen is called twice in the same event.
Steps to Reproduce
- Start the game and reach Stage 3
- Defeat the boss by typing all its words until HP reaches 0
- Observe the final score — it will show 200 points more than expected
Expected Behavior
When boss HP reaches 0, score should increment by +100 exactly once and showEndScreen("Selamat! Kamu Menang!") should be called once.
Actual Behavior
The following block runs twice consecutively in handleKeyPress:
score += 100;
showPopup(pest.element, "+100", "score");
pest.element.remove();
activePests.splice(i, 1);
showEndScreen("Selamat! Kamu Menang!");
This is because the if (pest.hp <= 0) check appears twice back-to-back in the source code without an else branch separating them.
Root Cause
In script.js, inside the handleKeyPress function under the boss word completion block, the if (pest.hp <= 0) condition and its entire body is copy-pasted twice. The second block runs immediately after the first.
Environment
- Chrome 122 / Firefox 124
- All platforms
Wallet: 0x964739472C587d24934c37BEbB405CeE36D59B24
Bug Description
When the boss HP reaches zero, the score increment and end screen logic runs twice due to duplicated code in the
handleKeyPressfunction. The player receives +100 score twice (total +200) andshowEndScreenis called twice in the same event.Steps to Reproduce
Expected Behavior
When boss HP reaches 0, score should increment by +100 exactly once and
showEndScreen("Selamat! Kamu Menang!")should be called once.Actual Behavior
The following block runs twice consecutively in
handleKeyPress:This is because the
if (pest.hp <= 0)check appears twice back-to-back in the source code without anelsebranch separating them.Root Cause
In
script.js, inside thehandleKeyPressfunction under the boss word completion block, theif (pest.hp <= 0)condition and its entire body is copy-pasted twice. The second block runs immediately after the first.Environment
Wallet: 0x964739472C587d24934c37BEbB405CeE36D59B24