]> git.localhorst.tv Git - alttp.git/commitdiff
better dungeon cleared check
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Mon, 25 Mar 2024 14:37:17 +0000 (15:37 +0100)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Mon, 25 Mar 2024 14:37:17 +0000 (15:37 +0100)
resources/js/components/tracker/Map.js
resources/js/helpers/tracker.js

index 9c27a3476ff938d7ce4a56be9ae642d67e00c7df..b2685f873d6776814e00db66ff2cc6c225d51b03 100644 (file)
@@ -7,6 +7,7 @@ import {
        decrement,
        hasDungeonBoss,
        increment,
+       isDungeonCleared,
        toggleBoolean,
        unclearAll,
 } from '../../helpers/tracker';
@@ -684,14 +685,8 @@ const Map = () => {
                const cleared = state[`${dungeon.id}-checks`] || 0;
                const total = definition.items;
                let status = 'available';
-               if (cleared === total) {
-                       if (['ct', 'gt'].includes(dungeon.id)) {
-                               if (hasDungeonBoss(state, dungeon)) {
-                                       status = 'cleared';
-                               }
-                       } else {
-                               status = 'cleared';
-                       }
+               if (isDungeonCleared(state, definition)) {
+                       status = 'cleared';
                }
                return {
                        ...dungeon,
index 1409b35e27ef6de1988309a973692ca5aebdcf35..92508d46f1bc9434b97e641c8132a4fd94f0a095 100644 (file)
@@ -1607,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 => {