From 8427292d0781fa25108b9b0c798b596f91efdee7 Mon Sep 17 00:00:00 2001 From: Ivor Barhansky Date: Fri, 21 Jun 2024 11:20:05 +0000 Subject: [PATCH] Update src/battle.js --- src/battle.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/battle.js b/src/battle.js index 7730d98..9ecff1a 100644 --- a/src/battle.js +++ b/src/battle.js @@ -69,7 +69,8 @@ function updateGameState(gameState) { const winnerDiv = document.createElement('div'); winnerDiv.innerHTML = `

Battle End! Winner: ${gameState.winner}

`; document.body.appendChild(winnerDiv); - submitButton.disabled = true; + submitButton.style.display = 'none'; + targetSelector.style.display = 'none'; clearInterval(pollInterval); } else { const aliveFighters = gameState.fighters.filter(fighter => fighter.hp > 0); @@ -94,10 +95,14 @@ function updateGameState(gameState) { targetSelector.style.display = 'none'; } - if (gameState.last_fighter === username) { + const currentFighter = gameState.fighters.find(fighter => fighter.name === username); + + if (gameState.last_fighter === username || currentFighter.hp <= 0) { submitButton.style.display = 'none'; + targetSelector.style.display = 'none'; } else { submitButton.style.display = 'block'; + targetSelector.style.display = 'block'; } } }