]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/components/tracker/Map/Overworld.js
tentative inverted logic
[alttp.git] / resources / js / components / tracker / Map / Overworld.js
index 609dc34cd7c92fd282f566580a9f3a2cc99dc4c3..a865c19849d7901e74af8b942bef96fc52039b99 100644 (file)
@@ -22,17 +22,12 @@ import {
 } from '../../../helpers/tracker';
 import { useTracker } from '../../../hooks/tracker';
 
-const LW_DUNGEONS = [
+const GENERIC_LW_DUNGEONS = [
        {
                id: 'hc',
                x: 0.5,
                y: 0.5,
        },
-       {
-               id: 'ct',
-               x: 0.5,
-               y: 0.4,
-       },
        {
                id: 'ep',
                x: 0.95,
@@ -50,7 +45,25 @@ const LW_DUNGEONS = [
        },
 ];
 
-const LW_LOCATIONS = [
+const LW_DUNGEONS = [
+       ...GENERIC_LW_DUNGEONS,
+       {
+               id: 'ct',
+               x: 0.5,
+               y: 0.4,
+       },
+];
+
+const INVERTED_LW_DUNGEONS = [
+       ...GENERIC_LW_DUNGEONS,
+       {
+               id: 'gt',
+               x: 0.5,
+               y: 0.4,
+       },
+];
+
+const GENERIC_LW_LOCATIONS = [
        {
                id: 'aginah',
                checks: [
@@ -220,14 +233,6 @@ const LW_LOCATIONS = [
                x: 0.15,
                y: 0.65,
        },
-       {
-               id: 'links-house',
-               checks: [
-                       'links-house',
-               ],
-               x: 0.55,
-               y: 0.6875,
-       },
        {
                id: 'lost-woods-hideout',
                checks: [
@@ -420,7 +425,21 @@ const LW_LOCATIONS = [
        },
 ];
 
-const DW_DUNGEONS = [
+const LW_LOCATIONS = [
+       ...GENERIC_LW_LOCATIONS,
+       {
+               id: 'links-house',
+               checks: [
+                       'links-house',
+               ],
+               x: 0.55,
+               y: 0.6875,
+       },
+];
+
+const INVERTED_LW_LOCATIONS = GENERIC_LW_LOCATIONS;
+
+const GENERIC_DW_DUNGEONS = [
        {
                id: 'pd',
                x: 0.95,
@@ -456,6 +475,10 @@ const DW_DUNGEONS = [
                x: 0.94,
                y: 0.06,
        },
+];
+
+const DW_DUNGEONS = [
+       ...GENERIC_DW_DUNGEONS,
        {
                id: 'gt',
                x: 0.56,
@@ -463,7 +486,16 @@ const DW_DUNGEONS = [
        },
 ];
 
-const DW_LOCATIONS = [
+const INVERTED_DW_DUNGEONS = [
+       ...GENERIC_DW_DUNGEONS,
+       {
+               id: 'ct',
+               x: 0.56,
+               y: 0.05,
+       },
+];
+
+const GENERIC_DW_LOCATIONS = [
        {
                id: 'blacksmith',
                checks: [
@@ -619,6 +651,20 @@ const DW_LOCATIONS = [
        },
 ];
 
+const DW_LOCATIONS = GENERIC_DW_LOCATIONS;
+
+const INVERTED_DW_LOCATIONS = [
+       ...GENERIC_DW_LOCATIONS,
+       {
+               id: 'links-house',
+               checks: [
+                       'links-house',
+               ],
+               x: 0.55,
+               y: 0.6875,
+       },
+];
+
 const Location = ({ number, l, size }) => {
        const { t } = useTranslation();
 
@@ -687,7 +733,7 @@ const makeBackground = (src, level) => {
 };
 
 const Overworld = () => {
-       const { dungeons, logic, setManualState, state } = useTracker();
+       const { config, dungeons, logic, setManualState, state } = useTracker();
 
        const mapDungeon = React.useCallback(dungeon => {
                const definition = dungeons.find(d => d.id === dungeon.id);
@@ -769,11 +815,23 @@ const Overworld = () => {
                };
        }, [logic, setManualState, state]);
 
-       const lwDungeons = React.useMemo(() => LW_DUNGEONS.map(mapDungeon), [mapDungeon]);
-       const lwLocations = React.useMemo(() => LW_LOCATIONS.map(mapLocation), [mapLocation]);
+       const lwDungeons = React.useMemo(() =>
+               (config.worldState === 'inverted' ? INVERTED_LW_DUNGEONS : LW_DUNGEONS)
+               .map(mapDungeon)
+       , [mapDungeon]);
+       const lwLocations = React.useMemo(() =>
+               (config.worldState === 'inverted' ? INVERTED_LW_LOCATIONS : LW_LOCATIONS)
+               .map(mapLocation)
+       , [mapLocation]);
 
-       const dwDungeons = React.useMemo(() => DW_DUNGEONS.map(mapDungeon), [mapDungeon]);
-       const dwLocations = React.useMemo(() => DW_LOCATIONS.map(mapLocation), [mapLocation]);
+       const dwDungeons = React.useMemo(() =>
+               (config.worldState === 'inverted' ? INVERTED_DW_DUNGEONS : DW_DUNGEONS)
+               .map(mapDungeon)
+       , [mapDungeon]);
+       const dwLocations = React.useMemo(() =>
+               (config.worldState === 'inverted' ? INVERTED_DW_LOCATIONS : DW_LOCATIONS)
+               .map(mapLocation)
+       , [mapLocation]);
 
        return <svg
                xmlns="http://www.w3.org/2000/svg"