From fbbed1a71413980e2effc7e857050bacb1e7bdb7 Mon Sep 17 00:00:00 2001 From: LoveEevee Date: Sun, 24 Feb 2019 18:13:41 +0300 Subject: [PATCH] Fix note streams on key press --- public/src/js/game.js | 97 ++++++++++++++++++++++++------------------- 1 file changed, 54 insertions(+), 43 deletions(-) diff --git a/public/src/js/game.js b/public/src/js/game.js index f612ed2..558b095 100644 --- a/public/src/js/game.js +++ b/public/src/js/game.js @@ -76,22 +76,6 @@ class Game{ var startIndex = this.currentCircle === 0 ? 0 : this.currentCircle - 1 var index = 0 - var skipNote = circle => { - if(circle.section){ - this.resetSection() - } - circle.played(-1, circle.type === "daiDon" || circle.type === "daiKa") - this.sectionNotes.push(0) - this.controller.displayScore(0, true) - this.updateCombo(0) - this.updateGlobalScore(0, 1) - if(this.controller.multiplayer === 1){ - p2.send("note", { - score: -1 - }) - } - } - for(var i = startIndex; i < circles.length; i++){ var circle = circles[i] if(circle && (!circle.branch || circle.branch.active) && !circle.isPlayed){ @@ -132,7 +116,7 @@ class Game{ p2.send("drumroll", value) } }else{ - skipNote(circle) + this.skipNote(circle) this.updateCurrentCircle() } } @@ -146,32 +130,6 @@ class Game{ } } - var circleIsNote = circle => { - var type = circle.type - return type === "don" || type === "ka" || type === "daiDon" || type === "daiKa" - } - var currentCircle = circles[this.currentCircle] - if(!this.controller.autoPlayEnabled && currentCircle && ms - currentCircle.ms >= this.rules.ok && circleIsNote(currentCircle)){ - for(var i = this.currentCircle + 1; i < circles.length; i++){ - var circle = circles[i] - var relative = ms - circle.ms - if(!circle.branch || circle.branch.active){ - if(!circleIsNote(circle) || relative < -this.rules.bad){ - break - }else if(Math.abs(relative) < this.rules.ok){ - for(var j = this.currentCircle; j < i; j++){ - var circle = circles[j] - if(circle && (!circle.branch || circle.branch.active)){ - skipNote(circles[j]) - } - } - this.currentCircle = i - break - } - } - } - } - var branches = this.songData.branches if(branches){ var force = this.controller.multiplayer === 2 ? p2 : this @@ -235,6 +193,52 @@ class Game{ } } } + fixNoteStream(keysDon){ + var circleIsNote = circle => { + var type = circle.type + return type === "don" || type === "ka" || type === "daiDon" || type === "daiKa" + } + var correctNote = circle => { + var type = circle.type + return keysDon ? (type === "don" || type === "daiDon") : (type === "ka" || type === "daiKa") + } + var ms = this.elapsedTime + var circles = this.songData.circles + + for(var i = this.currentCircle + 1; i < circles.length; i++){ + var circle = circles[i] + var relative = ms - circle.ms + if(!circle.branch || circle.branch.active){ + if((!circleIsNote(circle) || relative < -this.rules.bad)){ + break + }else if(Math.abs(relative) < this.rules.ok && correctNote(circle)){ + for(var j = this.currentCircle; j < i; j++){ + var circle = circles[j] + if(circle && !circle.branch || circle.branch.active){ + this.skipNote(circles[j]) + } + } + this.currentCircle = i + return circles[i] + } + } + } + } + skipNote(circle){ + if(circle.section){ + this.resetSection() + } + circle.played(-1, circle.type === "daiDon" || circle.type === "daiKa") + this.sectionNotes.push(0) + this.controller.displayScore(0, true) + this.updateCombo(0) + this.updateGlobalScore(0, 1) + if(this.controller.multiplayer === 1){ + p2.send("note", { + score: -1 + }) + } + } checkPlays(){ var circles = this.songData.circles var circle = circles[this.currentCircle] @@ -305,6 +309,13 @@ class Game{ var currentTime = keysDon ? keyTime["don"] : keyTime["ka"] var relative = currentTime - circle.ms + if(relative >= this.rules.ok){ + var fixedNote = this.fixNoteStream(keysDon) + if(fixedNote){ + return this.checkScore(fixedNote, check) + } + } + if(typeDon || typeKa){ if(-this.rules.bad >= relative || relative >= this.rules.bad){ return true