import { Box, Flex, IconButton, Popover, PopoverContent, PopoverTrigger, Progress, useColorMode, } from "@chakra-ui/react"; import { Ability } from "@prisma/client"; import { ViewSlotsAbilities } from "components/builds/ViewSlots"; import AbilityIcon from "components/common/AbilityIcon"; import { useMyTheme } from "hooks/common"; import { Explanation } from "hooks/useAbilityEffects"; import { useState } from "react"; import { FaChartLine, FaQuestion } from "react-icons/fa"; import { isMainAbility } from "utils/lists/abilities"; import StatChart from "./StatChart"; interface BuildStatsProps { explanations: Explanation[]; otherExplanations?: Explanation[]; build: ViewSlotsAbilities; hideExtra?: boolean; showNotActualProgress?: boolean; startChartsAtZero?: boolean; } const BuildStats: React.FC = ({ explanations, otherExplanations, build, hideExtra = true, showNotActualProgress = false, startChartsAtZero = true, }) => { const [expandedCharts, setExpandedCharts] = useState>(new Set()); const abilityArrays: (Ability | "UNKNOWN")[][] = [ build.headAbilities ?? [], build.clothingAbilities ?? [], build.shoesAbilities ?? [], ]; const abilityToPoints: Partial> = {}; abilityArrays.forEach((arr) => arr.forEach((ability, index) => { if (ability !== "UNKNOWN") { let abilityPoints = index === 0 ? 10 : 3; if (isMainAbility(ability)) abilityPoints = 999; abilityToPoints[ability] = abilityToPoints.hasOwnProperty(ability) ? (abilityToPoints[ability] as any) + abilityPoints : abilityPoints; } }) ); const BuildStat: React.FC<{ title: string; effect: string; otherEffect?: string; ability: Ability; info?: string; progressBarValue: number; otherProgressBarValue?: number; getEffect?: (ap: number) => number; ap: number; otherAp?: number; chartExpanded: boolean; toggleChart: () => void; }> = ({ title, effect, ability, otherEffect, otherProgressBarValue, getEffect, info, ap, otherAp, chartExpanded, toggleChart, progressBarValue = 0, }) => { const { themeColorShade, secondaryBgColor } = useMyTheme(); const { colorMode } = useColorMode(); return ( <> } onClick={() => toggleChart()} isRound variant="ghost" /> {title} {info && ( {info} )} {effect} {otherEffect && ( <> {otherEffect} )} {getEffect && chartExpanded && ( )} ); }; return ( <> {explanations.map((_explanation, index) => { const explanation = explanations[index]; const otherExplanation = otherExplanations ? otherExplanations[index] : undefined; if ( explanation.effectFromMax === 0 && (!otherExplanation || otherExplanation.effectFromMax === 0) && hideExtra ) { return null; } return ( { const newSet = new Set(expandedCharts); if (newSet.has(explanation.title)) { newSet.delete(explanation.title); } else { newSet.add(explanation.title); } setExpandedCharts(newSet); }} /> ); })} ); }; export default BuildStats;