def test_spooling_refire_time(): ft: FireTiming = FireTiming( is_automatic=True, refire_time=100, fire_duration=0, delay=0, charge_up_time=0, ) assert ft.spooling_refire_time(0) == 100 assert ft.spooling_refire_time(1000) == 100 ft: FireTiming = FireTiming( is_automatic=True, refire_time=90, fire_duration=0, delay=0, charge_up_time=0, spool_up_time=1000, spool_up_initial_refire_time=10, ) assert ft.spooling_refire_time(0) == 10 assert ft.spooling_refire_time(500) == 10 assert ft.spooling_refire_time(1000) == 90 assert ft.spooling_refire_time(2000) == 90
def test_shots_per_minute(): ft: FireTiming = FireTiming( is_automatic=True, refire_time=80, fire_duration=0, delay=0, charge_up_time=0, ) assert ft.shots_per_minute == 750 ft: FireTiming = FireTiming( is_automatic=False, refire_time=80, fire_duration=0, burst_length=3, burst_refire_time=80, delay=0, charge_up_time=0, ) assert ft.shots_per_minute == 750 ft: FireTiming = FireTiming( is_automatic=False, refire_time=180, fire_duration=0, delay=0, charge_up_time=0, ) assert ft.shots_per_minute == 333 ft: FireTiming = FireTiming( is_automatic=False, refire_time=170, fire_duration=0, delay=0, charge_up_time=0, chamber_time=1500, ) assert ft.shots_per_minute == 35 ft: FireTiming = FireTiming( is_automatic=False, refire_time=0, fire_duration=0, delay=0, charge_up_time=0, chamber_time=1000, ) assert ft.shots_per_minute == 60 ft: FireTiming = FireTiming( is_automatic=False, refire_time=250, fire_duration=0, burst_length=5, burst_refire_time=60, delay=250, charge_up_time=0, ) assert ft.shots_per_minute == 405
def test_total_delay(): ft: FireTiming = FireTiming( is_automatic=True, refire_time=0, fire_duration=0, delay=0, charge_up_time=0, ) assert ft.total_delay == 0 ft: FireTiming = FireTiming( is_automatic=True, refire_time=0, fire_duration=0, delay=100, charge_up_time=0, ) assert ft.total_delay == 100 ft: FireTiming = FireTiming( is_automatic=True, refire_time=0, fire_duration=0, delay=0, charge_up_time=200, ) assert ft.total_delay == 200 ft: FireTiming = FireTiming( is_automatic=True, refire_time=0, fire_duration=0, delay=100, charge_up_time=200, ) assert ft.total_delay == 300
def test_real_time_to_kill(): ft: FireTiming = FireTiming( is_automatic=True, refire_time=100, fire_duration=0, delay=0, charge_up_time=0, chamber_time=0, ) rc: Recoil = Recoil( max_angle=0.0, min_angle=0.0, max_vertical=0.0, min_vertical=0.0, vertical_increase=0.0, vertical_crouched_increase=0.0, max_horizontal=0.0, min_horizontal=0.0, horizontal_tolerance=0.0, max_horizontal_increase=0.0, min_horizontal_increase=0.0, recovery_acceleration=0.0, recovery_delay=0.0, recovery_rate=0.0, first_shot_multiplier=1.0, ) am: Ammo = Ammo( clip_size=10, total_capacity=100, ammo_per_shot=1, short_reload_time=700, reload_chamber_time=300, ) ddp: DamageProfile = DamageProfile( max_damage=1000, max_damage_range=10, min_damage=0, min_damage_range=20, pellets_count=1, resist_type=ResistType.SMALL_ARM, ) cof: ConeOfFire = ConeOfFire( max_angle=0.0, min_angle=0.0, bloom=0.0, recovery_rate=20, recovery_delay=100, multiplier=1.0, moving_multiplier=1.5, pellet_spread=0.0, ) fm: FireMode = FireMode( fire_mode_id=0, fire_mode_type=FireModeType.IRON_SIGHT, description="", is_ads=True, detect_range=30.0, move_multiplier=1.0, turn_multiplier=1.0, direct_damage_profile=ddp, zoom=1.5, ammo=am, fire_timing=ft, recoil=rc, player_state_cone_of_fire={PlayerState.STANDING: cof}, ) assert fm.real_time_to_kill(distance=1.0, runs=10)[0] == 0 assert fm.real_time_to_kill(distance=10.0, runs=10)[0] == 0 assert fm.real_time_to_kill(distance=11.0, runs=10)[0] == 100 assert fm.real_time_to_kill(distance=15.0, runs=10)[0] == 100 assert fm.real_time_to_kill(distance=16.0, runs=10)[0] == 200 assert fm.real_time_to_kill(distance=20.0, runs=10)[0] == -1
def test_generate_real_shot_timings(): ft: FireTiming = FireTiming( is_automatic=True, refire_time=100, fire_duration=0, delay=0, charge_up_time=0, ) rc: Recoil = Recoil( max_angle=0.0, min_angle=0.0, max_vertical=0.0, min_vertical=0.0, vertical_increase=0.0, vertical_crouched_increase=0.0, max_horizontal=0.0, min_horizontal=0.0, horizontal_tolerance=0.0, max_horizontal_increase=0.0, min_horizontal_increase=0.0, recovery_acceleration=0.0, recovery_delay=0.0, recovery_rate=0.0, first_shot_multiplier=1.0, ) am: Ammo = Ammo( clip_size=5, total_capacity=100, ammo_per_shot=1, short_reload_time=500, reload_chamber_time=500, ) fm: FireMode = FireMode( fire_mode_id=0, fire_mode_type=FireModeType.IRON_SIGHT, description="", is_ads=True, detect_range=30.0, move_multiplier=1.0, turn_multiplier=1.0, zoom=1.5, ammo=am, fire_timing=ft, recoil=rc, ) assert list(fm.generate_real_shot_timings(shots=7)) == [ (0, True), (100, False), (200, False), (300, False), (400, False), (1400, True), (1500, False), ] assert list(fm.generate_real_shot_timings(shots=7, control_time=100)) == [ (0, True), (100, False), (200, False), (300, False), (400, False), (1400, True), (1500, False), ] assert list( fm.generate_real_shot_timings(shots=7, control_time=100, auto_burst_length=2) ) == [ (0, True), (100, False), (300, True), (400, False), (600, True), (1600, True), (1700, False), ]
def test_shots_to_kill_ranges(): ft: FireTiming = FireTiming( is_automatic=True, refire_time=0, fire_duration=0, delay=0, charge_up_time=0, ) rc: Recoil = Recoil( max_angle=0.0, min_angle=0.0, max_vertical=0.0, min_vertical=0.0, vertical_increase=0.0, vertical_crouched_increase=0.0, max_horizontal=0.0, min_horizontal=0.0, horizontal_tolerance=0.0, max_horizontal_increase=0.0, min_horizontal_increase=0.0, recovery_acceleration=0.0, recovery_delay=0.0, recovery_rate=0.0, first_shot_multiplier=1.0, ) fm: FireMode = FireMode( fire_mode_id=0, fire_mode_type=FireModeType.IRON_SIGHT, description="", is_ads=True, detect_range=30.0, move_multiplier=1.0, turn_multiplier=1.0, zoom=1.5, fire_timing=ft, recoil=rc, ) fm.direct_damage_profile = DamageProfile( max_damage=1500, max_damage_range=100, min_damage=500, min_damage_range=200, pellets_count=1, resist_type=ResistType.SMALL_ARM, ) assert list(fm.shots_to_kill_ranges()) == [(0.0, 1), (150.0, 2)] fm: FireMode = FireMode( fire_mode_id=0, fire_mode_type=FireModeType.IRON_SIGHT, description="", is_ads=True, detect_range=30.0, move_multiplier=1.0, turn_multiplier=1.0, zoom=1.5, fire_timing=ft, recoil=rc, ) fm.direct_damage_profile = DamageProfile( max_damage=1500, max_damage_range=100, min_damage=500, min_damage_range=200, pellets_count=1, resist_type=ResistType.SMALL_ARM, ) fm.indirect_damage_profile = DamageProfile( max_damage=100, max_damage_range=1, min_damage=0, min_damage_range=3, pellets_count=1, resist_type=ResistType.SMALL_ARM, ) assert list(fm.shots_to_kill_ranges()) == [(0.0, 1), (160.0, 2)]
def test_damage_per_pellet(): ft: FireTiming = FireTiming( is_automatic=True, refire_time=0, fire_duration=0, delay=0, charge_up_time=0, ) rc: Recoil = Recoil( max_angle=0.0, min_angle=0.0, max_vertical=0.0, min_vertical=0.0, vertical_increase=0.0, vertical_crouched_increase=0.0, max_horizontal=0.0, min_horizontal=0.0, horizontal_tolerance=0.0, max_horizontal_increase=0.0, min_horizontal_increase=0.0, recovery_acceleration=0.0, recovery_delay=0.0, recovery_rate=0.0, first_shot_multiplier=1.0, ) fm: FireMode = FireMode( fire_mode_id=0, fire_mode_type=FireModeType.IRON_SIGHT, description="", is_ads=True, detect_range=30.0, move_multiplier=1.0, turn_multiplier=1.0, zoom=1.5, fire_timing=ft, recoil=rc, ) fm.direct_damage_profile = DamageProfile( max_damage=90, max_damage_range=10, min_damage=10, min_damage_range=20, pellets_count=1, resist_type=ResistType.SMALL_ARM, ) assert fm.damage_per_pellet(0) == 90 assert ( fm.damage_per_pellet(0, damage_target_type=DamageTargetType.INFANTRY_NANOWEAVE) == 72 ) assert fm.damage_per_pellet(10) == 90 assert fm.damage_per_pellet(15) == 50 assert fm.damage_per_pellet(20) == 10 assert fm.damage_per_pellet(30) == 10 fm: FireMode = FireMode( fire_mode_id=0, fire_mode_type=FireModeType.IRON_SIGHT, description="", is_ads=True, detect_range=30.0, move_multiplier=1.0, turn_multiplier=1.0, zoom=1.5, fire_timing=ft, recoil=rc, ) fm.direct_damage_profile = DamageProfile( max_damage=90, max_damage_range=10, min_damage=10, min_damage_range=20, pellets_count=1, resist_type=ResistType.SMALL_ARM, ) fm.indirect_damage_profile = DamageProfile( max_damage=10, max_damage_range=1, min_damage=0, min_damage_range=3, pellets_count=1, resist_type=ResistType.SMALL_ARM, ) assert fm.damage_per_pellet(0) == 100 assert fm.damage_per_pellet(10) == 100 assert fm.damage_per_pellet(15) == 60 assert fm.damage_per_pellet(20) == 20 assert fm.damage_per_pellet(30) == 20
def test_time_to_fire_shots(): ft: FireTiming = FireTiming( is_automatic=True, refire_time=100, fire_duration=0, delay=0, charge_up_time=0, ) assert ft.time_to_fire_shots(0) == 0 assert ft.time_to_fire_shots(1) == 0 assert ft.time_to_fire_shots(2) == 100 assert ft.time_to_fire_shots(10) == 900 ft: FireTiming = FireTiming( is_automatic=True, refire_time=100, fire_duration=0, delay=50, charge_up_time=25, ) assert ft.time_to_fire_shots(0) == 0 assert ft.time_to_fire_shots(1) == 75 assert ft.time_to_fire_shots(2) == 175 assert ft.time_to_fire_shots(10) == 975 ft: FireTiming = FireTiming( is_automatic=True, refire_time=100, fire_duration=0, delay=0, charge_up_time=0, chamber_time=200, ) assert ft.time_to_fire_shots(0) == 0 assert ft.time_to_fire_shots(1) == 0 assert ft.time_to_fire_shots(2) == 300 assert ft.time_to_fire_shots(10) == 2700 ft: FireTiming = FireTiming( is_automatic=True, refire_time=100, fire_duration=0, delay=50, charge_up_time=25, chamber_time=200, ) assert ft.time_to_fire_shots(0) == 0 assert ft.time_to_fire_shots(1) == 75 assert ft.time_to_fire_shots(2) == 375 assert ft.time_to_fire_shots(10) == 2775 ft: FireTiming = FireTiming( is_automatic=False, refire_time=200, fire_duration=0, delay=0, charge_up_time=0, burst_length=3, burst_refire_time=100, ) assert ft.time_to_fire_shots(0) == 0 assert ft.time_to_fire_shots(1) == 0 assert ft.time_to_fire_shots(2) == 100 assert ft.time_to_fire_shots(3) == 200 assert ft.time_to_fire_shots(4) == 400 assert ft.time_to_fire_shots(5) == 500 assert ft.time_to_fire_shots(6) == 600 assert ft.time_to_fire_shots(7) == 800 ft: FireTiming = FireTiming( is_automatic=False, refire_time=200, fire_duration=0, delay=50, charge_up_time=0, burst_length=3, burst_refire_time=100, ) assert ft.time_to_fire_shots(0) == 0 assert ft.time_to_fire_shots(1) == 50 assert ft.time_to_fire_shots(2) == 150 assert ft.time_to_fire_shots(3) == 250 assert ft.time_to_fire_shots(4) == 500 assert ft.time_to_fire_shots(5) == 600 assert ft.time_to_fire_shots(6) == 700 assert ft.time_to_fire_shots(7) == 950 ft: FireTiming = FireTiming( is_automatic=False, refire_time=100, fire_duration=0, delay=50, charge_up_time=0, burst_length=3, burst_refire_time=50, ) assert ft.time_to_fire_shots(shots=6) == 400 assert ft.time_to_fire_shots(shots=6, control_time=10) == 410
def test_generate_shot_timings(): ft: FireTiming = FireTiming( is_automatic=True, refire_time=100, fire_duration=0, delay=0, charge_up_time=0, ) assert list(ft.generate_shot_timings(shots=3)) == [ (0, True), (100, False), (200, False), ] assert list(ft.generate_shot_timings(shots=3, control_time=100)) == [ (0, True), (100, False), (200, False), ] assert list( ft.generate_shot_timings(shots=9, auto_burst_length=3, control_time=100) ) == [ (0, True), (100, False), (200, False), (400, True), (500, False), (600, False), (800, True), (900, False), (1000, False), ] ft: FireTiming = FireTiming( is_automatic=False, refire_time=100, fire_duration=0, delay=0, charge_up_time=0, ) assert list(ft.generate_shot_timings(shots=3)) == [ (0, True), (100, True), (200, True), ] ft: FireTiming = FireTiming( is_automatic=False, refire_time=100, fire_duration=0, delay=0, charge_up_time=0, burst_length=3, burst_refire_time=50, ) assert list(ft.generate_shot_timings(shots=6)) == [ (0, True), (50, False), (100, False), (200, True), (250, False), (300, False), ] assert list(ft.generate_shot_timings(shots=6, control_time=10)) == [ (0, True), (50, False), (100, False), (210, True), (260, False), (310, False), ] ft: FireTiming = FireTiming( is_automatic=False, refire_time=100, fire_duration=0, delay=0, charge_up_time=0, ) assert list(ft.generate_shot_timings(shots=3)) == [ (0, True), (100, True), (200, True), ] assert list(ft.generate_shot_timings(shots=3, control_time=100)) == [ (0, True), (200, True), (400, True), ] ft: FireTiming = FireTiming( is_automatic=False, refire_time=100, fire_duration=0, delay=50, charge_up_time=0, burst_length=3, burst_refire_time=50, ) assert list(ft.generate_shot_timings(shots=6)) == [ (50, True), (100, False), (150, False), (300, True), (350, False), (400, False), ] assert list(ft.generate_shot_timings(shots=6, control_time=10)) == [ (50, True), (100, False), (150, False), (310, True), (360, False), (410, False), ]
def test_no_fire_modes_attributes(): # Fire timing fit_1: FireTiming = FireTiming( is_automatic=True, refire_time=0, fire_duration=0, delay=0, charge_up_time=0, ) fit_2: FireTiming = FireTiming( is_automatic=True, refire_time=100, fire_duration=0, delay=0, charge_up_time=0, ) # Recoil rec_1: Recoil = Recoil( max_angle=0.0, min_angle=0.0, max_vertical=0.0, min_vertical=0.0, vertical_increase=0.0, vertical_crouched_increase=0.0, max_horizontal=0.0, min_horizontal=0.0, horizontal_tolerance=0.0, max_horizontal_increase=0.0, min_horizontal_increase=0.0, recovery_acceleration=0.0, recovery_delay=0.0, recovery_rate=0.0, first_shot_multiplier=1.0, ) rec_2: Recoil = Recoil( max_angle=1.0, min_angle=0.0, max_vertical=0.0, min_vertical=0.0, vertical_increase=0.0, vertical_crouched_increase=0.0, max_horizontal=0.0, min_horizontal=0.0, horizontal_tolerance=0.0, max_horizontal_increase=0.0, min_horizontal_increase=0.0, recovery_acceleration=0.0, recovery_delay=0.0, recovery_rate=0.0, first_shot_multiplier=1.0, ) # Player state cone of fire psc_1: Dict[PlayerState, ConeOfFire] = { PlayerState.STANDING: ConeOfFire( max_angle=1.0, min_angle=1.0, bloom=0.1, recovery_rate=10.0, recovery_delay=100, multiplier=2.0, moving_multiplier=2.0, pellet_spread=0.0, ) } psc_2: Dict[PlayerState, ConeOfFire] = { PlayerState.STANDING: ConeOfFire( max_angle=2.0, min_angle=1.0, bloom=0.1, recovery_rate=10.0, recovery_delay=100, multiplier=2.0, moving_multiplier=2.0, pellet_spread=0.0, ) } # Player state can ADS psa_1: Dict[PlayerState, bool] = {PlayerState.STANDING: True} psa_2: Dict[PlayerState, bool] = {PlayerState.STANDING: False} # Projectile prj_1: Projectile = Projectile( speed=100, gravity=0.0, life_time=3000, flight_type=ProjectileFlightType.BALLISTIC, drag=0.0, ) prj_2: Projectile = Projectile( speed=200, gravity=0.0, life_time=3000, flight_type=ProjectileFlightType.BALLISTIC, drag=0.0, ) # Lock-on lon_1: LockOn = LockOn( life_time=100, seek_in_flight=False, maintain=False, required=True, ) lon_2: LockOn = LockOn( life_time=200, seek_in_flight=False, maintain=False, required=True, ) # Damage profile ddp_1: DamageProfile = DamageProfile( max_damage=90, max_damage_range=10, min_damage=10, min_damage_range=20, pellets_count=1, resist_type=ResistType.SMALL_ARM, ) ddp_2: DamageProfile = DamageProfile( max_damage=95, max_damage_range=10, min_damage=10, min_damage_range=20, pellets_count=1, resist_type=ResistType.SMALL_ARM, ) # Indirect damage profile idp_1: DamageProfile = DamageProfile( max_damage=92, max_damage_range=1, min_damage=20, min_damage_range=2, pellets_count=1, resist_type=ResistType.SMALL_ARM, ) idp_2: DamageProfile = DamageProfile( max_damage=90, max_damage_range=1, min_damage=20, min_damage_range=2, pellets_count=1, resist_type=ResistType.SMALL_ARM, ) # Ammo amm_1: Ammo = Ammo( clip_size=12, total_capacity=100, ammo_per_shot=1, short_reload_time=0, reload_chamber_time=0, ) amm_2: Ammo = Ammo( clip_size=10, total_capacity=100, ammo_per_shot=1, short_reload_time=0, reload_chamber_time=0, ) # Heat hea_1: Heat = Heat( total_capacity=1000, heat_per_shot=0, overheat_penalty_time=0, recovery_delay=0, recovery_rate=0, ) hea_2: Heat = Heat( total_capacity=1200, heat_per_shot=0, overheat_penalty_time=0, recovery_delay=0, recovery_rate=0, ) # Fire modes fm_1: FireMode = FireMode( fire_mode_id=0, fire_mode_type=FireModeType.IRON_SIGHT, description="", is_ads=True, detect_range=30.0, move_multiplier=1.0, turn_multiplier=1.0, zoom=1.5, fire_timing=fit_1, recoil=rec_1, player_state_cone_of_fire=psc_1, player_state_can_ads=psa_1, projectile=prj_1, lock_on=lon_1, direct_damage_profile=ddp_1, indirect_damage_profile=idp_1, ammo=amm_1, heat=hea_1, ) fm_2: FireMode = FireMode( fire_mode_id=1, fire_mode_type=FireModeType.IRON_SIGHT, description="", is_ads=True, detect_range=30.0, move_multiplier=1.0, turn_multiplier=1.0, zoom=1.5, fire_timing=fit_2, recoil=rec_2, player_state_cone_of_fire=psc_2, player_state_can_ads=psa_2, projectile=prj_2, lock_on=lon_2, direct_damage_profile=ddp_2, indirect_damage_profile=idp_2, ammo=amm_2, heat=hea_2, ) # Fire group fg: FireGroup = FireGroup( fire_group_id=2, description="", transition_time=0, fire_modes=[fm_1, fm_2] ) assert fg.fire_timing is None assert fg.recoil is None assert fg.player_state_cone_of_fire is None assert fg.player_state_can_ads is None assert fg.projectile is None assert fg.lock_on is None assert fg.direct_damage_profile is None assert fg.indirect_damage_profile is None assert fg.ammo is None assert fg.heat is None