mirror of
https://github.com/mudabbir-ahmad/MAD-Treasure-Hunt.git
synced 2026-10-07 19:00:20 +00:00
Update GlobalMapScreen and usePlayerGame logic for improved cache claiming feedback
This commit is contained in:
1 parent
bb7e46cf4b
commit
ac7d89c0c5
2 files changed
+7
-5
No files matched your search
@@ -132,14 +132,12 @@ const GlobalMapScreen = ({ navigation, route }) => {
|
||||
setIsClaiming(false);
|
||||
|
||||
if (result) {
|
||||
const points = Number(claimedCache?.CachePoints ?? 0);
|
||||
const points = Number(claimedCache?.CachePoints ?? 10);
|
||||
const cacheName = claimedCache?.CacheName || "Cache";
|
||||
setFoundCacheIds((prev) =>
|
||||
prev.includes(cacheId) ? prev : [...prev, cacheId],
|
||||
);
|
||||
setClaimedPopupMessage(
|
||||
`${cacheName} claimed! You received ${points} points.`,
|
||||
);
|
||||
setClaimedPopupMessage(`${cacheName} claimed! You gained +${points} points.`);
|
||||
setClaimedPopupVisible(true);
|
||||
setTimeout(() => setClaimedPopupVisible(false), 3000);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ const usePlayerGame = (playerLocation, playerHeading, activeCaches, claimDistanc
|
||||
const prevIdRef = useRef('');
|
||||
|
||||
useEffect(() => {
|
||||
if (!playerLocation || playerHeading === null || playerHeading === undefined || !selectedCacheId) {
|
||||
if (!playerLocation || playerHeading === null || playerHeading === undefined) {
|
||||
if (prevIdRef.current !== '') {
|
||||
prevIdRef.current = '';
|
||||
setVisibleCaches([]);
|
||||
@@ -31,6 +31,10 @@ const usePlayerGame = (playerLocation, playerHeading, activeCaches, claimDistanc
|
||||
prevIdRef.current = newId;
|
||||
setVisibleCaches(visible ? [selected] : []);
|
||||
setIsClaiming(Boolean(visible));
|
||||
} else if (!visible && prevIdRef.current !== '') {
|
||||
prevIdRef.current = '';
|
||||
setVisibleCaches([]);
|
||||
setIsClaiming(false);
|
||||
}
|
||||
}, [playerLocation, playerHeading, activeCaches, claimDistance, selectedCacheId]);
|
||||
|
||||
|
||||
Reference in new issue
Block a user