def test_clock_reset(self): clock = Clock(ticks=30) clock.reset() self.assertEqual(clock, Clock(ticks=0)) clock = Clock(default=10) for _ in range(5): clock.tock() clock.reset() self.assertEqual(clock, Clock(10))
class DurationBuff: def __init__(self, name, duration): self.name = name self.duration = Clock(default=duration) def is_exhausted(self): return self.duration.is_zero() def buff(self, target): pass def renew(self, new): self.duration.reset() def __str__(self): return self.name def __eq__(self, other): return str(self) == str(other) def __hash__(self): return hash(str(self))