30 lines
705 B
Python
30 lines
705 B
Python
|
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")
|
||
|
|
||
|
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
|
||
|
|
||
|
def __str__(self):
|
||
|
return "%s|%s|%s|%s," % (self.delta, self.x, self.y, self.buttons)
|
||
|
|
||
|
def __bytes__(self):
|
||
|
return str(self).encode()
|