mirror of
https://github.com/shadoll/sLogos.git
synced 2025-12-20 03:26:59 +00:00
Add new achievements for "Star Performer" and "City Expert" with tracking logic in CapitalsQuiz
This commit is contained in:
@@ -29,6 +29,13 @@
|
||||
iconColor: "#fbbf24", // gold
|
||||
requirement: () => currentStreak >= 5,
|
||||
},
|
||||
star_performer: {
|
||||
name: "Star Performer",
|
||||
description: "Get 5 perfect rounds in a row",
|
||||
icon: "star.svg",
|
||||
iconColor: "#ffd700",
|
||||
requirement: () => achievements.perfectRounds >= 5,
|
||||
},
|
||||
dedication: {
|
||||
name: "Dedicated Learner",
|
||||
description: "Answer 10 questions in total",
|
||||
@@ -50,6 +57,13 @@
|
||||
iconColor: "#fbbf24", // gold
|
||||
requirement: () => achievements.consecutive_skips >= 10,
|
||||
},
|
||||
city_expert: {
|
||||
name: "City Expert",
|
||||
description: "Answer 10 capital city questions correctly",
|
||||
icon: "buildings.svg",
|
||||
iconColor: "#4f8cff",
|
||||
requirement: () => gameStats.capitalsCorrect >= 10,
|
||||
},
|
||||
persistent: {
|
||||
name: "Persistent Scholar",
|
||||
description: "Answer 25 questions (correct or wrong)",
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
|
||||
// Check if we're in game mode
|
||||
$: isGameMode = $location && $location.startsWith('/game');
|
||||
$: isQuizPage = $location && $location.startsWith('/game/flags');
|
||||
$: isQuizPage = $location && ($location.startsWith('/game/flags') || $location.startsWith('/game/capitals'));
|
||||
|
||||
// Determine default stats view based on quiz state
|
||||
$: {
|
||||
|
||||
@@ -48,6 +48,10 @@
|
||||
let showAchievements = false;
|
||||
let achievementsComponent;
|
||||
let achievementCount = { unlocked: 0, total: 0 };
|
||||
// New achievement tracking
|
||||
let capitalsCorrect = 0;
|
||||
let perfectRounds = 0;
|
||||
let mapChallengeCompleted = false;
|
||||
|
||||
// Settings
|
||||
let autoAdvance = true;
|
||||
@@ -449,6 +453,7 @@
|
||||
gameStats.correct++;
|
||||
sessionStats.correct++;
|
||||
currentStreak++;
|
||||
capitalsCorrect++;
|
||||
|
||||
// Play correct sound
|
||||
playCorrectSound();
|
||||
@@ -648,6 +653,11 @@
|
||||
}
|
||||
|
||||
function endSession() {
|
||||
// Track perfect rounds for achievements
|
||||
if (sessionStats.correct === sessionLength && sessionStats.wrong === 0 && sessionStats.skipped === 0) {
|
||||
perfectRounds++;
|
||||
}
|
||||
|
||||
// Clear session state
|
||||
sessionInProgress = false;
|
||||
clearSessionState();
|
||||
@@ -960,6 +970,9 @@
|
||||
{gameStats}
|
||||
{currentStreak}
|
||||
show={showAchievements}
|
||||
capitalsCorrect={capitalsCorrect}
|
||||
perfectRounds={perfectRounds}
|
||||
mapChallengeCompleted={mapChallengeCompleted}
|
||||
on:close={() => (showAchievements = false)}
|
||||
on:achievementsUnlocked={handleAchievementsUnlocked}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user