about summary refs log tree commit diff stats
path: root/html/tower/js/gameState.js
diff options
context:
space:
mode:
Diffstat (limited to 'html/tower/js/gameState.js')
-rw-r--r--html/tower/js/gameState.js23
1 files changed, 22 insertions, 1 deletions
diff --git a/html/tower/js/gameState.js b/html/tower/js/gameState.js
index 9da8474..41f25e5 100644
--- a/html/tower/js/gameState.js
+++ b/html/tower/js/gameState.js
@@ -149,12 +149,13 @@ const gameState = {
     towers: [],
     enemies: [],
     currency: 100,
-    phase: 'placement',
+    phase: GamePhase.PLACEMENT,
     isGameOver: false,
     particles: [],
     projectiles: [],
     enemiesDestroyed: 0,
     enemiesEscaped: 0,
+    level: 1,
     
     // Define the function as part of the initial object
     awardEnemyDestroyed() {
@@ -162,5 +163,25 @@ const gameState = {
         // Random reward between 1 and 3
         const reward = Math.floor(Math.random() * 3) + 1;
         this.currency += reward;
+    },
+    
+    // Add method to check for level completion
+    checkLevelComplete() {
+        return this.enemies.length === 0 && 
+               enemiesRemaining === 0 && 
+               this.phase === GamePhase.COMBAT;
+    },
+    
+    // Add method to advance to next level
+    advanceToNextLevel() {
+        this.level++;
+        this.phase = GamePhase.PLACEMENT;
+        this.towers = [];  // Clear existing towers
+        this.enemies = [];
+        this.projectiles = [];
+        this.particles = [];
+        this.grid = Array(20).fill().map(() => Array(20).fill('empty'));
+        // Award bonus currency for reaching new level
+        this.currency += 10;
     }
 }; 
\ No newline at end of file