Пример #1
0
def test_shots_to_kill_ranges():
    dp: DamageProfile = DamageProfile(
        max_damage=1500,
        max_damage_range=0,
        min_damage=1000,
        min_damage_range=0,
        pellets_count=1,
        resist_type=ResistType.SMALL_ARM,
    )

    assert list(dp.shots_to_kill_ranges()) == [(0.0, 1)]

    dp: DamageProfile = 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(dp.shots_to_kill_ranges()) == [(0.0, 1), (150.0, 2)]

    dp: DamageProfile = DamageProfile(
        max_damage=1500,
        max_damage_range=100,
        min_damage=1500,
        min_damage_range=200,
        pellets_count=1,
        resist_type=ResistType.SMALL_ARM,
    )

    assert list(dp.shots_to_kill_ranges()) == [(0.0, 1)]
Пример #2
0
def test_damage_per_shot():
    dp: DamageProfile = DamageProfile(
        max_damage=1500,
        max_damage_range=100,
        min_damage=500,
        min_damage_range=200,
        pellets_count=1,
        resist_type=ResistType.SMALL_ARM,
    )

    assert dp.damage_per_shot(0) == 1500
    assert (dp.damage_per_shot(
        0, damage_target_type=DamageTargetType.INFANTRY_NANOWEAVE) == 1200)
    assert dp.damage_per_shot(100) == 1500
    assert dp.damage_per_shot(150) == 1000
    assert dp.damage_per_shot(200) == 500
    assert dp.damage_per_shot(300) == 500

    dp: DamageProfile = DamageProfile(
        max_damage=100,
        max_damage_range=0,
        min_damage=100,
        min_damage_range=0,
        pellets_count=4,
        resist_type=ResistType.SMALL_ARM,
    )

    assert dp.damage_per_shot(0) == 4 * dp.damage_per_pellet(0)
Пример #3
0
def test_damage_per_pellet():
    dp: DamageProfile = DamageProfile(
        max_damage=100,
        max_damage_range=0,
        min_damage=100,
        min_damage_range=0,
        pellets_count=1,
        resist_type=ResistType.SMALL_ARM,
    )
    assert dp.damage_per_pellet(0) == 100
    assert dp.damage_per_pellet(10) == 100
    assert dp.damage_per_pellet(1000) == 100
    assert (dp.damage_per_pellet(
        0, damage_target_type=DamageTargetType.INFANTRY_NANOWEAVE) == 80)

    dp: DamageProfile = DamageProfile(
        max_damage=90,
        max_damage_range=10,
        min_damage=10,
        min_damage_range=20,
        pellets_count=1,
        resist_type=ResistType.SMALL_ARM,
    )
    assert dp.damage_per_pellet(0) == 90
    assert dp.damage_per_pellet(10) == 90
    assert dp.damage_per_pellet(15) == 50
    assert dp.damage_per_pellet(20) == 10
    assert dp.damage_per_pellet(30) == 10

    dp: DamageProfile = DamageProfile(
        max_damage=90,
        max_damage_range=10,
        min_damage=10,
        min_damage_range=20,
        location_multiplier={DamageLocation.HEAD: 2.0},
        pellets_count=1,
        resist_type=ResistType.SMALL_ARM,
    )

    assert dp.damage_per_pellet(0, damage_location=DamageLocation.HEAD) == 180
    assert dp.damage_per_pellet(10, damage_location=DamageLocation.HEAD) == 180
    assert dp.damage_per_pellet(15, damage_location=DamageLocation.HEAD) == 100
    assert dp.damage_per_pellet(20, damage_location=DamageLocation.HEAD) == 20
    assert dp.damage_per_pellet(30, damage_location=DamageLocation.HEAD) == 20

    assert dp.damage_per_pellet(0, damage_location=DamageLocation.LEGS) == 90
    assert dp.damage_per_pellet(10, damage_location=DamageLocation.LEGS) == 90
    assert dp.damage_per_pellet(15, damage_location=DamageLocation.LEGS) == 50
    assert dp.damage_per_pellet(20, damage_location=DamageLocation.LEGS) == 10
    assert dp.damage_per_pellet(30, damage_location=DamageLocation.LEGS) == 10
Пример #4
0
def test_shots_to_kill():
    dp: DamageProfile = DamageProfile(
        max_damage=1500,
        max_damage_range=200,
        min_damage=500,
        min_damage_range=400,
        pellets_count=1,
        resist_type=ResistType.SMALL_ARM,
    )

    assert dp.shots_to_kill(0) == 1
    assert dp.shots_to_kill(200) == 1
    assert dp.shots_to_kill(300.1) == 2
    assert dp.shots_to_kill(400) == 2
    assert dp.shots_to_kill(500) == 2

    dp: DamageProfile = DamageProfile(
        max_damage=500,
        max_damage_range=10,
        min_damage=100,
        min_damage_range=20,
        location_multiplier={DamageLocation.HEAD: 2.0},
        pellets_count=1,
        resist_type=ResistType.SMALL_ARM,
    )

    assert dp.shots_to_kill(0) == 2
    assert dp.shots_to_kill(0, damage_location=DamageLocation.HEAD) == 1

    assert dp.shots_to_kill(30) == 10
    assert dp.shots_to_kill(30, damage_location=DamageLocation.HEAD) == 5

    dp: DamageProfile = DamageProfile(
        max_damage=0,
        max_damage_range=10,
        min_damage=0,
        min_damage_range=20,
        location_multiplier={DamageLocation.HEAD: 2.0},
        pellets_count=1,
        resist_type=ResistType.SMALL_ARM,
    )

    assert dp.shots_to_kill(0) == -1
    assert dp.shots_to_kill(30) == -1
Пример #5
0
def test_damage_delta():
    dp: DamageProfile = DamageProfile(
        max_damage=100,
        max_damage_range=1234,
        min_damage=100,
        min_damage_range=5678,
        pellets_count=1,
        resist_type=ResistType.SMALL_ARM,
    )
    assert dp.damage_delta == 0

    dp: DamageProfile = DamageProfile(
        max_damage=100,
        max_damage_range=1234,
        min_damage=90,
        min_damage_range=5678,
        pellets_count=1,
        resist_type=ResistType.SMALL_ARM,
    )
    assert dp.damage_delta == 10
Пример #6
0
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
Пример #7
0
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)]
Пример #8
0
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
Пример #9
0
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