forked from platanus-hack/platanus-hack-25-arcade
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
413 lines (374 loc) · 19.3 KB
/
Copy pathindex.html
File metadata and controls
413 lines (374 loc) · 19.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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Platanus Hack 25: Arcade Challenge</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Oxanium:wght@400;500;600;700&display=swap" rel="stylesheet">
<script src="https://cdn.tailwindcss.com"></script>
<script>
tailwind.config = {
theme: {
extend: {
fontFamily: {
oxanium: ['Oxanium', 'sans-serif'],
}
}
}
}
</script>
<style>
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}
</style>
</head>
<body class="bg-black text-white m-0 p-0">
<div id="root"></div>
<script crossorigin src="https://unpkg.com/react@18/umd/react.production.min.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"></script>
<script src="https://unpkg.com/@babel/standalone/babel.min.js"></script>
<script type="text/babel">
const { useState, useEffect } = React;
// Submission Modal Component
function SubmissionModal({ isOpen, onClose, checks, gitInfo, coverCheck }) {
const [step, setStep] = useState(1);
if (!isOpen) return null;
const handleNext = () => {
if (checks?.passed && gitInfo?.isGitRepo && coverCheck?.isValid) {
setStep(2);
} else {
alert('Please make sure all checks pass, you have a valid 800x600 PNG cover, and a valid Git repository configured.');
}
};
const handleSubmit = () => {
if (gitInfo?.remoteUrl) {
const submitUrl = `https://hack.platan.us/arcade/submit?repo=${encodeURIComponent(gitInfo.remoteUrl)}`;
window.open(submitUrl, '_blank');
onClose();
}
};
return (
<div
className="fixed inset-0 bg-black/85 backdrop-blur-sm z-50 flex items-center justify-center"
onClick={(e) => e.target === e.currentTarget && onClose()}
>
<div className="bg-[#111] border border-white/20 rounded-lg max-w-2xl w-[90%] max-h-[90vh] overflow-y-auto shadow-2xl">
{step === 1 ? (
<>
<div className="p-6 pb-4 border-b border-white/10">
<h2 className="font-oxanium text-2xl mb-2">🚀 Submit Your Game</h2>
<p className="text-sm text-gray-400">Ready to submit your arcade game to Platanus Hack 25?</p>
</div>
<div className="p-6">
<div className="text-center text-gray-500 text-xs uppercase tracking-wider mb-4">Step 1 of 2</div>
<div className="mb-6">
<h3 className="text-sm font-semibold uppercase tracking-wider text-white mb-3">📊 Current Status</h3>
<div className="space-y-2">
<div className="flex items-center bg-white/[0.03] rounded p-2 text-sm">
<span className="text-base mr-2">{coverCheck?.isValid ? '✅' : '❌'}</span>
<span className="flex-1 text-gray-300">Custom Cover (800x600)</span>
<span className="font-medium">{coverCheck?.isValid ? 'Valid' : 'Invalid'}</span>
</div>
<div className="flex items-center bg-white/[0.03] rounded p-2 text-sm">
<span className="text-base mr-2">{checks?.sizeKB <= 50 ? '✅' : '❌'}</span>
<span className="flex-1 text-gray-300">File Size</span>
<span className="font-medium">{checks?.sizeKB?.toFixed(2)} KB / 50 KB</span>
</div>
{checks?.results?.filter(r => r.name !== 'Size Check').map((result, i) => (
<div key={i} className="flex items-center bg-white/[0.03] rounded p-2 text-sm">
<span className="text-base mr-2">{result.passed ? '✅' : '❌'}</span>
<span className="flex-1 text-gray-300">{result.name}</span>
<span className="font-medium">{result.passed ? 'Pass' : 'Fail'}</span>
</div>
))}
</div>
</div>
<div className="mb-6">
<h3 className="text-sm font-semibold uppercase tracking-wider text-white mb-3">👤 GitHub Repository</h3>
{!gitInfo?.isGitRepo ? (
<div className="bg-orange-500/10 border border-orange-500/30 rounded p-3 text-orange-400 text-sm">
⚠️ Not a git repository. Please initialize a git repository and set up a GitHub remote.
</div>
) : (
<div className="flex justify-between bg-white/[0.03] rounded p-3 text-sm">
<span className="text-gray-400">Repository:</span>
<a href={gitInfo.remoteUrl} target="_blank" className="text-blue-400 hover:underline font-medium break-all">
{gitInfo.remoteUrl}
</a>
</div>
)}
</div>
</div>
<div className="p-4 pt-0 flex flex-col gap-3">
<button onClick={handleNext} className="w-full py-3 bg-green-500/10 text-green-400 border border-green-500/30 rounded hover:bg-green-500/15 hover:border-green-500/50 transition-all uppercase tracking-wider text-sm font-medium">
Next →
</button>
<button onClick={onClose} className="w-full py-3 bg-white/5 text-gray-400 border border-white/15 rounded hover:bg-white/[0.08] hover:border-white/25 transition-all uppercase tracking-wider text-sm font-medium">
Cancel
</button>
</div>
</>
) : (
<>
<div className="p-6 pb-4 border-b border-white/10">
<h2 className="font-oxanium text-2xl mb-2">📤 Push & Submit</h2>
<p className="text-sm text-gray-400">Before submitting, make sure you've pushed your changes to GitHub!</p>
</div>
<div className="p-6">
<div className="text-center text-gray-500 text-xs uppercase tracking-wider mb-4">Step 2 of 2</div>
<div className="mb-6">
<h3 className="text-sm font-semibold uppercase tracking-wider text-white mb-3">🎮 Game Cover</h3>
<div className="bg-white/[0.03] rounded p-3 flex justify-center">
<img
src="/cover.png"
alt="Game Cover"
className="max-w-full h-auto rounded border border-white/20"
style={{ maxHeight: '200px' }}
/>
</div>
</div>
<div className="mb-6">
<h3 className="text-sm font-semibold uppercase tracking-wider text-white mb-3">📌 Repository</h3>
<div className="bg-white/[0.03] rounded p-3">
<div className="text-xs text-gray-400 mb-2">GitHub Repository URL:</div>
<a href={gitInfo?.remoteUrl} target="_blank" className="text-blue-400 hover:text-blue-300 font-medium text-sm break-all block">
{gitInfo?.remoteUrl}
</a>
</div>
</div>
<div className="mb-6">
<h3 className="text-sm font-semibold uppercase tracking-wider text-white mb-3">✅ Final Checklist</h3>
<div className="bg-orange-500/10 border border-orange-500/30 rounded p-4 text-orange-400 text-sm leading-relaxed">
<p className="mb-3">📤 <strong>Make sure to push your code to GitHub first!</strong></p>
<p className="mb-3">Run: <code className="bg-black/30 px-2 py-1 rounded">git push origin main</code></p>
<p className="mb-3">🔒 <strong>After submission, no changes are allowed!</strong> This is your final version.</p>
<p>If you win the contest, you will be contacted via <strong>GitHub issue</strong> in your forked repository!</p>
</div>
</div>
</div>
<div className="p-4 pt-0 flex flex-col gap-3">
<button onClick={handleSubmit} className="w-full py-3 bg-green-500/10 text-green-400 border border-green-500/30 rounded hover:bg-green-500/15 hover:border-green-500/50 transition-all uppercase tracking-wider text-sm font-medium">
🎮 Submit to Platanus Hack
</button>
<button onClick={() => setStep(1)} className="w-full py-3 bg-white/5 text-gray-400 border border-white/15 rounded hover:bg-white/[0.08] hover:border-white/25 transition-all uppercase tracking-wider text-sm font-medium">
← Back
</button>
</div>
</>
)}
</div>
</div>
);
}
// Main App Component
function App() {
const [metadata, setMetadata] = useState({ game_name: 'Loading...', description: 'Loading game information...' });
const [checks, setChecks] = useState(null);
const [gitInfo, setGitInfo] = useState(null);
const [coverCheck, setCoverCheck] = useState(null);
const [isModalOpen, setIsModalOpen] = useState(false);
const [timeRemaining, setTimeRemaining] = useState('');
const loadData = async () => {
try {
const [metadataRes, checksRes, gitRes, coverRes] = await Promise.all([
fetch('/metadata.json'),
fetch('/api/checks'),
fetch('/api/git-info'),
fetch('/api/cover-check')
]);
const metadataData = await metadataRes.json();
const checksData = await checksRes.json();
const gitData = await gitRes.json();
const coverData = await coverRes.json();
setMetadata(metadataData);
setChecks(checksData);
setGitInfo(gitData);
setCoverCheck(coverData);
} catch (error) {
console.error('Failed to load data:', error);
}
};
useEffect(() => {
loadData();
const interval = setInterval(loadData, 2000);
return () => clearInterval(interval);
}, []);
// Countdown timer for deadline
useEffect(() => {
const updateCountdown = () => {
// Deadline: November 10, 2025 at 23:59 Chile time (UTC-3)
const deadline = new Date('2025-11-10T23:59:00-03:00');
const now = new Date();
const diff = deadline - now;
if (diff <= 0) {
setTimeRemaining('DEADLINE PASSED');
} else {
const days = Math.floor(diff / (1000 * 60 * 60 * 24));
const hours = Math.floor((diff % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
const minutes = Math.floor((diff % (1000 * 60 * 60)) / (1000 * 60));
const seconds = Math.floor((diff % (1000 * 60)) / 1000);
if (days > 0) {
setTimeRemaining(`${days}d ${hours}h ${minutes}m ${seconds}s`);
} else if (hours > 0) {
setTimeRemaining(`${hours}h ${minutes}m ${seconds}s`);
} else {
setTimeRemaining(`${minutes}m ${seconds}s`);
}
}
};
updateCountdown();
const interval = setInterval(updateCountdown, 1000);
return () => clearInterval(interval);
}, []);
const isPlaceholder = metadata.game_name?.includes('<') || metadata.description?.includes('<');
const isDeadlinePassed = timeRemaining === 'DEADLINE PASSED';
const canSubmit = !isPlaceholder && checks?.passed && coverCheck?.isValid && !isDeadlinePassed;
const percentage = Math.min((checks?.sizeKB / 50) * 100 || 0, 100);
const barColor = percentage < 50 ? 'bg-green-500' : percentage < 80 ? 'bg-orange-500' : 'bg-red-500';
return (
<div className="flex w-full h-screen">
{/* Sidebar */}
<div className="w-[280px] bg-white/[0.02] border-r border-white/10 p-6 flex flex-col overflow-y-auto">
<header className="mb-6">
<h1 className="font-oxanium text-xl mb-1 font-semibold text-gray-400 tracking-wide">platanus hack 25</h1>
<div className="text-[0.7rem] text-gray-600 uppercase tracking-widest">arcade challenge</div>
</header>
<div className={`mb-5 pb-5 border-b border-white/10 ${(isPlaceholder || !coverCheck?.isChanged) ? 'relative' : ''}`}>
<h2 className={`text-base font-semibold mb-1.5 ${isPlaceholder ? 'text-orange-500' : 'text-white'}`}>
{metadata.game_name}
</h2>
<p className={`text-xs leading-relaxed ${isPlaceholder ? 'text-orange-500' : 'text-gray-400'}`}>
{metadata.description}
</p>
{isPlaceholder && (
<div className="mt-2 text-[0.7rem] text-orange-500 bg-orange-500/10 border border-orange-500/30 rounded px-2 py-1.5">
⚠️ Update metadata.json
</div>
)}
{coverCheck && !coverCheck.isValid && (
<div className="mt-2 text-[0.7rem] text-orange-500 bg-orange-500/10 border border-orange-500/30 rounded px-2 py-1.5">
⚠️ {coverCheck.message}
</div>
)}
</div>
<div className="mb-5 p-4 bg-white/[0.03] border border-white/10 rounded">
<div className="text-[0.7rem] text-gray-500 uppercase tracking-wider mb-2">Minified File Size</div>
<div className="text-3xl font-semibold mb-1 tabular-nums">{checks?.sizeKB?.toFixed(2) || '--'} KB</div>
<div className="text-xs text-gray-500 mb-3">original: {checks?.originalSizeKB?.toFixed(2) || '--'} KB</div>
<div className="w-full h-2 bg-white/10 rounded overflow-hidden">
<div className={`h-full ${barColor} transition-all duration-300`} style={{ width: `${percentage}%` }}></div>
</div>
<div className="text-[0.7rem] text-gray-500 mt-1.5 text-right">of 50 KB</div>
</div>
<div className="flex-1">
<h3 className="mb-4 text-[0.85rem] font-medium text-gray-500 uppercase tracking-wider">checks</h3>
<div className="space-y-2">
{checks?.results?.filter(r => r.name !== 'Size Check').map((result, i) => (
<div key={i} className="flex flex-col py-2 text-sm border-b border-white/5 last:border-0">
<div className="flex items-center mb-0.5">
<span className="mr-2">{result.passed ? '✅' : '❌'}</span>
<span className="text-gray-300 font-medium">{result.name}</span>
</div>
<div className="text-xs text-gray-500 ml-7">{result.message}</div>
</div>
)) || <div className="text-gray-500 text-sm italic">Checking restrictions...</div>}
</div>
<div className={`mt-4 text-center py-3 rounded text-xs ${checks?.passed ? 'bg-green-500/10 text-green-400 border border-green-500/20' : 'bg-red-500/10 text-red-400 border border-red-500/20'}`}>
{checks?.passed ? 'all checks passed' : 'some checks failed'}
</div>
</div>
<div className="mt-6 pt-4 border-t border-white/10">
{isDeadlinePassed ? (
<div className="mb-4 p-3 bg-red-500/10 border border-red-500/30 rounded text-center">
<div className="text-red-400 text-sm font-medium mb-1">⏰ Submission Deadline Passed</div>
<div className="text-red-400/80 text-xs">Submissions closed on Nov 10, 2025 at 23:59 CLT</div>
</div>
) : (
<div className="mb-4 p-3 bg-blue-500/10 border border-blue-500/30 rounded text-center">
<div className="text-blue-400 text-xs uppercase tracking-wider mb-1">Time Remaining</div>
<div className="text-blue-300 text-lg font-bold tabular-nums">{timeRemaining || 'Loading...'}</div>
</div>
)}
<button
onClick={() => setIsModalOpen(true)}
disabled={!canSubmit}
className={`w-full py-3 rounded text-sm font-medium uppercase tracking-wider transition-all ${
canSubmit
? 'bg-green-500/10 text-green-400 border border-green-500/30 hover:bg-green-500/15 hover:border-green-500/50 cursor-pointer'
: 'bg-white/[0.02] text-gray-600 border border-white/5 cursor-not-allowed opacity-60'
}`}
>
🚀 Submit
</button>
</div>
</div>
{/* Main Content */}
<div className="flex-1 flex flex-col items-center justify-center p-5">
<iframe
id="game-frame"
width="800"
height="600"
sandbox="allow-scripts allow-same-origin"
className="border-2 border-white/30 rounded shadow-2xl shadow-white/10"
></iframe>
</div>
<SubmissionModal
isOpen={isModalOpen}
onClose={() => setIsModalOpen(false)}
checks={checks}
gitInfo={gitInfo}
coverCheck={coverCheck}
/>
</div>
);
}
// Load game in iframe
async function loadGame() {
const iframe = document.getElementById('game-frame');
iframe.setAttribute('sandbox', 'allow-scripts allow-same-origin');
try {
const response = await fetch('/game.js');
if (!response.ok) throw new Error(`Failed to fetch game.js: ${response.status}`);
const gameCode = await response.text();
const iframeDoc = iframe.contentDocument || iframe.contentWindow.document;
iframeDoc.open();
iframeDoc.write(`
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<style>
body { margin: 0; padding: 0; overflow: hidden; background: #000; }
</style>
<script>
window.initGame = function() {
console.log('Phaser loaded, initializing game...');
try {
${gameCode}
console.log('Game initialized successfully');
} catch (error) {
console.error('Game initialization error:', error);
}
};
<\/script>
<script src="https://cdn.jsdelivr.net/npm/phaser@3.87.0/dist/phaser.min.js" onload="initGame()"><\/script>
</head>
<body></body>
</html>
`);
iframeDoc.close();
} catch (error) {
console.error('Failed to load game:', error);
}
}
// Initialize
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<App />);
// Load game when ready
setTimeout(loadGame, 100);
</script>
</body>
</html>