},
];
+export const getConfigValue = (config, name, fallback) =>
+ Object.prototype.hasOwnProperty.call(config, name) ? config[name] : fallback;
+
export const applyLogic = (config, dungeons, state) => {
const logic = Logic[config.worldState];
const map = {};
for (const name in logic) {
- map[name] = logic[name](config, dungeons, state);
+ try {
+ map[name] = logic[name](config, dungeons, state);
+ } catch (e) {
+ console.error('error evaluating', name, e);
+ }
}
return map;
};
export const countRemainingLocations = (state, locations) =>
locations.reduce((acc, cur) => state[cur] ? acc : acc + 1, 0);
-export const getGanonCrystals = (state) => state['ganon-crystals'];
+export const getGanonCrystals = (config) => getConfigValue(config, 'ganon-crystals', 7);
-export const getGTCrystals = (state) => state['gt-crystals'];
+export const getGTCrystals = (config) => getConfigValue(config, 'gt-crystals', 7);
export const getGTBoss = (state, which) => state[`gt-${which}-boss`];
!dungeon.boss || !!state[`${dungeon.id}-boss-defeated`];
export const getDungeonBoss = (state, dungeon) =>
- state[`${dungeon.id}-boss`] || dungeon.boss || null;
+ dungeon.bosses.length > 1
+ ? state[`${dungeon.id}-boss`] || dungeon.boss || null
+ : dungeon.bosses[0];
export const hasDungeonPrize = (state, dungeon) =>
!dungeon.prize || !!state[`${dungeon.id}-prize-acquired`];
});
state['mm-medallion'] = null;
state['tr-medallion'] = null;
- state['gt-crystals'] = 7;
- state['ganon-crystals'] = 7;
return state;
};
if (manualState[`${dungeon.id}-map`]) {
next[`${dungeon.id}-map`] = true;
}
+ if (manualState[`${dungeon.id}-boss`]) {
+ next[`${dungeon.id}-boss`] = manualState[`${dungeon.id}-boss`];
+ }
if (manualState[`${dungeon.id}-boss-defeated`]) {
next[`${dungeon.id}-boss-defeated`] = true;
}