Created
September 27, 2021 18:07
-
-
Save Pedr1ch/774d3d4482ead7a2010f48a77596cd0e to your computer and use it in GitHub Desktop.
cr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Clicker Setting */ | |
var cr_ = { | |
Currency:0, | |
upgrades: { | |
catcoin_machine:{ | |
amount:0, | |
cost:20, | |
ccps:1, | |
hasun:false, | |
unlocked:5, | |
name:"Buy 1 Catcoin Machine." | |
}, | |
catcoin_factory:{ | |
amount:0, | |
cost:100, | |
ccps:5, | |
hasun:false, | |
unlocked:25, | |
name:"Buy 1 Catcoin Factory." | |
} | |
}, | |
acheivs:[{req:"cr_.Currency>0",gotten:false,text:"Congratulations! You got one Catcoin!"},{req:"cr_.Currency>9",text:"Congratulations! You got Ten Catcoins!"},{req:"cr_.Currency>299",text:"Congratulations! You got 300 Catcoins!"},{req:"cr_.upgrades.catcoin_machine.amount>9",text:"Congratulations! You got 10 Catcoin Machines!"},{req:"cr_.upgrades.catcoin_factory.amount>9",text:"Congratulations! You got 10 Catcoin Factories!"}] | |
} | |
var delay = 0; | |
var ccps = 0; | |
// Update Upgrade Count and Save Data to the cookies. | |
function update_upgrades(){ | |
var d = 0; | |
document.querySelector('#upgrades').innerHTML=""; | |
for(i in cr_.upgrades){ | |
if(cr_.upgrades[i].hasun){ | |
document.querySelector('#upgrades').innerHTML+= `<br> <button onclick="mine_clicked('${i}')">${cr_.upgrades | |
[i].name}</button><h3>you have ${numberformat.format(cr_.upgrades[i].amount)}. Cost: ${numberformat.format(cr_.upgrades[i].cost)}. Catcoins / s: ${cr_.upgrades[i].ccps}</h3>`; | |
d+= cr_.upgrades[i].ccps * cr_.upgrades[i].amount | |
} | |
} | |
ccps = d; | |
} | |
function mine_clicked(thing){ | |
if(cr_.upgrades[thing].cost <= cr_.Currency){ | |
cr_.Currency-= cr_.upgrades[thing].cost; | |
cr_.upgrades[thing].amount++; | |
cr_.upgrades[thing].cost += Math.round(cr_.upgrades[thing].cost*0.15) | |
update_upgrades() | |
} | |
} | |
// Cookie Set | |
function updatecount(){ | |
update_upgrades() | |
if(Cookies.get("cr_") !=null && Cookies.get("cr_") != "undefined"){ | |
var _cr = JSON.parse(Cookies.get("cr_")); | |
for(i in cr_.upgrades){ | |
if(cr_.upgrades[i] == null){ | |
cr_.upgrades[i] = cr_.upgrades[i] | |
}} | |
for(i in cr_.acheivs){ | |
if(cr_.acheivs[i] == null || cr_.acheivs[i].text != _cr.acheivs[i].text){ | |
_cr.acheivs[i] = cr_.acheivs[i] | |
} | |
} | |
cr_ = _cr | |
} | |
setInterval(() => { | |
for(i in cr_.upgrades){ | |
cr_.Currency+=cr_.upgrades[i].amount*cr_.upgrades[i].ccps/20 | |
} | |
for(i in cr_.acheivs){ | |
var b = new Function('return '+cr_.acheivs[i].req); | |
if(b() && !cr_.acheivs[i].gotten){ | |
cr_.acheivs[i].gotten = true; | |
document.querySelector("#acheivs").innerHTML+=`<br>ACHIEVEMENT UNLOCKED!<br>${cr_.acheivs[i].text}`; | |
} | |
} | |
document.querySelector('#CurrencyIdentifier').innerHTML = "You have "+numberformat.format( Number(String(cr_.Currency).split(".")[0]))+" Catcoins." | |
for(i in cr_.upgrades){ | |
if(!cr_.upgrades[i].hasun && cr_.upgrades[i].unlocked <= cr_.Currency){ | |
cr_.upgrades[i].hasun = true; | |
update_upgrades(); | |
} | |
} | |
delay++; | |
if(delay >= 40) { | |
Cookies.set("cr_",JSON.stringify(cr_), {expires: 100000}); | |
Cookies.set("_lt"); | |
delay = 0 | |
} | |
update_upgrades() | |
},50); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
cr