diff --git a/TODO.md b/TODO.md index c3a1c8a..6dc1a34 100644 --- a/TODO.md +++ b/TODO.md @@ -6,8 +6,8 @@ - [ ] General: Responsive on mobile - [ ] Talent tree: Reset button per tree (?) - [ ] Fix: Initial load `pointString` validation (make sure all talents are valid and their deps are met) -- [ ] Fix: Arrow should start underneath the icon - [ ] Fix: Navigating between talent links for same class does not trigger re-render +- [x] Fix: Arrow should start underneath the icon - [x] Talent tree: Arrows for dependencies - [x] System: Generate URL for chosen talents - [x] Talent tree: Prettier talent frames diff --git a/src/App.scss b/src/App.scss index aed20bd..9c24140 100644 --- a/src/App.scss +++ b/src/App.scss @@ -52,58 +52,6 @@ a { } } -.trees { - display: flex; - justify-content: center; -} - -.tree { - position: relative; - min-width: 300px; - color: white; - margin-right: 1em; - background-color: #111; - - .talent { - position: absolute; - - // Rows - @for $i from 0 through 6 { - &[data-row="#{$i}"] { - top: $row-offset + (($i) * $row-distance); - } - } - - // Columns - @for $i from 0 through 3 { - &[data-col="#{$i}"] { - left: $col-offset + ($col-distance * $i); - } - } - } - - &:last-child { - margin-right: 0; - } - - &__header { - text-align: center; - - h3 { - margin-top: .75em; - margin-bottom: .75em; - } - } - - &__body { - position: relative; - height: 520px; - border: 1px solid black; - background-size: cover; - background-position: center; - } -} - .index { min-height: 85vh; } diff --git a/src/components/Calculator.tsx b/src/components/Calculator.tsx index 3a98ab8..008252c 100644 --- a/src/components/Calculator.tsx +++ b/src/components/Calculator.tsx @@ -19,14 +19,6 @@ interface Props { } const EMPTY_TALENTS = Map() - // .set(30, 5) - // .set(26, 5) - // .set(34, 5) - // .set(28, 2) - // .set(27, 3) - // .set(33, 1) - // .set(29, 1) - // .set(32, 1) export class Calculator extends React.PureComponent { static whyDidYouRender = true diff --git a/src/components/Talent.tsx b/src/components/Talent.tsx index 259b29e..a6d348a 100644 --- a/src/components/Talent.tsx +++ b/src/components/Talent.tsx @@ -63,4 +63,4 @@ export const Talent: FC = (props) => { Talent.defaultProps = defaultProps -// ;(Talent as any).whyDidYouRender = true \ No newline at end of file +;(Talent as any).whyDidYouRender = true \ No newline at end of file diff --git a/src/components/TalentTree.scss b/src/components/TalentTree.scss new file mode 100644 index 0000000..9db743c --- /dev/null +++ b/src/components/TalentTree.scss @@ -0,0 +1,53 @@ +@import "../sass/config"; + +.trees { + display: flex; + justify-content: center; +} + +.tree { + position: relative; + min-width: 300px; + color: white; + margin-right: 1em; + background-color: #111; + + .talent { + position: absolute; + + // Rows + @for $i from 0 through 6 { + &[data-row="#{$i}"] { + top: $row-offset + (($i) * $row-distance); + } + } + + // Columns + @for $i from 0 through 3 { + &[data-col="#{$i}"] { + left: $col-offset + ($col-distance * $i); + } + } + } + + &:last-child { + margin-right: 0; + } + + &__header { + text-align: center; + + h3 { + margin-top: .75em; + margin-bottom: .75em; + } + } + + &__body { + position: relative; + height: 520px; + border: 1px solid black; + background-size: cover; + background-position: center; + } +} \ No newline at end of file diff --git a/src/components/TalentTree.tsx b/src/components/TalentTree.tsx index 5fd75f7..c87a04a 100644 --- a/src/components/TalentTree.tsx +++ b/src/components/TalentTree.tsx @@ -1,7 +1,8 @@ +import './TalentTree.scss' import React, { useCallback } from 'react' import { Map } from 'immutable' import { Talent } from './Talent'; -import { getPointsInSpec, canLearnTalent, calcMeetsRequirements } from '../lib/tree'; +import { getPointsInSpec, canLearnTalent, calcMeetsRequirements, SORT_TALENTS_DESC } from '../lib/tree'; import { talentsBySpec, specNames, talentsById, talentToSpec } from '../data/talents' import { Arrow } from './Arrow' @@ -13,8 +14,7 @@ interface Props { } export const TalentTree: React.FC = ({ specId, knownTalents, availablePoints, onTalentPress }) => { - const talents = Object.values(talentsBySpec[specId]) - const bgImg = require(`../images/specs/${specId}.jpg`) + const talents = Object.values(talentsBySpec[specId]).sort(SORT_TALENTS_DESC) const handleClick = useCallback( (talentId) => onTalentPress(specId, talentId, 1), @@ -25,50 +25,40 @@ export const TalentTree: React.FC = ({ specId, knownTalents, availablePoi [specId, onTalentPress] ) - const arrows = talents - .filter((talent) => talent.requires.length) - .map((talent) => { - return 0 || canLearnTalent(knownTalents, talent)} - /> - }) - return (

{specNames[specId]} ({getPointsInSpec(specId, knownTalents)})

-
- {talents.map((talent) => - - )} +
+ {talents.map((talent) => { + const points = knownTalents.get(talent.id, 0) + const canLearn = canLearnTalent(knownTalents, talent) - {arrows} + return + + + {!!talent.requires.length && + 0 || canLearn} + /> + } + + })}
) } -// move this somewhere else/revise this -export const isAvailable = (talent: TalentData, knownTalents: Map): boolean => { - // Dependent on other talents? - if (!calcMeetsRequirements(talent, knownTalents)) { - return false - } - const specId = talentToSpec[talent.id] - const pointsInSpec = getPointsInSpec(specId, knownTalents) - return talent.row * 5 <= pointsInSpec -} - ;(TalentTree as any).whyDidYouRender = true \ No newline at end of file diff --git a/src/lib/tree.ts b/src/lib/tree.ts index 0786b8b..7818791 100644 --- a/src/lib/tree.ts +++ b/src/lib/tree.ts @@ -16,6 +16,13 @@ export const SORT_TALENTS = (a: TalentData, b: TalentData) => { return a.row - b.row } +export const SORT_TALENTS_DESC = (a: TalentData, b: TalentData) => { + if (a.row === b.row) { + return b.col - a.col + } + return b.row - a.row +} + export const SORT_TALENTS_BY_SPEC = (a: TalentData, b: TalentData) => { const aSpec = talentToSpec[a.id] const bSpec = talentToSpec[b.id]