case 'dungeon-tr':
case 'dungeon-tt':
return `/dungeon/${name.substr(8)}.png`;
+ case 'crystal-switch':
+ case 'crystal-switch-blue':
+ case 'crystal-switch-red':
+ return `/icon/${name}.png`;
default:
return '';
}
'flippers': 'item',
};
+const nextCSwitch = cur => {
+ switch (cur) {
+ case 'blue':
+ return 'red';
+ case 'red':
+ return '';
+ default:
+ return 'blue';
+ }
+};
+
+const prevCSwitch = cur => nextCSwitch(nextCSwitch(cur));
+
const DoorsTracker = () => {
const [state, setState] = React.useState(DUNGEONS.reduce((state, dungeon) => ({
...state,
[item]: false,
}), {
boss: true,
+ cswitch: '',
keys: 1,
}),
}), {}));
e.stopPropagation();
});
+ const handleCSwitchClick = React.useCallback(dungeon => e => {
+ setState(state => ({
+ ...state,
+ [dungeon]: {
+ ...state[dungeon],
+ cswitch: nextCSwitch(state[dungeon].cswitch),
+ },
+ }));
+ e.preventDefault();
+ e.stopPropagation();
+ });
+
+ const handleCSwitchRightClick = React.useCallback(dungeon => e => {
+ setState(state => ({
+ ...state,
+ [dungeon]: {
+ ...state[dungeon],
+ cswitch: prevCSwitch(state[dungeon].cswitch),
+ },
+ }));
+ e.preventDefault();
+ e.stopPropagation();
+ });
+
const handleKeysClick = React.useCallback(dungeon => e => {
setState(state => ({
...state,
>
{state[dungeon].keys}
</div>
+ <div
+ className={`cell ${state[dungeon].cswitch ? 'on' : 'off'} cswitch`}
+ onClick={handleCSwitchClick(dungeon)}
+ onContextMenu={handleCSwitchRightClick(dungeon)}
+ >
+ <ZeldaIcon name={state[dungeon].cswitch
+ ? `crystal-switch-${state[dungeon].cswitch}`
+ : 'crystal-switch'
+ } />
+ </div>
{ITEMS.map(item =>
<div
className={