Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if not get_setting("render_beatmap"):
self.has_beatmap = False
# beatmap stuff
if self.has_beatmap:
# values taken from https://github.com/ppy/osu-wiki/blob/master/meta/unused/difficulty-settings.md
# but it was taken from the osu! wiki since then so this might be a bit incorrect.
if self.beatmap.approach_rate == 5:
self.preempt = 1200
elif self.beatmap.approach_rate < 5:
self.preempt = 1200 + 600 * (5 - self.beatmap.approach_rate) / 5
else:
self.preempt = 1200 - 750 * (self.beatmap.approach_rate - 5) / 5
self.hitwindow = od_to_ms(self.beatmap.overall_difficulty).hit_50
self.fade_in = 400
self.hitcircle_radius = circle_radius(self.beatmap.circle_size) - WIDTH_CIRCLE_BORDER / 2
## loading stuff
self.is_loading = True
self.sliders_total = len(self.beatmap.hit_objects)
self.sliders_current = 0
self.thread = threading.Thread(target=self.process_sliders)
self.thread.start()
else:
self.is_loading = False
# replay stuff
self.num_replays = len(replays)
self.players = []
for i, replay in enumerate(replays):
self.players.append(
Player(replay=replay,
half_time):
"""Compute the stars and star components for this map.
Parameters
----------
easy : bool
Compute stars with easy.
hard_rock : bool
Compute stars with hard rock.
double_time : bool
Compute stars with double time.
half_time : bool
Compute stars with half time.
"""
cs = self.cs(easy=easy, hard_rock=hard_rock)
radius = circle_radius(cs)
difficulty_hit_objects = []
append_difficulty_hit_object = difficulty_hit_objects.append
intervals = []
append_interval = intervals.append
if double_time:
modify = op.attrgetter('double_time')
elif half_time:
modify = op.attrgetter('half_time')
else:
def modify(e):
return e
hit_objects = map(modify, self.hit_objects)
Compute difficulty with hard rock.
double_time : bool
Compute difficulty with double time.
half_time : bool
Compute difficulty with half time.
Returns
----------
times : np.ndarray
Single column array of times as ``timedelta64[ns]``
difficulties : np.ndarray
Array of difficulties as ``float64``. Speed in the first column,
aim in the second.
"""
cs = self.cs(easy=easy, hard_rock=hard_rock)
radius = circle_radius(cs)
if double_time:
modify = op.attrgetter('double_time')
elif half_time:
modify = op.attrgetter('half_time')
else:
def modify(e):
return e
times = np.empty(
(len(self.hit_objects) - 1, 1),
dtype='timedelta64[ns]',
)
strains = np.empty((len(self.hit_objects) - 1, 2), dtype=np.float64)
hit_objects = map(modify, self.hit_objects)
may be in slider_breaks in addition to another category
Slider calculations are unreliable so some objects may in the wrong
category.
Spinners are not yet calculated so are always in the 300s category.
"""
beatmap = self.beatmap
actions = self.actions
scores = {"300s": [],
"100s": [],
"50s": [],
"misses": [],
"slider_breaks": [],
}
hw = od_to_ms(beatmap.od(easy=self.easy, hard_rock=self.hard_rock))
rad = circle_radius(
beatmap.cs(easy=self.easy, hard_rock=self.hard_rock),
)
hit_50_threshold = datetime.timedelta(milliseconds=hw.hit_50)
i = 0
for obj in beatmap.hit_objects:
if self.hard_rock:
obj = obj.hard_rock
if isinstance(obj, Spinner):
# spinners are hard
scores['300s'].append(obj)
continue
# we can ignore events before the hit window so iterate
# until we get past the beginning of the hit window
while actions[i].offset < obj.time - hit_50_threshold:
i += 1
starti = i