mirror of
https://github.com/mudabbir-ahmad/MAD-Treasure-Hunt.git
synced 2026-10-07 19:00:20 +00:00
Update claiming logic in MapScreen and usePlayerGame to improve cache selection and visibility
This commit is contained in:
1 parent
82e15508c2
commit
c629cf6074
2 files changed
+6
-2
No files matched your search
@@ -442,6 +442,10 @@ const MapScreen = ({navigation, route}) => {
|
||||
|
||||
const handleClaim = useCallback(async (cacheId) => {
|
||||
if (!session.currentGid) return;
|
||||
if (!selectedCacheId || String(cacheId) !== String(selectedCacheId)) {
|
||||
setIsClaiming(false);
|
||||
return;
|
||||
}
|
||||
const result = await claimCache({
|
||||
gid: session.currentGid,
|
||||
cacheId,
|
||||
@@ -455,7 +459,7 @@ const MapScreen = ({navigation, route}) => {
|
||||
setTimeout(() => setClaimedPopupVisible(false), 3000);
|
||||
}
|
||||
await loadCaches();
|
||||
}, [session.currentGid, session.currentUid, session.currentTid, effectiveSGid, claimCache, setIsClaiming, loadCaches]);
|
||||
}, [session.currentGid, session.currentUid, session.currentTid, effectiveSGid, selectedCacheId, claimCache, setIsClaiming, loadCaches]);
|
||||
|
||||
const handleCreateCachePress = () => {
|
||||
const fallback = userLocation || {latitude: mapRegion.latitude, longitude: mapRegion.longitude};
|
||||
|
||||
@@ -22,7 +22,7 @@ const usePlayerGame = (playerLocation, playerHeading, activeCaches, claimDistanc
|
||||
: null;
|
||||
let visible = selected && isInClaimCone(playerHeading, playerLocation, selected.coordinates, claimDistance);
|
||||
|
||||
if (!visible) {
|
||||
if (!preferSelectedCache && !visible) {
|
||||
selected = caches.find((c) => isInClaimCone(playerHeading, playerLocation, c.coordinates, claimDistance)) || null;
|
||||
visible = Boolean(selected);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user