cutechicken commited on
Commit
444aef9
ยท
verified ยท
1 Parent(s): 9fe1916

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +19 -8
index.html CHANGED
@@ -257,23 +257,34 @@
257
  document.getElementById('shop').style.display = 'block';
258
  }
259
 
260
- function buyTank(tankImg, cost, tankId) {
 
 
 
 
 
 
261
  if (gold >= cost) {
262
  gold -= cost;
263
  playerImg.src = tankImg;
264
  document.getElementById(tankId).style.display = 'none';
265
  document.getElementById('shop').style.display = 'none';
266
 
267
- // ์ „์ฐจ๋ณ„ ํŠน์„ฑ ์ ์šฉ
268
- if (tankId === 'tank1') { // PZ.IV
 
 
 
 
269
  player.maxHealth += 500;
270
- player.health = player.maxHealth; // ํ˜„์žฌ ์ฒด๋ ฅ๋„ ์ฆ๊ฐ€๋œ ์ตœ๋Œ€ ์ฒด๋ ฅ์œผ๋กœ ์„ค์ •
271
- }
272
- else if (tankId === 'tank2') { // TIGER
273
  player.maxHealth += 1000;
274
- player.health = player.maxHealth;
275
- player.speed *= 0.7; // ์†๋„ 30% ๊ฐ์†Œ
276
  }
 
 
 
277
  }
278
  }
279
 
 
257
  document.getElementById('shop').style.display = 'block';
258
  }
259
 
260
+ // ํ”Œ๋ ˆ์ด์–ด์˜ ๊ธฐ๋ณธ ์ƒํƒœ๋ฅผ ์ €์žฅ
261
+ const defaultPlayerStats = {
262
+ maxHealth: 1000,
263
+ speed: 5
264
+ };
265
+
266
+ function buyTank(tankImg, cost, tankId) {
267
  if (gold >= cost) {
268
  gold -= cost;
269
  playerImg.src = tankImg;
270
  document.getElementById(tankId).style.display = 'none';
271
  document.getElementById('shop').style.display = 'none';
272
 
273
+ // ๋จผ์ € ํ”Œ๋ ˆ์ด์–ด ์Šคํƒฏ์„ ๊ธฐ๋ณธ๊ฐ’์œผ๋กœ ์ดˆ๊ธฐํ™”
274
+ player.maxHealth = defaultPlayerStats.maxHealth;
275
+ player.speed = defaultPlayerStats.speed;
276
+
277
+ // ๊ตฌ๋งคํ•œ ๋ชจ๋“  ์ „์ฐจ์˜ ํšจ๊ณผ๋ฅผ ํ•œ ๋ฒˆ์— ์ ์šฉ
278
+ if (document.getElementById('tank1').style.display === 'none') { // PZ.IV ๊ตฌ๋งค ์—ฌ๋ถ€
279
  player.maxHealth += 500;
280
+ }
281
+ if (document.getElementById('tank2').style.display === 'none') { // TIGER ๊ตฌ๋งค ์—ฌ๋ถ€
 
282
  player.maxHealth += 1000;
283
+ player.speed *= 0.7;
 
284
  }
285
+
286
+ // ํ˜„์žฌ ์ฒด๋ ฅ์„ ์ƒˆ๋กœ์šด ์ตœ๋Œ€ ์ฒด๋ ฅ์œผ๋กœ ์„ค์ •
287
+ player.health = player.maxHealth;
288
  }
289
  }
290