import './TalentTree.scss' import React, { useCallback } from 'react' import { Map } from 'immutable' import { Talent } from './Talent'; import { getPointsInSpec, canLearnTalent, SORT_TALENTS_DESC } from '../lib/tree'; import { talentsBySpec, specNames, talentsById } from '../data/talents' import { Arrow } from './Arrow' interface Props { specId: number availablePoints: number knownTalents: Map onTalentPress: TalentClickHandler } export const TalentTree: React.FC = ({ specId, knownTalents, availablePoints, onTalentPress }) => { const talents = Object.values(talentsBySpec[specId]).sort(SORT_TALENTS_DESC) const handleClick = useCallback( (talentId) => onTalentPress(specId, talentId, 1), [specId, onTalentPress] ) const handleRightClick = useCallback( (talentId) => onTalentPress(specId, talentId, -1), [specId, onTalentPress] ) return (

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

{talents.map((talent) => { const points = knownTalents.get(talent.id, 0) const canLearn = canLearnTalent(knownTalents, talent) return {!!talent.requires.length && 0 || canLearn} /> } })}
) } ;(TalentTree as any).whyDidYouRender = true