mirror of
https://github.com/yuukiwww/taiko-web.git
synced 2024-08-26 12:35:48 +02:00
Merge pull request #138 from bui/game-fix-notelocking
Game: Fix notelocking
This commit is contained in:
commit
a9006e7ca2
@ -220,7 +220,7 @@ class Controller{
|
|||||||
if(this.multiplayer){
|
if(this.multiplayer){
|
||||||
p2.play(circle, this.mekadon)
|
p2.play(circle, this.mekadon)
|
||||||
}else{
|
}else{
|
||||||
this.mekadon.play(circle)
|
return this.mekadon.play(circle)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
clean(){
|
clean(){
|
||||||
|
@ -75,6 +75,7 @@ class Game{
|
|||||||
var circles = this.songData.circles
|
var circles = this.songData.circles
|
||||||
var startIndex = this.currentCircle === 0 ? 0 : this.currentCircle - 1
|
var startIndex = this.currentCircle === 0 ? 0 : this.currentCircle - 1
|
||||||
var index = 0
|
var index = 0
|
||||||
|
|
||||||
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){
|
||||||
@ -115,21 +116,8 @@ class Game{
|
|||||||
p2.send("drumroll", value)
|
p2.send("drumroll", value)
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if(circle.section){
|
this.skipNote(circle)
|
||||||
this.resetSection()
|
|
||||||
}
|
|
||||||
var currentScore = 0
|
|
||||||
circle.played(-1, type === "daiDon" || type === "daiKa")
|
|
||||||
this.sectionNotes.push(0)
|
|
||||||
this.controller.displayScore(currentScore, true)
|
|
||||||
this.updateCurrentCircle()
|
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){
|
}else if(!this.controller.autoPlayEnabled && !nextSet){
|
||||||
@ -141,6 +129,7 @@ class Game{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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
|
||||||
@ -204,12 +193,61 @@ 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]
|
||||||
|
|
||||||
if(circle && this.controller.autoPlayEnabled){
|
if(this.controller.autoPlayEnabled){
|
||||||
return this.controller.autoPlay(circle)
|
while(circle && this.controller.autoPlay(circle)){
|
||||||
|
circle = circles[this.currentCircle]
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
var keys = this.controller.getKeys()
|
var keys = this.controller.getKeys()
|
||||||
var kbd = this.controller.getBindings()
|
var kbd = this.controller.getBindings()
|
||||||
@ -219,19 +257,31 @@ class Game{
|
|||||||
var ka_l = keys[kbd["ka_l"]] && !this.controller.isWaiting(kbd["ka_l"], "score")
|
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 ka_r = keys[kbd["ka_r"]] && !this.controller.isWaiting(kbd["ka_r"], "score")
|
||||||
|
|
||||||
if(don_l && don_r){
|
var checkDon = () => {
|
||||||
this.checkKey([kbd["don_l"], kbd["don_r"]], circle, "daiDon")
|
if(don_l && don_r){
|
||||||
}else if(don_l){
|
this.checkKey([kbd["don_l"], kbd["don_r"]], circle, "daiDon")
|
||||||
this.checkKey([kbd["don_l"]], circle, "don")
|
}else if(don_l){
|
||||||
}else if(don_r){
|
this.checkKey([kbd["don_l"]], circle, "don")
|
||||||
this.checkKey([kbd["don_r"]], circle, "don")
|
}else if(don_r){
|
||||||
|
this.checkKey([kbd["don_r"]], circle, "don")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(ka_l && ka_r){
|
var checkKa = () => {
|
||||||
this.checkKey([kbd["ka_l"], kbd["ka_r"]], circle, "daiKa")
|
if(ka_l && ka_r){
|
||||||
}else if(ka_l){
|
this.checkKey([kbd["ka_l"], kbd["ka_r"]], circle, "daiKa")
|
||||||
this.checkKey([kbd["ka_l"]], circle, "ka")
|
}else if(ka_l){
|
||||||
}else if(ka_r){
|
this.checkKey([kbd["ka_l"]], circle, "ka")
|
||||||
this.checkKey([kbd["ka_r"]], 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){
|
checkKey(keyCodes, circle, check){
|
||||||
@ -259,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
|
||||||
@ -288,6 +345,11 @@ class Game{
|
|||||||
circle.played(score, score === 0 ? typeDai : keyDai)
|
circle.played(score, score === 0 ? typeDai : keyDai)
|
||||||
this.controller.displayScore(score, false, typeDai && keyDai)
|
this.controller.displayScore(score, false, typeDai && keyDai)
|
||||||
}else{
|
}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)
|
circle.played(-1, typeDai)
|
||||||
this.controller.displayScore(score, true, false)
|
this.controller.displayScore(score, true, false)
|
||||||
}
|
}
|
||||||
|
@ -16,11 +16,11 @@ class Mekadon{
|
|||||||
}
|
}
|
||||||
type = circle.type
|
type = circle.type
|
||||||
if(type === "balloon"){
|
if(type === "balloon"){
|
||||||
this.playDrumrollAt(circle, 0, 30)
|
return this.playDrumrollAt(circle, 0, 30)
|
||||||
}else if(type === "drumroll" || type === "daiDrumroll"){
|
}else if(type === "drumroll" || type === "daiDrumroll"){
|
||||||
this.playDrumrollAt(circle, 0, 60)
|
return this.playDrumrollAt(circle, 0, 60)
|
||||||
}else{
|
}else{
|
||||||
this.playAt(circle, 0, 450)
|
return this.playAt(circle, 0, 450)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
playAt(circle, ms, score, dai, reverse){
|
playAt(circle, ms, score, dai, reverse){
|
||||||
@ -35,7 +35,7 @@ class Mekadon{
|
|||||||
if(kaAmount > 0){
|
if(kaAmount > 0){
|
||||||
score = Math.random() > kaAmount ? 1 : 2
|
score = Math.random() > kaAmount ? 1 : 2
|
||||||
}
|
}
|
||||||
this.playAt(circle, ms, score)
|
return this.playAt(circle, ms, score)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
miss(circle){
|
miss(circle){
|
||||||
|
@ -181,7 +181,8 @@ class ParseOsu{
|
|||||||
measures.push({
|
measures.push({
|
||||||
ms: ms,
|
ms: ms,
|
||||||
originalMS: ms,
|
originalMS: ms,
|
||||||
speed: speed
|
speed: speed,
|
||||||
|
visible: true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1100,7 +1100,7 @@
|
|||||||
var songSkinName = selectedSong.songSkin.name
|
var songSkinName = selectedSong.songSkin.name
|
||||||
var supportsBlend = "mixBlendMode" in this.songBg.style
|
var supportsBlend = "mixBlendMode" in this.songBg.style
|
||||||
var songLayers = [document.getElementById("layer1"), document.getElementById("layer2")]
|
var songLayers = [document.getElementById("layer1"), document.getElementById("layer2")]
|
||||||
var prefix = selectedSong.songSkin.prefix || ""
|
var prefix = ""
|
||||||
|
|
||||||
if(selectedSong.category in this.categories){
|
if(selectedSong.category in this.categories){
|
||||||
var catId = this.categories[selectedSong.category].sort
|
var catId = this.categories[selectedSong.category].sort
|
||||||
@ -1111,8 +1111,9 @@
|
|||||||
if(!selectedSong.songSkin.song){
|
if(!selectedSong.songSkin.song){
|
||||||
var id = selectedSong.songBg
|
var id = selectedSong.songBg
|
||||||
this.songBg.classList.add("songbg-" + id)
|
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"){
|
}else if(selectedSong.songSkin.song !== "none"){
|
||||||
|
var prefix = selectedSong.songSkin.prefix || ""
|
||||||
var notStatic = selectedSong.songSkin.song !== "static"
|
var notStatic = selectedSong.songSkin.song !== "static"
|
||||||
if(notStatic){
|
if(notStatic){
|
||||||
this.songBg.classList.add("songbg-" + selectedSong.songSkin.song)
|
this.songBg.classList.add("songbg-" + selectedSong.songSkin.song)
|
||||||
@ -1123,6 +1124,7 @@
|
|||||||
if(!selectedSong.songSkin.stage){
|
if(!selectedSong.songSkin.stage){
|
||||||
this.songStage.classList.add("song-stage-" + selectedSong.songStage)
|
this.songStage.classList.add("song-stage-" + selectedSong.songStage)
|
||||||
}else if(selectedSong.songSkin.stage !== "none"){
|
}else if(selectedSong.songSkin.stage !== "none"){
|
||||||
|
var prefix = selectedSong.songSkin.prefix || ""
|
||||||
this.setBgImage(this.songStage, assets.image[prefix + "bg_stage_" + songSkinName].src)
|
this.setBgImage(this.songStage, assets.image[prefix + "bg_stage_" + songSkinName].src)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1131,7 +1133,7 @@
|
|||||||
var songSkinName = selectedSong.songSkin.name
|
var songSkinName = selectedSong.songSkin.name
|
||||||
var donLayers = []
|
var donLayers = []
|
||||||
var filename = !selectedSong.songSkin.don && this.multiplayer === 2 ? "bg_don2_" : "bg_don_"
|
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 = document.createElement("div")
|
||||||
this.donBg.classList.add("donbg")
|
this.donBg.classList.add("donbg")
|
||||||
@ -1150,10 +1152,11 @@
|
|||||||
var asset1, asset2
|
var asset1, asset2
|
||||||
if(!selectedSong.songSkin.don){
|
if(!selectedSong.songSkin.don){
|
||||||
this.donBg.classList.add("donbg-" + selectedSong.donBg)
|
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"
|
asset1 = filename + selectedSong.donBg + "a"
|
||||||
asset2 = filename + selectedSong.donBg + "b"
|
asset2 = filename + selectedSong.donBg + "b"
|
||||||
}else if(selectedSong.songSkin.don !== "none"){
|
}else if(selectedSong.songSkin.don !== "none"){
|
||||||
|
var prefix = selectedSong.songSkin.prefix || ""
|
||||||
var notStatic = selectedSong.songSkin.don !== "static"
|
var notStatic = selectedSong.songSkin.don !== "static"
|
||||||
if(notStatic){
|
if(notStatic){
|
||||||
this.donBg.classList.add("donbg-" + selectedSong.songSkin.don)
|
this.donBg.classList.add("donbg-" + selectedSong.songSkin.don)
|
||||||
|
Loading…
Reference in New Issue
Block a user