All files / components/screens/combat/components/controls ControlsGuide.tsx

83.33% Statements 10/12
100% Branches 36/36
83.33% Functions 5/6
83.33% Lines 10/12

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 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229                                                    4x                         4x       23x   23x                                                                                       161x                                                                                                                                                                                                   1x 1x   2x                                 2x       2x                                  
/**
 * ControlsGuide Component - In-game controls reference
 * 
 * Features:
 * - Complete combat controls listing
 * - Korean/English bilingual labels
 * - Cyberpunk Korean theming
 * - Organized by action type
 */
 
import React from "react";
import { useAudio } from "../../../../../audio/AudioProvider";
import { KOREAN_COLORS, FONT_FAMILY } from "../../../../../types/constants";
import { hexToRgbaString } from "../../../../../utils/colorUtils";
 
export interface ControlsGuideProps {
  readonly onClose: () => void;
  readonly isMobile: boolean;
}
 
interface ControlMapping {
  readonly key: string;
  readonly actionKorean: string;
  readonly actionEnglish: string;
}
 
const CONTROL_MAPPINGS: ControlMapping[] = [
  { key: "WASD / ←↑↓→", actionKorean: "이동", actionEnglish: "Movement" },
  { key: "1-8", actionKorean: "팔괘 자세", actionEnglish: "Trigram Stances" },
  { key: "Space", actionKorean: "공격", actionEnglish: "Attack" },
  { key: "Shift", actionKorean: "방어", actionEnglish: "Defend" },
  { key: "Tab", actionKorean: "원형 전환", actionEnglish: "Switch Archetype" },
  { key: "ESC", actionKorean: "일시정지", actionEnglish: "Pause" },
  { key: "M", actionKorean: "음소거", actionEnglish: "Mute" },
];
 
/**
 * ControlsGuide - In-game controls reference overlay
 */
export const ControlsGuide: React.FC<ControlsGuideProps> = ({
  onClose,
  isMobile,
}) => {
  const audio = useAudio();
 
  return (
    <div
      data-testid="controls-guide"
      style={{
        position: "absolute",
        top: "50%",
        left: "50%",
        transform: "translate(-50%, -50%)",
        padding: isMobile ? "24px" : "32px",
        backgroundColor: hexToRgbaString(KOREAN_COLORS.UI_BACKGROUND_DARK, 0.95),
        border: `2px solid ${hexToRgbaString(KOREAN_COLORS.PRIMARY_CYAN, 0.8)}`,
        borderRadius: "12px",
        minWidth: isMobile ? "280px" : "400px",
        maxHeight: isMobile ? "70vh" : "80vh",
        overflow: "auto",
        boxShadow: `0 0 30px ${hexToRgbaString(KOREAN_COLORS.PRIMARY_CYAN, 0.3)}`,
        zIndex: 1000,
      }}
    >
      {/* Title */}
      <h2
        data-testid="controls-title"
        style={{
          fontSize: isMobile ? "20px" : "24px",
          color: hexToRgbaString(KOREAN_COLORS.ACCENT_GOLD, 1),
          fontFamily: FONT_FAMILY.KOREAN,
          fontWeight: "bold",
          margin: "0 0 24px 0",
          textAlign: "center",
          textShadow: `0 0 10px ${hexToRgbaString(KOREAN_COLORS.ACCENT_GOLD, 0.4)}`,
        }}
      >
        조작법 | Controls
      </h2>
 
      {/* Controls List */}
      <div
        style={{
          display: "flex",
          flexDirection: "column",
          gap: isMobile ? "12px" : "16px",
        }}
      >
        {CONTROL_MAPPINGS.map((control, index) => (
          <div
            key={index}
            data-testid={`control-item-${index}`}
            style={{
              display: "flex",
              alignItems: "center",
              justifyContent: "space-between",
              padding: isMobile ? "10px" : "12px",
              backgroundColor: hexToRgbaString(KOREAN_COLORS.UI_BACKGROUND_MEDIUM, 0.5),
              border: `1px solid ${hexToRgbaString(KOREAN_COLORS.PRIMARY_CYAN, 0.3)}`,
              borderRadius: "6px",
            }}
          >
            <div
              style={{
                flex: 1,
                fontSize: isMobile ? "12px" : "14px",
                color: hexToRgbaString(KOREAN_COLORS.PRIMARY_CYAN, 1),
                fontFamily: FONT_FAMILY.KOREAN,
                fontWeight: "bold",
              }}
            >
              {control.actionKorean}
              <br />
              <span
                style={{
                  fontSize: isMobile ? "11px" : "13px",
                  color: hexToRgbaString(KOREAN_COLORS.TEXT_SECONDARY, 1),
                  fontWeight: "normal",
                }}
              >
                {control.actionEnglish}
              </span>
            </div>
            <div
              style={{
                padding: isMobile ? "6px 12px" : "8px 16px",
                fontSize: isMobile ? "12px" : "14px",
                color: hexToRgbaString(KOREAN_COLORS.UI_BACKGROUND_DARK, 1),
                backgroundColor: hexToRgbaString(KOREAN_COLORS.ACCENT_GOLD, 1),
                fontFamily: FONT_FAMILY.MONO,
                fontWeight: "bold",
                borderRadius: "4px",
                textAlign: "center",
                minWidth: isMobile ? "80px" : "100px",
              }}
            >
              {control.key}
            </div>
          </div>
        ))}
      </div>
 
      {/* Additional Tips */}
      <div
        data-testid="controls-tips"
        style={{
          marginTop: isMobile ? "20px" : "24px",
          padding: isMobile ? "12px" : "16px",
          backgroundColor: hexToRgbaString(KOREAN_COLORS.UI_BACKGROUND_MEDIUM, 0.3),
          border: `1px solid ${hexToRgbaString(KOREAN_COLORS.ACCENT_GOLD, 0.3)}`,
          borderRadius: "6px",
        }}
      >
        <h3
          style={{
            fontSize: isMobile ? "14px" : "16px",
            color: hexToRgbaString(KOREAN_COLORS.ACCENT_GOLD, 1),
            fontFamily: FONT_FAMILY.KOREAN,
            fontWeight: "bold",
            margin: "0 0 8px 0",
          }}
        >
          💡 팁 | Tips
        </h3>
        <p
          style={{
            fontSize: isMobile ? "12px" : "14px",
            color: hexToRgbaString(KOREAN_COLORS.TEXT_SECONDARY, 1),
            fontFamily: FONT_FAMILY.KOREAN,
            margin: 0,
            lineHeight: "1.6",
          }}
        >
          • 각 팔괘 자세는 고유한 기술과 장점이 있습니다
          <br />
          • Each trigram stance has unique techniques and advantages
          <br />
          <br />
          • 적절한 타이밍에 방어하면 반격 기회를 얻습니다
          <br />
          • Perfect timing on defense creates counter opportunities
        </p>
      </div>
 
      {/* Close Button */}
      <button
        onClick={() => {
          audio.playSFX("menu_back");
          onClose();
        }}
        onMouseEnter={() => audio.playSFX("menu_hover")}
        data-testid="controls-close-button"
        style={{
          marginTop: isMobile ? "20px" : "24px",
          width: "100%",
          padding: isMobile ? "10px" : "12px",
          fontSize: isMobile ? "14px" : "16px",
          backgroundColor: hexToRgbaString(KOREAN_COLORS.PRIMARY_CYAN, 1),
          color: hexToRgbaString(KOREAN_COLORS.UI_BACKGROUND_DARK, 1),
          border: "none",
          borderRadius: "6px",
          fontFamily: FONT_FAMILY.KOREAN,
          fontWeight: "bold",
          cursor: "pointer",
          transition: "all 0.2s ease",
        }}
        onMouseOver={(e) => {
          e.currentTarget.style.backgroundColor = hexToRgbaString(
            KOREAN_COLORS.ACCENT_GOLD,
            1
          );
          e.currentTarget.style.transform = "scale(1.05)";
        }}
        onMouseOut={(e) => {
          e.currentTarget.style.backgroundColor = hexToRgbaString(
            KOREAN_COLORS.PRIMARY_CYAN,
            1
          );
          e.currentTarget.style.transform = "scale(1)";
        }}
      >
        닫기 | Close
      </button>
    </div>
  );
};
 
export default ControlsGuide;