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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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>Tiny Healer</title>
|
7 |
+
<style>
|
8 |
+
body {
|
9 |
+
font-family: Arial, sans-serif;
|
10 |
+
display: flex;
|
11 |
+
justify-content: center;
|
12 |
+
align-items: center;
|
13 |
+
height: 100vh;
|
14 |
+
margin: 0;
|
15 |
+
background-color: #1a1a1a;
|
16 |
+
color: white;
|
17 |
+
}
|
18 |
+
#game-container {
|
19 |
+
width: 800px;
|
20 |
+
height: 600px;
|
21 |
+
border: 2px solid #333;
|
22 |
+
padding: 20px;
|
23 |
+
background-color: #222;
|
24 |
+
}
|
25 |
+
#combat-window {
|
26 |
+
display: flex;
|
27 |
+
justify-content: space-between;
|
28 |
+
margin-bottom: 20px;
|
29 |
+
}
|
30 |
+
#allies {
|
31 |
+
width: 45%;
|
32 |
+
}
|
33 |
+
#boss {
|
34 |
+
width: 45%;
|
35 |
+
}
|
36 |
+
.health-bar {
|
37 |
+
height: 30px;
|
38 |
+
background-color: #4CAF50;
|
39 |
+
margin-bottom: 10px;
|
40 |
+
position: relative;
|
41 |
+
cursor: pointer;
|
42 |
+
}
|
43 |
+
.health-bar.selected {
|
44 |
+
background-color: #2196F3;
|
45 |
+
}
|
46 |
+
.health-bar-text {
|
47 |
+
position: absolute;
|
48 |
+
width: 100%;
|
49 |
+
text-align: center;
|
50 |
+
line-height: 30px;
|
51 |
+
}
|
52 |
+
#boss-health-bar {
|
53 |
+
height: 50px;
|
54 |
+
background-color: #f44336;
|
55 |
+
}
|
56 |
+
#spell-buttons {
|
57 |
+
display: flex;
|
58 |
+
justify-content: space-between;
|
59 |
+
margin-bottom: 10px;
|
60 |
+
}
|
61 |
+
.spell-button {
|
62 |
+
width: 18%;
|
63 |
+
height: 50px;
|
64 |
+
background-color: #008CBA;
|
65 |
+
border: none;
|
66 |
+
color: white;
|
67 |
+
text-align: center;
|
68 |
+
text-decoration: none;
|
69 |
+
display: inline-block;
|
70 |
+
font-size: 14px;
|
71 |
+
margin: 4px 2px;
|
72 |
+
cursor: pointer;
|
73 |
+
position: relative;
|
74 |
+
overflow: hidden;
|
75 |
+
}
|
76 |
+
.spell-button:disabled {
|
77 |
+
background-color: #555;
|
78 |
+
cursor: not-allowed;
|
79 |
+
}
|
80 |
+
.cooldown-progress {
|
81 |
+
position: absolute;
|
82 |
+
top: 0;
|
83 |
+
left: 0;
|
84 |
+
height: 100%;
|
85 |
+
width: 0;
|
86 |
+
background-color: rgba(0, 0, 0, 0.5);
|
87 |
+
transition: width linear;
|
88 |
+
}
|
89 |
+
#spellbook {
|
90 |
+
width: 100%;
|
91 |
+
padding: 10px;
|
92 |
+
background-color: #333;
|
93 |
+
border: none;
|
94 |
+
color: white;
|
95 |
+
font-size: 16px;
|
96 |
+
margin-top: 10px;
|
97 |
+
}
|
98 |
+
#spell-info {
|
99 |
+
margin-top: 10px;
|
100 |
+
padding: 10px;
|
101 |
+
background-color: #444;
|
102 |
+
border-radius: 5px;
|
103 |
+
display: none;
|
104 |
+
}
|
105 |
+
</style>
|
106 |
+
</head>
|
107 |
+
<body>
|
108 |
+
<div id="game-container">
|
109 |
+
<div id="combat-window">
|
110 |
+
<div id="allies"></div>
|
111 |
+
<div id="boss">
|
112 |
+
<div id="boss-health-bar" class="health-bar">
|
113 |
+
<div class="health-bar-text">Boss HP: 5000/5000</div>
|
114 |
+
</div>
|
115 |
+
</div>
|
116 |
+
</div>
|
117 |
+
<div id="spell-buttons"></div>
|
118 |
+
<select id="spellbook">
|
119 |
+
<option value="">Spellbook - Select a spell for info</option>
|
120 |
+
<option value="0">Quick Heal</option>
|
121 |
+
<option value="1">Strong Heal</option>
|
122 |
+
<option value="2">Healing Stream</option>
|
123 |
+
<option value="3">Chain Heal</option>
|
124 |
+
<option value="4">Team Heal</option>
|
125 |
+
</select>
|
126 |
+
<div id="spell-info"></div>
|
127 |
+
</div>
|
128 |
+
|
129 |
+
<script>
|
130 |
+
const allies = [];
|
131 |
+
let boss = { hp: 5000, maxHp: 5000 };
|
132 |
+
let selectedAlly = null;
|
133 |
+
let globalCooldown = false;
|
134 |
+
|
135 |
+
const spells = [
|
136 |
+
{ name: "Quick Heal", cooldown: 1.5, heal: 10, description: "Heals the target for 10 HP. Global cooldown: 1.5 seconds." },
|
137 |
+
{ name: "Strong Heal", cooldown: 15, heal: 30, description: "Heals the target for 30 HP. Cooldown: 15 seconds." },
|
138 |
+
{ name: "Healing Stream", cooldown: 45, heal: 3, duration: 10, interval: 0.5, description: "Heals the target for 3 HP every 0.5 seconds for 10 seconds. Cooldown: 45 seconds." },
|
139 |
+
{ name: "Chain Heal", cooldown: 15, heal: 10, targets: 3, description: "Heals 3 random allies for 10 HP each. Cooldown: 15 seconds." },
|
140 |
+
{ name: "Team Heal", cooldown: 120, heal: 50, description: "Heals all allies for 50 HP. Cooldown: 2 minutes." }
|
141 |
+
];
|
142 |
+
|
143 |
+
function createAlly(id) {
|
144 |
+
return { id, hp: 100, maxHp: 100 };
|
145 |
+
}
|
146 |
+
|
147 |
+
function updateHealthBar(entity, barElement) {
|
148 |
+
const percentage = (entity.hp / entity.maxHp) * 100;
|
149 |
+
barElement.style.width = `${percentage}%`;
|
150 |
+
barElement.querySelector('.health-bar-text').textContent = `HP: ${entity.hp}/${entity.maxHp}`;
|
151 |
+
}
|
152 |
+
|
153 |
+
function createAllies() {
|
154 |
+
const alliesContainer = document.getElementById('allies');
|
155 |
+
for (let i = 0; i < 5; i++) {
|
156 |
+
const ally = createAlly(i);
|
157 |
+
allies.push(ally);
|
158 |
+
const healthBar = document.createElement('div');
|
159 |
+
healthBar.className = 'health-bar';
|
160 |
+
healthBar.innerHTML = `<div class="health-bar-text">Ally ${i + 1} HP: 100/100</div>`;
|
161 |
+
healthBar.onclick = () => selectAlly(i);
|
162 |
+
alliesContainer.appendChild(healthBar);
|
163 |
+
updateHealthBar(ally, healthBar);
|
164 |
+
}
|
165 |
+
}
|
166 |
+
|
167 |
+
function selectAlly(index) {
|
168 |
+
const healthBars = document.querySelectorAll('#allies .health-bar');
|
169 |
+
healthBars.forEach(bar => bar.classList.remove('selected'));
|
170 |
+
healthBars[index].classList.add('selected');
|
171 |
+
selectedAlly = allies[index];
|
172 |
+
updateSpellButtons();
|
173 |
+
}
|
174 |
+
|
175 |
+
function createSpellButtons() {
|
176 |
+
const spellButtonsContainer = document.getElementById('spell-buttons');
|
177 |
+
spells.forEach((spell, index) => {
|
178 |
+
const button = document.createElement('button');
|
179 |
+
button.className = 'spell-button';
|
180 |
+
button.innerHTML = `${spell.name}<div class="cooldown-progress"></div>`;
|
181 |
+
button.onclick = () => castSpell(index);
|
182 |
+
button.disabled = true;
|
183 |
+
spellButtonsContainer.appendChild(button);
|
184 |
+
});
|
185 |
+
}
|
186 |
+
|
187 |
+
function updateSpellButtons() {
|
188 |
+
const spellButtons = document.querySelectorAll('.spell-button');
|
189 |
+
spellButtons.forEach((button, index) => {
|
190 |
+
button.disabled = !selectedAlly || globalCooldown || button.classList.contains('on-cooldown');
|
191 |
+
});
|
192 |
+
}
|
193 |
+
|
194 |
+
function castSpell(spellIndex) {
|
195 |
+
if (selectedAlly && !globalCooldown && !document.querySelectorAll('.spell-button')[spellIndex].classList.contains('on-cooldown')) {
|
196 |
+
const spell = spells[spellIndex];
|
197 |
+
switch (spellIndex) {
|
198 |
+
case 0:
|
199 |
+
case 1:
|
200 |
+
healAlly(selectedAlly, spell.heal);
|
201 |
+
break;
|
202 |
+
case 2:
|
203 |
+
startHealingStream(selectedAlly, spell);
|
204 |
+
break;
|
205 |
+
case 3:
|
206 |
+
chainHeal(spell);
|
207 |
+
break;
|
208 |
+
case 4:
|
209 |
+
teamHeal(spell);
|
210 |
+
break;
|
211 |
+
}
|
212 |
+
startSpellCooldown(spellIndex);
|
213 |
+
startGlobalCooldown();
|
214 |
+
}
|
215 |
+
}
|
216 |
+
|
217 |
+
function healAlly(ally, amount) {
|
218 |
+
ally.hp = Math.min(ally.hp + amount, ally.maxHp);
|
219 |
+
updateHealthBar(ally, document.querySelectorAll('.health-bar')[ally.id]);
|
220 |
+
}
|
221 |
+
|
222 |
+
function startHealingStream(ally, spell) {
|
223 |
+
let ticks = spell.duration / spell.interval;
|
224 |
+
function tick() {
|
225 |
+
if (ticks > 0) {
|
226 |
+
healAlly(ally, spell.heal);
|
227 |
+
ticks--;
|
228 |
+
setTimeout(tick, spell.interval * 1000);
|
229 |
+
}
|
230 |
+
}
|
231 |
+
tick();
|
232 |
+
}
|
233 |
+
|
234 |
+
function chainHeal(spell) {
|
235 |
+
const targets = allies.sort(() => 0.5 - Math.random()).slice(0, spell.targets);
|
236 |
+
targets.forEach(ally => healAlly(ally, spell.heal));
|
237 |
+
}
|
238 |
+
|
239 |
+
function teamHeal(spell) {
|
240 |
+
allies.forEach(ally => healAlly(ally, spell.heal));
|
241 |
+
}
|
242 |
+
|
243 |
+
function startSpellCooldown(spellIndex) {
|
244 |
+
const button = document.querySelectorAll('.spell-button')[spellIndex];
|
245 |
+
const progressBar = button.querySelector('.cooldown-progress');
|
246 |
+
button.classList.add('on-cooldown');
|
247 |
+
progressBar.style.transition = `width ${spells[spellIndex].cooldown}s linear`;
|
248 |
+
progressBar.style.width = '100%';
|
249 |
+
setTimeout(() => {
|
250 |
+
button.classList.remove('on-cooldown');
|
251 |
+
progressBar.style.width = '0';
|
252 |
+
updateSpellButtons();
|
253 |
+
}, spells[spellIndex].cooldown * 1000);
|
254 |
+
}
|
255 |
+
|
256 |
+
function startGlobalCooldown() {
|
257 |
+
globalCooldown = true;
|
258 |
+
updateSpellButtons();
|
259 |
+
setTimeout(() => {
|
260 |
+
globalCooldown = false;
|
261 |
+
updateSpellButtons();
|
262 |
+
}, 1500);
|
263 |
+
}
|
264 |
+
|
265 |
+
function bossDamage() {
|
266 |
+
const damageAmount = 15;
|
267 |
+
const targetAlly = allies[Math.floor(Math.random() * allies.length)];
|
268 |
+
targetAlly.hp = Math.max(targetAlly.hp - damageAmount, 0);
|
269 |
+
updateHealthBar(targetAlly, document.querySelectorAll('.health-bar')[targetAlly.id]);
|
270 |
+
}
|
271 |
+
|
272 |
+
function gameLoop() {
|
273 |
+
bossDamage();
|
274 |
+
setTimeout(gameLoop, 1000);
|
275 |
+
}
|
276 |
+
|
277 |
+
document.addEventListener('keydown', (event) => {
|
278 |
+
const key = event.key;
|
279 |
+
if (key >= '1' && key <= '5') {
|
280 |
+
castSpell(parseInt(key) - 1);
|
281 |
+
}
|
282 |
+
});
|
283 |
+
|
284 |
+
document.getElementById('spellbook').addEventListener('change', (event) => {
|
285 |
+
const spellIndex = event.target.value;
|
286 |
+
const spellInfo = document.getElementById('spell-info');
|
287 |
+
if (spellIndex !== "") {
|
288 |
+
spellInfo.textContent = spells[spellIndex].description;
|
289 |
+
spellInfo.style.display = 'block';
|
290 |
+
} else {
|
291 |
+
spellInfo.style.display = 'none';
|
292 |
+
}
|
293 |
+
});
|
294 |
+
|
295 |
+
createAllies();
|
296 |
+
createSpellButtons();
|
297 |
+
updateHealthBar(boss, document.getElementById('boss-health-bar'));
|
298 |
+
gameLoop();
|
299 |
+
</script>
|
300 |
+
</body>
|
301 |
+
</html>
|