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

Function moveSimulator

frontend/src/App.tsx:910–943  ·  view source on GitHub ↗
(direction: SimDirection)

Source from the content-addressed store, hash-verified

908 }
909
910 function moveSimulator(direction: SimDirection) {
911 if (!challenge) {
912 setSimMessage("当前挑战还没有加载完成。");
913 return;
914 }
915 const current = simPosition || {
916 lat: challenge.center_lat,
917 lng: challenge.center_lng,
918 };
919 if (!simPosition) {
920 resetSimulator();
921 }
922 const step = Math.max(1, Math.min(500, Math.round(simStepM || 30)));
923 const next = moveByMeters(current, direction, step, mapRotationDeg);
924 const nextCellId = safeLatLngToCell(next.lat, next.lng, challenge.h3_resolution);
925 const inside = Boolean(nextCellId && cellIdSet.has(nextCellId));
926 setGpsPosition(null);
927 setGpsCellId(null);
928 setSimPosition(next);
929 if (inside) {
930 setSimMine((prev) => new Set(prev).add(nextCellId));
931 }
932 const directionText =
933 direction === "north"
934 ? "北"
935 : direction === "south"
936 ? "南"
937 : direction === "west"
938 ? "西"
939 : "东";
940 setSimMessage(
941 `已向${directionText}移动约 ${step} 米,${inside ? "已进入挑战格。" : "当前位置在挑战范围外,不点亮。"}`
942 );
943 }
944
945 async function shareChallenge() {
946 if (!challenge) return;

Callers

nothing calls this directly

Calls 3

resetSimulatorFunction · 0.85
moveByMetersFunction · 0.85
safeLatLngToCellFunction · 0.85

Tested by

no test coverage detected