Unit tests for [effect]apply_to=movement and [effect]apply_to=vision
These would also pass on 1.14, checking that movement does affect vision if and only if vision hasn't been modified separately. The comments talk about an [effect]also_apply_to_vision= attribute which hasn't been added yet, the aim of these tests is to regression test that attribute when it is added.
This commit is contained in:
parent
6e7f4abaec
commit
20eb001be3
2 changed files with 251 additions and 0 deletions
247
data/test/scenarios/test_effect_on_vision.cfg
Normal file
247
data/test/scenarios/test_effect_on_vision.cfg
Normal file
|
@ -0,0 +1,247 @@
|
|||
# wmllint: no translatables
|
||||
|
||||
# This series of tests checks that the C++ unit class handles changes to movement and vision points correctly.
|
||||
|
||||
#define ASSERT_ALICE_STAT stat relation value
|
||||
[store_unit]
|
||||
[filter]
|
||||
id=alice
|
||||
[/filter]
|
||||
variable=temp_for_stat_assert
|
||||
[/store_unit]
|
||||
{ASSERT {VARIABLE_CONDITIONAL temp_for_stat_assert.{stat} {relation} {value}}}
|
||||
[clear_variable]
|
||||
name=temp_for_stat_assert
|
||||
[/clear_variable]
|
||||
#enddef
|
||||
|
||||
#define ASSERT_VISION_EFFECTIVELY relation value
|
||||
# Similar to "ASSERT_ALICE_STAT vision", but with manual handling for the -1 value. When using [store_unit], we see the raw value of -1, even though pathfinding calculations would interpret that as "same value as max_moves".
|
||||
[store_unit]
|
||||
[filter]
|
||||
id=alice
|
||||
[/filter]
|
||||
variable=temp_for_stat_assert
|
||||
[/store_unit]
|
||||
[if]
|
||||
{VARIABLE_CONDITIONAL temp_for_stat_assert.vision equals -1}
|
||||
[then]
|
||||
{ASSERT {VARIABLE_CONDITIONAL temp_for_stat_assert.max_moves {relation} {value}}}
|
||||
[/then]
|
||||
[else]
|
||||
{ASSERT {VARIABLE_CONDITIONAL temp_for_stat_assert.vision {relation} {value}}}
|
||||
[/else]
|
||||
[/if]
|
||||
[clear_variable]
|
||||
name=temp_for_stat_assert
|
||||
[/clear_variable]
|
||||
#enddef
|
||||
|
||||
# Test that changing the max_moves affects the vision points, assuming that the vision points haven't been explicitly set to a separate value.
|
||||
# This test would also pass on 1.14, movement always affected vision in this case.
|
||||
{GENERIC_UNIT_TEST "effect_move_affects_vision" (
|
||||
[event]
|
||||
name = side 1 turn 1
|
||||
|
||||
# Sanity-check default values for an Elvish Archer
|
||||
{ASSERT_ALICE_STAT max_moves equals 6}
|
||||
{ASSERT_VISION_EFFECTIVELY equals 6}
|
||||
{ASSERT_ALICE_STAT jamming equals 0}
|
||||
|
||||
[modify_unit]
|
||||
[filter]
|
||||
id=alice
|
||||
[/filter]
|
||||
[effect]
|
||||
apply_to=movement
|
||||
set=5
|
||||
[/effect]
|
||||
[/modify_unit]
|
||||
{ASSERT_ALICE_STAT max_moves equals 5}
|
||||
{ASSERT_VISION_EFFECTIVELY equals 5}
|
||||
{ASSERT_ALICE_STAT jamming equals 0}
|
||||
|
||||
[modify_unit]
|
||||
[filter]
|
||||
id=alice
|
||||
[/filter]
|
||||
[effect]
|
||||
apply_to=movement
|
||||
increase=5
|
||||
[/effect]
|
||||
[/modify_unit]
|
||||
{ASSERT_ALICE_STAT max_moves equals 10}
|
||||
{ASSERT_VISION_EFFECTIVELY equals 10}
|
||||
{ASSERT_ALICE_STAT jamming equals 0}
|
||||
|
||||
[modify_unit]
|
||||
[filter]
|
||||
id=alice
|
||||
[/filter]
|
||||
[effect]
|
||||
apply_to=movement
|
||||
increase=50%
|
||||
[/effect]
|
||||
[/modify_unit]
|
||||
{ASSERT_ALICE_STAT max_moves equals 15}
|
||||
{ASSERT_VISION_EFFECTIVELY equals 15}
|
||||
{ASSERT_ALICE_STAT jamming equals 0}
|
||||
|
||||
# Test a negative increase
|
||||
[modify_unit]
|
||||
[filter]
|
||||
id=alice
|
||||
[/filter]
|
||||
[effect]
|
||||
apply_to=movement
|
||||
increase=-5
|
||||
[/effect]
|
||||
[/modify_unit]
|
||||
{ASSERT_ALICE_STAT max_moves equals 10}
|
||||
{ASSERT_VISION_EFFECTIVELY equals 10}
|
||||
{ASSERT_ALICE_STAT jamming equals 0}
|
||||
|
||||
# Test that setting the stat to zero works
|
||||
[modify_unit]
|
||||
[filter]
|
||||
id=alice
|
||||
[/filter]
|
||||
[effect]
|
||||
apply_to=movement
|
||||
set=0
|
||||
[/effect]
|
||||
[/modify_unit]
|
||||
{ASSERT_ALICE_STAT max_moves equals 0}
|
||||
{ASSERT_VISION_EFFECTIVELY equals 0}
|
||||
{ASSERT_ALICE_STAT jamming equals 0}
|
||||
|
||||
{SUCCEED}
|
||||
[/event]
|
||||
)}
|
||||
|
||||
# Test that apply_to=vision works
|
||||
{GENERIC_UNIT_TEST "effect_vision" (
|
||||
[event]
|
||||
name = side 1 turn 1
|
||||
|
||||
# Sanity-check default values for an Elvish Archer
|
||||
{ASSERT_ALICE_STAT max_moves equals 6}
|
||||
{ASSERT_VISION_EFFECTIVELY equals 6}
|
||||
{ASSERT_ALICE_STAT jamming equals 0}
|
||||
|
||||
[modify_unit]
|
||||
[filter]
|
||||
id=alice
|
||||
[/filter]
|
||||
[effect]
|
||||
apply_to=vision
|
||||
set=2
|
||||
[/effect]
|
||||
[/modify_unit]
|
||||
{ASSERT_ALICE_STAT max_moves equals 6}
|
||||
{ASSERT_VISION_EFFECTIVELY equals 2}
|
||||
{ASSERT_ALICE_STAT jamming equals 0}
|
||||
|
||||
[modify_unit]
|
||||
[filter]
|
||||
id=alice
|
||||
[/filter]
|
||||
[effect]
|
||||
apply_to=vision
|
||||
increase=50%
|
||||
[/effect]
|
||||
[/modify_unit]
|
||||
{ASSERT_ALICE_STAT max_moves equals 6}
|
||||
{ASSERT_VISION_EFFECTIVELY equals 3}
|
||||
{ASSERT_ALICE_STAT jamming equals 0}
|
||||
|
||||
{SUCCEED}
|
||||
[/event]
|
||||
)}
|
||||
|
||||
# Test that setting vision will avoid changing vision afterwards.
|
||||
{GENERIC_UNIT_TEST "effect_move_ignores_vision" (
|
||||
[event]
|
||||
name = side 1 turn 1
|
||||
|
||||
# Sanity-check default values for an Elvish Archer
|
||||
{ASSERT_ALICE_STAT max_moves equals 6}
|
||||
{ASSERT_VISION_EFFECTIVELY equals 6}
|
||||
{ASSERT_ALICE_STAT jamming equals 0}
|
||||
|
||||
# In 1.14, this is a test that the default behavior hasn't changed, that setting vision to a value other than -1 will break the link between movement and vision.
|
||||
# In 1.16, this will be replaced by a test of the also_apply_to_vision=no attribute.
|
||||
[modify_unit]
|
||||
[filter]
|
||||
id=alice
|
||||
[/filter]
|
||||
[effect]
|
||||
apply_to=vision
|
||||
set=6
|
||||
[/effect]
|
||||
[/modify_unit]
|
||||
|
||||
# Make a copy so that each subpart of this test can reset her to this state
|
||||
[store_unit]
|
||||
[filter]
|
||||
id=alice
|
||||
[/filter]
|
||||
variable=unmodified_alice
|
||||
kill=no
|
||||
[/store_unit]
|
||||
|
||||
[modify_unit]
|
||||
[filter]
|
||||
id=alice
|
||||
[/filter]
|
||||
[effect]
|
||||
apply_to=movement
|
||||
set=7
|
||||
[/effect]
|
||||
[/modify_unit]
|
||||
{ASSERT_ALICE_STAT max_moves equals 7}
|
||||
{ASSERT_VISION_EFFECTIVELY equals 6}
|
||||
{ASSERT_ALICE_STAT jamming equals 0}
|
||||
|
||||
[unstore_unit]
|
||||
variable=unmodified_alice
|
||||
[/unstore_unit]
|
||||
|
||||
[modify_unit]
|
||||
[filter]
|
||||
id=alice
|
||||
[/filter]
|
||||
[effect]
|
||||
apply_to=movement
|
||||
increase=4
|
||||
[/effect]
|
||||
[/modify_unit]
|
||||
{ASSERT_ALICE_STAT max_moves equals 10}
|
||||
{ASSERT_VISION_EFFECTIVELY equals 6}
|
||||
{ASSERT_ALICE_STAT jamming equals 0}
|
||||
|
||||
[unstore_unit]
|
||||
variable=unmodified_alice
|
||||
[/unstore_unit]
|
||||
|
||||
[modify_unit]
|
||||
[filter]
|
||||
id=alice
|
||||
[/filter]
|
||||
[effect]
|
||||
apply_to=movement
|
||||
increase=50%
|
||||
[/effect]
|
||||
[/modify_unit]
|
||||
{ASSERT_ALICE_STAT max_moves equals 9}
|
||||
{ASSERT_VISION_EFFECTIVELY equals 6}
|
||||
{ASSERT_ALICE_STAT jamming equals 0}
|
||||
|
||||
{CLEAR_VARIABLE unmodified_alice}
|
||||
|
||||
{SUCCEED}
|
||||
[/event]
|
||||
)}
|
||||
|
||||
#undef ASSERT_VISION_EFFECTIVELY
|
||||
#undef ASSERT_ALICE_STAT
|
|
@ -169,6 +169,10 @@
|
|||
0 test_elf_longsighted_cave_and_hills_vision
|
||||
0 test_elf_longsighted_cave_slow_cave_vision
|
||||
0 test_resistances
|
||||
# [effect]apply_to=movement and [effect]apply_to=vision
|
||||
0 effect_move_affects_vision
|
||||
0 effect_move_ignores_vision
|
||||
0 effect_vision
|
||||
#
|
||||
# Attack calculations & codepath tests
|
||||
#
|
||||
|
|
Loading…
Add table
Reference in a new issue