diff --git a/src/pages/CookieClicker.vue b/src/pages/CookieClicker.vue index 0727f08..249b032 100644 --- a/src/pages/CookieClicker.vue +++ b/src/pages/CookieClicker.vue @@ -3,47 +3,166 @@ import { computed, ref } from 'vue'; const cookies = ref(0); const buildings = ref([ - { name: 'Cursor', price: 15, cps: 0.1, count: 0}, - { name: 'Grandma', price: 100, cps: 1, count: 0}, - { name: 'Farm', price: 1000, cps: 10, count: 0}, - { name: 'Factory', price: 10_000, cps: 100, count: 0}, + { name: '🖱️Cursor', price: 15, cps: 0.1, count: 0, multiplier: 1 }, + { name: '👵🏻Grandma', price: 100, cps: 1, count: 0, multiplier: 1 }, + { name: '🚜Farm', price: 1000, cps: 10, count: 0, multiplier: 1 }, + { name: '🏭Factory', price: 10_000, cps: 100, count: 0, multiplier: 1 }, + { name: '⛰️Mine', price: 100_000, cps: 1000, count: 0, multiplier: 1 }, + { name: '🥼Laboratory', price: 1_000_000, cps: 10000, count: 0, multiplier: 1 }, + { name: '🚀Rocket', price: 10_000_000, cps: 10000, count: 0, multiplier: 1 }, + { name: '🌚Moon', price: 100_000_000, cps: 100000, count: 0, multiplier: 1 }, + { name: 'COMING SOON', price: 0, cps: 0.000000001, count: 0, multiplier: 1 }, ]); -function buyBuilding(building){ +function buyBuilding(building) { cookies.value -= building.price; - building.price += Math.ceil(building.price / 100 * 15); + building.price += Math.ceil(building.price * 0.15); building.count++; } -let cps = computed(() => { - let cps = 0; - buildings.value.forEach(building => { - cps+=building.cps*building.count; - }); - return cps; + +const cps = computed(() => { + return buildings.value.reduce((sum, b) => sum + (b.cps * b.count * b.multiplier), 0); }); -setInterval(()=>{ - cookies.value+=cps.value; - document.title ='🍪' + +cookies.value.toFixed(1) + ' Cookies!'; -},1000); +// 🍪 Golden cookie logic +const goldenCookieVisible = ref(false); +const goldenCookieBoost = ref(false); + +function spawnGoldenCookie() { + goldenCookieVisible.value = true; + setTimeout(() => goldenCookieVisible.value = false, 7000); +} + +function clickGoldenCookie() { + goldenCookieVisible.value = false; + goldenCookieBoost.value = true; + setTimeout(() => goldenCookieBoost.value = false, 10000); // 10 sec boost +} + +const upgrades = ref([ + { name: "🖱️Sticky Fingertips", cost: 100, building: "Cursor", applied: false }, + { name: "👵🏻Nana-nator 9000", cost: 500, building: "Grandma", applied: false }, + { name: "🚜Cookies on the Cob", cost: 2500, building: "Farm", applied: false }, + { name: "🏭Union-Busting Biscuits", cost: 15_000, building: "Factory", applied: false }, + { name: "⛰️I yearn for the mines", cost: 150_000, building: "Mine", applied: false }, + { name: "🥼Dough Matter Accelerator", cost: 1_500_000, building: "Laboratory", applied: false }, + { name: "🚀Fueling with Frosting", cost: 15_000_000, building: "Rocket", applied: false }, + { name: "🌚THE MOON", cost: 150_000_000, building: "Moon", applied: false }, +]); + +function buyUpgrade(upgrade) { + cookies.value -= upgrade.cost; + const target = buildings.value.find(b => b.name === upgrade.building); + if (target) target.multiplier *= 2; + upgrade.applied = true; +} + +const achievementNotifications = ref([]); // For achievement pop-ups + +const achievements = ref([ + { name: "Buy 10 Cursors", unlocked: false, condition: () => buildings.value.find(b => b.name === "🖱️Cursor")?.count >= 10 }, + { name: "Sticky Fingertips", unlocked: false, condition: () => upgrades.value.find(u => u.name === "🖱️Sticky Fingertips")?.applied }, + { name: "First Grandma", unlocked: false, condition: () => buildings.value.find(b => b.name === "👵🏻Grandma")?.count >= 1 }, + { name: "Cookie Tycoon", unlocked: false, condition: () => cookies.value >= 1_000_000 }, + { name: "Golden Clicker", unlocked: false, condition: () => goldenCookieBoost.value }, + { name: "Ultimate Comitment", unlocked: false, condition: () => buildings.value.find(b => b.name === "COMING SOON")?.count >= 3600000 }, +]); + +function checkAchievements() { + achievements.value.forEach(a => { + if (!a.unlocked && a.condition()) { + a.unlocked = true; + achievementNotifications.value.push(a.name); + setTimeout(() => { + const index = achievementNotifications.value.indexOf(a.name); + if (index !== -1) { + achievementNotifications.value.splice(index, 1); + } + }, 5000); // Show popup for 8 seconds then fade out + } + }); +} + +setInterval(() => { + cookies.value += goldenCookieBoost.value ? cps.value * 2 : cps.value; + document.title = '🍪 ' + cookies.value.toFixed(1) + ' Cookies!'; + if (Math.random() < 0.01 && !goldenCookieVisible.value) spawnGoldenCookie(); // 1% chance per second + checkAchievements(); +}, 1000); + \ No newline at end of file + + + +
+ +
+ 🎉 Achievement Unlocked: {{ msg }}! +
+
+
+ + +