Spaces:
Running
Running
Upload index.html
Browse files- index.html +33 -42
index.html
CHANGED
|
@@ -1213,57 +1213,48 @@
|
|
| 1213 |
|
| 1214 |
// 顯示科目輸入
|
| 1215 |
function displaySubjectInput(index) {
|
| 1216 |
-
|
| 1217 |
-
|
| 1218 |
-
|
| 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 |
-
|
| 1240 |
-
|
| 1241 |
-
|
| 1242 |
-
|
| 1243 |
-
|
| 1244 |
-
|
| 1245 |
-
|
| 1246 |
-
|
| 1247 |
-
|
| 1248 |
-
|
| 1249 |
-
|
| 1250 |
-
|
| 1251 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1252 |
});
|
| 1253 |
|
| 1254 |
-
document.getElementById(
|
| 1255 |
-
|
| 1256 |
-
|
| 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 |
-
|
| 1266 |
-
|
|
|
|
| 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];
|