185 lines
5.1 KiB
JavaScript
185 lines
5.1 KiB
JavaScript
/**
|
|
* Cosmic Garden - Prestige System
|
|
* Allows resetting progress for permanent Stellar Essence bonuses
|
|
*/
|
|
|
|
const PRESTIGE = {
|
|
/**
|
|
* Calculate Stellar Essence earned from prestiging
|
|
* Formula: floor(sqrt(totalStardust / 1,000,000))
|
|
*/
|
|
calculateEssence() {
|
|
const totalStardust = Game.state.totalStardust || 0;
|
|
return Math.floor(Math.sqrt(totalStardust / 1e6));
|
|
},
|
|
|
|
/**
|
|
* Get the current prestige multiplier from essence
|
|
* Each essence provides +10% production bonus
|
|
*/
|
|
getMultiplier() {
|
|
const essence = Game.state.stellarEssence || 0;
|
|
return 1 + (essence * 0.1);
|
|
},
|
|
|
|
/**
|
|
* Perform the prestige reset
|
|
*/
|
|
prestige() {
|
|
const essenceGain = this.calculateEssence();
|
|
|
|
if (essenceGain <= 0) {
|
|
UI.showNotification('Need more stardust to prestige!', 'warning');
|
|
return false;
|
|
}
|
|
|
|
// Reset game state but keep essence and prestige count
|
|
const previousPrestigeCount = Game.state.prestigeCount || 0;
|
|
const previousEssence = Game.state.stellarEssence || 0;
|
|
const newEssence = previousEssence + essenceGain;
|
|
|
|
Game.state = {
|
|
stardust: 0,
|
|
totalStardust: 0,
|
|
totalClicks: 0,
|
|
clickPower: 1,
|
|
startTime: Date.now(),
|
|
lastSaveTime: Date.now(),
|
|
buildings: {},
|
|
upgrades: [],
|
|
achievements: [],
|
|
stellarEssence: newEssence,
|
|
prestigeCount: previousPrestigeCount + 1,
|
|
totalPrestigeEssence: (Game.state.totalPrestigeEssence || 0) + essenceGain,
|
|
prestigeUpgrades: Game.state.prestigeUpgrades || []
|
|
};
|
|
|
|
// Audio feedback (gated by the sound preference)
|
|
Game.playSound('prestige');
|
|
|
|
// Particle effect for prestige
|
|
const btn = document.getElementById('prestige-btn');
|
|
if (btn) {
|
|
const rect = btn.getBoundingClientRect();
|
|
Particles.createPrestigeEffect(rect.left + rect.width / 2, rect.top + rect.height / 2);
|
|
}
|
|
|
|
UI.showNotification(
|
|
`✦ Prestige! Earned ${essenceGain} Stellar Essence! (${newEssence} total)`,
|
|
'achievement'
|
|
);
|
|
|
|
UI.update();
|
|
return true;
|
|
},
|
|
|
|
/**
|
|
* Buy a prestige upgrade
|
|
*/
|
|
buyUpgrade(upgradeId) {
|
|
const upgrade = PRESTIGE_UPGRADES[upgradeId];
|
|
if (!upgrade || Game.state.prestigeUpgrades?.includes(upgradeId)) {
|
|
return false;
|
|
}
|
|
|
|
if (Game.state.stellarEssence >= upgrade.cost) {
|
|
Game.state.stellarEssence -= upgrade.cost;
|
|
Game.state.prestigeUpgrades = Game.state.prestigeUpgrades || [];
|
|
Game.state.prestigeUpgrades.push(upgradeId);
|
|
|
|
UI.showNotification(`Unlocked: ${upgrade.name}!`, 'achievement');
|
|
Game.playSound('purchase');
|
|
UI.update();
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
},
|
|
|
|
/**
|
|
* Get the effective click power with prestige bonus
|
|
*/
|
|
getEffectiveClickPower() {
|
|
const basePower = Game.getClickPower();
|
|
const multiplier = this.getMultiplier();
|
|
return Math.floor(basePower * multiplier);
|
|
},
|
|
|
|
/**
|
|
* Get the effective production per second with prestige bonus
|
|
*/
|
|
getEffectiveProductionPerSecond() {
|
|
const baseProduction = Game.getProductionPerSecond();
|
|
const multiplier = this.getMultiplier();
|
|
return baseProduction * multiplier;
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Prestige Upgrades - Permanent bonuses purchased with Stellar Essence
|
|
*/
|
|
const PRESTIGE_UPGRADES = {
|
|
cosmicFingers: {
|
|
id: 'cosmicFingers',
|
|
name: 'Cosmic Fingers',
|
|
description: 'Click power x2 (permanent)',
|
|
icon: '👆',
|
|
cost: 10,
|
|
effect: 'clickMultiplier',
|
|
value: 2
|
|
},
|
|
|
|
stellarTouch: {
|
|
id: 'stellarTouch',
|
|
name: 'Stellar Touch',
|
|
description: 'Click power x3 (permanent)',
|
|
icon: '✨',
|
|
cost: 50,
|
|
effect: 'clickMultiplier',
|
|
value: 3
|
|
},
|
|
|
|
essenceAmplifier: {
|
|
id: 'essenceAmplifier',
|
|
name: 'Essence Amplifier',
|
|
description: 'All production x1.5 (permanent)',
|
|
icon: '💎',
|
|
cost: 25,
|
|
effect: 'productionMultiplier',
|
|
value: 1.5
|
|
},
|
|
|
|
quantumGarden: {
|
|
id: 'quantumGarden',
|
|
name: 'Quantum Garden',
|
|
description: 'All production x2 (permanent)',
|
|
icon: '🌌',
|
|
cost: 100,
|
|
effect: 'productionMultiplier',
|
|
value: 2
|
|
},
|
|
|
|
acceleratedGrowth: {
|
|
id: 'acceleratedGrowth',
|
|
name: 'Accelerated Growth',
|
|
description: 'Buildings cost 10% less (permanent)',
|
|
icon: '📉',
|
|
cost: 75,
|
|
effect: 'costReduction',
|
|
value: 0.9
|
|
},
|
|
|
|
temporalManipulation: {
|
|
id: 'temporalManipulation',
|
|
name: 'Temporal Manipulation',
|
|
description: 'Offline earnings 75% (was 50%)',
|
|
icon: '⏰',
|
|
cost: 200,
|
|
effect: 'offlineBonus',
|
|
value: 0.75
|
|
}
|
|
};
|
|
|
|
window.PRESTIGE = PRESTIGE;
|
|
window.PRESTIGE_UPGRADES = PRESTIGE_UPGRADES;
|