2018-09-15 22:34:53 +08:00
|
|
|
class Game{
|
|
|
|
constructor(controller, selectedSong, songData){
|
|
|
|
this.controller = controller
|
|
|
|
this.selectedSong = selectedSong
|
|
|
|
this.songData = songData
|
2018-10-12 04:24:18 +08:00
|
|
|
this.elapsedTime = 0
|
2018-09-15 22:34:53 +08:00
|
|
|
this.currentCircle = 0
|
|
|
|
this.combo = 0
|
2018-10-01 15:33:43 +08:00
|
|
|
this.rules = new GameRules(this)
|
2018-09-15 22:34:53 +08:00
|
|
|
this.globalScore = {
|
|
|
|
points: 0,
|
|
|
|
good: 0,
|
2018-10-01 15:33:43 +08:00
|
|
|
ok: 0,
|
|
|
|
bad: 0,
|
2018-09-15 22:34:53 +08:00
|
|
|
maxCombo: 0,
|
2018-09-16 01:27:53 +08:00
|
|
|
drumroll: 0,
|
2018-10-01 15:33:43 +08:00
|
|
|
gauge: 0,
|
|
|
|
title: selectedSong.title,
|
|
|
|
difficulty: this.rules.difficulty
|
2018-09-15 22:34:53 +08:00
|
|
|
}
|
|
|
|
this.HPGain = 100 / this.songData.circles.filter(circle => {
|
|
|
|
var type = circle.getType()
|
2018-09-21 02:30:49 +08:00
|
|
|
return type === "don" || type === "ka" || type === "daiDon" || type === "daiKa"
|
2018-09-15 22:34:53 +08:00
|
|
|
}).length
|
|
|
|
this.paused = false
|
|
|
|
this.started = false
|
|
|
|
this.mainMusicPlaying = false
|
|
|
|
this.musicFadeOut = 0
|
|
|
|
this.fadeOutStarted = false
|
|
|
|
this.currentTimingPoint = 0
|
2018-09-22 04:31:35 +08:00
|
|
|
|
2018-09-15 22:34:53 +08:00
|
|
|
assets.songs.forEach(song => {
|
|
|
|
if(song.id == selectedSong.folder){
|
|
|
|
this.mainAsset = song.sound
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
run(){
|
|
|
|
this.timeForDistanceCircle = 2500
|
|
|
|
this.initTiming()
|
2018-10-12 04:24:18 +08:00
|
|
|
this.view = this.controller.view
|
2018-09-15 22:34:53 +08:00
|
|
|
}
|
|
|
|
initTiming(){
|
|
|
|
// Date when the chrono is started (before the game begins)
|
2018-10-03 17:48:18 +08:00
|
|
|
var offsetTime = Math.max(0, this.timeForDistanceCircle - this.songData.circles[0].ms) |0
|
|
|
|
this.elapsedTime = -offsetTime
|
2018-09-15 22:34:53 +08:00
|
|
|
// The real start for the game will start when chrono will reach 0
|
2018-10-03 22:22:40 +08:00
|
|
|
this.startDate = +(new Date) + offsetTime
|
2018-09-15 22:34:53 +08:00
|
|
|
}
|
|
|
|
update(){
|
|
|
|
// Main operations
|
|
|
|
this.updateTime()
|
|
|
|
this.updateCirclesStatus()
|
|
|
|
this.checkPlays()
|
|
|
|
// Event operations
|
|
|
|
this.whenFadeoutMusic()
|
|
|
|
this.whenLastCirclePlayed()
|
|
|
|
}
|
|
|
|
getCircles(){
|
|
|
|
return this.songData.circles
|
|
|
|
}
|
|
|
|
updateCirclesStatus(){
|
2018-10-15 06:00:40 +08:00
|
|
|
var nextSet = false
|
2018-09-15 22:34:53 +08:00
|
|
|
var circles = this.songData.circles
|
2018-10-15 06:00:40 +08:00
|
|
|
for(var i in circles){
|
|
|
|
var circle = circles[i]
|
2018-09-15 22:34:53 +08:00
|
|
|
if(!circle.getPlayed()){
|
2018-10-03 17:48:18 +08:00
|
|
|
var ms = this.elapsedTime
|
2018-09-15 22:34:53 +08:00
|
|
|
var type = circle.getType()
|
2018-09-19 01:33:18 +08:00
|
|
|
var drumrollNotes = type === "balloon" || type === "drumroll" || type === "daiDrumroll"
|
2018-09-22 04:31:35 +08:00
|
|
|
var endTime = circle.getEndTime() + (drumrollNotes ? 0 : this.rules.bad)
|
2018-09-15 22:34:53 +08:00
|
|
|
|
2018-09-22 04:31:35 +08:00
|
|
|
if(ms >= circle.getMS()){
|
2018-10-15 07:18:01 +08:00
|
|
|
if(drumrollNotes && !circle.rendaPlayed && ms < endTime){
|
2018-09-22 04:31:35 +08:00
|
|
|
circle.rendaPlayed = true
|
|
|
|
if(this.rules.difficulty === "easy"){
|
2018-10-03 17:48:18 +08:00
|
|
|
assets.sounds["renda" + this.controller.snd].stop()
|
|
|
|
this.controller.playSound("renda")
|
2018-09-19 01:33:18 +08:00
|
|
|
}
|
2018-09-15 22:34:53 +08:00
|
|
|
}
|
2018-10-12 04:24:18 +08:00
|
|
|
if(!circle.beatMSCopied){
|
|
|
|
if(this.view.beatInterval !== circle.beatMS){
|
|
|
|
this.view.changeBeatInterval(circle.beatMS)
|
|
|
|
}
|
|
|
|
circle.beatMSCopied = true
|
|
|
|
}
|
2018-09-22 04:31:35 +08:00
|
|
|
}
|
|
|
|
if(ms > endTime){
|
2018-09-21 02:30:49 +08:00
|
|
|
if(!this.controller.autoPlayEnabled){
|
|
|
|
if(drumrollNotes){
|
2018-09-22 04:31:35 +08:00
|
|
|
circle.played(-1, false)
|
2018-09-21 02:30:49 +08:00
|
|
|
this.updateCurrentCircle()
|
|
|
|
if(this.controller.multiplayer === 1){
|
|
|
|
p2.send("drumroll", {
|
2018-09-22 04:31:35 +08:00
|
|
|
pace: (ms - circle.getMS()) / circle.timesHit
|
2018-09-21 02:30:49 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}else{
|
2018-09-15 22:34:53 +08:00
|
|
|
var currentScore = 0
|
2018-09-22 04:31:35 +08:00
|
|
|
circle.played(-1, type === "daiDon" || type === "daiKa")
|
2018-09-15 22:34:53 +08:00
|
|
|
this.controller.displayScore(currentScore, true)
|
|
|
|
this.updateCurrentCircle()
|
|
|
|
this.updateCombo(currentScore)
|
2018-09-19 01:33:18 +08:00
|
|
|
this.updateGlobalScore(currentScore, 1)
|
2018-09-21 02:30:49 +08:00
|
|
|
if(this.controller.multiplayer === 1){
|
|
|
|
p2.send("note", {
|
|
|
|
score: -1
|
|
|
|
})
|
|
|
|
}
|
2018-09-15 22:34:53 +08:00
|
|
|
}
|
|
|
|
}
|
2018-10-15 07:18:01 +08:00
|
|
|
}else if(!this.controller.autoPlayEnabled && !nextSet){
|
|
|
|
nextSet = true
|
|
|
|
this.currentCircle = i
|
2018-09-15 22:34:53 +08:00
|
|
|
}
|
|
|
|
}
|
2018-10-15 06:00:40 +08:00
|
|
|
}
|
2018-09-15 22:34:53 +08:00
|
|
|
}
|
|
|
|
setHPGain(gain){
|
|
|
|
this.HPGain = gain
|
|
|
|
}
|
|
|
|
checkPlays(){
|
|
|
|
var circles = this.songData.circles
|
|
|
|
var circle = circles[this.currentCircle]
|
|
|
|
|
|
|
|
if(circle && this.controller.autoPlayEnabled){
|
|
|
|
return this.controller.autoPlay(circle)
|
|
|
|
}
|
|
|
|
var keys = this.controller.getKeys()
|
|
|
|
var kbd = this.controller.getBindings()
|
2018-09-19 01:33:18 +08:00
|
|
|
|
|
|
|
var don_l = keys[kbd["don_l"]] && !this.controller.isWaiting(kbd["don_l"], "score")
|
|
|
|
var don_r = keys[kbd["don_r"]] && !this.controller.isWaiting(kbd["don_r"], "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")
|
|
|
|
|
|
|
|
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")
|
2018-09-15 22:34:53 +08:00
|
|
|
}
|
2018-09-19 01:33:18 +08:00
|
|
|
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")
|
2018-09-15 22:34:53 +08:00
|
|
|
}
|
|
|
|
}
|
2018-09-19 01:33:18 +08:00
|
|
|
checkKey(keyCodes, circle, check){
|
2018-09-22 04:31:35 +08:00
|
|
|
if(circle && !circle.getPlayed()){
|
2018-09-19 01:33:18 +08:00
|
|
|
if(!this.checkScore(circle, check)){
|
|
|
|
return
|
2018-09-15 22:34:53 +08:00
|
|
|
}
|
|
|
|
}
|
2018-09-19 01:33:18 +08:00
|
|
|
keyCodes.forEach(keyCode => {
|
|
|
|
this.controller.waitForKeyup(keyCode, "score")
|
|
|
|
})
|
2018-09-15 22:34:53 +08:00
|
|
|
}
|
2018-09-19 01:33:18 +08:00
|
|
|
checkScore(circle, check){
|
2018-10-03 17:48:18 +08:00
|
|
|
var ms = this.elapsedTime
|
2018-09-15 22:34:53 +08:00
|
|
|
var type = circle.getType()
|
2018-09-19 01:33:18 +08:00
|
|
|
|
|
|
|
var keysDon = check === "don" || check === "daiDon"
|
|
|
|
var keysKa = check === "ka" || check === "daiKa"
|
|
|
|
var keyDai = check === "daiDon" || check === "daiKa"
|
|
|
|
var typeDon = type === "don" || type === "daiDon"
|
|
|
|
var typeKa = type === "ka" || type === "daiKa"
|
|
|
|
var typeDai = type === "daiDon" || type === "daiKa"
|
2018-09-15 22:34:53 +08:00
|
|
|
|
2018-09-22 04:31:35 +08:00
|
|
|
var keyTime = this.controller.getKeyTime()
|
|
|
|
var currentTime = keysDon ? keyTime["don"] : keyTime["ka"]
|
|
|
|
var relative = currentTime - circle.getMS()
|
|
|
|
|
2018-09-15 22:34:53 +08:00
|
|
|
if(typeDon || typeKa){
|
2018-09-22 04:31:35 +08:00
|
|
|
if(-this.rules.bad >= relative || relative >= this.rules.bad){
|
|
|
|
return true
|
|
|
|
}
|
2018-09-15 22:34:53 +08:00
|
|
|
var score = 0
|
|
|
|
if(keysDon && typeDon || keysKa && typeKa){
|
2018-09-19 01:33:18 +08:00
|
|
|
if(typeDai && !keyDai){
|
|
|
|
if(!circle.daiFailed){
|
|
|
|
circle.daiFailed = ms
|
|
|
|
return false
|
2018-09-22 04:31:35 +08:00
|
|
|
}else if(ms < circle.daiFailed + this.rules.daiLeniency){
|
2018-09-19 01:33:18 +08:00
|
|
|
return false
|
|
|
|
}
|
|
|
|
}
|
2018-09-22 04:31:35 +08:00
|
|
|
var circleStatus = -1
|
|
|
|
relative = Math.abs(relative)
|
|
|
|
if(relative < this.rules.good){
|
|
|
|
circleStatus = 450
|
|
|
|
}else if(relative < this.rules.ok){
|
|
|
|
circleStatus = 230
|
|
|
|
}else if(relative < this.rules.bad){
|
|
|
|
circleStatus = 0
|
|
|
|
}
|
2018-09-19 01:33:18 +08:00
|
|
|
if(circleStatus === 230 || circleStatus === 450){
|
2018-09-15 22:34:53 +08:00
|
|
|
score = circleStatus
|
|
|
|
}
|
|
|
|
this.controller.displayScore(score)
|
|
|
|
}else{
|
|
|
|
this.controller.displayScore(score, true)
|
|
|
|
}
|
|
|
|
this.updateCombo(score)
|
2018-09-20 07:20:26 +08:00
|
|
|
this.updateGlobalScore(score, typeDai && keyDai ? 2 : 1, circle.gogoTime)
|
2018-09-15 22:34:53 +08:00
|
|
|
this.updateCurrentCircle()
|
2018-09-20 07:20:26 +08:00
|
|
|
circle.played(score, score === 0 ? typeDai : keyDai)
|
2018-09-15 22:34:53 +08:00
|
|
|
if(this.controller.multiplayer == 1){
|
|
|
|
p2.send("note", {
|
|
|
|
score: score,
|
2018-09-22 04:31:35 +08:00
|
|
|
ms: circle.getMS() - currentTime,
|
2018-09-19 01:33:18 +08:00
|
|
|
dai: typeDai ? keyDai ? 2 : 1 : 0
|
2018-09-15 22:34:53 +08:00
|
|
|
})
|
|
|
|
}
|
2018-09-22 04:31:35 +08:00
|
|
|
}else{
|
|
|
|
if(circle.getMS() > currentTime || currentTime > circle.getEndTime()){
|
|
|
|
return true
|
2018-09-19 01:33:18 +08:00
|
|
|
}
|
2018-09-22 04:31:35 +08:00
|
|
|
if(keysDon && type === "balloon"){
|
|
|
|
this.checkBalloon(circle)
|
|
|
|
if(check === "daiDon" && !circle.getPlayed()){
|
|
|
|
this.checkBalloon(circle)
|
|
|
|
}
|
|
|
|
}else if((keysDon || keysKa) && (type === "drumroll" || type === "daiDrumroll")){
|
2018-09-19 01:33:18 +08:00
|
|
|
this.checkDrumroll(circle)
|
2018-09-22 04:31:35 +08:00
|
|
|
if(keyDai){
|
|
|
|
this.checkDrumroll(circle)
|
|
|
|
}
|
2018-09-19 01:33:18 +08:00
|
|
|
}
|
2018-09-15 22:34:53 +08:00
|
|
|
}
|
2018-09-19 01:33:18 +08:00
|
|
|
return true
|
2018-09-15 22:34:53 +08:00
|
|
|
}
|
|
|
|
checkBalloon(circle){
|
|
|
|
if(circle.timesHit >= circle.requiredHits - 1){
|
|
|
|
var score = 5000
|
|
|
|
this.updateCurrentCircle()
|
|
|
|
circle.hit()
|
|
|
|
circle.played(score)
|
|
|
|
if(this.controller.multiplayer == 1){
|
|
|
|
p2.send("drumroll", {
|
2018-10-03 17:48:18 +08:00
|
|
|
pace: (this.elapsedTime - circle.getMS()) / circle.timesHit
|
2018-09-15 22:34:53 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
var score = 300
|
|
|
|
circle.hit()
|
|
|
|
}
|
2018-09-16 01:27:53 +08:00
|
|
|
this.globalScore.drumroll ++
|
2018-09-15 22:34:53 +08:00
|
|
|
this.globalScore.points += score
|
|
|
|
}
|
|
|
|
checkDrumroll(circle){
|
2018-10-08 02:58:42 +08:00
|
|
|
var ms = this.elapsedTime
|
2018-09-19 01:33:18 +08:00
|
|
|
var dai = circle.getType() === "daiDrumroll"
|
2018-09-15 22:34:53 +08:00
|
|
|
var score = 100
|
|
|
|
circle.hit()
|
|
|
|
var keyTime = this.controller.getKeyTime()
|
2018-09-19 01:33:18 +08:00
|
|
|
if(circle.getType() === "drumroll"){
|
2018-09-15 22:34:53 +08:00
|
|
|
var sound = keyTime["don"] > keyTime["ka"] ? "don" : "ka"
|
|
|
|
}else{
|
|
|
|
var sound = keyTime["don"] > keyTime["ka"] ? "daiDon" : "daiKa"
|
|
|
|
}
|
2018-09-20 07:20:26 +08:00
|
|
|
var circleAnim = new Circle({
|
|
|
|
id: 0,
|
2018-10-08 02:58:42 +08:00
|
|
|
start: ms,
|
2018-09-20 07:20:26 +08:00
|
|
|
type: sound,
|
|
|
|
txt: "",
|
|
|
|
speed: circle.speed,
|
|
|
|
gogoTime: circle.gogoTime
|
|
|
|
})
|
2018-09-19 01:33:18 +08:00
|
|
|
circleAnim.played(score, dai)
|
2018-10-08 02:58:42 +08:00
|
|
|
circleAnim.animate(ms)
|
2018-10-12 04:24:18 +08:00
|
|
|
this.view.drumroll.push(circleAnim)
|
2018-09-19 01:33:18 +08:00
|
|
|
this.globalScore.drumroll++
|
|
|
|
this.globalScore.points += score * (dai ? 2 : 1)
|
2018-09-15 22:34:53 +08:00
|
|
|
}
|
|
|
|
whenLastCirclePlayed(){
|
|
|
|
var circles = this.songData.circles
|
2018-09-20 07:20:26 +08:00
|
|
|
var lastCircle = circles[circles.length - 1]
|
2018-10-03 17:48:18 +08:00
|
|
|
var ms = this.elapsedTime
|
2018-09-22 04:31:35 +08:00
|
|
|
if(!this.fadeOutStarted && ms >= lastCircle.getEndTime() + 2000){
|
2018-09-18 06:37:59 +08:00
|
|
|
this.fadeOutStarted = ms
|
2018-09-15 22:34:53 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
whenFadeoutMusic(){
|
2018-09-18 06:37:59 +08:00
|
|
|
var started = this.fadeOutStarted
|
|
|
|
if(started){
|
2018-10-03 17:48:18 +08:00
|
|
|
var ms = this.elapsedTime
|
2018-10-11 06:13:24 +08:00
|
|
|
var musicDuration = this.controller.mainAsset.duration * 1000 - this.controller.offset
|
2018-09-18 06:37:59 +08:00
|
|
|
if(this.musicFadeOut === 0){
|
|
|
|
if(this.controller.multiplayer === 1){
|
2018-09-26 08:26:42 +08:00
|
|
|
p2.send("gameresults", this.getGlobalScore())
|
2018-09-15 22:34:53 +08:00
|
|
|
}
|
|
|
|
this.musicFadeOut++
|
2018-09-18 06:37:59 +08:00
|
|
|
}else if(this.musicFadeOut === 1 && ms >= started + 1600){
|
|
|
|
this.controller.gameEnded()
|
2018-09-15 22:34:53 +08:00
|
|
|
p2.send("gameend")
|
2018-09-18 06:37:59 +08:00
|
|
|
this.musicFadeOut++
|
2018-10-11 06:13:24 +08:00
|
|
|
}else if(this.musicFadeOut === 2 && (ms >= started + 8600 && ms >= musicDuration + 250)){
|
2018-09-18 06:37:59 +08:00
|
|
|
this.controller.displayResults()
|
2018-09-15 22:34:53 +08:00
|
|
|
this.musicFadeOut++
|
2018-10-11 06:13:24 +08:00
|
|
|
}else if(this.musicFadeOut === 3 && (ms >= started + 9600 && ms >= musicDuration + 1250)){
|
2018-10-06 01:03:59 +08:00
|
|
|
this.controller.clean()
|
2018-10-01 15:33:43 +08:00
|
|
|
if(this.controller.scoresheet){
|
|
|
|
this.controller.scoresheet.startRedraw()
|
|
|
|
}
|
2018-09-15 22:34:53 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
playMainMusic(){
|
2018-10-11 06:13:24 +08:00
|
|
|
var ms = this.elapsedTime + this.controller.offset
|
|
|
|
if(!this.mainMusicPlaying && (!this.fadeOutStarted || ms < this.fadeOutStarted + 1600)){
|
2018-09-19 01:33:18 +08:00
|
|
|
if(this.controller.multiplayer !== 2){
|
2018-09-15 22:34:53 +08:00
|
|
|
this.mainAsset.play((ms < 0 ? -ms : 0) / 1000, false, Math.max(0, ms / 1000))
|
|
|
|
}
|
|
|
|
this.mainMusicPlaying = true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
togglePause(){
|
|
|
|
if(!this.paused){
|
|
|
|
assets.sounds["pause"].play()
|
|
|
|
this.paused = true
|
2018-10-03 22:22:40 +08:00
|
|
|
this.latestDate = +new Date
|
2018-09-15 22:34:53 +08:00
|
|
|
this.mainAsset.stop()
|
|
|
|
this.mainMusicPlaying = false
|
|
|
|
}else{
|
|
|
|
assets.sounds["cancel"].play()
|
|
|
|
this.paused = false
|
2018-10-03 22:22:40 +08:00
|
|
|
var currentDate = +new Date
|
|
|
|
this.startDate += currentDate - this.latestDate
|
|
|
|
this.sndTime = currentDate - snd.buffer.getTime() * 1000
|
2018-09-15 22:34:53 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
isPaused(){
|
|
|
|
return this.paused
|
|
|
|
}
|
|
|
|
updateTime(){
|
|
|
|
// Refreshed date
|
2018-10-03 17:48:18 +08:00
|
|
|
var ms = this.elapsedTime
|
2018-09-15 22:34:53 +08:00
|
|
|
if(ms >= 0 && !this.started){
|
2018-10-03 22:22:40 +08:00
|
|
|
this.startDate = +new Date
|
2018-10-03 17:48:18 +08:00
|
|
|
this.elapsedTime = this.getAccurateTime()
|
2018-09-15 22:34:53 +08:00
|
|
|
this.started = true
|
2018-10-03 22:22:40 +08:00
|
|
|
this.sndTime = this.startDate - snd.buffer.getTime() * 1000
|
2018-09-15 22:34:53 +08:00
|
|
|
}else if(ms < 0 || ms >= 0 && this.started){
|
2018-10-06 15:23:36 +08:00
|
|
|
var currentDate = +new Date
|
|
|
|
if(!this.controller.touchEnabled){
|
|
|
|
var sndTime = currentDate - snd.buffer.getTime() * 1000
|
|
|
|
var lag = sndTime - this.sndTime
|
|
|
|
if(Math.abs(lag) >= 50){
|
|
|
|
this.startDate += lag
|
|
|
|
this.sndTime = sndTime
|
|
|
|
}
|
|
|
|
}
|
|
|
|
this.elapsedTime = currentDate - this.startDate
|
2018-09-15 22:34:53 +08:00
|
|
|
}
|
|
|
|
}
|
2018-09-22 04:31:35 +08:00
|
|
|
getAccurateTime(){
|
2018-09-27 05:12:50 +08:00
|
|
|
if(this.isPaused()){
|
2018-10-03 17:48:18 +08:00
|
|
|
return this.elapsedTime
|
2018-09-27 05:12:50 +08:00
|
|
|
}else{
|
2018-10-06 15:23:36 +08:00
|
|
|
return (+new Date) - this.startDate
|
2018-09-27 05:12:50 +08:00
|
|
|
}
|
2018-09-22 04:31:35 +08:00
|
|
|
}
|
2018-09-15 22:34:53 +08:00
|
|
|
getCircles(){
|
|
|
|
return this.songData.circles
|
|
|
|
}
|
|
|
|
updateCurrentCircle(){
|
|
|
|
this.currentCircle++
|
|
|
|
}
|
|
|
|
getCurrentCircle(){
|
|
|
|
return this.currentCircle
|
|
|
|
}
|
|
|
|
updateCombo(score){
|
2018-09-19 01:33:18 +08:00
|
|
|
if(score !== 0){
|
2018-09-15 22:34:53 +08:00
|
|
|
this.combo++
|
|
|
|
}else{
|
|
|
|
this.combo = 0
|
|
|
|
}
|
|
|
|
if(this.combo > this.globalScore.maxCombo){
|
|
|
|
this.globalScore.maxCombo = this.combo
|
|
|
|
}
|
2018-09-19 01:33:18 +08:00
|
|
|
if(this.combo === 50 || this.combo > 0 && this.combo % 100 === 0 && this.combo <= 1400){
|
2018-09-15 22:34:53 +08:00
|
|
|
this.controller.playSoundMeka("combo-" + this.combo)
|
|
|
|
}
|
2018-10-12 04:24:18 +08:00
|
|
|
this.view.updateCombo(this.combo)
|
2018-09-15 22:34:53 +08:00
|
|
|
}
|
|
|
|
getCombo(){
|
|
|
|
return this.combo
|
|
|
|
}
|
|
|
|
getGlobalScore(){
|
|
|
|
return this.globalScore
|
|
|
|
}
|
2018-09-20 07:20:26 +08:00
|
|
|
updateGlobalScore(score, multiplier, gogoTime){
|
2018-09-15 22:34:53 +08:00
|
|
|
// Circle score
|
|
|
|
switch(score){
|
|
|
|
case 450:
|
2018-10-01 15:33:43 +08:00
|
|
|
this.globalScore.good++
|
2018-09-15 22:34:53 +08:00
|
|
|
break
|
|
|
|
case 230:
|
2018-10-01 15:33:43 +08:00
|
|
|
this.globalScore.ok++
|
2018-09-15 22:34:53 +08:00
|
|
|
break
|
|
|
|
case 0:
|
2018-10-01 15:33:43 +08:00
|
|
|
this.globalScore.bad++
|
2018-09-15 22:34:53 +08:00
|
|
|
break
|
|
|
|
}
|
2018-10-01 15:33:43 +08:00
|
|
|
// Gauge update
|
2018-09-19 01:33:18 +08:00
|
|
|
if(score !== 0){
|
2018-10-01 15:33:43 +08:00
|
|
|
this.globalScore.gauge += this.HPGain
|
|
|
|
}else if(this.globalScore.gauge - this.HPGain > 0){
|
|
|
|
this.globalScore.gauge -= this.HPGain
|
2018-09-15 22:34:53 +08:00
|
|
|
}else{
|
2018-10-01 15:33:43 +08:00
|
|
|
this.globalScore.gauge = 0
|
2018-09-15 22:34:53 +08:00
|
|
|
}
|
|
|
|
// Points update
|
|
|
|
score += Math.max(0, Math.floor((Math.min(this.combo, 100) - 1) / 10) * 100)
|
|
|
|
|
2018-09-20 07:20:26 +08:00
|
|
|
if(gogoTime){
|
|
|
|
multiplier *= 1.2
|
|
|
|
}
|
|
|
|
this.globalScore.points += Math.floor(score * multiplier / 10) * 10
|
2018-09-15 22:34:53 +08:00
|
|
|
}
|
|
|
|
}
|