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
This commit is contained in:
LoveEevee 2019-02-24 15:04:14 +03:00
parent 1aecc7d52f
commit 29a4d154b3
5 changed files with 93 additions and 38 deletions

View File

@ -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(){

View File

@ -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,6 +253,7 @@ 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")
var checkDon = () => {
if(don_l && don_r){
this.checkKey([kbd["don_l"], kbd["don_r"]], circle, "daiDon")
}else if(don_l){
@ -226,6 +261,8 @@ class Game{
}else if(don_r){
this.checkKey([kbd["don_r"]], circle, "don")
}
}
var checkKa = () => {
if(ka_l && ka_r){
this.checkKey([kbd["ka_l"], kbd["ka_r"]], circle, "daiKa")
}else if(ka_l){
@ -234,6 +271,15 @@ class Game{
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){
if(circle && !circle.isPlayed){
if(!this.checkScore(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)
}

View File

@ -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){

View File

@ -181,7 +181,8 @@ class ParseOsu{
measures.push({
ms: ms,
originalMS: ms,
speed: speed
speed: speed,
visible: true
})
}
}

View File

@ -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)