README
This commit is contained in:
parent
204aed6b06
commit
8cfa8c7907
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -95,4 +95,4 @@ ENV/
|
||||||
.ropeproject
|
.ropeproject
|
||||||
|
|
||||||
# VSC
|
# VSC
|
||||||
.vscode/
|
.vscode/
|
||||||
|
|
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
|
@ -1,3 +0,0 @@
|
||||||
{
|
|
||||||
"python.linting.pylintEnabled": true
|
|
||||||
}
|
|
113
README.md
113
README.md
|
@ -1,3 +1,114 @@
|
||||||
# osu-repy
|
# osu-repy
|
||||||
|
osu! replay helper in python
|
||||||
|
|
||||||
python osu! replay helper
|
## Sample
|
||||||
|
```python
|
||||||
|
from osuRepy.frame import ReplayFrame # ReplayFrame
|
||||||
|
from osuRepy.replay import Replay # Replay instance
|
||||||
|
|
||||||
|
from osuRepy.helpers import osuButtons, osuMods # Enum helpers
|
||||||
|
|
||||||
|
replay = Replay() # Create replay instance
|
||||||
|
|
||||||
|
replay.write( ReplayFrame(2, 256, 192, osuButtons.M1) ) # Add replay frame (time, x, y, buttons)
|
||||||
|
|
||||||
|
replay.set_score(score = 29284624,
|
||||||
|
s300 = 416,
|
||||||
|
s50 = 2,
|
||||||
|
miss = 1,
|
||||||
|
combo = 358) # Set score info
|
||||||
|
|
||||||
|
replay.set_mods(osuMods.HIDDEN | osuMods.DOUBLETIME) # Enable HDDT mods
|
||||||
|
replay.set_timestamp(1552466941) # Set unix timestamp
|
||||||
|
|
||||||
|
replay.save("myReplay.osr") # Export replay to file
|
||||||
|
```
|
||||||
|
|
||||||
|
# Enums (from helpers)
|
||||||
|
### osuButtons
|
||||||
|
|Name|Value|
|
||||||
|
|-|-|
|
||||||
|
|NONE|0|
|
||||||
|
|LEFTMOUSE|1|
|
||||||
|
|RIGHTMOUSE|2|
|
||||||
|
|LEFTKEY|4|
|
||||||
|
|RIGHTKEY|8|
|
||||||
|
|SMOKE|16|
|
||||||
|
|M1|1|
|
||||||
|
|M2|2|
|
||||||
|
|K1|5|
|
||||||
|
|K2|10|
|
||||||
|
|
||||||
|
### osuModes
|
||||||
|
|Name|Value|
|
||||||
|
|-|-|
|
||||||
|
|STANDARD|0|
|
||||||
|
|TAIKO|1|
|
||||||
|
|CATCH_THE_BEAT|2|
|
||||||
|
|MANIA|3|
|
||||||
|
|
||||||
|
### osuMods
|
||||||
|
|Name|Value|
|
||||||
|
|-|-|
|
||||||
|
|NOMOD|0|
|
||||||
|
|NOFAIL|1|
|
||||||
|
|EASY|2|
|
||||||
|
|TOUCHSCREEN|4|
|
||||||
|
|HIDDEN|8|
|
||||||
|
|HARDROCK|16|
|
||||||
|
|SUDDENDEATH|32|
|
||||||
|
|DOUBLETIME|64|
|
||||||
|
|RELAX|128|
|
||||||
|
|HALFTIME|256|
|
||||||
|
|NIGHTCORE|512|
|
||||||
|
|FLASHLIGHT|1024|
|
||||||
|
|AUTOPLAY|2048|
|
||||||
|
|SPUNOUT|4096|
|
||||||
|
|AUTOPILOT|8192|
|
||||||
|
|PERFECT|16384|
|
||||||
|
|KEY4|32768|
|
||||||
|
|KEY5|65536|
|
||||||
|
|KEY6|131072|
|
||||||
|
|KEY7|262144|
|
||||||
|
|KEY8|524288|
|
||||||
|
|KEYMOD|1048576|
|
||||||
|
|FADEIN|2097152|
|
||||||
|
|RANDOM|4194304|
|
||||||
|
|LASTMOD|8388608|
|
||||||
|
|KEY9|16777216|
|
||||||
|
|KEY10|33554432|
|
||||||
|
|KEY1|67108864|
|
||||||
|
|KEY3|134217728|
|
||||||
|
|KEY2|268435456|
|
||||||
|
|SCOREV2|536870912|
|
||||||
|
|
||||||
|
### osuRanks
|
||||||
|
|Name|Value|
|
||||||
|
|-|-|
|
||||||
|
|SSH|0|
|
||||||
|
|SH|1|
|
||||||
|
|SS|2|
|
||||||
|
|S|3|
|
||||||
|
|A|4|
|
||||||
|
|B|5|
|
||||||
|
|C|6|
|
||||||
|
|D|7|
|
||||||
|
|F|8|
|
||||||
|
|N|9|
|
||||||
|
|
||||||
|
(We dont speak of typeSerializer)
|
||||||
|
|
||||||
|
# Tips
|
||||||
|
```python
|
||||||
|
if you.style is 'passing arrays of information':
|
||||||
|
```
|
||||||
|
```python
|
||||||
|
frames = [
|
||||||
|
ReplayFrame(0, 256, 192, osuButtons.NONE),
|
||||||
|
ReplayFrame(8, 258, 191, osuButtons.NONE),
|
||||||
|
ReplayFrame(13, 257, 198, osuButtons.M1 | osuButtons.SMOKE)
|
||||||
|
]
|
||||||
|
|
||||||
|
replay = Replay()
|
||||||
|
replay.write( frames )
|
||||||
|
```
|
|
@ -13,6 +13,7 @@ class ReplayFrame:
|
||||||
def set_delta(self, delta):
|
def set_delta(self, delta):
|
||||||
if type(delta) is not int:
|
if type(delta) is not int:
|
||||||
raise Exception("Delta is not type of int")
|
raise Exception("Delta is not type of int")
|
||||||
|
self.delta = delta
|
||||||
|
|
||||||
def set_position(self, x, y):
|
def set_position(self, x, y):
|
||||||
self.x = x
|
self.x = x
|
||||||
|
@ -24,7 +25,7 @@ class ReplayFrame:
|
||||||
self.buttons = buttons
|
self.buttons = buttons
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "%s|%s|%s|%s," % (self.delta, self.x, self.y, self.buttons)
|
return "%d|%s|%s|%d," % (self.delta, repr(self.x), repr(self.y), self.buttons)
|
||||||
|
|
||||||
def __bytes__(self):
|
def __bytes__(self):
|
||||||
return str(self).encode()
|
return str(self).encode()
|
||||||
|
|
|
@ -12,7 +12,7 @@ NIGHTCORE = 1 << 9
|
||||||
FLASHLIGHT = 1 << 10
|
FLASHLIGHT = 1 << 10
|
||||||
AUTOPLAY = 1 << 11
|
AUTOPLAY = 1 << 11
|
||||||
SPUNOUT = 1 << 12
|
SPUNOUT = 1 << 12
|
||||||
RELAX2 = 1 << 13
|
AUTOPILOT = 1 << 13
|
||||||
PERFECT = 1 << 14
|
PERFECT = 1 << 14
|
||||||
KEY4 = 1 << 15
|
KEY4 = 1 << 15
|
||||||
KEY5 = 1 << 16
|
KEY5 = 1 << 16
|
||||||
|
|
|
@ -2,6 +2,8 @@ import struct
|
||||||
import string
|
import string
|
||||||
import lzma
|
import lzma
|
||||||
|
|
||||||
|
from .frame import ReplayFrame
|
||||||
|
|
||||||
from .helpers import osuModes
|
from .helpers import osuModes
|
||||||
from .helpers import osuMods
|
from .helpers import osuMods
|
||||||
from .helpers import osuRanks
|
from .helpers import osuRanks
|
||||||
|
@ -199,12 +201,19 @@ class Replay:
|
||||||
# Write replay data --------------------------------------------------------
|
# Write replay data --------------------------------------------------------
|
||||||
|
|
||||||
def write(self, frame):
|
def write(self, frame):
|
||||||
if type(frame) is list:
|
t_frame = type(frame)
|
||||||
|
if t_frame is list:
|
||||||
for _frame in frame: # (frames)
|
for _frame in frame: # (frames)
|
||||||
self.write(_frame)
|
self.write(_frame)
|
||||||
return
|
return
|
||||||
|
if t_frame is ReplayFrame:
|
||||||
self._replay_data.value += bytes(frame)
|
self._replay_data.value += bytes(frame)
|
||||||
|
elif t_frame is bytes:
|
||||||
|
self._replay_data.value += frame
|
||||||
|
elif t_frame is str:
|
||||||
|
self._replay_data.value += frame.encode()
|
||||||
|
else:
|
||||||
|
raise Exception("Invalid frame data")
|
||||||
|
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
# IO replay data -----------------------------------------------------------
|
# IO replay data -----------------------------------------------------------
|
||||||
|
|
23
test.py
23
test.py
|
@ -1,10 +1,19 @@
|
||||||
from osuRepy.frame import ReplayFrame
|
from osuRepy.frame import ReplayFrame # ReplayFrame
|
||||||
from osuRepy.replay import Replay
|
from osuRepy.replay import Replay # Replay instance
|
||||||
|
|
||||||
replay = Replay()
|
from osuRepy.helpers import osuButtons, osuMods # Enum helpers
|
||||||
replay.write( ReplayFrame(2, 3, 4, 4) )
|
|
||||||
|
|
||||||
replay.set_score(s300 = 10)
|
replay = Replay() # Create replay instance
|
||||||
replay.set_timestamp( 1552466941 )# Wed Feb 11 2015 09:03:52 GMT+0100 (Central European Standard Time)
|
|
||||||
|
|
||||||
replay.save("test.osr")
|
replay.write( ReplayFrame(2, 256, 192, osuButtons.M1) ) # Add replay frame (time, x, y, buttons)
|
||||||
|
|
||||||
|
replay.set_score(score = 29284624,
|
||||||
|
s300 = 416,
|
||||||
|
s50 = 2,
|
||||||
|
miss = 1,
|
||||||
|
combo = 358) # Set score info
|
||||||
|
|
||||||
|
replay.set_mods(osuMods.HIDDEN | osuMods.DOUBLETIME) # Enable HDDT mods
|
||||||
|
replay.set_timestamp(1552466941) # Set unix timestamp
|
||||||
|
|
||||||
|
replay.save("myReplay.osr") # Export replay to file
|
||||||
|
|
Loading…
Reference in New Issue
Block a user