Upload root files
Why the hell is there a limit of 5 files?? Signed-off-by: nif <nif@incremental.social>
This commit is contained in:
parent
8385d9f872
commit
5094f2ca57
3 changed files with 409 additions and 0 deletions
104
index.html
Normal file
104
index.html
Normal file
|
@ -0,0 +1,104 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<link rel="stylesheet" href="themes/dark.css" id="theme"/>
|
||||||
|
<link rel="stylesheet" href="style.css"/>
|
||||||
|
<title>Infinite Generators</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<br>
|
||||||
|
<div id="head">
|
||||||
|
<h1>Infinite Generators</h1>
|
||||||
|
<div id="tabs">
|
||||||
|
<button id="main-tab-btn"> Main tab </button>
|
||||||
|
<button id="condensed-btn" style="display: none;"> Condensed </button>
|
||||||
|
<button id="settings-btn"> Settings </button>
|
||||||
|
<button id="changelog-btn"> Changelog </button>
|
||||||
|
</div>
|
||||||
|
<h3>
|
||||||
|
You have <span id="pts">10.0</span> points.<br>
|
||||||
|
<span id="condensed-points">You have <span id="cpts">0.00</span> condensed points.</span>
|
||||||
|
</h3>
|
||||||
|
</div>
|
||||||
|
<div id="main-tab" style="display: block;">
|
||||||
|
<div id="ab-en-wrap" style="display: none;">
|
||||||
|
<button id="ab-en-btn">
|
||||||
|
Generator autobuyer is <span id="ab-en" style="color: greenyellow;">Enabled</span>
|
||||||
|
</button>
|
||||||
|
<br><br>
|
||||||
|
</div>
|
||||||
|
<table class="gens">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th> Generator # </th>
|
||||||
|
<th> Amount </th>
|
||||||
|
<th> Generation </th>
|
||||||
|
<th> Next Cost </th>
|
||||||
|
<th> Buy </th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody id="gens">
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div id="condensed" style="display: none;">
|
||||||
|
<button id="cond-btn"><h2>
|
||||||
|
Condense your generators for<br>+<span id="c-gain">0.00</span> Condensed Points
|
||||||
|
</h2></button><br><br>
|
||||||
|
<button style="padding: 8px;" id="cupg-0">
|
||||||
|
<b>Condensed Upgrade 1<br>Point Accelerator</b><br>
|
||||||
|
Raise point generation ^<span id="cupg-0-eff">1.00</span><br>
|
||||||
|
Cost: <span id="cupg-0-cost">1.00</span> Condensed Points
|
||||||
|
</button>
|
||||||
|
<button style="padding: 8px;" id="cupg-1">
|
||||||
|
<b>Condensed Upgrade 2<br>Generator Booster</b><br>
|
||||||
|
Multiply generator production by x<span id="cupg-1-eff">1.00</span><br>
|
||||||
|
Cost: <span id="cupg-1-cost">1.00</span> Condensed Points
|
||||||
|
</button><br>
|
||||||
|
<button style="padding: 8px;" id="cupg-2">
|
||||||
|
<b>Condensed Upgrade 3<br>Autobuyer</b><br>
|
||||||
|
Auto-buy the first <span id="cupg-2-eff">0.00</span> generator(s)<br>
|
||||||
|
Cost: <span id="cupg-2-cost">3.00</span> Condensed Points
|
||||||
|
</button>
|
||||||
|
<button style="padding: 8px;" id="cupg-3">
|
||||||
|
<b>Condensed Upgrade 4<br>Autobuyer Accelerator</b><br>
|
||||||
|
Multiply autobuyer speed x<span id="cupg-3-eff">1.00</span><br>
|
||||||
|
Cost: <span id="cupg-3-cost">8.00</span> Condensed Points
|
||||||
|
</button><br>
|
||||||
|
<button style="padding: 8px;" id="cupg-4">
|
||||||
|
<b>Condensed Upgrade 5<br>Condensed Optimizer</b><br>
|
||||||
|
Raise condensed point gain ^<span id="cupg-4-eff">1.00</span><br>
|
||||||
|
Cost: <span id="cupg-4-cost">15.0</span> Condensed Points
|
||||||
|
</button>
|
||||||
|
<button style="padding: 8px;" id="cupg-5">
|
||||||
|
<b>Condensed Upgrade 6<br>Multiplier booster</b><br>
|
||||||
|
Raise generator multipliers ^<span id="cupg-5-eff">1.00</span><br>
|
||||||
|
Cost: <span id="cupg-5-cost">22.5</span> Condensed Points
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div id="settings" style="display: none;">
|
||||||
|
<textarea id="save" rows="6" cols="50">Use this area to save and load your game</textarea><br>
|
||||||
|
<button id="save-game">Save your game</button>
|
||||||
|
<button id="load-game">Load your saved game</button>
|
||||||
|
<button id="wipe-game">Clear your saved game</button><br><br>
|
||||||
|
<select id="theme-sel">
|
||||||
|
<option value="dark">Dark theme</option>
|
||||||
|
<option value="blue">Blue theme</option>
|
||||||
|
<option value="light">Light theme</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
<div id="changelog" style="display: none;">
|
||||||
|
<h3>v1.0</h3>
|
||||||
|
<ul>
|
||||||
|
<li>Added points</li>
|
||||||
|
<li>Added generators</li>
|
||||||
|
<li>Added condensed points</li>
|
||||||
|
<li>Added 6 condensed upgrades</li>
|
||||||
|
<li>Added the autobuyer</li>
|
||||||
|
<li>Added 3 themes (dark, blue, light)</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
<script src="main.js"></script>
|
||||||
|
</html>
|
278
main.js
Normal file
278
main.js
Normal file
|
@ -0,0 +1,278 @@
|
||||||
|
// Player data
|
||||||
|
let player = {
|
||||||
|
points: 10,
|
||||||
|
condensed: 0,
|
||||||
|
gens: [0],
|
||||||
|
egens: [0],
|
||||||
|
cupgs: [0, 0, 0, 0],
|
||||||
|
abs: [],
|
||||||
|
unlocked: {
|
||||||
|
condensed: false,
|
||||||
|
autobuyer: false
|
||||||
|
},
|
||||||
|
abEnabled: true
|
||||||
|
|
||||||
|
}
|
||||||
|
let local = {
|
||||||
|
tab: "main-tab",
|
||||||
|
updates: [],
|
||||||
|
dontSave: false,
|
||||||
|
}
|
||||||
|
|
||||||
|
// General event listeners
|
||||||
|
document.getElementById("main-tab-btn").addEventListener("click", () => {
|
||||||
|
document.getElementById(local.tab).style = "display: none;"
|
||||||
|
local.tab = "main-tab"
|
||||||
|
document.getElementById("main-tab").style = "display: block;"
|
||||||
|
})
|
||||||
|
document.getElementById("condensed-btn").addEventListener("click", () => {
|
||||||
|
document.getElementById(local.tab).style = "display: none;"
|
||||||
|
local.tab = "condensed"
|
||||||
|
document.getElementById("condensed").style = "display: block;"
|
||||||
|
})
|
||||||
|
document.getElementById("settings-btn").addEventListener("click", () => {
|
||||||
|
document.getElementById(local.tab).style = "display: none;"
|
||||||
|
local.tab = "settings"
|
||||||
|
document.getElementById("settings").style = "display: block;"
|
||||||
|
})
|
||||||
|
document.getElementById("changelog-btn").addEventListener("click", () => {
|
||||||
|
document.getElementById(local.tab).style = "display: none;"
|
||||||
|
local.tab = "changelog"
|
||||||
|
document.getElementById("changelog").style = "display: block;"
|
||||||
|
})
|
||||||
|
|
||||||
|
// Generator functions
|
||||||
|
function getPointsPerSecond(gen = -1) {
|
||||||
|
if (gen > player.gens.length - 2) return 0
|
||||||
|
return ((player.egens[gen+1] + player.gens[gen+1]) * (Math.sqrt(player.gens[gen+1] + 1)
|
||||||
|
** Math.cbrt((player.cupgs[5] || 0) + 1))) * (2 ** (player.cupgs[1] || 0))
|
||||||
|
** (gen == -1 ? 1.2 ** (player.cupgs[0] || 0) : 1)
|
||||||
|
}
|
||||||
|
function pushGenerator() {
|
||||||
|
const index = player.gens.push(0) - 1
|
||||||
|
player.egens.push(0)
|
||||||
|
newGenerator(index)
|
||||||
|
}
|
||||||
|
function newGenerator(index) {
|
||||||
|
const cost = document.createElement("span")
|
||||||
|
cost.innerText = ((100 ** index * 10) * (1.5 ** player.gens[index])).toPrecision(3)
|
||||||
|
const buyBtn = document.createElement("button")
|
||||||
|
buyBtn.addEventListener("click", () => {
|
||||||
|
if ((100 ** index * 10) * (1.5 ** player.gens[index]) !== Number.POSITIVE_INFINITY
|
||||||
|
&& player.points >= (100 ** index * 10) * (1.5 ** player.gens[index])) {
|
||||||
|
player.points -= (100 ** index * 10) * (1.5 ** player.gens[index])
|
||||||
|
player.gens[index] ++
|
||||||
|
if (player.gens[index] == 10) { pushGenerator() }
|
||||||
|
}
|
||||||
|
})
|
||||||
|
buyBtn.innerText = "Buy"
|
||||||
|
const buyMaxBtn = document.createElement("button")
|
||||||
|
buyMaxBtn.addEventListener("click", () => {
|
||||||
|
while ((100 ** index * 10) * (1.5 ** player.gens[index]) !== Number.POSITIVE_INFINITY
|
||||||
|
&& player.points >= (100 ** index * 10) * (1.5 ** player.gens[index]) ) {
|
||||||
|
player.points -= (100 ** index * 10) * (1.5 ** player.gens[index])
|
||||||
|
player.gens[index] ++
|
||||||
|
if (player.gens[index] == 10) { pushGenerator() }
|
||||||
|
}
|
||||||
|
})
|
||||||
|
buyMaxBtn.innerText = "Buy Max"
|
||||||
|
const extra = document.createElement("span")
|
||||||
|
extra.innerText = 0
|
||||||
|
extra.id = "gen-" + index + "-extra"
|
||||||
|
const gens = document.createElement("span")
|
||||||
|
gens.innerText = 0
|
||||||
|
gens.id = "gen-" + index + "-gens"
|
||||||
|
const gener = document.createElement("span")
|
||||||
|
gener.innerText = getPointsPerSecond(index-1).toPrecision(3)
|
||||||
|
gener.id = "gen-" + index + "-gener"
|
||||||
|
|
||||||
|
const newRow = document.createElement("tr")
|
||||||
|
newRow.append(
|
||||||
|
(() => {
|
||||||
|
const el = document.createElement("td")
|
||||||
|
el.innerText = "Gen " + (index + 1)
|
||||||
|
return el
|
||||||
|
})(),
|
||||||
|
(() => {
|
||||||
|
const el = document.createElement("td")
|
||||||
|
el.append(gens, " + ", extra)
|
||||||
|
return el
|
||||||
|
})(),
|
||||||
|
(() => {
|
||||||
|
const el = document.createElement("td")
|
||||||
|
el.append(gener, "/s")
|
||||||
|
return el
|
||||||
|
})(),
|
||||||
|
(() => {
|
||||||
|
const el = document.createElement("td")
|
||||||
|
cost.id = "gen-" + index + "-cost"
|
||||||
|
el.append(cost, " points")
|
||||||
|
return el
|
||||||
|
})(),
|
||||||
|
(() => {
|
||||||
|
const el = document.createElement("td")
|
||||||
|
el.append(buyBtn, " ", buyMaxBtn)
|
||||||
|
return el
|
||||||
|
})(),
|
||||||
|
)
|
||||||
|
if (index % 2 == 0) newRow.className = "alt"
|
||||||
|
document.getElementById("gens").appendChild(newRow)
|
||||||
|
|
||||||
|
local.updates.push(function() {
|
||||||
|
extra.innerText = player.egens[index].toPrecision(3)
|
||||||
|
gens.innerText = player.gens[index].toPrecision(3)
|
||||||
|
gener.innerText = getPointsPerSecond(index-1).toPrecision(3)
|
||||||
|
cost.innerText = ((100 ** index * 10) * (1.5 ** player.gens[index])).toPrecision(3)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// Condensed functions
|
||||||
|
function condensedGain() {
|
||||||
|
return Math.sqrt(Math.max(0, player.gens.length - 24)) ** Math.sqrt((player.cupgs[4] || 0) + 1)
|
||||||
|
}
|
||||||
|
document.getElementById("cond-btn").addEventListener("click", () => {
|
||||||
|
if (condensedGain() == 0) return
|
||||||
|
player.condensed += condensedGain()
|
||||||
|
player.gens = [0]
|
||||||
|
player.egens = [0]
|
||||||
|
local.updates = []
|
||||||
|
player.points = 10
|
||||||
|
})
|
||||||
|
document.getElementById("cupg-0").addEventListener("click", () => {
|
||||||
|
if (player.condensed >= 1.3 ** (player.cupgs[0] || 0)) {
|
||||||
|
player.condensed -= 1.3 ** (player.cupgs[0] || 0)
|
||||||
|
player.cupgs[0] = (player.cupgs[0] || 0) + 1
|
||||||
|
}
|
||||||
|
})
|
||||||
|
document.getElementById("cupg-1").addEventListener("click", () => {
|
||||||
|
if (player.condensed >= 1.3 ** (player.cupgs[1] || 0)) {
|
||||||
|
player.condensed -= 1.3 ** (player.cupgs[1] || 0)
|
||||||
|
player.cupgs[1] = (player.cupgs[1] || 0) + 1
|
||||||
|
}
|
||||||
|
})
|
||||||
|
document.getElementById("cupg-2").addEventListener("click", () => {
|
||||||
|
if (player.condensed >= 3 * 1.6 ** (player.cupgs[2] || 0)) {
|
||||||
|
player.condensed -= 3 * 1.6 ** (player.cupgs[2] || 0)
|
||||||
|
player.cupgs[2] = (player.cupgs[2] || 0) + 1
|
||||||
|
player.abs.push(0)
|
||||||
|
player.unlocked.autobuyer = true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
document.getElementById("ab-en-btn").addEventListener("click", () => {
|
||||||
|
if (player.unlocked.autobuyer) player.abEnabled = !player.abEnabled
|
||||||
|
})
|
||||||
|
document.getElementById("cupg-3").addEventListener("click", () => {
|
||||||
|
if (player.condensed >= 8 * 2.2 ** (player.cupgs[3] || 0)) {
|
||||||
|
player.condensed -= 8 * 2.2 ** (player.cupgs[3] || 0)
|
||||||
|
player.cupgs[3] = (player.cupgs[3] || 0) + 1
|
||||||
|
}
|
||||||
|
})
|
||||||
|
document.getElementById("cupg-4").addEventListener("click", () => {
|
||||||
|
if (player.condensed >= 15 * 3 ** (player.cupgs[4] || 0)) {
|
||||||
|
player.condensed -= 15 * 3 ** (player.cupgs[4] || 0)
|
||||||
|
player.cupgs[4] = (player.cupgs[4] || 0) + 1
|
||||||
|
}
|
||||||
|
})
|
||||||
|
document.getElementById("cupg-5").addEventListener("click", () => {
|
||||||
|
if (player.condensed >= 22.5 * 4 ** (player.cupgs[5] || 0)) {
|
||||||
|
player.condensed -= 22.5 * 4 ** (player.cupgs[5] || 0)
|
||||||
|
player.cupgs[5] = (player.cupgs[5] || 0) + 1
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// Updates & game state
|
||||||
|
function saveGame() {
|
||||||
|
localStorage.setItem("nif's-infinite-generators", btoa(JSON.stringify(player)))
|
||||||
|
return btoa(JSON.stringify(player))
|
||||||
|
}
|
||||||
|
function loadGame(save = null) {
|
||||||
|
localStorage.setItem("nif's-infinite-generators", save)
|
||||||
|
local.dontSave = true
|
||||||
|
location.reload()
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById("save-game").addEventListener("click", () => {
|
||||||
|
document.getElementById("save").innerText = saveGame()
|
||||||
|
})
|
||||||
|
addEventListener("beforeunload", () => {
|
||||||
|
if (!local.dontSave) { saveGame() }
|
||||||
|
})
|
||||||
|
document.getElementById("load-game").addEventListener("click", () => {
|
||||||
|
loadGame(document.getElementById("save").innerText)
|
||||||
|
})
|
||||||
|
document.getElementById("wipe-game").addEventListener("click", () => {
|
||||||
|
if (event.getModifierState("Shift") ||
|
||||||
|
window.confirm("Are you sure you want to wipe your save file? This action is irreversible!")) {
|
||||||
|
localStorage.setItem("nif's-infinite-generators", btoa("{}"))
|
||||||
|
local.dontSave = true
|
||||||
|
location.reload()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
{
|
||||||
|
let falsePlayer = JSON.parse(atob(localStorage.getItem("nif's-infinite-generators")))
|
||||||
|
player = {...player, ...falsePlayer}
|
||||||
|
player.unlocked = {...player.unlocked, ...falsePlayer.unlocked}
|
||||||
|
player.cupgs = [...player.cupgs, ...falsePlayer.cupgs]
|
||||||
|
for (const i in player.gens) newGenerator(Number(i))
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateVars() {
|
||||||
|
const dt = 0.05
|
||||||
|
|
||||||
|
player.points += getPointsPerSecond() * dt
|
||||||
|
for (let i = 0; i < player.gens.length - 1; i ++) {
|
||||||
|
player.egens[i] += getPointsPerSecond(i) * dt
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player.gens.length >= 25) player.unlocked.condensed = true
|
||||||
|
|
||||||
|
if (player.abEnabled && player.unlocked.autobuyer) {
|
||||||
|
for (let k in player.abs) {
|
||||||
|
k = Number(k)
|
||||||
|
player.abs[k] += dt * Math.sqrt((player.cupgs[3] || 0) + 1)
|
||||||
|
let buys = Math.floor(player.abs / (2 * 3 ** k))
|
||||||
|
player.abs[k] %= 2 * 3 ** k
|
||||||
|
for (let w = 0; w < buys; w ++) {
|
||||||
|
if (player.points >= (100 ** k * 10) * (1.5 ** player.gens[k])) {
|
||||||
|
player.points -= (100 ** k * 10) * (1.5 ** player.gens[k])
|
||||||
|
player.gens[k] ++
|
||||||
|
if (player.gens[k] == 10) { pushGenerator() }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function updateDisplay() {
|
||||||
|
document.getElementById("pts").innerText = player.points.toPrecision(3)
|
||||||
|
for (const i of local.updates) i();
|
||||||
|
document.getElementById("cpts").innerText = player.condensed.toPrecision(3)
|
||||||
|
document.getElementById("c-gain").innerText = condensedGain().toPrecision(3)
|
||||||
|
if (player.unlocked.condensed) {
|
||||||
|
document.getElementById("condensed-btn").style = "display: inline;"
|
||||||
|
document.getElementById("condensed-points").style = "display: inline;"
|
||||||
|
}
|
||||||
|
if (player.unlocked.autobuyer) document.getElementById("ab-en-wrap").style = "display: inline;"
|
||||||
|
document.getElementById("theme").setAttribute("href", "themes/" + document.getElementById("theme-sel").value + ".css")
|
||||||
|
document.getElementById("ab-en").style = "color: var(--" + (player.abEnabled ? "good" : "bad") + ")"
|
||||||
|
document.getElementById("ab-en").innerText = (player.abEnabled ? "Enabled" : "Disabled")
|
||||||
|
|
||||||
|
document.getElementById("cupg-0-eff").innerText = (1.2 ** (player.cupgs[0] || 0)).toPrecision(3)
|
||||||
|
document.getElementById("cupg-0-cost").innerText = (1.3 ** (player.cupgs[0] || 0)).toPrecision(3)
|
||||||
|
document.getElementById("cupg-1-eff").innerText = (2 ** (player.cupgs[1] || 0)).toPrecision(3)
|
||||||
|
document.getElementById("cupg-1-cost").innerText = (1.3 ** (player.cupgs[1] || 0)).toPrecision(3)
|
||||||
|
document.getElementById("cupg-2-eff").innerText = (player.cupgs[2] || 0).toPrecision(3)
|
||||||
|
document.getElementById("cupg-2-cost").innerText = (3 * 1.6 ** (player.cupgs[2] || 0)).toPrecision(3)
|
||||||
|
document.getElementById("cupg-3-eff").innerText = (Math.sqrt((player.cupgs[3] || 0) + 1)).toPrecision(3)
|
||||||
|
document.getElementById("cupg-3-cost").innerText = (8 * 2.2 ** (player.cupgs[3] || 0)).toPrecision(3)
|
||||||
|
document.getElementById("cupg-4-eff").innerText = (Math.sqrt((player.cupgs[4] || 0) + 1)).toPrecision(3)
|
||||||
|
document.getElementById("cupg-4-cost").innerText = (15 * 3 ** (player.cupgs[4] || 0)).toPrecision(3)
|
||||||
|
document.getElementById("cupg-5-eff").innerText = (Math.cbrt((player.cupgs[5] || 0) + 1)).toPrecision(3)
|
||||||
|
document.getElementById("cupg-5-cost").innerText = (22.5 * 4 ** (player.cupgs[5] || 0)).toPrecision(3)
|
||||||
|
}
|
||||||
|
|
||||||
|
setInterval(function() {
|
||||||
|
updateVars()
|
||||||
|
updateDisplay()
|
||||||
|
}, 50)
|
||||||
|
setInterval(save, 60000)
|
27
style.css
Normal file
27
style.css
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
html {
|
||||||
|
background-color: var(--bg);
|
||||||
|
color: var(--text);
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
}
|
||||||
|
table.gens, table.gens thead {
|
||||||
|
text-align: center;
|
||||||
|
border: 1px solid var(--text);
|
||||||
|
border-collapse: collapse;
|
||||||
|
}
|
||||||
|
table.gens td, table.gens th {
|
||||||
|
border-left: 1px solid var(--text);
|
||||||
|
border-right: 1px solid var(--text);
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
table.gens tr.alt {
|
||||||
|
background-color: var(--bg-alt);
|
||||||
|
}
|
||||||
|
button, textarea, select {
|
||||||
|
background-color: var(--btn);
|
||||||
|
color: var(--text);
|
||||||
|
border: 2px solid var(--btn-bd)
|
||||||
|
}
|
||||||
|
button:hover {
|
||||||
|
background-color: var(--btn-hv);
|
||||||
|
}
|
Loading…
Reference in a new issue