Files
novafarma/STAMINA_SYSTEM_INTEGRATION.js
2025-12-12 13:40:51 +01:00

110 lines
2.8 KiB
JavaScript

// STAMINA SYSTEM - INTEGRATION GUIDE
// 1. DODAJ V index.html (po AccessibilitySystem.js):
<script src="src/systems/StaminaSystem.js"></script> <!--Stamina System-- >
// 2. DODAJ V GameScene.js create() metodo:
// Initialize Stamina System
console.log('⚡ Initializing Stamina System...');
this.staminaSystem = new StaminaSystem(this);
this.staminaSystem.createUI();
// 3. DODAJ V GameScene.js update() metodo:
if (this.staminaSystem) this.staminaSystem.update(delta);
// 4. POSODOBI FarmingSystem.js - tillSoil():
tillSoil(gridX, gridY) {
// Check stamina
if (!this.scene.staminaSystem.useStamina('till')) {
console.log('⚡ Not enough stamina to till!');
return false;
}
// Existing till logic...
}
// 5. POSODOBI FarmingSystem.js - plantSeed():
plantSeed(gridX, gridY, seedType) {
// Check stamina
if (!this.scene.staminaSystem.useStamina('plant')) {
console.log('⚡ Not enough stamina to plant!');
return false;
}
// Existing plant logic...
}
// 6. POSODOBI FarmingSystem.js - harvestCrop():
harvestCrop(gridX, gridY) {
// Check stamina
if (!this.scene.staminaSystem.useStamina('harvest')) {
console.log('⚡ Not enough stamina to harvest!');
return false;
}
// Existing harvest logic...
}
// 7. POSODOBI BuildSystem.js - placeBuilding():
placeBuilding(gridX, gridY) {
// Check stamina
if (!this.scene.staminaSystem.useStamina('build')) {
console.log('⚡ Not enough stamina to build!');
return false;
}
// Existing build logic...
}
// 8. FOOD RESTORES STAMINA
// V InventorySystem.js - consumeItem():
if (item.type === 'carrot' || item.type === 'wheat') {
// Restore stamina
if (this.scene.staminaSystem) {
this.scene.staminaSystem.restoreStamina(20);
}
}
// 9. SAVE/LOAD INTEGRATION
// V SaveSystem.js - getSaveData():
stamina: this.scene.staminaSystem.getSaveData(),
// V SaveSystem.js - loadSaveData():
if (data.stamina) {
this.scene.staminaSystem.loadSaveData(data.stamina);
}
// 10. TESTING
// Console commands:
window.testStamina = () => {
console.log('Current stamina:', gameScene.staminaSystem.currentStamina);
gameScene.staminaSystem.useStamina('till');
};
window.restoreStamina = (amount = 50) => {
gameScene.staminaSystem.restoreStamina(amount);
};
// USAGE:
// - Farming actions cost stamina
// - Stamina auto-regenerates after 2 seconds
// - Food restores stamina
// - Stamina bar shows below health (yellow)
// - Icon: ⚡
// STAMINA COSTS:
// - Till: 5
// - Plant: 3
// - Harvest: 4
// - Build: 10
// - Attack: 8
// - Sprint: 2/sec
// FEATURES:
// ✅ Stamina bar (yellow, below health)
// ✅ Auto-regenerate (5/sec after 2s delay)
// ✅ Farming costs stamina
// ✅ Food restores stamina
// ✅ Save/Load support
// ✅ Visual feedback