Skip to content

Commit

Permalink
Fix [damage] weapon special produces unexpected damage values
Browse files Browse the repository at this point in the history
  • Loading branch information
newfrenchy83 committed Dec 22, 2024
1 parent 11eaca1 commit 3e36bb4
Show file tree
Hide file tree
Showing 27 changed files with 78 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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" (
Expand All @@ -27,6 +27,6 @@
[/modify_unit]
[/event]

{CHECK_STRIKES "3,3" ({SUCCEED})}
{CHECK_STRIKES "4,4" ({SUCCEED})}
)}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -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" (
Expand All @@ -27,6 +27,6 @@
[/modify_unit]
[/event]

{CHECK_STRIKES "4,4" ({SUCCEED})}
{CHECK_STRIKES "6,6" ({SUCCEED})}
)}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -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" (
Expand All @@ -28,6 +28,6 @@
[/modify_unit]
[/event]

{CHECK_STRIKES "6,12" ({SUCCEED})}
{CHECK_STRIKES "8,16" ({SUCCEED})}
)}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -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" (
Expand All @@ -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"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" (
Expand All @@ -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"}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
#####
Expand All @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" (
Expand Down Expand Up @@ -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]
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" (
Expand Down Expand Up @@ -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]
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" (
Expand All @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" (
Expand All @@ -27,7 +27,7 @@
[/effect]
[/modify_unit]

{ATTACK_AND_VALIDATE 144}
{ATTACK_AND_VALIDATE 146}
{SUCCEED}
[/event]
) SIDE1_LEADER=Mage SIDE2_LEADER=Mage}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" (
Expand All @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" (
Expand All @@ -26,7 +26,7 @@
[/effect]
[/modify_unit]

{ATTACK_AND_VALIDATE 144}
{ATTACK_AND_VALIDATE 146}
{SUCCEED}
[/event]
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" (
Expand Down Expand Up @@ -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]
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" (
Expand Down Expand Up @@ -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]
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" (
Expand All @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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" (
Expand All @@ -27,7 +27,7 @@
[/effect]
[/modify_unit]

{ATTACK_AND_VALIDATE 56}
{ATTACK_AND_VALIDATE 54}
{SUCCEED}
[/event]
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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=
##
Expand All @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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" (
Expand All @@ -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]
Expand Down
Loading

0 comments on commit 3e36bb4

Please sign in to comment.