about summary refs log tree commit diff stats
path: root/html/tower/js
diff options
context:
space:
mode:
Diffstat (limited to 'html/tower/js')
-rw-r--r--html/tower/js/game.js10
-rw-r--r--html/tower/js/gameState.js77
-rw-r--r--html/tower/js/mechanics.js4
-rw-r--r--html/tower/js/path.js2
-rw-r--r--html/tower/js/renderer.js2
-rw-r--r--html/tower/js/uiHandlers.js2
6 files changed, 92 insertions, 5 deletions
diff --git a/html/tower/js/game.js b/html/tower/js/game.js
index 7495fbe..4d8ed39 100644
--- a/html/tower/js/game.js
+++ b/html/tower/js/game.js
@@ -1,3 +1,13 @@
+// generate updated docs
+// jsdoc js -d docs
+
+/**
+ * Main game entry point
+ * Initializes the game state and starts the game loop
+ * 
+ * @module game
+ */
+
 /** Canvas elements for rendering the game */
 const canvas = document.getElementById('gameCanvas');
 const ctx = canvas.getContext('2d');
diff --git a/html/tower/js/gameState.js b/html/tower/js/gameState.js
index 3cee9ed..ac7a968 100644
--- a/html/tower/js/gameState.js
+++ b/html/tower/js/gameState.js
@@ -1,8 +1,29 @@
+/**
+ * Game State Module
+ * 
+ * This module defines the game state and game phases
+ * 
+ * @module gameState
+ */
+
+
+/**
+ * Game phases
+ * 
+ * @enum {string}
+ * @readonly
+ */
 const GamePhase = {
     PLACEMENT: 'place',
     COMBAT: 'run'
 };
 
+/**
+ * Tower types
+ * 
+ * @enum {string}
+ * @readonly
+ */
 const TowerTypes = {
     BASIC: {
         name: 'Basic',
@@ -55,6 +76,12 @@ const TowerTypes = {
     }
 };
 
+/**
+ * Particle types
+ * 
+ * @enum {string}
+ * @readonly
+ */
 const ParticleTypes = {
     DEATH_PARTICLE: {
         lifetime: 1000, // milliseconds
@@ -81,6 +108,12 @@ const ParticleTypes = {
     }
 };
 
+/**
+ * Enemy types
+ * 
+ * @enum {string}
+ * @readonly
+ */
 const EnemyTypes = {
     BASIC: {
         color: '#c0392b',
@@ -100,6 +133,12 @@ const EnemyTypes = {
     }
 };
 
+/**
+ * Creates a tower
+ * 
+ * @param {string} type - Tower type
+ * @param {Object} position - Position of the tower
+ */
 function createTower(type, position) {
     const towerType = TowerTypes[type];
     return {
@@ -113,6 +152,11 @@ function createTower(type, position) {
     };
 }
 
+/**
+ * Creates an enemy
+ * 
+ * @param {Object} startPosition - Starting position of the enemy
+ */
 function createEnemy(startPosition) {
     // 20% chance for ranged enemy
     const type = Math.random() < 0.2 ? 'RANGED' : 'BASIC';
@@ -138,6 +182,12 @@ function createEnemy(startPosition) {
     };
 }
 
+/**
+ * Creates a particle
+ * 
+ * @param {string} type - Particle type
+ * @param {Object} position - Position of the particle
+ */
 function createParticle(type, position, angle) {
     return {
         position: { ...position },
@@ -154,7 +204,12 @@ function createParticle(type, position, angle) {
     };
 }
 
-// Initialize game state at the bottom of the file
+
+/**
+ * Game state
+ * 
+ * @type {Object}
+ */
 const gameState = {
     grid: Array(20).fill().map(() => Array(20).fill('empty')),
     path: [],
@@ -169,6 +224,9 @@ const gameState = {
     enemiesEscaped: 0,
     level: 1,
     
+    /**
+     * Resets the game state
+     */
     resetGame() {
         this.grid = Array(20).fill().map(() => Array(20).fill('empty'));
         this.path = [];
@@ -184,7 +242,10 @@ const gameState = {
         this.level = 1;
     },
     
-    // Define the function as part of the initial object
+
+    /**
+     * Awards the enemy destroyed
+     */
     awardEnemyDestroyed() {
         this.enemiesDestroyed++;
         // Random reward between 1 and 3
@@ -192,14 +253,22 @@ const gameState = {
         this.currency += reward;
     },
     
-    // Add method to check for level completion
+
+    /**
+     * Checks if the level is complete
+     * 
+     * @returns {boolean}
+     */
     checkLevelComplete() {
         return this.enemies.length === 0 && 
                enemiesRemaining === 0 && 
                this.phase === GamePhase.COMBAT;
     },
     
-    // Add method to advance to next level
+
+    /**
+     * Advances to the next level
+     */
     advanceToNextLevel() {
 
         let ammoBonus = 0;
diff --git a/html/tower/js/mechanics.js b/html/tower/js/mechanics.js
index e9d751a..bc73fff 100644
--- a/html/tower/js/mechanics.js
+++ b/html/tower/js/mechanics.js
@@ -1,11 +1,13 @@
 /**
  * Combat Mechanics Module
- * 
+ *  
  * This module handles all combat-related game mechanics including:
  * 1. Enemy movement and behavior
  * 2. Tower attacks and targeting
  * 3. Projectile and particle systems
  * 4. Status effects and special abilities
+ * 
+ * @module mechanics
  */
 
 /**
diff --git a/html/tower/js/path.js b/html/tower/js/path.js
index 91193e2..8b840ce 100644
--- a/html/tower/js/path.js
+++ b/html/tower/js/path.js
@@ -5,6 +5,8 @@
  * 1. Procedural Content Generation (PCG)
  * 2. Pathfinding algorithms
  * 3. Constraint-based generation
+ * 
+ * @module path
  */
 
 /**
diff --git a/html/tower/js/renderer.js b/html/tower/js/renderer.js
index 29dd35f..fce4b88 100644
--- a/html/tower/js/renderer.js
+++ b/html/tower/js/renderer.js
@@ -7,6 +7,8 @@
  * 2. Particle systems
  * 3. Visual state feedback
  * 4. Canvas state management
+ * 
+ * @module renderer
  */
 
 /**
diff --git a/html/tower/js/uiHandlers.js b/html/tower/js/uiHandlers.js
index f171358..00651ca 100644
--- a/html/tower/js/uiHandlers.js
+++ b/html/tower/js/uiHandlers.js
@@ -7,6 +7,8 @@
  * 2. Event handling
  * 3. UI state management
  * 4. Input validation
+ * 
+ * @module uiHandlers
  */
 
 /**