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
+17 -3
View File
@@ -1,15 +1,29 @@
from dataclasses import dataclass
from ..event_receiver import FameEventReceiver
from .statistics import Stats
@dataclass
class FameStats(FameEventReceiver):
class FameStats(FameEventReceiver, Stats):
fame: float = 0.0
def __init__(self):
self.fame = 0.0
@classmethod
def new(self):
return FameStats()
@classmethod
def from_other(other: Stats):
return FameStats(fame=other.fame)
def update(self, other: Stats):
self.fame += other.fame
def on_fame_update(self, value: float):
self.fame += value
def stats(self):
return {
'fame': self.fame,
'fame_per_hour': 0.0 # TODO: remove, added because backward compatibility
}