This commit is contained in:
2025-04-23 20:24:12 +07:00
parent f933b5aad5
commit ef52d632bd
63 changed files with 3911 additions and 138 deletions

View File

@@ -0,0 +1,25 @@
"use client";
import { useMemo } from "react";
import useBattleDataStore from "@/stores/battleDataStore";
export function useSkillDamageByAvatar(avatarId: number) {
const { turnHistory } = useBattleDataStore.getState();
return useMemo(() => {
const skillTypes = ['technique', 'talent', 'basic', 'skill', 'ultimate', 'servant'];
const dmgMap = new Map<string, number>();
skillTypes.forEach((type) => dmgMap.set(type, 0));
for (const turn of turnHistory) {
const type = turn.skillType.toLowerCase();
if (turn.avatarId === avatarId && dmgMap.has(type)) {
dmgMap.set(type, dmgMap.get(type)! + turn.totalDamage);
}
}
const labels = Array.from(dmgMap.keys());
const damageValues = Array.from(dmgMap.values());
return { labels, damageValues };
}, [avatarId, turnHistory]);
}