From 29a4d154b363e153ff836d625e380f807059d762 Mon Sep 17 00:00:00 2001 From: LoveEevee Date: Sun, 24 Feb 2019 15:04:14 +0300 Subject: [PATCH] Game: Fix notelocking - Will not skip the note if `ka` was pressed right before `don` note or `don` was pressed right before `ka` note - Will still skip the note if `don` and `ka` is pressed at the same time (within 25ms) - Fixed `TAIKOWEBSKIN:` in imported songs crashing the game with some values --- public/src/js/controller.js | 2 +- public/src/js/game.js | 107 ++++++++++++++++++++++++++---------- public/src/js/mekadon.js | 8 +-- public/src/js/parseosu.js | 3 +- public/src/js/view.js | 11 ++-- 5 files changed, 93 insertions(+), 38 deletions(-) diff --git a/public/src/js/controller.js b/public/src/js/controller.js index d161d83..1c33b39 100644 --- a/public/src/js/controller.js +++ b/public/src/js/controller.js @@ -220,7 +220,7 @@ class Controller{ if(this.multiplayer){ p2.play(circle, this.mekadon) }else{ - this.mekadon.play(circle) + return this.mekadon.play(circle) } } clean(){ diff --git a/public/src/js/game.js b/public/src/js/game.js index 3f0845b..f612ed2 100644 --- a/public/src/js/game.js +++ b/public/src/js/game.js @@ -75,6 +75,23 @@ class Game{ var circles = this.songData.circles 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){ @@ -115,21 +132,8 @@ class Game{ p2.send("drumroll", value) } }else{ - if(circle.section){ - this.resetSection() - } - var currentScore = 0 - circle.played(-1, type === "daiDon" || type === "daiKa") - this.sectionNotes.push(0) - this.controller.displayScore(currentScore, true) + skipNote(circle) this.updateCurrentCircle() - this.updateCombo(currentScore) - this.updateGlobalScore(currentScore, 1) - if(this.controller.multiplayer === 1){ - p2.send("note", { - score: -1 - }) - } } } }else if(!this.controller.autoPlayEnabled && !nextSet){ @@ -141,6 +145,33 @@ 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 @@ -208,8 +239,11 @@ class Game{ var circles = this.songData.circles var circle = circles[this.currentCircle] - if(circle && this.controller.autoPlayEnabled){ - return this.controller.autoPlay(circle) + if(this.controller.autoPlayEnabled){ + while(circle && this.controller.autoPlay(circle)){ + circle = circles[this.currentCircle] + } + return } var keys = this.controller.getKeys() var kbd = this.controller.getBindings() @@ -219,19 +253,31 @@ class Game{ var ka_l = keys[kbd["ka_l"]] && !this.controller.isWaiting(kbd["ka_l"], "score") var ka_r = keys[kbd["ka_r"]] && !this.controller.isWaiting(kbd["ka_r"], "score") - if(don_l && don_r){ - this.checkKey([kbd["don_l"], kbd["don_r"]], circle, "daiDon") - }else if(don_l){ - this.checkKey([kbd["don_l"]], circle, "don") - }else if(don_r){ - this.checkKey([kbd["don_r"]], circle, "don") + var checkDon = () => { + if(don_l && don_r){ + this.checkKey([kbd["don_l"], kbd["don_r"]], circle, "daiDon") + }else if(don_l){ + this.checkKey([kbd["don_l"]], circle, "don") + }else if(don_r){ + this.checkKey([kbd["don_r"]], circle, "don") + } } - if(ka_l && ka_r){ - this.checkKey([kbd["ka_l"], kbd["ka_r"]], circle, "daiKa") - }else if(ka_l){ - this.checkKey([kbd["ka_l"]], circle, "ka") - }else if(ka_r){ - this.checkKey([kbd["ka_r"]], circle, "ka") + var checkKa = () => { + if(ka_l && ka_r){ + this.checkKey([kbd["ka_l"], kbd["ka_r"]], circle, "daiKa") + }else if(ka_l){ + this.checkKey([kbd["ka_l"]], circle, "ka") + }else if(ka_r){ + this.checkKey([kbd["ka_r"]], circle, "ka") + } + } + var keyTime = this.controller.getKeyTime() + if(keyTime["don"] >= keyTime["ka"]){ + checkDon() + checkKa() + }else{ + checkKa() + checkDon() } } checkKey(keyCodes, circle, check){ @@ -288,6 +334,11 @@ class Game{ circle.played(score, score === 0 ? typeDai : keyDai) this.controller.displayScore(score, false, typeDai && keyDai) }else{ + var keyTime = this.controller.getKeyTime() + var keyTimeRelative = Math.abs(keyTime.don - keyTime.ka) + if(Math.abs(relative) >= (keyTimeRelative <= 25 ? this.rules.bad : this.rules.good)){ + return true + } circle.played(-1, typeDai) this.controller.displayScore(score, true, false) } diff --git a/public/src/js/mekadon.js b/public/src/js/mekadon.js index 962b9ff..fe63d71 100644 --- a/public/src/js/mekadon.js +++ b/public/src/js/mekadon.js @@ -16,11 +16,11 @@ class Mekadon{ } type = circle.type if(type === "balloon"){ - this.playDrumrollAt(circle, 0, 30) + return this.playDrumrollAt(circle, 0, 30) }else if(type === "drumroll" || type === "daiDrumroll"){ - this.playDrumrollAt(circle, 0, 60) + return this.playDrumrollAt(circle, 0, 60) }else{ - this.playAt(circle, 0, 450) + return this.playAt(circle, 0, 450) } } playAt(circle, ms, score, dai, reverse){ @@ -35,7 +35,7 @@ class Mekadon{ if(kaAmount > 0){ score = Math.random() > kaAmount ? 1 : 2 } - this.playAt(circle, ms, score) + return this.playAt(circle, ms, score) } } miss(circle){ diff --git a/public/src/js/parseosu.js b/public/src/js/parseosu.js index 336bc70..b8d94e2 100644 --- a/public/src/js/parseosu.js +++ b/public/src/js/parseosu.js @@ -181,7 +181,8 @@ class ParseOsu{ measures.push({ ms: ms, originalMS: ms, - speed: speed + speed: speed, + visible: true }) } } diff --git a/public/src/js/view.js b/public/src/js/view.js index a50bf13..211b0bd 100644 --- a/public/src/js/view.js +++ b/public/src/js/view.js @@ -1100,7 +1100,7 @@ var songSkinName = selectedSong.songSkin.name var supportsBlend = "mixBlendMode" in this.songBg.style var songLayers = [document.getElementById("layer1"), document.getElementById("layer2")] - var prefix = selectedSong.songSkin.prefix || "" + var prefix = "" if(selectedSong.category in this.categories){ var catId = this.categories[selectedSong.category].sort @@ -1111,8 +1111,9 @@ if(!selectedSong.songSkin.song){ var id = selectedSong.songBg this.songBg.classList.add("songbg-" + id) - this.setLayers(songLayers, prefix + "bg_song_" + id + (supportsBlend ? "" : "a"), supportsBlend) + this.setLayers(songLayers, "bg_song_" + id + (supportsBlend ? "" : "a"), supportsBlend) }else if(selectedSong.songSkin.song !== "none"){ + var prefix = selectedSong.songSkin.prefix || "" var notStatic = selectedSong.songSkin.song !== "static" if(notStatic){ this.songBg.classList.add("songbg-" + selectedSong.songSkin.song) @@ -1123,6 +1124,7 @@ if(!selectedSong.songSkin.stage){ this.songStage.classList.add("song-stage-" + selectedSong.songStage) }else if(selectedSong.songSkin.stage !== "none"){ + var prefix = selectedSong.songSkin.prefix || "" this.setBgImage(this.songStage, assets.image[prefix + "bg_stage_" + songSkinName].src) } } @@ -1131,7 +1133,7 @@ var songSkinName = selectedSong.songSkin.name var donLayers = [] var filename = !selectedSong.songSkin.don && this.multiplayer === 2 ? "bg_don2_" : "bg_don_" - var prefix = selectedSong.songSkin.prefix || "" + var prefix = "" this.donBg = document.createElement("div") this.donBg.classList.add("donbg") @@ -1150,10 +1152,11 @@ var asset1, asset2 if(!selectedSong.songSkin.don){ this.donBg.classList.add("donbg-" + selectedSong.donBg) - this.setLayers(donLayers, prefix + filename + selectedSong.donBg, true) + this.setLayers(donLayers, filename + selectedSong.donBg, true) asset1 = filename + selectedSong.donBg + "a" asset2 = filename + selectedSong.donBg + "b" }else if(selectedSong.songSkin.don !== "none"){ + var prefix = selectedSong.songSkin.prefix || "" var notStatic = selectedSong.songSkin.don !== "static" if(notStatic){ this.donBg.classList.add("donbg-" + selectedSong.songSkin.don)