improve conditions
All checks were successful
NPM Audit Check / Check NPM audit (push) Successful in -2m18s
Unit tests / Unit tests (push) Successful in -2m11s

This commit is contained in:
2025-08-29 02:02:00 -05:00
parent b8d09a6666
commit e6964315ab
3 changed files with 7 additions and 7 deletions

View File

@@ -49,17 +49,17 @@
"hilo 1": {
"tracks": [
"audio/hi_01.flac",
"%cory hi",
"%cory weather.temp.max",
"audio/lo_01.flac",
"%cory lo"
"%cory weather.temp.min"
]
},
"hilo 2": {
"tracks": [
"audio/hi_02.flac",
"%cory hi",
"%cory weather.temp.max",
"audio/lo_02.flac",
"%cory lo"
"%cory weather.temp.min"
]
},
"rain 1": {

View File

@@ -77,7 +77,7 @@ function processSequence(sequence: Sequence, currentWeather: CurrentWeather): st
function processSegment(segment: SegmentName, currentWeather: CurrentWeather): string[] {
if (!(segment in config.segments)) {
return processSequence(config.sequences[segment], currentWeather);
return (config.sequences[segment].conditions || []).every(c => conditionIsMet(c, currentWeather)) ? processSequence(config.sequences[segment], currentWeather) : [];
}
const potentialSequences: SequenceName[] = config.segments[segment].filter(s => (config.sequences[s].conditions || []).every(c => conditionIsMet(c, currentWeather)));
if (potentialSequences.length === 0) {

View File

@@ -83,7 +83,7 @@ describe('sequencer', () => {
it('can include tracks conditionally', async () => {
expect(await Sequencer({
programs: [['segment 1', 'segment 2']],
programs: [['segment 1', 'sequence 1', 'segment 2', 'sequence 2']],
segments: {
'segment 1': ['sequence 1'],
'segment 2': ['sequence 2']
@@ -104,7 +104,7 @@ describe('sequencer', () => {
},
voices: {},
weather: dummyWeather
})).to.be.ordered.members(['seq1.flac']);
})).to.be.ordered.members(['seq1.flac', 'seq1.flac']);
});
});