]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/hooks/tracker.js
base logic test cases
[alttp.git] / resources / js / hooks / tracker.js
index ec1e8ce25c2a6725c5ebbd726377eb6a890755ad..ce01c4b94079dd646e17f9263882a85544bc3153 100644 (file)
@@ -2,10 +2,10 @@ import PropTypes from 'prop-types';
 import React from 'react';
 
 import {
-       BOSSES,
        CONFIG,
        DUNGEONS,
        applyLogic,
+       configureDungeons,
        makeEmptyState,
        mergeStates,
 } from '../helpers/tracker';
@@ -38,25 +38,7 @@ export const TrackerProvider = ({ children }) => {
        }, []);
 
        React.useEffect(() => {
-               const newDungeons = DUNGEONS.map(dungeon => {
-                       const newDungeon = JSON.parse(JSON.stringify(dungeon));
-                       if (config.wildMap && dungeon.map) {
-                               ++newDungeon.items;
-                       }
-                       if (config.wildCompass && dungeon.compass) {
-                               ++newDungeon.items;
-                       }
-                       if (config.wildSmall) {
-                               newDungeon.items += dungeon.sk;
-                       }
-                       if (config.wildBig && dungeon.bk && !dungeon.dropBk) {
-                               ++newDungeon.items;
-                       }
-                       if (dungeon.boss) {
-                               newDungeon.bosses = config.bossShuffle ? BOSSES : [dungeon.boss];
-                       }
-                       return newDungeon;
-               });
+               const newDungeons = configureDungeons(config);
                setDungeons(newDungeons);
        }, [config]);