All files / systems/bodypart InjuryIntegration.ts

0% Statements 0/3
100% Branches 0/0
0% Functions 0/3
0% Lines 0/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 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67                                                                                                                                     
/**
 * Injury Integration Utilities
 * 
 * **Korean**: 부상 통합 유틸리티
 * 
 * Utilities to convert between InjuryTracker format and TraumaOverlay3D format,
 * enabling seamless integration of injury tracking with visual trauma display.
 * 
 * @module systems/bodypart/InjuryIntegration
 * @category Body Part System
 * @korean 부상통합
 */
 
import { InjuryLocation } from "./InjuryTracker";
import { Injury } from "../../types/injury";
 
/**
 * Convert InjuryLocation to TraumaOverlay3D Injury format.
 * 
 * **Korean**: InjuryLocation을 TraumaOverlay3D Injury 형식으로 변환
 * 
 * @param injuryLocation - Injury from InjuryTracker
 * @param playerId - Optional player ID for multi-player scenarios
 * @returns Injury in TraumaOverlay3D format
 * 
 * @public
 */
export function convertInjuryForVisualization(
  injuryLocation: InjuryLocation,
  playerId?: string | number
): Injury {
  return {
    id: injuryLocation.id,
    region: injuryLocation.bodyRegion,
    type: injuryLocation.type,
    position: [
      injuryLocation.position.x,
      injuryLocation.position.y,
      injuryLocation.position.z,
    ],
    severity: injuryLocation.severity / 100, // Convert 0-100 to 0-1
    hitCount: injuryLocation.hitCount,
    timestamp: injuryLocation.timestamp,
    playerId,
  };
}
 
/**
 * Convert array of InjuryLocations to TraumaOverlay3D Injuries.
 * 
 * **Korean**: InjuryLocation 배열을 TraumaOverlay3D Injuries로 변환
 * 
 * @param injuryLocations - Array of injuries from InjuryTracker
 * @param playerId - Optional player ID
 * @returns Array of injuries in TraumaOverlay3D format
 * 
 * @public
 */
export function convertInjuriesForVisualization(
  injuryLocations: InjuryLocation[],
  playerId?: string | number
): Injury[] {
  return injuryLocations.map((loc) =>
    convertInjuryForVisualization(loc, playerId)
  );
}