All files / systems/vitalpoint types.ts

0% Statements 0/0
0% Branches 0/0
0% Functions 0/0
0% Lines 0/0

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 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
/**
 * Type definitions for vitalpoint types
 * Auto-generated by type migration script
 */
 
// Vital point system imports from shared types
import type {
  DamageRange,
  KoreanText,
  PlayerArchetype,
  Position,
  TrigramStance,
  VitalPointCategory,
  VitalPointEffectType,
  VitalPointSeverity,
} from "../../types";
import type { PhysicalReachConfig } from "../../types/physics";
import { AnimationType } from "../animation";
import { EffectIntensity } from "../effects";
import { StatusEffect } from "../types";
 
// Minimal player shape for applying vital point effects without importing full PlayerState
export interface VitalPointEffectTarget {
  readonly statusEffects: readonly StatusEffect[];
  readonly vitalPoints: readonly {
    readonly id: string;
    readonly isHit: boolean;
    readonly damage: number;
    readonly lastHitTime: number;
  }[];
}
 
/**
 * Korean Technique - Core martial arts technique definition
 * 한국 무술 기술 정의
 *
 * @korean 한국무술기술
 */
export interface KoreanTechnique {
  /** Unique identifier for the technique */
  id: string;
 
  /** Bilingual name with romanization */
  name: {
    korean: string;
    english: string;
    romanized: string;
  };
 
  /** Korean name (한글) */
  koreanName: string;
  /** English name */
  englishName: string;
  /** Romanized Korean (로마자) */
  romanized: string;
 
  /** Technique description */
  description: {
    korean: string;
    english: string;
  };
 
  /** Required stance for execution (팔괘 자세) */
  stance: TrigramStance;
 
  /** Combat attack type (e.g., "strike", "kick", "throw") */
  type: string;
  /** Damage type (e.g., "blunt", "internal", "joint") */
  damageType: string;
 
  // Combat stats (전투 능력치)
  damage: number;
  kiCost: number;
  staminaCost: number;
  accuracy: number;
 
  /**
   * Physical reach configuration using body parts and attributes.
   * Replaces simple range value with complex calculation based on:
   * - Body part length (arm/leg from archetype physical attributes)
   * - Animation extension multiplier (from hit timing)
   * - Stance modifiers (Eight Trigrams bonuses)
   *
   * **Korean**: 물리적 도달 설정
   * @korean 물리적도달설정
   */
  reachConfig: PhysicalReachConfig;
 
  executionTime: number;
  recoveryTime: number;
  critChance: number;
  critMultiplier: number;
 
  /** Status effects applied on hit */
  effects: readonly StatusEffect[];
 
  /**
   * Animation category for this technique
   * Represents the TYPE/CATEGORY of animation (e.g., "punch", "kick", "throw")
   * Multiple techniques can share the same category.
   * 
   * 애니메이션 카테고리 (타입)
   * 
   * @example AnimationCategory.PUNCH, AnimationCategory.KICK
   * @korean 애니메이션카테고리
   */
  animationCategory?: string; // Will be AnimationCategory enum
  
  /**
   * Unique animation identifier for 1-1 mapping with technique
   * Should match the technique ID for direct animation lookup.
   * 
   * 고유 애니메이션 식별자 (1-1 매핑)
   * 
   * @example "geon_heavenly_fist", "son_rhythmic_strikes"
   * @korean 애니메이션ID
   */
  animationId?: string;
 
  /**
   * Legacy: Animation type field (being migrated to animationCategory + animationId)
   * @deprecated Use animationCategory and animationId instead
   * 스켈레탈 애니메이션에 직접 매핑하기 위한 애니메이션 타입
   *
   * @korean 애니메이션타입
   */
  animationType?: AnimationType;
 
  /**
   * Animation speed modifier (default: 1.0)
   * 애니메이션 속도 조절 (기본: 1.0)
   */
  animationSpeed?: number;
 
  /**
   * Technique category for gameplay balance
   * 기술 분류 (경량/중형/중량/특수)
   *
   * - light: Fast, low damage, low stamina cost
   * - medium: Balanced speed/damage/cost
   * - heavy: Slow, high damage, high stamina cost
   * - special: Unique effects, vital point targeting
   *
   * Note: Optional for backward compatibility, but required for all
   * trigram stance techniques. Tests validate presence and correctness.
   *
   * @korean 기술분류
   */
  category?: TechniqueBalanceCategory;
 
  /**
   * Effective range category
   * 유효 거리 분류
   *
   * - short: Close combat (0-1m)
   * - medium: Mid range (1-2m)
   * - long: Extended reach (2-3m)
   *
   * Note: Optional for backward compatibility, but required for all
   * trigram stance techniques. Tests validate presence and distribution.
   *
   * @korean 거리분류
   */
  range?: TechniqueRange;
 
  /**
   * Speed rating for technique execution
   * 기술 실행 속도 등급
   *
   * Higher values = faster execution
   * Typical range: 0.6 (slow) to 1.4 (very fast)
   *
   * Note: Optional for backward compatibility, but required for all
   * trigram stance techniques. Should align with animationSpeed.
   *
   * @korean 속도등급
   */
  speed?: number;
 
  // =====================================================
  // DEFENSIVE MECHANICS (GAN - MOUNTAIN)
  // =====================================================
 
  /**
   * Block timing window in milliseconds for blocking attacks
   * 막기 타이밍 창 (밀리초)
   *
   * Defines the time window during which a block can successfully
   * defend against an incoming attack. Used for Gan (Mountain) stance
   * immovable defense techniques.
   *
   * @korean 막기타이밍창
   * @example 250 // 250ms window for standard block
   */
  blockWindow?: number;
 
  /**
   * Perfect block timing window in milliseconds
   * 완벽한 막기 타이밍 창 (밀리초)
   *
   * A tighter window within the blockWindow for executing a perfect block,
   * which may trigger additional effects like stone particles or increased
   * damage reduction. For Gan (Mountain) stance defensive mastery.
   *
   * @korean 완벽막기타이밍창
   * @example 75 // 75ms window for perfect block
   */
  perfectBlockWindow?: number;
 
  /**
   * Damage reduction multiplier when blocking (0.0 to 1.0)
   * 막기 시 데미지 감소 배율
   *
   * Represents the percentage of damage absorbed when blocking.
   * 0.7 = 70% damage reduction (30% damage taken)
   * Higher values = better defense
   *
   * @korean 데미지감소배율
   * @example 0.7 // 70% damage reduction
   */
  damageReduction?: number;
 
  /**
   * Stability bonus multiplier for defensive fortitude
   * 안정성 보너스 배율
   *
   * Multiplier applied to stability/fortitude when in defensive stance.
   * Represents the mountain-like immovable nature of Gan techniques.
   * Higher values = more difficult to break through defense
   *
   * @korean 안정성보너스
   * @example 1.5 // 150% stability increase
   */
  stabilityBonus?: number;
 
  /**
   * Rooting effect flag for ground connection
   * 뿌리내림 효과 플래그
   *
   * When true, indicates the technique creates a rooted, grounded stance
   * with visible ground connection. For Gan (Mountain) immovable defense.
   *
   * @korean 뿌리내림효과
   * @example true // Technique creates rooting effect
   */
  rootingEffect?: boolean;
}
 
/**
 * Balance category for techniques (gameplay categorization)
 * 기술 밸런스 카테고리 타입
 *
 * Used for combat balance and AI selection logic. Not to be confused
 * with TechniqueCategory in AI module (which categorizes by martial arts type).
 *
 * @korean 기술밸런스분류타입
 */
export type TechniqueBalanceCategory = "light" | "medium" | "heavy" | "special";
 
/**
 * Technique range type (shared across systems)
 * 기술 거리 타입
 *
 * @korean 기술거리타입
 */
export type TechniqueRange = "short" | "medium" | "long";
 
/**
 * Stricter type for Trigram Stance Techniques
 * 팔괘 자세 기술 정의 타입
 *
 * Extends KoreanTechnique with required categorization fields for
 * all trigram stance techniques. Use this type for technique arrays
 * in stance files to enforce compile-time validation.
 *
 * This type is named TrigramStanceTechnique (not TrigramTechnique) to
 * avoid confusion with TrigramTechniqueSummary in trigram/types.ts.
 *
 * Example usage:
 * ```typescript
 * export const GEON_TECHNIQUES: readonly TrigramStanceTechnique[] = [...]
 * ```
 *
 * @korean 팔괘자세기술정의타입
 */
export type TrigramStanceTechnique = KoreanTechnique & {
  readonly category: TechniqueBalanceCategory;
  readonly range: TechniqueRange;
  readonly speed: number;
  
  /**
   * Timing window for next technique in combo chain (milliseconds)
   * 연속 기술 시간 창 (밀리초)
   * 
   * Specifies how long after this technique completes that the next
   * technique can be chained for combo continuation. Son (Wind) stance
   * uses 200ms for consistent rhythmic flow.
   * 
   * @korean 콤보창
   */
  readonly comboWindow?: number;
  
  /**
   * Priority in combo chain (1=starter, 2=mid-chain, 3=finisher)
   * 콤보 우선순위 (1=시작, 2=중간, 3=마무리)
   * 
   * Determines where technique fits in combo sequences:
   * - 1 (starter): Opens combo chains, low recovery
   * - 2 (mid-chain): Bridges combos, balanced stats
   * - 3 (finisher): Ends combos, high damage/recovery
   * 
   * @korean 콤보우선순위
   */
  readonly comboPriority?: number;
  
  /**
   * Pressure stacks accumulated on hit (for Son/Wind stance)
   * 압박 누적치 (손 바람 자세용)
   * 
   * Number of pressure stacks applied when technique connects.
   * Used by Son (Wind) stance for continuous pressure mechanics.
   * Typically 1-3 stacks per technique.
   * 
   * @korean 압박스택
   */
  readonly pressureStacks?: number;
};
 
/**
 * Korean text with romanization for vital point names
 */
export interface VitalPointNames {
  readonly korean: string;
  readonly english: string;
  readonly romanized: string;
}
 
/**
 * Unified VitalPoint interface matching actual usage
 */
export interface VitalPoint {
  readonly id: string;
  readonly names: VitalPointNames; // ✅ Fixed: Use 'names' structure
  readonly position: Position;
  readonly category: VitalPointCategory;
  readonly severity: VitalPointSeverity;
  readonly baseDamage?: number;
  readonly effects: readonly VitalPointEffect[];
  readonly description: KoreanText;
  readonly targetingDifficulty: number;
  readonly effectiveStances: readonly TrigramStance[];
 
  // Optional properties for backwards compatibility
  readonly korean?: KoreanText;
  readonly english?: string;
  readonly anatomicalName?: string;
  readonly radius?: number; // Make optional with default
  readonly damage?: DamageRange;
  readonly difficulty?: number;
  readonly requiredForce?: number; // Make optional with default
  readonly safetyWarning?: string;
  readonly location?: Position;
  readonly region?: string;
}
 
/**
 * Result of a vital point hit calculation
 * Unified to resolve property name conflicts and includes meridian effects
 */
export interface VitalPointHitResult {
  /** Whether the vital point was successfully hit */
  readonly hit: boolean;
 
  /** The vital point that was hit (primary property name) */
  readonly vitalPointHit?: VitalPoint;
 
  /** Legacy property name for backwards compatibility */
  readonly vitalPoint?: VitalPoint;
 
  /** Base damage from the vital point hit */
  readonly damage: number;
 
  /** Status effects applied by the vital point hit */
  readonly effects: readonly StatusEffect[];
 
  /** Severity level of the vital point hit */
  readonly severity: VitalPointSeverity;
 
  /** Accuracy of the hit (0-1) */
  readonly accuracy?: number;
 
  /** Additional multiplier applied to damage */
  readonly multiplier?: number;
 
  /** Meridian flow multiplier based on time of day (0.7-1.3) */
  readonly meridianMultiplier?: number;
 
  /** Status effects from meridian disruption */
  readonly meridianEffects?: readonly StatusEffect[];
}
 
export interface VitalPointEffect {
  readonly id: string;
  readonly type: VitalPointEffectType;
  readonly intensity: EffectIntensity;
  readonly duration: number;
  readonly description: KoreanText;
  readonly stackable: boolean;
  readonly source?: string;
}
 
export interface DamageResult {
  readonly damage: number;
  readonly effects: readonly StatusEffect[];
  readonly isCritical: boolean;
  readonly isVitalPoint: boolean;
}
 
export interface AnatomicalRegion {
  readonly id: string;
  readonly name: KoreanText;
  readonly boundaries: readonly Position[];
  readonly vitalPoints: readonly VitalPoint[];
}
 
export interface BodyRegionData {
  readonly id: string;
  readonly name: KoreanText;
  readonly boundaries: readonly Position[];
  readonly vitalPoints: readonly VitalPoint[];
}
 
export interface VitalPointSystemConfig {
  readonly precisionRequired: number;
  readonly damageMultipliers: Record<string, number>;
  readonly effectDurations: Record<string, number>;
}
 
export interface VitalPointSystemInterface {
  processHit: (
    targetPosition: Position,
    technique: KoreanTechnique,
    baseDamage: number,
    attackerArchetype: PlayerArchetype,
    targetDimensions: { width: number; height: number },
    targetedVitalPointId?: string | null
  ) => VitalPointHitResult;
  calculateHit: (
    technique: KoreanTechnique,
    targetVitalPointId: string | null,
    accuracyRoll: number,
    attackerPosition: Position,
    defenderPosition: Position,
    defenderStance: TrigramStance
  ) => VitalPointHitResult;
  applyVitalPointEffects: <T extends VitalPointEffectTarget>(
    player: T,
    vitalPoint: VitalPoint,
    intensityMultiplier?: number
  ) => T;
}
 
export interface VitalPointSystem {
  readonly getVitalPoints: () => readonly VitalPoint[];
  readonly checkHit: (position: Position, force: number) => VitalPointHitResult;
  readonly calculateDamage: (vitalPoint: VitalPoint, force: number) => number;
}
 
// Define VitalPoint locally to avoid circular import
export interface VitalPoint {
  readonly id: string;
  readonly names: {
    readonly korean: string;
    readonly english: string;
    readonly romanized: string;
  };
  readonly position: Position;
  readonly category: VitalPointCategory;
  readonly severity: VitalPointSeverity;
  readonly baseDamage?: number;
  readonly effects: readonly VitalPointEffect[];
  readonly description: KoreanText;
  readonly targetingDifficulty: number;
  readonly effectiveStances: readonly TrigramStance[];
}
 
export interface VitalPointEffect {
  readonly id: string;
  readonly type: VitalPointEffectType;
  readonly intensity: EffectIntensity;
  readonly duration: number;
  readonly description: KoreanText;
  readonly stackable: boolean;
  readonly source?: string;
}
 
// Region data
export interface RegionData {
  readonly name: KoreanText;
  readonly boundaries: readonly Position[];
  readonly vitalPoints: readonly VitalPoint[];
  readonly vulnerabilities: readonly string[];
}