58 lines
1.4 KiB
JavaScript
58 lines
1.4 KiB
JavaScript
let mood = 0;
|
|
let moodPerClick = 1;
|
|
|
|
const moodCounter = document.getElementById('mood-counter');
|
|
const favicon = document.getElementById('favicon');
|
|
|
|
function updateMoodCounter() {
|
|
moodCounter.innerText = mood;
|
|
|
|
if (mood < 100) {
|
|
favicon.setAttribute('href', './assets/favicons/1.ico');
|
|
} else if (mood < 1e3) {
|
|
favicon.setAttribute('href', './assets/favicons/2.ico');
|
|
} else if (mood < 1e5) {
|
|
favicon.setAttribute('href', './assets/favicons/3.ico');
|
|
} else if (mood < 1e9) {
|
|
favicon.setAttribute('href', './assets/favicons/4.ico');
|
|
} else if (mood < 1e16) {
|
|
favicon.setAttribute('href', './assets/favicons/5.ico');
|
|
} else if (mood < 1e19) {
|
|
favicon.setAttribute('href', './assets/favicons/6.ico');
|
|
} else if (mood < 1e22) {
|
|
favicon.setAttribute('href', './assets/favicons/7.ico');
|
|
}
|
|
}
|
|
|
|
function onLiftMoodClick() {
|
|
mood += moodPerClick;
|
|
updateMoodCounter();
|
|
}
|
|
|
|
function purchaseUpgrade(id) {
|
|
const upgrade = upgrades.filter((upgrade) => upgrade.id === id)[0];
|
|
|
|
if (mood >= upgrade.cost) {
|
|
mood -= upgrade.cost;
|
|
updateMoodCounter();
|
|
upgrade.onPurchase();
|
|
}
|
|
}
|
|
|
|
// UPGRADES
|
|
|
|
const upgrades = [
|
|
{
|
|
id: 'mood_lifter',
|
|
name: 'Mood Lifter',
|
|
description: 'Lift your Mood. +5/Click.',
|
|
image: '../assets/img/upgrades/mood_lifter.png',
|
|
cost: 50,
|
|
onPurchase: moodLifterUpgrade,
|
|
},
|
|
];
|
|
|
|
function moodLifterUpgrade() {
|
|
moodPerClick = 5;
|
|
}
|