1
1
from pathlib import Path
2
- from typing import Dict , List , Optional , Tuple , Union
2
+ from . import BaseGetter
3
+ from typing import Dict , List , Optional , Tuple
3
4
4
5
5
- class DifficultyPoint :
6
+ class DifficultyPoint ( BaseGetter ) :
6
7
'''
7
8
DifficultyPoint object
8
9
@@ -14,27 +15,13 @@ class DifficultyPoint:
14
15
time : float
15
16
speed_multiplier : float
16
17
17
- def __repr__ (self ) -> str :
18
- return f'<DifficultyPoint object ({ self .attrs } )>'
19
-
20
- @property
21
- def as_string (self ) -> str : ...
22
18
@property
23
19
def as_dict (self ) -> Dict [str , float ]: ...
24
-
25
- # Properties -----
26
- @property
27
- def attrs (self ) -> str :
28
- '''Get attrs as text'''
29
- return self .as_string
30
-
31
20
@property
32
- def attrs_dict (self ) -> Dict [str , float ]:
33
- '''Get attrs as dict'''
34
- return self .as_dict
21
+ def attrs_dict (self ) -> Dict [str , float ]: ...
35
22
36
23
37
- class TimingPoint :
24
+ class TimingPoint ( BaseGetter ) :
38
25
'''
39
26
TimingPoint object
40
27
@@ -46,28 +33,13 @@ class TimingPoint:
46
33
time : float
47
34
beat_len : float
48
35
49
- def __repr__ (self ) -> str :
50
- return f'<TimingPoint object ({ self .attrs } )>'
51
-
52
- @property
53
- def as_string (self ) -> str : ...
54
-
55
36
@property
56
37
def as_dict (self ) -> Dict [str , float ]: ...
57
-
58
- # Properties -----
59
38
@property
60
- def attrs (self ) -> str :
61
- '''Get attrs as text'''
62
- return self .as_string
63
-
64
- @property
65
- def attrs_dict (self ) -> Dict [str , float ]:
66
- '''Get attrs as dict'''
67
- return self .as_dict
39
+ def attrs_dict (self ) -> Dict [str , float ]: ...
68
40
69
41
70
- class Pos2 :
42
+ class Pos2 ( BaseGetter ) :
71
43
'''
72
44
Pos2 object
73
45
@@ -85,16 +57,8 @@ class Pos2:
85
57
length_squared : float
86
58
length : float
87
59
88
- def __repr__ (self ) -> str :
89
- return f'<Pos2 object ({ self .attrs } )>'
90
-
91
- @property
92
- def as_string (self ) -> str : ...
93
-
94
- @property
95
- def as_dict (self ) -> Dict [str , float ]: ...
96
-
97
60
# Methods ------
61
+
98
62
def dot (self , other : Pos2 ) -> float : ...
99
63
def distance (self , other : Pos2 ) -> float : ...
100
64
def normalize (self ) -> Pos2 : ...
@@ -104,25 +68,18 @@ class Pos2:
104
68
def div (self , rhs : float ) -> Pos2 : ...
105
69
def add_assign (self , other : Pos2 ): ...
106
70
107
- # Properties -----
108
-
109
71
@property
110
- def attrs (self ) -> str :
111
- '''Get attrs as text'''
112
- return self .as_string
113
-
72
+ def as_dict (self ) -> Dict [str , float ]: ...
114
73
@property
115
- def attrs_dict (self ) -> Dict [str , float ]:
116
- '''Get attrs as dict'''
117
- return self .as_dict
74
+ def attrs_dict (self ) -> Dict [str , float ]: ...
118
75
119
76
@property
120
77
def as_tuple (self ) -> Tuple [float , float ]:
121
78
'''Get (x, y) as tuple'''
122
- return self . as_tuple
79
+ ...
123
80
124
81
125
- class HitObjectKind :
82
+ class HitObjectKind ( BaseGetter ) :
126
83
'''
127
84
HitObjectKind object
128
85
@@ -144,32 +101,15 @@ class HitObjectKind:
144
101
repeats : Optional [int ]
145
102
path_type : Optional [str ]
146
103
end_time : Optional [float ]
147
-
148
- # cache needed attrs
149
104
curve_points : Optional [List [Pos2 ]]
150
105
151
- def __repr__ (self ) -> str :
152
- return f'<HitObjectKind object ({ self .attrs } )>'
153
-
154
- @property
155
- def as_string (self ) -> str : ...
156
-
157
106
@property
158
107
def as_dict (self ) -> Dict [str , float ]: ...
159
-
160
- # Properties -----
161
- @property
162
- def attrs (self ) -> str :
163
- '''Get attrs as text'''
164
- return self .as_string
165
-
166
108
@property
167
- def attrs_dict (self ) -> Dict [str , float ]:
168
- '''Get attrs as dict'''
169
- return self .as_dict
109
+ def attrs_dict (self ) -> Dict [str , float ]: ...
170
110
171
111
172
- class HitObject :
112
+ class HitObject ( BaseGetter ) :
173
113
'''
174
114
HitObject object
175
115
@@ -199,34 +139,95 @@ class HitObject:
199
139
is_slider : bool
200
140
is_spinner : bool
201
141
kind_str : str
202
-
203
- # cache needed attrs
204
142
pos : Pos2
205
143
kind : HitObjectKind
206
144
207
- def __repr__ (self ) -> str :
208
- return f'<HitObject object ({ self .attrs } )>'
209
-
210
- @property
211
- def as_string (self ) -> str : ...
212
-
213
145
@property
214
146
def as_dict (self ) -> Dict [str , float ]: ...
215
-
216
- # Properties -----
217
147
@property
218
- def attrs (self ) -> str :
219
- '''Get attrs as text'''
220
- return self .as_string
148
+ def attrs_dict (self ) -> Dict [str , float ]: ...
221
149
222
- @property
223
- def attrs_dict (self ) -> Dict [str , float ]:
224
- '''Get attrs as dict'''
225
- return self .as_dict
226
150
151
+ class Beatmap (BaseGetter ):
152
+ '''
153
+ The Beatmap used to calculate the pp, it contains the parsed .osu beatmap.
154
+
155
+ `path`: `Optional[Path]`
156
+
157
+ `mode`: `int`
158
+
159
+ `mode_str`: `str`
160
+
161
+ `version`: `int`
162
+
163
+ `n_circles`: `int`
164
+
165
+ `n_sliders`: `int`
166
+
167
+ `n_spinners`: `int`
168
+
169
+ `ar`: `float`
170
+
171
+ `od`: `float`
172
+
173
+ `cs`: `float`
174
+
175
+ `hp`: `float`
176
+
177
+ `sv`: `float`
178
+
179
+ `tick_rate`: `float`
180
+
181
+ `stack_leniency`: `Optional[float]`
182
+
183
+ `hit_objects`: `Optional[List[HitObject]]`
227
184
228
- class Beatmap :
229
- ...
185
+ `timing_points`: `Optional[List[TimingPoint]]`
186
+
187
+ `difficulty_points`: `Optional[List[DifficultyPoint]]`
188
+
189
+
190
+ # Examples:
191
+ ```
192
+ # Read and parse .osu files from local
193
+ beatmap = Beatmap('path_to_osu_file')
194
+ # Same as
195
+ beatmap = Beatmap.create('path_to_osu_file')
196
+
197
+ # Async Rust
198
+ beatmap = await Beatmap.create_async_rs('path_to_osu_file')
199
+ # Async Python (wrapper)
200
+ beatmap = await Beatmap.create_async_py('path_to_osu_file')
201
+
202
+
203
+
204
+ # We can reload this .osu files as:
205
+ beatmap.reload()
206
+
207
+ # Async Rust
208
+ await beatmap.reload_async_rs()
209
+ # Async Python (wrapper)
210
+ await beatmap.reload_async_py()
211
+
212
+ # We can load another .osu files as:
213
+ beatmap.init('path_to_another_osu_file')
214
+
215
+ # Async Rust
216
+ await beatmap.init_rs('path_to_another_osu_file')
217
+ # Async Python (wrapper)
218
+ await beatmap.init_py('path_to_another_osu_file')
219
+
220
+ # Calculate PP
221
+ c = Calculator()
222
+ c.set_acc(98.8)
223
+ c.set_combo(727)
224
+ # or
225
+ c = Calculator({'acc': 98.8, 'combo': 727})
226
+ # then
227
+ result = c.calculate(beatmap)
228
+
229
+ ```
230
+ '''
230
231
mode : int
231
232
mode_str : str
232
233
version : int
@@ -250,11 +251,6 @@ class Beatmap:
250
251
@property
251
252
def difficulty_points (self ) -> List [DifficultyPoint ]: ...
252
253
253
- @property
254
- def as_string (self ) -> str : ...
255
- @property
256
- def as_dict (self ) -> Dict [str , Union [float , int , None ]]: ...
257
-
258
254
259
255
async def read_beatmap_async (path : Path ) -> Beatmap : ...
260
256
def read_beatmap_sync (path : Path ) -> Beatmap : ...
0 commit comments