kolaslab commited on
Commit
ae69bc4
ยท
verified ยท
1 Parent(s): 683efc9

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +414 -18
index.html CHANGED
@@ -1,19 +1,415 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
  </html>
 
1
+ <!DOCTYPE html>
2
+ <html lang="ko">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>๋ผ์ธ๋ฐฐํ‹€: AI ์‹ฑ๊ธ€ํ”Œ๋ ˆ์ด ์˜ˆ์‹œ</title>
6
+ <style>
7
+ /* ๊ฐ„๋‹จํ•œ ์Šคํƒ€์ผ */
8
+ body {
9
+ margin: 20px;
10
+ font-family: sans-serif;
11
+ }
12
+ h1 {
13
+ margin-bottom: 10px;
14
+ }
15
+ #infoBar {
16
+ margin-bottom: 10px;
17
+ }
18
+ #gameBoard {
19
+ display: grid;
20
+ grid-template-columns: repeat(10, 40px);
21
+ grid-template-rows: repeat(6, 40px);
22
+ gap: 2px;
23
+ margin-bottom: 10px;
24
+ }
25
+ .cell {
26
+ width: 40px;
27
+ height: 40px;
28
+ border: 1px solid #666;
29
+ display: flex;
30
+ align-items: center;
31
+ justify-content: center;
32
+ cursor: pointer;
33
+ background-color: #ccc;
34
+ }
35
+ .red {
36
+ background-color: #ffaaaa;
37
+ }
38
+ .blue {
39
+ background-color: #aaaaff;
40
+ }
41
+ #endTurnBtn {
42
+ padding: 6px 12px;
43
+ font-size: 14px;
44
+ cursor: pointer;
45
+ margin-right: 10px;
46
+ }
47
+ </style>
48
+ </head>
49
+ <body>
50
+ <h1>๋ผ์ธ๋ฐฐํ‹€: AI ์‹ฑ๊ธ€ํ”Œ๋ ˆ์ด ์˜ˆ์‹œ</h1>
51
+ <div id="infoBar">
52
+ <span id="turnInfo"></span> |
53
+ <span id="selectedInfo"></span>
54
+ </div>
55
+ <div id="gameBoard"></div>
56
+ <button id="endTurnBtn">ํ„ด ์ข…๋ฃŒ</button>
57
+ <div id="message"></div>
58
+
59
+ <script>
60
+ /********************************************************
61
+ * 1. ์œ ๋‹›/๊ฒŒ์ž„ ํŒŒ๋ผ๋ฏธํ„ฐ ์ •์˜
62
+ ********************************************************/
63
+ const UNIT_TYPES = {
64
+ INFANTRY: {
65
+ name: "Infantry",
66
+ hp: 25,
67
+ attack: 3,
68
+ defense: 3,
69
+ move: 2,
70
+ range: 1,
71
+ advantage: "ARCHER", // ๋ณด๋ณ‘ > ๊ถ์ˆ˜
72
+ },
73
+ ARCHER: {
74
+ name: "Archer",
75
+ hp: 20,
76
+ attack: 2,
77
+ defense: 2,
78
+ move: 2,
79
+ range: 3,
80
+ advantage: "CAVALRY", // ๊ถ์ˆ˜ > ๊ธฐ๋ณ‘
81
+ },
82
+ CAVALRY: {
83
+ name: "Cavalry",
84
+ hp: 22,
85
+ attack: 4,
86
+ defense: 2,
87
+ move: 3,
88
+ range: 1,
89
+ advantage: "INFANTRY", // ๊ธฐ๋ณ‘ > ๋ณด๋ณ‘
90
+ }
91
+ };
92
+
93
+ // ๊ฐ„๋‹จํ•œ ์ƒ์„ฑ ๋ณด์ •(์˜ˆ: 1.5๋ฐฐ)
94
+ const ADVANTAGE_MULTIPLIER = 1.5;
95
+
96
+ // ๋งต ํฌ๊ธฐ
97
+ const WIDTH = 10;
98
+ const HEIGHT = 6;
99
+
100
+ // ํŒ€ ์ •์˜
101
+ const RED = "RED";
102
+ const BLUE = "BLUE";
103
+
104
+ // ๊ฒŒ์ž„ ์ƒํƒœ
105
+ let units = []; // ์ „์ฒด ์œ ๋‹› ๊ฐ์ฒด๋ฅผ ๋ณด๊ด€
106
+ let currentTeam = RED; // ํ˜„์žฌ ํ„ด์˜ ํŒ€
107
+ let selectedUnit = null; // ์œ ์ €๊ฐ€ ์„ ํƒํ•œ ์œ ๋‹›(RED ํ„ด ์ค‘)
108
+
109
+ /********************************************************
110
+ * 2. ์œ ๋‹› ํด๋ž˜์Šค
111
+ ********************************************************/
112
+ class Unit {
113
+ constructor(typeKey, team, x, y) {
114
+ const data = UNIT_TYPES[typeKey];
115
+ this.type = typeKey; // "INFANTRY", "ARCHER", "CAVALRY"
116
+ this.team = team; // "RED" ๋˜๋Š” "BLUE"
117
+ this.hp = data.hp;
118
+ this.attack = data.attack;
119
+ this.defense = data.defense;
120
+ this.move = data.move;
121
+ this.range = data.range;
122
+ this.advantage = data.advantage;
123
+ this.x = x;
124
+ this.y = y;
125
+ this.hasActed = false; // ์ด ํ„ด ์ค‘ ์ด๋™/๊ณต๊ฒฉ ์—ฌ๋ถ€๋ฅผ ๋‹จ์ˆœ ์ฒดํฌ(ํ™•์žฅ ๊ฐ€๋Šฅ)
126
+ }
127
+ get isAlive() {
128
+ return this.hp > 0;
129
+ }
130
+ get displayName() {
131
+ // ์˜ˆ: 'I25' (Infantry, HP 25)
132
+ return this.type[0] + this.hp;
133
+ }
134
+ }
135
+
136
+ /********************************************************
137
+ * 3. ์ดˆ๊ธฐํ™”: ์œ ๋‹› ๋ฐฐ์น˜
138
+ ********************************************************/
139
+ function initUnits() {
140
+ units = [];
141
+ // RED - ๋ณด๋ณ‘(6), ๊ถ์ˆ˜(3), ๊ธฐ๋ณ‘(3) / ์˜ˆ์‹œ๋กœ ์ขŒ์ธก์— ๋ฐฐ์น˜
142
+ for (let i = 0; i < 6; i++) {
143
+ units.push(new Unit("INFANTRY", RED, 0, i % HEIGHT));
144
+ }
145
+ for (let i = 0; i < 3; i++) {
146
+ units.push(new Unit("ARCHER", RED, 1, i));
147
+ }
148
+ for (let i = 0; i < 3; i++) {
149
+ units.push(new Unit("CAVALRY", RED, 2, i + 3));
150
+ }
151
+ // BLUE - ๋ณด๋ณ‘(6), ๊ถ์ˆ˜(3), ๊ธฐ๋ณ‘(3) / ์˜ˆ์‹œ๋กœ ์šฐ์ธก์— ๋ฐฐ์น˜
152
+ for (let i = 0; i < 6; i++) {
153
+ units.push(new Unit("INFANTRY", BLUE, WIDTH - 1, i % HEIGHT));
154
+ }
155
+ for (let i = 0; i < 3; i++) {
156
+ units.push(new Unit("ARCHER", BLUE, WIDTH - 2, i));
157
+ }
158
+ for (let i = 0; i < 3; i++) {
159
+ units.push(new Unit("CAVALRY", BLUE, WIDTH - 3, i + 3));
160
+ }
161
+ }
162
+
163
+ /********************************************************
164
+ * 4. ํ™”๋ฉด ๋ Œ๋”๋ง
165
+ ********************************************************/
166
+ function renderBoard() {
167
+ const board = document.getElementById("gameBoard");
168
+ board.innerHTML = "";
169
+
170
+ // ๋งต์„ HEIGHT x WIDTH ์ˆœํšŒํ•˜๋ฉฐ ์…€ ์ƒ์„ฑ
171
+ for (let y = 0; y < HEIGHT; y++) {
172
+ for (let x = 0; x < WIDTH; x++) {
173
+ const cellDiv = document.createElement("div");
174
+ cellDiv.classList.add("cell");
175
+ cellDiv.dataset.x = x;
176
+ cellDiv.dataset.y = y;
177
+
178
+ // ์ด ์ขŒํ‘œ์— ์œ ๋‹›์ด ์žˆ๋Š”์ง€ ํ™•์ธ
179
+ const unitHere = units.find(u => u.isAlive && u.x === x && u.y === y);
180
+ if (unitHere) {
181
+ if (unitHere.team === RED) cellDiv.classList.add("red");
182
+ else cellDiv.classList.add("blue");
183
+ cellDiv.textContent = unitHere.displayName;
184
+ }
185
+
186
+ // ํด๋ฆญ ์ด๋ฒคํŠธ
187
+ cellDiv.addEventListener("click", () => onCellClick(x, y));
188
+ board.appendChild(cellDiv);
189
+ }
190
+ }
191
+
192
+ // ์ƒ๋‹จ ์ •๋ณด
193
+ document.getElementById("turnInfo").textContent = `ํ˜„์žฌ ํ„ด: ${currentTeam}`;
194
+ if (selectedUnit) {
195
+ document.getElementById("selectedInfo").textContent =
196
+ `์„ ํƒ ์œ ๋‹›: ${selectedUnit.type} (HP: ${selectedUnit.hp})`;
197
+ } else {
198
+ document.getElementById("selectedInfo").textContent = `์„ ํƒ ์œ ๋‹›: ์—†์Œ`;
199
+ }
200
+ }
201
+
202
+ /********************************************************
203
+ * 5. ์œ ์ € ์ž…๋ ฅ ์ฒ˜๋ฆฌ
204
+ ********************************************************/
205
+ function onCellClick(x, y) {
206
+ if (currentTeam !== RED) {
207
+ // ํ”Œ๋ ˆ์ด์–ด ํ„ด์ด ์•„๋‹ ๋•Œ๋Š” ํด๋ฆญ ๋ฌด์‹œ
208
+ return;
209
+ }
210
+
211
+ // ํด๋ฆญ ์ง€์ ์— ์œ ๋‹›์ด ์žˆ๋Š”์ง€ ํ™•์ธ
212
+ const clickedUnit = units.find(u => u.isAlive && u.x === x && u.y === y);
213
+
214
+ if (!selectedUnit) {
215
+ // ์•„์ง ์œ ๋‹›์„ ์„ ํƒํ•˜์ง€ ์•Š์€ ์ƒํƒœ
216
+ if (clickedUnit && clickedUnit.team === RED) {
217
+ // ์•„๊ตฐ ์œ ๋‹›์ด๋ฉด ์„ ํƒ
218
+ if (!clickedUnit.hasActed) {
219
+ selectedUnit = clickedUnit;
220
+ }
221
+ }
222
+ } else {
223
+ // ์ด๋ฏธ ์œ ๋‹›์„ ์„ ํƒํ•œ ์ƒํƒœ
224
+ if (clickedUnit) {
225
+ // ๊ณต๊ฒฉ ์‹œ๋„ ์—ฌ๋ถ€ ํ™•์ธ
226
+ if (clickedUnit.team !== RED) {
227
+ // ์  ์œ ๋‹›์ด๋ฉด ๊ณต๊ฒฉ ์‹œ๋„
228
+ const dist = getDistance(selectedUnit, clickedUnit);
229
+ if (dist <= selectedUnit.range) {
230
+ // ๊ณต๊ฒฉ
231
+ attack(selectedUnit, clickedUnit);
232
+ selectedUnit.hasActed = true;
233
+ selectedUnit = null;
234
+ }
235
+ } else {
236
+ // ๊ฐ™์€ ํŒ€ ์œ ๋‹› ํด๋ฆญ => ์„ ํƒ ์œ ๋‹› ๋ณ€๊ฒฝ(๋‹จ, ์ด๋ฏธ ํ–‰๋™ ๋๋‚œ ์œ ๋‹›์€ ์„ ํƒ ๋ถˆ๊ฐ€)
237
+ if (!clickedUnit.hasActed) {
238
+ selectedUnit = clickedUnit;
239
+ }
240
+ }
241
+ } else {
242
+ // ๋นˆ ์นธ ํด๋ฆญ -> ์ด๋™ ์‹œ๋„
243
+ const dist = Math.abs(selectedUnit.x - x) + Math.abs(selectedUnit.y - y);
244
+ // (๊ฐ„๋‹จํžˆ ๋งจํ•ดํŠผ ๊ฑฐ๋ฆฌ๋กœ๋งŒ ๊ณ„์‚ฐ. ๋Œ€๊ฐ ์ด๋™/์žฅ์• ๋ฌผ์€ ๊ณ ๋ ค ์•ˆ ํ•จ)
245
+ if (dist <= selectedUnit.move) {
246
+ selectedUnit.x = x;
247
+ selectedUnit.y = y;
248
+ // ์ด๋™๋งŒ ํ•˜๊ณ  ์‹ถ์œผ๋ฉด ์—ฌ๊ธฐ์„œ hasActed๋ฅผ true๋กœ ํ•˜๊ฑฐ๋‚˜,
249
+ // ์ด๋™ ํ›„ ๊ณต๊ฒฉ์„ ํ—ˆ์šฉํ• ์ง€ ์—ฌ๋ถ€๋Š” ๊ทœ์น™์— ๋”ฐ๋ผ ๊ฒฐ์ •
250
+ // ์—ฌ๊ธฐ์„  ์ด๋™ํ•ด๋„ ๊ณต๊ฒฉ ๊ฐ€๋Šฅํ•˜๋„๋ก hasActed = false ์œ ์ง€
251
+ }
252
+ }
253
+ }
254
+ renderBoard();
255
+ }
256
+
257
+ // ๊ณต๊ฒฉ ํ•จ์ˆ˜
258
+ function attack(attacker, defender) {
259
+ if (!attacker || !defender) return;
260
+ const baseDamage = Math.max(0, attacker.attack - defender.defense);
261
+ let finalDamage = baseDamage;
262
+ // ์ƒ์„ฑ ์ฒดํฌ
263
+ if (attacker.advantage === defender.type) {
264
+ finalDamage = Math.floor(finalDamage * ADVANTAGE_MULTIPLIER);
265
+ }
266
+ defender.hp -= finalDamage;
267
+ // ๋ฉ”์„ธ์ง€ ์ถœ๋ ฅ
268
+ const msg =
269
+ `[${attacker.team} ${attacker.type}]๊ฐ€ [${defender.team} ${defender.type}]๋ฅผ ๊ณต๊ฒฉ! (๋ฐ๋ฏธ์ง€ ${finalDamage})`;
270
+ showMessage(msg);
271
+ // ์‚ฌ๋ง ์ฒดํฌ
272
+ if (defender.hp <= 0) {
273
+ defender.hp = 0;
274
+ showMessage(`โ†’ [${defender.team} ${defender.type}] ๊ฒฉํŒŒ!`);
275
+ }
276
+ }
277
+
278
+ // ๋ฉ”์„ธ์ง€ ํ‘œ์‹œ(๋‹จ์ˆœํžˆ ๋ˆ„์  ์ถœ๋ ฅ)
279
+ function showMessage(msg) {
280
+ const messageDiv = document.getElementById("message");
281
+ messageDiv.innerHTML += msg + "<br>";
282
+ messageDiv.scrollTop = messageDiv.scrollHeight;
283
+ }
284
+
285
+ /********************************************************
286
+ * 6. ํ„ด ์ข…๋ฃŒ & AI ๋™์ž‘
287
+ ********************************************************/
288
+ function endTurn() {
289
+ // ํ”Œ๋ ˆ์ด์–ด๊ฐ€ ํ„ด ์ข…๋ฃŒ ํด๋ฆญ
290
+ if (currentTeam === RED) {
291
+ // ๋ชจ๋“  ์œ ๋‹›์˜ hasActed ์ดˆ๊ธฐํ™”
292
+ units.forEach(u => {
293
+ if (u.team === RED) {
294
+ u.hasActed = false;
295
+ }
296
+ });
297
+ // ํ„ด ๊ต์ฒด
298
+ currentTeam = BLUE;
299
+ selectedUnit = null;
300
+ renderBoard();
301
+ // AI ์ˆ˜ํ–‰
302
+ setTimeout(() => performAiTurn(), 500);
303
+ }
304
+ }
305
+
306
+ // AI ๊ฐ„๋‹จ ๋กœ์ง
307
+ function performAiTurn() {
308
+ // 1. ํ–‰๋™ํ•  ์ˆ˜ ์žˆ๋Š” BLUE ์œ ๋‹› ๋ชฉ๋ก
309
+ const blueUnits = units.filter(u => u.team === BLUE && u.isAlive);
310
+
311
+ // ๊ฐ„๋‹จํ•œ ์ˆœ์ฐจ ์ฒ˜๋ฆฌ: ๊ฐ ์œ ๋‹›๋ณ„๋กœ ์ œ์ผ ๊ฐ€๊นŒ์šด ์ (RED)์„ ํƒ์ƒ‰โ†’์ด๋™โ†’๊ณต๊ฒฉ
312
+ for (const aiUnit of blueUnits) {
313
+ // ๊ฐ€์žฅ ๊ฐ€๊นŒ์šด RED ์œ ๋‹› ์ฐพ๊ธฐ
314
+ const enemies = units.filter(u => u.team === RED && u.isAlive);
315
+ if (enemies.length === 0) break; // ์ ์ด ์—†์œผ๋ฉด ์ข…๋ฃŒ
316
+
317
+ let closestEnemy = null;
318
+ let minDist = 9999;
319
+ for (const e of enemies) {
320
+ const d = getDistance(aiUnit, e);
321
+ if (d < minDist) {
322
+ minDist = d;
323
+ closestEnemy = e;
324
+ }
325
+ }
326
+
327
+ if (!closestEnemy) continue;
328
+
329
+ // ๊ณต๊ฒฉ ๋ฒ”์œ„ ์•ˆ์— ์žˆ์œผ๋ฉด ๊ณต๊ฒฉ
330
+ if (minDist <= aiUnit.range) {
331
+ attack(aiUnit, closestEnemy);
332
+ } else {
333
+ // ๋ฒ”์œ„ ๋ฐ–์ด๋ฉด ์ด๋™(๊ฐ€์žฅ ๊ฐ„๋‹จํžˆ, ๊ฐ€๊นŒ์›Œ์ง€๋„๋ก x,y๋ฅผ 1์นธ ์ด๋™)
334
+ const moveStep = getSimpleMoveToward(aiUnit, closestEnemy);
335
+ if (moveStep) {
336
+ aiUnit.x = clamp(aiUnit.x + moveStep.dx, 0, WIDTH - 1);
337
+ aiUnit.y = clamp(aiUnit.y + moveStep.dy, 0, HEIGHT - 1);
338
+ // ์ด๋™ ํ›„, ์‚ฌ๊ฑฐ๋ฆฌ ์•ˆ์ด๋ฉด ๋‹ค์‹œ ๊ณต๊ฒฉ
339
+ const distAfterMove = getDistance(aiUnit, closestEnemy);
340
+ if (distAfterMove <= aiUnit.range) {
341
+ attack(aiUnit, closestEnemy);
342
+ }
343
+ }
344
+ }
345
+ }
346
+ // AI ํ„ด ์ข…๋ฃŒ
347
+ currentTeam = RED;
348
+ // AI ์œ ๋‹› hasActed ์ดˆ๊ธฐํ™”
349
+ units.forEach(u => {
350
+ if (u.team === BLUE) {
351
+ u.hasActed = false;
352
+ }
353
+ });
354
+ renderBoard();
355
+ checkWinCondition();
356
+ }
357
+
358
+ /********************************************************
359
+ * 7. ๋ณด์กฐ ํ•จ์ˆ˜๋“ค
360
+ ********************************************************/
361
+ // ๋‘ ์œ ๋‹› ๊ฐ„ ๊ฑฐ๋ฆฌ(๊ฐ„๋‹จํžˆ ๋งจํ•ดํŠผ ๊ฑฐ๋ฆฌ)
362
+ function getDistance(u1, u2) {
363
+ return Math.abs(u1.x - u2.x) + Math.abs(u1.y - u2.y);
364
+ }
365
+
366
+ // AI ์ด๋™์šฉ: ๋ชฉํ‘œ ์  ์œ ๋‹›์— ์กฐ๊ธˆ ๋” ๋‹ค๊ฐ€๊ฐ€๋Š” ๋ฐฉํ–ฅ ๊ณ„์‚ฐ
367
+ function getSimpleMoveToward(aiUnit, target) {
368
+ // ์ด๋™๋ ฅ๋งŒํผ ์„ธ๋ฐ€ํžˆ ๊ณ„์‚ฐํ•˜๊ธฐ๋ณด๋‹ค๋Š”, 1์นธ๋งŒ ์ „์ง„(๋˜๋Š” 2์นธ) ํ•˜๋Š” ์‹
369
+ const dx = target.x - aiUnit.x;
370
+ const dy = target.y - aiUnit.y;
371
+ let stepX = 0;
372
+ let stepY = 0;
373
+
374
+ if (Math.abs(dx) > Math.abs(dy)) {
375
+ stepX = dx > 0 ? 1 : -1;
376
+ } else {
377
+ stepY = dy > 0 ? 1 : -1;
378
+ }
379
+
380
+ // aiUnit.move ๋งŒํผ ์ด๋™ํ•  ์ˆ˜๋„ ์žˆ์ง€๋งŒ, ์—ฌ๊ธฐ์„  ๋‹จ์ˆœํ™”ํ•ด์„œ 1์นธ๋งŒ ์ด๋™
381
+ return { dx: stepX, dy: stepY };
382
+ }
383
+
384
+ // ๋ฒ”์œ„ ์ œํ•œ ํ•จ์ˆ˜
385
+ function clamp(value, min, max) {
386
+ return Math.max(min, Math.min(max, value));
387
+ }
388
+
389
+ // ์Šน๋ฆฌ ์กฐ๊ฑด ์ฒดํฌ
390
+ function checkWinCondition() {
391
+ const redAlive = units.some(u => u.team === RED && u.isAlive);
392
+ const blueAlive = units.some(u => u.team === BLUE && u.isAlive);
393
+
394
+ if (!redAlive) {
395
+ showMessage("BLUE ์Šน๋ฆฌ!");
396
+ } else if (!blueAlive) {
397
+ showMessage("RED ์Šน๋ฆฌ!");
398
+ }
399
+ }
400
+
401
+ /********************************************************
402
+ * 8. ์ดˆ๊ธฐ ์‹คํ–‰
403
+ ********************************************************/
404
+ // ์ดˆ๊ธฐ ์„ธํŒ…
405
+ initUnits();
406
+ renderBoard();
407
+
408
+ // ํ„ด ์ข…๋ฃŒ ๋ฒ„ํŠผ
409
+ document.getElementById("endTurnBtn").addEventListener("click", () => {
410
+ endTurn();
411
+ checkWinCondition();
412
+ });
413
+ </script>
414
+ </body>
415
  </html>