-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
202 lines (167 loc) · 6.47 KB
/
index.js
File metadata and controls
202 lines (167 loc) · 6.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
// === Load saved values or set defaults ===
// == Batarongs ==
let batarongs = Number(localStorage.getItem("batarongs")) || 0;
let increment = Number(localStorage.getItem("increment")) || 1;
// == YouTube ==
let ytbought = Number(localStorage.getItem("ytbought")) || 0;
let bataytCost = Number(localStorage.getItem("bataytCost")) || 10;
// == SOPV ==
let sopvbought = Number(localStorage.getItem("sopvbought")) || 0;
let sopvCost = Number(localStorage.getItem("sopvCost")) || 100;
let sopvInterval = null;
// == MED ==
let medbought = Number(localStorage.getItem("medbought")) || 0;
let medCost = Number(localStorage.getItem("medCost")) || 500;
let medInterval = null;
// == UI Elements ==
const upgradesPanel = document.getElementById("upgradesPanel");
const openBtn = document.getElementById("openUpgrades");
const closeBtn = document.getElementById("closeUpgrades");
const totalRateEl = document.getElementById("totalrate");
// === Toggle upgrades panel with slide ===
openBtn.onclick = () => upgradesPanel.classList.add("open");
closeBtn.onclick = () => upgradesPanel.classList.remove("open");
// === Update UI ===
const updateUI = () => {
document.getElementById("batarongsclicked").textContent = `Batarongs: ${batarongs}`;
document.getElementById("bycount").textContent = ytbought;
document.getElementById("bytcost").innerHTML = `Cost: ${bataytCost} Batarongs.<br>Doubles click production`;
document.getElementById("sopvcount").textContent = sopvbought;
document.getElementById("sopvcost").innerHTML = `Cost: ${sopvCost} Batarongs.<br>Gives 1 batarong /sec`;
document.getElementById("sopvrate").innerHTML = `<span style="color:limegreen;">Income: +${sopvbought}/sec</span>`;
document.getElementById("medcount").textContent = medbought;
document.getElementById("medcost").innerHTML = `Cost: ${medCost} Batarongs.<br>Gives 3 batarongs /sec<br>Triples Click Production`;
document.getElementById("medrate").innerHTML = `<span style="color:limegreen;">Income: +${medbought * 3}/sec</span>`;
const total = sopvbought + medbought * 3;
totalRateEl.textContent = `Total Income: +${total}/sec`;
};
updateUI();
// === Clicking main button ===
document.getElementById("batarongbut").onclick = () => {
batarongs += increment;
localStorage.setItem("batarongs", batarongs);
updateUI();
};
// === Upgrades ===
document.getElementById("bataytclick").onclick = () => {
if (batarongs >= bataytCost) {
batarongs -= bataytCost;
increment += 1;
ytbought += 1;
bataytCost = Math.ceil(bataytCost * 1.2);
localStorage.setItem("batarongs", batarongs);
localStorage.setItem("increment", increment);
localStorage.setItem("ytbought", ytbought);
localStorage.setItem("bataytCost", bataytCost);
updateUI();
}
};
document.getElementById("sopvclick").onclick = () => {
if (batarongs >= sopvCost) {
batarongs -= sopvCost;
sopvbought += 1;
sopvCost = Math.ceil(sopvCost * 1.2);
localStorage.setItem("batarongs", batarongs);
localStorage.setItem("sopvbought", sopvbought);
localStorage.setItem("sopvCost", sopvCost);
updateUI();
startSopvInterval();
}
};
document.getElementById("medclick").onclick = () => {
if (batarongs >= medCost) {
batarongs -= medCost;
medbought += 1;
increment += 3;
medCost = Math.ceil(medCost * 1.25);
localStorage.setItem("batarongs", batarongs);
localStorage.setItem("medbought", medbought);
localStorage.setItem("medCost", medCost);
updateUI();
startMedInterval();
}
};
// === Intervals ===
function startSopvInterval() {
if (sopvInterval) clearInterval(sopvInterval);
sopvInterval = setInterval(() => {
batarongs += sopvbought;
localStorage.setItem("batarongs", batarongs);
updateUI();
}, 1000);
}
function startMedInterval() {
if (medInterval) clearInterval(medInterval);
medInterval = setInterval(() => {
batarongs += medbought * 3;
localStorage.setItem("batarongs", batarongs);
updateUI();
}, 1000);
}
if (sopvbought > 0) startSopvInterval();
if (medbought > 0) startMedInterval();
// === Global Game Object ===
window.game = {
Reset: function() {
// Reset all game values to defaults
batarongs = 0;
increment = 1;
ytbought = 0;
bataytCost = 10;
sopvbought = 0;
sopvCost = 100;
medbought = 0;
medCost = 500;
localStorage.clear();
if (sopvInterval) clearInterval(sopvInterval);
if (medInterval) clearInterval(medInterval);
updateUI();
console.log("♻️ Game fully reset to defaults.");
},
Test: function() {
batarongs = 9999;
localStorage.setItem("batarongs", batarongs);
updateUI();
console.log("💰 Test mode: 9999 Batarongs added.");
}
};
// === Developer Menu ===
function createDeveloperMenu() {
if (document.querySelector('.developer-menu')) return;
const devMenu = document.createElement('div');
devMenu.className = 'developer-menu';
devMenu.innerHTML = `
<div class="dev-header">
<h2>Developer Menu</h2>
<button id="dev-close">✖</button>
</div>
<div id="dev-content">
<button id="dev-test">💰 Test (Set 9999 Batarongs)</button>
<button id="dev-reset">♻️ Reset Game</button>
</div>
`;
document.body.appendChild(devMenu);
const header = devMenu.querySelector('.dev-header');
let isDragging = false, offsetX, offsetY;
header.addEventListener('mousedown', e => {
isDragging = true;
offsetX = e.clientX - devMenu.getBoundingClientRect().left;
offsetY = e.clientY - devMenu.getBoundingClientRect().top;
});
document.addEventListener('mouseup', () => isDragging = false);
document.addEventListener('mousemove', e => {
if (!isDragging) return;
devMenu.style.left = `${e.clientX - offsetX}px`;
devMenu.style.top = `${e.clientY - offsetY}px`;
devMenu.style.right = 'auto';
devMenu.style.transform = 'none';
});
document.getElementById("dev-close").onclick = () => devMenu.remove();
document.getElementById("dev-test").onclick = () => game.Test();
document.getElementById("dev-reset").onclick = () => game.Reset();
}
// ✅ expose dev menu
window.game.Developer = function() {
createDeveloperMenu();
console.log("✅ Developer Menu opened.");
};