Skip to content

Commit

Permalink
._.
Browse files Browse the repository at this point in the history
  • Loading branch information
Lucas-Plumb committed Mar 2, 2024
1 parent 8f5fc87 commit df0db40
Show file tree
Hide file tree
Showing 12 changed files with 92 additions and 301 deletions.
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
prepare:
tsc
tsc
cleancss --batch-suffix "" -O2 -b pages/*.css pages/dist
102 changes: 0 additions & 102 deletions pages/dist/buildings.js
Original file line number Diff line number Diff line change
@@ -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++;
Expand Down Expand Up @@ -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);
});
1 change: 0 additions & 1 deletion pages/dist/buildings.min.js

This file was deleted.

35 changes: 35 additions & 0 deletions pages/dist/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};
File renamed without changes.
4 changes: 2 additions & 2 deletions pages/src/index.html → pages/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ <h2>Hotdogs Per Second: <span id="passive">0</span></h2>
<button id="crispButton">Buy Extra Crispy Buns (5000 hotdogs)</button>
</div>
</div>
<script src="./dist/globals.min.js"></script>
<script defer src="./dist/buildings.min.js"></script>
<script src="./dist/globals.js"></script>
<script src="./dist/buildings.js"></script>
</div>
<div id="context" class="hide">
<h1>Main Menu</h1>
Expand Down
54 changes: 0 additions & 54 deletions pages/src/game.css

This file was deleted.

16 changes: 0 additions & 16 deletions pages/src/help.html

This file was deleted.

Loading

0 comments on commit df0db40

Please sign in to comment.