Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix [store_unit_defense] and add [store_unit_defense_on], add unit test
The existing tag has a confusing name - it returns the chance to be hit rather than the defense, for example 30 would be returned for a unit on 70% terrain. The new tag returns a higher-is-better value.
- Loading branch information
1 parent
5db9727
commit b8f03c4
Showing
4 changed files
with
138 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
# wmllint: no translatables | ||
|
||
{GENERIC_UNIT_TEST "test_store_unit_defense_on" ( | ||
[event] | ||
name = start | ||
|
||
# Alice and Bob are both standing on castles, add another unit on grassland | ||
{NOTRAIT_UNIT 1 "Footpad" 1 1} | ||
|
||
[store_unit_defense_on] | ||
id=alice | ||
# default output will be to terrain_defense | ||
[/store_unit_defense_on] | ||
{ASSERT {VARIABLE_CONDITIONAL terrain_defense equals 60}} | ||
|
||
# Check that both terrain= and variable= are supported | ||
[store_unit_defense_on] | ||
type="Footpad" | ||
terrain=Ke | ||
variable=footpad_defense | ||
[/store_unit_defense_on] | ||
{ASSERT {VARIABLE_CONDITIONAL footpad_defense equals 70}} | ||
# Check it didn't overwrite the default variable | ||
{ASSERT {VARIABLE_CONDITIONAL terrain_defense equals 60}} | ||
|
||
[store_unit_defense_on] | ||
id=alice | ||
terrain=Ke | ||
[/store_unit_defense_on] | ||
{ASSERT {VARIABLE_CONDITIONAL terrain_defense equals 60}} | ||
|
||
[store_unit_defense_on] | ||
id=alice | ||
terrain=Gg | ||
[/store_unit_defense_on] | ||
{ASSERT {VARIABLE_CONDITIONAL terrain_defense equals 40}} | ||
|
||
# Void is one of the terrains that's always defined, even if it's not used on the map | ||
[store_unit_defense_on] | ||
id=alice | ||
terrain=Xv | ||
[/store_unit_defense_on] | ||
{ASSERT {VARIABLE_CONDITIONAL terrain_defense equals 0}} | ||
|
||
# On this map, 1,1 is grassland | ||
[store_unit_defense_on] | ||
id=alice | ||
loc_x,loc_y=1,1 | ||
[/store_unit_defense_on] | ||
{ASSERT {VARIABLE_CONDITIONAL terrain_defense equals 40}} | ||
|
||
{SUCCEED} | ||
[/event] | ||
)} | ||
|
||
# Expected to succeed but trigger a deprecation warning (a BROKE_STRICT result) | ||
{GENERIC_UNIT_TEST "test_store_unit_defense_deprecated" ( | ||
[event] | ||
name = start | ||
|
||
# Alice and Bob are both standing on castles, add another unit on grassland | ||
{NOTRAIT_UNIT 1 "Footpad" 1 1} | ||
|
||
[store_unit_defense] | ||
id=alice | ||
[/store_unit_defense] | ||
{ASSERT {VARIABLE_CONDITIONAL terrain_defense equals 40}} | ||
|
||
# Check that both terrain= and variable= are supported | ||
[store_unit_defense] | ||
type="Footpad" | ||
terrain=Ke | ||
variable=footpad_defense | ||
[/store_unit_defense] | ||
{ASSERT {VARIABLE_CONDITIONAL footpad_defense equals 30}} | ||
# Check it didn't overwrite the default variable | ||
{ASSERT {VARIABLE_CONDITIONAL terrain_defense equals 40}} | ||
|
||
[store_unit_defense] | ||
id=alice | ||
terrain=Ke | ||
[/store_unit_defense] | ||
{ASSERT {VARIABLE_CONDITIONAL terrain_defense equals 40}} | ||
|
||
[store_unit_defense] | ||
id=alice | ||
terrain=Gg | ||
[/store_unit_defense] | ||
{ASSERT {VARIABLE_CONDITIONAL terrain_defense equals 60}} | ||
|
||
# Void is one of the terrains that's always defined, even if it's not used on the map | ||
[store_unit_defense] | ||
id=alice | ||
terrain=Xv | ||
[/store_unit_defense] | ||
{ASSERT {VARIABLE_CONDITIONAL terrain_defense equals 100}} | ||
|
||
# On this map, 1,1 is grassland | ||
[store_unit_defense] | ||
id=alice | ||
loc_x,loc_y=1,1 | ||
[/store_unit_defense] | ||
{ASSERT {VARIABLE_CONDITIONAL terrain_defense equals 60}} | ||
|
||
{SUCCEED} | ||
[/event] | ||
)} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters