from .helpers import osuButtons class ReplayFrame: delta = 0 # Int x = 0.0 # Float y = 0.0 # Float buttons = 0 # Int def __init__(self, delta, x, y, buttons): self.set_delta(delta) self.set_position(x, y) self.set_buttons(buttons) def set_delta(self, delta): if type(delta) is not int: raise Exception("Delta is not type of int") self.delta = delta def set_position(self, x, y): self.x = x self.y = y def set_buttons(self, buttons): if buttons < 0 or buttons > (1 << 5) - 1: raise Exception("Buttons are out of range") self.buttons = buttons @staticmethod def _float_convert(f): if f % 1 == 0: return repr(int(f)) return repr(round(f, 1)) def __str__(self): return "%d|%s|%s|%d," % (self.delta, self._float_convert(self.x), self._float_convert(self.y), self.buttons) def __bytes__(self): return str(self).encode()