Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | /**
* @classdesc Keep track of current player and scroes etc. of the player.
* @class
*/
export class CurrentPlayer {
/**
* Initalize a Player as current.
* @param {string} playerName Name of the player.
*/
constructor(playerName) {
this.name = playerName;
this.scores = {};
this.lastGame = '';
}
/**
*
* @param {string} level Passed lavel matrix.
* @param {string} lastScore Time elapsed for it.
*/
addScore(level, lastScore) {
this.lastGame = `${lastScore.strDiff}`;
level = `_${level}`;
this.scores[level] = this.scores[level] || [];
this.scores[level].push(lastScore);
this.scores[level].sort((first, second) => {
return first.timer.diff - second.timer.diff;
});
}
/**
* Prepares table.
* @deprecated Score table needs to be new consepted,
* which can be used for external settings panel.
* @return {string} Formatted table for the scores of currentPlayer.
*/
table() {
let tbl = '<table>';
Object.keys(this.scores).forEach((key) => {
const param = this.scores[key];
tbl += `<tr><td>${param.slice(1)}</td><td> </td></tr>`;
param.forEach((v) => {
tbl += `<tr><td> </td><td>${v.strDiff}</td></tr>`;
});
});
return tbl + '</table>';
}
}
|