Unit tests to evaluate behavior with max_experience=0 and with no advancements (#7344)

This commit is contained in:
Toranks 2023-02-04 13:14:44 +01:00 committed by GitHub
parent 71ceac09b1
commit ec8ad5f26f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 156 additions and 0 deletions

View file

@ -0,0 +1,66 @@
# wmllint: no translatables
#####
# API(s) being tested: [unit][advancement]
##
# Actions:
# Harm Alice and Bob with 1 hitpoint to be sure that they have some damage. Delete advancements of both units and give them 999 experience. They then fight each other.
##
# Expected end state:
# Bob and Alice doesn't level up, keeps their HP, and gains experience. The default behaviour should be that a unit will never advances if it has no advancements, but still can gain experience internally (seen with inspect console).
#####
{COMMON_KEEP_A_B_UNIT_TEST "unit_no_advancements" (
[event]
name=prestart
[harm_unit]
[filter]
id=bob,alice
[/filter]
amount=1
[/harm_unit]
[modify_unit]
[filter]
id=alice,bob
[/filter]
[object]
[effect]
apply_to=remove_advancement
types=Orcish Warrior,Elvish Ranger,Elvish Marksman
[/effect]
[/object]
experience=999
[/modify_unit]
[/event]
[event]
name=start
[do_command]
[attack]
weapon=0
defender_weapon=0
[source]
x,y=5,3
[/source]
[destination]
x,y=4,3
[/destination]
[/attack]
[/do_command]
[store_unit]
[filter]
id=alice
[/filter]
variable=alice
[/store_unit]
[store_unit]
[filter]
id=bob
[/filter]
variable=bob
[/store_unit]
{ASSERT ({VARIABLE_CONDITIONAL bob.hitpoints less_than $bob.max_hitpoints})}
{ASSERT ({VARIABLE_CONDITIONAL alice.hitpoints less_than $alice.max_hitpoints})}
{ASSERT ({VARIABLE_CONDITIONAL bob.experience greater_than 999})}
{ASSERT ({VARIABLE_CONDITIONAL alice.experience greater_than 999})}
{SUCCEED}
[/event]
)}

View file

@ -0,0 +1,88 @@
# wmllint: no translatables
#####
# API(s) being tested: [unit]max_experience=0
##
# Actions:
# Try to set Alice's and Bob's max_experience to 0 and check that the engine applies a minimum of 1. Delete Bob's 'Orcish Warrior' advancement but not Alice's. Harm bob with 1 hitpoint to be sure that he have some damage. They then fight each other.
##
# Expected end state:
# Alice levels up and changes his max_experience to the advancement. Bob don't advances and have 1 point of max experience. The default behaviour is for a unit with max_experience 0 always changes to 1, no matter if they have advancements or not (seen with inspect console).
#####
{COMMON_KEEP_A_B_UNIT_TEST "zero_experience" (
[event]
name=prestart
[modify_unit]
[filter]
id=alice,bob
[/filter]
[effect]
apply_to=max_experience
set=0
[/effect]
[/modify_unit]
[modify_unit]
[filter]
id=alice,bob
[/filter]
[object]
[effect]
apply_to=remove_advancement
types=Orcish Warrior
[/effect]
[/object]
[/modify_unit]
[harm_unit]
[filter]
id=bob,alice
[/filter]
amount=1
[/harm_unit]
[store_unit]
[filter]
id=alice
[/filter]
variable=pre_alice
[/store_unit]
[store_unit]
[filter]
id=bob
[/filter]
variable=pre_bob
[/store_unit]
[/event]
[event]
name=start
[do_command]
[attack]
weapon=0
defender_weapon=0
[source]
x,y=5,3
[/source]
[destination]
x,y=4,3
[/destination]
[/attack]
[/do_command]
[store_unit]
[filter]
id=alice
[/filter]
variable=alice
[/store_unit]
[store_unit]
[filter]
id=bob
[/filter]
variable=bob
[/store_unit]
{ASSERT ({VARIABLE_CONDITIONAL pre_bob.max_experience numerical_equals 1})}
{ASSERT ({VARIABLE_CONDITIONAL pre_alice.max_experience numerical_equals 1})}
{ASSERT ({VARIABLE_CONDITIONAL bob.max_experience numerical_equals 1})}
{ASSERT ({VARIABLE_CONDITIONAL alice.max_experience greater_than 1})}
{ASSERT ({VARIABLE_CONDITIONAL bob.level numerical_equals 1})}
{ASSERT ({VARIABLE_CONDITIONAL alice.level numerical_equals 2})}
{SUCCEED}
[/event]
)}

View file

@ -430,6 +430,8 @@
0 kill_fires_events
# Game mechanics
0 heal
0 zero_experience
0 unit_no_advancements
# Warnings about WML
0 unknown_scenario_false_positives
0 unknown_scenario_interpolated