Spaces:
Running
Running
Add 2 files
Browse files- README.md +6 -4
- index.html +721 -19
README.md
CHANGED
@@ -1,10 +1,12 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
colorTo: blue
|
6 |
sdk: static
|
7 |
pinned: false
|
|
|
|
|
8 |
---
|
9 |
|
10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
+
title: a-space
|
3 |
+
emoji: 🐳
|
4 |
+
colorFrom: blue
|
5 |
colorTo: blue
|
6 |
sdk: static
|
7 |
pinned: false
|
8 |
+
tags:
|
9 |
+
- deepsite
|
10 |
---
|
11 |
|
12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
@@ -1,19 +1,721 @@
|
|
1 |
-
<!
|
2 |
-
<html>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<!DOCTYPE html>
|
2 |
+
<html lang="en">
|
3 |
+
<head>
|
4 |
+
<meta charset="UTF-8">
|
5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6 |
+
<title>Code Battler - Defeat Bugs with Coding Knowledge!</title>
|
7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
8 |
+
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
|
9 |
+
<style>
|
10 |
+
@keyframes shake {
|
11 |
+
0%, 100% { transform: translateX(0); }
|
12 |
+
20%, 60% { transform: translateX(-10px); }
|
13 |
+
40%, 80% { transform: translateX(10px); }
|
14 |
+
}
|
15 |
+
.shake {
|
16 |
+
animation: shake 0.5s;
|
17 |
+
}
|
18 |
+
.damage-number {
|
19 |
+
position: absolute;
|
20 |
+
font-weight: bold;
|
21 |
+
color: #ef4444;
|
22 |
+
animation: fadeOut 1s ease-out forwards;
|
23 |
+
pointer-events: none;
|
24 |
+
font-size: 1.5rem;
|
25 |
+
text-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
26 |
+
}
|
27 |
+
@keyframes fadeOut {
|
28 |
+
to { opacity: 0; transform: translateY(-30px); }
|
29 |
+
}
|
30 |
+
.modal {
|
31 |
+
transition: opacity 0.3s ease;
|
32 |
+
}
|
33 |
+
.modal-content {
|
34 |
+
transition: all 0.3s ease;
|
35 |
+
transform: translateY(20px);
|
36 |
+
}
|
37 |
+
.modal.show {
|
38 |
+
opacity: 1;
|
39 |
+
pointer-events: all;
|
40 |
+
}
|
41 |
+
.modal.show .modal-content {
|
42 |
+
transform: translateY(0);
|
43 |
+
}
|
44 |
+
#battle-log {
|
45 |
+
scrollbar-width: thin;
|
46 |
+
scrollbar-color: #c7d2fe #f1f5f9;
|
47 |
+
}
|
48 |
+
#battle-log::-webkit-scrollbar {
|
49 |
+
width: 8px;
|
50 |
+
}
|
51 |
+
#battle-log::-webkit-scrollbar-track {
|
52 |
+
background: #f1f5f9;
|
53 |
+
border-radius: 4px;
|
54 |
+
}
|
55 |
+
#battle-log::-webkit-scrollbar-thumb {
|
56 |
+
background-color: #c7d2fe;
|
57 |
+
border-radius: 4px;
|
58 |
+
}
|
59 |
+
</style>
|
60 |
+
</head>
|
61 |
+
<body class="min-h-screen bg-gray-50 font-sans">
|
62 |
+
<div class="container mx-auto px-4 py-6 max-w-6xl">
|
63 |
+
<!-- Header -->
|
64 |
+
<header class="flex flex-col sm:flex-row justify-between items-start sm:items-center mb-8 gap-4">
|
65 |
+
<div class="flex items-center">
|
66 |
+
<div class="mr-3 bg-indigo-600 text-white p-2 rounded-lg shadow">
|
67 |
+
<i class="fas fa-gamepad text-xl"></i>
|
68 |
+
</div>
|
69 |
+
<div>
|
70 |
+
<h1 class="text-2xl font-bold text-gray-800">Code Battler</h1>
|
71 |
+
<p class="text-sm text-gray-500">Defeat bugs with your coding knowledge</p>
|
72 |
+
</div>
|
73 |
+
</div>
|
74 |
+
<div class="flex items-center gap-3">
|
75 |
+
<div class="bg-white rounded-lg px-3 py-1.5 shadow-sm flex items-center border border-gray-100">
|
76 |
+
<i class="fas fa-coins text-yellow-500 mr-2 text-sm"></i>
|
77 |
+
<span id="coins" class="font-medium">0</span>
|
78 |
+
</div>
|
79 |
+
<div class="bg-white rounded-lg px-3 py-1.5 shadow-sm flex items-center border border-gray-100">
|
80 |
+
<i class="fas fa-trophy text-indigo-500 mr-2 text-sm"></i>
|
81 |
+
<span id="level" class="font-medium">1</span>
|
82 |
+
</div>
|
83 |
+
</div>
|
84 |
+
</header>
|
85 |
+
|
86 |
+
<!-- Game Layout -->
|
87 |
+
<div class="grid grid-cols-1 lg:grid-cols-3 gap-6">
|
88 |
+
<!-- Player Area -->
|
89 |
+
<div class="bg-white p-6 rounded-xl shadow-sm border border-gray-100 flex flex-col items-center">
|
90 |
+
<h2 class="text-lg font-semibold text-gray-800 mb-4 flex items-center">
|
91 |
+
<i class="fas fa-user-shield mr-2 text-indigo-500"></i> Your Pet
|
92 |
+
</h2>
|
93 |
+
<div class="mb-4 relative w-40 h-40 bg-indigo-50 rounded-full flex items-center justify-center shadow">
|
94 |
+
<img id="player-pet-img" src="https://cdn-icons-png.flaticon.com/512/616/616408.png" alt="Pet" class="w-full h-full object-contain">
|
95 |
+
</div>
|
96 |
+
|
97 |
+
<div class="w-full mb-4">
|
98 |
+
<div class="h-2 bg-gray-200 rounded-full w-full">
|
99 |
+
<div id="player-health" class="h-full rounded-full bg-gradient-to-r from-green-500 to-green-400" style="width: 100%"></div>
|
100 |
+
</div>
|
101 |
+
<div class="flex justify-between text-xs text-gray-500 mt-1">
|
102 |
+
<span>HP</span>
|
103 |
+
<span id="player-hp-text">15/15</span>
|
104 |
+
</div>
|
105 |
+
</div>
|
106 |
+
|
107 |
+
<div class="text-center w-full">
|
108 |
+
<h3 id="pet-name" class="font-semibold text-gray-800">Code Cat</h3>
|
109 |
+
<p id="pet-level" class="text-xs text-gray-500">Level <span class="font-medium">1</span></p>
|
110 |
+
|
111 |
+
<div class="mt-6 grid grid-cols-2 gap-2 w-full">
|
112 |
+
<button id="attack-btn" class="bg-red-500 hover:bg-red-600 text-white py-2 px-3 rounded-lg text-sm transition">
|
113 |
+
<i class="fas fa-bolt mr-1"></i>Attack
|
114 |
+
</button>
|
115 |
+
<button id="heal-btn" class="bg-green-500 hover:bg-green-600 text-white py-2 px-3 rounded-lg text-sm transition">
|
116 |
+
<i class="fas fa-heart mr-1"></i>Heal
|
117 |
+
</button>
|
118 |
+
<button id="special-btn" class="bg-indigo-500 hover:bg-indigo-600 text-white py-2 px-3 rounded-lg text-sm transition col-span-2">
|
119 |
+
<i class="fas fa-star mr-1"></i>Special (2 moves)
|
120 |
+
</button>
|
121 |
+
</div>
|
122 |
+
</div>
|
123 |
+
</div>
|
124 |
+
|
125 |
+
<!-- Battle Log & Question Area -->
|
126 |
+
<div class="flex flex-col gap-4">
|
127 |
+
<div class="bg-white p-6 rounded-xl shadow-sm border border-gray-100 flex-1">
|
128 |
+
<h2 class="text-lg font-semibold text-gray-800 mb-3 flex items-center">
|
129 |
+
<i class="fas fa-scroll mr-2 text-indigo-500"></i> Battle Log
|
130 |
+
</h2>
|
131 |
+
<div id="battle-log" class="h-64 overflow-y-auto bg-gray-50 rounded-lg p-3 space-y-2 text-sm">
|
132 |
+
<p class="text-gray-500 italic">Welcome to Code Battler! Defeat monsters by answering coding questions correctly.</p>
|
133 |
+
</div>
|
134 |
+
</div>
|
135 |
+
|
136 |
+
<div id="question-area" class="bg-white p-6 rounded-xl shadow-sm border border-gray-100 hidden">
|
137 |
+
<h3 class="font-semibold mb-3 text-gray-800 flex items-center">
|
138 |
+
<i class="fas fa-question-circle mr-2 text-indigo-500"></i> Code Challenge
|
139 |
+
</h3>
|
140 |
+
<p id="question-text" class="mb-4 text-gray-700"></p>
|
141 |
+
<div id="options" class="grid grid-cols-1 gap-2"></div>
|
142 |
+
</div>
|
143 |
+
|
144 |
+
<div class="flex gap-2">
|
145 |
+
<button id="learn-btn" class="bg-gray-100 hover:bg-gray-200 text-gray-700 py-2 px-4 rounded-lg text-sm flex-1 transition">
|
146 |
+
<i class="fas fa-book mr-1"></i> Learn
|
147 |
+
</button>
|
148 |
+
<button id="shop-btn" class="bg-gray-100 hover:bg-gray-200 text-gray-700 py-2 px-4 rounded-lg text-sm flex-1 transition">
|
149 |
+
<i class="fas fa-shopping-cart mr-1"></i> Shop
|
150 |
+
</button>
|
151 |
+
</div>
|
152 |
+
</div>
|
153 |
+
|
154 |
+
<!-- Enemy Area -->
|
155 |
+
<div class="bg-white p-6 rounded-xl shadow-sm border border-gray-100 flex flex-col items-center">
|
156 |
+
<h2 class="text-lg font-semibold text-gray-800 mb-4 flex items-center">
|
157 |
+
<i class="fas fa-bug mr-2 text-red-500"></i> Enemy
|
158 |
+
</h2>
|
159 |
+
|
160 |
+
<div class="mb-4 relative w-40 h-40 bg-red-50 rounded-full flex items-center justify-center shadow">
|
161 |
+
<img id="enemy-img" src="https://cdn-icons-png.flaticon.com/512/740/740878.png" alt="Enemy" class="w-full h-full object-contain">
|
162 |
+
</div>
|
163 |
+
|
164 |
+
<div class="w-full mb-4">
|
165 |
+
<div class="h-2 bg-gray-200 rounded-full w-full">
|
166 |
+
<div id="enemy-health" class="h-full rounded-full bg-gradient-to-r from-green-500 to-green-400" style="width: 100%"></div>
|
167 |
+
</div>
|
168 |
+
<div class="flex justify-between text-xs text-gray-500 mt-1">
|
169 |
+
<span>HP</span>
|
170 |
+
<span id="enemy-hp-text">15/15</span>
|
171 |
+
</div>
|
172 |
+
</div>
|
173 |
+
|
174 |
+
<div class="text-center w-full">
|
175 |
+
<h3 id="enemy-name" class="font-semibold text-gray-800">Bug Monster</h3>
|
176 |
+
<p id="enemy-level" class="text-xs text-gray-500">Level <span class="font-medium">1</span></p>
|
177 |
+
|
178 |
+
<div class="mt-4 bg-gray-50 rounded-lg p-3 shadow-sm">
|
179 |
+
<h4 class="font-medium text-xs mb-1 text-gray-700 flex items-center">
|
180 |
+
<i class="fas fa-eye mr-1 text-indigo-500"></i> Next Move
|
181 |
+
</h4>
|
182 |
+
<p id="enemy-next-move" class="text-xs text-gray-700">Preparing attack...</p>
|
183 |
+
</div>
|
184 |
+
</div>
|
185 |
+
</div>
|
186 |
+
</div>
|
187 |
+
</div>
|
188 |
+
|
189 |
+
<!-- Modals -->
|
190 |
+
<div id="shop-modal" class="fixed inset-0 bg-black bg-opacity-30 flex items-center justify-center p-4 z-50 opacity-0 pointer-events-none modal">
|
191 |
+
<div class="w-full max-w-2xl max-h-[90vh] overflow-auto">
|
192 |
+
<div class="bg-white rounded-xl shadow-lg modal-content p-6">
|
193 |
+
<div class="flex justify-between items-center mb-5 pb-3 border-b border-gray-200">
|
194 |
+
<h2 class="text-xl font-semibold text-gray-800">
|
195 |
+
<i class="fas fa-paw mr-2 text-indigo-500"></i> Pet Shop
|
196 |
+
</h2>
|
197 |
+
<button id="close-shop" class="text-gray-400 hover:text-gray-600">
|
198 |
+
<i class="fas fa-times"></i>
|
199 |
+
</button>
|
200 |
+
</div>
|
201 |
+
|
202 |
+
<div class="grid grid-cols-2 md:grid-cols-3 gap-4" id="shop-pets">
|
203 |
+
<!-- Pets will be added here -->
|
204 |
+
</div>
|
205 |
+
</div>
|
206 |
+
</div>
|
207 |
+
</div>
|
208 |
+
|
209 |
+
<div id="game-over-modal" class="fixed inset-0 bg-black bg-opacity-30 flex items-center justify-center p-4 z-50 opacity-0 pointer-events-none modal">
|
210 |
+
<div class="w-full max-w-sm">
|
211 |
+
<div class="bg-white rounded-xl shadow-lg p-6 text-center modal-content">
|
212 |
+
<div class="w-16 h-16 mx-auto mb-4 rounded-full bg-red-100 flex items-center justify-center">
|
213 |
+
<i class="fas fa-skull-crossbones text-2xl text-red-500"></i>
|
214 |
+
</div>
|
215 |
+
<h2 id="game-over-title" class="text-xl font-semibold text-gray-800 mb-1">Game Over</h2>
|
216 |
+
<p id="game-over-message" class="text-gray-600 mb-5">You were defeated!</p>
|
217 |
+
<button id="restart-btn" class="bg-indigo-500 hover:bg-indigo-600 text-white py-2 px-6 rounded-lg transition">
|
218 |
+
<i class="fas fa-redo mr-1"></i> Play Again
|
219 |
+
</button>
|
220 |
+
</div>
|
221 |
+
</div>
|
222 |
+
</div>
|
223 |
+
|
224 |
+
<div id="level-up-modal" class="fixed inset-0 bg-black bg-opacity-30 flex items-center justify-center p-4 z-50 opacity-0 pointer-events-none modal">
|
225 |
+
<div class="w-full max-w-sm">
|
226 |
+
<div class="bg-white rounded-xl shadow-lg p-6 text-center modal-content">
|
227 |
+
<div class="w-16 h-16 mx-auto mb-4 rounded-full bg-indigo-100 flex items-center justify-center">
|
228 |
+
<i class="fas fa-trophy text-2xl text-indigo-500"></i>
|
229 |
+
</div>
|
230 |
+
<h2 class="text-xl font-semibold text-gray-800 mb-1">Level Up!</h2>
|
231 |
+
<p class="text-gray-600">You've reached level <span id="new-level" class="font-semibold text-indigo-500">2</span>!</p>
|
232 |
+
<div class="flex items-center justify-center my-4">
|
233 |
+
<i class="fas fa-coins text-yellow-500 mr-2"></i>
|
234 |
+
<span class="font-medium">+50 coins bonus!</span>
|
235 |
+
</div>
|
236 |
+
<button id="continue-btn" class="bg-indigo-500 hover:bg-indigo-600 text-white py-2 px-6 rounded-lg transition">
|
237 |
+
<i class="fas fa-arrow-right mr-1"></i> Continue
|
238 |
+
</button>
|
239 |
+
</div>
|
240 |
+
</div>
|
241 |
+
</div>
|
242 |
+
|
243 |
+
<script>
|
244 |
+
// Game State
|
245 |
+
const gameState = {
|
246 |
+
coins: 0,
|
247 |
+
level: 1,
|
248 |
+
currentPet: 'cat',
|
249 |
+
unlockedPets: ['cat'],
|
250 |
+
playerHealth: 15,
|
251 |
+
maxHealth: 15,
|
252 |
+
enemyHealth: 15,
|
253 |
+
attackCount: 0,
|
254 |
+
gameActive: true,
|
255 |
+
enemyNextMove: 'attack',
|
256 |
+
currentEnemy: 0,
|
257 |
+
totalCoinsEarned: 0,
|
258 |
+
pets: {
|
259 |
+
cat: { name: 'Code Cat', image: 'https://cdn-icons-png.flaticon.com/512/616/616408.png', cost: 0 },
|
260 |
+
dog: { name: 'Debug Dog', image: 'https://cdn-icons-png.flaticon.com/512/616/616430.png', cost: 50, special: "+1 attack damage" },
|
261 |
+
owl: { name: 'Syntax Owl', image: 'https://cdn-icons-png.flaticon.com/512/3281/3281289.png', cost: 150, special: "+10% heal power" }
|
262 |
+
},
|
263 |
+
enemies: [
|
264 |
+
{ name: 'Bug Monster', image: 'https://cdn-icons-png.flaticon.com/512/740/740878.png' },
|
265 |
+
{ name: 'Glitch Gremlin', image: 'https://cdn-icons-png.flaticon.com/512/2491/2491902.png' },
|
266 |
+
{ name: 'Error Eel', image: 'https://cdn-icons-png.flaticon.com/512/3069/3069172.png' }
|
267 |
+
],
|
268 |
+
questions: [
|
269 |
+
{
|
270 |
+
question: "Which HTML tag is used to link an external CSS file?",
|
271 |
+
options: ["<script>", "<style>", "<link>", "<css>"],
|
272 |
+
answer: 2
|
273 |
+
},
|
274 |
+
{
|
275 |
+
question: "Which CSS property changes the text color?",
|
276 |
+
options: ["text-color", "font-color", "color", "text-style"],
|
277 |
+
answer: 2
|
278 |
+
},
|
279 |
+
{
|
280 |
+
question: "How do you write 'Hello World' in an alert box?",
|
281 |
+
options: ["alertBox('Hello World')", "alert('Hello World')", "msg('Hello World')", "msgBox('Hello World')"],
|
282 |
+
answer: 1
|
283 |
+
}
|
284 |
+
]
|
285 |
+
};
|
286 |
+
|
287 |
+
// DOM Elements
|
288 |
+
const coinsDisplay = document.getElementById('coins');
|
289 |
+
const levelDisplay = document.getElementById('level');
|
290 |
+
const playerHealthBar = document.getElementById('player-health');
|
291 |
+
const enemyHealthBar = document.getElementById('enemy-health');
|
292 |
+
const playerHpText = document.getElementById('player-hp-text');
|
293 |
+
const enemyHpText = document.getElementById('enemy-hp-text');
|
294 |
+
const battleLog = document.getElementById('battle-log');
|
295 |
+
const attackBtn = document.getElementById('attack-btn');
|
296 |
+
const healBtn = document.getElementById('heal-btn');
|
297 |
+
const specialBtn = document.getElementById('special-btn');
|
298 |
+
const shopBtn = document.getElementById('shop-btn');
|
299 |
+
const learnBtn = document.getElementById('learn-btn');
|
300 |
+
const shopModal = document.getElementById('shop-modal');
|
301 |
+
const closeShopBtn = document.getElementById('close-shop');
|
302 |
+
const gameOverModal = document.getElementById('game-over-modal');
|
303 |
+
const restartBtn = document.getElementById('restart-btn');
|
304 |
+
const levelUpModal = document.getElementById('level-up-modal');
|
305 |
+
const continueBtn = document.getElementById('continue-btn');
|
306 |
+
const questionArea = document.getElementById('question-area');
|
307 |
+
const questionText = document.getElementById('question-text');
|
308 |
+
const optionsContainer = document.getElementById('options');
|
309 |
+
const playerPetImg = document.getElementById('player-pet-img');
|
310 |
+
const petNameDisplay = document.getElementById('pet-name');
|
311 |
+
const petLevelDisplay = document.getElementById('pet-level');
|
312 |
+
const enemyImage = document.getElementById('enemy-img');
|
313 |
+
const enemyNameDisplay = document.getElementById('enemy-name');
|
314 |
+
const enemyLevelDisplay = document.getElementById('enemy-level');
|
315 |
+
const enemyNextMoveDisplay = document.getElementById('enemy-next-move');
|
316 |
+
const newLevelDisplay = document.getElementById('new-level');
|
317 |
+
const shopPetsContainer = document.getElementById('shop-pets');
|
318 |
+
|
319 |
+
// Helper functions
|
320 |
+
function showModal(modal) {
|
321 |
+
modal.classList.add('show');
|
322 |
+
}
|
323 |
+
|
324 |
+
function hideModal(modal) {
|
325 |
+
modal.classList.remove('show');
|
326 |
+
}
|
327 |
+
|
328 |
+
function addToLog(message, type = 'info') {
|
329 |
+
const colors = {
|
330 |
+
player: 'bg-blue-50 text-blue-800',
|
331 |
+
enemy: 'bg-red-50 text-red-800',
|
332 |
+
info: 'bg-gray-50 text-gray-600'
|
333 |
+
};
|
334 |
+
const logEntry = document.createElement('div');
|
335 |
+
logEntry.className = `p-2 rounded ${colors[type]}`;
|
336 |
+
logEntry.textContent = message;
|
337 |
+
battleLog.appendChild(logEntry);
|
338 |
+
battleLog.scrollTop = battleLog.scrollHeight;
|
339 |
+
}
|
340 |
+
|
341 |
+
function showDamage(element, amount, isHeal = false) {
|
342 |
+
const damageElement = document.createElement('div');
|
343 |
+
damageElement.className = isHeal ? 'heal-number' : 'damage-number';
|
344 |
+
damageElement.textContent = (isHeal ? '+' : '-') + amount;
|
345 |
+
damageElement.style.color = isHeal ? '#10b981' : '#ef4444';
|
346 |
+
element.appendChild(damageElement);
|
347 |
+
setTimeout(() => damageElement.remove(), 1000);
|
348 |
+
}
|
349 |
+
|
350 |
+
function updateUI() {
|
351 |
+
coinsDisplay.textContent = gameState.coins;
|
352 |
+
levelDisplay.textContent = gameState.level;
|
353 |
+
|
354 |
+
// Update health bars
|
355 |
+
const playerHealthPercent = (gameState.playerHealth / gameState.maxHealth) * 100;
|
356 |
+
const enemyHealthPercent = (gameState.enemyHealth / 15) * 100;
|
357 |
+
|
358 |
+
playerHealthBar.style.width = `${playerHealthPercent}%`;
|
359 |
+
enemyHealthBar.style.width = `${enemyHealthPercent}%`;
|
360 |
+
|
361 |
+
// Update health colors
|
362 |
+
playerHealthBar.className = `h-full rounded-full ${
|
363 |
+
playerHealthPercent > 70 ? 'bg-gradient-to-r from-green-500 to-green-400' :
|
364 |
+
playerHealthPercent > 30 ? 'bg-gradient-to-r from-yellow-500 to-yellow-400' :
|
365 |
+
'bg-gradient-to-r from-red-500 to-red-400'
|
366 |
+
}`;
|
367 |
+
|
368 |
+
enemyHealthBar.className = `h-full rounded-full ${
|
369 |
+
enemyHealthPercent > 70 ? 'bg-gradient-to-r from-green-500 to-green-400' :
|
370 |
+
enemyHealthPercent > 30 ? 'bg-gradient-to-r from-yellow-500 to-yellow-400' :
|
371 |
+
'bg-gradient-to-r from-red-500 to-red-400'
|
372 |
+
}`;
|
373 |
+
|
374 |
+
playerHpText.textContent = `${gameState.playerHealth}/${gameState.maxHealth}`;
|
375 |
+
enemyHpText.textContent = `${gameState.enemyHealth}/15`;
|
376 |
+
|
377 |
+
// Update pet info
|
378 |
+
playerPetImg.src = gameState.pets[gameState.currentPet].image;
|
379 |
+
petNameDisplay.textContent = gameState.pets[gameState.currentPet].name;
|
380 |
+
petLevelDisplay.innerHTML = `Level <span class="font-medium">${gameState.level}</span>`;
|
381 |
+
|
382 |
+
// Update enemy info
|
383 |
+
enemyImage.src = gameState.enemies[gameState.currentEnemy].image;
|
384 |
+
enemyNameDisplay.textContent = gameState.enemies[gameState.currentEnemy].name;
|
385 |
+
enemyLevelDisplay.innerHTML = `Level <span class="font-medium">${gameState.level}</span>`;
|
386 |
+
|
387 |
+
// Update button states
|
388 |
+
attackBtn.disabled = !gameState.gameActive;
|
389 |
+
healBtn.disabled = !gameState.gameActive;
|
390 |
+
specialBtn.disabled = !gameState.gameActive;
|
391 |
+
}
|
392 |
+
|
393 |
+
function setEnemy() {
|
394 |
+
const enemy = gameState.enemies[gameState.currentEnemy];
|
395 |
+
enemyImage.src = enemy.image;
|
396 |
+
enemyNameDisplay.textContent = enemy.name;
|
397 |
+
enemyHealthBar.style.width = '100%';
|
398 |
+
gameState.enemyHealth = 15;
|
399 |
+
gameState.enemyNextMove = Math.random() > 0.3 ? 'attack' : 'heal';
|
400 |
+
enemyNextMoveDisplay.textContent = gameState.enemyNextMove === 'attack' ? 'Preparing attack...' : 'Preparing to heal...';
|
401 |
+
}
|
402 |
+
|
403 |
+
// Game Actions
|
404 |
+
function playerAttack() {
|
405 |
+
if (!gameState.gameActive) return;
|
406 |
+
|
407 |
+
let damage = Math.floor(Math.random() * 3) + 2; // 2-4 damage
|
408 |
+
if (gameState.currentPet === 'dog') damage += 1; // Debug Dog bonus
|
409 |
+
|
410 |
+
gameState.enemyHealth -= damage;
|
411 |
+
if (gameState.enemyHealth < 0) gameState.enemyHealth = 0;
|
412 |
+
|
413 |
+
enemyImage.parentElement.classList.add('shake');
|
414 |
+
showDamage(enemyImage.parentElement, damage);
|
415 |
+
addToLog(`Your ${gameState.pets[gameState.currentPet].name} attacks for ${damage} damage!`, 'player');
|
416 |
+
updateUI();
|
417 |
+
|
418 |
+
setTimeout(() => {
|
419 |
+
enemyImage.parentElement.classList.remove('shake');
|
420 |
+
if (gameState.enemyHealth <= 0) {
|
421 |
+
enemyDefeated();
|
422 |
+
} else {
|
423 |
+
gameState.attackCount++;
|
424 |
+
if (gameState.attackCount % 2 === 0) {
|
425 |
+
showQuestion();
|
426 |
+
} else {
|
427 |
+
setTimeout(enemyTurn, 1000);
|
428 |
+
}
|
429 |
+
}
|
430 |
+
}, 500);
|
431 |
+
}
|
432 |
+
|
433 |
+
function playerHeal() {
|
434 |
+
if (!gameState.gameActive) return;
|
435 |
+
|
436 |
+
let healAmount = Math.floor(Math.random() * 3) + 2; // 2-4 heal
|
437 |
+
if (gameState.currentPet === 'owl') healAmount = Math.floor(healAmount * 1.1); // Syntax Owl bonus
|
438 |
+
|
439 |
+
gameState.playerHealth += healAmount;
|
440 |
+
if (gameState.playerHealth > gameState.maxHealth) gameState.playerHealth = gameState.maxHealth;
|
441 |
+
|
442 |
+
playerPetImg.parentElement.classList.add('shake');
|
443 |
+
showDamage(playerPetImg.parentElement, healAmount, true);
|
444 |
+
addToLog(`Your ${gameState.pets[gameState.currentPet].name} heals for ${healAmount} health!`, 'player');
|
445 |
+
updateUI();
|
446 |
+
|
447 |
+
setTimeout(() => {
|
448 |
+
playerPetImg.parentElement.classList.remove('shake');
|
449 |
+
gameState.attackCount++;
|
450 |
+
if (gameState.attackCount % 2 === 0) {
|
451 |
+
showQuestion();
|
452 |
+
} else {
|
453 |
+
setTimeout(enemyTurn, 1000);
|
454 |
+
}
|
455 |
+
}, 500);
|
456 |
+
}
|
457 |
+
|
458 |
+
function playerSpecial() {
|
459 |
+
if (!gameState.gameActive) return;
|
460 |
+
|
461 |
+
let damage = Math.floor(Math.random() * 5) + 3; // 3-7 damage
|
462 |
+
if (gameState.currentPet === 'dog') damage += 1; // Debug Dog bonus
|
463 |
+
|
464 |
+
gameState.enemyHealth -= damage;
|
465 |
+
if (gameState.enemyHealth < 0) gameState.enemyHealth = 0;
|
466 |
+
|
467 |
+
enemyImage.parentElement.classList.add('shake');
|
468 |
+
showDamage(enemyImage.parentElement, damage);
|
469 |
+
addToLog(`Your ${gameState.pets[gameState.currentPet].name} uses SPECIAL for ${damage} damage!`, 'player');
|
470 |
+
updateUI();
|
471 |
+
|
472 |
+
setTimeout(() => {
|
473 |
+
enemyImage.parentElement.classList.remove('shake');
|
474 |
+
if (gameState.enemyHealth <= 0) {
|
475 |
+
enemyDefeated();
|
476 |
+
} else {
|
477 |
+
gameState.attackCount += 2;
|
478 |
+
showQuestion();
|
479 |
+
}
|
480 |
+
}, 500);
|
481 |
+
}
|
482 |
+
|
483 |
+
function enemyTurn() {
|
484 |
+
if (!gameState.gameActive) return;
|
485 |
+
|
486 |
+
if (gameState.enemyNextMove === 'attack') {
|
487 |
+
const damage = Math.floor(Math.random() * 3) + 1; // 1-3 damage
|
488 |
+
gameState.playerHealth -= damage;
|
489 |
+
if (gameState.playerHealth < 0) gameState.playerHealth = 0;
|
490 |
+
|
491 |
+
playerPetImg.parentElement.classList.add('shake');
|
492 |
+
showDamage(playerPetImg.parentElement, damage);
|
493 |
+
addToLog(`${gameState.enemies[gameState.currentEnemy].name} attacks for ${damage} damage!`, 'enemy');
|
494 |
+
|
495 |
+
setTimeout(() => {
|
496 |
+
playerPetImg.parentElement.classList.remove('shake');
|
497 |
+
if (gameState.playerHealth <= 0) {
|
498 |
+
gameOver(false);
|
499 |
+
} else {
|
500 |
+
gameState.enemyNextMove = Math.random() > 0.3 ? 'attack' : 'heal';
|
501 |
+
enemyNextMoveDisplay.textContent = gameState.enemyNextMove === 'attack' ? 'Preparing attack...' : 'Preparing to heal...';
|
502 |
+
updateUI();
|
503 |
+
}
|
504 |
+
}, 500);
|
505 |
+
} else {
|
506 |
+
const healAmount = Math.floor(Math.random() * 3) + 1; // 1-3 heal
|
507 |
+
gameState.enemyHealth += healAmount;
|
508 |
+
if (gameState.enemyHealth > 15) gameState.enemyHealth = 15;
|
509 |
+
|
510 |
+
showDamage(enemyImage.parentElement, healAmount, true);
|
511 |
+
addToLog(`${gameState.enemies[gameState.currentEnemy].name} heals for ${healAmount} health!`, 'enemy');
|
512 |
+
gameState.enemyNextMove = Math.random() > 0.3 ? 'attack' : 'heal';
|
513 |
+
enemyNextMoveDisplay.textContent = gameState.enemyNextMove === 'attack' ? 'Preparing attack...' : 'Preparing to heal...';
|
514 |
+
updateUI();
|
515 |
+
}
|
516 |
+
}
|
517 |
+
|
518 |
+
function enemyDefeated() {
|
519 |
+
const coinsEarned = Math.floor(Math.random() * 20) + 10 * gameState.level;
|
520 |
+
gameState.coins += coinsEarned;
|
521 |
+
gameState.totalCoinsEarned += coinsEarned;
|
522 |
+
gameState.currentEnemy++;
|
523 |
+
|
524 |
+
addToLog(`You defeated ${gameState.enemies[gameState.currentEnemy-1].name} and earned ${coinsEarned} coins!`, 'player');
|
525 |
+
|
526 |
+
if (gameState.currentEnemy >= gameState.enemies.length) {
|
527 |
+
gameState.currentEnemy = 0;
|
528 |
+
levelUp();
|
529 |
+
} else {
|
530 |
+
setTimeout(() => {
|
531 |
+
setEnemy();
|
532 |
+
addToLog(`A wild ${gameState.enemies[gameState.currentEnemy].name} appeared!`, 'enemy');
|
533 |
+
updateUI();
|
534 |
+
}, 1500);
|
535 |
+
}
|
536 |
+
updateUI();
|
537 |
+
}
|
538 |
+
|
539 |
+
function levelUp() {
|
540 |
+
gameState.level++;
|
541 |
+
const coinsBonus = 50;
|
542 |
+
gameState.coins += coinsBonus;
|
543 |
+
gameState.totalCoinsEarned += coinsBonus;
|
544 |
+
gameState.maxHealth += 5;
|
545 |
+
gameState.playerHealth = gameState.maxHealth;
|
546 |
+
|
547 |
+
newLevelDisplay.textContent = gameState.level;
|
548 |
+
showModal(levelUpModal);
|
549 |
+
gameState.gameActive = false;
|
550 |
+
updateUI();
|
551 |
+
}
|
552 |
+
|
553 |
+
function gameOver(won) {
|
554 |
+
gameState.gameActive = false;
|
555 |
+
showModal(gameOverModal);
|
556 |
+
}
|
557 |
+
|
558 |
+
function showQuestion() {
|
559 |
+
const randomQuestion = gameState.questions[Math.floor(Math.random() * gameState.questions.length)];
|
560 |
+
questionText.textContent = randomQuestion.question;
|
561 |
+
|
562 |
+
optionsContainer.innerHTML = '';
|
563 |
+
randomQuestion.options.forEach((option, index) => {
|
564 |
+
const button = document.createElement('button');
|
565 |
+
button.textContent = option;
|
566 |
+
button.className = 'bg-gray-100 hover:bg-gray-200 text-gray-700 py-2 px-3 rounded text-left transition question-option';
|
567 |
+
button.onclick = () => checkAnswer(index, randomQuestion.answer);
|
568 |
+
optionsContainer.appendChild(button);
|
569 |
+
});
|
570 |
+
|
571 |
+
questionArea.classList.remove('hidden');
|
572 |
+
gameState.gameActive = false;
|
573 |
+
}
|
574 |
+
|
575 |
+
function checkAnswer(selectedIndex, correctIndex) {
|
576 |
+
const options = document.querySelectorAll('.question-option');
|
577 |
+
options.forEach(option => option.disabled = true);
|
578 |
+
|
579 |
+
options[correctIndex].classList.add('bg-green-500', 'text-white', 'hover:bg-green-500');
|
580 |
+
if (selectedIndex !== correctIndex) {
|
581 |
+
options[selectedIndex].classList.add('bg-red-500', 'text-white', 'hover:bg-red-500');
|
582 |
+
}
|
583 |
+
|
584 |
+
if (selectedIndex === correctIndex) {
|
585 |
+
addToLog("Correct answer! Your knowledge strengthens your pet!", 'player');
|
586 |
+
setTimeout(() => {
|
587 |
+
questionArea.classList.add('hidden');
|
588 |
+
gameState.gameActive = true;
|
589 |
+
setTimeout(enemyTurn, 1000);
|
590 |
+
}, 1500);
|
591 |
+
} else {
|
592 |
+
addToLog("Wrong answer! The enemy gets an extra turn!", 'enemy');
|
593 |
+
setTimeout(() => {
|
594 |
+
questionArea.classList.add('hidden');
|
595 |
+
gameState.gameActive = true;
|
596 |
+
setTimeout(() => {
|
597 |
+
enemyTurn();
|
598 |
+
setTimeout(enemyTurn, 1000);
|
599 |
+
}, 1000);
|
600 |
+
}, 1500);
|
601 |
+
}
|
602 |
+
}
|
603 |
+
|
604 |
+
function renderShop() {
|
605 |
+
shopPetsContainer.innerHTML = '';
|
606 |
+
Object.entries(gameState.pets).forEach(([petType, pet]) => {
|
607 |
+
const isUnlocked = gameState.unlockedPets.includes(petType);
|
608 |
+
const isSelected = gameState.currentPet === petType;
|
609 |
+
|
610 |
+
const petCard = document.createElement('div');
|
611 |
+
petCard.className = 'bg-white p-4 rounded-lg border border-gray-100 flex flex-col items-center';
|
612 |
+
|
613 |
+
petCard.innerHTML = `
|
614 |
+
<div class="relative w-20 h-20 mb-3">
|
615 |
+
<img src="${pet.image}" alt="${pet.name}" class="w-full h-full object-contain ${isUnlocked ? '' : 'opacity-50 grayscale'}">
|
616 |
+
</div>
|
617 |
+
<h3 class="font-semibold text-sm text-center">${pet.name}</h3>
|
618 |
+
${pet.special ? `<p class="text-xs text-center text-gray-600 mt-1">${pet.special}</p>` : ''}
|
619 |
+
<div class="mt-3 text-xs font-medium ${isUnlocked ? 'text-indigo-600' : 'text-gray-500'}">
|
620 |
+
${isUnlocked ? (isSelected ? '✓ Selected' : 'Unlocked') : `${pet.cost} coins`}
|
621 |
+
</div>
|
622 |
+
<button class="mt-3 w-full py-1 rounded text-sm ${isUnlocked
|
623 |
+
? (isSelected ? 'bg-gray-200 text-gray-500' : 'bg-indigo-500 hover:bg-indigo-600 text-white')
|
624 |
+
: (gameState.coins >= pet.cost ? 'bg-indigo-500 hover:bg-indigo-600 text-white' : 'bg-gray-200 text-gray-500')}"
|
625 |
+
${isUnlocked ? '' : (gameState.coins >= pet.cost ? '' : 'disabled')}
|
626 |
+
data-pet="${petType}">
|
627 |
+
${isUnlocked ? (isSelected ? 'Selected' : 'Select') : 'Buy'}
|
628 |
+
</button>
|
629 |
+
`;
|
630 |
+
|
631 |
+
shopPetsContainer.appendChild(petCard);
|
632 |
+
});
|
633 |
+
}
|
634 |
+
|
635 |
+
function resetGame() {
|
636 |
+
gameState.coins = 0;
|
637 |
+
gameState.level = 1;
|
638 |
+
gameState.currentPet = 'cat';
|
639 |
+
gameState.unlockedPets = ['cat'];
|
640 |
+
gameState.playerHealth = 15;
|
641 |
+
gameState.maxHealth = 15;
|
642 |
+
gameState.enemyHealth = 15;
|
643 |
+
gameState.attackCount = 0;
|
644 |
+
gameState.gameActive = true;
|
645 |
+
gameState.currentEnemy = 0;
|
646 |
+
gameState.totalCoinsEarned = 0;
|
647 |
+
|
648 |
+
questionArea.classList.add('hidden');
|
649 |
+
hideModal(gameOverModal);
|
650 |
+
hideModal(levelUpModal);
|
651 |
+
hideModal(shopModal);
|
652 |
+
|
653 |
+
battleLog.innerHTML = '<p class="text-gray-500 italic p-2 rounded bg-gray-50">Welcome to Code Battler! Defeat monsters by answering coding questions correctly.</p>';
|
654 |
+
|
655 |
+
setEnemy();
|
656 |
+
updateUI();
|
657 |
+
addToLog(`A wild ${gameState.enemies[gameState.currentEnemy].name} appeared!`, 'enemy');
|
658 |
+
}
|
659 |
+
|
660 |
+
// Event Listeners
|
661 |
+
attackBtn.addEventListener('click', playerAttack);
|
662 |
+
healBtn.addEventListener('click', playerHeal);
|
663 |
+
specialBtn.addEventListener('click', playerSpecial);
|
664 |
+
|
665 |
+
shopBtn.addEventListener('click', () => {
|
666 |
+
renderShop();
|
667 |
+
showModal(shopModal);
|
668 |
+
gameState.gameActive = false;
|
669 |
+
});
|
670 |
+
|
671 |
+
learnBtn.addEventListener('click', () => {
|
672 |
+
// Learn mode would go here
|
673 |
+
alert("Learn mode would be implemented here");
|
674 |
+
});
|
675 |
+
|
676 |
+
closeShopBtn.addEventListener('click', () => {
|
677 |
+
hideModal(shopModal);
|
678 |
+
gameState.gameActive = true;
|
679 |
+
});
|
680 |
+
|
681 |
+
restartBtn.addEventListener('click', resetGame);
|
682 |
+
|
683 |
+
continueBtn.addEventListener('click', () => {
|
684 |
+
hideModal(levelUpModal);
|
685 |
+
gameState.gameActive = true;
|
686 |
+
setEnemy();
|
687 |
+
addToLog(`A wild ${gameState.enemies[gameState.currentEnemy].name} appeared!`, 'enemy');
|
688 |
+
updateUI();
|
689 |
+
});
|
690 |
+
|
691 |
+
// Shop pet selection
|
692 |
+
shopPetsContainer.addEventListener('click', (e) => {
|
693 |
+
const petBtn = e.target.closest('button');
|
694 |
+
if (!petBtn) return;
|
695 |
+
|
696 |
+
const petType = petBtn.dataset.pet;
|
697 |
+
const pet = gameState.pets[petType];
|
698 |
+
|
699 |
+
if (!gameState.unlockedPets.includes(petType)) {
|
700 |
+
if (gameState.coins >= pet.cost) {
|
701 |
+
gameState.coins -= pet.cost;
|
702 |
+
gameState.unlockedPets.push(petType);
|
703 |
+
addToLog(`You unlocked the ${pet.name}!`, 'info');
|
704 |
+
renderShop();
|
705 |
+
updateUI();
|
706 |
+
}
|
707 |
+
} else if (gameState.currentPet !== petType) {
|
708 |
+
gameState.currentPet = petType;
|
709 |
+
addToLog(`You selected the ${pet.name}!`, 'info');
|
710 |
+
renderShop();
|
711 |
+
updateUI();
|
712 |
+
}
|
713 |
+
});
|
714 |
+
|
715 |
+
// Initialize the game
|
716 |
+
setEnemy();
|
717 |
+
updateUI();
|
718 |
+
addToLog(`A wild ${gameState.enemies[gameState.currentEnemy].name} appeared!`, 'enemy');
|
719 |
+
</script>
|
720 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - <a href="https://enzostvs-deepsite.hf.space?remix=1234techrules/a-space" style="color: #fff;text-decoration: underline;" target="_blank" >🧬 Remix</a></p></body>
|
721 |
+
</html>
|