back to back bonus

This commit is contained in:
Adrien MALINGREY 2020-11-09 02:44:58 +01:00
parent a161826a37
commit ccd85b6bd8

28
app.js
View File

@ -348,6 +348,7 @@ class Stats {
this.combo = -1 this.combo = -1
this.lockDelay = DELAY.LOCK this.lockDelay = DELAY.LOCK
this.fallPeriod = DELAY.FALL this.fallPeriod = DELAY.FALL
this.b2bSequence = false
} }
get score() { get score() {
@ -379,7 +380,8 @@ class Stats {
lockDown(tSpin, clearedLines) { lockDown(tSpin, clearedLines) {
var patternName = [] var patternName = []
var patternScore = 0 var patternScore = 0
var combo_score = 0 var b2bScore = 0
var comboScore = 0
if (tSpin) if (tSpin)
patternName.push(tSpin) patternName.push(tSpin)
@ -397,18 +399,30 @@ class Stats {
this.goalCell.innerText = this.goal this.goalCell.innerText = this.goal
patternName = patternName.join("\n") patternName = patternName.join("\n")
} }
if (this.combo >= 1)
combo_score = (clearedLines == 1 ? 20 : 50) * this.combo * this.level
if (patternScore || combo_score) if (this.b2bSequence) {
this.score += patternScore + combo_score if ((clearedLines == 4) || (tSpin && clearedLines)) {
b2bScore = patternScore / 2
} else if ((0 < clearedLines) && (clearedLines < 4) && !tSpin) {
this.b2bSequence = false
}
} else if ((clearedLines == 4) || (tSpin && clearedLines)) {
this.b2bSequence = true
}
if (this.combo >= 1)
comboScore = (clearedLines == 1 ? 20 : 50) * this.combo * this.level
if (patternScore) { if (patternScore) {
var messages = [patternName, patternScore] var messages = [patternName, patternScore]
if (combo_score) if (b2bScore)
messages.push(`COMBO x${this.combo}`, combo_score) messages.push(`BACK TO BACK BONUS`, b2bScore)
if (comboScore)
messages.push(`COMBO x${this.combo}`, comboScore)
printTempTexts(messages.join("<br/>")) printTempTexts(messages.join("<br/>"))
} }
this.score += patternScore + comboScore + b2bScore
} }
} }