import { useState } from 'react'
import { useAllocator, usePointRandomizer, useLeftPoints } from '@remake/hooks'
import { usePicked, useReplaced, useStart, useIsClassic } from '@remake/hooks'
import type { AdditionalPoint } from '@remake/hooks'
import { properties } from '@/display'
import { keys } from '@remake/vitex'
import { judgeGradeByValue } from '@/config'
import { talents } from '@remake/data'
import Replaced from '@/components/Replaced'
import './Alloc.css'
interface AllocInputProps {
point: number
onChange: (point: number) => void
}
function AllocInput(props: AllocInputProps) {
return (
props.onChange(Number(e.target.value))}
/>
)
}
interface PointsDetailProps {
base: number
source: AdditionalPoint[]
fixed?: boolean
}
function PointsDetail({ base, source, fixed }: PointsDetailProps) {
return (
-
{fixed ? '固定' : '基础'}
{base}
{source.map(({ talent, points }) => (
-
{talents.get(talent)?.name ?? talent}
{points}
))}
)
}
export function Alloc() {
const isClassic = useIsClassic()
const picked = usePicked()
const {
talents: { chains },
additionalPoints: { source },
} = useReplaced()
const { base, left } = useLeftPoints()
const [{ alloc, final, base: ba }, allocator] = useAllocator()
const random = usePointRandomizer()
const start = useStart()
const [showDetail, setShowDetail] = useState(false)
const handleNext = () => {
if (left != 0) {
// TODO: Show a warning that there are still points left
return
}
const achievements = start()
// TODO: Show achievements
console.log('Achievements', achievements)
}
return (
{Array.from(picked, id => (
-
))}
-
剩余点数
{showDetail && (
)}
{keys(alloc).map(key => (
-
{properties[key]}
{!isClassic && (
[{ba[key]}]
)}
{!isClassic && (
{final[key]}
)}
allocator(key, value)}
/>
))}
)
}
export default Alloc