about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--js/puzzle-dungeon/commandHandler.js14
-rw-r--r--js/puzzle-dungeon/game.js20
-rw-r--r--js/puzzle-dungeon/index.html2
3 files changed, 20 insertions, 16 deletions
diff --git a/js/puzzle-dungeon/commandHandler.js b/js/puzzle-dungeon/commandHandler.js
index 5eec5e0..f480d6f 100644
--- a/js/puzzle-dungeon/commandHandler.js
+++ b/js/puzzle-dungeon/commandHandler.js
@@ -61,9 +61,9 @@ function handleUseCommand(item, callback) {
             player.health += 1; // Increase health by 1
             console.log(`Used ${item}, health is now ${player.health}`);
             flashPlayer(callback);
-        } else if (item === 'food') {
-            player.endurance = Math.min(player.endurance + 2, 10); // Increase endurance by 2, up to a max of 10
-            console.log(`Used ${item}, endurance is now ${player.endurance}`);
+        } else if (item === 'battery') {
+            player.power = Math.min(player.power + 2, 10); // Increase power by 2, up to a max of 10
+            console.log(`Used ${item}, power is now ${player.power}`);
             flashPlayer(callback);
         } else {
             callback();
@@ -103,16 +103,16 @@ function handleMovement(direction, steps, callback) {
 
         player.steps += 1;
         if (player.steps % 8 === 0) {
-            player.endurance = Math.max(player.endurance - 1, 0);  // Decrease endurance but not below 0
-            if (player.endurance <= 0) {
+            player.power = Math.max(player.power - 1, 0);  // Decrease endurance but not below 0
+            if (player.power <= 0) {
                 player.health -= 1;
-                console.log(`Endurance depleted, health is now ${player.health}`);
+                console.log(`Power depleted, health is now ${player.health}`);
                 if (player.health <= 0) {
                     alertGameOver();
                     return;
                 }
             }
-            console.log(`Endurance decreased, endurance is now ${player.endurance}`);
+            console.log(`Power decreased, power is now ${player.power}`);
         }
 
         drawGrid(grid);
diff --git a/js/puzzle-dungeon/game.js b/js/puzzle-dungeon/game.js
index ae2e627..a41d90c 100644
--- a/js/puzzle-dungeon/game.js
+++ b/js/puzzle-dungeon/game.js
@@ -4,7 +4,7 @@ export let player = {
     inventory: [],
     health: 10,
     power: 10,
-    score: 0,
+    level: 0,
     steps: 0,
     flashing: false
 };
@@ -106,10 +106,14 @@ export function initializeGame() {
     generateCollectables(grid, 10);  // Adjust the number as needed
     generateDamagingSpaces(grid, Math.floor(Math.random() * 7) + 1);  // Random number of damaging spaces, no more than 7
     generateTargetBlock(grid);  // Add target block
-    player.position = { x: 0, y: 0 };  // Reset player position
-    player.inventory = [];  // Clear inventory
-    player.health = 10;  // Reset health
-    player.endurance = 10;  // Reset endurance
+
+    if (player.level === 0) {
+        player.position = { x: 0, y: 0 };  // Reset player position
+        player.inventory = [];  // Clear inventory
+        player.health = 10;  // Reset health
+        player.power = 10;  // Reset endurance
+    }
+
     player.steps = 0;  // Reset steps
     resizeCanvas();
     drawGrid(grid);
@@ -137,7 +141,7 @@ export function updatePlayerStatus() {
     document.getElementById('playerHealth').textContent = `Health: ${player.health}`;
     document.getElementById('playerPower').textContent = `Power: ${player.power}`;
     document.getElementById('playerInventory').textContent = `Inventory: [${player.inventory.join(', ')}]`;
-    document.getElementById('playerScore').textContent = `Score: ${player.score}`;
+    document.getElementById('playerLevel').textContent = `Level: ${player.level}`;
 }
 
 function checkForDamageOrTarget() {
@@ -158,8 +162,8 @@ function checkForDamageOrTarget() {
             flashPlayer();
         }
     } else if (x === targetPosition.x && y === targetPosition.y) {
-        player.score += 1;
-        console.log(`Reached target block, score is now ${player.score}`);
+        player.level += 1;
+        console.log(`Reached target block, level is now ${player.level}`);
         initializeGame();  // Generate new level and reset player position
     }
 }
diff --git a/js/puzzle-dungeon/index.html b/js/puzzle-dungeon/index.html
index 5a88fc3..ee6bff4 100644
--- a/js/puzzle-dungeon/index.html
+++ b/js/puzzle-dungeon/index.html
@@ -37,7 +37,7 @@
     <p>
         <span id="playerHealth">Health: 10</span> / 
         <span id="playerPower">Power: 10</span> /
-        <span id="playerScore">Score: 0</span> /
+        <span id="playerLevel">Level: 0</span> /
         <span id="playerPosition">(0, 0)</span>
     </p>
     <canvas id="gameCanvas"></canvas>