feat(audio): battle music layer with 5s linger#355
Merged
Conversation
Replace single cave-melody.ogg with per-zone MIX tracks (Dark Cave, Windy Peaks). SoundContext now reads currentZone from MapContext and crossfades between zone audio on transition. Moved SoundProvider inside MapProvider to access zone state. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Adds per-zone battle music (battle-dark-cave-mix, battle-windy-peaks-mix) with a state machine that punches in fast on combat start (600ms) and exhales out slow after combat (3000ms). A 5s linger timer keeps battle music playing across back-to-back fights during grinding, so the mood doesn't whiplash on every encounter gap. - Battle track selection keys off (currentZone, currentBattle) tuple - Zone change mid-battle switches to new zone's battle track - Fixes pre-existing autoplay bug: Howler.ctx.resume() on first pointer/ key/touch gesture after auto-enable, so ambient actually plays without requiring the player to click the sound toggle - Reorder App.tsx providers (BattleProvider now wraps SoundProvider) so SoundContext can read combat state 19 vitest cases cover: toggle/persistence, zone ambient, battle entry, zone-2 battle track, zone change during combat, linger cancel-on-reentry, linger-fires-after-timeout, mute mid-battle, autoplay unlock. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
Two fixes from deep review: 1. battleMode was initialized to false even when currentBattle was already non-null on mount, causing a one-tick flash of ambient music when loading a page mid-combat. Initialize from currentBattle so the first playback effect run picks the correct track. 2. Unknown zones (e.g. when zone 3 ships before its music does) now fall back to zone 1's track with a one-time console.warn per (mode, zone) pair, instead of going silently off. Adds two tests: battle track resumes on mute/unmute mid-combat, and zone-99 combat falls back to the dark-cave battle track. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
# Conflicts: # packages/client/src/App.tsx # packages/client/src/contexts/SoundContext.test.tsx # packages/client/src/contexts/SoundContext.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Per-zone battle music (battle-dark-cave-mix, battle-windy-peaks-mix) with a state machine that punches in fast on combat start (600ms) and exhales out slow after combat (3000ms). A 5s linger timer keeps battle music playing across back-to-back fights during grinding so the mood doesn't whiplash on every encounter gap.
Howler.ctx.resume()on first pointer/key/touch gesture after auto-enable, so ambient actually plays without requiring the player to click the sound toggleApp.tsxproviders (BattleProvidernow wrapsSoundProvider) soSoundContextcan read combat statebattleModefromcurrentBattleto avoid a one-tick flash of ambient when loading mid-combatTest plan
pnpm --filter client test -- SoundContext— 21/21 passingpnpm --filter client build— clean🤖 Generated with Claude Code