Time + fame backward compatible with previous 0.8.1
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user