Big update

This commit is contained in:
Daniel Ledda
2020-08-13 15:10:55 +02:00
parent 42b7560d6d
commit 5f747142e5
28 changed files with 310 additions and 179 deletions

View File

@@ -10,6 +10,7 @@ class AccountStats {
constructor(data: AccountStatsMongoData) {
this.data = data;
this.updater = new StatsUpdater();
this.updater.use(data);
}
use(data: AccountStatsMongoData) {
@@ -21,8 +22,8 @@ class AccountStats {
if (this.data) {
for (const playerGameResult of playerGameResults) {
this.updater.updateStats(playerGameResult, ruleset);
this.data.gamesPlayed += 1;
}
this.data.gamesPlayed += 1;
}
else {
throw new UpdateError(`Cannot update without data! Call the use() method to hydrate the updater with data