Skip to content

Commit

Permalink
rewrite documentation for 5.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
tybug committed May 30, 2021
1 parent b80eb47 commit dbbb67f
Showing 1 changed file with 90 additions and 23 deletions.
113 changes: 90 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ pip install osrparse

## Documentation

### Parsing

To parse a replay from a filepath:

```python
Expand All @@ -35,34 +37,99 @@ parse_replay(lzma_string, pure_lzma=True)

Note that if you use the `/get_replay` endpoint to retrieve a replay, you must decode the response before passing it to osrparse, as the response is encoded in base 64 by default.

Replay objects provide the following fields:
### Attributes

`Replay` objects have the following attibutes:

```python
self.game_mode # GameMode enum
self.game_version # int
self.beatmap_hash # str
self.player_name # str
self.replay_hash # str
self.number_300s # int
self.number_100s # int
self.number_50s # int
self.gekis # int
self.katus # int
self.misses # int
self.score # int
self.max_combo # int
self.game_mode # GameMode enum
self.game_version # int
self.beatmap_hash # str
self.player_name # str
self.replay_hash # str
self.number_300s # int
self.number_100s # int
self.number_50s # int
self.gekis # int
self.katus # int
self.misses # int
self.score # int
self.max_combo # int
self.is_perfect_combo # bool
self.mod_combination # Mod enum
self.life_bar_graph # str, currently unparsed
self.timestamp # datetime.datetime object
self.play_data # list[ReplayEvent]
self.mod_combination # Mod enum
self.life_bar_graph # str, currently unparsed
self.timestamp # datetime.datetime object
# list of either ReplayEventOsu, ReplayEventTaiko,
# ReplayEventCatch, or ReplayEventMania objects,
# depending on self.game_mode
self.play_data
```

`ReplayEventOsu` objects have the following attributes:

```python
self.time_delta # int, time since previous event in milliseconds
self.x # float, x axis location
self.y # float, y axis location
self.keys # Key enum, keys pressed
```

`ReplayEventTaiko` objects have the following attributes:

```python
self.time_delta # int, time since previous event in milliseconds
self.x # float, x axis location
self.keys # KeyTaiko enum, keys pressed
```

`ReplayEventCatch` objects have the following attributes:

```python
self.time_delta # int, time since previous event in milliseconds
self.x # float, x axis location
self.dashing # bool, whether the player was dashing or not
```

`ReplayEventMania` objects have the following attributes:

```python
self.time_delta # int, time since previous event in milliseconds
self.keys # KeyMania enum
```

ReplayEvent objects provide the following fields:
The `Key` enums used in the above `ReplayEvent`s are defined as follows:

```python
self.time_delta # int (in milliseconds)
self.x # x axis location
self.y # y axis location
self.keys # Key IntFlag of keys pressed
class Key(IntFlag):
M1 = 1 << 0
M2 = 1 << 1
K1 = 1 << 2
K2 = 1 << 3
SMOKE = 1 << 4

class KeyTaiko(IntFlag):
LEFT_DON = 1 << 0
LEFT_KAT = 1 << 1
RIGHT_DON = 1 << 2
RIGHT_KAT = 1 << 3

class KeyMania(IntFlag):
K1 = 1 << 0
K2 = 1 << 1
K3 = 1 << 2
K4 = 1 << 3
K5 = 1 << 4
K6 = 1 << 5
K7 = 1 << 6
K8 = 1 << 7
K9 = 1 << 8
K10 = 1 << 9
K11 = 1 << 10
K12 = 1 << 11
K13 = 1 << 12
K14 = 1 << 13
K15 = 1 << 14
K16 = 1 << 15
K17 = 1 << 16
K18 = 1 << 17
```

0 comments on commit dbbb67f

Please sign in to comment.