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 | 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 5x 1x 1x 4x 1x 1x 5x 23x 4x 19x 1x 18x 7x 11x 1x 10x 21x 16x 5x 5x 5x 5x 4x 1x 1x 4x 4x 4x 1x 4x 3x 3x 3x 3x 1x 2x 3x 4x 2x 2x 2x 2x 2x | /**
* Utility functions for Pain and Consciousness management in combat.
*
* **Korean**: 고통 의식 관리 유틸리티
*
* Provides helper functions for managing pain and consciousness effects
* in combat scenarios, including status checking, effect application,
* and recovery management.
*
* @module systems/combat/painConsciousnessUtils
* @category Combat System
*/
import { PlayerState } from "../player";
import { VitalPointCategory } from "@/types";
import { CombatResult } from "./types";
import PainResponseSystem, { PainLevel, ShockPainEffect } from "./PainResponseSystem";
import ConsciousnessSystem, { ConsciousnessLevel } from "./ConsciousnessSystem";
/**
* Pain and consciousness status information.
*/
export interface PainConsciousnessStatus {
/** Current pain level */
readonly painLevel: PainLevel;
/** Current consciousness level */
readonly consciousnessLevel: ConsciousnessLevel;
/** Whether player is in pain overload */
readonly isInPainOverload: boolean;
/** Whether player is at incapacitation threshold */
readonly isIncapacitated: boolean;
/** Whether player is combat effective */
readonly isCombatEffective: boolean;
/** Overall combat effectiveness percentage (0-1) */
readonly combatEffectiveness: number;
/** Bilingual status description */
readonly statusDescription: {
readonly korean: string;
readonly english: string;
};
}
/**
* Gets comprehensive pain and consciousness status for a player.
*
* @param player - Player to check status for
* @param painSystem - Pain response system instance
* @param consciousnessSystem - Consciousness system instance
* @returns Comprehensive status information
*
* @example
* ```typescript
* const status = getPainConsciousnessStatus(player, painSystem, consciousnessSystem);
* console.log(`Combat effectiveness: ${status.combatEffectiveness * 100}%`);
* console.log(`Status: ${status.statusDescription.english}`);
* ```
*
* @public
* @korean 상태확인
*/
export function getPainConsciousnessStatus(
player: PlayerState,
painSystem: PainResponseSystem,
consciousnessSystem: ConsciousnessSystem
): PainConsciousnessStatus {
const painLevel = painSystem.getPainLevel(player.pain);
const consciousnessLevel = consciousnessSystem.getLevel(player.consciousness);
const isInPainOverload = painSystem.isInPainOverload(player);
const isIncapacitated = consciousnessSystem.isAtIncapacitationThreshold(player);
// Calculate overall combat effectiveness
const painPenalty = painSystem.getEffects(painLevel).performancePenalty;
const consciousnessPenalty = consciousnessSystem.getEffects(consciousnessLevel).accuracyPenalty;
const combatEffectiveness = Math.max(0, 1 - Math.max(painPenalty, consciousnessPenalty));
const isCombatEffective = combatEffectiveness > 0.5;
// Generate status description
const painName = painSystem.getLevelName(painLevel);
const consciousnessName = consciousnessSystem.getLevelName(consciousnessLevel);
let statusKorean = `고통: ${painName.korean}, 의식: ${consciousnessName.korean}`;
let statusEnglish = `Pain: ${painName.english}, Consciousness: ${consciousnessName.english}`;
if (isIncapacitated) {
statusKorean = "무력화 상태";
statusEnglish = "Incapacitated";
} else if (isInPainOverload) {
statusKorean = "고통 과부하";
statusEnglish = "Pain Overload";
}
return {
painLevel,
consciousnessLevel,
isInPainOverload,
isIncapacitated,
isCombatEffective,
combatEffectiveness,
statusDescription: {
korean: statusKorean,
english: statusEnglish,
},
};
}
/**
* Determines if a combat result should trigger head trauma.
*
* Head trauma occurs for:
* - Neurological vital point hits
* - Vascular hits to head region
* - High damage hits (>25) that could cause concussion
* - Critical hits to upper body
*
* @param result - Combat result to check
* @param category - Vital point category if known
* @returns True if result should cause head trauma
*
* @public
* @korean 두부외상확인
*/
export function isHeadTraumaHit(
result: CombatResult,
category?: VitalPointCategory
): boolean {
// Neurological hits often target head
if (category === VitalPointCategory.NEUROLOGICAL) {
return true;
}
// Vascular hits to head region
if (category === VitalPointCategory.VASCULAR && result.damage > 15) {
return true;
}
// High damage hits that could concuss
if (result.damage > 25) {
return true;
}
// Critical hits to vital points
if (result.isCritical && result.vitalPointHit) {
return true;
}
return false;
}
/**
* Extracts vital point category from combat result.
*
* Uses heuristics to determine category from effect sources and hit data.
*
* @param result - Combat result
* @returns Vital point category if determinable
*
* @public
* @korean 급소분류추출
*/
export function extractVitalPointCategory(result: CombatResult): VitalPointCategory | undefined {
if (!result.vitalPointHit || !result.effects || result.effects.length === 0) {
return undefined;
}
const effect = result.effects[0];
Iif (!effect.source) {
return undefined;
}
const source = effect.source.toLowerCase();
// Map source strings to categories
if (source.includes('neuro') || source.includes('nerve')) {
return VitalPointCategory.NEUROLOGICAL;
}
Eif (source.includes('vascular') || source.includes('blood') || source.includes('artery')) {
return VitalPointCategory.VASCULAR;
}
if (source.includes('respiratory') || source.includes('breath') || source.includes('lung')) {
return VitalPointCategory.RESPIRATORY;
}
if (source.includes('skeletal') || source.includes('bone')) {
return VitalPointCategory.SKELETAL;
}
if (source.includes('muscular') || source.includes('muscle')) {
return VitalPointCategory.MUSCULAR;
}
if (source.includes('organ') || source.includes('visceral')) {
return VitalPointCategory.ORGAN;
}
if (source.includes('joint')) {
return VitalPointCategory.JOINT;
}
return undefined;
}
/**
* Calculates recommended recovery time based on player condition.
*
* @param player - Player state
* @param consciousnessSystem - Consciousness system
* @returns Estimated recovery time in seconds
*
* @example
* ```typescript
* const recoveryTime = getRecommendedRecoveryTime(player, consciousnessSystem);
* console.log(`Recovery needed: ${recoveryTime}s`);
* ```
*
* @public
* @korean 회복시간계산
*/
export function getRecommendedRecoveryTime(
player: PlayerState,
consciousnessSystem: ConsciousnessSystem
): number {
let painRecoveryTime = 0;
let consciousnessRecoveryTime = 0;
// Pain recovery time (-5 pain/second)
if (player.pain > 0) {
painRecoveryTime = player.pain / 5;
}
// Consciousness recovery time (5 points/second after 5s delay)
if (player.consciousness < 100) {
const consciousnessToRecover = 100 - player.consciousness;
const consciousnessLevel = consciousnessSystem.getLevel(player.consciousness);
// Account for slower recovery at low consciousness
let recoveryRate = 5; // Base rate
if (consciousnessLevel === ConsciousnessLevel.STUNNED) {
recoveryRate = 2.5; // 50% slower
I} else if (consciousnessLevel === ConsciousnessLevel.UNCONSCIOUS) {
recoveryRate = 1; // 20% of base
}
consciousnessRecoveryTime = 5 + (consciousnessToRecover / recoveryRate);
}
// Since pain and consciousness recover in parallel (concurrently in game loop),
// return the maximum of the two recovery times, not the sum
return Math.ceil(Math.max(painRecoveryTime, consciousnessRecoveryTime));
}
/**
* Checks if shock pain effect is still active.
*
* @param shockEffect - Shock pain effect to check
* @returns True if effect is still active
*
* @public
* @korean 충격통활성확인
*/
export function isShockPainActive(shockEffect: ShockPainEffect): boolean {
const elapsed = Date.now() - shockEffect.startTime;
return elapsed < shockEffect.duration;
}
/**
* Gets remaining shock pain duration.
*
* @param shockEffect - Shock pain effect
* @returns Remaining duration in milliseconds, or 0 if expired
*
* @public
* @korean 충격통잔여시간
*/
export function getShockPainRemainingDuration(shockEffect: ShockPainEffect): number {
const elapsed = Date.now() - shockEffect.startTime;
return Math.max(0, shockEffect.duration - elapsed);
}
/**
* Formats pain and consciousness values for display.
*
* @param player - Player state
* @returns Formatted display strings
*
* @example
* ```typescript
* const display = formatPainConsciousnessDisplay(player);
* console.log(display.pain); // "Pain: 45/100"
* console.log(display.consciousness); // "Consciousness: 85/100"
* ```
*
* @public
* @korean 표시형식
*/
export function formatPainConsciousnessDisplay(player: PlayerState): {
readonly pain: string;
readonly consciousness: string;
readonly painKorean: string;
readonly consciousnessKorean: string;
} {
return {
pain: `Pain: ${Math.floor(player.pain)}/100`,
consciousness: `Consciousness: ${Math.floor(player.consciousness)}/100`,
painKorean: `고통: ${Math.floor(player.pain)}/100`,
consciousnessKorean: `의식: ${Math.floor(player.consciousness)}/100`,
};
}
|