mirror of
https://github.com/jiojciojsioe3/a3cjroijsiojiorj.git
synced 2024-11-15 15:31:51 +08: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){
|
||||
p2.play(circle, this.mekadon)
|
||||
}else{
|
||||
this.mekadon.play(circle)
|
||||
return this.mekadon.play(circle)
|
||||
}
|
||||
}
|
||||
clean(){
|
||||
|
@ -75,6 +75,7 @@ class Game{
|
||||
var circles = this.songData.circles
|
||||
var startIndex = this.currentCircle === 0 ? 0 : this.currentCircle - 1
|
||||
var index = 0
|
||||
|
||||
for(var i = startIndex; i < circles.length; i++){
|
||||
var circle = circles[i]
|
||||
if(circle && (!circle.branch || circle.branch.active) && !circle.isPlayed){
|
||||
@ -115,21 +116,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)
|
||||
this.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 +129,7 @@ class Game{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var branches = this.songData.branches
|
||||
if(branches){
|
||||
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(){
|
||||
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 +257,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 +265,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 +275,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)){
|
||||
@ -259,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
|
||||
@ -288,6 +345,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)
|
||||
}
|
||||
|
@ -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){
|
||||
|
@ -181,7 +181,8 @@ class ParseOsu{
|
||||
measures.push({
|
||||
ms: ms,
|
||||
originalMS: ms,
|
||||
speed: speed
|
||||
speed: speed,
|
||||
visible: true
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user