Refactor code structure for improved readability and maintainability
Gitea Auto Deploy / Deploy-Container (push) Successful in 41s

This commit is contained in:
2026-10-02 23:32:50 +07:00
parent 786ccf7cce
commit e9af27e724
23 changed files with 8040 additions and 142 deletions
+13 -2
View File
@@ -1,19 +1,30 @@
import useBattleDataStore from "@/stores/battleDataStore";
import { useShallow } from "zustand/react/shallow";
import { useMemo } from "react";
export function useDamageLinesForAll(mode: 1 | 2 = 1) {
const { turnHistory, skillHistory } = useBattleDataStore.getState();
const { turnHistory, skillHistory } = useBattleDataStore(
useShallow(state => ({
turnHistory: state.turnHistory,
skillHistory: state.skillHistory,
}))
);
return useMemo(() => {
const avatarMap = new Map<number, Map<number, number>>();
for (const skill of skillHistory) {
if (!skill.avatarId || skill.avatarId <= 0) continue;
if (!avatarMap.has(skill.avatarId)) {
avatarMap.set(skill.avatarId, new Map());
}
const turn = turnHistory[skill.turnBattleId];
if (!turn) continue;
const charMap = avatarMap.get(skill.avatarId)!;
const actionValue = turnHistory[skill.turnBattleId].actionValue
const actionValue = turn.actionValue;
const prev = charMap.get(actionValue) || 0;
charMap.set(actionValue, prev + skill.totalDamage);
}