All files / utils attackPresentation.ts

100% Statements 3/3
100% Branches 0/0
100% Functions 1/1
100% Lines 3/3

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12              30x 30x 30x    
import { getAnimationDurationOrFallback, TARGET_ANIMATION_FPS } from "../systems/animation";
 
/** Match the clip duration and active frame used by the game animation clock. */
export function getAttackPresentation(animationName: string): {
  readonly duration: number;
  readonly impactFrame: number;
} {
  const duration = getAnimationDurationOrFallback(animationName);
  const frames = Math.max(1, Math.round(duration * TARGET_ANIMATION_FPS));
  return { duration, impactFrame: Math.round(frames * 0.4) };
}