1 import PropTypes from 'prop-types';
2 import React from 'react';
4 import CountDisplay from './CountDisplay';
5 import ToggleIcon from './ToggleIcon';
9 getDungeonRemainingItems,
10 shouldShowDungeonItem,
11 } from '../../helpers/tracker';
12 import { useTracker } from '../../hooks/tracker';
14 const Dungeons = ({ columns }) => {
15 const { config, dungeons, state } = useTracker();
17 const layout = React.useMemo(() => {
19 const compassX = shouldShowDungeonItem(config, 'Map') ? mapX + 1 : mapX;
20 const smallX = shouldShowDungeonItem(config, 'Compass') ? compassX + 1 : compassX;
21 const bigX = shouldShowDungeonItem(config, 'Small') ? smallX + 1 : smallX;
22 const countX = shouldShowDungeonItem(config, 'Big') ? bigX + 1 : bigX;
23 const bossX = countX + 1;
24 const prizeX = bossX + 1;
25 const dungeonWidth = Math.max(5, prizeX + 1);
26 const width = (columns * dungeonWidth) + Math.max(0, columns - 1);
29 const transform = (col, row) =>
30 `scale(${1 / width}) translate(${
31 (col * dungeonWidth) + 0.5 + (col ? col - (columns > 3 ? 1 : 0) : 0)
36 map: `translate(${mapX} 0) scale(0.9)`,
37 compass: `translate(${compassX} 0) scale(0.9)`,
38 small: `translate(${smallX} 0) scale(0.9)`,
39 big: `translate(${bigX} 0) scale(0.9)`,
40 checks: `translate(${countX} 0) scale(0.9)`,
41 boss: `translate(${bossX} 0)`,
42 prize: `translate(${prizeX} 0)`,
46 gtBoss1: `translate(${bossX - 2} 1)`,
47 gtBoss2: `translate(${bossX - 1} 1)`,
48 gtBoss3: `translate(${bossX} 1)`,
52 transforms.ep = transform(0, 4);
53 transforms.dp = transform(0, 5);
54 transforms.th = transform(0, 6);
55 transforms.pd = transform(0, 8);
56 transforms.sp = transform(0, 9);
57 transforms.sw = transform(0, 10);
58 transforms.tt = transform(0, 11);
59 transforms.ip = transform(0, 12);
60 transforms.mm = transform(0, 13);
61 transforms.tr = transform(0, 14);
62 } else if (columns === 2) {
63 transforms.ep = transform(0, 4);
64 transforms.dp = transform(0, 5);
65 transforms.th = transform(0, 6);
66 transforms.pd = transform(1, 0);
67 transforms.sp = transform(1, 1);
68 transforms.sw = transform(1, 2);
69 transforms.tt = transform(1, 3);
70 transforms.ip = transform(1, 4);
71 transforms.mm = transform(1, 5);
72 transforms.tr = transform(1, 6);
74 transforms.ep = transform(1, 0);
75 transforms.dp = transform(1, 1);
76 transforms.th = transform(1, 2);
77 transforms.pd = transform(2, 0);
78 transforms.sp = transform(2, 1);
79 transforms.sw = transform(2, 2);
80 transforms.tt = transform(2, 3);
81 transforms.ip = transform(3, 0);
82 transforms.mm = transform(3, 1);
83 transforms.tr = transform(3, 2);
91 }, [config, dungeons]);
94 {dungeons.map(dungeon =>
96 className={`dungeon dungeon-${dungeon.id}`}
98 transform={layout.transforms[dungeon.id]}
100 <g transform={layout.transforms.tag}>
101 <text className="dungeon-tag">{dungeon.id.toUpperCase()}</text>
103 {shouldShowDungeonItem(config, 'Map') ?
105 controller={ToggleIcon.dungeonController(dungeon)}
108 transform={layout.transforms.map}
111 {shouldShowDungeonItem(config, 'Compass') ?
113 controller={ToggleIcon.dungeonController(dungeon)}
116 transform={layout.transforms.compass}
119 {shouldShowDungeonItem(config, 'Small') ?
120 <g transform={layout.transforms.small}>
122 controller={ToggleIcon.dungeonCountController(dungeon, dungeon.sk)}
123 icons={['small-key']}
127 count={getDungeonAcquiredSKs(state, dungeon)}
132 {shouldShowDungeonItem(config, 'Big') ?
134 controller={ToggleIcon.dungeonController(dungeon)}
137 transform={layout.transforms.big}
140 <g transform={layout.transforms.checks}>
142 controller={ToggleIcon.dungeonCheckController(dungeon)}
143 icons={['open-chest', 'chest']}
146 <CountDisplay count={getDungeonRemainingItems(state, dungeon)} />
150 controller={ToggleIcon.dungeonBossController(dungeon)}
151 icons={dungeon.bosses}
153 transform={layout.transforms.boss}
158 controller={ToggleIcon.dungeonPrizeController(dungeon)}
166 transform={layout.transforms.prize}
169 {dungeon.id === 'gt' && config.bossShuffle ? <>
171 controller={ToggleIcon.gtBossController('bot')}
174 transform={layout.transforms.gtBoss1}
177 controller={ToggleIcon.gtBossController('mid')}
180 transform={layout.transforms.gtBoss2}
183 controller={ToggleIcon.gtBossController('top')}
186 transform={layout.transforms.gtBoss3}
194 Dungeons.propTypes = {
195 columns: PropTypes.number,
198 Dungeons.defaultProps = {
202 export default Dungeons;