decrement,
hasDungeonBoss,
increment,
+ isDungeonCleared,
toggleBoolean,
unclearAll,
} from '../../helpers/tracker';
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,
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 => {