Spaces:
Running
Running
Upload 42 files
Browse files- achievements.html +54 -2
achievements.html
CHANGED
|
@@ -308,6 +308,7 @@
|
|
| 308 |
const waitForAchievementSystem = () => {
|
| 309 |
if (window.achievementSystem && window.achievementSystem.achievements.length > 0) {
|
| 310 |
displayAchievements();
|
|
|
|
| 311 |
} else {
|
| 312 |
setTimeout(waitForAchievementSystem, 100);
|
| 313 |
}
|
|
@@ -316,6 +317,47 @@
|
|
| 316 |
setTimeout(waitForAchievementSystem, 500);
|
| 317 |
});
|
| 318 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 319 |
function displayAchievements() {
|
| 320 |
const achievementSystem = window.achievementSystem;
|
| 321 |
if (!achievementSystem) {
|
|
@@ -348,8 +390,18 @@
|
|
| 348 |
card.className = `achievement-card ${achievement.type || achievement.category || 'default'} ${isUnlocked ? 'unlocked' : 'locked'}`;
|
| 349 |
|
| 350 |
const icon = getAchievementIcon(achievement.type || achievement.category);
|
| 351 |
-
|
| 352 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 353 |
|
| 354 |
card.innerHTML = `
|
| 355 |
<div class="achievement-icon">${icon}</div>
|
|
|
|
| 308 |
const waitForAchievementSystem = () => {
|
| 309 |
if (window.achievementSystem && window.achievementSystem.achievements.length > 0) {
|
| 310 |
displayAchievements();
|
| 311 |
+
setupTabButtons();
|
| 312 |
} else {
|
| 313 |
setTimeout(waitForAchievementSystem, 100);
|
| 314 |
}
|
|
|
|
| 317 |
setTimeout(waitForAchievementSystem, 500);
|
| 318 |
});
|
| 319 |
|
| 320 |
+
function setupTabButtons() {
|
| 321 |
+
const tabButtons = document.querySelectorAll('.tab-button');
|
| 322 |
+
tabButtons.forEach(button => {
|
| 323 |
+
button.addEventListener('click', function() {
|
| 324 |
+
// 移除所有按鈕的 active 類
|
| 325 |
+
tabButtons.forEach(btn => btn.classList.remove('active'));
|
| 326 |
+
// 添加 active 類到當前按鈕
|
| 327 |
+
this.classList.add('active');
|
| 328 |
+
|
| 329 |
+
// 根據選擇的類型過濾成就
|
| 330 |
+
const selectedType = this.getAttribute('data-type');
|
| 331 |
+
filterAchievements(selectedType);
|
| 332 |
+
});
|
| 333 |
+
});
|
| 334 |
+
}
|
| 335 |
+
|
| 336 |
+
function filterAchievements(type) {
|
| 337 |
+
const achievementSystem = window.achievementSystem;
|
| 338 |
+
const achievementsContainer = document.getElementById('achievements-grid');
|
| 339 |
+
|
| 340 |
+
// 清空容器
|
| 341 |
+
achievementsContainer.innerHTML = '';
|
| 342 |
+
|
| 343 |
+
// 過濾成就
|
| 344 |
+
let filteredAchievements;
|
| 345 |
+
if (type === 'all') {
|
| 346 |
+
filteredAchievements = achievementSystem.achievements;
|
| 347 |
+
} else {
|
| 348 |
+
filteredAchievements = achievementSystem.achievements.filter(achievement =>
|
| 349 |
+
achievement.type === type
|
| 350 |
+
);
|
| 351 |
+
}
|
| 352 |
+
|
| 353 |
+
// 顯示過濾後的成就
|
| 354 |
+
filteredAchievements.forEach(achievement => {
|
| 355 |
+
const isUnlocked = achievementSystem.isAchievementUnlocked(achievement.id);
|
| 356 |
+
const achievementCard = createAchievementCard(achievement, isUnlocked);
|
| 357 |
+
achievementsContainer.appendChild(achievementCard);
|
| 358 |
+
});
|
| 359 |
+
}
|
| 360 |
+
|
| 361 |
function displayAchievements() {
|
| 362 |
const achievementSystem = window.achievementSystem;
|
| 363 |
if (!achievementSystem) {
|
|
|
|
| 390 |
card.className = `achievement-card ${achievement.type || achievement.category || 'default'} ${isUnlocked ? 'unlocked' : 'locked'}`;
|
| 391 |
|
| 392 |
const icon = getAchievementIcon(achievement.type || achievement.category);
|
| 393 |
+
|
| 394 |
+
// 根據成就類型決定是否顯示名稱和描述
|
| 395 |
+
let title, description;
|
| 396 |
+
if (achievement.type === 'secret' && !isUnlocked) {
|
| 397 |
+
// 隱藏彩蛋未解鎖時不顯示名稱和描述
|
| 398 |
+
title = '???';
|
| 399 |
+
description = '尚未解鎖';
|
| 400 |
+
} else {
|
| 401 |
+
// 魔力足跡和試煉之魂始終顯示名稱和描述
|
| 402 |
+
title = achievement.title;
|
| 403 |
+
description = achievement.description;
|
| 404 |
+
}
|
| 405 |
|
| 406 |
card.innerHTML = `
|
| 407 |
<div class="achievement-icon">${icon}</div>
|