Skip to content

Commit

Permalink
feat(das): compute das average server side
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheeg committed Aug 24, 2024
1 parent 2d8bc2c commit 50b8657
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions modules/Game.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,9 @@ class Game {
onPiece(data) {
let cur_piece;

if (this.IS_CLASSIC_ROM) {
if (data.cur_piece !== null) {
cur_piece = data.cur_piece; // 💪
} else if (this.IS_CLASSIC_ROM) {
if (this.num_pieces === 0) {
cur_piece = PIECES.find(p => data[p]); // first truthy value is piece
} else {
Expand All @@ -389,9 +391,6 @@ class Game {
// record new state
this.num_pieces = this._getNumPieces(data);
PIECES.forEach(p => (this.data[p] = data[p]));
} else if (data.cur_piece_das !== null) {
cur_piece = data.cur_piece; // 💪
this.das_total += data.cur_piece_das;
} else {
cur_piece = this.prior_preview;
}
Expand All @@ -410,6 +409,10 @@ class Game {
this.num_droughts += 1;
}
}

if (data.cur_piece_das !== null) {
this.das_total += data.cur_piece_das;
}
}

getReport() {
Expand Down

0 comments on commit 50b8657

Please sign in to comment.