diff options
author | elioat <elioat@tilde.institute> | 2025-02-16 22:31:40 -0500 |
---|---|---|
committer | elioat <elioat@tilde.institute> | 2025-02-16 22:31:40 -0500 |
commit | be8f389e4ceea897ebe63e31b84c73247adde387 (patch) | |
tree | b0e7110b7818d393568b8bc908b3655522bcc001 /html/tower/js/mechanics.js | |
parent | af33663d8be0f19b319922bcf37cf0239ab2ed06 (diff) | |
download | tour-be8f389e4ceea897ebe63e31b84c73247adde387.tar.gz |
*
Diffstat (limited to 'html/tower/js/mechanics.js')
-rw-r--r-- | html/tower/js/mechanics.js | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/html/tower/js/mechanics.js b/html/tower/js/mechanics.js index d172025..c1dcb1c 100644 --- a/html/tower/js/mechanics.js +++ b/html/tower/js/mechanics.js @@ -35,6 +35,8 @@ function updateEnemies() { // Handle path completion if (enemy.progress >= 1) { gameState.enemiesEscaped++; + // Deduct currency when enemy escapes + gameState.currency = Math.max(0, gameState.currency - 10); return false; } @@ -236,7 +238,10 @@ function createSlimeTrail(enemy, cellSize) { * @param {number} cellSize - Grid cell size */ function handleTowerAttack(tower, target, projectiles, particles, timestamp, cellSize) { - // Decrease ammo + // Only attack if we have ammo + if (tower.ammo <= 0) return; + + // Decrease ammo (already checked it's > 0) tower.ammo--; // Create projectile |