371 lines
13 KiB
HTML
371 lines
13 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="zh-CN">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title>成就 - 战锤40K行星总督</title>
|
||
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}">
|
||
<style>
|
||
/* 全局滚动条样式 */
|
||
html, body {
|
||
height: 100%;
|
||
margin: 0;
|
||
padding: 0;
|
||
overflow-y: auto;
|
||
background-color: #1a1a1a;
|
||
color: #fff;
|
||
}
|
||
|
||
/* 自定义滚动条样式 */
|
||
::-webkit-scrollbar {
|
||
width: 10px;
|
||
}
|
||
|
||
::-webkit-scrollbar-track {
|
||
background: #333;
|
||
border-radius: 5px;
|
||
}
|
||
|
||
::-webkit-scrollbar-thumb {
|
||
background: #666;
|
||
border-radius: 5px;
|
||
}
|
||
|
||
::-webkit-scrollbar-thumb:hover {
|
||
background: #888;
|
||
}
|
||
|
||
.achievements-container {
|
||
max-width: 800px;
|
||
margin: 20px auto;
|
||
padding: 20px;
|
||
height: auto;
|
||
overflow-y: auto;
|
||
}
|
||
.achievements-grid {
|
||
display: grid;
|
||
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
|
||
gap: 20px;
|
||
margin-top: 20px;
|
||
}
|
||
.achievement-card {
|
||
background-color: #222;
|
||
border-radius: 10px;
|
||
padding: 15px;
|
||
text-align: center;
|
||
cursor: pointer;
|
||
transition: transform 0.3s ease, box-shadow 0.3s ease;
|
||
border: 1px solid #444;
|
||
}
|
||
.achievement-card:hover {
|
||
transform: translateY(-5px);
|
||
box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
|
||
}
|
||
.achievement-locked {
|
||
filter: grayscale(100%);
|
||
opacity: 0.7;
|
||
}
|
||
.achievement-icon {
|
||
font-size: 36px;
|
||
margin-bottom: 10px;
|
||
}
|
||
.achievement-name {
|
||
font-weight: bold;
|
||
margin-bottom: 5px;
|
||
color: #e6b800;
|
||
}
|
||
.achievement-desc {
|
||
font-size: 12px;
|
||
color: #ccc;
|
||
}
|
||
.achievement-status {
|
||
margin-top: 10px;
|
||
font-size: 12px;
|
||
color: #7fc47f;
|
||
}
|
||
.achievement-locked .achievement-status {
|
||
color: #999;
|
||
}
|
||
.progress-bar {
|
||
height: 6px;
|
||
background-color: #333;
|
||
border-radius: 3px;
|
||
margin: 20px 0;
|
||
overflow: hidden;
|
||
}
|
||
.progress-fill {
|
||
height: 100%;
|
||
background-color: #e6b800;
|
||
transition: width 0.5s ease;
|
||
}
|
||
.achievement-details-dialog {
|
||
display: none;
|
||
position: fixed;
|
||
top: 0;
|
||
left: 0;
|
||
width: 100%;
|
||
height: 100%;
|
||
background-color: rgba(0, 0, 0, 0.7);
|
||
z-index: 1000;
|
||
justify-content: center;
|
||
align-items: center;
|
||
overflow: hidden;
|
||
}
|
||
.achievement-details-dialog.show {
|
||
display: flex;
|
||
}
|
||
.details-content {
|
||
background-color: #2a2a2a;
|
||
border-radius: 10px;
|
||
padding: 20px;
|
||
width: 90%;
|
||
max-width: 500px;
|
||
max-height: 80vh;
|
||
overflow-y: auto;
|
||
position: relative;
|
||
border: 2px solid #e6b800;
|
||
}
|
||
.details-close {
|
||
position: absolute;
|
||
top: 10px;
|
||
right: 15px;
|
||
font-size: 24px;
|
||
color: #999;
|
||
cursor: pointer;
|
||
background: none;
|
||
border: none;
|
||
}
|
||
.details-close:hover {
|
||
color: #fff;
|
||
}
|
||
.details-image {
|
||
width: 100%;
|
||
height: 200px;
|
||
margin-bottom: 20px;
|
||
background-color: #333;
|
||
border-radius: 5px;
|
||
display: flex;
|
||
justify-content: center;
|
||
align-items: center;
|
||
overflow: hidden;
|
||
}
|
||
.details-image img {
|
||
max-width: 100%;
|
||
max-height: 100%;
|
||
object-fit: contain;
|
||
}
|
||
.details-image-placeholder {
|
||
font-size: 72px;
|
||
}
|
||
.details-title {
|
||
display: flex;
|
||
align-items: center;
|
||
margin-bottom: 15px;
|
||
}
|
||
.details-icon {
|
||
font-size: 36px;
|
||
margin-right: 15px;
|
||
}
|
||
.details-name {
|
||
font-size: 24px;
|
||
font-weight: bold;
|
||
color: #e6b800;
|
||
}
|
||
.details-description {
|
||
color: #ddd;
|
||
margin-bottom: 20px;
|
||
line-height: 1.6;
|
||
}
|
||
.details-unlock-time {
|
||
color: #7fc47f;
|
||
font-size: 14px;
|
||
margin-top: 10px;
|
||
}
|
||
.details-locked-message {
|
||
color: #999;
|
||
font-style: italic;
|
||
text-align: center;
|
||
padding: 20px;
|
||
}
|
||
.nav-button {
|
||
display: inline-block;
|
||
padding: 10px 20px;
|
||
background-color: #222;
|
||
color: #fff;
|
||
border: 1px solid #444;
|
||
border-radius: 5px;
|
||
text-decoration: none;
|
||
margin-right: 10px;
|
||
transition: background-color 0.3s;
|
||
}
|
||
.nav-button:hover {
|
||
background-color: #444;
|
||
}
|
||
</style>
|
||
</head>
|
||
<body>
|
||
<div class="achievements-container">
|
||
<h1>战锤40K行星总督 - 成就</h1>
|
||
|
||
<div>
|
||
<a href="{{ url_for('game') }}" class="nav-button">返回游戏</a>
|
||
<a href="{{ url_for('index') }}" class="nav-button">返回主页</a>
|
||
</div>
|
||
|
||
<div class="progress-bar">
|
||
<div class="progress-fill" id="achievement-progress"></div>
|
||
</div>
|
||
|
||
<div id="progress-text">已解锁:0/0</div>
|
||
|
||
<div class="achievements-grid" id="achievements-grid">
|
||
<!-- 成就卡片将通过JavaScript动态添加 -->
|
||
</div>
|
||
</div>
|
||
|
||
<!-- 成就详情对话框 -->
|
||
<div class="achievement-details-dialog" id="achievement-details-dialog">
|
||
<div class="details-content">
|
||
<button class="details-close" id="close-details">×</button>
|
||
|
||
<div class="details-image" id="details-image">
|
||
<div class="details-image-placeholder" id="details-image-placeholder"></div>
|
||
</div>
|
||
|
||
<div class="details-title">
|
||
<div class="details-icon" id="details-icon"></div>
|
||
<div class="details-name" id="details-name"></div>
|
||
</div>
|
||
|
||
<div class="details-description" id="details-description"></div>
|
||
|
||
<div class="details-unlock-time" id="details-unlock-time"></div>
|
||
|
||
<div class="details-locked-message" id="details-locked-message">
|
||
这个成就尚未解锁
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<script>
|
||
document.addEventListener('DOMContentLoaded', () => {
|
||
const achievementsGrid = document.getElementById('achievements-grid');
|
||
const progressFill = document.getElementById('achievement-progress');
|
||
const progressText = document.getElementById('progress-text');
|
||
const detailsDialog = document.getElementById('achievement-details-dialog');
|
||
const closeDetailsBtn = document.getElementById('close-details');
|
||
|
||
// 关闭详情对话框
|
||
closeDetailsBtn.addEventListener('click', () => {
|
||
detailsDialog.classList.remove('show');
|
||
});
|
||
|
||
// 点击对话框背景也可以关闭
|
||
detailsDialog.addEventListener('click', (e) => {
|
||
if (e.target === detailsDialog) {
|
||
detailsDialog.classList.remove('show');
|
||
}
|
||
});
|
||
|
||
// 加载成就数据
|
||
fetchAchievements();
|
||
|
||
function fetchAchievements() {
|
||
fetch('/api/achievements')
|
||
.then(response => response.json())
|
||
.then(data => {
|
||
renderAchievements(data);
|
||
})
|
||
.catch(error => {
|
||
console.error('加载成就数据失败:', error);
|
||
});
|
||
}
|
||
|
||
function renderAchievements(data) {
|
||
const { achievements, total, unlocked } = data;
|
||
|
||
// 更新进度条
|
||
const progressPercent = total > 0 ? (unlocked / total) * 100 : 0;
|
||
progressFill.style.width = `${progressPercent}%`;
|
||
progressText.textContent = `已解锁:${unlocked}/${total}`;
|
||
|
||
// 清空现有内容
|
||
achievementsGrid.innerHTML = '';
|
||
|
||
// 添加成就卡片
|
||
achievements.forEach(achievement => {
|
||
const card = document.createElement('div');
|
||
card.className = `achievement-card ${achievement.unlocked ? '' : 'achievement-locked'}`;
|
||
card.dataset.id = achievement.id;
|
||
card.dataset.unlocked = achievement.unlocked;
|
||
|
||
if (achievement.unlock_time) {
|
||
card.dataset.unlockTime = achievement.unlock_time;
|
||
}
|
||
|
||
card.innerHTML = `
|
||
<div class="achievement-icon">${achievement.icon}</div>
|
||
<div class="achievement-name">${achievement.name}</div>
|
||
<div class="achievement-desc">${achievement.unlocked ? achievement.description : '???'}</div>
|
||
<div class="achievement-status">${achievement.unlocked ? '已解锁' : '未解锁'}</div>
|
||
`;
|
||
|
||
// 点击显示详情
|
||
card.addEventListener('click', () => {
|
||
showAchievementDetails(achievement);
|
||
});
|
||
|
||
achievementsGrid.appendChild(card);
|
||
});
|
||
}
|
||
|
||
function showAchievementDetails(achievement) {
|
||
// 设置详情内容
|
||
document.getElementById('details-icon').textContent = achievement.icon;
|
||
document.getElementById('details-name').textContent = achievement.name;
|
||
document.getElementById('details-description').textContent = achievement.unlocked ? achievement.description : '???';
|
||
|
||
// 设置图片
|
||
const imagePlaceholder = document.getElementById('details-image-placeholder');
|
||
imagePlaceholder.textContent = achievement.unlocked ? '' : '?';
|
||
|
||
// 如果有死亡场景ID且已解锁,显示对应的死亡场景图片
|
||
if (achievement.unlocked && achievement.id.startsWith('death_')) {
|
||
// 提取死亡场景ID
|
||
const deathScenarioId = achievement.id.replace('death_', '');
|
||
|
||
// 如果有图片,显示图片
|
||
const imagePath = `/static/images/deaths/${deathScenarioId}.png`;
|
||
imagePlaceholder.innerHTML = `<img src="${imagePath}" alt="${achievement.name}" onerror="this.style.display='none'; this.parentNode.textContent='${achievement.icon}'" />`;
|
||
}
|
||
|
||
// 设置解锁时间
|
||
const unlockTimeElement = document.getElementById('details-unlock-time');
|
||
const lockedMessage = document.getElementById('details-locked-message');
|
||
|
||
if (achievement.unlocked) {
|
||
// 格式化解锁时间
|
||
const unlockDate = new Date(achievement.unlock_time);
|
||
const formattedDate = unlockDate.toLocaleString('zh-CN', {
|
||
year: 'numeric',
|
||
month: '2-digit',
|
||
day: '2-digit',
|
||
hour: '2-digit',
|
||
minute: '2-digit'
|
||
});
|
||
|
||
unlockTimeElement.textContent = `解锁时间:${formattedDate}`;
|
||
unlockTimeElement.style.display = 'block';
|
||
lockedMessage.style.display = 'none';
|
||
} else {
|
||
unlockTimeElement.style.display = 'none';
|
||
lockedMessage.style.display = 'block';
|
||
}
|
||
|
||
// 显示对话框
|
||
detailsDialog.classList.add('show');
|
||
}
|
||
});
|
||
</script>
|
||
</body>
|
||
</html> |