309 lines
8.6 KiB
JavaScript
309 lines
8.6 KiB
JavaScript
/**
|
|
* Cosmic Garden - Achievement Definitions & Checker
|
|
*/
|
|
|
|
const ACHIEVEMENTS = {
|
|
// Click achievements
|
|
firstClick: {
|
|
id: 'firstClick',
|
|
name: 'First Contact',
|
|
description: 'Click for the first time',
|
|
icon: '👆',
|
|
condition: (state) => state.totalClicks >= 1
|
|
},
|
|
|
|
clicker: {
|
|
id: 'clicker',
|
|
name: 'Clicker',
|
|
description: 'Click 100 times',
|
|
icon: '🖱️',
|
|
condition: (state) => state.totalClicks >= 100
|
|
},
|
|
|
|
spammer: {
|
|
id: 'spammer',
|
|
name: 'Spam Finger',
|
|
description: 'Click 1,000 times',
|
|
icon: '🔥',
|
|
condition: (state) => state.totalClicks >= 1000
|
|
},
|
|
|
|
clickMaster: {
|
|
id: 'clickMaster',
|
|
name: 'Click Master',
|
|
description: 'Click 10,000 times',
|
|
icon: '⚡',
|
|
condition: (state) => state.totalClicks >= 10000
|
|
},
|
|
|
|
// Stardust achievements
|
|
dustCollector: {
|
|
id: 'dustCollector',
|
|
name: 'Dust Collector',
|
|
description: 'Earn 1,000 total stardust',
|
|
icon: '✨',
|
|
condition: (state) => state.totalStardust >= 1000
|
|
},
|
|
|
|
stardustMagnate: {
|
|
id: 'stardustMagnate',
|
|
name: 'Stardust Magnate',
|
|
description: 'Earn 100,000 total stardust',
|
|
icon: '💫',
|
|
condition: (state) => state.totalStardust >= 100000
|
|
},
|
|
|
|
cosmicTycoon: {
|
|
id: 'cosmicTycoon',
|
|
name: 'Cosmic Tycoon',
|
|
description: 'Earn 10,000,000 total stardust',
|
|
icon: '🌟',
|
|
condition: (state) => state.totalStardust >= 10000000
|
|
},
|
|
|
|
galaxyBaron: {
|
|
id: 'galaxyBaron',
|
|
name: 'Galaxy Baron',
|
|
description: 'Earn 1,000,000,000 total stardust',
|
|
icon: '👑',
|
|
condition: (state) => state.totalStardust >= 1000000000
|
|
},
|
|
|
|
// Building achievements
|
|
firstPlant: {
|
|
id: 'firstPlant',
|
|
name: 'First Plant',
|
|
description: 'Buy your first building',
|
|
icon: '🌱',
|
|
condition: (state) => Object.values(state.buildings).some(c => c >= 1)
|
|
},
|
|
|
|
gardenStart: {
|
|
id: 'gardenStart',
|
|
name: 'Garden Starter',
|
|
description: 'Own 10 total buildings',
|
|
icon: '🌿',
|
|
condition: (state) => Object.values(state.buildings).reduce((a, b) => a + b, 0) >= 10
|
|
},
|
|
|
|
gardenCenter: {
|
|
id: 'gardenCenter',
|
|
name: 'Garden Center',
|
|
description: 'Own 50 total buildings',
|
|
icon: '🏡',
|
|
condition: (state) => Object.values(state.buildings).reduce((a, b) => a + b, 0) >= 50
|
|
},
|
|
|
|
cosmicGarden: {
|
|
id: 'cosmicGarden',
|
|
name: 'Cosmic Garden',
|
|
description: 'Own 100 total buildings',
|
|
icon: '🌌',
|
|
condition: (state) => Object.values(state.buildings).reduce((a, b) => a + b, 0) >= 100
|
|
},
|
|
|
|
// Specific building achievements
|
|
sproutFarmer: {
|
|
id: 'sproutFarmer',
|
|
name: 'Sprout Farmer',
|
|
description: 'Own 25 Star Sprouts',
|
|
icon: '🌱',
|
|
condition: (state) => (state.buildings.starSprout || 0) >= 25
|
|
},
|
|
|
|
bloomGarden: {
|
|
id: 'bloomGarden',
|
|
name: 'Bloom Garden',
|
|
description: 'Own 25 Moon Blooms',
|
|
icon: '🌸',
|
|
condition: (state) => (state.buildings.moonBloom || 0) >= 25
|
|
},
|
|
|
|
solarPowered: {
|
|
id: 'solarPowered',
|
|
name: 'Solar Powered',
|
|
description: 'Own 25 Solar Leaves',
|
|
icon: '☀️',
|
|
condition: (state) => (state.buildings.solarLeaf || 0) >= 25
|
|
},
|
|
|
|
// Production achievements
|
|
steadyStream: {
|
|
id: 'steadyStream',
|
|
name: 'Steady Stream',
|
|
description: 'Reach 100 stardust/sec',
|
|
icon: '💧',
|
|
condition: (state) => Game.getProductionPerSecond() >= 100
|
|
},
|
|
|
|
rushingRiver: {
|
|
id: 'rushingRiver',
|
|
name: 'Rushing River',
|
|
description: 'Reach 1,000 stardust/sec',
|
|
icon: '🌊',
|
|
condition: (state) => Game.getProductionPerSecond() >= 1000
|
|
},
|
|
|
|
cosmicFlood: {
|
|
id: 'cosmicFlood',
|
|
name: 'Cosmic Flood',
|
|
description: 'Reach 100,000 stardust/sec',
|
|
icon: '🌊',
|
|
condition: (state) => Game.getProductionPerSecond() >= 100000
|
|
},
|
|
|
|
// Prestige achievements
|
|
firstPrestige: {
|
|
id: 'firstPrestige',
|
|
name: 'Cosmic Rebirth',
|
|
description: 'Prestige for the first time',
|
|
icon: '🌀',
|
|
condition: (state) => state.prestigeCount >= 1
|
|
},
|
|
|
|
stellarAdaptation: {
|
|
id: 'stellarAdaptation',
|
|
name: 'Stellar Adaptation',
|
|
description: 'Prestige 5 times',
|
|
icon: '⭐',
|
|
condition: (state) => state.prestigeCount >= 5
|
|
},
|
|
|
|
cosmicAscension: {
|
|
id: 'cosmicAscension',
|
|
name: 'Cosmic Ascension',
|
|
description: 'Prestige 10 times',
|
|
icon: '🌟',
|
|
condition: (state) => state.prestigeCount >= 10
|
|
},
|
|
|
|
eternalGardener: {
|
|
id: 'eternalGardener',
|
|
name: 'Eternal Gardener',
|
|
description: 'Earn 100 total Stellar Essence',
|
|
icon: '💎',
|
|
condition: (state) => state.totalPrestigeEssence >= 100
|
|
},
|
|
|
|
quantumGrowth: {
|
|
id: 'quantumGrowth',
|
|
name: 'Quantum Growth',
|
|
description: 'Earn 1,000 total Stellar Essence',
|
|
icon: '🔮',
|
|
condition: (state) => state.totalPrestigeEssence >= 1000
|
|
},
|
|
|
|
// Building milestone achievements
|
|
voidWeaver: {
|
|
id: 'voidWeaver',
|
|
name: 'Void Weaver',
|
|
description: 'Own 25 Void Ferns',
|
|
icon: '🌿',
|
|
condition: (state) => (state.buildings.voidFern || 0) >= 25
|
|
},
|
|
|
|
supernovaGrowth: {
|
|
id: 'supernovaGrowth',
|
|
name: 'Supernova Growth',
|
|
description: 'Own 25 Supernova Seeds',
|
|
icon: '💥',
|
|
condition: (state) => (state.buildings.supernovaSeed || 0) >= 25
|
|
},
|
|
|
|
// Click power achievements
|
|
powerfulHarvester: {
|
|
id: 'powerfulHarvester',
|
|
name: 'Powerful Harvester',
|
|
description: 'Reach 1,000 click power',
|
|
icon: '✋',
|
|
condition: (state) => Game.getClickPower() >= 1000
|
|
},
|
|
|
|
divineTouch: {
|
|
id: 'divineTouch',
|
|
name: 'Divine Touch',
|
|
description: 'Reach 10,000 click power',
|
|
icon: '🤚',
|
|
condition: (state) => Game.getClickPower() >= 10000
|
|
},
|
|
|
|
// Time-based achievement
|
|
dedicatedGardener: {
|
|
id: 'dedicatedGardener',
|
|
name: 'Dedicated Gardener',
|
|
description: 'Play for 1 hour total',
|
|
icon: '⏰',
|
|
condition: (state) => (Date.now() - state.startTime) >= 3600000
|
|
},
|
|
|
|
// Golden Starbloom achievements
|
|
firstGoldenBloom: {
|
|
id: 'firstGoldenBloom',
|
|
name: 'Lucky Bloom',
|
|
description: 'Claim your first Golden Starbloom',
|
|
icon: '⭐',
|
|
condition: (state) => (state.goldenBlooms.totalClaimed || 0) >= 1
|
|
},
|
|
|
|
goldenCollector: {
|
|
id: 'goldenCollector',
|
|
name: 'Golden Collector',
|
|
description: 'Claim 25 Golden Blooms',
|
|
icon: '🌟',
|
|
condition: (state) => (state.goldenBlooms.totalClaimed || 0) >= 25
|
|
},
|
|
|
|
goldenEnthusiast: {
|
|
id: 'goldenEnthusiast',
|
|
name: 'Golden Enthusiast',
|
|
description: 'Claim 100 Golden Blooms',
|
|
icon: '💛',
|
|
condition: (state) => (state.goldenBlooms.totalClaimed || 0) >= 100
|
|
}
|
|
};
|
|
|
|
const Achievements = {
|
|
/**
|
|
* Check all achievements and unlock new ones
|
|
*/
|
|
check() {
|
|
for (const [id, achievement] of Object.entries(ACHIEVEMENTS)) {
|
|
if (Game.state.achievements.includes(id)) continue;
|
|
|
|
if (achievement.condition(Game.state)) {
|
|
Game.state.achievements.push(id);
|
|
UI.showNotification(`Achievement: ${achievement.name}!`, 'achievement');
|
|
|
|
// Audio feedback (gated by the sound preference)
|
|
Game.playSound('achievement');
|
|
|
|
// Particle effect for achievement unlock
|
|
const countEl = document.querySelector('#achievements-tab h3');
|
|
if (countEl) {
|
|
const rect = countEl.getBoundingClientRect();
|
|
Particles.createAchievementEffect(rect.left + rect.width / 2, rect.top + rect.height / 2);
|
|
}
|
|
|
|
console.log(`🏆 Achievement unlocked: ${achievement.name}`);
|
|
}
|
|
}
|
|
},
|
|
|
|
/**
|
|
* Get achievement count
|
|
*/
|
|
getCount() {
|
|
return Game.state.achievements.length;
|
|
},
|
|
|
|
/**
|
|
* Get total achievements
|
|
*/
|
|
getTotal() {
|
|
return Object.keys(ACHIEVEMENTS).length;
|
|
}
|
|
};
|
|
|
|
window.ACHIEVEMENTS = ACHIEVEMENTS;
|
|
window.Achievements = Achievements;
|