]> git.localhorst.tv Git - alttp.git/blobdiff - resources/js/helpers/tracker.js
better dungeon cleared check
[alttp.git] / resources / js / helpers / tracker.js
index f2be2434a3eb69944685b5fd503c765d75089196..92508d46f1bc9434b97e641c8132a4fd94f0a095 100644 (file)
@@ -92,7 +92,7 @@ export const DUNGEONS = [
                mask: DUNGEON_MASKS.HC,
                checks: [
                        'dark-cross',
-                       'hc-map',
+                       'hc-map-chest',
                        'hc-boom',
                        'hc-cell',
                        'sanc',
@@ -905,7 +905,7 @@ export const UNDERWORLD_LOCATIONS = [
                chest: 0,
        },
        {
-               id: 'hc-map',
+               id: 'hc-map-chest',
                area: 'hc',
                room: 0x72,
                chest: 0,
@@ -948,7 +948,7 @@ export const UNDERWORLD_LOCATIONS = [
        {
                id: 'hype-cave-bottom',
                room: 0x11E,
-               chest: 4,
+               chest: 3,
        },
        {
                id: 'hype-cave-npc',
@@ -1140,12 +1140,12 @@ export const UNDERWORLD_LOCATIONS = [
        {
                id: 'paradox-lower-far-right',
                room: 0xEF,
-               chest: 4,
+               chest: 3,
        },
        {
                id: 'paradox-lower-mid',
                room: 0xEF,
-               chest: 5,
+               chest: 4,
        },
        {
                id: 'paradox-upper-left',
@@ -1543,12 +1543,12 @@ export const UNDERWORLD_LOCATIONS = [
        {
                id: 'waterfall-fairy-left',
                room: 0x114,
-               chest: 4,
+               chest: 0,
        },
        {
                id: 'waterfall-fairy-right',
                room: 0x114,
-               chest: 5,
+               chest: 1,
        },
 ];
 
@@ -1588,6 +1588,16 @@ export const highestActive = (state, names) => {
        return null;
 };
 
+export const clearAll = names => state => {
+       const changes = names.reduce((acc, cur) => ({ ...acc, [cur]: true }), {});
+       return { ...state, ...changes };
+};
+
+export const unclearAll = names => state => {
+       const changes = names.reduce((acc, cur) => ({ ...acc, [cur]: false }), {});
+       return { ...state, ...changes };
+};
+
 export const hasDungeonBoss = (state, dungeon) => !!state[`${dungeon.id}-boss-defeated`];
 
 export const getDungeonBoss = (state, dungeon) =>
@@ -1597,6 +1607,15 @@ export const hasDungeonPrize = (state, dungeon) => !!state[`${dungeon.id}-prize-
 
 export const getDungeonPrize = (state, dungeon) => state[`${dungeon.id}-prize`] || null;
 
+export const isDungeonCleared = (state, dungeon) => {
+       const cleared = state[`${dungeon.id}-checks`] || 0;
+       const total = dungeon.items;
+       const hasItems = cleared >= total;
+       const hasBoss = !dungeon.boss || hasDungeonBoss(state, dungeon);
+       const hasPrize = !dungeon.porize || hasDungeonPrize(state, dungeon);
+       return hasItems && hasBoss && hasPrize;
+};
+
 export const makeEmptyState = () => {
        const state = {};
        BOOLEAN_STATES.forEach(p => {