Compare commits

..

No commits in common. "23541270e510b77157b501e36ad3527f4c4be248" and "acb0e336eefa3b18f1bf450858b3b74cdfdc7c78" have entirely different histories.

2 changed files with 17 additions and 40 deletions

51
app.js
View File

@ -17,7 +17,7 @@ const T_SPIN = {
T_SPIN: "T-SPIN" T_SPIN: "T-SPIN"
} }
// score = SCORES[tSpin][nbClearedLines] // score = SCORES[tSpin][clearedLines]
const SCORES = { const SCORES = {
[T_SPIN.NONE]: [0, 100, 300, 500, 800], [T_SPIN.NONE]: [0, 100, 300, 500, 800],
[T_SPIN.MINI]: [100, 200], [T_SPIN.MINI]: [100, 200],
@ -29,7 +29,7 @@ const CLEARED_LINES_NAMES = [
"SINGLE", "SINGLE",
"DOUBLE", "DOUBLE",
"TRIPLE", "TRIPLE",
"<h4>QUATRIS</h4>", "<strong>QUATRIS</strong>",
] ]
const DELAY = { const DELAY = {
@ -411,7 +411,6 @@ function changeKey(input) {
class Stats { class Stats {
constructor() { constructor() {
this.highScore = Number(localStorage["highScore"]) || 0 this.highScore = Number(localStorage["highScore"]) || 0
this.combo = -1
} }
set score(score) { set score(score) {
@ -461,36 +460,6 @@ class Stats {
get goal() { get goal() {
return this._goal return this._goal
} }
lockDown(nbClearedLines, tSpin) {
messagesSpan.innerHTML = ""
// Cleared lines & T-Spin
if (nbClearedLines || tSpin ) {
this.goal -= nbClearedLines
let patternScore = SCORES[tSpin][nbClearedLines] * this.level
this.score += patternScore
if (tSpin) messagesSpan.innerHTML += `<div class="rotate-in-animation">${tSpin}</div>\n`
if (nbClearedLines) messagesSpan.innerHTML += `<div class="zoom-in-animation">${CLEARED_LINES_NAMES[nbClearedLines]}</div>\n`
messagesSpan.innerHTML += `<div class="zoom-in-animation">${patternScore}</div>\n`
}
// Combo
if (nbClearedLines) {
this.combo++
if (this.combo >= 1) {
let comboScore = (nbClearedLines == 1 ? 20 : 50) * this.combo * this.level
this.score += comboScore
messagesSpan.innerHTML += `<div class="zoom-in-animation">COMBO x${this.combo}</div>\n`
messagesSpan.innerHTML += `<div class="zoom-in-animation">${comboScore}</div>\n`
}
} else {
this.combo = -1
}
if (this.goal <= 0) this.level++
}
} }
@ -695,8 +664,20 @@ function lockDown() {
matrix.lockedMinoes.unshift(Array(matrix.columns)) matrix.lockedMinoes.unshift(Array(matrix.columns))
matrix.table.rows[y].classList.add("line-cleared-animation") matrix.table.rows[y].classList.add("line-cleared-animation")
} }
matrix.redraw() let nbClearedLines = clearedLines.length
stats.lockDown(clearedLines.length, tSpin) if (nbClearedLines || tSpin) {
matrix.redraw()
stats.goal -= nbClearedLines
stats.score += SCORES[tSpin][nbClearedLines]
messagesSpan.innerHTML = ""
if (tSpin) messagesSpan.innerHTML += `<div class="rotate-in-animation">${tSpin}</div>\n`
if (nbClearedLines) messagesSpan.innerHTML += `<div class="zoom-in-animation">${CLEARED_LINES_NAMES[nbClearedLines]}</div>\n`
messagesSpan.innerHTML += `<div class="zoom-in-animation">${SCORES[tSpin][nbClearedLines]}</div>\n`
}
if (stats.goal <= 0) {
stats.level++
}
generate() generate()
} }

View File

@ -1,9 +1,5 @@
.mino { .mino {
background-image: radial-gradient( background: rgba(127, 229, 255, 0.3);
farthest-corner at 4px 6px,
rgba(204, 238, 247, 0.3) 0%,
rgba(106, 197, 220, 0.3) 100%
);
border: 1px solid rgba(127, 229, 255, 0.7); border: 1px solid rgba(127, 229, 255, 0.7);
border-radius: 0.3vmin; border-radius: 0.3vmin;
} }