mirror of
https://framagit.org/JonathanMM/sutom.git
synced 2024-05-21 15:16:38 +02:00
Correction dans les stats à l'initialisation
This commit is contained in:
parent
965404a51c
commit
8bb4d7139d
|
@ -2,7 +2,7 @@ export default class SauvegardeStats {
|
|||
public static Default: SauvegardeStats = {
|
||||
partiesJouees: 0,
|
||||
partiesGagnees: 0,
|
||||
dernierePartie: new Date(),
|
||||
dernierePartie: null,
|
||||
repartition: {
|
||||
1: 0,
|
||||
2: 0,
|
||||
|
@ -19,7 +19,7 @@ export default class SauvegardeStats {
|
|||
},
|
||||
};
|
||||
|
||||
dernierePartie: Date = new Date();
|
||||
dernierePartie: Date | null = null;
|
||||
partiesJouees: number = 0;
|
||||
partiesGagnees: number = 0;
|
||||
repartition: {
|
||||
|
|
|
@ -114,6 +114,7 @@ export default class Gestionnaire {
|
|||
// On regarde si c'est le même jour que la dernière partie dans les stats.
|
||||
// Si c'est identique, on ne sauvegarde pas
|
||||
if (
|
||||
this._stats.dernierePartie &&
|
||||
this._stats.dernierePartie.getFullYear() === this._datePartieEnCours.getFullYear() &&
|
||||
this._stats.dernierePartie.getMonth() === this._datePartieEnCours.getMonth() &&
|
||||
this._stats.dernierePartie.getDate() === this._datePartieEnCours.getDate()
|
||||
|
|
|
@ -33,6 +33,7 @@ export default class Sauvegardeur {
|
|||
if (!dataStats) return;
|
||||
|
||||
let stats = JSON.parse(dataStats) as SauvegardeStats;
|
||||
if (stats.dernierePartie !== null) stats.dernierePartie = new Date(stats.dernierePartie);
|
||||
return stats;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue