Time + fame backward compatible with previous 0.8.1

This commit is contained in:
Wiktor Mazur
2020-03-02 21:53:07 +01:00
parent 6720adc78b
commit cffca90288
6 changed files with 131 additions and 36 deletions
+21 -4
View File
@@ -1,9 +1,26 @@
from dataclasses import field
from dataclasses import dataclass
from . import time_utils
from .statistics import Stats
class TimeStats:
def __init__(self):
self.time = time_utils.now()
@dataclass
class TimeStats(Stats):
time : float = field(default_factory=lambda: time_utils.now())
@classmethod
def new(self):
return TimeStats()
def stats(self):
return time_utils.delta(self.time)
return {
'seconds_in_game': time_utils.as_seconds(time_utils.delta(self.time))
}
@classmethod
def from_other(other):
return TimeStats(time=other.time)
def update(self, other):
self.time = other.time