From 4e24f36eb5d6907697c106ca15c2c405728d78a8 Mon Sep 17 00:00:00 2001 From: Daniel Karbach Date: Mon, 25 Mar 2024 15:37:17 +0100 Subject: [PATCH] better dungeon cleared check --- resources/js/components/tracker/Map.js | 11 +++-------- resources/js/helpers/tracker.js | 9 +++++++++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/resources/js/components/tracker/Map.js b/resources/js/components/tracker/Map.js index 9c27a34..b2685f8 100644 --- a/resources/js/components/tracker/Map.js +++ b/resources/js/components/tracker/Map.js @@ -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, diff --git a/resources/js/helpers/tracker.js b/resources/js/helpers/tracker.js index 1409b35..92508d4 100644 --- a/resources/js/helpers/tracker.js +++ b/resources/js/helpers/tracker.js @@ -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 => { -- 2.39.2