import React from 'react';
-import CountDisplay from './CountDisplay';
import ToggleIcon from './ToggleIcon';
+import { BOTTLE_CONTENTS } from '../../helpers/tracker';
import { useTracker } from '../../hooks/tracker';
const Items = () => {
<ToggleIcon controller={ToggleIcon.simpleController} icons={['book']} />
</div>
<div className="item">
- <ToggleIcon controller={ToggleIcon.countController(4)} icons={['bottle']} />
- <CountDisplay className="bottom-right" count={state.bottle || 0} />
+ <ToggleIcon
+ className="top-left"
+ controller={ToggleIcon.bottleController('bottle-1')}
+ icons={BOTTLE_CONTENTS}
+ />
+ <ToggleIcon
+ className="top-right"
+ controller={ToggleIcon.bottleController('bottle-2')}
+ icons={BOTTLE_CONTENTS}
+ />
+ <ToggleIcon
+ className="bottom-left"
+ controller={ToggleIcon.bottleController('bottle-3')}
+ icons={BOTTLE_CONTENTS}
+ />
+ <ToggleIcon
+ className="bottom-right"
+ controller={ToggleIcon.bottleController('bottle-4')}
+ icons={BOTTLE_CONTENTS}
+ />
</div>
<div className="item">
<ToggleIcon controller={ToggleIcon.simpleController} icons={['somaria']} />
setState(s => ({ ...s, [property]: previous }));
};
+ToggleIcon.bottleController = ctrl => ({
+ getActive: (state, icons) => state[ctrl] ? icons[state[ctrl] - 1] : null,
+ getDefault: () => 'bottle',
+ handlePrimary: (state, setState, icons) => {
+ if (state[ctrl] === 0) {
+ // skip over mushroom
+ setState(s => ({ ...s, [ctrl]: 2 }));
+ } else {
+ setState(increment(ctrl, icons.length));
+ }
+ },
+ handleSecondary: (state, setState, icons) => {
+ if (state[ctrl] === 2) {
+ // skip over mushroom
+ setState(s => ({ ...s, [ctrl]: 0 }));
+ } else {
+ setState(decrement(ctrl, icons.length));
+ }
+ },
+});
+
ToggleIcon.countController = max => ({
getActive: highestActive,
getDefault: firstIcon,
// Equipment
+const countBottles = (config, dungeons, state) =>
+ ['bottle-1', 'bottle-2', 'bottle-3', 'bottle-4'].filter(b => !!state[b]).length;
+
const hasBig = dungeon => (config, dungeons, state) =>
!config.wildBig || !!state[`${dungeon}-big-key`];
const hasBoots = (config, dungeons, state) => !!state['boots'];
-const hasBottle = n => (config, dungeons, state) => state['bottle'] >= (n || 1);
+const hasBottle = n => (...args) => countBottles(...args) >= (n || 1);
const hasBow = (config, dungeons, state) => !!state['bow'];
];
export const INTEGER_STATES = [
- 'bottle',
+ 'bottle-1',
+ 'bottle-2',
+ 'bottle-3',
+ 'bottle-4',
'heart-piece',
'lift',
'mail',
mail: 1,
};
+export const BOTTLE_CONTENTS = [
+ 'mushroom',
+ 'bottle',
+ 'red-potion',
+ 'green-potion',
+ 'blue-potion',
+ 'fairy',
+ 'bottle-bee',
+ 'bottle-bee',
+];
+
export const BOSSES = [
'armos',
'lanmolas',
state.duck = !!(data[INV_ADDR.RANDO_FLUTE] & 0x01);
state.bugnet = !!data[INV_ADDR.BUGNET];
state.book = !!data[INV_ADDR.BOOK];
- state.bottle = 0;
- if (data[INV_ADDR.BOTTLE_1]) {
- ++state.bottle;
- }
- if (data[INV_ADDR.BOTTLE_2]) {
- ++state.bottle;
- }
- if (data[INV_ADDR.BOTTLE_3]) {
- ++state.bottle;
- }
- if (data[INV_ADDR.BOTTLE_4]) {
- ++state.bottle;
- }
+ state['bottle-1'] = data[INV_ADDR.BOTTLE_1];
+ state['bottle-2'] = data[INV_ADDR.BOTTLE_2];
+ state['bottle-3'] = data[INV_ADDR.BOTTLE_3];
+ state['bottle-4'] = data[INV_ADDR.BOTTLE_4];
state.somaria = !!data[INV_ADDR.SOMARIA];
state.byrna = !!data[INV_ADDR.BYRNA];
state.cape = !!data[INV_ADDR.CAPE];
next[loc.id] = true;
}
});
+ // prefer auto
+ next['bottle-1'] = autoState['bottle-1'] || manualState['bottle-1'] || 0;
+ next['bottle-2'] = autoState['bottle-2'] || manualState['bottle-2'] || 0;
+ next['bottle-3'] = autoState['bottle-3'] || manualState['bottle-3'] || 0;
+ next['bottle-4'] = autoState['bottle-4'] || manualState['bottle-4'] || 0;
+ // force manual
next['mm-medallion'] = manualState['mm-medallion'];
next['tr-medallion'] = manualState['tr-medallion'];
next['gt-crystals'] = manualState['gt-crystals'];