update wave, cycle, damage type ...
This commit is contained in:
@@ -1,20 +1,21 @@
|
||||
import useBattleDataStore from "@/stores/battleDataStore";
|
||||
import { useMemo } from "react";
|
||||
|
||||
export function useDamageLinesForAll(mode: 0 | 1 = 0) {
|
||||
const { turnHistory } = useBattleDataStore.getState();
|
||||
export function useDamageLinesForAll(mode: 1 | 2 = 1) {
|
||||
const { turnHistory, skillHistory } = useBattleDataStore.getState();
|
||||
|
||||
return useMemo(() => {
|
||||
const avatarMap = new Map<number, Map<number, number>>();
|
||||
|
||||
for (const turn of turnHistory) {
|
||||
if (!avatarMap.has(turn.avatarId)) {
|
||||
avatarMap.set(turn.avatarId, new Map());
|
||||
for (const skill of skillHistory) {
|
||||
if (!avatarMap.has(skill.avatarId)) {
|
||||
avatarMap.set(skill.avatarId, new Map());
|
||||
}
|
||||
|
||||
const charMap = avatarMap.get(turn.avatarId)!;
|
||||
const prev = charMap.get(turn.actionValue) || 0;
|
||||
charMap.set(turn.actionValue, prev + turn.totalDamage);
|
||||
const charMap = avatarMap.get(skill.avatarId)!;
|
||||
const actionValue = turnHistory[skill.turnBattleId].actionValue
|
||||
const prev = charMap.get(actionValue) || 0;
|
||||
charMap.set(actionValue, prev + skill.totalDamage);
|
||||
}
|
||||
|
||||
const result: Record<number, { x: number; y: number }[]> = {};
|
||||
@@ -27,7 +28,7 @@ export function useDamageLinesForAll(mode: 0 | 1 = 0) {
|
||||
if (mode === 1) {
|
||||
let cumulative = 0;
|
||||
result[avatarId] = points.map(p => {
|
||||
cumulative += p.y;
|
||||
cumulative += Number(p.y);
|
||||
return { x: p.x, y: Number(cumulative.toFixed(2)) };
|
||||
});
|
||||
} else {
|
||||
@@ -39,5 +40,5 @@ export function useDamageLinesForAll(mode: 0 | 1 = 0) {
|
||||
}
|
||||
|
||||
return result;
|
||||
}, [turnHistory, mode]);
|
||||
}, [turnHistory, skillHistory, mode]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user