Add `first_time_only=no` to some existing tests, and verify that events that
should only trigger once do trigger exactly once.
A new test of `[filter_attack]` when an event lacks attack data. In testing,
I found that it used to trigger a warning that I thought was useless code, and
had removed during 88439d6427a81a6b131acd8b0f7bf04b2d981d71's review. I think
removing it is still good, at the time that the filter was checked it would have
warned "attempt to filter attack for an event with no attack data."
A new test of what happens when a unit with only a ranged weapon fights a
unit with only a melee weapon. This commit is just the test, it depends on
the engine fix in a previous commit.
This only tests the filtering so far. There should probably be another
additional test to check what the combat results are, however that would need
an ability such as the Deep Elves' Stardust that passively affects the amount
of damage taken. It can't be tested with Slows, as that needs the defender to
hit with a weapon first.
When we try to trigger an event conditioned by the use of a special whose activity is subject to a condition, we cannot use special_active because the specials are always considered inactive. Additionally, abilities used as weapons possessed or taught by a leadership are also not detectable in [event][filter_attack]. This PR is there to remedy this double problem.
Also remove matches_special_filter and directly use matches_filter.
Since a0ee38a49, the inner this_item was still in scope when the inner loop
writes changed data back to the outer loop's variable, which meant that
changes were silently ignored.
A lot of the changes in wml-flow.lua are just indentation because of the
extra block.
* Add basic achievements functionality.
This reads the mainline achievements.cfg and then all the achievements of each installed add-on.
This is intentionally handled separately from other WML loading so that:
a) All achievements and their status are able to be displayed on the main menu right after Wesnoth starts and regardless of which add-ons are active.
b) Add-ons can add additional achievements to other content, whether UMC or mainline. For example, a modification that adds more achievements for mainline campaigns.
Marking something as achieved is handled by the new [set_achieved] tag and whether an achievement has been completed can be checked via [has_achievement].
There is no attempt to prevent people from manually editing which achievements they've accomplished.
NOTE: These are *not* in any way related to Steam achievements!
I think I'm using two wmlindent bugs against each other here, putting two
opening statements on the same line to balance two closing statements on the
same line. However, the unit tests ought to be code that can be cut & pasted
elsewhere without causing indentation problems, and this is simpler than fixing
wmlindent's Lua parsing.
This doesn't cover all of the unit tests, it's the result of running wmlindent
on all of them and then reviewing whether the changes were bugs in the test, or
whether they're bugs in wmlindent.
Note: there are two cve_2018_1999023 tests. The other one needs to be treated
as a binary file, but the one changed here is plain text that loads its attack
from a separate file.
The change in start_position_generic.cfg doesn't seem good, but it's not
particularly bad and it's what wmlindent currently does.
Covers the math for [attack]add=, [attack]divide=, [attack]multiply= and
[attack]sub=. The behavior is the same in 1.16.
* 5 + 2 = 7
* 5 - 3 = 2
* 5 + 2 - 3 = 2. Yes it does, that's half of why this unit test exists ...
* 5 + 2 + 3 = 8
* 5 + 3 + 2 = 8
* 5 + 2 - (-3) = 7
* 3 * 3.34 = 10
* 3 * 3.334 = 9. ... and that's the other half of why this unit test exists.
The movetype's special notes were becoming a new note for the individual unit.
Clean up the documentation on some of movetype's functions, as they had
documentation in both the .hpp and the .cpp.
Move `event_name_variable_substitution` to the top of the file, as it's testing
that the event triggers at all, before the tests that check which order the
events are triggered in.
The old `order_of_variable_events1` seemed to be a combination of two tests that
should exist, but the code didn't quite test either of them. This replaces it
with a new `order_of_variable_events1` and `order_of_variable_events3`.
Docs partially written by Pentarctagon, this started as a review comment
on the documentation PR.
The existing backstab tests' common code is moved to a utility file
for reuse in other tests, because it can be used to check whether a
weapon special was active during the damage calculations.
Git's diff can show a lot of lines being deleted, but that's just
because it's showing a file being copied, and then half of each copy
being removed.
Basically this means each of the call modes of the old function is now a separate function.
- add_repeating and add_menu take an ID and a function
- add_wml takes variable substitution setting and a config
- add takes the full options table
in this test, two same leadership with value attribute and cumulative=yes add their value then what two leadership with same id and 'add' attribute using on 'add' only(the highest when 'add' value is different)
this test is added for verify what cumulative=yes work in same time what 'add' and 'sub' and what using of these attributes in[leadership] don't be
changed, only using of cumulative work anew like in 1.14
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.
Turn the 4 side setup of the firststrike_and_laststrike test into a macro
called `COMMON_KEEP_A_B_C_D`for reuse in other tests.
The comment for `GENERIC_UNIT_TEST` gets a couple of extra paragraphs.
All the files get wmlindent run on them, which reindents `FAIL_IF_NOT`.
The main reason for having these is separate files is Git's fuzzy-patch
matching when merging and rebasing. Having large blocks of identical text
in `wml_unit_test_macros.cfg` can mean the wrong section gets patched.
This returns a label handle which allows you to remove, reposition, or replace the label later.
In addition to all the features of wesnoth.print, you can now specify where the label appears onscreen, as well as a fadeout time separate from the duration.
You can also anchor the text to an edge or corner instead of centering in on the screen,
specify the maximum width it can occupy as an absolute width or a percentage,
and specify a background colour and transparency.
It includes a demo scenario that demonstrates many of the capabilities of the API.
To play the demo scenario, run with -toverlay_text_demo or select it from the in-game test list.
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