Update src/battle.js
This commit is contained in:
parent
a17028c651
commit
8427292d07
@ -69,7 +69,8 @@ function updateGameState(gameState) {
|
|||||||
const winnerDiv = document.createElement('div');
|
const winnerDiv = document.createElement('div');
|
||||||
winnerDiv.innerHTML = `<p>Battle End! Winner: ${gameState.winner}</p>`;
|
winnerDiv.innerHTML = `<p>Battle End! Winner: ${gameState.winner}</p>`;
|
||||||
document.body.appendChild(winnerDiv);
|
document.body.appendChild(winnerDiv);
|
||||||
submitButton.disabled = true;
|
submitButton.style.display = 'none';
|
||||||
|
targetSelector.style.display = 'none';
|
||||||
clearInterval(pollInterval);
|
clearInterval(pollInterval);
|
||||||
} else {
|
} else {
|
||||||
const aliveFighters = gameState.fighters.filter(fighter => fighter.hp > 0);
|
const aliveFighters = gameState.fighters.filter(fighter => fighter.hp > 0);
|
||||||
@ -94,10 +95,14 @@ function updateGameState(gameState) {
|
|||||||
targetSelector.style.display = 'none';
|
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';
|
submitButton.style.display = 'none';
|
||||||
|
targetSelector.style.display = 'none';
|
||||||
} else {
|
} else {
|
||||||
submitButton.style.display = 'block';
|
submitButton.style.display = 'block';
|
||||||
|
targetSelector.style.display = 'block';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user