-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshop.html
256 lines (236 loc) Β· 7.71 KB
/
shop.html
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>The Shop - BananaClicker</title>
<style>
/* Styles remain unchanged */
body {
font-family: "Arial", sans-serif;
text-align: center;
background-color: #f0f4c3;
color: #212121;
line-height: 1.6;
}
h1 {
font-size: 2em;
color: #f57c00;
margin-bottom: 20px;
}
.banana {
font-size: 5em;
cursor: pointer;
}
#score {
font-size: 1.8em;
margin-top: 20px;
font-weight: bold;
color: #212121;
}
#shop-btn {
display: inline-block;
margin-top: 30px;
padding: 12px 24px;
font-size: 1.3em;
color: #fff;
background-color: #8d6e63;
border: none;
cursor: pointer;
border-radius: 8px;
transition: background-color 0.3s ease;
}
#shop-btn:hover {
background-color: #6d4c41;
}
#shop-btn:focus {
outline: none;
}
#score-display {
font-size: 1.8em;
margin: 25px 0;
color: #212121;
}
#upgrade-cost {
font-size: 1.6em;
margin-top: 15px;
font-weight: bold;
color: #f57c00;
}
.shop-item {
font-size: 1.6em;
margin: 25px;
color: #212121;
}
.shop-item button {
padding: 12px 24px;
font-size: 1.3em;
color: white;
background-color: #8d6e63;
border: none;
cursor: pointer;
border-radius: 8px;
margin-top: 10px;
transition: background-color 0.3s ease;
}
.shop-item button:hover {
background-color: #6d4c41;
}
#back-btn {
padding: 12px 24px;
font-size: 1.3em;
color: white;
background-color: #f57c00;
border: none;
cursor: pointer;
border-radius: 8px;
margin-top: 30px;
transition: background-color 0.3s ease;
}
#back-btn:hover {
background-color: #e65100;
}
/* Style for the new "Banana Upgrades" button */
#banana-upgrades-btn {
display: inline-block;
margin-top: 40px;
padding: 12px 24px;
font-size: 1.3em;
color: white;
background-color: #8d6e63;
border: none;
cursor: pointer;
border-radius: 8px;
transition: background-color 0.3s ease;
}
#banana-upgrades-btn:hover {
background-color: #6d4c41;
}
#banana-upgrades-btn:focus {
outline: none;
}
#banana-upgrades-btn img {
width: 30px;
vertical-align: middle;
margin-right: 10px;
}
</style>
</head>
<body>
<h1>Welcome to The Shop!</h1>
<div id="score-display">π: 0</div>
<!-- Score display -->
<div id="shop-items">
<div class="shop-item">
<p>Upgrade Click Power</p>
<div id="upgrade-cost">Cost: 50</div>
<!-- Display upgrade cost -->
<button onclick="buyClickPowerUpgrade()">Buy Upgrade</button>
</div>
<div class="shop-item">
<p>Monkey Helper</p>
<div id="monkey-cost">Cost: 100</div>
<!-- Display monkey upgrade cost -->
<button onclick="buyMonkeyHelper()">Buy Monkey Helper</button>
</div>
<div class="shop-item">
<p>More upgrades coming soon!</p>
</div>
</div>
<button id="back-btn" onclick="goBack()">Back to BananaClicker</button>
<!-- New Banana Upgrades button -->
<button id="banana-upgrades-btn" onclick="goToBananaUpgrades()">
<img src="images/banana.png" alt="Banana" /> Banana Upgrades
</button>
<script>
// Load saved score and upgrade data from localStorage
let score = parseInt(localStorage.getItem("score")) || 0;
let clickPower = parseInt(localStorage.getItem("clickPower")) || 1;
let upgradeCost = parseInt(localStorage.getItem("upgradeCost")) || 50;
// Load saved monkey data from localStorage
let monkeyCount = parseInt(localStorage.getItem("monkeyCount")) || 0;
let monkeyCost = parseInt(localStorage.getItem("monkeyCost")) || 100;
// Display current score on the Shop page
document.getElementById("score-display").innerText = "π: " + score;
// Display the current upgrade cost
document.getElementById("upgrade-cost").innerText =
"Cost: " + upgradeCost;
// Display the current monkey cost
document.getElementById("monkey-cost").innerText =
"Cost: " + monkeyCost;
function buyClickPowerUpgrade() {
if (score >= upgradeCost) {
// Deduct score and upgrade click power
score -= upgradeCost;
clickPower *= 2;
// Prevent upgrade cost from becoming too high
if (upgradeCost * 2 <= 10000000000) {
upgradeCost *= 3; // Triple the upgrade cost
} else {
upgradeCost = 1000; // Cap at 1000 if it gets too high
}
// Save updated values to localStorage
localStorage.setItem("score", score);
localStorage.setItem("clickPower", clickPower);
localStorage.setItem("upgradeCost", upgradeCost);
// Update score display
document.getElementById("score-display").innerText = "π: " + score;
// Update the upgrade cost display
document.getElementById("upgrade-cost").innerText =
"Cost: " + upgradeCost;
alert("Upgrade successful! New score: " + score);
} else {
alert("You don't have enough points!");
}
}
function buyMonkeyHelper() {
if (score >= monkeyCost) {
// Deduct score and add a monkey
score -= monkeyCost;
monkeyCount += 1;
// Double.5s the monkey cost. (2.5x)
monkeyCost = Math.floor(monkeyCost * 2.5); // Use Math.floor to ensure no decimals
// Save updated values to localStorage
localStorage.setItem("score", score);
localStorage.setItem("monkeyCount", monkeyCount);
localStorage.setItem("monkeyCost", monkeyCost);
// Update score display
document.getElementById("score-display").innerText = "π: " + score;
// Update the monkey cost display
document.getElementById("monkey-cost").innerText =
"Cost: " + monkeyCost;
alert("Monkey Helper purchased! Total monkeys: " + monkeyCount);
} else {
alert("You don't have enough points!");
}
}
function goBack() {
window.location.href = "index.html"; // Go back to the main page
}
// Redirect to the "Banana Upgrades" page
function goToBananaUpgrades() {
window.location.href = "banana_upgrades.html"; // Go to Banana Upgrades page
}
// Admin login detection
let adminCode = "";
document.addEventListener("keyup", (event) => {
adminCode += event.key.toUpperCase();
if (adminCode.includes("ADMIN")) {
window.location.href = "admin-login.html"; // Redirect to the admin login page
}
if (adminCode.includes("RESET")) {
const confirmation = confirm("Are you sure you want to reset all your data?");
if (confirmation) {
// Reset localStorage and reload the page
localStorage.clear();
alert("All data has been reset.");
window.location.reload(); // Reload the page to reflect changes
}
}
if (adminCode.length > 5) {
adminCode = adminCode.slice(-5); // Keep only the last 5 characters
}
});
</script>
</body>
</html>