-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpress.js
More file actions
39 lines (36 loc) · 1.42 KB
/
Copy pathpress.js
File metadata and controls
39 lines (36 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//Everything about presses
Game.pressCount = 0;
Game.pressPrice = 500;
Game.pressMakeCount = 1;
Game.pressCounterText = document.getElementById("pressCounterText");
Game.buyPressButton = document.getElementById("buyPressButton");
Game.updatePressBuyButton = function () {
document.getElementById("buyPressButton").innerHTML = `buy press (${Game.pressPrice})`;
}
// runs when you buy a press
Game.buyPress = function () {
if (Game.kiwis - Game.pressPrice >= 0) {
// remove and update kiwis
Game.kiwis -= Game.pressPrice;
Game.updateKiwiCounter();
// update press count
Game.pressCount += 1;
Game.updatePressCounter();
// some console msgs cause why not
console.log("press bought");
console.log(Game.pressCount + "press");
// calculate new pressPrice and flatten it
Game.pressPrice = Math.floor(Game.pressPrice * 1.8);
document.getElementById("buyPressButton").innerHTML = `buy press (${Game.pressPrice})`;
} else {
// let the player know how many kiwis left
let missingKiwis = Game.pressPrice - Game.kiwis;
alert(`You don't have enough kiwis (missing ${missingKiwis} kiwis)`);
}
};
setInterval(function () {
if (Game.pressCount > 0) {
Game.kiwis = Game.kiwis + Game.pressMakeCount * Game.pressCount;
Game.kiwiCounterText.innerHTML = `${formatter.format(Game.kiwis)} kiwis`;
}
}, 1000);