Holiday music: a dark carol for Christmas, a spring tune for Easter, a harpsichord dance for Halloween
During a holiday the title music plays its piece, the build music every fourth time. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
65ed76865d
commit
9800ce7156
8 files changed
+319
-8
No files matched your search
+10
-3
@@ -492,11 +492,12 @@ fn apply_settings(s: &Settings, r3d: &mut R3d) {
|
||||
struct MusicDirector {
|
||||
next: std::collections::HashMap<u8, usize>, // category -> next index within the category
|
||||
current: Option<audio::Category>,
|
||||
build_picks: usize, // build tracks picked so far (during a holiday every fourth is its piece)
|
||||
}
|
||||
|
||||
impl MusicDirector {
|
||||
fn new() -> MusicDirector {
|
||||
MusicDirector { next: std::collections::HashMap::new(), current: None }
|
||||
MusicDirector { next: std::collections::HashMap::new(), current: None, build_picks: 0 }
|
||||
}
|
||||
|
||||
fn pick(&mut self, c: audio::Category) -> usize {
|
||||
@@ -573,11 +574,17 @@ impl MusicDirector {
|
||||
}
|
||||
let rotate = matches!(want, C::Build | C::Title | C::Surface) && self.current == Some(want) && audio::music_loops() >= 2;
|
||||
// after the chosen track was let go, the director picks again
|
||||
let foreign = chosen.is_none() && audio::current_track().map_or(false, |t| crate::tracks::TRACKS.get(t).map_or(false, |x| x.1 != want)) && calm && self.current == Some(want);
|
||||
// (a holiday's piece belongs to the title and build music)
|
||||
let holiday = holiday::current();
|
||||
let fits = |c: C| c == want || (matches!(want, C::Title | C::Build) && audio::holiday_music(holiday) == Some(c));
|
||||
let foreign = chosen.is_none() && audio::current_track().map_or(false, |t| crate::tracks::TRACKS.get(t).map_or(false, |x| !fits(x.1))) && calm && self.current == Some(want);
|
||||
if self.current != Some(want) || rotate || foreign || audio::current_track().is_none() {
|
||||
let before = self.current;
|
||||
self.current = Some(want);
|
||||
let t = self.pick(want);
|
||||
let t = self.pick(audio::holiday_category(want, holiday, self.build_picks));
|
||||
if want == C::Build {
|
||||
self.build_picks += 1;
|
||||
}
|
||||
// between the dungeon and the surface the music changes slowly
|
||||
let fade = if matches!(want, C::Victory | C::Defeat) {
|
||||
1.0
|
||||
|
||||
Reference in new issue
Block a user