import type { CombatLogEntry } from '../game' export type BasicFloatingCombatText = { id: number memberId: string value: number } export const DEFAULT_COMBAT_LOG_LIMIT = 60 export const STADIUM_COMBAT_LOG_LIMIT = 70 export const DEFAULT_FLOATING_TEXT_LIMIT = 48 export function appendCombatLog( current: CombatLogEntry[], entry: CombatLogEntry, limit = DEFAULT_COMBAT_LOG_LIMIT, ) { return [entry, ...current].slice(0, limit) } export function appendFloatingText( current: T[], entry: T, limit = DEFAULT_FLOATING_TEXT_LIMIT, ) { return [...current, entry].slice(-limit) } export function groupFloatingTextsByMember(texts: T[]) { const groups = new Map() texts.forEach((entry) => { const current = groups.get(entry.memberId) if (current) current.push(entry) else groups.set(entry.memberId, [entry]) }) return groups } export function stripFloatingTextSide(texts: T[]): BasicFloatingCombatText[] { return texts.map(({ id, memberId, value }) => ({ id, memberId, value })) }