Spaces:
Running
Running
Add Feature:s "Gather Food" and "Show Food reserves" - Follow Up Deployment
Browse files- index.html +25 -1
index.html
CHANGED
@@ -189,6 +189,9 @@
|
|
189 |
<div>
|
190 |
<span class="font-semibold">Troops:</span> <span id="player-troops">0/50</span>
|
191 |
</div>
|
|
|
|
|
|
|
192 |
<div class="pt-2">
|
193 |
<div class="w-full bg-gray-700 rounded-full h-2.5">
|
194 |
<div id="health-bar" class="bg-red-600 h-2.5 rounded-full" style="width: 100%"></div>
|
@@ -224,6 +227,9 @@
|
|
224 |
<button class="action-btn w-full px-4 py-2 bg-purple-700 hover:bg-purple-800 rounded disabled:opacity-50 disabled:cursor-not-allowed" disabled>
|
225 |
<i class="fas fa-store mr-2"></i> Trade
|
226 |
</button>
|
|
|
|
|
|
|
227 |
<button class="action-btn w-full px-4 py-2 bg-gray-700 hover:bg-gray-600 rounded disabled:opacity-50 disabled:cursor-not-allowed" disabled>
|
228 |
<i class="fas fa-route mr-2"></i> Travel
|
229 |
</button>
|
@@ -659,7 +665,10 @@
|
|
659 |
trade();
|
660 |
break;
|
661 |
|
662 |
-
case 4: //
|
|
|
|
|
|
|
663 |
travelTo(settlement);
|
664 |
break;
|
665 |
}
|
@@ -890,6 +899,20 @@
|
|
890 |
updatePlayerInfo();
|
891 |
}
|
892 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
893 |
// Trade goods
|
894 |
function trade() {
|
895 |
const settlement = gameState.selectedSettlement;
|
@@ -1047,6 +1070,7 @@
|
|
1047 |
playerGoldEl.textContent = gameState.player.gold;
|
1048 |
playerRenownEl.textContent = gameState.player.renown;
|
1049 |
playerTroopsEl.textContent = `${gameState.player.currentTroops}/${gameState.player.maxTroops}`;
|
|
|
1050 |
healthTextEl.textContent = `${gameState.player.health}`;
|
1051 |
healthBarEl.style.width = `${gameState.player.health}%`;
|
1052 |
}
|
|
|
189 |
<div>
|
190 |
<span class="font-semibold">Troops:</span> <span id="player-troops">0/50</span>
|
191 |
</div>
|
192 |
+
<div>
|
193 |
+
<span class="font-semibold">Food:</span> <span id="player-food">50</span>
|
194 |
+
</div>
|
195 |
<div class="pt-2">
|
196 |
<div class="w-full bg-gray-700 rounded-full h-2.5">
|
197 |
<div id="health-bar" class="bg-red-600 h-2.5 rounded-full" style="width: 100%"></div>
|
|
|
227 |
<button class="action-btn w-full px-4 py-2 bg-purple-700 hover:bg-purple-800 rounded disabled:opacity-50 disabled:cursor-not-allowed" disabled>
|
228 |
<i class="fas fa-store mr-2"></i> Trade
|
229 |
</button>
|
230 |
+
<button class="action-btn w-full px-4 py-2 bg-green-700 hover:bg-green-800 rounded disabled:opacity-50 disabled:cursor-not-allowed" disabled>
|
231 |
+
<i class="fas fa-leaf mr-2"></i> Gather Food
|
232 |
+
</button>
|
233 |
<button class="action-btn w-full px-4 py-2 bg-gray-700 hover:bg-gray-600 rounded disabled:opacity-50 disabled:cursor-not-allowed" disabled>
|
234 |
<i class="fas fa-route mr-2"></i> Travel
|
235 |
</button>
|
|
|
665 |
trade();
|
666 |
break;
|
667 |
|
668 |
+
case 4: // Gather Food
|
669 |
+
gatherFood();
|
670 |
+
break;
|
671 |
+
case 5: // Travel
|
672 |
travelTo(settlement);
|
673 |
break;
|
674 |
}
|
|
|
899 |
updatePlayerInfo();
|
900 |
}
|
901 |
|
902 |
+
// Gather food from surrounding area
|
903 |
+
function gatherFood() {
|
904 |
+
if (gameState.selectedSettlement.type !== 'village') {
|
905 |
+
addGameLog("You can only gather food in villages!");
|
906 |
+
return;
|
907 |
+
}
|
908 |
+
|
909 |
+
const foodGathered = Math.floor(Math.random() * 30) + 10;
|
910 |
+
gameState.player.inventory.food += foodGathered;
|
911 |
+
|
912 |
+
addGameLog(`You gathered ${foodGathered} food from the surrounding countryside.`);
|
913 |
+
updatePlayerInfo();
|
914 |
+
}
|
915 |
+
|
916 |
// Trade goods
|
917 |
function trade() {
|
918 |
const settlement = gameState.selectedSettlement;
|
|
|
1070 |
playerGoldEl.textContent = gameState.player.gold;
|
1071 |
playerRenownEl.textContent = gameState.player.renown;
|
1072 |
playerTroopsEl.textContent = `${gameState.player.currentTroops}/${gameState.player.maxTroops}`;
|
1073 |
+
document.getElementById('player-food').textContent = gameState.player.inventory.food;
|
1074 |
healthTextEl.textContent = `${gameState.player.health}`;
|
1075 |
healthBarEl.style.width = `${gameState.player.health}%`;
|
1076 |
}
|