Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (async function IncrementalityGame() {
- /* ═══════════════════════════════════════════════
- INCREMENTALLITY v1.4.3D
- ═══════════════════════════════════════════════ */
- await new Promise((res, rej) => {
- if (typeof Decimal !== "undefined") return res();
- const s = document.createElement("script");
- s.src = "https://cdn.jsdelivr.net/npm/break_eternity.js";
- s.onload = res;
- s.onerror = () => {
- const s2 = document.createElement("script");
- s2.src = "https://unpkg.com/break_eternity.js";
- s2.onload = res;
- s2.onerror = rej;
- document.head.appendChild(s2);
- };
- document.head.appendChild(s);
- });
- const D = v => new Decimal(v);
- const COOLDOWN = 5;
- const WIN_W = 62;
- const WIN_H = 28; // Increased height to 28
- const UPG_PER_PAGE = 3;
- let running = false;
- let stopped = false;
- let instantMode = false;
- let points = D(0);
- let pointGain = D(1);
- let gx = 0, gy = 0;
- let selfSending = false;
- let currentPage = 1;
- let renderBusy = false;
- // Mechanics flags
- let automationOn = false;
- let boosterOn = false;
- let fullAutoOn = false;
- let rbPointBoost = false;
- let rbDoubler = false;
- let rbX2Level = 0;
- let rbRaiserLevel = 0;
- let rbMaximizer = false;
- let breakerActive = false; // Breaker prestige upgrade (breaks hardcaps)
- // Prestige Layers
- let rebirths = 0;
- let increments = D(0);
- let greaterGainMul = D(1);
- // Anti-Inc Prestige Layer (CID 5)
- let antiInc = D(0);
- let autoIncActive = false;
- // Quantum Layer (CID 1)
- let quantumPoints = D(0);
- let antiIncToPtsActive = false; // Q1 Upgrade
- let atomicizeUnlocked = false; // Q2 Upgrade
- // Atomic Layer
- let proton = D(0); // CID 11
- let neutron = D(0); // CID 4 (unlocked at 100 Proton)
- let electron = D(0); // CID 8 (unlocked at 100 Neutron)
- const timers = [];
- const rebirthPages = [];
- // Global Rate Limiter for 600 char/s Instant Mode
- let lastWriteTime = performance.now();
- let writeTokens = 0;
- const MAX_TOKENS = 50; // Burst budget capacity
- const CHARS_PER_MS = 600 / 1000; // 0.6 characters per ms = 600 chars/sec
- // Command Deduplication History
- const commandExecutionHistory = new Map();
- /* ══════════════════════════════════════
- SOFTCAP & HARDCAP SYSTEM
- ══════════════════════════════════════ */
- const SOFTCAP_THRESHOLDS = {
- 1: { sc:50, sc2:500, sc3:5000, hc:50000 },
- 2: { sc:30, sc2:300, sc3:3000, hc:30000 },
- 3: { sc:40, sc2:400, sc3:4000, hc:40000 },
- 4: { sc:1, sc2:1, sc3:1, hc:1 },
- 5: { sc:20, sc2:200, sc3:2000, hc:20000 },
- 6: { sc:1, sc2:1, sc3:1, hc:1 },
- 7: { sc:25, sc2:250, sc3:2500, hc:25000 }
- };
- const INC_SOFTCAPS = {
- sc: D("1e20"),
- sc2: D("1e40"),
- sc3: D("1e60"),
- hc: D("1e80")
- };
- function getSoftcapLabel(upgId, level) {
- const t = SOFTCAP_THRESHOLDS[upgId];
- if (!t) return "";
- if (level >= t.hc && !breakerActive) return " [HARDCAP]";
- if (level >= t.sc3) return " [SC^3]";
- if (level >= t.sc2) return " [SC^2]";
- if (level >= t.sc) return " [SC]";
- return "";
- }
- function getCostMultiplier(upgId, level) {
- const t = SOFTCAP_THRESHOLDS[upgId];
- if (!t) return 1;
- if (level >= t.sc3) return 8;
- if (level >= t.sc2) return 4;
- if (level >= t.sc) return 2;
- return 1;
- }
- function isHardcapped(upgId, level) {
- if (breakerActive) return false; // Breaker breaks hardcap limit entirely
- const t = SOFTCAP_THRESHOLDS[upgId];
- if (!t) return false;
- return level >= t.hc;
- }
- function applyIncSoftcap(raw) {
- raw = D(raw);
- if (raw.gte(INC_SOFTCAPS.hc)) return INC_SOFTCAPS.hc;
- if (raw.gte(INC_SOFTCAPS.sc3)) {
- const over = raw.div(INC_SOFTCAPS.sc3);
- return INC_SOFTCAPS.sc3.mul(over.pow(0.125));
- }
- if (raw.gte(INC_SOFTCAPS.sc2)) {
- const over = raw.div(INC_SOFTCAPS.sc2);
- return INC_SOFTCAPS.sc2.mul(over.pow(0.25));
- }
- if (raw.gte(INC_SOFTCAPS.sc)) {
- const over = raw.div(INC_SOFTCAPS.sc);
- return INC_SOFTCAPS.sc.mul(over.pow(0.5));
- }
- return raw;
- }
- function getIncSoftcapLabel(raw) {
- raw = D(raw);
- if (raw.gte(INC_SOFTCAPS.hc)) return " [HC]";
- if (raw.gte(INC_SOFTCAPS.sc3)) return " [SC^3]";
- if (raw.gte(INC_SOFTCAPS.sc2)) return " [SC^2]";
- if (raw.gte(INC_SOFTCAPS.sc)) return " [SC]";
- return "";
- }
- /* ══════════════════════════════════════
- UPGRADE DEFINITIONS
- ══════════════════════════════════════ */
- function defaultUpgrades() {
- return [
- { id:1, name:"Increase point gain", cost:D(10), level:0, scaling:1.5, maxBuy:-1 },
- { id:2, name:"Multiplication (x3)", cost:D(50), level:0, scaling:2.5, maxBuy:-1 },
- { id:3, name:"Cheaper stuff (/1.5)", cost:D(100), level:0, scaling:3, maxBuy:-1 },
- { id:4, name:"Automation [ONE-TIME]", cost:D(1000), level:0, scaling:1, maxBuy:1 },
- { id:5, name:"Exponentiation (^1.1)", cost:D(17500), level:0, scaling:3, maxBuy:-1 },
- { id:6, name:"Booster [ONE-TIME]", cost:D(1e5), level:0, scaling:1, maxBuy:1 },
- { id:7, name:"Greater Gain (+25%)", cost:D(1e7), level:0, scaling:4, maxBuy:-1 }
- ];
- }
- function defaultRebirthUpgrades() {
- return [
- { id:"R1", name:"Point Booster [1x]", cost:D(10), level:0, scaling:1, maxBuy:1, desc:"Boost pts by Inc count" },
- { id:"R2", name:"Full Automation [1x]", cost:D(30), level:0, scaling:1, maxBuy:1, desc:"Auto 50 lvls every 10s" },
- { id:"R3", name:"Doubler [1x]", cost:D(100), level:0, scaling:1, maxBuy:1, desc:"Double rebirth Inc gain" },
- { id:"R4", name:"x2 Rebirth Gain", cost:D(50), level:0, scaling:2.5, maxBuy:-1, desc:"x2 Inc gain (stacks)" },
- { id:"R5", name:"Raiser (^1.4)", cost:D(150), level:0, scaling:2.0, maxBuy:30, desc:"^1.4 Point gain scaling" },
- { id:"R6", name:"Maximizer [ONE-TIME]", cost:D(500), level:0, scaling:1, maxBuy:1, desc:"+150 Lvls to R1-R5 free" }
- ];
- }
- function defaultAntiIncUpgrades() {
- return [
- { id:"A1", name:"Auto-Inc Conversion", cost:D(1), level:0, maxBuy:1, desc:"Convert Pts to passive Inc" },
- { id:"A2", name:"Breaker [ONE-TIME]", cost:D(10), level:0, maxBuy:1, desc:"Breaks all normal upgrade hardcaps" }
- ];
- }
- function defaultQuantumUpgrades() {
- return [
- { id:"Q1", name:"Anti Inc to Pts", cost:D(1), level:0, maxBuy:1, desc:"Boosts Anti-Inc gain by Pts" },
- { id:"Q2", name:"Atomicize", cost:D(10), level:0, maxBuy:1, desc:"Unlocks the Atomic Layer" }
- ];
- }
- let upgrades = defaultUpgrades();
- let rebirthUpgrades = defaultRebirthUpgrades();
- let antiIncUpgrades = defaultAntiIncUpgrades();
- let quantumUpgrades = defaultQuantumUpgrades();
- /* ══════════════════════════════════════
- HELPERS
- ══════════════════════════════════════ */
- const sleep = ms => new Promise(r => setTimeout(r, ms));
- function formatNum(n) {
- n = D(n);
- if (n.isNan()) return "NaN";
- if (!n.isFinite()) return "Inf";
- if (n.eq(0)) return "0";
- if (n.lt(0)) return "-" + formatNum(n.neg());
- if (n.lt(1e4)) {
- const v = n.toNumber();
- if (Math.abs(v - Math.round(v)) < 0.005) return String(Math.round(v));
- return v.toFixed(2);
- }
- if (n.layer > 1) return n.toString();
- const exp = n.log10().floor();
- const man = n.div(Decimal.pow(10, exp));
- return man.toNumber().toFixed(2) + "e" + exp.toNumber();
- }
- function roundCost(d) {
- d = D(d);
- if (d.lt(0.01)) return D(0.01);
- if (d.lt(1e13)) return D(Math.round(d.toNumber() * 100) / 100);
- return d.floor();
- }
- function fit(s, ww) { return s.length >= ww ? s.slice(0, ww) : s.padEnd(ww); }
- async function typeAt(str, color, x, y) {
- for (let i = 0; i < str.length; i++) {
- if (stopped) return;
- if (instantMode) {
- while (true) {
- if (stopped) return;
- const now = performance.now();
- const elapsed = now - lastWriteTime;
- lastWriteTime = now;
- writeTokens = Math.min(MAX_TOKENS, writeTokens + elapsed * CHARS_PER_MS);
- if (writeTokens >= 1) {
- writeTokens -= 1;
- writeCharAt(str[i], color, x + i, y);
- break;
- }
- await sleep(1);
- }
- } else {
- writeCharAt(str[i], color, x + i, y);
- await sleep(COOLDOWN);
- }
- }
- }
- async function chatSend(msg) {
- selfSending = true;
- try { w.chat.send(msg); } catch (_) {}
- await sleep(150);
- selfSending = false;
- }
- /* ══════════════════════════════════════
- FORMULAS & PRESTIGE
- ══════════════════════════════════════ */
- function calcIncrements(pts) {
- pts = D(pts);
- if (pts.lt(1e10)) return D(0);
- let logP = pts.max(1).log10();
- let earned = logP.pow(1.5).div(5).floor();
- // Apply multipliers
- if (rbDoubler) earned = earned.mul(2);
- if (rbX2Level > 0) earned = earned.mul(D(2).pow(rbX2Level));
- // Neutron boosts Rebirth Increments gain (Atomic Layer)
- if (neutron.gt(0)) {
- earned = earned.mul(neutron.max(1).pow(0.15).add(1));
- }
- // Softcap calculations
- earned = applyIncSoftcap(earned);
- return earned;
- }
- function calcRawIncrements(pts) {
- pts = D(pts);
- if (pts.lt(1e10)) return D(0);
- let logP = pts.max(1).log10();
- let earned = logP.pow(1.5).div(5).floor();
- if (rbDoubler) earned = earned.mul(2);
- if (rbX2Level > 0) earned = earned.mul(D(2).pow(rbX2Level));
- if (neutron.gt(0)) earned = earned.mul(neutron.max(1).pow(0.15).add(1));
- return earned;
- }
- function calcAntiInc(inc) {
- inc = D(inc);
- if (inc.lt("1e20")) return D(0);
- let ratio = inc.div("1e20");
- let earned = ratio.log10().pow(1.2).floor();
- // Q1 Upgrade: Boosts Anti-Inc by Pts
- if (antiIncToPtsActive) {
- earned = earned.mul(points.max(1).log10().add(1));
- }
- // Electron boosts Anti-Inc gain (Atomic Layer)
- if (electron.gt(0)) {
- earned = earned.mul(electron.max(1).pow(0.2).add(1));
- }
- return earned;
- }
- function calcQuantumPoints(ai) {
- ai = D(ai);
- if (ai.lt(100)) return D(0);
- return ai.div(100).log10().max(0).pow(1.1).floor().add(1);
- }
- /* ══════════════════════════════════════════════════════
- RAW CHAT EXTRACTION — ALL USERS, EXHAUSTIVE
- ══════════════════════════════════════════════════════ */
- const dedupSet = new Map();
- function processRaw(text, source) {
- if (!text || stopped || !running) return;
- text = String(text).trim();
- if (!text || text.length > 600) return;
- const key = text.toLowerCase() + "|" + Math.floor(Date.now() / 900);
- if (dedupSet.has(key)) return;
- dedupSet.set(key, true);
- setTimeout(() => dedupSet.delete(key), 2500);
- console.log(`[RAW ${source || "?"}] ${text}`);
- const tildaMatch = text.match(/^(.+?)\s*~\s*(.+)$/);
- if (tildaMatch) {
- const afterTilda = tildaMatch[2].trim();
- if (afterTilda.startsWith("/")) {
- console.log(`[CMD from tilda] ${afterTilda}`);
- handleCmd(afterTilda, tildaMatch[1].trim());
- return;
- }
- }
- let user = "unknown";
- let msg = text;
- for (const pat of [
- /^([^:]{1,30}):\s*(.+)/,
- /^\[([^\]]{1,30})\]\s*(.+)/,
- /^<([^>]{1,30})>\s*(.+)/,
- /^(\S{1,30})\s*[»>]\s*(.+)/
- ]) {
- const m = text.match(pat);
- if (m) { user = m[1].trim(); msg = m[2].trim(); break; }
- }
- if (!msg) return;
- console.log(`${user} ~ ${msg}`);
- if (msg.startsWith("/")) handleCmd(msg, user);
- }
- function extractField(d) {
- if (!d) return "";
- if (typeof d === "string") return d;
- return d.message || d.msg || d.text || d.content || d.body ||
- d.value || d.chat || d.line || d.raw ||
- (typeof d.data === "string" ? d.data : "") || "";
- }
- function tryProcess(d, src) {
- if (!d) return;
- if (typeof d === "string") { processRaw(d, src); return; }
- const m = extractField(d);
- if (typeof m === "string" && m) processRaw(m, src);
- if (Array.isArray(d)) d.forEach(x => tryProcess(x, src));
- }
- (function setupChat() {
- try {
- const real = w.chat.send.bind(w.chat);
- w.chat.send = function (m) {
- const r = real(m);
- if (!selfSending) processRaw(m, "send-hook");
- return r;
- };
- } catch (e) { console.warn("[Inc] hook-send:", e); }
- try {
- if (typeof w.on === "function")
- for (const ev of ["chat","message","receive","msg","data","say","talk","text"])
- try { w.on(ev, (...a) => a.forEach(x => tryProcess(x, "w.on-" + ev))); } catch (_) {}
- } catch (_) {}
- try {
- if (w.events) {
- const hookEm = em => {
- if (!em) return;
- if (typeof em.on === "function")
- for (const ev of ["chat","message","receive","msg","data"])
- try { em.on(ev, d => tryProcess(d, "events-" + ev)); } catch (_) {}
- };
- if (typeof w.events === "function") try { hookEm(w.events()); } catch (_) {}
- hookEm(w.events);
- }
- } catch (_) {}
- try {
- if (w.chat) {
- if (typeof w.chat.on === "function")
- for (const ev of ["message","receive","msg","data","chat","text"])
- try { w.chat.on(ev, d => tryProcess(d, "chat.on-" + ev)); } catch (_) {}
- }
- } catch (_) {}
- try {
- if (typeof w.on === "function")
- for (let code = 0; code <= 30; code++)
- try {
- w.on(code, (...a) => {
- for (const item of a) {
- if (!item) continue;
- const s = typeof item === "string" ? item : extractField(item);
- if (s && typeof s === "string") processRaw(s, `w.on(${code})`);
- }
- });
- } catch (_) {}
- } catch (_) {}
- try {
- function hookWS(sock) {
- if (!sock || sock.__inc143) return;
- sock.__inc143 = true;
- sock.addEventListener("message", function (ev) {
- try {
- if (typeof ev.data === "string") {
- if (ev.data.length > 1 && ev.data.length < 500)
- processRaw(ev.data, "ws-raw");
- }
- } catch (_) {}
- });
- }
- const socks = new Set();
- for (const k of ["socket","ws","conn","websocket","sock","wss","io"]) {
- try { if (w[k] instanceof WebSocket) socks.add(w[k]); } catch (_) {}
- }
- socks.forEach(hookWS);
- const OrigWS = window.WebSocket;
- window.WebSocket = function (...a) {
- const s = new OrigWS(...a);
- setTimeout(() => hookWS(s), 50);
- return s;
- };
- window.WebSocket.prototype = OrigWS.prototype;
- } catch (e) { console.warn("[Inc] hook-ws:", e); }
- // DOM Observers
- try {
- const obs = new Set();
- const sels = ["#chat","#chatbox",".chat-messages","#chat_messages","#chatlog",".chatlog"];
- function observeEl(el) {
- if (obs.has(el)) return; obs.add(el);
- new MutationObserver(muts => {
- for (const m of muts)
- for (const nd of m.addedNodes) {
- const t = (nd.textContent || "").trim();
- if (t) processRaw(t, "dom-obs");
- }
- }).observe(el, { childList: true, subtree: true });
- }
- sels.forEach(sel => { try { document.querySelectorAll(sel).forEach(observeEl); } catch (_) {} });
- } catch (_) {}
- })();
- /* ── Startup & Intro Animations ── */
- async function playIntro() {
- const str = "Incrementallity";
- const ver = "v1.4.3D";
- // Slide down animation (CID 12 Style Cyan-blue)
- for (let offset = 0; offset < 5; offset++) {
- if (stopped) return;
- await typeAt(" ".repeat(WIN_W), "#000000", gx, gy + offset - 1);
- await typeAt(str.padStart(15 + Math.floor((WIN_W - 15) / 2)), "#06b6d4", gx, gy + offset);
- await sleep(100);
- }
- // Slide up animation
- for (let offset = 5; offset >= 1; offset--) {
- if (stopped) return;
- await typeAt(" ".repeat(WIN_W), "#000000", gx, gy + offset);
- await typeAt(str.padStart(15 + Math.floor((WIN_W - 15) / 2)), "#06b6d4", gx, gy + offset - 1);
- await sleep(100);
- }
- // Clear paths
- for (let i = 0; i < 6; i++) {
- await typeAt(" ".repeat(WIN_W), "#000000", gx, gy + i);
- }
- // Final Title render
- await typeAt(str.padStart(15 + Math.floor((WIN_W - 15) / 2)), "#06b6d4", gx, gy + 1);
- // Type the version char-by-char with 0.15s delay
- const verPadding = Math.floor((WIN_W - ver.length) / 2);
- for (let i = 0; i < ver.length; i++) {
- if (stopped) return;
- writeCharAt(ver[i], "#a855f7", gx + verPadding + i, gy + 2);
- await sleep(150);
- }
- await sleep(1200);
- // Clear everything to transition to the window
- for (let i = 0; i < 4; i++) {
- await typeAt(" ".repeat(WIN_W), "#000000", gx, gy + i);
- }
- }
- /* ══════════════════════════════════════
- HUD PANEL
- ══════════════════════════════════════ */
- const shade = document.createElement("div");
- shade.style.cssText = "position:fixed;inset:0;background:rgba(0,0,0,.55);z-index:999998";
- const hud = document.createElement("div");
- hud.style.cssText = `
- position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);
- background:#0f172a;border:2px solid #f43f5e;border-radius:14px;
- padding:28px 34px;z-index:999999;color:#e2e8f0;
- font-family:'Courier New',monospace;
- box-shadow:0 0 50px rgba(244,63,94,.45);min-width:380px`;
- hud.innerHTML = `
- <div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:20px">
- <span style="font-size:17px;font-weight:700;color:#f43f5e">⚙ Generate the Game at</span>
- <button id="_ic_close" style="background:#f43f5e;color:#fff;border:none;border-radius:4px;
- padding:6px 18px;font-size:13px;cursor:pointer;font-family:monospace;font-weight:700">✕ Close</button>
- </div>
- <label style="font-size:12px;color:#94a3b8">X Coordinate</label>
- <input id="_ic_x" type="text" value="0" style="display:block;width:100%;padding:8px 10px;margin:4px 0 14px;
- background:#1e293b;border:1px solid #334155;border-radius:8px;color:#e2e8f0;font-family:monospace;font-size:14px;box-sizing:border-box">
- <label style="font-size:12px;color:#94a3b8">Y Coordinate</label>
- <input id="_ic_y" type="text" value="0" style="display:block;width:100%;padding:8px 10px;margin:4px 0 14px;
- background:#1e293b;border:1px solid #334155;border-radius:8px;color:#e2e8f0;font-family:monospace;font-size:14px;box-sizing:border-box">
- <div style="margin: 15px 0 20px 0; display:flex; align-items:center;">
- <input type="checkbox" id="_ic_instant" style="margin-right:10px; cursor:pointer;">
- <label for="_ic_instant" style="font-size:13px; color:#94a3b8; cursor:pointer; user-select:none;">⚡ Instant Draw (600 cps)</label>
- </div>
- <button id="_ic_go" style="width:100%;padding:13px;background:linear-gradient(135deg,#f43f5e,#e11d48);color:#fff;
- border:none;border-radius:10px;font-size:15px;font-weight:700;cursor:pointer;font-family:monospace;letter-spacing:1px">▶ SUBMIT</button>
- <p style="text-align:center;margin:16px 0 0;color:#475569;font-size:11px">Incrementallity v1.4.3D</p>`;
- document.body.appendChild(shade);
- document.body.appendChild(hud);
- function closeHUD() { shade.remove(); hud.remove(); }
- document.getElementById("_ic_close").onclick = () => { closeHUD(); stopped = true; timers.forEach(clearInterval); };
- document.getElementById("_ic_go").onclick = async () => {
- if (running) return;
- running = true;
- gx = parseInt(document.getElementById("_ic_x").value) || 0;
- gy = -(parseInt(document.getElementById("_ic_y").value) || 0);
- instantMode = document.getElementById("_ic_instant").checked;
- closeHUD();
- await launch();
- };
- /* ══════════════════════════════════════
- GAME LAUNCHER
- ══════════════════════════════════════ */
- async function launch() {
- await playIntro(); // Cinematic Intro Animations
- await typeAt("Load....", "#f43f5e", gx, gy);
- if (!instantMode) await sleep(3000);
- for (let i = 0; i < 8; i++) { writeCharAt(" ", "#000000", gx + i, gy); if (!instantMode) await sleep(COOLDOWN); }
- await drawWindow();
- await render();
- await sleep(100);
- await chatSend("/upg N | /rebirth | /page CMD for help");
- startTicks();
- }
- async function drawWindow() {
- const inner = WIN_W - 2;
- await typeAt("╔" + "═".repeat(inner) + "╗", "#f43f5e", gx, gy);
- await typeAt("║" + " Incrementallity v1.4.3D ".padEnd(inner) + "║", "#fbbf24", gx, gy + 1);
- await typeAt("╠" + "═".repeat(inner) + "╣", "#f43f5e", gx, gy + 2);
- for (let r = 3; r < WIN_H - 1; r++)
- await typeAt("║" + " ".repeat(inner) + "║", "#f43f5e", gx, gy + r);
- await typeAt("╚" + "═".repeat(inner) + "╝", "#f43f5e", gx, gy + WIN_H - 1);
- }
- /* ══════════════════════════════════════ */
- function startTicks() {
- // Main points generation tick
- timers.push(setInterval(() => {
- if (stopped) return;
- let gain = pointGain.mul(greaterGainMul);
- if (boosterOn) gain = gain.add(points.max(1).pow(0.05));
- if (rbPointBoost) gain = gain.mul(increments.max(1).pow(0.3).add(1));
- // Proton boosts point gain (Atomic Layer)
- if (proton.gt(0)) {
- gain = gain.mul(proton.max(1).pow(0.1).add(1));
- }
- // Raiser R5 multiplier
- if (rbRaiserLevel > 0) {
- gain = gain.pow(Decimal.pow(1.4, rbRaiserLevel));
- }
- points = points.add(gain);
- }, 1000));
- // Display updates
- timers.push(setInterval(async () => {
- if (renderBusy || stopped) return;
- renderBusy = true; await render(); renderBusy = false;
- }, 500));
- // Auto upgrade 1-3 tick
- timers.push(setInterval(() => {
- if (stopped || !automationOn) return;
- for (const u of upgrades)
- if (u.id >= 1 && u.id <= 3 && (u.maxBuy === -1 || u.level < u.maxBuy) && !isHardcapped(u.id, u.level))
- if (points.gte(u.cost)) buyUpgrade(u, true);
- }, 1000));
- // Full auto upgrade 1-7 tick
- timers.push(setInterval(() => {
- if (stopped || !fullAutoOn) return;
- for (let rep = 0; rep < 50; rep++)
- for (const u of upgrades)
- if ((u.maxBuy === -1 || u.level < u.maxBuy) && !isHardcapped(u.id, u.level) && points.gte(u.cost))
- buyUpgrade(u, true);
- }, 10000));
- // Anti-Inc Auto conversion generation tick
- timers.push(setInterval(() => {
- if (stopped || !autoIncActive) return;
- const generatedInc = points.max(1).log10().pow(2).div(1000);
- if (generatedInc.gt(0)) {
- increments = increments.add(generatedInc);
- }
- }, 1000));
- // Atomic elements generation tick
- timers.push(setInterval(() => {
- if (stopped) return;
- // Proton generated by all layers (Points, Increments, Anti-Inc, QP)
- let pGain = points.max(1).log10()
- .add(increments.max(1).log10())
- .add(antiInc.max(1).log10())
- .add(quantumPoints.max(1).mul(10).log10())
- .div(10);
- if (pGain.gt(0)) {
- proton = proton.add(pGain);
- }
- // Neutron generated if Proton >= 100
- if (proton.gte(100)) {
- let nGain = proton.div(100).log10().max(0).add(1).div(10);
- neutron = neutron.add(nGain);
- }
- // Electron generated if Neutron >= 100
- if (neutron.gte(100)) {
- let eGain = neutron.div(100).log10().max(0).add(1).div(10);
- electron = electron.add(eGain);
- }
- }, 1000));
- }
- /* ══════════════════════════════════════
- RENDER
- ══════════════════════════════════════ */
- async function render() {
- const ix = gx + 2, iy = gy + 3, iw = WIN_W - 4;
- // Dynamic theme changing via w.changeColor based on current page
- try {
- if (currentPage === "RU") w.changeColor(10); // Purple for Rebirth Upgrades
- else if (currentPage === "AI") w.changeColor(5); // Lime green for Anti-Inc
- else if (currentPage === "QU") w.changeColor(1); // Gold/Yellow for Quantum
- else if (currentPage === "AT") w.changeColor(11); // Blue/Cyan for Atomic Layer
- else w.changeColor(12); // Standard Cyan-Blue
- } catch (_) {}
- // Points line
- let effGain = pointGain.mul(greaterGainMul);
- if (boosterOn) effGain = effGain.add(points.max(1).pow(0.05));
- if (rbPointBoost) effGain = effGain.mul(increments.max(1).pow(0.3).add(1));
- if (proton.gt(0)) effGain = effGain.mul(proton.max(1).pow(0.1).add(1));
- if (rbRaiserLevel > 0) effGain = effGain.pow(Decimal.pow(1.4, rbRaiserLevel));
- await typeAt(fit(`Pts: ${formatNum(points)} (+${formatNum(effGain)}/s)`, iw), "#34d399", ix, iy);
- // Rebirth/Prestige line
- let iLine = `Inc: ${formatNum(increments)} | RB: ${rebirths}`;
- if (points.gte(1e10)) {
- const pend = calcIncrements(points);
- const raw = calcRawIncrements(points);
- const scl = getIncSoftcapLabel(raw);
- iLine += ` | Next: +${formatNum(pend)}${scl}`;
- }
- await typeAt(fit(iLine, iw), "#e879f9", ix, iy + 1);
- // Anti-Inc line (CID 5 Styled)
- let aLine = `Anti-Inc: ${formatNum(antiInc)}`;
- if (increments.gte("1e20")) {
- const pendAnti = calcAntiInc(increments);
- aLine += ` | Next: +${formatNum(pendAnti)} (Requires 1e20 Inc)`;
- }
- await typeAt(fit(aLine, iw), "#84cc16", ix, iy + 2);
- // Quantum line (CID 1 Styled)
- let qLine = `Quantum Points: ${formatNum(quantumPoints)}`;
- if (antiInc.gte(100)) {
- const pendQuantum = calcQuantumPoints(antiInc);
- qLine += ` | Next: +${formatNum(pendQuantum)} (Requires 100 Anti-Inc)`;
- }
- await typeAt(fit(qLine, iw), "#facc15", ix, iy + 3);
- // State flags
- let flags = "";
- if (automationOn) flags += "[AUTO] ";
- if (fullAutoOn) flags += "[FULL-AUTO] ";
- if (boosterOn) flags += "[BOOST] ";
- if (rbPointBoost) flags += "[RB-BOOST] ";
- if (rbDoubler) flags += "[2x INC] ";
- if (breakerActive) flags += "[BREAKER] ";
- if (rbX2Level > 0) flags += `[x${D(2).pow(rbX2Level).toString()} RB] `;
- if (rbRaiserLevel > 0) flags += `[^1.4^${rbRaiserLevel} PT] `;
- if (autoIncActive) flags += "[INC-GEN] ";
- if (antiIncToPtsActive) flags += "[AI->PT] ";
- if (atomicizeUnlocked) flags += "[ATOM] ";
- await typeAt(fit(flags, iw), "#a78bfa", ix, iy + 4);
- const showRbPage = typeof currentPage === "string" && currentPage.startsWith("B");
- const showRuPage = currentPage === "RU";
- const showCmdPage = currentPage === "CMD";
- const showAiPage = currentPage === "AI";
- const showQuPage = currentPage === "QU";
- const showAtPage = currentPage === "AT";
- if (showCmdPage) {
- await typeAt(fit("──── Commands ────", iw), "#fbbf24", ix, iy + 6);
- const cmds = [
- "/upg N - Buy upgrade N",
- "/upg N max - Buy upgrade N to max",
- "/upg all - Buy all upgrades x1",
- "/upg all max - Buy all upgrades to max",
- "/page N - Go to upgrade page N",
- "/page RU - Rebirth upgrades page",
- "/page AI - Anti-Inc upgrades page",
- "/page QU - Quantum upgrades page",
- "/page AT - Atomic sub-stat page",
- "/page CMD - This commands page",
- "/rupg N - Buy rebirth upgrade N",
- "/aupg N - Buy Anti-Inc upgrade N",
- "/qupg N - Buy Quantum upgrade N",
- "/rebirth - Perform rebirth (1e100 pts)",
- "/antiinc - Perform Anti-Inc prestige (1e20 Inc)",
- "/quantum (qut) - Perform Quantum prestige (100 Anti-Inc)"
- ];
- for (let i = 0; i < cmds.length && i < 17; i++)
- await typeAt(fit(cmds[i], iw), "#94a3b8", ix, iy + 7 + i);
- for (let r = 7 + cmds.length; r <= 23; r++)
- await typeAt(fit("", iw), "#0f172a", ix, iy + r);
- await typeAt(fit("Page CMD (Commands)", iw), "#fbbf24", ix, iy + 24);
- } else if (showRbPage) {
- await typeAt(fit("──── Rebirth Bonuses ────", iw), "#e879f9", ix, iy + 6);
- const rbIdx = parseInt(String(currentPage).slice(1)) || 1;
- const rbData = rebirthPages[rbIdx - 1];
- if (rbData) {
- await typeAt(fit(`Rebirth #${rbIdx}`, iw), "#fbbf24", ix, iy + 7);
- await typeAt(fit(`Points at RB: ${formatNum(rbData.points)}`, iw), "#94a3b8", ix, iy + 8);
- await typeAt(fit(`Gain at RB: ${formatNum(rbData.gain)}`, iw), "#94a3b8", ix, iy + 9);
- await typeAt(fit(`Inc earned: ${formatNum(rbData.incEarned)}`, iw), "#94a3b8", ix, iy + 10);
- for (let r = 11; r <= 23; r++) await typeAt(fit("", iw), "#0f172a", ix, iy + r);
- } else {
- await typeAt(fit("No data for this rebirth page.", iw), "#94a3b8", ix, iy + 7);
- for (let r = 8; r <= 23; r++) await typeAt(fit("", iw), "#0f172a", ix, iy + r);
- }
- const totalRbP = Math.max(rebirthPages.length, 1);
- await typeAt(fit(`Page B${parseInt(String(currentPage).slice(1)) || 1}/${totalRbP}`, iw), "#fbbf24", ix, iy + 24);
- } else if (showRuPage) {
- await typeAt(fit("──── Rebirth Upgrades ────", iw), "#e879f9", ix, iy + 6);
- for (let i = 0; i < rebirthUpgrades.length; i++) {
- const ru = rebirthUpgrades[i];
- const row = iy + 7 + i * 2;
- const maxed = ru.maxBuy !== -1 && ru.level >= ru.maxBuy;
- const tag = maxed ? " [BOUGHT/MAX]" : ru.maxBuy === 1 ? " [1x]" : ` Lv${ru.level}`;
- await typeAt(fit(`[${ru.id}] ${ru.name}${tag}`, iw), "#e879f9", ix, row);
- await typeAt(fit(` Cost: ${formatNum(ru.cost)} Inc | ${ru.desc}`, iw), "#94a3b8", ix, row + 1);
- }
- for (let r = 7 + rebirthUpgrades.length * 2; r <= 23; r++)
- await typeAt(fit("", iw), "#0f172a", ix, iy + r);
- await typeAt(fit("Page RU (Rebirth Upgrades)", iw), "#fbbf24", ix, iy + 24);
- } else if (showAiPage) {
- await typeAt(fit("──── Anti-Inc Upgrades ────", iw), "#84cc16", ix, iy + 6);
- for (let i = 0; i < antiIncUpgrades.length; i++) {
- const au = antiIncUpgrades[i];
- const row = iy + 7 + i * 2;
- const maxed = au.maxBuy !== -1 && au.level >= au.maxBuy;
- const tag = maxed ? " [BOUGHT]" : " [1x]";
- await typeAt(fit(`[${au.id}] ${au.name}${tag}`, iw), "#a8a29e", ix, row);
- await typeAt(fit(` Cost: ${formatNum(au.cost)} Anti-Inc | ${au.desc}`, iw), "#94a3b8", ix, row + 1);
- }
- for (let r = 7 + antiIncUpgrades.length * 2; r <= 23; r++)
- await typeAt(fit("", iw), "#0f172a", ix, iy + r);
- await typeAt(fit("Page AI (Anti-Inc Upgrades)", iw), "#fbbf24", ix, iy + 24);
- } else if (showQuPage) {
- await typeAt(fit("──── Quantum Upgrades ────", iw), "#facc15", ix, iy + 6);
- for (let i = 0; i < quantumUpgrades.length; i++) {
- const qu = quantumUpgrades[i];
- const row = iy + 7 + i * 2;
- const maxed = qu.maxBuy !== -1 && qu.level >= qu.maxBuy;
- const tag = maxed ? " [BOUGHT]" : " [1x]";
- await typeAt(fit(`[${qu.id}] ${qu.name}${tag}`, iw), "#fbbf24", ix, row);
- await typeAt(fit(` Cost: ${formatNum(qu.cost)} QP | ${qu.desc}`, iw), "#94a3b8", ix, row + 1);
- }
- for (let r = 7 + quantumUpgrades.length * 2; r <= 23; r++)
- await typeAt(fit("", iw), "#0f172a", ix, iy + r);
- await typeAt(fit("Page QU (Quantum Upgrades)", iw), "#fbbf24", ix, iy + 24);
- } else if (showAtPage) {
- // Atomic layer page (CID 11 Blue/Cyan, CID 4 Green, CID 8 Blue-Purple)
- await typeAt(fit("──── Atomic Layer Sub-stats ────", iw), "#06b6d4", ix, iy + 6);
- await typeAt(fit(`Protons: ${formatNum(proton)}`, iw), "#38bdf8", ix, iy + 8);
- await typeAt(fit(" Formula: log10(all layers generation) / 10", iw), "#94a3b8", ix, iy + 9);
- await typeAt(fit(" Effect: Multiplies point gain", iw), "#06b6d4", ix, iy + 10);
- // Neutron
- const neutronUnl = proton.gte(100);
- const nColor = neutronUnl ? "#4ade80" : "#ef4444";
- const nText = neutronUnl ? `Neutrons: ${formatNum(neutron)}` : "Neutrons: LOCKED (Needs 100 Proton)";
- await typeAt(fit(nText, iw), nColor, ix, iy + 12);
- await typeAt(fit(" Effect: Multiplies Rebirth Inc gain", iw), "#94a3b8", ix, iy + 13);
- // Electron
- const electronUnl = neutron.gte(100);
- const eColor = electronUnl ? "#a78bfa" : "#ef4444";
- const eText = electronUnl ? `Electrons: ${formatNum(electron)}` : "Electrons: LOCKED (Needs 100 Neutron)";
- await typeAt(fit(eText, iw), eColor, ix, iy + 15);
- await typeAt(fit(" Effect: Multiplies Anti-Inc gain", iw), "#94a3b8", ix, iy + 16);
- for (let r = 17; r <= 23; r++) await typeAt(fit("", iw), "#0f172a", ix, iy + r);
- await typeAt(fit("Page AT (Atomic Stats)", iw), "#fbbf24", ix, iy + 24);
- } else {
- const numPage = typeof currentPage === "number" ? currentPage : 1;
- const totalPages = Math.ceil(upgrades.length / UPG_PER_PAGE);
- const cp = Math.max(1, Math.min(numPage, totalPages));
- currentPage = cp;
- const start = (cp - 1) * UPG_PER_PAGE;
- const pageUpg = upgrades.slice(start, start + UPG_PER_PAGE);
- await typeAt(fit("──── Upgrades ────", iw), "#fbbf24", ix, iy + 6);
- const colors = { 1:"#38bdf8", 2:"#c084fc", 3:"#fb923c", 4:"#4ade80", 5:"#f472b6", 6:"#facc15", 7:"#22d3ee" };
- for (let i = 0; i < UPG_PER_PAGE; i++) {
- const row = iy + 7 + i * 4;
- if (i < pageUpg.length) {
- const u = pageUpg[i];
- const oneTime = u.maxBuy === 1;
- const maxed = oneTime && u.level >= 1;
- const hc = isHardcapped(u.id, u.level);
- const scLabel = hc ? " [HARDCAP]" : maxed ? " [BOUGHT]" : oneTime ? " [1x]" : getSoftcapLabel(u.id, u.level);
- await typeAt(fit(`[${u.id}] ${u.name}${scLabel}`, iw), colors[u.id] || "#38bdf8", ix, row);
- await typeAt(fit(` Cost: ${formatNum(u.cost)} pts | Lvl ${u.level}`, iw), "#94a3b8", ix, row + 1);
- const scm = getCostMultiplier(u.id, u.level);
- const scInfo = scm > 1 ? `Cost x${scm}` : "";
- await typeAt(fit(` ${scInfo}`, iw), "#ef4444", ix, row + 2);
- await typeAt(fit("", iw), "#0f172a", ix, row + 3);
- } else {
- for (let j = 0; j < 4; j++) await typeAt(fit("", iw), "#0f172a", ix, row + j);
- }
- }
- const usedRows = UPG_PER_PAGE * 4;
- for (let r = 7 + usedRows; r <= 23; r++)
- await typeAt(fit("", iw), "#0f172a", ix, iy + r);
- await typeAt(fit(`Page ${cp}/${totalPages} | /page CMD for help`, iw), "#fbbf24", ix, iy + 24);
- }
- const canRebirth = points.gte(D("1e100"));
- const canAntiInc = increments.gte("1e20");
- const canQuantum = antiInc.gte(100);
- // Prompt alert priority rendering
- if (canQuantum) {
- try { w.changeColor(1); } catch (_) {}
- const pendQ = calcQuantumPoints(antiInc);
- await typeAt(fit(`⚡ QUANTUMIZE for ${formatNum(pendQ)} QP! /quantum ⚡`, iw), "#facc15", ix, iy + 25);
- try { w.changeColor(0); } catch (_) {}
- } else if (canAntiInc) {
- try { w.changeColor(5); } catch (_) {}
- const pendAnti = calcAntiInc(increments);
- await typeAt(fit(`⚡ PRESTIGE for ${formatNum(pendAnti)} Anti-Inc! /antiinc ⚡`, iw), "#84cc16", ix, iy + 25);
- try { w.changeColor(0); } catch (_) {}
- } else if (canRebirth) {
- try { w.changeColor(10); } catch (_) {}
- const pendInc = calcIncrements(points);
- await typeAt(fit(`★ REBIRTH for ${formatNum(pendInc)} Inc! /rebirth ★`, iw), "#ff00ff", ix, iy + 25);
- try { w.changeColor(0); } catch (_) {}
- } else {
- await typeAt(fit("", iw), "#0f172a", ix, iy + 25);
- }
- }
- /* ══════════════════════════════════════
- BUY LOGIC
- ══════════════════════════════════════ */
- function buyUpgrade(u, silent) {
- if (u.maxBuy !== -1 && u.level >= u.maxBuy) return false;
- if (isHardcapped(u.id, u.level)) return false;
- if (!points.gte(u.cost)) return false;
- points = points.sub(u.cost);
- u.level++;
- const scm = getCostMultiplier(u.id, u.level);
- switch (u.id) {
- case 1: pointGain = pointGain.add(1); u.cost = roundCost(D(u.cost).mul(u.scaling * scm)); break;
- case 2: pointGain = pointGain.mul(3); u.cost = roundCost(D(u.cost).mul(u.scaling * scm)); break;
- case 3:
- u.cost = roundCost(D(u.cost).mul(u.scaling * scm));
- for (const upg of upgrades) upg.cost = roundCost(D(upg.cost).div(1.5));
- break;
- case 4: automationOn = true; break;
- case 5: pointGain = pointGain.pow(1.1); u.cost = roundCost(D(u.cost).mul(u.scaling * scm)); break;
- case 6: boosterOn = true; break;
- case 7:
- greaterGainMul = greaterGainMul.mul(1.25);
- pointGain = pointGain.mul(1.25);
- u.cost = roundCost(D(u.cost).mul(u.scaling * scm));
- break;
- }
- return true;
- }
- function buyRebirthUpgrade(ru) {
- if (ru.maxBuy !== -1 && ru.level >= ru.maxBuy) return false;
- if (!increments.gte(ru.cost)) return false;
- increments = increments.sub(ru.cost);
- ru.level++;
- switch (ru.id) {
- case "R1": rbPointBoost = true; break;
- case "R2": fullAutoOn = true; break;
- case "R3": rbDoubler = true; break;
- case "R4":
- rbX2Level++;
- ru.cost = roundCost(D(ru.cost).mul(ru.scaling));
- break;
- case "R5":
- rbRaiserLevel++;
- ru.cost = roundCost(D(ru.cost).mul(ru.scaling));
- break;
- case "R6":
- rbMaximizer = true;
- for (const other of rebirthUpgrades) {
- if (other.id !== "R6") {
- other.level += 150;
- if (other.id === "R1") rbPointBoost = true;
- if (other.id === "R2") fullAutoOn = true;
- if (other.id === "R3") rbDoubler = true;
- if (other.id === "R4") rbX2Level += 150;
- if (other.id === "R5") rbRaiserLevel += 150;
- }
- }
- break;
- }
- return true;
- }
- function buyAntiIncUpgrade(au) {
- if (au.maxBuy !== -1 && au.level >= au.maxBuy) return false;
- if (!antiInc.gte(au.cost)) return false;
- antiInc = antiInc.sub(au.cost);
- au.level++;
- switch (au.id) {
- case "A1": autoIncActive = true; break;
- case "A2": breakerActive = true; break;
- }
- return true;
- }
- function buyQuantumUpgrade(qu) {
- if (qu.maxBuy !== -1 && qu.level >= qu.maxBuy) return false;
- if (!quantumPoints.gte(qu.cost)) return false;
- quantumPoints = quantumPoints.sub(qu.cost);
- qu.level++;
- switch (qu.id) {
- case "Q1": antiIncToPtsActive = true; break;
- case "Q2": atomicizeUnlocked = true; break;
- }
- return true;
- }
- /* ══════════════════════════════════════
- PRESTIGE LOGICS
- ══════════════════════════════════════ */
- function doRebirth() {
- if (!points.gte(D("1e100"))) return false;
- const earned = calcIncrements(points);
- rebirthPages.push({ points: D(points), gain: D(pointGain), incEarned: D(earned), rb: rebirths + 1 });
- increments = increments.add(earned);
- rebirths++;
- points = D(0); pointGain = D(1);
- automationOn = false; boosterOn = false;
- greaterGainMul = D(1);
- upgrades = defaultUpgrades();
- currentPage = 1;
- rbPointBoost = false; fullAutoOn = false; rbDoubler = false;
- for (const ru of rebirthUpgrades) {
- if (ru.id === "R1" && ru.level >= 1) rbPointBoost = true;
- if (ru.id === "R2" && ru.level >= 1) fullAutoOn = true;
- if (ru.id === "R3" && ru.level >= 1) rbDoubler = true;
- }
- return true;
- }
- function doAntiIncPrestige() {
- if (increments.lt("1e20")) return false;
- const earned = calcAntiInc(increments);
- antiInc = antiInc.add(earned);
- points = D(0);
- pointGain = D(1);
- rebirths = 0;
- increments = D(0);
- greaterGainMul = D(1);
- automationOn = false;
- boosterOn = false;
- fullAutoOn = false;
- rbPointBoost = false;
- rbDoubler = false;
- rbX2Level = 0;
- rbRaiserLevel = 0;
- rbMaximizer = false;
- upgrades = defaultUpgrades();
- rebirthUpgrades = defaultRebirthUpgrades();
- rebirthPages.length = 0;
- currentPage = 1;
- return true;
- }
- function doQuantumPrestige() {
- if (antiInc.lt(100)) return false;
- const earned = calcQuantumPoints(antiInc);
- quantumPoints = quantumPoints.add(earned);
- // Heavy wipe for Quantum layer
- points = D(0);
- pointGain = D(1);
- rebirths = 0;
- increments = D(0);
- greaterGainMul = D(1);
- antiInc = D(0);
- automationOn = false;
- boosterOn = false;
- fullAutoOn = false;
- rbPointBoost = false;
- rbDoubler = false;
- rbX2Level = 0;
- rbRaiserLevel = 0;
- rbMaximizer = false;
- breakerActive = false;
- autoIncActive = false;
- upgrades = defaultUpgrades();
- rebirthUpgrades = defaultRebirthUpgrades();
- antiIncUpgrades = defaultAntiIncUpgrades();
- rebirthPages.length = 0;
- currentPage = 1;
- return true;
- }
- /* ══════════════════════════════════════
- COMMAND HANDLER
- ══════════════════════════════════════ */
- async function handleCmd(raw, user) {
- if (!running || stopped) return;
- const cmd = raw.toLowerCase().replace(/\s+/g, " ").trim();
- // Check deduplication
- const cmdKey = `${user.toLowerCase()}:${cmd}`;
- const now = Date.now();
- if (commandExecutionHistory.has(cmdKey)) {
- const lastTime = commandExecutionHistory.get(cmdKey);
- if (now - lastTime < 1000) return;
- }
- commandExecutionHistory.set(cmdKey, now);
- if (commandExecutionHistory.size > 200) {
- for (const [k, t] of commandExecutionHistory.entries()) {
- if (now - t > 5000) commandExecutionHistory.delete(k);
- }
- }
- if (cmd === "/rebirth") {
- if (doRebirth()) {
- const last = rebirthPages[rebirthPages.length - 1];
- await chatSend(`✓ REBIRTH #${rebirths}! +${formatNum(last.incEarned)} Inc`);
- } else await chatSend(`✗ Need 1e100 pts`);
- return;
- }
- if (cmd === "/antiinc") {
- if (doAntiIncPrestige()) {
- await chatSend(`⚡ PRESTIGE SUCCESSFUL! Now at ${formatNum(antiInc)} Anti-Inc.`);
- } else await chatSend(`✗ Need 1e20 Inc`);
- return;
- }
- if (cmd === "/quantum" || cmd === "/qut") {
- if (doQuantumPrestige()) {
- await chatSend(`⚡ QUANTUM PRESTIGE SUCCESSFUL! Now at ${formatNum(quantumPoints)} QP.`);
- } else await chatSend(`✗ Need 100 Anti-Inc`);
- return;
- }
- if (cmd === "/page cmd") { currentPage = "CMD"; await chatSend("Commands page"); return; }
- if (cmd === "/page ru") { currentPage = "RU"; await chatSend("Rebirth Upgrades"); return; }
- if (cmd === "/page ai") { currentPage = "AI"; await chatSend("Anti-Inc Upgrades"); return; }
- if (cmd === "/page qu") { currentPage = "QU"; await chatSend("Quantum Upgrades"); return; }
- if (cmd === "/page at" || cmd === "/page atom") {
- if (!atomicizeUnlocked) { await chatSend("✗ Atomic Layer locked. Buy 'Atomicize' in QU."); return; }
- currentPage = "AT";
- await chatSend("Atomic Layer Stats");
- return;
- }
- const rbpm = cmd.match(/^\/page\s+b(\d+)$/i);
- if (rbpm) {
- const idx = parseInt(rbpm[1]);
- if (idx >= 1 && idx <= Math.max(rebirthPages.length, 1)) { currentPage = "B" + idx; await chatSend(`Rebirth Page B${idx}`); }
- return;
- }
- const pm = cmd.match(/^\/page\s+(\d+)$/);
- if (pm) {
- const p = parseInt(pm[1]);
- const tot = Math.ceil(upgrades.length / UPG_PER_PAGE);
- if (p >= 1 && p <= tot) { currentPage = p; await chatSend(`Page ${p}/${tot}`); }
- return;
- }
- const umSingle = cmd.match(/^\/upg\s+(\d+)$/);
- if (umSingle) {
- const id = parseInt(umSingle[1]);
- const u = upgrades.find(x => x.id === id);
- if (!u) { await chatSend("Unknown #" + id); return; }
- if (u.maxBuy !== -1 && u.level >= u.maxBuy) { await chatSend(`✗ [${u.id}] maxed`); return; }
- if (isHardcapped(u.id, u.level)) { await chatSend(`✗ [${u.id}] HARDCAPPED`); return; }
- if (buyUpgrade(u)) {
- await chatSend(`✓ [${u.id}] Lvl ${u.level}`);
- } else await chatSend(`✗ Need ${formatNum(u.cost)} pts`);
- return;
- }
- const umMax = cmd.match(/^\/upg\s+(\d+)\s+max$/);
- if (umMax) {
- const id = parseInt(umMax[1]);
- const u = upgrades.find(x => x.id === id);
- if (!u) { await chatSend("Unknown #" + id); return; }
- let n = 0;
- while (points.gte(u.cost) && (u.maxBuy === -1 || u.level < u.maxBuy) && !isHardcapped(u.id, u.level) && n < 100000) {
- buyUpgrade(u, true); n++;
- }
- if (n > 0) await chatSend(`✓ [${u.id}] bought x${n}`);
- return;
- }
- if (cmd === "/upg all max") {
- let total = 0, go = true;
- while (go && total < 200000) {
- go = false;
- for (const u of upgrades)
- if ((u.maxBuy === -1 || u.level < u.maxBuy) && !isHardcapped(u.id, u.level) && points.gte(u.cost)) {
- buyUpgrade(u, true); total++; go = true;
- }
- }
- if (total > 0) await chatSend(`✓ Bought ${total} upgrades max!`);
- return;
- }
- if (cmd === "/upg all") {
- let n = 0;
- for (const u of upgrades)
- if ((u.maxBuy === -1 || u.level < u.maxBuy) && !isHardcapped(u.id, u.level) && points.gte(u.cost)) {
- buyUpgrade(u, true); n++;
- }
- if (n > 0) await chatSend(`✓ Bought ${n} upgrades!`);
- return;
- }
- const rup = cmd.match(/^\/rupg\s+(\d+)$/);
- if (rup) {
- const rn = parseInt(rup[1]);
- const ru = rebirthUpgrades.find(x => x.id === "R" + rn);
- if (!ru) { await chatSend("Unknown R" + rn); return; }
- if (ru.maxBuy !== -1 && ru.level >= ru.maxBuy) { await chatSend(`✗ [${ru.id}] maxed`); return; }
- if (buyRebirthUpgrade(ru)) await chatSend(`✓ [${ru.id}] ${ru.name}`);
- return;
- }
- const rupMax = cmd.match(/^\/rupg\s+(\d+)\s+max$/);
- if (rupMax) {
- const rn = parseInt(rupMax[1]);
- const ru = rebirthUpgrades.find(x => x.id === "R" + rn);
- if (!ru) { await chatSend("Unknown R" + rn); return; }
- let n = 0;
- while ((ru.maxBuy === -1 || ru.level < ru.maxBuy) && increments.gte(ru.cost) && n < 100000) {
- buyRebirthUpgrade(ru); n++;
- }
- if (n > 0) await chatSend(`✓ [${ru.id}] bought x${n}`);
- return;
- }
- const aup = cmd.match(/^\/aupg\s+(\d+)$/);
- if (aup) {
- const an = parseInt(aup[1]);
- const au = antiIncUpgrades.find(x => x.id === "A" + an);
- if (!au) { await chatSend("Unknown A" + an); return; }
- if (au.maxBuy !== -1 && au.level >= au.maxBuy) { await chatSend(`✗ [${au.id}] maxed`); return; }
- if (buyAntiIncUpgrade(au)) await chatSend(`✓ [${au.id}] ${au.name}`);
- return;
- }
- const qup = cmd.match(/^\/qupg\s+(\d+)$/);
- if (qup) {
- const qn = parseInt(qup[1]);
- const qu = quantumUpgrades.find(x => x.id === "Q" + qn);
- if (!qu) { await chatSend("Unknown Q" + qn); return; }
- if (qu.maxBuy !== -1 && qu.level >= qu.maxBuy) { await chatSend(`✗ [${qu.id}] maxed`); return; }
- if (buyQuantumUpgrade(qu)) await chatSend(`✓ [${qu.id}] ${qu.name}`);
- return;
- }
- }
- /* ══════════════════════════════════════ */
- window.quit = async function () {
- stopped = true; timers.forEach(clearInterval); timers.length = 0;
- if (running) {
- for (let r = 0; r < WIN_H; r++)
- for (let c = 0; c < WIN_W; c++) {
- writeCharAt(" ", "#000000", gx + c, gy + r);
- if (!instantMode) await sleep(COOLDOWN);
- }
- }
- running = false;
- try { shade.remove(); } catch (_) {} try { hud.remove(); } catch (_) {}
- try { w.chat.send("Stopped"); } catch (_) {}
- console.log("[Incrementallity] Game stopped.");
- };
- window.info = function () { console.log("incrementality is a game that i made."); };
- })();
Advertisement