Commit graph

25 commits

Author SHA1 Message Date
Steve Cotton
84b1a778ae Backstab unit tests: check that backstab works in a free-for-all
The units on the outsides of a backstab don't have to be allied
to each other, they just have to be enemies of the victim. That's
hardcoded into the AI via attack.cpp's backstab_check() function,
hence a unit test to check that WEAPON_SPECIAL_BACKSTAB activates
in that situation.

Add a new map with 4 sides all on separate castles. This is a
variation of the generic 2p unit test map, extended in the south
with a horizontal reflection of existing map.

Add a MAP_FILE argument to COMMON_KEEP_A_B_C_D_UNIT_TEST,
because it's the same setup except for the map file.
2024-01-26 14:35:07 +00:00
Steve Cotton
0f6a94f2a7 Unit tests for [drains], [poison] and [slow], with apply_to=opponent
Slightly different to PR #6582, which was the 1.16 version of this. The five
lines that were labelled `preserving known bug` are changed to test that it's
been fixed.

Here `apply_to=opponent` means that the weapon special gives the opponent the
ability, the unit that should get poisoned or slowed is the unit that has the
weapon special.

There's a known bug in 1.16, that `apply_to=opponent` check the wrong unit to
see it it's `unpoisonable`, `undrainable` etc. It also checks the wrong unit to
see if it's already poisoned or slowed, so a battle between two units that both
have reverse-poison results in at most one being poisoned.

Most of the credit for this is Newfrenchy's, as he's already written a fix
and a WML based test. This commit uses a Lua test instead to test more
combinations of statuses.

This adds a `COMMON_KEEP_A_B_UNIT_TEST` macro, which is a counterpart to the
`GENERIC_UNIT_TEST` macro that starts the leaders next to each other, ready
to attack. The `A_B` is because I'm planning a multiple-side variant too.

There's no test for [petrify], as simulate_combat doesn't provide a stat for it.

This tests only 3 of the 6 abilities whose behavior changed in 650f70405f.
My thoughts on testing the others are:
* [firststrike]'s test is in 650f70405f.
* [drains], [poison] and [slow] are tested here.
* [petrify] ends combat, it's also not exposed in simulate_combat's stats.
* [plague] triggers after combat ends.
2022-04-19 15:27:49 +02:00
newfrenchy83
650f70405f
fix [firststrike] special with apply_to=opponent crashes Wesnoth 1.17.x (#6574)
As reported on the forum in https://forums.wesnoth.org/viewtopic.php?p=672374#p672374
If a unit with "last strike" ([firststrike] special with apply_to=opponent, on any of its attacks)
was targeted by other unit for attack, wesnoth crashed.

Fix similar problems for other weapon specials like poisons, when two users of specials with
apply_to=opponent fought, one fighter only could be poisoned or slowed.

* Add a unit test for poison
* Add a unit test for firststrike and laststrike
2022-04-08 02:30:14 +02:00
Wedge009
f983a998a2 Replace deprecated share_maps and share_view with share_vision.
Closes #6496.

share_maps=yes -> share_vision=shroud
share_view=yes -> share_vision=all
2022-02-15 22:08:03 +11:00
Celtic Minstrel
d39e6b3f42 Schema: Make turns validation more generic
This means other things can now easily accept the special keyword "unlimited".
2021-06-18 13:53:34 -04:00
Celtic Minstrel
0c42cdc038
Enable translation mark validation by the schema (#5800)
- The t_string type is now a schema built-in type and no longer attempts a regex match.
- You can also specify that non-t_string types may be optionally-translatable; this case supports a regex match on the string (but note that the translation mark is not part of the match).
- Error messages involving keys with very large values ( > 128 characters) will now truncate the value.
- To account for occasional cases where the schema is intentionally violated, the --validate command-line option now automatically defines the SCHEMA_VALIDATION preprocessor define.

A key validates as type t_string if one of the following is true:
- The key is not present
- The key has at least one segment with a translation mark
- The key is blank (an empty string)

Any type other than t_string is not allowed to be translatable by default, unless you specify allow_translatable=yes in the [type] tag.

An optionally-translatable string could also be defined as a union of t_string and some other type.
2021-06-14 23:59:52 -04:00
Celtic Minstrel
574bc1a36e Resolve [terrain_mask]mask_file= relative to the [binary_path] like map_file= is 2021-05-11 14:52:22 -04:00
Pentarctagon
5af1f129cd Mass convert of *^Uf terrain for SP. 2020-09-15 09:26:00 -05:00
Celtic Minstrel
b8759f8c19 Add some additional cases to the move_unit test, and fix a few issues that they revealed
One of the cases fails due to something in find_vacant_tile - perhaps someone else can figure out how to fix this?

If nothing else, setting check_passability=no in the [move_unit] should do it, but I'd prefer not to have to do that...
2019-12-10 21:16:06 -05:00
nemaara
50629f28cb Change dunefolk units in faction definitions and pathfinding tests 2019-11-08 16:44:13 -05:00
Steve Cotton
06dd9a140c Add [find_path] option "nearest_by", and simple_find_path test
Adding this is issue 2 of #4177, changing the behavior when [find_path]
is given a SLF which matches multiple hexes.

The map and tests here should be easy enough for manually editing them. It
duplicates some of the functionality of the existing characterize_pathfinding
tests, however those tests need their expected values to be calculated and
can't be changed by hand.

'''nearest_by''': {DevFeature1.15|2} possible values "movement_cost"
(default), "steps", "hexes". If the [destination] SLF matches multiple hexes,
the one that would need the least movement points to reach may not be the one
that's closest as measured by '''hexes''', or closest as measured by steps,
from the starting point.

Behavior in 1.14 depended on which hex was checked first.
2019-09-11 11:17:56 +02:00
Steve Cotton
358f564301 Add unit tests for movement and vision costs
Includes changing the terrain costs, and aliased terrains.

Can be cleanly cherry-picked to 1.14.
2019-07-22 17:18:20 +02:00
Celtic Minstrel
8b9d317d72 WML Unit Tests: Fix issues found by the schema validator
With this, the WML unit tests are as clean of schema errors as they can get
The two remaining errors are unit tests for dealing with invalid input,
so they are intentionally violating the schema.
2018-10-23 22:49:45 -04:00
sigurdfdragon
dfdf8ccacd Update ids to match type changes in 91e0bb4911 2018-02-16 17:51:00 -05:00
Charles Dang
91e0bb4911 Fixed some remaining uses of deprecated Khalifate names
[ci skip]

Also "colour"->"color"
2018-02-13 05:45:31 +11:00
gfgtdf
7f13156c28 Revert "Rename team_name/user_team_name to team_id/team_name (old syntax still valid)"
And related commits.

This reverts commit 545253ec2b.
This reverts commit 1215f65eb8.
This reverts commit 11664f4024.
This reverts commit e948df3424.
This reverts commit 3781e7839f.

This commits were reverted to exclude them from wesnoth 1.13.2 release because:
1) We are still unsure about the best name oftthese attributes
2) This breaks multiple campaigns, including LoW and the tutorial.
Feel free to revert this revert after 1.13.2 when thse issues can be solved..
2015-12-10 21:29:52 +01:00
Charles Dang
e948df3424 Updated unit tests to use new team id/name syntax 2015-10-26 13:40:44 +11:00
Ignacio R. Morelle
1799d5eb0d wmlindent pass on data/test/, safe subset
There is some WML in data/test/scenarios/ that causes wmlindent to
misbehave (bug #22264 and possibly others awaiting a more thorough
diagnosis), so that subdir is not part of this commit.
2014-07-02 22:04:52 -04:00
Chris Beck
3a102774b5 fixup pathfind tests, add reachability tests 2014-05-28 01:31:09 -04:00
Chris Beck
6cb367594b test [store_locations], and try to characterize [find_path] 2014-05-27 20:30:30 -04:00
Chris Beck
d129d80ebe Add unit tests for check victory function
Mainly focused on defeat_condition field right now... woudl be good
to add some that test victory_when_enemies_defeated.
2014-05-22 17:21:53 -04:00
Chris Beck
2c486ed699 add tests of the [move] skip_sighted_option
This is partially a follow up of previous commit
403af25e9d
2014-05-16 19:35:06 -04:00
Chris Beck
94fdab4389 add sighted events unit tests 2014-05-16 18:09:52 -04:00
Chris Beck
9df026f8e8 move test_grunt_tod_damage map to a map file 2014-05-16 17:11:27 -04:00
Chris Beck
0201fe3247 put generic unit test map in its own file 2014-05-16 17:05:31 -04:00