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 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 | 19x 19x 19x 15x 15x 15x 15x 15x 15x 15x 15x 1375x 1364x 7x 1x 1x 1x 1x 13x 13x 13x 13x 2x 2x 2x 2x 13x 1340x 1340x 1340x 8x 8x 8x 1331x 1331x 1331x 1331x 1331x 1331x 1331x 1331x 1331x 1331x 1331x 1331x 1331x 1331x 1331x 1331x 1331x 1331x 1331x 1331x 1331x 1331x 1331x 1331x 1331x 1330x 1330x 1330x 1330x 1331x 1331x 2x 1x 1330x 1331x 1331x 1329x 1329x 1329x 2x 2x 2x 1331x 10007x 10007x 10007x 2x 10005x 10005x 10005x 10005x 10004x 10004x 10005x 10007x 10007x 2x 10005x 10005x 10005x 10005x | import {
PlayerArchetype,
TrigramStance,
VitalPointSeverity,
} from "../../types/common";
import {
calculateHipRotationPowerModifier,
calculateKickPowerFromHipRotation,
type HipRotationState,
type KickType,
} from "../animation";
import { PlayerState } from "../player";
import { TrigramCalculator } from "../trigram/TrigramCalculator";
import { asExtendedGonTechnique } from "../trigram/types/GonTechniqueExtensions";
import { StatusEffect } from "../types";
import { calculateMeridianFlow } from "./KoreanAnatomy";
import { getMeridiansForVitalPoint } from "./MeridianVitalPointMapping";
import {
DamageResult,
KoreanTechnique,
VitalPoint,
VitalPointHitResult,
} from "./types";
export class DamageCalculator {
/**
* Vital point severity damage multipliers
*/
private static readonly SEVERITY_MULTIPLIERS: Record<
VitalPointSeverity,
number
> = {
[VitalPointSeverity.MINOR]: 1.2,
[VitalPointSeverity.MODERATE]: 1.5,
[VitalPointSeverity.MAJOR]: 2.0,
[VitalPointSeverity.CRITICAL]: 2.5,
[VitalPointSeverity.LETHAL]: 3.0,
};
/**
* Accuracy bonus scaling constants
* Maps 0.0-1.0 accuracy to 0.8x-1.2x multiplier
*/
private static readonly ACCURACY_MIN_MULTIPLIER = 0.8;
private static readonly ACCURACY_RANGE = 0.4; // Range from min to max (1.2 - 0.8)
/**
* Calculate vital point damage with proper archetype bonuses
*/
static calculateVitalPointDamage(
vitalPoint: VitalPoint,
baseDamage: number,
attacker: PlayerState,
accuracy: number,
): DamageResult {
const effects: StatusEffect[] = [];
// Fix: Use static method call instead of this
const archetypeModifier = DamageCalculator.getArchetypeModifier(
attacker.archetype,
);
const techniqueEffectiveness = accuracy;
const finalDamage = Math.max(
1,
(vitalPoint.baseDamage ?? vitalPoint.damage?.min ?? baseDamage) *
archetypeModifier *
techniqueEffectiveness,
);
// Create status effects from vital point
vitalPoint.effects.forEach((effect) => {
const statusEffect: StatusEffect = {
id: `${effect.id}_${Date.now()}`,
type: "weakened", // Map to valid EffectType
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- EffectIntensity type mapping from vital point effect
intensity: "moderate" as any,
duration: effect.duration,
description: effect.description,
stackable: effect.stackable,
source: vitalPoint.id,
startTime: Date.now(),
endTime: Date.now() + effect.duration,
};
effects.push(statusEffect);
});
return {
damage: finalDamage,
effects,
isCritical: accuracy > 0.9,
isVitalPoint: true,
};
}
/**
* Fix: Add missing getArchetypeModifier method
*/
static getArchetypeModifier(archetype: PlayerArchetype): number {
switch (archetype) {
case PlayerArchetype.MUSA:
return 1.2; // Traditional warrior - strong base damage
case PlayerArchetype.AMSALJA:
return 1.5; // Assassin - high damage modifier
case PlayerArchetype.HACKER:
return 1.1; // Cyber warrior - precision over power
case PlayerArchetype.JEONGBO_YOWON:
return 1.1; // Intelligence operative - strategic damage
case PlayerArchetype.JOJIK_POKRYEOKBAE:
return 1.3; // Organized crime - brutal effectiveness
default:
return 1.0;
}
}
/**
* Calculate technique damage with vital point consideration
*/
static calculateTechniqueDamage(
technique: KoreanTechnique,
attacker: PlayerState,
vitalPoint: VitalPoint | null,
accuracy: number,
): DamageResult {
// Fix: Remove unused baseDamage variable and use technique.damage directly
const effects: StatusEffect[] = [];
const archetypeModifier = DamageCalculator.getArchetypeModifier(
attacker.archetype,
);
let finalDamage = (technique.damage ?? 15) * archetypeModifier * accuracy;
// Apply vital point multiplier if hitting a vital point
if (vitalPoint) {
finalDamage *=
(vitalPoint.baseDamage ?? vitalPoint.damage?.min ?? 10) / 10;
// Add vital point effects
vitalPoint.effects.forEach((effect) => {
const statusEffect: StatusEffect = {
id: `${effect.id}_${Date.now()}`,
type: "weakened",
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- EffectIntensity type mapping from vital point effect
intensity: "moderate" as any,
duration: effect.duration,
description: effect.description,
stackable: effect.stackable,
source: vitalPoint.id,
startTime: Date.now(),
endTime: Date.now() + effect.duration,
};
effects.push(statusEffect);
});
}
return {
damage: Math.max(1, Math.floor(finalDamage)),
effects,
isCritical: accuracy > 0.8,
isVitalPoint: !!vitalPoint,
};
}
/**
* Calculate damage reduction from defense
*/
static calculateDamageReduction(
incomingDamage: number,
defenderDefense: number,
isBlocking: boolean = false,
): number {
const blockMultiplier = isBlocking ? 0.5 : 1.0;
const defenseReduction = Math.min(0.8, defenderDefense / 200); // Max 80% reduction
return Math.max(
1,
incomingDamage * (1 - defenseReduction) * blockMultiplier,
);
}
/**
* Calculate critical hit chance
*/
static calculateCriticalChance(
baseCritChance: number,
attacker: PlayerState,
technique: KoreanTechnique,
): number {
const archetypeBonus =
DamageCalculator.getArchetypeModifier(attacker.archetype) * 0.1;
const techniqueBonus = (technique.critChance || 0.1) * 0.5;
return Math.min(0.95, baseCritChance + archetypeBonus + techniqueBonus);
}
/**
* Calculate comprehensive vital point damage with all modifiers.
*
* **Korean**: 종합 급소 피해 계산 (Comprehensive Vital Point Damage Calculation)
*
* Integrates all damage modifiers including:
* - Base damage from attacker strength and technique power
* - Stance effectiveness (攻克关系)
* - Vital point severity multipliers (1.5x-3.0x)
* - Accuracy bonus (0.8x-1.2x)
* - Meridian flow bonus (1.0x-1.3x at peak hours)
* - Time-of-day bonus (+20% for Dark Ops techniques at night)
* - Archetype-specific bonuses
* - Hip rotation power modifier (1.0x-1.3x for strikes with full rotation)
* - Critical hit multiplier (2x when accuracy > 0.9)
* - Damage variance (±10% randomness)
* - Defense reduction
*
* ## Damage Formula
*
* ```typescript
* finalDamage =
* baseDamage ×
* stanceEffectiveness ×
* vitalPointMultiplier ×
* accuracyBonus ×
* meridianBonus ×
* timeBonus ×
* archetypeBonus ×
* hipRotationModifier ×
* criticalMultiplier ×
* variance ×
* defenseReduction
* ```
*
* @param attacker - Attacking player state
* @param defender - Defending player state
* @param technique - Korean martial arts technique being used
* @param vitalPointHit - Result of vital point hit detection
* @param currentHour - Current hour of day (0-23) for meridian flow
* @param meridianStates - Current meridian disruption states (0=blocked, 1=normal)
* @param hipRotationAngle - Hip rotation angle in radians (optional, defaults to 0)
* @param kickHipState - Hip rotation state for kicks (optional, for kick-specific power)
* @returns Comprehensive damage result with all modifiers applied
*
* @example
* ```typescript
* const result = DamageCalculator.calculateEnhancedVitalPointDamage(
* attackerState,
* defenderState,
* technique,
* vitalPointHitResult,
* 2, // 2 AM - liver meridian peak
* { liver: 1.0, gallbladder: 0.8 }
* );
* console.log(`Final damage: ${result.damage}`);
* console.log(`Critical hit: ${result.isCritical}`);
* ```
*
* @public
* @korean 종합급소피해계산
*/
static calculateEnhancedVitalPointDamage(
attacker: PlayerState,
defender: PlayerState,
technique: KoreanTechnique,
vitalPointHit: VitalPointHitResult,
currentHour: number,
meridianStates: Record<string, number>,
hipRotationAngle: number = 0,
kickHipState?: HipRotationState,
): DamageResult {
// 1. Base damage from technique
const attackerStrength = attacker.attackPower || 50;
const techniquePower = technique.damage || 15;
const baseDamage = attackerStrength * (techniquePower / 10);
// 2. Stance effectiveness (攻克关系)
const stanceEffectiveness = TrigramCalculator.calculateStanceEffectiveness(
attacker.currentStance,
defender.currentStance,
);
// 3. Vital point severity multiplier
const vitalPointMultiplier = vitalPointHit.vitalPointHit
? (DamageCalculator.SEVERITY_MULTIPLIERS[vitalPointHit.severity] ?? 1)
: 1;
// 4. Accuracy bonus (better aim = more damage)
// Maps 0.0-1.0 accuracy to 0.8x-1.2x multiplier
const accuracy = vitalPointHit.accuracy ?? 0.5;
const accuracyBonus =
DamageCalculator.ACCURACY_MIN_MULTIPLIER +
accuracy * DamageCalculator.ACCURACY_RANGE;
// 5. Meridian flow bonus
const meridianBonus = DamageCalculator.calculateMeridianDamageBonus(
vitalPointHit.vitalPointHit?.id ?? "",
currentHour,
meridianStates,
);
// 6. Time-of-day bonus (Dark Ops techniques at night)
const timeBonus = DamageCalculator.calculateTimeBonus(
technique,
currentHour,
);
// 7. Archetype-specific bonus
const archetypeBonus = DamageCalculator.getArchetypeDamageBonus(
attacker.archetype,
technique,
vitalPointHit.vitalPointHit,
);
// 8. Hip rotation power modifier (허리회전 파워 보너스)
// Determine technique type for appropriate modifier calculation
let hipRotationModifier = 1.0;
// Check if this is a kick technique and we have kick-specific hip state
const techniqueName =
technique.name?.english || technique.englishName || "";
const isKickTechnique =
technique.type === "kick" || techniqueName.toLowerCase().includes("kick");
Iif (kickHipState && isKickTechnique) {
// Use advanced kick-specific hip rotation calculation (up to 40% bonus)
const kickType = DamageCalculator.determineKickType(techniqueName);
hipRotationModifier = calculateKickPowerFromHipRotation(
kickHipState,
kickType,
);
I} else if (hipRotationAngle !== 0) {
// Use general hip rotation for strikes/throws/joints (up to 30% bonus)
const techniqueType: "strike" | "throw" | "joint" =
technique.type === "throw"
? "throw"
: technique.type === "joint_lock"
? "joint"
: "strike";
hipRotationModifier = calculateHipRotationPowerModifier(
hipRotationAngle,
techniqueType,
);
}
// 9. Critical hit (accuracy > 0.9)
const criticalMultiplier = accuracy > 0.9 ? 2.0 : 1.0;
const isCritical = accuracy > 0.9;
// 10. Calculate total damage before defense
let totalDamage =
baseDamage *
stanceEffectiveness *
vitalPointMultiplier *
accuracyBonus *
meridianBonus *
timeBonus *
archetypeBonus *
hipRotationModifier *
criticalMultiplier;
// 11. Add damage variance (±10%)
const variance = 0.9 + Math.random() * 0.2; // 0.9 to 1.1
totalDamage *= variance;
// 12. Apply defense reduction using existing method for consistency
const defenderDefense = defender.defense || 0;
const finalDamage = DamageCalculator.calculateDamageReduction(
totalDamage,
defenderDefense,
false,
);
// 13. Combine effects from vital point hit
const effects = vitalPointHit.effects || [];
return {
damage: Math.max(1, finalDamage), // Minimum 1 damage
effects,
isCritical,
isVitalPoint: !!vitalPointHit.vitalPointHit,
};
}
/**
* Determine kick type from technique name for hip rotation power calculation
*
* @param techniqueName - Name of the technique
* @returns Kick type for hip rotation calculation
*
* @private
* @korean 차기유형결정
*/
private static determineKickType(techniqueName: string): KickType {
const name = techniqueName.toLowerCase();
if (
name.includes("front") ||
name.includes("앞차기") ||
name.includes("snap")
) {
return "front";
} else if (
name.includes("roundhouse") ||
name.includes("돌려차기") ||
name.includes("round")
) {
return "roundhouse";
} else if (
name.includes("side") ||
name.includes("옆차기") ||
name.includes("lateral")
) {
return "side";
} else if (name.includes("hook") || name.includes("후려차기")) {
return "hook";
} else if (
name.includes("axe") ||
name.includes("내려차기") ||
name.includes("downward")
) {
return "axe";
}
// Default to front kick for unknown kick types
return "front";
}
/**
* Calculate meridian flow damage bonus based on time of day.
*
* **Korean**: 경락 유효성 피해 보너스 계산
*
* Calculates bonus damage when striking vital points during their peak
* meridian flow hours. Peak flow provides +30% damage bonus.
*
* @param vitalPointId - ID of the vital point being struck
* @param currentHour - Current hour of day (0-23)
* @param meridianStates - Current meridian disruption states
* @returns Damage multiplier (1.0-1.3)
*
* @private
* @korean 경락유효성피해보너스계산
*/
private static calculateMeridianDamageBonus(
vitalPointId: string,
currentHour: number,
meridianStates: Record<string, number>,
): number {
if (!vitalPointId) return 1;
const relatedMeridians = getMeridiansForVitalPoint(vitalPointId);
let maxBonus = 1.0;
for (const meridianId of relatedMeridians) {
const flow = calculateMeridianFlow(meridianId, currentHour);
const state = meridianStates[meridianId] ?? 1.0;
// Peak flow (>0.9) with normal state gives +30% bonus
// flow ranges from 0.7 to 1.3, state from 0 (blocked) to 1 (normal)
const effectiveFlow = flow * state;
if (effectiveFlow > 0.9) {
// Bonus scales linearly from 1.0 (no bonus) at effectiveFlow = 0.9
// to 1.3 (maximum 30% bonus) at effectiveFlow = 1.3:
// bonus = 1.0 + ((effectiveFlow - 0.9) / 0.4) * 0.3
const bonus = 1.0 + ((effectiveFlow - 0.9) / 0.4) * 0.3;
maxBonus = Math.max(maxBonus, Math.min(1.3, bonus));
}
}
return maxBonus;
}
/**
* Calculate time-of-day bonus for Dark Ops techniques.
*
* **Korean**: 시간대 보너스 계산
*
* Dark Ops techniques gain +20% damage at night (20:00-05:59)
* to reflect tactical advantage of darkness.
*
* @param technique - Technique being used
* @param currentHour - Current hour of day (0-23)
* @returns Time bonus multiplier (1.0 or 1.2)
*
* @private
* @korean 시간대보너스계산
*/
private static calculateTimeBonus(
technique: KoreanTechnique,
currentHour: number,
): number {
// Dark Ops techniques get +20% at night (20:00-05:59)
// Check if technique has dark_ops or stealth in its ID or type
const isDarkOpsTechnique =
technique.id.includes("dark_ops") ||
technique.id.includes("stealth") ||
technique.id.includes("shadow") ||
technique.id.includes("night");
if (isDarkOpsTechnique) {
// Night hours: 20:00 through 05:59 (6 AM is considered daylight)
if (currentHour >= 20 || currentHour < 6) {
return 1.2;
}
}
return 1.0;
}
/**
* Get archetype-specific damage bonus for technique and vital point.
*
* **Korean**: 원형 특화 피해 보너스
*
* Each archetype has specialized bonuses for different techniques
* and vital point categories:
*
* - **무사 (Musa)**: +20% with 건 (Geon) stance techniques
* - **암살자 (Amsalja)**: +30% on neurological vital points
* - **해커 (Hacker)**: +15% baseline precision bonus
* - **정보요원 (Jeongbo)**: +25% on vascular vital points
* - **조직폭력배 (Jojik)**: +20% on dirty/ruthless techniques
*
* @param archetype - Attacker's archetype
* @param technique - Technique being used
* @param vitalPoint - Vital point being struck (optional)
* @returns Archetype damage multiplier (1.0-1.5)
*
* @private
* @korean 원형특화피해보너스
*/
private static getArchetypeDamageBonus(
archetype: PlayerArchetype,
technique: KoreanTechnique,
vitalPoint?: VitalPoint,
): number {
// Base archetype modifier
let bonus = DamageCalculator.getArchetypeModifier(archetype);
// Additional bonuses based on technique-archetype synergy
switch (archetype) {
case PlayerArchetype.MUSA:
// Musa gets bonus with Geon (Heaven) stance techniques
Eif (technique.stance === TrigramStance.GEON) {
bonus *= 1.2;
}
break;
case PlayerArchetype.AMSALJA:
// Assassin gets bonus on neurological vital points
Eif (vitalPoint?.category === "neurological") {
bonus *= 1.3;
}
break;
case PlayerArchetype.HACKER:
// Hacker gets consistent precision bonus
bonus *= 1.15;
break;
case PlayerArchetype.JEONGBO_YOWON:
// Intelligence operative gets bonus on vascular targets
if (vitalPoint?.category === "vascular") {
bonus *= 1.25;
}
break;
case PlayerArchetype.JOJIK_POKRYEOKBAE:
// Organized crime gets bonus on ruthless techniques
// Check for keywords in technique ID
if (
technique.id.includes("ruthless") ||
technique.id.includes("brutal") ||
technique.id.includes("dirty")
) {
bonus *= 1.2;
}
break;
}
// Cap maximum bonus at 1.5x
return Math.min(1.5, bonus);
}
/**
* Calculate throw/takedown impact damage with ground multiplier.
*
* **Korean**: 던지기 충격 피해 계산 (Throw Impact Damage Calculation)
*
* Applies groundImpactMultiplier from Gon (Earth) techniques when opponent
* hits the ground after a throw or takedown. Integrates with base damage
* calculation to provide authentic Ssireum/Hapkido throw mechanics.
*
* **Formula**:
* ```
* impactDamage = baseDamage × groundImpactMultiplier × strengthModifier
* ```
*
* **Ground Impact Multiplier Ranges**:
* - 1.0-1.2: Low impact (controlled takedowns)
* - 1.3-1.5: Medium impact (standard throws)
* - 1.6-1.8: High impact (power throws)
* - 1.9-2.0: Maximum impact (slams like 대지강타)
*
* @param technique - Korean martial arts technique (checks for ExtendedGonTechnique)
* @param baseDamage - Base damage before ground impact modifier
* @param attackerStrength - Attacker's strength stat for scaling
* @param options - Optional configuration for damage calculation
* @param options.applyVariance - Whether to apply random ±5% variance (default: true)
* @returns Enhanced damage result with ground impact applied
*
* @example
* ```typescript
* const throwDamage = DamageCalculator.calculateThrowImpactDamage(
* ssireumThrowTechnique, // groundImpactMultiplier: 1.7
* 50, // base damage
* 80 // attacker strength
* );
* // Result: ~85 damage (50 × 1.7 × 1.0) with ±5% variance
*
* // For deterministic testing:
* const testDamage = DamageCalculator.calculateThrowImpactDamage(
* technique, 50, 80, { applyVariance: false }
* );
* ```
*
* @public
* @korean 던지기충격피해계산
*/
static calculateThrowImpactDamage(
technique: KoreanTechnique,
baseDamage: number,
attackerStrength: number = 50,
options: { applyVariance?: boolean } = {},
): DamageResult {
const { applyVariance = true } = options;
// Check if technique has Gon-specific ground impact metadata
// Use helper function for safe type casting
const gonTechnique = asExtendedGonTechnique(technique);
if (!gonTechnique) {
// Non-Gon technique: return base damage without ground multiplier
return {
damage: Math.max(1, baseDamage),
effects: [],
isCritical: false,
isVitalPoint: false,
};
}
// Extract ground impact multiplier from validated Gon technique
const groundMultiplier = gonTechnique.groundImpactMultiplier;
// Calculate strength modifier (50 = baseline, scales ±20%)
// Stronger attackers create more impact, weaker create less
const strengthModifier = 0.8 + (attackerStrength / 250);
// Apply ground impact multiplier with strength scaling
let impactDamage = baseDamage * groundMultiplier * strengthModifier;
// Add small damage variance (±5%) for realistic impact variation
// Can be disabled for deterministic testing
if (applyVariance) {
const variance = 0.95 + Math.random() * 0.1; // 0.95 to 1.05
impactDamage *= variance;
}
// Earth connection healing (대지는 모든 것을 품고 키운다)
// Supportive healing is applied separately by calling system
// This method focuses on damage calculation only
return {
damage: Math.max(1, Math.floor(impactDamage)),
effects: [],
isCritical: impactDamage > baseDamage * 1.5, // High impact = critical
isVitalPoint: false,
};
}
/**
* Calculate earth's supportive healing from Gon technique.
*
* **Korean**: 대지 치유 계산 (Earth Healing Calculation)
*
* Implements Korean martial arts philosophy:
* "대지는 모든 것을 품고 키운다" (The earth embraces and nurtures all things)
*
* Gon techniques restore HP to the attacker after successful execution
* based on their connection with earth energy. Traditional techniques
* like Ssireum throws provide stronger healing due to cultural authenticity.
*
* **Healing Formula**:
* ```
* healingAmount = supportiveHealing × (1 + earthAffinityBonus)
* ```
*
* **Supportive Healing Ranges**:
* - 0-2: Minimal earth connection (aggressive techniques)
* - 3-4: Moderate earth connection (standard Ssireum)
* - 5-6: Strong earth connection (traditional, sacrifice throws)
* - 7-10: RESERVED for meditation/healing techniques
*
* @param technique - Korean martial arts technique (checks for ExtendedGonTechnique)
* @param earthAffinityBonus - Player's earth affinity stat modifier (0.0-1.0)
* @returns HP healing amount (0 if not a Gon technique)
*
* @example
* ```typescript
* const healing = DamageCalculator.calculateEarthHealing(
* ssireumThrowTechnique, // supportiveHealing: 5
* 0.3 // 30% earth affinity bonus
* );
* // Result: 6.5 HP restored (5 × 1.3)
* ```
*
* @public
* @korean 대지치유계산
*/
static calculateEarthHealing(
technique: KoreanTechnique,
earthAffinityBonus: number = 0,
): number {
// Use helper function for safe type casting
const gonTechnique = asExtendedGonTechnique(technique);
if (!gonTechnique) {
return 0; // Non-Gon technique: no earth healing
}
const baseHealing = gonTechnique.supportiveHealing;
// Apply earth affinity bonus (typically 0-100% bonus)
const affinityMultiplier = 1 + Math.max(0, Math.min(1, earthAffinityBonus));
// Calculate final healing with bonus
const healingAmount = baseHealing * affinityMultiplier;
// Return rounded healing value (minimum 0)
return Math.max(0, Math.floor(healingAmount));
}
}
export default DamageCalculator;
|