Skip to content

Commit 48ba44c

Browse files
authored
hopefully this works part 2
1 parent 7d21481 commit 48ba44c

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

src/components/Game/QuizMode.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export const QuizMode: React.FC = observer(() => {
5151
gameStore.allFlags.filter(f => f.country !== gameStore.currentFlag?.country),
5252
gameStore.currentFlag,
5353
3,
54-
gameStore.originalFlags,
54+
gameStore.allFlags,
5555
settingsStore.difficulty
5656
);
5757

src/services/StorageService.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ interface GameState {
1010
isReplayMode: boolean;
1111
elapsedTime: number;
1212
nextFlag: Flag | null;
13+
allFlags: Flag[];
1314
quizState: {
1415
options: string[];
1516
translatedOptions: string[];

src/stores/GameStore.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ export class GameStore {
6666
quizState: this.quizState,
6767
typeState: this.typeState,
6868
elapsedTime: this.elapsedTime,
69-
nextFlag: this.nextFlag
69+
nextFlag: this.nextFlag,
70+
allFlags: this.allFlags
7071
});
7172
}
7273

@@ -114,7 +115,12 @@ export class GameStore {
114115
if (!answerIsCorrect) {
115116
this.incorrectFlags.push(this.currentFlag!);
116117
}
117-
118+
});
119+
120+
// Wait for animations to complete before updating flags
121+
await new Promise(resolve => setTimeout(resolve, 300));
122+
123+
runInAction(() => {
118124
// Remove the current flag from remaining flags
119125
this.remainingFlags = this.remainingFlags.slice(1);
120126

@@ -182,7 +188,7 @@ export class GameStore {
182188
}
183189

184190
get scorePercentage(): string {
185-
let answeredFlags = this.allFlags.length - this.remainingFlags.length;
191+
const answeredFlags = this.allFlags.length - this.remainingFlags.length;
186192
if (answeredFlags === 0) return '0';
187193
return ((this.correctCount / answeredFlags) * 100).toFixed(0);
188194
}

0 commit comments

Comments
 (0)