import { getImageURL, getLocalImageURL } from '@/utils/images' import type { ISkill } from '@/api/info/type' import { useVModel } from '@vueuse/core' import CalcButton from '@/components/calc/button/index.vue' import './style.scss' export default defineComponent({ name: 'SkillTree', props: { skills: { type: Array as PropType, default: () => [], }, lvInfo: { type: Object as PropType>, default: () => ({}), }, bindAwake: { type: Number, default: () => 50, }, }, setup(props) { const skills = computed(() => props.skills) const lvInfo = useVModel(props, 'lvInfo') const bindAwake = useVModel(props, 'bindAwake') const getSkill = (lvStart: number, lvEnd: number, position: number) => { if (position >= 0) return skills.value.find( (item) => item.line > lvStart - 5 && item.line <= Math.max(lvEnd - 5, 1) && item.position == position, ) else return skills.value.filter( (item) => item.line > lvStart - 5 && item.line <= Math.max(lvEnd - 5, 1), ) } const lvList = [15, 20, 25, 30, 35, 40, 45, 50, 60, 70, 80, 90, 100] const columns = [...new Array(11).keys()] const activeSkill = ref(-1) const chooseSkill = (skill?: ISkill, operation: string = 'add') => { if (!skill) { activeSkill.value = -1 return } if (activeSkill.value == skill.id) actionSkillLv(skill, operation) else activeSkill.value = skill.id } const awakeSkill_1 = computed(() => skills.value.find((item) => item.learnLv == 50 && item.type == 'active' && item.bind), ) const awakeSkill_2 = computed(() => skills.value.find((item) => item.learnLv == 85 && item.type == 'active' && item.bind), ) const actionSkillLv = (skill: ISkill, operation: string) => { if (operation == 'add') { lvInfo.value[skill.id.toString()].lv = Math.min(lvInfo.value[skill.id.toString()]?.lv + 1, skill.maxLv) return } if (operation == 'addMax') { lvInfo.value[skill.id.toString()].lv = skill.maxLearnLv return } if (operation == 'sub') { lvInfo.value[skill.id.toString()].lv = Math.max(lvInfo.value[skill.id.toString()]?.lv - 1, 0) return } if (operation == 'subMax') { lvInfo.value[skill.id.toString()] = { lv: 0 , vp: 0, up: 0 } return } } const chooseBindAwake = (lv: number) => { bindAwake.value = lv console.log(bindAwake.value, lv) } const renderSkill = (skill: ISkill, index: number) => { const info = lvInfo.value?.[skill.id.toString()] let color = 'white' if (info?.lv < skill.maxLearnLv) color = '#32E432' if (info?.lv > skill.maxLearnLv) color = '#58E0FC' return ( <>
{info?.vp > 0 && (
)} {info?.up > 0 && (
)}
{activeSkill.value == skill.id && renderSkillAction(skill)}
{ e.stopPropagation() chooseSkill(skill) }} onContextmenu={(e) => { e.stopPropagation() e.preventDefault() chooseSkill(skill, 'sub') }} key={index} > {skill.name}
{info?.lv ?? 0}
{skill.learnLv == 100 && skill.bind && ( <>
chooseBindAwake(50)} >
1次
chooseBindAwake(85)} >
2次
)}
) } const renderSkillAction = (skill: ISkill) => ( <> <>
{ e.stopPropagation() actionSkillLv(skill, 'subMax') }} > { e.stopPropagation() actionSkillLv(skill, 'sub') }} > { e.stopPropagation() actionSkillLv(skill, 'add') }} > = skill.maxLearnLv} onClick={(e: Event) => { e.stopPropagation() actionSkillLv(skill, 'addMax') }} > {/* { e.stopPropagation() actionSkillLv(skill, 'subMax') }} > { e.stopPropagation() actionSkillLv(skill, 'sub') }} > { e.stopPropagation() actionSkillLv(skill, 'add') }} > { e.stopPropagation() actionSkillLv(skill, 'addMax') }} > */}
) return () => ( <>
(activeSkill.value = -1)}> {((getSkill(0, 15, -1) ?? []) as ISkill[]).length > 0 && ( <>
其
余
{((getSkill(0, 15, -1) ?? []) as ISkill[])?.map((skill, index) => renderSkill(skill, index), )}
)} {lvList.map((lv, index) => ((getSkill(lv, lvList[index + 1] ?? 150, -1) as ISkill[])?.length ?? 0) > 0 ? (
{lv == 1 || lv % 10 == 0 ? (
{lv}
) : (
)} {columns.map((column, i) => { const skill = getSkill(lv, lvList[index + 1] ?? 150, column) as ISkill return skill ? renderSkill(skill, index) :
})}
(activeSkill.value = -1)}>
) : ( <> ), )}
) }, })