diff --git a/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/attacks/attacks_high_fraction.cfg b/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/attacks/attacks_high_fraction.cfg index 78598f1c0aab0..cbb6c7b1249bc 100644 --- a/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/attacks/attacks_high_fraction.cfg +++ b/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/attacks/attacks_high_fraction.cfg @@ -8,7 +8,7 @@ # Have the side 1 leader attack the side 2 leader with both its weapons ## # Expected end state: -# The side 1 leader has 2 weapons both of which have 3 strikes +# The side 1 leader has 2 weapons both of which have 4 strikes ##### #ifndef SCHEMA_VALIDATION {COMMON_KEEP_A_B_UNIT_TEST "attacks_high_fraction" ( @@ -27,6 +27,6 @@ [/modify_unit] [/event] - {CHECK_STRIKES "3,3" ({SUCCEED})} + {CHECK_STRIKES "4,4" ({SUCCEED})} )} #endif diff --git a/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/attacks/attacks_multiply_fraction.cfg b/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/attacks/attacks_multiply_fraction.cfg index 513bf78bcebad..b255d75b7eb08 100644 --- a/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/attacks/attacks_multiply_fraction.cfg +++ b/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/attacks/attacks_multiply_fraction.cfg @@ -8,7 +8,7 @@ # Have the side 1 leader attack the side 2 leader with both its weapons ## # Expected end state: -# The side 1 leader has 2 weapons both of which have 4 strikes (2*2, the .5 is truncated) +# The side 1 leader has 2 weapons both of which have 6 strikes (2*3, the .5 is rounded up) ##### #ifndef SCHEMA_VALIDATION {COMMON_KEEP_A_B_UNIT_TEST "attacks_multiply_fraction" ( @@ -27,6 +27,6 @@ [/modify_unit] [/event] - {CHECK_STRIKES "4,4" ({SUCCEED})} + {CHECK_STRIKES "6,6" ({SUCCEED})} )} #endif diff --git a/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/berserk/berserk_high_fraction.cfg b/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/berserk/berserk_high_fraction.cfg index 35464cb745b32..d8626b764884f 100644 --- a/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/berserk/berserk_high_fraction.cfg +++ b/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/berserk/berserk_high_fraction.cfg @@ -8,8 +8,8 @@ # Have the side 1 leader attack the side 2 leader with both its weapons ## # Expected end state: -# The side 1 leader's first weapon strikes 6 times (2*3) -# The side 1 leader's second weapon strikes 12 times (4*3) +# The side 1 leader's first weapon strikes 8 times (2*4) +# The side 1 leader's second weapon strikes 16 times (4*4) ##### #ifndef SCHEMA_VALIDATION {COMMON_KEEP_A_B_UNIT_TEST "berserk_high_fraction" ( @@ -28,6 +28,6 @@ [/modify_unit] [/event] - {CHECK_STRIKES "6,12" ({SUCCEED})} + {CHECK_STRIKES "8,16" ({SUCCEED})} )} #endif diff --git a/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/damage/damage_high_fraction.cfg b/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/damage/damage_high_fraction.cfg index 985034ce82a6d..fc71495f08ef1 100644 --- a/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/damage/damage_high_fraction.cfg +++ b/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/damage/damage_high_fraction.cfg @@ -8,7 +8,7 @@ # Have the side 1 leader attack the side 2 leader with both its weapons ## # Expected end state: -# The side 1 leader has 2 weapons both of which have 3 damage +# The side 1 leader has 2 weapons both of which have 4 damage ##### #ifndef SCHEMA_VALIDATION {COMMON_KEEP_A_B_UNIT_TEST "damage_high_fraction" ( @@ -26,7 +26,7 @@ [/effect] [/modify_unit] - {ATTACK_AND_VALIDATE 3 (DAMAGE_VALUE=) WEAPON_COUNT=2} + {ATTACK_AND_VALIDATE 4 (DAMAGE_VALUE=) WEAPON_COUNT=2} {SUCCEED} [/event] ) SIDE2_LEADER="Elvish Archer"} diff --git a/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/damage/damage_multiply_fraction.cfg b/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/damage/damage_multiply_fraction.cfg index c0738ae0474eb..1b4cd52ce5174 100644 --- a/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/damage/damage_multiply_fraction.cfg +++ b/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/damage/damage_multiply_fraction.cfg @@ -8,7 +8,7 @@ # Have the side 1 leader attack the side 2 leader with both its weapons ## # Expected end state: -# The side 1 leader has 2 weapons both of which have 6 damage (3*3, the .5 is truncated) +# The side 1 leader has 2 weapons both of which have 8 damage (3*3, the .5 is rounded up) ##### #ifndef SCHEMA_VALIDATION {COMMON_KEEP_A_B_UNIT_TEST "damage_multiply_fraction" ( @@ -26,7 +26,7 @@ [/effect] [/modify_unit] - {ATTACK_AND_VALIDATE 6 (DAMAGE_VALUE=) WEAPON_COUNT=2} + {ATTACK_AND_VALIDATE 8 (DAMAGE_VALUE=) WEAPON_COUNT=2} {SUCCEED} [/event] ) SIDE2_LEADER="Elvish Archer"} diff --git a/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/drains/drains_high_fraction.cfg b/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/drains/drains_high_fraction.cfg index 9509ebafc9696..aa3f30f5c478f 100644 --- a/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/drains/drains_high_fraction.cfg +++ b/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/drains/drains_high_fraction.cfg @@ -23,7 +23,7 @@ [effect] apply_to = new_ability [abilities] - {TEST_ABILITY drains 3.8 () SELF=yes} + {TEST_ABILITY drains 2.8 () SELF=yes} [/abilities] [/effect] [/modify_unit] diff --git a/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/drains/drains_multiply_fraction.cfg b/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/drains/drains_multiply_fraction.cfg index 0a6083e65309f..22d78cf3f78df 100644 --- a/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/drains/drains_multiply_fraction.cfg +++ b/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/drains/drains_multiply_fraction.cfg @@ -8,7 +8,7 @@ # Have the side 1 leader attack the side 2 leader with both its weapons ## # Expected end state: -# The both leaders have 2 weapons each of which now drains 6 hp (3*2, the .5 is truncated) +# The both leaders have 2 weapons each of which now drains 6 hp (3*2, the .5 is rounded up) # The leader of side 1 heals 6 hp total since it has full hp when its first strike is made # The leader of side 2 heals 12 hp total since it was damaged when its first strike was made ##### @@ -23,7 +23,7 @@ [effect] apply_to = new_ability [abilities] - {TEST_ABILITY drains 3.5 (multiply=2) SELF=yes} + {TEST_ABILITY drains 2.5 (multiply=2) SELF=yes} [/abilities] [/effect] [/modify_unit] diff --git a/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/heal_on_hit/heal_on_hit_high_fraction.cfg b/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/heal_on_hit/heal_on_hit_high_fraction.cfg index 7a8d80109846c..5c570218496e9 100644 --- a/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/heal_on_hit/heal_on_hit_high_fraction.cfg +++ b/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/heal_on_hit/heal_on_hit_high_fraction.cfg @@ -23,7 +23,7 @@ [effect] apply_to = new_ability [abilities] - {TEST_ABILITY heal_on_hit 3.8 () SELF=yes} + {TEST_ABILITY heal_on_hit 2.8 () SELF=yes} [/abilities] [/effect] [/modify_unit] diff --git a/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/heal_on_hit/heal_on_hit_multiply_fraction.cfg b/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/heal_on_hit/heal_on_hit_multiply_fraction.cfg index 84133e755b210..daf994be606d6 100644 --- a/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/heal_on_hit/heal_on_hit_multiply_fraction.cfg +++ b/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/heal_on_hit/heal_on_hit_multiply_fraction.cfg @@ -23,7 +23,7 @@ [effect] apply_to = new_ability [abilities] - {TEST_ABILITY heal_on_hit 3.5 (multiply=2) SELF=yes} + {TEST_ABILITY heal_on_hit 2.5 (multiply=2) SELF=yes} [/abilities] [/effect] [/modify_unit] diff --git a/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/heals/heal_high_fraction.cfg b/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/heals/heal_high_fraction.cfg index db1c944abfc8e..9bbad5a2fa318 100644 --- a/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/heals/heal_high_fraction.cfg +++ b/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/heals/heal_high_fraction.cfg @@ -10,7 +10,7 @@ # Wait a turn for healing to take place. ## # Expected end state: -# The Mage has 5 hp: 1 + 2 (rest healing) + 2 ([heals], fraction truncated) +# The Mage has 6 hp: 1 + 2 (rest healing) + 3 ([heals], fraction roundd up) ##### #ifndef SCHEMA_VALIDATION {GENERIC_UNIT_TEST "heal_high_fraction" ( @@ -53,7 +53,7 @@ [/filter] variable = temp [/store_unit] - {ASSERT {VARIABLE_CONDITIONAL temp.hitpoints numerical_equals 5}} + {ASSERT {VARIABLE_CONDITIONAL temp.hitpoints numerical_equals 6}} {SUCCEED} [/event] )} diff --git a/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/heals/heal_multiply_fraction.cfg b/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/heals/heal_multiply_fraction.cfg index 2369d1febb47a..694a4b2a88cc0 100644 --- a/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/heals/heal_multiply_fraction.cfg +++ b/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/heals/heal_multiply_fraction.cfg @@ -10,7 +10,7 @@ # Wait a turn for healing to take place. ## # Expected end state: -# The Mage has 7 hp: 1 + 2 (rest healing) + 4 ([heals], 2.5*2), the 2.5 is truncated to just 2 prior to being multiplied +# The Mage has 9 hp: 1 + 2 (rest healing) + 6 ([heals], 2.5*2), the 2.5 is rounded up to just 3 prior to being multiplied ##### #ifndef SCHEMA_VALIDATION {GENERIC_UNIT_TEST "heal_multiply_fraction" ( @@ -54,7 +54,7 @@ [/filter] variable = temp [/store_unit] - {ASSERT {VARIABLE_CONDITIONAL temp.hitpoints numerical_equals 7}} + {ASSERT {VARIABLE_CONDITIONAL temp.hitpoints numerical_equals 9}} {SUCCEED} [/event] )} diff --git a/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/illuminates/illuminates_high_fraction.cfg b/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/illuminates/illuminates_high_fraction.cfg index 39b0dfc98a6cc..e20c9df010d33 100644 --- a/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/illuminates/illuminates_high_fraction.cfg +++ b/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/illuminates/illuminates_high_fraction.cfg @@ -8,7 +8,7 @@ # Attack each other ## # Expected end state: -# The damage from the attack is increased by 45% - the .8 is truncated +# The damage from the attack is increased by 45% - the .8 is rounded up ##### #ifndef SCHEMA_VALIDATION {COMMON_KEEP_A_B_UNIT_TEST "illuminates_high_fraction" ( @@ -21,7 +21,7 @@ [effect] apply_to = new_ability [abilities] - {TEST_ABILITY illuminates 45.8 (max_value=100) SELF=yes} + {TEST_ABILITY illuminates 44.8 (max_value=100) SELF=yes} [/abilities] [/effect] [/modify_unit] diff --git a/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/illuminates/illuminates_multiply_fraction.cfg b/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/illuminates/illuminates_multiply_fraction.cfg index c754400f1db7a..4d51ad80c8a8e 100644 --- a/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/illuminates/illuminates_multiply_fraction.cfg +++ b/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/illuminates/illuminates_multiply_fraction.cfg @@ -8,7 +8,7 @@ # Attack each other ## # Expected end state: -# The damage from the attack is increased by 44% - the .9 is truncated before multiplication is done +# The damage from the attack is increased by 46% - the .9 is rounded up before multiplication is done ##### #ifndef SCHEMA_VALIDATION {COMMON_KEEP_A_B_UNIT_TEST "illuminates_multiply_fraction" ( @@ -27,7 +27,7 @@ [/effect] [/modify_unit] - {ATTACK_AND_VALIDATE 144} + {ATTACK_AND_VALIDATE 146} {SUCCEED} [/event] ) SIDE1_LEADER=Mage SIDE2_LEADER=Mage} diff --git a/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/leadership/leadership_high_fraction.cfg b/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/leadership/leadership_high_fraction.cfg index d87952523ef83..7d62a40863d6d 100644 --- a/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/leadership/leadership_high_fraction.cfg +++ b/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/leadership/leadership_high_fraction.cfg @@ -4,11 +4,11 @@ # API(s) being tested: [leadership]value= ## # Actions: -# Give all units 45.8% self-leadership bonus damage +# Give all units 44.8% self-leadership bonus damage # Attack each other ## # Expected end state: -# The damage from the attack is increased by 45% - the .8 is truncated +# The damage from the attack is increased by 45% - the .8 is rounded up ##### #ifndef SCHEMA_VALIDATION {COMMON_KEEP_A_B_UNIT_TEST "leadership_high_fraction" ( @@ -21,7 +21,7 @@ [effect] apply_to = new_ability [abilities] - {TEST_ABILITY leadership 45.8 () SELF=yes} + {TEST_ABILITY leadership 44.8 () SELF=yes} [/abilities] [/effect] [/modify_unit] diff --git a/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/leadership/leadership_multiply_fraction.cfg b/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/leadership/leadership_multiply_fraction.cfg index b2b1721bc69d0..34adb11877e30 100644 --- a/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/leadership/leadership_multiply_fraction.cfg +++ b/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/leadership/leadership_multiply_fraction.cfg @@ -8,7 +8,7 @@ # Attack each other ## # Expected end state: -# The damage from the attack is increased by 44% - the .9 is truncated before multiplication is done +# The damage from the attack is increased by 46% - the .9 is rounded up before multiplication is done ##### #ifndef SCHEMA_VALIDATION {COMMON_KEEP_A_B_UNIT_TEST "leadership_multiply_fraction" ( @@ -26,7 +26,7 @@ [/effect] [/modify_unit] - {ATTACK_AND_VALIDATE 144} + {ATTACK_AND_VALIDATE 146} {SUCCEED} [/event] )} diff --git a/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/regenerate/regenerate_high_fraction.cfg b/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/regenerate/regenerate_high_fraction.cfg index a8c6f36829e2d..ed0e5164b9f79 100644 --- a/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/regenerate/regenerate_high_fraction.cfg +++ b/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/regenerate/regenerate_high_fraction.cfg @@ -9,7 +9,7 @@ # Wait a turn for regenerating to take place. ## # Expected end state: -# The Mage has 5 hp: 1 + 2 (rest healing) + 2 ([regenerate], fraction truncated) +# The Mage has 6 hp: 1 + 2 (rest healing) + 3 ([regenerate], fraction rounded up) ##### #ifndef SCHEMA_VALIDATION {GENERIC_UNIT_TEST "regenerate_high_fraction" ( @@ -51,7 +51,7 @@ [/filter] variable = temp [/store_unit] - {ASSERT {VARIABLE_CONDITIONAL temp.hitpoints numerical_equals 5}} + {ASSERT {VARIABLE_CONDITIONAL temp.hitpoints numerical_equals 6}} {SUCCEED} [/event] )} diff --git a/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/regenerate/regenerate_multiply_fraction.cfg b/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/regenerate/regenerate_multiply_fraction.cfg index f14b9acfaad23..b49dfbe5ea8e9 100644 --- a/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/regenerate/regenerate_multiply_fraction.cfg +++ b/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/regenerate/regenerate_multiply_fraction.cfg @@ -9,7 +9,7 @@ # Wait a turn for regenerating to take place. ## # Expected end state: -# The Mage has 7 hp: 1 + 2 (rest healing) + 4 ([regenerate], 2.5*2), the 2.5 is truncated to just 2 prior to being multiplied +# The Mage has 9 hp: 1 + 2 (rest healing) + 6 ([regenerate], 2.5*2), the 2.5 is rounded up to 3 prior to being multiplied ##### #ifndef SCHEMA_VALIDATION {GENERIC_UNIT_TEST "regenerate_multiply_fraction" ( @@ -51,7 +51,7 @@ [/filter] variable = temp [/store_unit] - {ASSERT {VARIABLE_CONDITIONAL temp.hitpoints numerical_equals 7}} + {ASSERT {VARIABLE_CONDITIONAL temp.hitpoints numerical_equals 9}} {SUCCEED} [/event] )} diff --git a/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/resistance/resistance_high_fraction.cfg b/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/resistance/resistance_high_fraction.cfg index 53876f66db03c..c8e05e6e4da3d 100644 --- a/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/resistance/resistance_high_fraction.cfg +++ b/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/resistance/resistance_high_fraction.cfg @@ -4,11 +4,11 @@ # API(s) being tested: [resistance]value= ## # Actions: -# Give all units 45.8% resistance to all damage types +# Give all units 44.8% resistance to all damage types # Attack each other ## # Expected end state: -# The damage from the attack is reduced by 45% - the .8 is truncated +# The damage from the attack is reduced by 45% - the .8 is rounded up ##### #ifndef SCHEMA_VALIDATION {COMMON_KEEP_A_B_UNIT_TEST "resistance_high_fraction" ( @@ -21,7 +21,7 @@ [effect] apply_to = new_ability [abilities] - {TEST_ABILITY resistance 45.8 (max_value=100) SELF=yes} + {TEST_ABILITY resistance 44.8 (max_value=100) SELF=yes} [/abilities] [/effect] [/modify_unit] diff --git a/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/resistance/resistance_multiply_fraction.cfg b/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/resistance/resistance_multiply_fraction.cfg index 70419e62bc30a..3f98ad081af7c 100644 --- a/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/resistance/resistance_multiply_fraction.cfg +++ b/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/resistance/resistance_multiply_fraction.cfg @@ -8,7 +8,7 @@ # Attack each other ## # Expected end state: -# The damage from the attack is reduced by 44% - the .9 is truncated before multiplication is done +# The damage from the attack is reduced by 46% - the .9 is rounded up before multiplication is done ##### #ifndef SCHEMA_VALIDATION {COMMON_KEEP_A_B_UNIT_TEST "resistance_multiply_fraction" ( @@ -27,7 +27,7 @@ [/effect] [/modify_unit] - {ATTACK_AND_VALIDATE 56} + {ATTACK_AND_VALIDATE 54} {SUCCEED} [/event] )} diff --git a/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/special_calculations.cfg b/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/special_calculations.cfg index 31c1f5d711c59..2b48a84b49061 100644 --- a/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/special_calculations.cfg +++ b/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/special_calculations.cfg @@ -178,30 +178,30 @@ # API(s) being tested: [attacks]divide= ## # Expected end state: -# Bob's attack has 4 strikes after rounding down. +# Bob's attack has 5 strikes after rounding up. ##### -{ONE_CALCULATION_UNIT_TEST divide_float_2dp 10 (divide=2.02) 4} +{ONE_CALCULATION_UNIT_TEST divide_float_2dp 10 (divide=2.02) 5} ##### # API(s) being tested: [attacks]divide= ## # Expected end state: -# Bob's attack has 5 strikes. Here 2.008 is truncated to 2.00, and then 10 / 2.00 is 5. +# Bob's attack has 5 strikes. Here 2.008 is rounded up to 2.10, and then 10 / 2.10 is rounded up to 5. ##### {ONE_CALCULATION_UNIT_TEST divide_float_3dp 10 (divide=2.008) 5} ##### # API(s) being tested: [attacks] ## # Expected end state: -# Bob's attack is the expected answer: 10 strikes * 2 / 3 = 6 strikes after rounding down. +# Bob's attack is the expected answer: 10 strikes * 2 / 3 = 7 strikes after rounding up. ##### -{ONE_CALCULATION_UNIT_TEST divide_multiply_combined 10 (divide,multiply=3,2) 6} +{ONE_CALCULATION_UNIT_TEST divide_multiply_combined 10 (divide,multiply=3,2) 7} ##### # API(s) being tested: [attacks]divide=,[attacks]multiply= ## # Expected end state: -# Bob's attack is the expected answer: 10 strikes * 2 / 3 = 6 strikes after rounding down. +# Bob's attack is the expected answer: 10 strikes * 2 / 3 = 7 strikes after rounding up. ##### -{TWO_CALCULATION_UNIT_TEST divide_multiply_separated 10 (divide=3) (multiply=2) 6} +{TWO_CALCULATION_UNIT_TEST divide_multiply_separated 10 (divide=3) (multiply=2) 7} ##### # API(s) being tested: [attacks]multiply= ## @@ -213,9 +213,9 @@ # API(s) being tested: [attacks]multiply= ## # Expected end state: -# Bob's attack has 9 strikes, because 3 * 3.334 first rounds 3.334 to 3.33, and then 3 * 3.33 floors to 9. +# Bob's attack has 10 strikes, because 3 * 3.334 first rounds 3.334 to 3.33, and then 3 * 3.33 rounds up to 10. ##### -{ONE_CALCULATION_UNIT_TEST multiply_float_3dp 3 (multiply=3.334) 9} +{ONE_CALCULATION_UNIT_TEST multiply_float_3dp 3 (multiply=3.334) 10} #undef ONE_CALCULATION_UNIT_TEST #undef TWO_CALCULATION_UNIT_TEST diff --git a/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/swarm/swarm_attacks_max_fraction.cfg b/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/swarm/swarm_attacks_max_fraction.cfg index d4e1bb7e50fd5..bdf3245daff8e 100644 --- a/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/swarm/swarm_attacks_max_fraction.cfg +++ b/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/swarm/swarm_attacks_max_fraction.cfg @@ -10,7 +10,7 @@ # Have the side 1 leader attack the side 2 leader with its second weapon twice ## # Expected end state: -# For both weapons, the first attack has 28 strikes and the second attack has 0 strikes (28/29, rounded down) +# For both weapons, the first attack has 28 strikes and the second attack has 0 strikes (28/29, rounded up) ##### #ifndef SCHEMA_VALIDATION {COMMON_KEEP_A_B_UNIT_TEST "swarm_attacks_max_fraction" ( @@ -24,7 +24,7 @@ apply_to = new_ability [abilities] {TEST_ABILITY_NO_VALUE swarm (swarm_attacks_min=0 - swarm_attacks_max=28.9) SELF=yes} + swarm_attacks_max=27.9) SELF=yes} [/abilities] [/effect] [/modify_unit] diff --git a/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/swarm/swarm_attacks_min_fraction.cfg b/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/swarm/swarm_attacks_min_fraction.cfg index 9c9a34494063f..d4b1a88938b2a 100644 --- a/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/swarm/swarm_attacks_min_fraction.cfg +++ b/data/test/scenarios/wml_tests/UnitsWML/AbilitiesWML/swarm/swarm_attacks_min_fraction.cfg @@ -24,7 +24,7 @@ [effect] apply_to = new_ability [abilities] - {TEST_ABILITY_NO_VALUE swarm (swarm_attacks_min=0.9 + {TEST_ABILITY_NO_VALUE swarm (swarm_attacks_min=0.4 swarm_attacks_max=28) SELF=yes} [/abilities] [/effect] diff --git a/src/actions/attack.cpp b/src/actions/attack.cpp index 39a8213a79f40..b56daa3ad37b4 100644 --- a/src/actions/attack.cpp +++ b/src/actions/attack.cpp @@ -183,7 +183,7 @@ battle_context_unit_stats::battle_context_unit_stats(nonempty_unit_const_ptr up, chance_to_hit = std::clamp(cth, 0, 100); // Compute base damage done with the weapon. - int base_damage = weapon->modified_damage(); + double base_damage = weapon->modified_damage(); // Get the damage multiplier applied to the base damage of the weapon. int damage_multiplier = 100; @@ -317,7 +317,7 @@ battle_context_unit_stats::battle_context_unit_stats(const unit_type* u_type, chance_to_hit = std::clamp(cth, 0, 100); - int base_damage = weapon->modified_damage(); + double base_damage = weapon->modified_damage(); int damage_multiplier = 100; unit_alignments::type alignment = weapon->alignment().value_or(u_type->alignment()); damage_multiplier diff --git a/src/reports.cpp b/src/reports.cpp index 11a4f1768cf73..79a7a09bbd9a3 100644 --- a/src/reports.cpp +++ b/src/reports.cpp @@ -782,7 +782,7 @@ static int attack_info(const reports::context& rc, const attack_type &at, config { auto ctx = at.specials_context(u.shared_from_this(), hex, u.side() == rc.screen().playing_team().side()); int base_damage = at.damage(); - int specials_damage = at.modified_damage(); + double specials_damage = at.modified_damage(); int damage_multiplier = 100; const_attack_ptr weapon = at.shared_from_this(); unit_alignments::type attack_alignment = weapon->alignment().value_or(u.alignment()); diff --git a/src/units/abilities.cpp b/src/units/abilities.cpp index 8daa9abde39e1..2aaa71b891d1e 100644 --- a/src/units/abilities.cpp +++ b/src/units/abilities.cpp @@ -700,9 +700,9 @@ std::pair unit_ability_list::get_extremum(const std::string& k int stack = 0; for (const unit_ability& p : cfgs_) { - int value = get_single_ability_value((*p.ability_cfg)[key], def, p, loc(), const_attack_ptr(), [&](const wfl::formula& formula, wfl::map_formula_callable& callable) { - return formula.evaluate(callable).as_int(); - }); + int value = std::round(get_single_ability_value((*p.ability_cfg)[key], static_cast(def), p, loc(), const_attack_ptr(), [&](const wfl::formula& formula, wfl::map_formula_callable& callable) { + return formula.evaluate(callable).as_int() / 1.0; + })); if ((*p.ability_cfg)["cumulative"].to_bool()) { stack += value; @@ -1373,9 +1373,9 @@ std::set attack_type::alternative_damage_types() const /** * Returns the damage per attack of this weapon, considering specials. */ -int attack_type::modified_damage() const +double attack_type::modified_damage() const { - int damage_value = composite_value(get_specials_and_abilities("damage"), damage()); + double damage_value = unit_abilities::effect(get_specials_and_abilities("damage"), damage(), shared_from_this()).get_composite_double_value(); return damage_value; } @@ -2452,10 +2452,10 @@ effect::effect(const unit_ability_list& list, int def, const const_attack_ptr& a if(wham != EFFECT_CUMULABLE){ if (const config::attribute_value *v = cfg.get("value")) { - int value = get_single_ability_value(*v, def, ability, list.loc(), att, [&](const wfl::formula& formula, wfl::map_formula_callable& callable) { + int value = std::round(get_single_ability_value(*v, static_cast(def), ability, list.loc(), att, [&](const wfl::formula& formula, wfl::map_formula_callable& callable) { callable.add("base_value", wfl::variant(def)); - return formula.evaluate(callable).as_int(); - }); + return std::round(formula.evaluate(callable).as_int()); + })); int value_cum = cfg["cumulative"].to_bool() ? std::max(def, value) : value; assert((set_effect_min.type != NOT_USED) == (set_effect_max.type != NOT_USED)); @@ -2484,27 +2484,27 @@ effect::effect(const unit_ability_list& list, int def, const const_attack_ptr& a } if (const config::attribute_value *v = cfg.get("add")) { - int add = get_single_ability_value(*v, def, ability, list.loc(), att, [&](const wfl::formula& formula, wfl::map_formula_callable& callable) { + int add = std::round(get_single_ability_value(*v, static_cast(def), ability, list.loc(), att, [&](const wfl::formula& formula, wfl::map_formula_callable& callable) { callable.add("base_value", wfl::variant(def)); - return formula.evaluate(callable).as_int(); - }); + return std::round(formula.evaluate(callable).as_int()); + })); std::map::iterator add_effect = values_add.find(effect_id); if(add_effect == values_add.end() || add > add_effect->second.value) { values_add[effect_id].set(ADD, add, ability.ability_cfg, ability.teacher_loc); } } if (const config::attribute_value *v = cfg.get("sub")) { - int sub = - get_single_ability_value(*v, def, ability, list.loc(), att, [&](const wfl::formula& formula, wfl::map_formula_callable& callable) { + int sub = - std::round(get_single_ability_value(*v, static_cast(def), ability, list.loc(), att, [&](const wfl::formula& formula, wfl::map_formula_callable& callable) { callable.add("base_value", wfl::variant(def)); - return formula.evaluate(callable).as_int(); - }); + return std::round(formula.evaluate(callable).as_int()); + })); std::map::iterator sub_effect = values_sub.find(effect_id); if(sub_effect == values_sub.end() || sub < sub_effect->second.value) { values_sub[effect_id].set(ADD, sub, ability.ability_cfg, ability.teacher_loc); } } if (const config::attribute_value *v = cfg.get("multiply")) { - int multiply = static_cast(get_single_ability_value(*v, static_cast(def), ability, list.loc(), att, [&](const wfl::formula& formula, wfl::map_formula_callable& callable) { + int multiply = std::round(get_single_ability_value(*v, static_cast(def), ability, list.loc(), att, [&](const wfl::formula& formula, wfl::map_formula_callable& callable) { callable.add("base_value", wfl::variant(def)); return formula.evaluate(callable).as_decimal() / 1000.0 ; }) * 100); @@ -2514,7 +2514,7 @@ effect::effect(const unit_ability_list& list, int def, const const_attack_ptr& a } } if (const config::attribute_value *v = cfg.get("divide")) { - int divide = static_cast(get_single_ability_value(*v, static_cast(def), ability, list.loc(), att, [&](const wfl::formula& formula, wfl::map_formula_callable& callable) { + int divide = std::round(get_single_ability_value(*v, static_cast(def), ability, list.loc(), att, [&](const wfl::formula& formula, wfl::map_formula_callable& callable) { callable.add("base_value", wfl::variant(def)); return formula.evaluate(callable).as_decimal() / 1000.0 ; }) * 100); @@ -2576,15 +2576,16 @@ effect::effect(const unit_ability_list& list, int def, const const_attack_ptr& a effect_list_.push_back(val.second); } - composite_value_ = static_cast((value_set + addition + substraction) * multiplier / divisor); + composite_double_value_ = (value_set + addition + substraction) * multiplier / divisor; //clamp what if min_value < max_value or one attribute only used. if(max_value && min_value && *min_value < *max_value) { - composite_value_ = std::clamp(*min_value, *max_value, composite_value_); + composite_double_value_ = std::clamp(static_cast(*min_value), static_cast(*max_value), composite_double_value_); } else if(max_value && !min_value) { - composite_value_ = std::min(*max_value, composite_value_); + composite_double_value_ = std::min(static_cast(*max_value), composite_double_value_); } else if(min_value && !max_value) { - composite_value_ = std::max(*min_value, composite_value_); + composite_double_value_ = std::max(static_cast(*min_value), composite_double_value_); } + composite_value_ = std::round(composite_double_value_); } } // end namespace unit_abilities diff --git a/src/units/abilities.hpp b/src/units/abilities.hpp index 74ae67a65af65..8620d21904a89 100644 --- a/src/units/abilities.hpp +++ b/src/units/abilities.hpp @@ -48,6 +48,8 @@ class effect int get_composite_value() const { return composite_value_; } + double get_composite_double_value() const + { return composite_double_value_; } const_iterator begin() const { return effect_list_.begin(); } const_iterator end() const @@ -55,6 +57,7 @@ class effect private: std::vector effect_list_; int composite_value_; + double composite_double_value_; }; diff --git a/src/units/attack_type.hpp b/src/units/attack_type.hpp index f2177b09cd677..a780eac173573 100644 --- a/src/units/attack_type.hpp +++ b/src/units/attack_type.hpp @@ -112,7 +112,7 @@ class attack_type : public std::enable_shared_from_this std::set alternative_damage_types() const; /** Returns the damage per attack of this weapon, considering specials. */ - int modified_damage() const; + double modified_damage() const; /** Return the special weapon value, considering specials. * @param abil_list The list of special checked.