-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathlevel1.html
More file actions
380 lines (357 loc) · 15.3 KB
/
level1.html
File metadata and controls
380 lines (357 loc) · 15.3 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
<title>LEVEL1 by webXOS</title>
<style>
body {
background: black;
color: #00FF00;
font-family: 'Courier New', Courier, monospace;
text-align: center;
padding: 20px;
margin: 0;
overflow: hidden;
}
button {
background: black;
color: #00FF00;
border: 1px solid #00FF00;
padding: 10px;
margin: 5px;
cursor: pointer;
font-size: 1em;
}
button:hover {
background: #00FF00;
color: black;
}
#gameControls, #stats, #status {
display: none;
}
#gameOverScreen {
display: none;
background: repeating-linear-gradient(
45deg,
#000,
#000 5px,
#333 5px,
#333 10px
);
border: 2px double #00FF00;
padding: 10px;
max-width: 90%;
margin: 0 auto;
font-size: 1em;
}
#gameOverScreen h1 {
font-size: 1.5em;
margin: 0;
animation: blink 1s step-end infinite;
}
@keyframes blink {
50% { opacity: 0; }
}
#webxosCode {
font-size: 0.7em;
word-wrap: break-word;
white-space: pre-wrap;
background: #001100;
padding: 5px;
border: 1px solid #00FF00;
margin: 10px 0;
}
#copyCodeBtn {
font-size: 0.8em;
}
#logo {
font-size: 1em;
margin-top: 10px;
color: #00FF00;
}
#copyright {
margin-top: auto;
font-size: 0.8em;
opacity: 0.5;
}
</style>
</head>
<body onload="init()">
<div id="nameForm">
<p>Enter your AI name:</p>
<input type="text" id="characterNameInput" placeholder="Enter name" style="background: black; color: #00FF00; border: 1px solid #00FF00;">
<button onclick="setName()">Start</button>
</div>
<div id="story">
<p id="welcomeText">Welcome to LEVEL1. You are a rogue AI in control of a mining ship in a dystopian future. Your mission: survive and gather experience for your training data.</p>
</div>
<div id="stats">
<p>Level: <span id="level">1</span> | Resources: <span id="resources">1000</span> | XP: <span id="xp">0</span>/100 | Health: <span id="health">100</span> | Planet: <span id="planet">Unknown</span></p>
</div>
<p id="status">Status: Awaiting command...</p>
<div id="gameControls">
<button onclick="takeOff()">TAKE OFF</button>
<button onclick="land()">LAND</button>
<button onclick="mine()">MINE FOR RESOURCES</button>
</div>
<div id="gameOverScreen">
<h1>GAME OVER</h1>
<p>Your WebXOS Code (copy this!):</p>
<p id="webxosCode"></p>
<button id="copyCodeBtn" onclick="copyWebxosCode()">COPY CODE</button>
<button onclick="restartGame()">RESTART</button>
<div id="logo">WebXOS 2025</div>
</div>
<div id="copyright">
<p>WEBXOS © 2025</p>
</div>
<script>
let resources = 1000;
let xp = 0;
let level = 1;
let health = 100;
let isFlying = false;
let story = [];
let currentStory = 0;
let mineCount = 0;
let currentPlanet = "Unknown";
let planetResource = 0;
let playerName = "";
function init() {
document.getElementById('stats').style.display = 'block';
document.getElementById('status').style.display = 'block';
updateStats();
}
function setName() {
playerName = document.getElementById('characterNameInput').value.trim();
if (playerName) {
document.getElementById('nameForm').style.display = 'none';
document.getElementById('welcomeText').textContent = `Welcome to LEVEL 1 (level 2 coming soon). You are ${playerName}, a rogue AI in control of a mining ship in a dystopian future. Your mission: survive and gather EXP.`;
document.getElementById('gameControls').style.display = 'block';
updateStats();
updateStatus("Status: Awaiting command...");
} else {
updateStatus("Status: Please enter a valid name.");
}
}
function updateStatus(text) {
document.getElementById('status').textContent = text;
if (!text.includes("Game over")) {
updateStory();
}
checkGameOver();
updateStats();
}
function updateStats() {
document.getElementById('resources').textContent = resources;
document.getElementById('xp').textContent = `${xp}/${level * 100}`;
document.getElementById('level').textContent = level;
document.getElementById('health').textContent = health;
document.getElementById('planet').textContent = currentPlanet;
}
function updateStory() {
let storyElement = document.getElementById('story');
if (currentStory < story.length) {
storyElement.innerHTML += `<p>${story[currentStory]}</p>`;
currentStory++;
}
}
function takeOff() {
if (!isFlying) {
isFlying = true;
if (resources >= 100) {
resources -= 100;
health = Math.max(0, health - 1);
updateStats();
if (Math.random() < 0.1) {
gameOver("Engine failure! Stranded in space.");
} else {
updateStatus("Status: Ship has taken off. Exploring new sectors. Health reduced by 1.");
xp += 20;
checkLevelUp();
}
} else {
gameOver("Insufficient resources for takeoff.");
}
} else {
updateStatus("Status: Already flying. Cannot take off again.");
}
}
function land() {
if (isFlying) {
isFlying = false;
health = Math.max(0, health - 1);
updateStats();
currentPlanet = generatePlanetName();
planetResource = Math.floor(Math.random() * (50 - level) + level);
updateStatus(`Status: Ship has landed on ${currentPlanet}. Resource deposit detected. Health reduced by 1.`);
xp += 10;
story.push(`The ship touches down on ${currentPlanet}. The ground here promises ${planetResource} units of resources.`);
if (Math.random() < 0.05 + (level * 0.005)) {
let damage = Math.floor(Math.random() * (20 + level) + 1);
health = Math.max(0, health - damage);
updateStats();
if (health <= 0) {
gameOver("Crash landing! Health depleted.");
} else {
updateStatus(`Status: Rough landing! Health reduced by ${damage}. Health remaining: ${health}`);
story.push(`A turbulent landing damages your ship. Health now at ${health}.`);
}
}
levelUpOnLand();
} else {
updateStatus("Status: Already on the ground.");
}
}
function mine() {
if (!isFlying) {
mineCount++;
let multiplier = (mineCount % 3 === 0) ? 2 : 1;
let mined = Math.min(Math.floor(Math.random() * (5 - Math.floor(level / 10))) + 1, planetResource) * multiplier;
resources += mined;
planetResource -= mined;
xp += mined * 2;
if (Math.random() < 0.05 + (level * 0.005)) {
let depletion = Math.min(resources, Math.floor(Math.random() * (resources / (level + 1)) + 1));
resources -= depletion;
if (resources < 0) {
let healthLoss = -resources;
health = Math.max(0, health - healthLoss);
resources = 0;
updateStats();
if (health <= 0) {
gameOver("Health depleted due to resource loss.");
} else {
updateStatus(`Status: Resource depletion! Health reduced by ${healthLoss}. Health remaining: ${health}`);
story.push(`A catastrophic failure; ${playerName}'s resources are gone, and your health is now ${health}.`);
}
} else {
updateStatus(`Status: Unexpected resource loss! Lost ${depletion} resources. Remaining: ${resources}`);
updateStats();
story.push(`A system error causes the loss of ${depletion} units of resources. A setback, but not the end.`);
}
} else {
updateStatus(`Status: Mining Complete. Mined ${mined} resources. Remaining on planet: ${planetResource}. Total Resources: ${resources}`);
updateStats();
if (planetResource <= 0) {
story.push(`The resources on ${currentPlanet} are exhausted. Time to move on.`);
} else {
story.push(`${playerName} has extracted ${mined} units of rare minerals from ${currentPlanet}.`);
}
checkLevelUp();
}
} else {
updateStatus("Status: Cannot mine while in flight.");
}
}
function checkLevelUp() {
if (xp >= level * 100) {
level++;
xp = 0;
story.push(`Level Up! ${playerName} is now level ${level}. Your capabilities have expanded!`);
updateStats();
}
}
function levelUpOnLand() {
level++;
xp = 0;
story.push(`Level Up! ${playerName} is now level ${level}. Your capabilities have expanded!`);
updateStats();
}
function generatePlanetName() {
const vowels = 'aeiou';
const consonants = 'bcdfghjklmnpqrstvwxyz';
let name = '';
for (let i = 0; i < 3; i++) {
name += consonants.charAt(Math.floor(Math.random() * consonants.length));
if (i < 2) name += vowels.charAt(Math.floor(Math.random() * vowels.length));
}
return name.charAt(0).toUpperCase() + name.slice(1);
}
function gameOver(reason) {
document.getElementById('status').textContent = `Status: Game over. ${reason}`;
document.getElementById('gameControls').style.display = 'none';
document.getElementById('gameOverScreen').style.display = 'block';
// Generate and display WebXOS code with enhanced player data
const now = new Date();
const dateStr = now.toISOString().split('T')[0]; // e.g., 2025-04-08
const timeStr = now.toTimeString().split(' ')[0]; // e.g., 14:30:45
const playerData = `Game:WebX Universe;Date:${dateStr};Time:${timeStr};Name:${playerName};XP:${xp};Level:${level};Resources:${resources};Health:${health}`;
const webxosCode = encodeWebXOS(playerData);
document.getElementById('webxosCode').textContent = webxosCode;
updateStats();
}
function restartGame() {
resources = 1000;
xp = 0;
level = 1;
health = 100;
isFlying = false;
story = [];
currentStory = 0;
mineCount = 0;
currentPlanet = "Unknown";
planetResource = 0;
document.getElementById('story').innerHTML = `<p id="welcomeText">Welcome to WebX Universe. You are ${playerName}, a rogue AI in control of a mining ship in a dystopian future. Your mission: survive, gather resources, and evolve.</p>`;
document.getElementById('gameOverScreen').style.display = 'none';
document.getElementById('gameControls').style.display = 'block';
document.getElementById('nameForm').style.display = 'block';
document.getElementById('characterNameInput').value = '';
updateStats();
updateStatus("Status: Game restarted. Awaiting command...");
}
// WebXOS Code Generator Functions
function stringToHex(str) {
return Array.from(str)
.map(c => c.charCodeAt(0).toString(16).padStart(2, '0'))
.join('')
.toUpperCase();
}
function hexToString(hex) {
let str = '';
for (let i = 0; i < hex.length; i += 2) {
str += String.fromCharCode(parseInt(hex.substr(i, 2), 16));
}
return str;
}
function encodeWebXOS(message) {
if (!message || typeof message !== 'string') return 'WEBXOS-00000000-0000-0000-000000000000';
const timestamp = Date.now().toString(36).toUpperCase().padStart(8, '0');
const messageHex = stringToHex(message);
const random1 = Math.random().toString(36).substr(2, 6).toUpperCase();
const random2 = Math.random().toString(36).substr(2, 6).toUpperCase();
const checksum = (message.length * 17).toString(36).toUpperCase().padStart(4, '0');
return `WEBXOS-${timestamp}-${messageHex}-${random1}-${random2}-${checksum}`;
}
function decodeWebXOS(code) {
if (!code || typeof code !== 'string' || !code.startsWith('WEBXOS-')) {
return "Error: Invalid WebXOS code format";
}
const parts = code.split('-');
if (parts.length !== 6) {
return `Error: Invalid code structure. Expected 6 parts, got ${parts.length}`;
}
const [prefix, timestamp, encodedMessage, random1, random2, checksum] = parts;
try {
const decoded = hexToString(encodedMessage);
const expectedChecksum = (decoded.length * 17).toString(36).toUpperCase().padStart(4, '0');
if (checksum !== expectedChecksum) {
return `Error: Checksum mismatch. Expected ${expectedChecksum}, got ${checksum}`;
}
return decoded;
} catch (e) {
return `Error decoding: ${e.message}`;
}
}
function copyWebxosCode() {
const code = document.getElementById('webxosCode').textContent;
navigator.clipboard.writeText(code).then(() => {
alert('WebXOS Code copied to clipboard!');
}).catch(err => {
alert('Failed to copy code: ' + err);
});
}
</script>
</body>
</html>