Lashtw commited on
Commit
f005203
·
verified ·
1 Parent(s): ca49b67

Upload index.html

Browse files
Files changed (1) hide show
  1. index.html +33 -42
index.html CHANGED
@@ -1213,57 +1213,48 @@
1213
 
1214
  // 顯示科目輸入
1215
  function displaySubjectInput(index) {
1216
- // 檢查是否已經顯示過社會科攻擊描述
1217
- if (socialAttackCompleted) {
1218
- return; // 已經完成社會科攻擊,不再重複顯示
1219
- }
1220
-
1221
- // 標記社會科攻擊已完成
1222
- socialAttackCompleted = true;
1223
-
1224
- // 在戰鬥日誌中添加選項按鈕
1225
- const optionsDiv = document.createElement('div');
1226
- optionsDiv.className = 'battle-options';
1227
- optionsDiv.innerHTML = `
1228
- <h3>社會科攻擊完成!</h3>
1229
- <p>你已完成所有科目的攻擊。</p>
1230
- <div>
1231
- <button id="view-result-btn">查看結果</button>
1232
- <button id="use-holy-item-btn">使用聖物補刀</button>
1233
- </div>
1234
- `;
1235
- battleLog.appendChild(optionsDiv);
1236
- battleLog.scrollTop = battleLog.scrollHeight;
1237
 
1238
- // 添加按鈕事件
1239
- document.getElementById('view-result-btn').addEventListener('click', function() {
1240
- // 判斷戰鬥結果
1241
- if (monsterHP <= 0) {
1242
- // 播放勝利音效
1243
- audioController.playResultSound('win');
1244
- // 顯示成功結果
1245
- displayResult(true);
1246
- } else {
1247
- // 播放失敗音效
1248
- audioController.playResultSound('lose');
1249
- // 顯示失敗結果
1250
- displayResult(false);
1251
- }
 
 
 
 
 
 
 
1252
  });
1253
 
1254
- document.getElementById('use-holy-item-btn').addEventListener('click', function() {
1255
- // 顯示聖物補刀區域
1256
- battleSection.classList.add('hidden');
1257
- holyItemSection.classList.remove('hidden');
1258
  remainingHpDisplay.textContent = monsterHP.toFixed(1);
1259
 
1260
  // 確保聖物補刀區域顯示king.jpg
1261
  monsterImageHoly.src = 'images/king.jpg';
1262
  });
1263
-
1264
  // 關鍵修改:清空科目輸入區域,防止重複攻擊
1265
- subjectInput.innerHTML = '';
1266
- return;
 
1267
  }
1268
 
1269
  const subject = subjects[index];
 
1213
 
1214
  // 顯示科目輸入
1215
  function displaySubjectInput(index) {
1216
+ if (index >= subjects.length) {
1217
+ // 檢查是否已經顯示過社會科攻擊描述
1218
+ if (socialAttackCompleted) {
1219
+ return; // 已經完成社會科攻擊,不再重複顯示
1220
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1221
 
1222
+ // 標記社會科攻擊已完成
1223
+ socialAttackCompleted = true;
1224
+
1225
+ // 在戰鬥日誌中添加選項按鈕
1226
+ const optionsDiv = document.createElement("div");
1227
+ optionsDiv.className = "battle-options";
1228
+ optionsDiv.innerHTML = `
1229
+ <h3>社會科攻擊完成!</h3>
1230
+ <p>你已完成所有科目的攻擊。</p>
1231
+ <div>
1232
+ <button id="view-result-btn">查看結果</button>
1233
+ <button id="use-holy-item-btn">使用聖物補刀</button>
1234
+ </div>
1235
+ `;
1236
+ battleLog.appendChild(optionsDiv);
1237
+ battleLog.scrollTop = battleLog.scrollHeight;
1238
+
1239
+ document.getElementById("view-result-btn").addEventListener("click", () => {
1240
+ battleSection.classList.add("hidden");
1241
+ resultSection.classList.remove("hidden");
1242
+ displayResult(monsterHP <= 0);
1243
  });
1244
 
1245
+ document.getElementById("use-holy-item-btn").addEventListener("click", () => {
1246
+ battleSection.classList.add("hidden");
1247
+ holyItemSection.classList.remove("hidden");
 
1248
  remainingHpDisplay.textContent = monsterHP.toFixed(1);
1249
 
1250
  // 確保聖物補刀區域顯示king.jpg
1251
  monsterImageHoly.src = 'images/king.jpg';
1252
  });
1253
+
1254
  // 關鍵修改:清空科目輸入區域,防止重複攻擊
1255
+ subjectInput.innerHTML = "";
1256
+
1257
+ return;
1258
  }
1259
 
1260
  const subject = subjects[index];