From dcfdb0814d949d194bfa0ed35722c65787c63397 Mon Sep 17 00:00:00 2001 From: William Toohey Date: Tue, 5 Jan 2016 22:31:29 +1000 Subject: [PATCH] Fix odd numbered inverts when buildups are off --- js/HuesCore.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/js/HuesCore.js b/js/HuesCore.js index 8416d8a..6e23093 100644 --- a/js/HuesCore.js +++ b/js/HuesCore.js @@ -370,7 +370,16 @@ HuesCore.prototype.fillBuildup = function() { } } console.log("Buildup length:", buildBeats); - this.beatIndex = this.doBuildup ? -this.currentSong.buildupRhythm.length : 0; + if(this.doBuildup) { + this.beatIndex = -this.currentSong.buildupRhythm.length; + } else { + this.beatIndex = 0; + // If there's an odd amount of inverts in the build, invert our display + var invertCount = (this.currentSong.buildupRhythm.match(/i|I/g)||[]).length + if(invertCount % 2) { + this.setInvert(true); + } + } }; HuesCore.prototype.randomSong = function() {