Lashtw commited on
Commit
6593389
·
verified ·
1 Parent(s): 5ce0f9e

Upload 41 files

Browse files
Files changed (2) hide show
  1. spring.html +14 -1
  2. spring.js +41 -27
spring.html CHANGED
@@ -108,10 +108,18 @@
108
 
109
  <div class="progress-container">
110
  <div class="progress-text">進度:<span id="progress-count">0</span>/6</div>
111
- <div class="progress-bar">
112
  <div id="progress-fill"></div>
113
  </div>
114
  </div>
 
 
 
 
 
 
 
 
115
  </div>
116
 
117
  <div class="completion-message" id="completion-section" style="display: none;">
@@ -120,6 +128,11 @@
120
  <p>你已獲得「直覺感知」的能力!</p>
121
  <p>守泉獸欣慰地說:「你已經掌握了平方的基本感知,但這只是開始。真正的勇者需要學會轉換的藝術。前往變換山谷吧,那裡的山谷之靈會教導你下一階段的力量。」</p>
122
 
 
 
 
 
 
123
  <div class="navigation-buttons">
124
  <button id="back-to-map" class="nav-btn">返回王國地圖</button>
125
  <button id="next-trial" class="nav-btn">前往下一試煉</button>
 
108
 
109
  <div class="progress-container">
110
  <div class="progress-text">進度:<span id="progress-count">0</span>/6</div>
111
+ <div class="progress-bar" id="progress-bar">
112
  <div id="progress-fill"></div>
113
  </div>
114
  </div>
115
+
116
+ <div class="score-container">
117
+ <div id="score-display">分數:0/0</div>
118
+ </div>
119
+
120
+ <div class="next-question-container">
121
+ <button id="next-question" class="action-btn" style="display: none;">下一題</button>
122
+ </div>
123
  </div>
124
 
125
  <div class="completion-message" id="completion-section" style="display: none;">
 
128
  <p>你已獲得「直覺感知」的能力!</p>
129
  <p>守泉獸欣慰地說:「你已經掌握了平方的基本感知,但這只是開始。真正的勇者需要學會轉換的藝術。前往變換山谷吧,那裡的山谷之靈會教導你下一階段的力量。」</p>
130
 
131
+ <div class="score-summary">
132
+ <div id="final-score">最終分數:0/0</div>
133
+ <div id="stars-display">☆☆☆</div>
134
+ </div>
135
+
136
  <div class="navigation-buttons">
137
  <button id="back-to-map" class="nav-btn">返回王國地圖</button>
138
  <button id="next-trial" class="nav-btn">前往下一試煉</button>
spring.js CHANGED
@@ -1,8 +1,6 @@
1
  document.addEventListener('DOMContentLoaded', function() {
2
  // 檢查是否有玩家資料
3
  const currentPlayerId = localStorage.getItem('currentPlayerId');
4
- const playerName = localStorage.getItem('currentPlayerName');
5
- const playerProfession = localStorage.getItem('currentPlayerProfession');
6
 
7
  // 如果沒有玩家資料,重定向到首頁
8
  if (!currentPlayerId) {
@@ -20,16 +18,16 @@ document.addEventListener('DOMContentLoaded', function() {
20
  const optionsContainer = document.getElementById('options-container');
21
  const nextQuestionBtn = document.getElementById('next-question');
22
  const backToMapBtn = document.getElementById('back-to-map');
23
- const progressBar = document.getElementById('progress-bar');
24
- const progressText = document.getElementById('progress-text');
25
  const scoreDisplay = document.getElementById('score-display');
26
- const finalScoreDisplay = document.getElementById('final-score');
27
  const starsDisplay = document.getElementById('stars-display');
28
 
29
  // 遊戲狀態
30
  let currentQuestionIndex = 0;
31
  let score = 0;
32
- let totalQuestions = 10;
33
  let questions = [];
34
  let startTime = Date.now();
35
 
@@ -86,7 +84,9 @@ document.addEventListener('DOMContentLoaded', function() {
86
  updateProgress();
87
 
88
  // 隱藏下一題按鈕
89
- nextQuestionBtn.style.display = 'none';
 
 
90
  }
91
 
92
  // 選擇答案
@@ -102,8 +102,12 @@ document.addEventListener('DOMContentLoaded', function() {
102
  allButtons.forEach(btn => {
103
  if (parseInt(btn.textContent) === question.correctAnswer) {
104
  btn.classList.add('correct');
 
 
105
  } else if (btn === buttonElement && !isCorrect) {
106
  btn.classList.add('incorrect');
 
 
107
  }
108
  });
109
 
@@ -122,21 +126,27 @@ document.addEventListener('DOMContentLoaded', function() {
122
  updateScore();
123
 
124
  // 顯示下一題按鈕
125
- setTimeout(() => {
126
  nextQuestionBtn.style.display = 'block';
127
- }, 1000);
128
  }
129
 
130
  // 更新進度
131
  function updateProgress() {
132
  const progress = ((currentQuestionIndex + 1) / totalQuestions) * 100;
133
- progressBar.style.width = progress + '%';
134
- progressText.textContent = `第 ${currentQuestionIndex + 1} 題 / 共 ${totalQuestions} 題`;
 
 
 
 
135
  }
136
 
137
  // 更新分數
138
  function updateScore() {
139
- scoreDisplay.textContent = `分數:${score}/${currentQuestionIndex + 1}`;
 
 
140
  }
141
 
142
  // 下一題
@@ -150,8 +160,8 @@ document.addEventListener('DOMContentLoaded', function() {
150
  const endTime = Date.now();
151
  const completionTime = Math.round((endTime - startTime) / 1000);
152
 
153
- quizSection.style.display = 'none';
154
- completionSection.style.display = 'block';
155
 
156
  // 計算星級
157
  const percentage = (score / totalQuestions) * 100;
@@ -161,18 +171,22 @@ document.addEventListener('DOMContentLoaded', function() {
161
  else if (percentage >= 50) stars = 1;
162
 
163
  // 顯示最終分數和星級
164
- finalScoreDisplay.textContent = `最終分數:${score}/${totalQuestions} (${percentage.toFixed(1)}%)`;
 
 
165
 
166
  // 顯示星星
167
- let starsHTML = '';
168
- for (let i = 0; i < 3; i++) {
169
- if (i < stars) {
170
- starsHTML += '<span class="star filled">★</span>';
171
- } else {
172
- starsHTML += '<span class="star">☆</span>';
 
 
173
  }
 
174
  }
175
- starsDisplay.innerHTML = starsHTML;
176
 
177
  // 保存進度
178
  saveProgress(stars, score, completionTime);
@@ -226,8 +240,8 @@ document.addEventListener('DOMContentLoaded', function() {
226
  if (startChallengeBtn) {
227
  startChallengeBtn.addEventListener('click', function() {
228
  console.log('開始平方之泉挑戰');
229
- storySection.style.display = 'none';
230
- quizSection.style.display = 'block';
231
 
232
  // 生成題目並開始
233
  generateQuestions();
@@ -251,8 +265,8 @@ document.addEventListener('DOMContentLoaded', function() {
251
  }
252
 
253
  // 初始化顯示
254
- storySection.style.display = 'block';
255
- quizSection.style.display = 'none';
256
- completionSection.style.display = 'none';
257
  });
258
 
 
1
  document.addEventListener('DOMContentLoaded', function() {
2
  // 檢查是否有玩家資料
3
  const currentPlayerId = localStorage.getItem('currentPlayerId');
 
 
4
 
5
  // 如果沒有玩家資料,重定向到首頁
6
  if (!currentPlayerId) {
 
18
  const optionsContainer = document.getElementById('options-container');
19
  const nextQuestionBtn = document.getElementById('next-question');
20
  const backToMapBtn = document.getElementById('back-to-map');
21
+ const progressCount = document.getElementById('progress-count');
22
+ const progressFill = document.getElementById('progress-fill');
23
  const scoreDisplay = document.getElementById('score-display');
24
+ const finalScore = document.getElementById('final-score');
25
  const starsDisplay = document.getElementById('stars-display');
26
 
27
  // 遊戲狀態
28
  let currentQuestionIndex = 0;
29
  let score = 0;
30
+ let totalQuestions = 6; // 改為6題
31
  let questions = [];
32
  let startTime = Date.now();
33
 
 
84
  updateProgress();
85
 
86
  // 隱藏下一題按鈕
87
+ if (nextQuestionBtn) {
88
+ nextQuestionBtn.style.display = 'none';
89
+ }
90
  }
91
 
92
  // 選擇答案
 
102
  allButtons.forEach(btn => {
103
  if (parseInt(btn.textContent) === question.correctAnswer) {
104
  btn.classList.add('correct');
105
+ btn.style.backgroundColor = '#4CAF50';
106
+ btn.style.color = 'white';
107
  } else if (btn === buttonElement && !isCorrect) {
108
  btn.classList.add('incorrect');
109
+ btn.style.backgroundColor = '#f44336';
110
+ btn.style.color = 'white';
111
  }
112
  });
113
 
 
126
  updateScore();
127
 
128
  // 顯示下一題按鈕
129
+ if (nextQuestionBtn) {
130
  nextQuestionBtn.style.display = 'block';
131
+ }
132
  }
133
 
134
  // 更新進度
135
  function updateProgress() {
136
  const progress = ((currentQuestionIndex + 1) / totalQuestions) * 100;
137
+ if (progressFill) {
138
+ progressFill.style.width = progress + '%';
139
+ }
140
+ if (progressCount) {
141
+ progressCount.textContent = currentQuestionIndex + 1;
142
+ }
143
  }
144
 
145
  // 更新分數
146
  function updateScore() {
147
+ if (scoreDisplay) {
148
+ scoreDisplay.textContent = `分數:${score}/${currentQuestionIndex + 1}`;
149
+ }
150
  }
151
 
152
  // 下一題
 
160
  const endTime = Date.now();
161
  const completionTime = Math.round((endTime - startTime) / 1000);
162
 
163
+ if (quizSection) quizSection.style.display = 'none';
164
+ if (completionSection) completionSection.style.display = 'block';
165
 
166
  // 計算星級
167
  const percentage = (score / totalQuestions) * 100;
 
171
  else if (percentage >= 50) stars = 1;
172
 
173
  // 顯示最終分數和星級
174
+ if (finalScore) {
175
+ finalScore.textContent = `最終分數:${score}/${totalQuestions} (${percentage.toFixed(1)}%)`;
176
+ }
177
 
178
  // 顯示星星
179
+ if (starsDisplay) {
180
+ let starsHTML = '';
181
+ for (let i = 0; i < 3; i++) {
182
+ if (i < stars) {
183
+ starsHTML += '<span class="star filled">★</span>';
184
+ } else {
185
+ starsHTML += '<span class="star">☆</span>';
186
+ }
187
  }
188
+ starsDisplay.innerHTML = starsHTML;
189
  }
 
190
 
191
  // 保存進度
192
  saveProgress(stars, score, completionTime);
 
240
  if (startChallengeBtn) {
241
  startChallengeBtn.addEventListener('click', function() {
242
  console.log('開始平方之泉挑戰');
243
+ if (storySection) storySection.style.display = 'none';
244
+ if (quizSection) quizSection.style.display = 'block';
245
 
246
  // 生成題目並開始
247
  generateQuestions();
 
265
  }
266
 
267
  // 初始化顯示
268
+ if (storySection) storySection.style.display = 'block';
269
+ if (quizSection) quizSection.style.display = 'none';
270
+ if (completionSection) completionSection.style.display = 'none';
271
  });
272