Fix note streams on key press

This commit is contained in:
LoveEevee 2019-02-24 18:13:41 +03:00
parent 29a4d154b3
commit fbbed1a714

View File

@ -76,22 +76,6 @@ class Game{
var startIndex = this.currentCircle === 0 ? 0 : this.currentCircle - 1 var startIndex = this.currentCircle === 0 ? 0 : this.currentCircle - 1
var index = 0 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++){ for(var i = startIndex; i < circles.length; i++){
var circle = circles[i] var circle = circles[i]
if(circle && (!circle.branch || circle.branch.active) && !circle.isPlayed){ if(circle && (!circle.branch || circle.branch.active) && !circle.isPlayed){
@ -132,7 +116,7 @@ class Game{
p2.send("drumroll", value) p2.send("drumroll", value)
} }
}else{ }else{
skipNote(circle) this.skipNote(circle)
this.updateCurrentCircle() 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 var branches = this.songData.branches
if(branches){ if(branches){
var force = this.controller.multiplayer === 2 ? p2 : this 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(){ checkPlays(){
var circles = this.songData.circles var circles = this.songData.circles
var circle = circles[this.currentCircle] var circle = circles[this.currentCircle]
@ -305,6 +309,13 @@ class Game{
var currentTime = keysDon ? keyTime["don"] : keyTime["ka"] var currentTime = keysDon ? keyTime["don"] : keyTime["ka"]
var relative = currentTime - circle.ms 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(typeDon || typeKa){
if(-this.rules.bad >= relative || relative >= this.rules.bad){ if(-this.rules.bad >= relative || relative >= this.rules.bad){
return true return true