This repository has been archived on 2026-10-23. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
tetris/tetris-stats.js
2012-03-22 20:17:02 +01:00

37 lines
734 B
JavaScript

function TetrisStats() {
this.countBrickTypes = Array(8);
this.countLineCombosCleared = Array(5);
this.countLinesCleared = 0;
this.newBrick = function(brickId) {
if (brickId < 0 || brickId > 7) {
return false;
}
this.countBrickTypes[brickId]++;
return true;
}
this.linesCleared = function(amount) {
if (amount < 0 || amount > 4) {
return false;
}
this.countLineCombosCleared[amount]++;
this.countLinesCleared += amount;
return true;
}
this.TetrisStats = function() {
for (var i = 0; i < this.countBrickTypes.length; i++) {
this.countBrickTypes[i] = 0;
}
for (var i = 0; i < this.countLineCombosCleared.length; i++) {
this.countLineCombosCleared[i] = 0;
}
}
this.TetrisStats();
}