Files
joke-app/apps/web/src/games/janggi/sound.ts
EJClaw 8175cebd2c 체스·장기·쿼리도 소리·움직임, 장기 상차림 시간 무제한
- 체스: 기물이 출발 칸에서 미끄러져 와 내려앉음(내가 끌어다 놓은 수는 제외), 캐슬링은 룩도 같이, 잡힌 기물(앙파상 폰 포함) 사라짐, 체크 칸 빛·말풍선 튀어나옴, 마지막 수 칸 살짝 나타남
- 체스 소리: 나무 기물 톡, 잡기, 캐슬링, 승진, 체크, 체크메이트 순간, 무르기, 기물 집기, 안 되는 칸 (fx.ts 순수 함수 + 테스트)
- 장기: 묵직한 기물 미끄러짐·내려앉기, 잡힌 기물 사라짐, 장군 궁 자리 고동, 상차림 마·상 하나씩 튀어나옴
- 장기 소리: 두꺼운 나무 "딱", 잡기, 장군·멍군·빅장, 외통 순간, 한수쉼, 무르기, 상차림 놓기 (fx.ts + 테스트)
- 장기 상차림 고르는 시간에 무제한(0) 추가, 방 설정 "자세한 설정"에서 30초·1분·3분·무제한 (기본 1분 그대로), 무제한이면 상차림 시계 숨김, 끊긴 사람만 접속 유예 뒤 자동 선택
- 쿼리도: 말 한 칸은 살짝 튀며, 점프는 높이 뛰어 넘음, 도착 칸 고리, 벽 내려앉기+먼지, 무르기로 빠진 벽 사라짐, 안 되는 벽 흔들림, 목표 도착 띠 깜빡임·금빛 고리
- 쿼리도 소리: 말 톡, 점프, 벽 끼우기, 안 되는 곳, 목표 도착, 무르기
- 상대·컴퓨터 수도 화면 변화로 같은 소리·움직임, 새로 열면 다시 재생 안 함, 숨은 탭 내 차례 소리는 방 화면에 맡김

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 13:08:18 +09:00

63 lines
2.4 KiB
TypeScript

/**
* Janggi sounds: thick octagonal wooden blocks, so a lower, heavier "clack" than the chess "tok"
* (site volume is applied inside feedback.ts).
*/
import { noise, sfx, tone } from '../../lib/feedback';
import type { JanggiCue } from './fx';
/** A heavy wooden block put down on the board: a low knock plus a short dry crack. */
function clack(delay = 0, pitch = 1, gain = 1): void {
tone(330 * pitch, 80, 'triangle', 0.2 * gain, delay, { slideTo: 220 * pitch });
noise(50, 0.11 * gain, delay, 'bandpass', 1250 * pitch, 1.1);
noise(18, 0.05 * gain, delay, 'highpass', 3200);
}
/** Each cue starts `d` ms from now (when the sliding piece lands). */
const PLAY: Record<JanggiCue, (d: number) => void> = {
move: (d) => clack(d),
// The piece lands, then the taken block is knocked against it.
capture: (d) => {
clack(d, 1.08);
clack(d + 60, 0.82, 0.75);
noise(70, 0.06, d + 70, 'lowpass', 700);
},
// 한수쉼: just a light tap on the board edge.
pass: (d) => {
tone(520, 40, 'triangle', 0.06, d, { slideTo: 420 });
noise(40, 0.03, d, 'bandpass', 1800, 0.8);
},
// "장군!": a short rising call.
janggun: (d) => {
tone(659, 90, 'triangle', 0.1, d + 70);
tone(880, 150, 'triangle', 0.09, d + 160);
},
// "멍군!": the answer, falling back down.
meonggun: (d) => {
tone(880, 90, 'triangle', 0.08, d + 70);
tone(659, 150, 'triangle', 0.07, d + 160);
},
// 빅장: the two 궁 face each other; a small "standoff" figure.
bikjang: (d) => [587, 698, 587].forEach((f, i) => tone(f, 110, 'sine', 0.09, d + 260 + i * 100)),
// 외통: a low ringing chord as the last move lands (the win / lose jingle comes from the result screen).
mate: (d) => {
tone(294, 360, 'triangle', 0.12, d + 80);
tone(440, 380, 'triangle', 0.08, d + 110);
tone(587, 420, 'sine', 0.07, d + 140);
},
undo: () => sfx.whoosh(),
};
export function playJanggi(cues: JanggiCue[], delayMs = 0): void {
for (const c of cues) PLAY[c](delayMs);
}
/** 상차림 pieces put down one after another. */
export function setupSound(n: number, gapMs: number): void {
for (let i = 0; i < Math.min(n, 8); i++) clack(i * gapMs, 1.05 + (i % 2) * 0.06, 0.6);
}
/** Picking up one of my pieces: a very quiet low tick (lower than chess). */
export const pickSound = () => tone(820, 28, 'triangle', 0.06);
/** A tap that does nothing: soft and low. */
export const nopeSound = () => tone(200, 90, 'triangle', 0.06, 0, { slideTo: 160 });