Spaces:
Running
Running
Upload 26 files
Browse files
valley.js
CHANGED
|
@@ -229,10 +229,14 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
| 229 |
else if (correctAnswers >= 5) currentStars = 2;
|
| 230 |
else if (correctAnswers >= 4) currentStars = 1;
|
| 231 |
|
|
|
|
|
|
|
| 232 |
// 檢查是否已有變換山谷的紀錄及其星數
|
| 233 |
const existingTrial = gameProgress.completedTrials["變換山谷"];
|
| 234 |
const existingStars = existingTrial && existingTrial.stars ? existingTrial.stars : 0;
|
| 235 |
|
|
|
|
|
|
|
| 236 |
// 根據答對題數顯示不同結果
|
| 237 |
if (correctAnswers >= 4) {
|
| 238 |
gameProgress.completedTrials["變換山谷"].completed = true;
|
|
@@ -251,7 +255,9 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
| 251 |
`;
|
| 252 |
|
| 253 |
// 顯示星星 - 顯示歷史最高星數與當前星數中的較高者
|
| 254 |
-
|
|
|
|
|
|
|
| 255 |
|
| 256 |
// 顯示成功按鈕,隱藏失敗按鈕
|
| 257 |
successButtons.style.display = 'flex';
|
|
@@ -272,6 +278,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
| 272 |
`;
|
| 273 |
|
| 274 |
// 不顯示星星,但保留歷史星數
|
|
|
|
| 275 |
updateStars(existingStars);
|
| 276 |
|
| 277 |
// 顯示失敗按鈕,隱藏成功按鈕
|
|
@@ -327,6 +334,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
| 327 |
});
|
| 328 |
|
| 329 |
// 前往下一試煉按鈕點擊事件
|
|
|
|
| 330 |
nextTrialBtn.addEventListener('click', function() {
|
| 331 |
// 直接導向展開之塔
|
| 332 |
window.location.href = 'tower.html';
|
|
|
|
| 229 |
else if (correctAnswers >= 5) currentStars = 2;
|
| 230 |
else if (correctAnswers >= 4) currentStars = 1;
|
| 231 |
|
| 232 |
+
console.log("當前答對題數:", correctAnswers, "當前星數:", currentStars);
|
| 233 |
+
|
| 234 |
// 檢查是否已有變換山谷的紀錄及其星數
|
| 235 |
const existingTrial = gameProgress.completedTrials["變換山谷"];
|
| 236 |
const existingStars = existingTrial && existingTrial.stars ? existingTrial.stars : 0;
|
| 237 |
|
| 238 |
+
console.log("歷史星數:", existingStars);
|
| 239 |
+
|
| 240 |
// 根據答對題數顯示不同結果
|
| 241 |
if (correctAnswers >= 4) {
|
| 242 |
gameProgress.completedTrials["變換山谷"].completed = true;
|
|
|
|
| 255 |
`;
|
| 256 |
|
| 257 |
// 顯示星星 - 顯示歷史最高星數與當前星數中的較高者
|
| 258 |
+
const displayStars = Math.max(currentStars, existingStars);
|
| 259 |
+
console.log("顯示星數:", displayStars);
|
| 260 |
+
updateStars(displayStars);
|
| 261 |
|
| 262 |
// 顯示成功按鈕,隱藏失敗按鈕
|
| 263 |
successButtons.style.display = 'flex';
|
|
|
|
| 278 |
`;
|
| 279 |
|
| 280 |
// 不顯示星星,但保留歷史星數
|
| 281 |
+
console.log("失敗時顯示歷史星數:", existingStars);
|
| 282 |
updateStars(existingStars);
|
| 283 |
|
| 284 |
// 顯示失敗按鈕,隱藏成功按鈕
|
|
|
|
| 334 |
});
|
| 335 |
|
| 336 |
// 前往下一試煉按鈕點擊事件
|
| 337 |
+
const nextTrialBtn = document.getElementById('next-trial');
|
| 338 |
nextTrialBtn.addEventListener('click', function() {
|
| 339 |
// 直接導向展開之塔
|
| 340 |
window.location.href = 'tower.html';
|