All files / components/screens/combat/components/hud CombatRightHUD.tsx

100% Statements 3/3
100% Branches 2/2
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 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 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173                                                                                                                          2x                     70x               70x                                                                                                                                                                                        
/**
 * CombatRightHUD - Right side HUD for combat screen (Player 2 / AI)
 *
 * REUSES existing components:
 * - PlayerHUD: Archetype image, name, health/stamina bars
 * - SpeedIndicatorHUD: Movement speed percentage
 * - BodyPartHealthDisplay: Individual body part health bars
 * - DifficultyIndicator: AI difficulty tier display
 *
 * Gaming Layout Best Practice:
 * - Width: Resolution-based 14-18% of screen
 * - Height: 100% minus top/bottom HUD heights
 * - Leaves remaining center region for arena (width varies by resolution)
 *
 * Now uses shared HUD utilities with resolution-based sizing.
 *
 * @korean 전투화면 오른쪽 HUD - 플레이어 2/AI 상태
 */
 
import React from "react";
import { useHUDLayout } from "../../../../../hooks/useHUDLayout";
import { PlayerState } from "../../../../../systems";
import type { StanceLaterality } from "../../../../../systems/trigram/types";
import { BaseHUDContainer } from "../../../../shared/ui/BaseHUDContainer";
import { BodyPartHealthDisplay } from "../../../../shared/three/ui/BodyPartHealthDisplay";
import { PlayerHUD } from "../../../../shared/three/ui/PlayerHUD";
import { SpeedIndicatorHUD } from "../../../../shared/three/ui/SpeedIndicatorHUD";
import { BreathingIndicator } from "../../../../shared/three/ui/BreathingIndicator";
import { DifficultyIndicator } from "./DifficultyIndicator";
 
export interface CombatRightHUDProps {
  /** Screen width for layout calculations */
  readonly width: number;
  /** Screen height for layout calculations */
  readonly height: number;
  /** Whether mobile layout is active */
  readonly isMobile: boolean;
  /** Position scale multiplier for large displays */
  readonly positionScale: number;
  /** Player 2/AI state */
  readonly player: PlayerState;
  /** Player laterality (left/right foot forward) */
  readonly laterality: StanceLaterality;
  /** Current AI difficulty tier (1-5) */
  readonly difficultyTier: number;
  /** Player speed modifiers */
  readonly speedModifiers: {
    finalSpeed: number;
    baseSpeed: number;
  };
}
 
/**
 * CombatRightHUD Component
 *
 * Right side of the combat screen containing Player 2/AI stats.
 * Occupies approximately 14–18% of screen width based on resolution breakpoints/interpolation,
 * positioned between top and bottom HUDs.
 * REUSES existing PlayerHUD, SpeedIndicatorHUD, BodyPartHealthDisplay, DifficultyIndicator.
 * Uses shared HUD utilities for consistent, resolution-based layout and styling.
 */
export const CombatRightHUD: React.FC<CombatRightHUDProps> = ({
  width,
  height,
  isMobile,
  positionScale,
  player,
  laterality,
  difficultyTier,
  speedModifiers,
}) => {
  // Use shared HUD layout hook
  const layout = useHUDLayout(
    width,
    height,
    positionScale,
    'right',
    'combat'
  );
 
  return (
    <BaseHUDContainer
      position="right"
      width={layout.hudWidth}
      height={layout.availableHeight}
      topOffset={layout.topOffset}
      padding={layout.padding}
      gap={layout.gap}
      style={{ overflow: "hidden" }}
      dataTestId="combat-right-hud"
    >
      {/* Player 2/AI Stats - REUSING PlayerHUD component */}
      <div
        style={{
          pointerEvents: "none",
          position: "relative",
        }}
        data-testid="combat-right-hud-player-section"
      >
        <PlayerHUD
          player={player}
          position="right"
          isMobile={isMobile}
          laterality={laterality}
        />
      </div>
 
      {/* Difficulty Tier - REUSING DifficultyIndicator component */}
      <div
        style={{
          pointerEvents: "none",
          position: "relative",
        }}
        data-testid="combat-right-hud-difficulty-section"
      >
        <DifficultyIndicator tier={difficultyTier} isMobile={isMobile} />
      </div>
 
      {/* Speed Indicator - REUSING SpeedIndicatorHUD component */}
      <div
        style={{
          pointerEvents: "none",
          position: "relative",
        }}
        data-testid="combat-right-hud-speed-section"
      >
        <SpeedIndicatorHUD
          finalSpeed={speedModifiers.finalSpeed}
          baseSpeed={speedModifiers.baseSpeed}
          position="right"
          isMobile={isMobile}
          visible={true}
        />
      </div>
 
      {/* Body Part Health - REUSING BodyPartHealthDisplay component */}
      {player.bodyPartHealth && (
        <div
          style={{
            pointerEvents: "none",
            position: "relative",
            marginTop: "auto",
          }}
          data-testid="combat-right-hud-bodypart-section"
        >
          <BodyPartHealthDisplay
            bodyPartHealth={player.bodyPartHealth}
            playerId={player.id}
            position="right"
            isMobile={isMobile}
          />
        </div>
      )}
 
      {/* Breathing Disruption Indicator - Shows breathing difficulty status */}
      <div
        style={{
          pointerEvents: "none",
          position: "relative",
        }}
        data-testid="combat-right-hud-breathing-section"
      >
        <BreathingIndicator
          player={player}
          isMobile={isMobile}
        />
      </div>
    </BaseHUDContainer>
  );
};
 
export default CombatRightHUD;