Files
novafarma/old_logic/src_backup_1768938138/systems/GronkStats.js
2026-01-21 01:08:21 +01:00

187 lines
4.6 KiB
JavaScript

/**
* GRONK STATS SYSTEM
* Level-up progression for Gronk companion
* Powers increase with vape usage
*/
class GronkStats {
constructor() {
this.level = 1;
this.xp = 0;
this.vapeUsageCount = 0;
// Gronk abilities
this.stats = {
vapeCloudSize: 1.0, // Multiplier for cloud area
vapeCloudDuration: 3000, // ms
shieldStrength: 100, // HP absorbed
speedBoost: 1.2, // 20% speed boost baseline
cooldown: 10000 // 10s between vapes
};
this.maxLevel = 10;
this.load();
}
/**
* GAIN XP FROM VAPE USAGE
*/
useVape() {
this.vapeUsageCount++;
this.addXP(10); // 10 XP per vape use
console.log(`💨 Gronk vape used! (${this.vapeUsageCount} total)`);
this.save();
}
/**
* ADD XP AND CHECK FOR LEVEL UP
*/
addXP(amount) {
this.xp += amount;
const xpNeeded = this.getXPForNextLevel();
if (this.xp >= xpNeeded && this.level < this.maxLevel) {
this.levelUp();
}
this.save();
}
/**
* LEVEL UP GRONK
*/
levelUp() {
this.level++;
this.xp = 0;
// Increase all stats
this.stats.vapeCloudSize += 0.15; // +15% cloud size per level
this.stats.vapeCloudDuration += 500; // +0.5s per level
this.stats.shieldStrength += 20; // +20 HP per level
this.stats.speedBoost += 0.05; // +5% speed per level
this.stats.cooldown = Math.max(5000, this.stats.cooldown - 500); // -0.5s cooldown
console.log('⬆️ GRONK LEVELED UP to ' + this.level + '!');
console.log(' Stats:', this.stats);
// Emit level up event
const event = new CustomEvent('gronk-levelup', {
detail: {
level: this.level,
stats: this.stats
}
});
window.dispatchEvent(event);
this.save();
}
/**
* GET XP NEEDED FOR NEXT LEVEL
*/
getXPForNextLevel() {
// Exponential XP curve
return Math.floor(100 * Math.pow(1.5, this.level - 1));
}
/**
* GET CURRENT PROGRESS TO NEXT LEVEL
*/
getLevelProgress() {
const needed = this.getXPForNextLevel();
return {
current: this.xp,
needed: needed,
percentage: Math.min(100, (this.xp / needed) * 100)
};
}
/**
* GET ALL STATS
*/
getStats() {
return {
level: this.level,
xp: this.xp,
vapeUsageCount: this.vapeUsageCount,
...this.stats,
nextLevel: this.getLevelProgress()
};
}
/**
* CHECK IF VAPE IS READY (not on cooldown)
*/
isVapeReady(lastUseTime) {
const now = Date.now();
return (now - lastUseTime) >= this.stats.cooldown;
}
/**
* GET VAPE COOLDOWN REMAINING
*/
getVapeCooldownRemaining(lastUseTime) {
const now = Date.now();
const elapsed = now - lastUseTime;
return Math.max(0, this.stats.cooldown - elapsed);
}
/**
* SAVE TO LOCALSTORAGE
*/
save() {
const data = {
level: this.level,
xp: this.xp,
vapeUsageCount: this.vapeUsageCount,
stats: this.stats,
lastSaved: new Date().toISOString()
};
localStorage.setItem('gronk_stats', JSON.stringify(data));
}
/**
* LOAD FROM LOCALSTORAGE
*/
load() {
const stored = localStorage.getItem('gronk_stats');
if (!stored) return;
try {
const data = JSON.parse(stored);
this.level = data.level || 1;
this.xp = data.xp || 0;
this.vapeUsageCount = data.vapeUsageCount || 0;
this.stats = data.stats || this.stats;
console.log('📊 Gronk stats loaded:', this.getStats());
} catch (e) {
console.warn('Failed to load Gronk stats:', e);
}
}
/**
* RESET PROGRESSION (for testing)
*/
reset() {
this.level = 1;
this.xp = 0;
this.vapeUsageCount = 0;
this.stats = {
vapeCloudSize: 1.0,
vapeCloudDuration: 3000,
shieldStrength: 100,
speedBoost: 1.2,
cooldown: 10000
};
localStorage.removeItem('gronk_stats');
console.log('🔄 Gronk stats reset');
}
}
// Singleton instance
const gronkStats = new GronkStats();
export default gronkStats;