MCPcopy Create free account
hub / github.com/ImGoodBai/MapGoGoGo / resetSimulator

Function resetSimulator

frontend/src/App.tsx:883–908  ·  view source on GitHub ↗
(clearProgress = false)

Source from the content-addressed store, hash-verified

881 }
882
883 function resetSimulator(clearProgress = false) {
884 if (!challenge) {
885 setSimMessage("当前挑战还没有格子,无法模拟。");
886 return;
887 }
888 const center = { lat: challenge.center_lat, lng: challenge.center_lng };
889 const centerCellId = safeLatLngToCell(
890 center.lat,
891 center.lng,
892 challenge.h3_resolution
893 );
894 const centerInside = Boolean(centerCellId && cellIdSet.has(centerCellId));
895 setGpsPosition(null);
896 setGpsCellId(null);
897 setSimPosition(center);
898 if (clearProgress) {
899 setSimMine(centerInside ? new Set([centerCellId]) : new Set());
900 } else {
901 setSimMine((prev) => {
902 const next = new Set([...prev].filter((cellId) => cellIdSet.has(cellId)));
903 if (centerInside) next.add(centerCellId);
904 return next;
905 });
906 }
907 setSimMessage(clearProgress ? "已回到挑战中心,并清空本地模拟轨迹。" : "已回到挑战中心。");
908 }
909
910 function moveSimulator(direction: SimDirection) {
911 if (!challenge) {

Callers 2

moveSimulatorFunction · 0.85
ChallengeViewFunction · 0.85

Calls 1

safeLatLngToCellFunction · 0.85

Tested by

no test coverage detected