]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/components/tracker/Map.js
simple logic tracking
[alttp.git] / resources / js / components / tracker / Map.js
index b77612ef65bd02ae9eb481df3c8e90b28daf4bb1..3ee4b2f81458ab4eeb6190273623467406788bc1 100644 (file)
@@ -4,12 +4,13 @@ import { useTranslation } from 'react-i18next';
 
 import {
        addDungeonCheck,
+       aggregateDungeonStatus,
+       aggregateLocationStatus,
        clearAll,
        completeDungeonChecks,
        countRemainingLocations,
        getDungeonClearedItems,
        getDungeonRemainingItems,
-       hasClearedLocations,
        hasDungeonBoss,
        hasDungeonPrize,
        isDungeonCleared,
@@ -686,15 +687,12 @@ const makeBackground = (src, level) => {
 };
 
 const Map = () => {
-       const { dungeons, setManualState, state } = useTracker();
+       const { dungeons, logic, setManualState, state } = useTracker();
 
        const mapDungeon = React.useCallback(dungeon => {
                const definition = dungeons.find(d => d.id === dungeon.id);
                const remaining = getDungeonRemainingItems(state, definition);
-               let status = 'available';
-               if (isDungeonCleared(state, definition)) {
-                       status = 'cleared';
-               }
+               const status = aggregateDungeonStatus(definition, logic, state);
                return {
                        ...dungeon,
                        status,
@@ -745,14 +743,11 @@ const Map = () => {
                                }
                        },
                };
-       }, [dungeons, setManualState, state]);
+       }, [dungeons, logic, setManualState, state]);
 
        const mapLocation = React.useCallback(loc => {
                const remaining = countRemainingLocations(state, loc.checks);
-               let status = 'available';
-               if (hasClearedLocations(state, loc.checks)) {
-                       status = 'cleared';
-               }
+               const status = aggregateLocationStatus(loc.checks, logic, state);
                return {
                        ...loc,
                        remaining,
@@ -772,7 +767,7 @@ const Map = () => {
                                }
                        },
                };
-       }, [setManualState, state]);
+       }, [logic, setManualState, state]);
 
        const lwDungeons = React.useMemo(() => LW_DUNGEONS.map(mapDungeon), [mapDungeon]);
        const lwLocations = React.useMemo(() => LW_LOCATIONS.map(mapLocation), [mapLocation]);