diff --git a/app/(gameplay)/game/_context/GameContext.tsx b/app/(gameplay)/game/_context/GameContext.tsx index 942f26f..e9466dd 100644 --- a/app/(gameplay)/game/_context/GameContext.tsx +++ b/app/(gameplay)/game/_context/GameContext.tsx @@ -75,8 +75,17 @@ export const GameProvider = ({ useEffect(() => { if(currentLevelId && imageSrcs && imageIds) { - setCurrentImageSrcUrls(imageSrcs.filter((src): src is string => src !== null)); - setCurrentImageIds(imageIds); + // Pair the image src and id together + const pairedArray = imageSrcs + .map((src, index) => ( { src, id: imageIds[index] })) + .filter(pair => pair.src !== null); + + // shuffle the order + const shuffledArray = pairedArray.sort(() => Math.random() - 0.5); + + // set the values + setCurrentImageSrcUrls(shuffledArray.map(pair => pair.src).filter(src => src !== null) as string[]); + setCurrentImageIds(shuffledArray.map(pair => pair.id)); } }, [currentLevelId, imageSrcs, imageIds]); diff --git a/convex/game.ts b/convex/game.ts index c82b3ff..22619e7 100644 --- a/convex/game.ts +++ b/convex/game.ts @@ -133,11 +133,9 @@ export const checkGuess = mutation({ let correct = false; if(args.selectedImageId === AIGeneratedImageId._id) { - // TODO: Implement correct guess here score = 50; correct = true; } else { - // TODO: Implement incorrect guess here score = 0; correct = false; }