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 | 3x 37x 19x 7x 12x 12x 13x 4x 9x 3x 1x 2x 3x 2x 2x 2x 2x 2x 2x 2x 2x | /**
* Haptic Feedback Utility
*
* Provides tactile feedback for mobile touch interactions
* Uses Vibration API for physical response on button presses and combat hits
*
* @module utils/haptics
* @category Mobile Controls
* @korean 햅틱 피드백 유틸리티
*/
/**
* Haptic intensity levels for different interactions
*/
export type HapticIntensity = 'light' | 'medium' | 'heavy';
/**
* Vibration patterns for different haptic intensities
* - light: Quick tap (10ms) - UI interactions
* - medium: Moderate pulse (50ms) - Combat actions
* - heavy: Strong pulse (100ms) - Critical hits
*
* @korean 햅틱 강도 패턴
*/
const HAPTIC_PATTERNS: Record<HapticIntensity, number[]> = {
light: [10],
medium: [50],
heavy: [100],
} as const;
/**
* Check if haptic feedback is supported by the device
*
* @returns True if Vibration API is available
* @korean 햅틱 지원 확인
*
* @example
* ```typescript
* if (isHapticSupported()) {
* triggerHaptic('medium');
* }
* ```
*/
export function isHapticSupported(): boolean {
return typeof navigator !== 'undefined' && 'vibrate' in navigator;
}
/**
* Trigger haptic feedback with specified intensity
*
* Provides tactile response for:
* - Light: Menu selections, button taps
* - Medium: Attack actions, stance changes
* - Heavy: Critical hits, successful vital point strikes
*
* Falls back gracefully if Vibration API is not supported
*
* @param intensity - Haptic intensity level
* @korean 햅틱 피드백 실행
*
* @example
* ```typescript
* // Light feedback for UI interaction
* triggerHaptic('light');
*
* // Medium feedback for combat action
* triggerHaptic('medium');
*
* // Heavy feedback for critical hit
* triggerHaptic('heavy');
* ```
*
* @public
*/
export function triggerHaptic(intensity: HapticIntensity): void {
if (!isHapticSupported()) {
return;
}
const pattern = HAPTIC_PATTERNS[intensity];
navigator.vibrate(pattern);
}
/**
* Custom haptic pattern for specific game events
* Allows creating complex vibration sequences
*
* @param pattern - Array of vibration durations in milliseconds
* @korean 커스텀 햅틱 패턴
*
* @example
* ```typescript
* // Combo hit feedback: buzz, pause, buzz
* triggerCustomHaptic([30, 20, 30]);
*
* // Critical vital point strike: long buzz
* triggerCustomHaptic([200]);
* ```
*
* @public
*/
export function triggerCustomHaptic(pattern: number[]): void {
if (!isHapticSupported()) {
return;
}
navigator.vibrate(pattern);
}
/**
* Stop any ongoing haptic feedback
* Useful for interrupting long vibrations
*
* @korean 햅틱 피드백 중지
*
* @example
* ```typescript
* // Cancel ongoing vibration
* stopHaptic();
* ```
*
* @public
*/
export function stopHaptic(): void {
if (!isHapticSupported()) {
return;
}
navigator.vibrate(0);
}
/**
* Combat-specific haptic feedback patterns
* Pre-configured patterns for common combat scenarios
*
* @korean 전투 햅틱 패턴
*/
export const CombatHaptics = {
/**
* Standard attack hit feedback
* @korean 일반 공격
*/
attack: () => triggerHaptic('medium'),
/**
* Block successful feedback
* @korean 방어 성공
*/
block: () => triggerHaptic('light'),
/**
* Critical hit feedback with double pulse
* @korean 크리티컬 히트
*/
criticalHit: () => triggerCustomHaptic([50, 30, 100]),
/**
* Vital point strike feedback
* @korean 급소 타격
*/
vitalPointStrike: () => triggerHaptic('heavy'),
/**
* Stance change feedback
* @korean 자세 변경
*/
stanceChange: () => triggerHaptic('light'),
/**
* Combo counter increment
* @korean 콤보 카운터
*/
comboIncrement: () => triggerHaptic('light'),
/**
* Player KO feedback with extended pattern
* @korean 플레이어 KO
*/
knockout: () => triggerCustomHaptic([100, 50, 100, 50, 200]),
/**
* Error or invalid action feedback
* @korean 오류 피드백
*/
error: () => triggerCustomHaptic([20, 10, 20]),
} as const;
|