def test_attack_hit_rule_returns_true_if_at_least_one_hit(self,): rule = UncontestedToHitRule() outcome = rule.resolve({ "shooter": UnitBuilder().ballistics(13).combi_rifle().build(), "shooter_rolls": (10, 20), "target": UnitBuilder().build(), "distance": 1 }) assert outcome["shooter_hits"] is True
def test_attack_hit_rule_returns_criticals_count_if_hit_is_critical(self,): rule = UncontestedToHitRule() outcome = rule.resolve({ "shooter": UnitBuilder().ballistics(13).combi_rifle().build(), "shooter_rolls": (16, 16), "target": UnitBuilder().physical(20).build(), "distance": 1 }) assert outcome["criticals_count"] == 2
def test_attack_hit_rule_returns_false_if_roll_missess_hit_threshold(self,): # noqa rule = UncontestedToHitRule() outcome = rule.resolve({ "shooter": UnitBuilder().ballistics(13).combi_rifle().build(), "shooter_rolls": (20,), "target": UnitBuilder().build(), "distance": 1 }) assert outcome["shooter_hits"] is False
def test_rule_returns_an_outcome(self,): rule = ToSaveRule() outcome = rule.resolve({ "shooter": UnitBuilder().build(), "shooter_rolls": (10,), "target": UnitBuilder().build(), "target_rolls": (1,), "distance": 1 }) assert outcome is not None
def test_attack_hit_rule_returns_false_if_roll_under_threshold_but_enemy_saves_it(self,): # noqa rule = UncontestedAttackRule() outcome = rule.resolve({ "shooter": UnitBuilder().ballistics(13).combi_rifle().build(), "shooter_rolls": (10,), "target": UnitBuilder().build(), "target_rolls": (21,), "distance": 1 }) assert outcome["shooter_hits"] is False
def test_attack_save_rule_returns_false_if_fails(self,): rule = ToSaveRule() outcome = rule.resolve({ "shooter": UnitBuilder().ballistics(13).combi_rifle().build(), "shooter_rolls": (10,), "target": UnitBuilder().armor(1).build(), "target_rolls": (12,), "distance": 1 }) assert outcome["saves"] is False assert outcome["saves_count"] == 0
def test_attack_hit_rule_returns_true_if_at_least_one_roll_doesnt_save(self,): # noqa rule = UncontestedAttackRule() outcome = rule.resolve({ "shooter": UnitBuilder().ballistics(13).combi_rifle().build(), "shooter_rolls": (10, 10), "target": UnitBuilder().build(), "target_rolls": (21, 1), "distance": 1 }) assert outcome["shooter_hits"] is True assert outcome["hits_count"] == 1
def test_calculate_hit_probabilities_for_one_shot_of_vanilla_BS13_unit_targeting_unit_under_cover_with_mimetism_minus3_with_combi_in_bad_range( self, ): # noqa encounter = Encounter({ "shooter": (UnitBuilder().vanilla().ballistics(13).combi_rifle_b1().build()), "target": (UnitBuilder().vanilla().partial_cover().mimetism().build()), "distance": CombiRifle.BadRange }) result = encounter.compute() assert result["shooter_hits"] == 0.05
def test_calculate_hit_probabilities_BS13_unit_targeting_with_combi( self): # noqa encounter = Encounter({ "shooter": UnitBuilder().vanilla().ballistics(13).combi_rifle().build(), "target": UnitBuilder().vanilla().build(), "distance": 1 }) result = encounter.compute_with_saves() assert result["shooter_hits"] == 0.48 assert result["shooter_misses"] == 0.52
def test_calculate_hit_probabilities_for_one_shot_of_vanilla_BS13_unit_targeting_vanilla_unit_with_combi_with_ARM1( self): # noqa encounter = Encounter({ "shooter": UnitBuilder().vanilla().ballistics(13).combi_rifle_b1().build(), "target": UnitBuilder().vanilla().build(), "distance": 1 }) result = encounter.compute_with_saves() assert result["shooter_hits"] == 0.6615384615384615 assert result["shooter_misses"] == 0.3384615384615385
def test_calculate_hit_probabilities_for_one_shot_of_vanilla_BS13_unit_targeting_vanilla_unit_with_null_weapon( self): # noqa encounter = Encounter({ "shooter": UnitBuilder().vanilla().ballistics(13).build(), "target": UnitBuilder().vanilla().armor(1).build(), "distance": None }) result = encounter.compute() assert result["shooter_hits"] == 0.65
def test_calculate_hit_probabilities_for_one_shot_of_vanilla_BS13_unit_targeting_vanilla_unit_with_combi_in_good_range( self, ): # noqa encounter = Encounter({ "shooter": (UnitBuilder().vanilla().ballistics(13).combi_rifle_b1().build()), "target": UnitBuilder().vanilla().build(), "distance": CombiRifle.GoodRange }) result = encounter.compute() assert result["shooter_hits"] == 0.8
def test_calculate_wound_probabilities_for_one_shot_of_vanilla_BS13_unit_targeting_vanilla_unit_with_combi( self): # noqa encounter = Encounter({ "shooter": UnitBuilder().vanilla().ballistics(13).build(), "target": UnitBuilder().vanilla().build(), "distance": 1 }) result = encounter.compute() assert result["no_wounds"] == 0.65 assert result["one_wound"] == 0.65 assert result["two_wounds"] == 0.65
def test_a_new_unit_has_basic_profile_to_zero(self, ): unit = UnitBuilder().build() assert unit.cc == 0 assert unit.bs == 0 assert unit.ph == 0 assert unit.wip == 0 assert unit.arm == 0 assert unit.bts == 0 assert unit.w == 0 assert unit.ava == 0 assert unit.points == 0 assert unit.scw == 0
def test_a_vanilla_BS13_unit_with_no_mods_has_default_target_threshold_of_13( self, ): # noqa unit = UnitBuilder().vanilla().ballistics(13).build() assert unit.threshold_to_hit() == 13
def test_a_vanilla_BS13_unit_with_combi_in_bad_range_has_target_threshold_of_7( self, ): # noqa unit = UnitBuilder().vanilla().ballistics(13).combi_rifle().build() assert unit.threshold_to_hit(CombiRifle.BadRange) == 7
def test_a_vanilla_BS13_unit_with_mimetism_minus3_has_a_shooter_penalty_of_minus3( self, ): # noqa unit = UnitBuilder().vanilla().ballistics(13).mimetism().build() assert unit.modifier_to_defend() == -3
def test_a_unit_with_cover_saving_threshold_is_shooter_weapon_damage_minus_armor_minus_cover( self, ): # noqa unit = UnitBuilder().vanilla().partial_cover().build() assert unit.threshold_to_save(CombiRifle()) == 9