diff options
-rw-r--r-- | html/tower/js/game.js | 16 | ||||
-rw-r--r-- | html/tower/js/gameState.js | 34 | ||||
-rw-r--r-- | html/tower/js/mechanics.js | 7 |
3 files changed, 39 insertions, 18 deletions
diff --git a/html/tower/js/game.js b/html/tower/js/game.js index 34c225d..80b10d4 100644 --- a/html/tower/js/game.js +++ b/html/tower/js/game.js @@ -314,12 +314,28 @@ function handleLevelComplete() { // Pause the game briefly gameState.phase = GamePhase.TRANSITION; + // Calculate ammo bonus + let ammoBonus = 0; + gameState.towers.forEach(tower => { + ammoBonus += tower.ammo * 0.25; + }); + ammoBonus = Math.floor(ammoBonus); + // Show level complete message with modal const message = ` Level ${gameState.level} Complete! + + Stats: + Enemies Destroyed: ${gameState.enemiesDestroyed} + Enemies Escaped: ${gameState.enemiesEscaped} + + Bonuses: Current Money: $${gameState.currency} + Remaining Ammo Bonus: +$${ammoBonus} Level Bonus: +$10 + Total After Bonuses: $${gameState.currency + ammoBonus + 10} + Ready for Level ${gameState.level + 1}? `; diff --git a/html/tower/js/gameState.js b/html/tower/js/gameState.js index af5442a..d0ca661 100644 --- a/html/tower/js/gameState.js +++ b/html/tower/js/gameState.js @@ -11,7 +11,16 @@ const TowerTypes = { damage: 1, attackSpeed: 1, color: '#3498db', - maxAmmo: 100 + maxAmmo: 75 + }, + RAPID: { + name: 'Fast', + cost: 10, + range: 2, + damage: 1, + attackSpeed: 3, + color: '#16a085', + maxAmmo: 50 }, SNIPER: { name: 'Distance', @@ -22,15 +31,6 @@ const TowerTypes = { color: '#8e44ad', maxAmmo: 50 }, - RAPID: { - name: 'Fast', - cost: 10, - range: 2, - damage: 1, - attackSpeed: 3, - color: '#16a085', - maxAmmo: 200 - }, GOOP: { name: 'Goop', cost: 20, @@ -40,18 +40,18 @@ const TowerTypes = { color: '#27ae60', special: 'slow', slowAmount: 0.75, - maxAmmo: 100 + maxAmmo: 25 }, AOE: { name: 'AOE', cost: 25, range: 2, damage: 3, - attackSpeed: 0.3, + attackSpeed: 0.25, color: '#d35400', special: 'aoe', - aoeRadius: 4, - maxAmmo: 75 + aoeRadius: 2, + maxAmmo: 25 } }; @@ -181,12 +181,12 @@ const gameState = { // Add method to advance to next level advanceToNextLevel() { - // Award bonus for remaining ammo + let ammoBonus = 0; this.towers.forEach(tower => { - ammoBonus += tower.ammo * 2; + ammoBonus += tower.ammo * 0.25; }); - this.currency += ammoBonus; + this.currency += Math.floor(ammoBonus); // Round down to nearest whole number this.level++; this.phase = GamePhase.PLACEMENT; 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 |