def test_hit_objects_hard_rock(beatmap): # Only hit object 0 tested for now hit_objects_hard_rock_0 = beatmap.hit_objects(hard_rock=True, stacking=False)[0] assert hit_objects_hard_rock_0.position == Position(x=243, y=220) assert hit_objects_hard_rock_0.curve.points == [Position(x=243, y=220), Position(x=301, y=209)]
def test_closest_hitobject(): beatmap = slider.example_data.beatmaps.miiro_vs_ai_no_scenario('Beginner') hit_object1 = beatmap.hit_objects()[4] hit_object2 = beatmap.hit_objects()[5] hit_object3 = beatmap.hit_objects()[6] middle_t = timedelta(milliseconds=11076 - ((11076 - 9692) / 2)) assert hit_object1.time == timedelta(milliseconds=8615) assert hit_object2.time == timedelta(milliseconds=9692) assert hit_object3.time == timedelta(milliseconds=11076) assert beatmap.closest_hitobject(timedelta(milliseconds=8615)) == \ hit_object1 assert beatmap.closest_hitobject(timedelta(milliseconds=(8615 - 30))) == \ hit_object1 assert beatmap.closest_hitobject(middle_t) == hit_object2 assert beatmap.closest_hitobject(middle_t, side="right") == hit_object3
def test_hit_objects_stacking(): hit_objects = [ slider.beatmap.Circle(Position(128, 128), timedelta(milliseconds=x * 10), hitsound=1) for x in range(10) ] beatmap = slider.Beatmap(format_version=14, audio_filename="audio.mp3", audio_lead_in=timedelta(), preview_time=timedelta(), countdown=False, sample_set="soft", stack_leniency=1, mode=0, letterbox_in_breaks=False, widescreen_storyboard=False, bookmarks=[0], distance_spacing=1, beat_divisor=1, grid_size=1, timeline_zoom=1, title="title", title_unicode="title", artist="artist", artist_unicode="artist", creator="creator", version="1.0", source="source", tags=["tags"], beatmap_id=0, beatmap_set_id=0, hp_drain_rate=5, circle_size=5, overall_difficulty=5, approach_rate=5, slider_multiplier=1, slider_tick_rate=1, timing_points=[], hit_objects=hit_objects) radius = slider.beatmap.circle_radius(5) stack_offset = radius / 10 for i, ob in enumerate(reversed(beatmap.hit_objects(stacking=True))): assert ob.position.y == 128 - (i * stack_offset)
def test_parse_section_hit_objects(beatmap): # Only hit object 0 tested for now hit_objects_0 = beatmap.hit_objects(stacking=False)[0] assert hit_objects_0.position == Position(x=243, y=164) assert hit_objects_0.time == timedelta(milliseconds=1076) # Hit object note `type` is done by subclassing HitObject assert isinstance(hit_objects_0, slider.beatmap.Slider) # Slider specific parameters assert hit_objects_0.end_time == timedelta(milliseconds=1173) assert hit_objects_0.hitsound == 0 assert isinstance(hit_objects_0.curve, slider.curve.Linear) assert hit_objects_0.curve.points == [Position(x=243, y=164), Position(x=301, y=175)] assert round(hit_objects_0.curve.req_length) == 45 assert isclose(hit_objects_0.length, 45.0000017166138) assert hit_objects_0.ticks == 2 assert hit_objects_0.num_beats == 0.3125 assert hit_objects_0.tick_rate == 1.0 assert isclose(hit_objects_0.ms_per_beat, 307.692307692308) assert hit_objects_0.edge_sounds == [2, 0] assert hit_objects_0.edge_additions == ['0:0', '0:0'] assert hit_objects_0.addition == "0:0:0:0:"