diff --git a/Makefile b/Makefile index b4cc687..b6c0a1c 100644 --- a/Makefile +++ b/Makefile @@ -1,2 +1,3 @@ prepare: - tsc \ No newline at end of file + tsc + cleancss --batch-suffix "" -O2 -b pages/*.css pages/dist \ No newline at end of file diff --git a/pages/dist/buildings.js b/pages/dist/buildings.js index fe87710..e6acf52 100644 --- a/pages/dist/buildings.js +++ b/pages/dist/buildings.js @@ -1,68 +1,4 @@ "use strict"; -const update = () => { - checkBuyables(); - clickCountElement != null ? clickCountElement.innerText = formatter.format(Number(clickCount.toFixed(2))) : null; - passiveClicksElement != null ? passiveClicksElement.innerText = formatter.format(Number(passiveClicks.toFixed(2))) : null; - bunCountElement != null ? bunCountElement.innerText = formatter.format(bunCount) : null; - bunPriceElement != null ? bunPriceElement.innerText = formatter.format(bunCost) : null; - dadCountElement != null ? dadCountElement.innerText = formatter.format(dadCount) : null; - dadPriceElement != null ? dadPriceElement.innerText = formatter.format(dadCost) : null; - grillCountElement != null ? grillCountElement.innerText = formatter.format(grillCount) : null; - grillPriceElement != null ? grillPriceElement.innerText = formatter.format(grillCost) : null; - farmCountElement != null ? farmCountElement.innerText = formatter.format(farmCount) : null; - farmPriceElement != null ? farmPriceElement.innerText = formatter.format(farmCost) : null; - facCountElement != null ? facCountElement.innerText = formatter.format(facCount) : null; - facPriceElement != null ? facPriceElement.innerText = formatter.format(facCost) : null; - bankCountElement != null ? bankCountElement.innerText = formatter.format(bankCount) : null; - bankPriceElement != null ? bankPriceElement.innerText = formatter.format(bankCost) : null; - freezerCountElement != null ? freezerCountElement.innerText = formatter.format(freezerCount) : null; - freezerPriceElement != null ? freezerPriceElement.innerText = formatter.format(freezerCost) : null; -}; -const save = () => { - const save = `{"Hotdogs":${clickCount},"HotdogsPerSecond":${passiveClicks},"Bun":{"Owned":${bunCount},"Rate":${bunRate},"Price": ${bunCost}},"Dad":{"Owned":${dadCount},"Rate":${dadRate},"Price":${dadCost}},"Grill":{"Owned": ${grillCount},"Rate": ${grillRate},"Price":${grillCost}},"Farm":{"Owned":${farmCost},"Rate":${farmRate},"Price":${farmCost}},"Factory":{"Owned":${facCount},"Rate":${facRate},"Price":${facCost}},"Bank":{"Owned":${bankCount},"Rate":${bankRate},"Price":${bankCost}},"Freezer":{"Owned":${freezerCount},"Rate":${freezerRate},"Price":${freezerCost}}}`; - const file = new File([`${save}`], "hotdog-clicker-save.json", { type: "application/json" }); - const url = window.URL.createObjectURL(file); - const a = document.createElement("a"); - a.href = url; - a.download = file.name; - a.click(); - window.URL.revokeObjectURL(url); - a.remove(); -}; -const load = (file) => { - const content = file.text().then(res => { - const json = JSON.parse(res); - console.log(json); - clickCount = json.Hotdogs || 0; - passiveClicks = json.HotdogsPerSecond || 0; - bunCount = json.Bun.Owned || 0; - bunRate = json.Bun.Rate || 0.2; - bunCost = json.Bun.Price || 10; - dadCount = json.Dad.Owned || 0; - dadRate = json.Dad.Rate || 2; - dadCost = json.Dad.Price || 100; - grillCount = json.Grill.Owned || 0; - grillRate = json.Grill.Rate || 2; - grillCost = json.Grill.Price || 100; - update(); - }); -}; -const checkBuyables = () => { - const worker = new Worker('./dist/check.js'); - worker.postMessage([ - clickCount, - { - bunImage: bunImage, - dadImage: dadImage, - grillImage: grillImage, - farmImage: farmImage, - facImage: facImage, - bankImage: bankImage, - freezerImage: freezerImage, - } - ]); - worker.terminate(); -}; hotdogButton === null || hotdogButton === void 0 ? void 0 : hotdogButton.addEventListener("click", function () { if (clickCountElement != null) { clickCount++; @@ -188,41 +124,3 @@ document.oncontextmenu = () => { }); return false; }; -if (wipe) - wipe.onclick = () => { - const willing = prompt("This action cannot be undone. You will lose all of your progress. Type 'wipe' to continue."); - if (willing === "wipe") { - clearInterval(ID); - localStorage.clear(); - load(); - ID = setInterval(() => { - if (clickCountElement != null) { - clickCount += passiveClicks / 10; - update(); - } - }, 100); - } - }; -if (saveBtn) - saveBtn.onclick = () => { - clearInterval(ID); - save(); - ID = setInterval(() => { - if (clickCountElement != null) { - clickCount += passiveClicks / 10; - update(); - } - }, 100); - }; -if (file != null && file.files != null) - file.addEventListener('input', () => { - var _a; - clearInterval(ID); - load((_a = file === null || file === void 0 ? void 0 : file.files) === null || _a === void 0 ? void 0 : _a.item(0)); - ID = setInterval(() => { - if (clickCountElement != null) { - clickCount += passiveClicks / 10; - update(); - } - }, 100); - }); diff --git a/pages/dist/buildings.min.js b/pages/dist/buildings.min.js deleted file mode 100644 index b535fa2..0000000 --- a/pages/dist/buildings.min.js +++ /dev/null @@ -1 +0,0 @@ -"use strict";const increment=1.3,increase=(e,t)=>e*increment+t/increment,wipe=document.getElementById("wipe"),saveBtn=document.getElementById("save"),loadBtn=document.getElementById("load"),file=document.querySelector("#file"),formatter=new Intl.NumberFormat("en-us",{minimumFractionDigits:2}),bunBuyable="./Can-Buy-Bun-Button.svg",bunUnBuyable="./Cant-Buy-Bun-Button.svg",dadBuyable="./Can-Buy-Dad-Button.svg",dadUnBuyable="./Cant-Buy-Dad-Button.svg",grillBuyable="./Can-Buy-Grill-Button.svg",grillUnBuyable="./Cant-Buy-Grill-Button.svg",farmBuyable="./Can-Buy-Farm-Button.svg",farmUnBuyable="./Cant-Buy-Farm-Button.svg",facBuyable="./Can-Buy-Fac-Button.svg",facUnBuyable="./Cant-Buy-Fac-Button.svg",bankBuyable="./Can-Buy-Bank-Button.svg",bankUnBuyable="./Cant-Buy-Bank-Button.svg",freezerBuyable="./Can-Buy-Freezer-Button.svg",freezerUnBuyable="./Cant-Buy-Freezer-Button.svg";let passiveClicks=0,clickCount=0,bunCount=0,dadCount=0,grillCount=0,farmCount=0,facCount=0,bankCount=0,freezerCount=0,bunCost=10,bunRate=.2,dadCost=100,dadRate=2,grillCost=500,grillRate=10,farmCost=5e3,farmRate=50,facCost=5e4,facRate=500,bankCost=25e4,bankRate=2500,freezerCost=1e6,freezerRate=15e3;const passiveClicksElement=document.getElementById("passive"),clickCountElement=document.getElementById("clickCount"),grillCountElement=document.getElementById("grillCount"),bunCountElement=document.getElementById("bunCount"),dadCountElement=document.getElementById("dadCount"),farmCountElement=document.getElementById("farmCount"),facCountElement=document.getElementById("dogFacCount"),bankCountElement=document.getElementById("dogBankCount"),freezerCountElement=document.getElementById("freezerCount"),hotdogButton=document.getElementById("hotdogButton"),bunButton=document.getElementById("bunButton"),dadButton=document.getElementById("dadButton"),grillButton=document.getElementById("grillButton"),farmButton=document.getElementById("farmButton"),facButton=document.getElementById("dogFacButton"),bankButton=document.getElementById("dogBankButton"),freezerButton=document.getElementById("freezerButton"),bunPriceElement=document.getElementById("bunPrice"),dadPriceElement=document.getElementById("dadPrice"),grillPriceElement=document.getElementById("grillPrice"),farmPriceElement=document.getElementById("farmPrice"),facPriceElement=document.getElementById("facPrice"),bankPriceElement=document.getElementById("bankPrice"),freezerPriceElement=document.getElementById("freezerPrice"),bunImage=document.getElementById("bunImg"),dadImage=document.getElementById("dadImg"),grillImage=document.getElementById("grillImg"),farmImage=document.getElementById("farmImg"),facImage=document.getElementById("facImg"),bankImage=document.getElementById("bankImg"),freezerImage=document.getElementById("freezerImg"),update=()=>{checkBuyables(),null!=clickCountElement&&(clickCountElement.innerText=formatter.format(Number(clickCount.toFixed(2)))),null!=passiveClicksElement&&(passiveClicksElement.innerText=formatter.format(Number(passiveClicks.toFixed(2)))),null!=bunCountElement&&(bunCountElement.innerText=formatter.format(bunCount)),null!=bunPriceElement&&(bunPriceElement.innerText=formatter.format(bunCost)),null!=dadCountElement&&(dadCountElement.innerText=formatter.format(dadCount)),null!=dadPriceElement&&(dadPriceElement.innerText=formatter.format(dadCost)),null!=grillCountElement&&(grillCountElement.innerText=formatter.format(grillCount)),null!=grillPriceElement&&(grillPriceElement.innerText=formatter.format(grillCost)),null!=farmCountElement&&(farmCountElement.innerText=formatter.format(farmCount)),null!=farmPriceElement&&(farmPriceElement.innerText=formatter.format(farmCost)),null!=facCountElement&&(facCountElement.innerText=formatter.format(facCount)),null!=facPriceElement&&(facPriceElement.innerText=formatter.format(facCost)),null!=bankCountElement&&(bankCountElement.innerText=formatter.format(bankCount)),null!=bankPriceElement&&(bankPriceElement.innerText=formatter.format(bankCost)),null!=freezerCountElement&&(freezerCountElement.innerText=formatter.format(freezerCount)),null!=freezerPriceElement&&(freezerPriceElement.innerText=formatter.format(freezerCost))},save=()=>{var e=`{"Hotdogs":${clickCount},"HotdogsPerSecond":${passiveClicks},"Bun":{"Owned":${bunCount},"Rate":${bunRate},"Price": ${bunCost}},"Dad":{"Owned":${dadCount},"Rate":${dadRate},"Price":${dadCost}},"Grill":{"Owned": ${grillCount},"Rate": ${grillRate},"Price":${grillCost}},"Farm":{"Owned":${farmCost},"Rate":${farmRate},"Price":${farmCost}},"Factory":{"Owned":${facCount},"Rate":${facRate},"Price":${facCost}},"Bank":{"Owned":${bankCount},"Rate":${bankRate},"Price":${bankCost}},"Freezer":{"Owned":${freezerCount},"Rate":${freezerRate},"Price":${freezerCost}}}`,e=new File([e],"hotdog-clicker-save.json",{type:"application/json"}),t=window.URL.createObjectURL(e),n=document.createElement("a");n.href=t,n.download=e.name,n.click(),window.URL.revokeObjectURL(t),n.remove()},load=e=>{e.text().then(e=>{e=JSON.parse(e);console.log(e),clickCount=e.Hotdogs||0,passiveClicks=e.HotdogsPerSecond||0,bunCount=e.Bun.Owned||0,bunRate=e.Bun.Rate||.2,bunCost=e.Bun.Price||10,dadCount=e.Dad.Owned||0,dadRate=e.Dad.Rate||2,dadCost=e.Dad.Price||100,grillCount=e.Grill.Owned||0,grillRate=e.Grill.Rate||2,grillCost=e.Grill.Price||100,update()})},checkBuyables=()=>{clickCount>=bunCost?bunImage.src=bunBuyable:bunImage.src=bunUnBuyable,clickCount>=dadCost?dadImage.src=dadBuyable:dadImage.src=dadUnBuyable,clickCount>=grillCost?grillImage.src=grillBuyable:grillImage.src=grillUnBuyable,clickCount>=farmCost?farmImage.src=farmBuyable:farmImage.src=farmUnBuyable,clickCount>=facCost?facImage.src=facBuyable:facImage.src=facUnBuyable,clickCount>=bankCost?bankImage.src=bankBuyable:bankImage.src=bankUnBuyable,clickCount>=freezerCost?freezerImage.src=freezerBuyable:freezerImage.src=freezerUnBuyable},mustardCost=(null!==hotdogButton&&void 0!==hotdogButton&&hotdogButton.addEventListener("click",function(){null!=clickCountElement?(clickCount++,update()):alert("Hotdog Clicker has encountered a fatal error.")}),null!==bunButton&&void 0!==bunButton&&bunButton.addEventListener("click",function(){clickCount>=bunCost&&null!=bunPriceElement&&null!=clickCountElement&&null!=bunCountElement&&null!=passiveClicksElement&&(clickCount-=bunCost,bunCost=increase(bunCost,bunCount),bunCount++,passiveClicks+=bunRate,update())}),null!==dadButton&&void 0!==dadButton&&dadButton.addEventListener("click",function(){clickCount>=dadCost&&null!=dadPriceElement&&null!=clickCountElement&&null!=dadCountElement&&null!=passiveClicksElement&&(clickCount-=dadCost,dadCost=increase(dadCost,dadCount),dadCount++,passiveClicks+=dadRate,update())}),null!==grillButton&&void 0!==grillButton&&grillButton.addEventListener("click",function(){clickCount>=grillCost&&null!=grillPriceElement&&null!=clickCountElement&&null!=grillCountElement&&null!=passiveClicksElement&&(clickCount-=grillCost,grillCost=increase(grillCost,grillCount),grillCount++,passiveClicks+=grillRate,update())}),null!==farmButton&&void 0!==farmButton&&farmButton.addEventListener("click",function(){clickCount>=farmCost&&null!=farmPriceElement&&null!=clickCountElement&&null!=farmCountElement&&null!=passiveClicksElement&&(clickCount-=farmCost,farmCost=increase(farmCost,farmCount),farmCount++,passiveClicks+=farmRate,update())}),null!==facButton&&void 0!==facButton&&facButton.addEventListener("click",function(){clickCount>=facCost&&null!=facPriceElement&&null!=clickCountElement&&null!=facCountElement&&null!=passiveClicksElement&&(clickCount-=facCost,facCost=increase(facCost,facCount),facCount++,passiveClicks+=facRate,update())}),null!==bankButton&&void 0!==bankButton&&bankButton.addEventListener("click",function(){clickCount>=bankCost&&null!=bankPriceElement&&null!=clickCountElement&&null!=bankCountElement&&null!=passiveClicksElement&&(clickCount-=bankCost,bankCost=increase(bankCost,bankCount),bankCount++,passiveClicks+=bankRate,update())}),null!==freezerButton&&void 0!==freezerButton&&freezerButton.addEventListener("click",function(){clickCount>=freezerCost&&null!=freezerPriceElement&&null!=freezerCountElement&&null!=clickCountElement&&null!=passiveClicksElement&&(clickCount-=freezerCost,freezerCost=increase(freezerCost,freezerCount),freezerCount++,passiveClicks+=freezerRate,update())}),5e3),tSauceCost=1e3,crispCost=5e3,tSauceButton=document.getElementById("tSauceButton"),mustardButton=document.getElementById("mustardButton"),crispButton=document.getElementById("crispButton");null!==tSauceButton&&void 0!==tSauceButton&&tSauceButton.addEventListener("click",function(){clickCount>=tSauceCost&&null!=clickCountElement&&null!=passiveClicksElement&&(clickCount-=tSauceCost,tSauceButton.style.display="none",passiveClicks+=25,update())}),null!==mustardButton&&void 0!==mustardButton&&mustardButton.addEventListener("click",function(){clickCount>=mustardCost&&null!=clickCountElement&&null!=passiveClicksElement&&(clickCount-=mustardCost,clickCountElement.textContent=clickCount.toFixed(2),mustardButton.style.display="none",passiveClicks+=50,update())}),null!==crispButton&&void 0!==crispButton&&crispButton.addEventListener("click",function(){clickCount>=crispCost&&null!=clickCountElement&&(clickCount-=crispCost,crispButton.style.display="none",bunRate*=2,update())});let ID=setInterval(()=>{null!=clickCountElement&&(clickCount+=passiveClicks/10,update())},100);document.oncontextmenu=()=>{var e;return null!=(e=document.getElementById("main"))&&e.setAttribute("class","blur display"),null!=(e=document.getElementById("context"))&&e.setAttribute("class","display"),window.onscroll=()=>!1,document.addEventListener("dblclick",()=>{var e;null!=(e=document.getElementById("main"))&&e.setAttribute("class","display"),null!=(e=document.getElementById("context"))&&e.setAttribute("class","hide"),window.onscroll=function(){}}),!1},wipe&&(wipe.onclick=()=>{"wipe"===prompt("This action cannot be undone. You will lose all of your progress. Type 'wipe' to continue.")&&(clearInterval(ID),localStorage.clear(),load(),ID=setInterval(()=>{null!=clickCountElement&&(clickCount+=passiveClicks/10,update())},100))}),saveBtn&&(saveBtn.onclick=()=>{clearInterval(ID),save(),ID=setInterval(()=>{null!=clickCountElement&&(clickCount+=passiveClicks/10,update())},100)}),null!=file&&null!=file.files&&file.addEventListener("input",()=>{var e;clearInterval(ID),load(null==(e=null===file||void 0===file?void 0:file.files)?void 0:e.item(0)),ID=setInterval(()=>{null!=clickCountElement&&(clickCount+=passiveClicks/10,update())},100)}); \ No newline at end of file diff --git a/pages/dist/globals.js b/pages/dist/globals.js index 0d0cce1..ebb6e01 100644 --- a/pages/dist/globals.js +++ b/pages/dist/globals.js @@ -76,3 +76,38 @@ const farmImage = document.getElementById("farmImg"); const facImage = document.getElementById("facImg"); const bankImage = document.getElementById("bankImg"); const freezerImage = document.getElementById("freezerImg"); +const update = () => { + checkBuyables(); + clickCountElement != null ? clickCountElement.innerText = formatter.format(Number(clickCount.toFixed(2))) : null; + passiveClicksElement != null ? passiveClicksElement.innerText = formatter.format(Number(passiveClicks.toFixed(2))) : null; + bunCountElement != null ? bunCountElement.innerText = formatter.format(bunCount) : null; + bunPriceElement != null ? bunPriceElement.innerText = formatter.format(bunCost) : null; + dadCountElement != null ? dadCountElement.innerText = formatter.format(dadCount) : null; + dadPriceElement != null ? dadPriceElement.innerText = formatter.format(dadCost) : null; + grillCountElement != null ? grillCountElement.innerText = formatter.format(grillCount) : null; + grillPriceElement != null ? grillPriceElement.innerText = formatter.format(grillCost) : null; + farmCountElement != null ? farmCountElement.innerText = formatter.format(farmCount) : null; + farmPriceElement != null ? farmPriceElement.innerText = formatter.format(farmCost) : null; + facCountElement != null ? facCountElement.innerText = formatter.format(facCount) : null; + facPriceElement != null ? facPriceElement.innerText = formatter.format(facCost) : null; + bankCountElement != null ? bankCountElement.innerText = formatter.format(bankCount) : null; + bankPriceElement != null ? bankPriceElement.innerText = formatter.format(bankCost) : null; + freezerCountElement != null ? freezerCountElement.innerText = formatter.format(freezerCount) : null; + freezerPriceElement != null ? freezerPriceElement.innerText = formatter.format(freezerCost) : null; +}; +const checkBuyables = () => { + const worker = new Worker('./dist/check.js'); + worker.postMessage([ + clickCount, + { + bunImage: bunImage, + dadImage: dadImage, + grillImage: grillImage, + farmImage: farmImage, + facImage: facImage, + bankImage: bankImage, + freezerImage: freezerImage, + } + ]); + worker.terminate(); +}; diff --git a/pages/src/index.css b/pages/index.css similarity index 100% rename from pages/src/index.css rename to pages/index.css diff --git a/pages/src/index.html b/pages/index.html similarity index 96% rename from pages/src/index.html rename to pages/index.html index 33017bf..dcfb856 100644 --- a/pages/src/index.html +++ b/pages/index.html @@ -66,8 +66,8 @@

Hotdogs Per Second: 0

- - + +

Main Menu

diff --git a/pages/src/game.css b/pages/src/game.css deleted file mode 100644 index b53cab7..0000000 --- a/pages/src/game.css +++ /dev/null @@ -1,54 +0,0 @@ -h1, -h2, -h3, -h4, -h5, -h6, -b, -p, -label, -span, -button { - font-family: arial, sans-serif, system-ui; - color: white; - transition-duration: 0.5s; -} - -body { - background-color: #101010; -} - -button { - background-color: transparent; - border-color: transparent; -} - -#wipe { - color: crimson; -} - -#save { - color: lawngreen; -} - -.display { - opacity: 1; - transition-duration: 1s; -} - -.hide { - opacity: 0; - transition-duration: 1s; -} - -.blur { - filter: blur(1rem); - transition-duration: 1s; -} - -#context { - position: absolute; - top: 50%; - right: 50%; - transform: translate(50%, -50%); -} diff --git a/pages/src/help.html b/pages/src/help.html deleted file mode 100644 index a0f914a..0000000 --- a/pages/src/help.html +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - Hotdog Clicker -- Help - - - - -

Hotdog Clicker -- Help

-

Right click to access the main menu. Click the hotdog to earn hotdogs. Click on the item buttons to buy the item.

- - - \ No newline at end of file diff --git a/pages/src/ts/buildings.ts b/pages/ts/buildings.ts similarity index 50% rename from pages/src/ts/buildings.ts rename to pages/ts/buildings.ts index 9f3f436..1cf5d42 100644 --- a/pages/src/ts/buildings.ts +++ b/pages/ts/buildings.ts @@ -1,87 +1,3 @@ -const update = (): void => { - checkBuyables() - - clickCountElement != null ? clickCountElement.innerText = formatter.format(Number(clickCount.toFixed(2))) : null - passiveClicksElement != null ? passiveClicksElement.innerText = formatter.format(Number(passiveClicks.toFixed(2))) : null - - bunCountElement != null ? bunCountElement.innerText = formatter.format(bunCount) : null - bunPriceElement != null ? bunPriceElement.innerText = formatter.format(bunCost) : null - - dadCountElement != null ? dadCountElement.innerText = formatter.format(dadCount) : null - dadPriceElement != null ? dadPriceElement.innerText = formatter.format(dadCost) : null - - grillCountElement != null ? grillCountElement.innerText = formatter.format(grillCount) : null - grillPriceElement != null ? grillPriceElement.innerText = formatter.format(grillCost) : null - - farmCountElement != null ? farmCountElement.innerText = formatter.format(farmCount) : null - farmPriceElement != null ? farmPriceElement.innerText = formatter.format(farmCost) : null - - facCountElement != null ? facCountElement.innerText = formatter.format(facCount) : null - facPriceElement != null ? facPriceElement.innerText = formatter.format(facCost) : null - - bankCountElement != null ? bankCountElement.innerText = formatter.format(bankCount) : null - bankPriceElement != null ? bankPriceElement.innerText = formatter.format(bankCost) : null - - freezerCountElement != null ? freezerCountElement.innerText = formatter.format(freezerCount) : null - freezerPriceElement != null ? freezerPriceElement.innerText = formatter.format(freezerCost) : null -} - -const save = (): void => { - const save = `{"Hotdogs":${clickCount},"HotdogsPerSecond":${passiveClicks},"Bun":{"Owned":${bunCount},"Rate":${bunRate},"Price": ${bunCost}},"Dad":{"Owned":${dadCount},"Rate":${dadRate},"Price":${dadCost}},"Grill":{"Owned": ${grillCount},"Rate": ${grillRate},"Price":${grillCost}},"Farm":{"Owned":${farmCost},"Rate":${farmRate},"Price":${farmCost}},"Factory":{"Owned":${facCount},"Rate":${facRate},"Price":${facCost}},"Bank":{"Owned":${bankCount},"Rate":${bankRate},"Price":${bankCost}},"Freezer":{"Owned":${freezerCount},"Rate":${freezerRate},"Price":${freezerCost}}}` - const file = new File([`${save}`], "hotdog-clicker-save.json", { type: "application/json" }) - const url = window.URL.createObjectURL(file) - const a = document.createElement("a") - a.href = url - a.download = file.name - a.click(); - window.URL.revokeObjectURL(url); - a.remove() -} - -const load: Function = (file: File): void => { - const content = file.text().then(res => { - const json = JSON.parse(res) - console.log(json) - - clickCount = json.Hotdogs || 0 - passiveClicks = json.HotdogsPerSecond || 0 - - bunCount = json.Bun.Owned || 0 - bunRate = json.Bun.Rate || 0.2 - bunCost = json.Bun.Price || 10 - - dadCount = json.Dad.Owned || 0 - dadRate = json.Dad.Rate || 2 - dadCost = json.Dad.Price || 100 - - grillCount = json.Grill.Owned || 0 - grillRate = json.Grill.Rate || 2 - grillCost = json.Grill.Price || 100 - - update() - }) -} - -const checkBuyables = () => { - const worker = new Worker('./dist/check.js') - - worker.postMessage([ - clickCount, - { - bunImage: bunImage, - dadImage: dadImage, - grillImage: grillImage, - farmImage: farmImage, - facImage: facImage, - bankImage: bankImage, - freezerImage: freezerImage, - - } - ]); - - worker.terminate(); -} - hotdogButton?.addEventListener("click", function () { if (clickCountElement != null) { clickCount++ @@ -214,40 +130,4 @@ document.oncontextmenu = () => { window.onscroll = function() {}; }) return false; -} - -if (wipe) wipe.onclick = () => { - const willing = prompt("This action cannot be undone. You will lose all of your progress. Type 'wipe' to continue.") - if (willing === "wipe") { - clearInterval(ID) - localStorage.clear(); - load() - ID = setInterval(() => { - if (clickCountElement != null) { - clickCount += passiveClicks / 10; - update(); - } - }, 100) - } -} - -if (saveBtn) saveBtn.onclick = () => { - clearInterval(ID) - save() - ID = setInterval(() => { - if (clickCountElement != null) { - clickCount += passiveClicks / 10; - update(); - } - }, 100) -} -if (file != null && file.files != null) file.addEventListener('input', () => { - clearInterval(ID) - load(file?.files?.item(0)) - ID = setInterval(() => { - if (clickCountElement != null) { - clickCount += passiveClicks / 10; - update(); - } - }, 100) -}) +} \ No newline at end of file diff --git a/pages/src/ts/check.ts b/pages/ts/check.ts similarity index 100% rename from pages/src/ts/check.ts rename to pages/ts/check.ts diff --git a/pages/src/ts/globals.ts b/pages/ts/globals.ts similarity index 69% rename from pages/src/ts/globals.ts rename to pages/ts/globals.ts index 9ce1f11..fe9bdad 100644 --- a/pages/src/ts/globals.ts +++ b/pages/ts/globals.ts @@ -97,4 +97,52 @@ const grillImage: HTMLImageElement = document.getElementById("grillImg") as HTML const farmImage: HTMLImageElement = document.getElementById("farmImg") as HTMLImageElement const facImage: HTMLImageElement = document.getElementById("facImg") as HTMLImageElement const bankImage: HTMLImageElement = document.getElementById("bankImg") as HTMLImageElement -const freezerImage: HTMLImageElement = document.getElementById("freezerImg") as HTMLImageElement \ No newline at end of file +const freezerImage: HTMLImageElement = document.getElementById("freezerImg") as HTMLImageElement + +const update = (): void => { + checkBuyables() + + clickCountElement != null ? clickCountElement.innerText = formatter.format(Number(clickCount.toFixed(2))) : null + passiveClicksElement != null ? passiveClicksElement.innerText = formatter.format(Number(passiveClicks.toFixed(2))) : null + + bunCountElement != null ? bunCountElement.innerText = formatter.format(bunCount) : null + bunPriceElement != null ? bunPriceElement.innerText = formatter.format(bunCost) : null + + dadCountElement != null ? dadCountElement.innerText = formatter.format(dadCount) : null + dadPriceElement != null ? dadPriceElement.innerText = formatter.format(dadCost) : null + + grillCountElement != null ? grillCountElement.innerText = formatter.format(grillCount) : null + grillPriceElement != null ? grillPriceElement.innerText = formatter.format(grillCost) : null + + farmCountElement != null ? farmCountElement.innerText = formatter.format(farmCount) : null + farmPriceElement != null ? farmPriceElement.innerText = formatter.format(farmCost) : null + + facCountElement != null ? facCountElement.innerText = formatter.format(facCount) : null + facPriceElement != null ? facPriceElement.innerText = formatter.format(facCost) : null + + bankCountElement != null ? bankCountElement.innerText = formatter.format(bankCount) : null + bankPriceElement != null ? bankPriceElement.innerText = formatter.format(bankCost) : null + + freezerCountElement != null ? freezerCountElement.innerText = formatter.format(freezerCount) : null + freezerPriceElement != null ? freezerPriceElement.innerText = formatter.format(freezerCost) : null +} + +const checkBuyables = () => { + const worker = new Worker('./dist/check.js') + + worker.postMessage([ + clickCount, + { + bunImage: bunImage, + dadImage: dadImage, + grillImage: grillImage, + farmImage: farmImage, + facImage: facImage, + bankImage: bankImage, + freezerImage: freezerImage, + + } + ]); + + worker.terminate(); +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 7534269..f75bdf4 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -55,7 +55,7 @@ // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ - "outDir": "./pages/dist", /* Specify an output folder for all emitted files. */ + "outDir": "pages/dist", /* Specify an output folder for all emitted files. */ // "removeComments": true, /* Disable emitting comments. */ // "noEmit": true, /* Disable emitting files from a compilation. */ // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ @@ -107,6 +107,6 @@ "skipLibCheck": true /* Skip type checking all .d.ts files. */ }, "include": [ - "./pages/src/ts/*.ts" - ] + "pages/ts/*.ts" +, "buildings.ts" ] }