1 import React from 'react';
3 import ZeldaIcon from '../common/ZeldaIcon';
37 const ITEM_CLASSES = {
38 'compass': 'dungeon-item',
39 'map': 'dungeon-item',
40 'big-key': 'dungeon-item',
47 'fighter-sword': 'item',
53 const DoorsTracker = () => {
54 const [state, setState] = React.useState(DUNGEONS.reduce((state, dungeon) => ({
56 [dungeon]: ITEMS.reduce((items, item) => ({
65 const handleItemClick = React.useCallback((dungeon, item) => e => {
70 [item]: !state[dungeon][item],
77 const handleKeysClick = React.useCallback(dungeon => e => {
82 keys: state[dungeon].keys + 1,
89 const handleKeysRightClick = React.useCallback(dungeon => e => {
94 keys: Math.max(state[dungeon].keys - 1, 0),
101 return <div className="doors-tracker d-flex flex-column">
102 {DUNGEONS.map(dungeon =>
103 <div className="d-flex flex-row" key={dungeon}>
105 className={`cell ${state[dungeon].boss ? 'on' : 'off'} dungeon`}
106 onClick={handleItemClick(dungeon, 'boss')}
108 <ZeldaIcon name={`dungeon-${dungeon}`} />
111 className={`cell ${state[dungeon].keys ? 'on' : 'off'} keys`}
112 onClick={handleKeysClick(dungeon)}
113 onContextMenu={handleKeysRightClick(dungeon)}
115 {state[dungeon].keys}
120 `cell ${state[dungeon][item] ? 'on' : 'off'} ${ITEM_CLASSES[item]}`
123 onClick={handleItemClick(dungeon, item)}
125 <ZeldaIcon name={item} />
133 export default DoorsTracker;