forked from JesuscoinsIII/RegenTrail-Modal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
417 lines (364 loc) · 12.6 KB
/
index.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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="viewport" content="width=device-width, initial-scale=1.0">
<meta charset="UTF-8">
<title>Regen Trail - Blockchain Adventure</title>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/tailwind.min.css" rel="stylesheet">
<style>
/* Matrix Effect */
#matrix-canvas {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
z-index: 0;
}
/* Text Background with 50% Opacity */
.text-background {
background: rgba(0, 0, 0, 0.5);
padding: 20px;
border-radius: 10px;
}
/* Text Glitch Effect */
.glitch {
position: relative;
color: #0f0;
font-family: "Courier New", Courier, monospace;
animation: glitch 2s infinite;
}
@keyframes glitch {
0% {
text-shadow: 2px 2px #0f0, -2px -2px #ff0;
}
20% {
text-shadow: -4px -4px #f00, 4px 4px #00f;
}
40% {
text-shadow: 1px 1px #0f0, -1px -1px #ff0;
}
60% {
text-shadow: -2px -2px #0f0, 2px 2px #f0f;
}
80% {
text-shadow: 3px 3px #0ff, -3px -3px #f00;
}
100% {
text-shadow: 0px 0px #0f0;
}
}
/* Button Hover Effects */
button {
transition: all 0.3s ease;
}
button:hover {
transform: scale(1.1);
box-shadow: 0px 0px 10px #00ff00;
}
/* Starburst Effect for Completion */
.starburst {
position: relative;
color: #00ff00;
font-size: 2rem;
animation: burst 1s ease-out forwards;
}
@keyframes burst {
0% {
transform: scale(1);
opacity: 1;
}
50% {
transform: scale(1.5);
opacity: 0.8;
}
100% {
transform: scale(2);
opacity: 0;
}
}
/* Story Text Reveal Effect */
#story-text {
font-size: 1.5rem;
line-height: 1.5;
letter-spacing: 2px;
opacity: 0;
animation: reveal 1s forwards;
}
@keyframes reveal {
0% { opacity: 0; }
100% { opacity: 1; }
}
</style>
</head>
<body class="bg-gray-900 text-white font-mono relative overflow-hidden">
<!-- Matrix Background -->
<canvas id="matrix-canvas"></canvas>
<div id="game-container" class="container mx-auto p-6 text-center relative z-10 text-background">
<div class="text-4xl font-bold mb-4 glitch" data-text="🌱 Welcome to Regen Trail 🌍">🌱 Welcome to Regen Trail 🌍</div>
<div id="boot-log" class="text-lg mb-4">Initializing system...</div>
<div id="story-text" class="text-lg mb-4 hidden">Booting up the system...</div>
<!-- Game Stats -->
<div id="stats-container" class="flex justify-around mb-6 hidden">
<div class="p-4 border border-gray-700 rounded text-background">
<p>HAND Tokens: <span id="hand-tokens">100</span></p>
<p>EARTH Tokens: <span id="earth-tokens">50</span></p>
<p>CARBON Tokens: <span id="carbon-tokens">0</span></p>
<p>Energy: <span id="energy">100</span></p>
<p>Studio Level: <span id="studio-level">1</span></p>
</div>
</div>
<!-- Mission Choices -->
<div id="action-container" class="mb-6 hidden text-background">
<p class="text-xl">Choose an Action:</p>
<div id="actions" class="grid grid-cols-2 gap-4 mt-4">
<!-- Actions will be injected here by JavaScript -->
</div>
</div>
<!-- Milestone Log -->
<div id="milestone-log" class="border border-gray-700 p-4 mt-6 rounded hidden text-background">
<h3 class="text-lg font-bold">Milestone Log</h3>
<div id="milestones" class="mt-2 text-sm"></div>
</div>
</div>
<!-- JavaScript for Game Logic -->
<script>
// Matrix Rain Effect with Regen Tech Elements
const canvas = document.getElementById('matrix-canvas');
const ctx = canvas.getContext('2d');
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
const letters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789🌳☀️💧⚡🌍';
const fontSize = 16;
const columns = canvas.width / fontSize;
const drops = Array(Math.floor(columns)).fill(1);
function drawMatrix() {
ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
ctx.fillRect(0, 0, canvas.width, canvas.height);
ctx.fillStyle = '#0f0';
ctx.font = fontSize + 'px monospace';
for (let i = 0; i < drops.length; i++) {
const text = letters[Math.floor(Math.random() * letters.length)];
ctx.fillText(text, i * fontSize, drops[i] * fontSize);
if (drops[i] * fontSize > canvas.height && Math.random() > 0.975) {
drops[i] = 0;
}
drops[i]++;
}
}
// Slowing down the matrix effect
setInterval(drawMatrix, 80);
// Ensure canvas resizes with window
window.addEventListener('resize', () => {
canvas.width = window.innerWidth;
canvas.height = window.innerHeight;
});
// Game Variables
let handTokens = 100;
let earthTokens = 50;
let carbonTokens = 0;
let energy = 100;
let studioLevel = 1;
let milestones = [];
// HTML Elements
const storyText = document.getElementById('story-text');
const handTokensEl = document.getElementById('hand-tokens');
const earthTokensEl = document.getElementById('earth-tokens');
const carbonTokensEl = document.getElementById('carbon-tokens');
const energyEl = document.getElementById('energy');
const studioLevelEl = document.getElementById('studio-level');
const actionsContainer = document.getElementById('actions');
const milestonesEl = document.getElementById('milestones');
const bootLogEl = document.getElementById('boot-log');
const statsContainer = document.getElementById('stats-container');
const actionContainer = document.getElementById('action-container');
const milestoneLog = document.getElementById('milestone-log');
// Events and Missions
const events = [
{ name: "ETHDenver", location: "Denver, USA" },
{ name: "Devcon", location: "Bangkok, Thailand" },
{ name: "SolarPunk Summit", location: "Berlin, Germany" },
{ name: "ReFi Summit", location: "San Francisco, USA" },
];
const missions = [
{ name: "Plant Trees", reward: 10, cost: 5, requiredLevel: 1 },
{ name: "Build Solar Farm", reward: 25, cost: 15, requiredLevel: 2 },
{ name: "Clean Ocean Plastic", reward: 50, cost: 25, requiredLevel: 3 },
];
// Simulate Boot Log
const bootMessages = [
"Connecting to blockchain...",
"Verifying contracts...",
"Accessing liquidity pools...",
"System ready!"
];
function simulateBootLog() {
let index = 0;
const interval = setInterval(() => {
if (index < bootMessages.length) {
bootLogEl.innerText = bootMessages[index];
index++;
} else {
clearInterval(interval);
bootLogEl.classList.add('hidden');
startGame();
}
}, 1000); // 1 second delay for each boot log
}
// Initialize the Game
function startGame() {
storyText.classList.remove('hidden');
statsContainer.classList.remove('hidden');
actionContainer.classList.remove('hidden');
milestoneLog.classList.remove('hidden');
setTimeout(() => {
revealText("Booting up the system...");
}, 1000);
setTimeout(() => {
revealText("Preparing missions...");
displayActions();
}, 3000);
}
// Letter-by-Letter Text Reveal
function revealText(text) {
storyText.innerHTML = '';
let index = 0;
const interval = setInterval(() => {
if (index < text.length) {
storyText.innerHTML += text[index];
index++;
} else {
clearInterval(interval);
}
}, 50); // Adjust speed here
}
// Display Actions
function displayActions() {
actionsContainer.innerHTML = '';
const actions = ["Perform a Mission", "Mine CARBON Tokens", "Rest to Recharge", "Upgrade Studio"];
actions.forEach((action, index) => {
const actionButton = document.createElement('button');
actionButton.className = 'p-2 bg-green-500 hover:bg-green-600 text-white rounded';
actionButton.innerText = action;
actionButton.onclick = () => performAction(index);
actionsContainer.appendChild(actionButton);
});
}
// Perform Action Based on Choice
function performAction(index) {
if (index === 0) {
performMission();
} else if (index === 1) {
mineCarbonTokens();
} else if (index === 2) {
restToRecharge();
} else if (index === 3) {
upgradeStudio();
}
}
// Perform a Mission
function performMission() {
const mission = getAvailableMission();
if (!mission) {
updateStory("You need to upgrade your studio to perform more advanced missions!");
return;
}
if (energy >= mission.cost) {
energy -= mission.cost;
earthTokens += mission.reward;
updateStats();
// Simulate Block Confirmation
simulateBlockConfirmation(() => {
updateStory(`Completed mission: ${mission.name} at ${getRandomEvent()}. You contributed ${mission.reward} EARTH tokens to a holistic growth fund, helping regenerate the ecosystem.`);
triggerStarburstEffect(`Mission completed: ${mission.name}. EARTH tokens contribute to DeFi pools.`);
});
} else {
updateStory("Not enough energy to complete this mission!");
}
}
// Simulate Block Confirmation
function simulateBlockConfirmation(callback) {
let step = 1;
const interval = setInterval(() => {
console.log(`Confirming Block ${step}/3...`);
step++;
if (step > 3) {
clearInterval(interval);
console.log("Attested on KarmaGap");
callback();
}
}, 1000); // 1 second between block confirmations
}
// Mine CARBON Tokens
function mineCarbonTokens() {
if (energy >= 10) {
energy -= 10;
const mined = Math.floor(Math.random() * 50) + 10;
carbonTokens += mined;
updateStats();
simulateBlockConfirmation(() => {
updateStory(`Mined ${mined} CARBON tokens. You used them in a decentralized liquidity pool to promote carbon offset projects.`);
triggerStarburstEffect(`Mined ${mined} CARBON tokens. Contributed to sustainability.`);
});
} else {
updateStory("Not enough energy to mine CARBON tokens!");
}
}
// Rest to Recharge Energy
function restToRecharge() {
const recharge = Math.floor(Math.random() * 30) + 10;
energy += recharge;
if (energy > 100) energy = 100;
updateStats();
updateStory(`Recharged ${recharge} energy. You took a break to meditate and restore balance to your journey.`);
triggerStarburstEffect("Rested and recharged energy.");
}
// Upgrade the Studio
function upgradeStudio() {
const cost = 50; // Cost to upgrade the studio
if (handTokens >= cost) {
handTokens -= cost;
studioLevel++;
updateStats();
updateStory(`Upgraded your Solar Mobile Studio to level ${studioLevel}. You can now access more advanced missions!`);
triggerStarburstEffect("Solar Mobile Studio upgraded!");
} else {
updateStory("Not enough HAND tokens to upgrade the studio!");
}
}
// Get Available Mission based on Studio Level
function getAvailableMission() {
return missions.find(mission => mission.requiredLevel <= studioLevel);
}
// Get Random Event Location
function getRandomEvent() {
const randomIndex = Math.floor(Math.random() * events.length);
return `${events[randomIndex].name} in ${events[randomIndex].location}`;
}
// Update Stats in the UI
function updateStats() {
handTokensEl.innerText = handTokens;
earthTokensEl.innerText = earthTokens;
carbonTokensEl.innerText = carbonTokens;
energyEl.innerText = energy;
studioLevelEl.innerText = studioLevel;
}
// Update Story Text
function updateStory(text) {
storyText.innerText = text;
}
// Trigger Starburst Effect for Milestone
function triggerStarburstEffect(message) {
const milestoneEl = document.createElement('p');
milestoneEl.innerText = message;
milestoneEl.classList.add('starburst');
milestonesEl.appendChild(milestoneEl);
setTimeout(() => {
milestoneEl.classList.remove('starburst');
}, 1000);
}
// Start the boot sequence
simulateBootLog();
</script>
</body>
</html>