Commit graph

329 commits

Author SHA1 Message Date
gfgtdf
851c909cd3
Fix #8460 [effect] apply_to=variation (#8475)
* Fix #8460 [effect] apply_to=variation

Previously the code could apply the variation effects
last, so that codes like
```
[effect]
  apply_to=variation
  ..
[/effect]
[effect]
  apply_to=hitpoints
  heal_full=yes
[/effect]
```
Would not set the unit hitpoints to the new variations
hitpoints because the variation effect was applied after
the healing effect.

In 1.16 this worked because healing was applied a little
too often but that lead also to bugs like #8342

* f prev

* f prev

* f prev

* f prev

* f prev

* Create modification_effect_type_variation.cfg

* Update wml_test_schedule
2024-03-07 01:25:59 +01:00
newfrenchy83
b4abee7c38
Fix increase by percentage returns 1 if experience is equal to zero (#8425)
Using `[effect]app/y_to,increase=experience,"40%"` on a unit with 0 XP used
to give that unit 1 XP, because of a minimum in the C++.
2024-02-19 13:49:09 +01:00
Steve Cotton
6b516e8aa5 Fix deprecation warning when setting [endlevel]end_credits=
Change the Lua implementation to directly call the
non-deprecated function, this is related to 9daa10a9f2.

Clean up the C++ header files by removing the declarations of
functions that were removed in 3c8de46771.

Use [endlevel]end_credits=no in the test scenario (trigger it
by moving to hex 9,3). If you debug with :next_level without
triggering the moveto, "The End" will show; trigger the moveto
first, and it won't show the credits.
2024-02-02 16:04:27 +01:00
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
87b42c404b Add a unit test for the event-handler reordering bug
This test would fail without the fix from the previous commit.
2024-01-21 01:38:48 +01:00
Steve Cotton
c25fc888a7 Make event_test_filter_condition check when the filters run
Also add the missing first_time_only=no, which is why the three [moveto]
events didn't trigger the third event three times.
2024-01-20 23:00:59 +01:00
Toom
2056be55a3
Support [harm_unit]experience values kill/attack/defend/fight/yes/no (#8231) 2024-01-18 11:32:18 +01:00
pentarctagon
26de1195e3 add a bunch of attacks tests 2024-01-08 12:04:45 -06:00
Steve Cotton
7c14bee3f8 Add tests for [harm_unit]
This is testing experience=yes and experience=no, with the expectation that
some new values for that attribute will be added afterwards.

Adds a new generic macro ASSERT_UNIT_HP_XP. Looking thorugh the ability tests,
ASSERT_UNIT_HP (without the XP) could be a heavily-used macro, but it wouldn't
be used by this particular commit, so I'm not adding it in this commit.
2024-01-04 17:50:49 +01:00
Pentarctagon
d4b1e7e6c4
Add some more abilities' tests (hides, skirmisher, teleport) 2024-01-01 12:34:08 +01:00
Pentarctagon
f992190267
add a bunch of illuminates tests. (#8139) 2023-12-23 12:07:45 -06:00
pentarctagon
23d7e3e7af add a comment. 2023-12-18 10:55:32 -06:00
pentarctagon
74e6f56d06 schema fixup. 2023-12-18 09:36:03 -06:00
pentarctagon
4080a6ebd0 max_value negative tests. 2023-12-17 23:42:35 -06:00
Pentarctagon
e94d4f0b7e
add a bunch of leadership ability tests (#8125) 2023-12-17 18:29:27 -06:00
Pentarctagon
6322ca8bc8
add a bunch of resistance ability tests (#8105) 2023-12-15 09:59:01 -06:00
newfrenchy83
f5c6402ed1 Fix [resistance] without max_value bug
Fix https://github.com/wesnoth/wesnoth/issues/8092 issue.

If none [resistance] ability of the list contain max_value, then [resistance] must work without max_value defined by default.
2023-12-14 17:12:44 -06:00
gfgtdf
99399a2b26 allow units.remove_modifications to remove multiple types
previously it needed multiple calls to remove multiple types of modifications (which could be slow since each call involves a full rebuild of the unit).
2023-12-13 17:01:28 +01:00
Steve Cotton
b63a5025e8 Fix the textdomain for the regeneration unit tests
The msgid "test-regenerate" was leaking into wesnoth.pot,
this was seen when running a pot-update locally.
2023-12-10 03:10:10 +01:00
pentarctagon
16ccaefc86 Test multiplying by a fractional value. 2023-12-07 00:07:33 -06:00
Pentarctagon
0ec7048a02
add a bunch of regenerate tests (#8079)
mostly the same as the heals tests, since they're basically the same ability with different defaults.
2023-12-05 23:15:26 -06:00
Pentarctagon
87ed0d0339
Add a bunch of tests for heals. (#8074)
Covers only attributes, not filters.
2023-11-30 11:09:52 +01:00
pentarctagon
e9588d755d [filter_specials] -> [experimental_filter_specials]
Since it calls into the same code as [filter_ability] did.
2023-11-17 17:41:41 -06:00
newfrenchy83
b54a901ff3 rename [filter_ability(_active)] to experimental_ability
because it is experimental the tag of filter is changed except for [overwrite][filter_specials]
2023-11-16 01:05:56 +01:00
Steve Cotton
f1807e03d3 New unit test for UtBS-style [heals] with a filter
The ability's code in UtBS hasn't changed since 1.16, but there's now a bug about
healing sometimes not working in UtBS S02. The new test was written to check
for an engine bug when a healer has two units next to it, only one of which
passes the filter; although it's passing, it seems reasonable to keep the test.

Also, use `{ASSERT ...}` for better logging in the old healing test.
2023-11-15 17:45:58 +01:00
newfrenchy83
9474525612
check alternative_type and replacement_type when filtering on type
Also move them from being attributes of [damage] to [damage_type], to avoid infinite recursion when determining what the damage type should be.
2023-11-10 16:35:57 -06:00
newfrenchy83
3910817cf7
add a 'replacement_type' and 'alternative_type' attribute in [damage] special or ability who modify the type of attack used (#7865)
At the suggestion of @stevecotton, I propose a special 'replacement_type' and 'alternative_type' attribute capable of modifying the type of attack used when the conditions are met.

Also make Holy water combine arcane damage with native type of weapon

Like holy water imbued ordinary weapon, it's seem logic what arcane damage dominant what if more efficient what original type(water can't altered pierce or blading of spear or sword)
2023-10-25 08:10:52 -05:00
Wedge009
45e537505f Use 'curly' quotes as per typography standard.
[ci skip]
2023-10-23 09:44:50 +02:00
Wedge009
4037e2a138 Replace non-standard spacing.
[ci skip]
2023-10-23 09:44:50 +02:00
newfrenchy83
532d17f958 repair detects non-existent default attribute value
Fix https://github.com/wesnoth/wesnoth/issues/7923 .when we want to detect an ability with value=0-20 and an ability with add=15 is present, this is detected because the system assigns a value of 0 when 'value' is not present, and so the system matches abilities that do not use 'value' or even no numerical value at all. it is therefore necessary to decide that the absence of an attribute is a non-correspondence to the criteria.
2023-10-14 20:14:51 -05:00
Steve Cotton
30eb439a27 Remove [filter_ability]type_value=
There are questions about how this filter should treat empty values, and the
use cases that we can think of can be implemented in other ways, for example,
if we want to look for big damage boosts, then we could filter for
`add=5-infinity` `[or]` `multiply=2-infinity`.

The simple answer seems to be to remove it from the API before we freeze for 1.18.
There's more discussion in issue 7944.
2023-10-12 15:31:45 +02:00
Steve Cotton
07c1f7805b Make the ability filter tests stricter
With the default first_time_only=yes then these events would be triggered at
most once even if the filter would have passed multiple times.
2023-10-12 15:31:45 +02:00
newfrenchy83
b5805eca8f
Add priority and filter to overwrite specials (#7746)
using overwrite_specials alone means that we have only two possibilities, either one_side is chosen and in this case if the ability used as a weapon carrying the attribute is applied to the unit (apply_to=self), the other abilities are the same type applied also to 'self' not carrying the attribute will be overwritten, but those of the opponent with apply_to=opponent will be kept in the list; or else both_sides is chosen and all abilities of the same type that do not carry the attribute will be overwritten. To be able to use the attribute in abilities like [damage] for example, it is necessary to be able to be even more selective as for a 'charge' type leadership with multiply=2.5 but which must not be combined with the classic charge and without overwriting the aute [damage] as backstab, [overwrite_filter] to only match damage with apply_to=both and active_on=offense is then interesting.

adding priority allows you to select that it ability can use its overwrite_specials attribute while the others can be overwritten in the same way as an ability without the attribute. Finally, this system makes it unnecessary to limit the use of the attribute to abilities used as weapons but also to special weapons.
2023-10-08 10:09:31 -05:00
newfrenchy83
a17369597c
give to abilitie support of halo or overlay (#7856)
give abilities support of halo or overlay so that the unit benefits from a second halo or overlay when conditions are matched

One of the things that bothers me is the permanent character of the halos of the Mage of Light and other units with the "illuminates" ability, which forces them to program only a permanent illumination applied only to the possessor of the ability.

Adding the halo attribute to ability does not change anything about the behavior of the unit, but can be used in several cases:

1 allowing the use of ""illuminates" whose activity would be variable, in this case encoding the halo in [illuminates] ability and not in the unit_type allows to modulate the appearance of the halo under the same conditions

2. Applying illumination to adjacent units, I know it's pretty cheesy but a set developer might consider it easier if the hlo display follows the same logic.

3 The halo used to illustrate the possession in the unit of a special weapon used as leadership, the halo would be used to raise the possessor of the ability.

for overlay, same logic for illustrate possession of a special weapon used as leadership, or influence on student

with the "halo_image" attribute, it is now possible to give Sun Sylph units an illumination ability with an activity depending on the incarnate sun attack instead of giving the ability and the halo via obect and therefore allowing the player to have access to the description of the ability even when it is inactive.
2023-09-25 11:06:41 -05:00
newfrenchy83
2a4a073da4 Add tests for ranges and negative values in ability filters
Changed to use "-" instead of ".." as the separator by octalot,
but I believe newfrenchy83 prefers "..".
2023-08-11 21:59:06 +02:00
Steve Cotton
cc8dddea6e Support negative numbers in ranges
Adds support for using these in the weapons and ability filters:
* "-1", which was previously treated as an parse error (no number before the separator).
* "-3--1"
* "-infinity" as the lower number in the range, provided a different upper number is given.

This treats "-infinity" (with no other number), "-infinity--infinity",
"infinity" (with no other number) and "infinity-infinity" as errors. It seems
unlikely that someone would intend to use a filter that can't match any
reasonable number.

The range "-infinity-infinity" will be parsed successfully. I don't see a use
case for that, but nor do I see a reason to add extra C++ to reject it.
However, it's not added to the schema, as I think it's good for the schema to
give a warning when someone creates a filter which will accept every value
(including accepting the default, so "-infinity-infinity" accepts the unset
value too).

Includes new unit tests for the C++ and the Lua stringx.parse_range functions.
The next commit adds more WML tests, but is kept separate to credit the author.

This started as a change to move common filter functions from unit.cpp to
somewhere that they could be reused for other config-based filters. In the
process a missing feature was found and added, the move is still included in a
single Git commit because the move was required in order to make these
functions accessible to the Boost unit tests.

Two CodeBlocks project files additionally get src/utils/any.hpp added,
which was in one of them but missing from the other two. I noticed because
these are alphabetically at the start of the src/utils file list.

Thanks to @CelticMinstrel for the review comments and Xcode project updates.
2023-08-11 21:59:06 +02:00
Ivo Julca
5ebc9a790a Implement event priority
For any given event name, events execute in order of decreasing priority.

Priority is a real number, and may be assigned via the `priority` attribute for
the WML [event] tag, or through the Lua APIs:

- wesnoth.game_events.add({priority = number})
- wesnoth.game_events.add_repeating(name, action, [priority])

Note that delayed variable substitution is not currently supported in the WML attribute.
2023-08-11 08:34:43 +02:00
Gunter Labes
64f702e96d
Move {join,host}.lua to a better place 2023-08-03 22:06:27 +02:00
Gunter Labes
dcbecefe9e
Improve script to update pathfinding unit tests 2023-07-18 19:41:42 +02:00
Pentarctagon
ac797db32a Add script to automate generating new pathfinding answers 2023-07-17 11:08:55 -05:00
Pentarctagon
9721ae4d23 Add unit movement changes from Hejnewar.
Also update the pathfinding test answers.
2023-07-17 09:11:38 -05:00
Cody Burchell
71e83f7b85
Prevent duplicate advancements from being added to unit type (#7743)
* Add myself to Miscellaneous Contributors

* types: Add unit tests over adding advancements
2023-07-09 05:08:10 +02:00
Steve Cotton
1efa0c8c54 Add a test for formulas in taught abilities
Originally by gfgtdf, this was cherry-picked from gfgtdf's PR #7589, with
modifications.

COMMON_KEEP_A_B_UNIT_TEST gains support for optional args
SIDE1_LEADER and SIDE2_LEADER.
2023-07-06 16:57:27 +02:00
Toom
b86b6efd0e
Create test for special_id_active in the style of eoma_beam (#7713)
Test created to verify that special_id_active does not work in 1.16.0.

https://github.com/inferno8/wesnoth-Era_of_Magic/issues/30
https://github.com/inferno8/wesnoth-Era_of_Magic/pull/54
2023-07-04 11:28:39 +02:00
Steve Cotton
1ecc30972e Test weapon-special plague vs taught plague
The expectation is that the a unit's own weapon special will take
priority over a teacher's ability.
2023-07-02 18:54:17 +02:00
Steve Cotton
aaf2735c1c Add [test_do_attack_by_id], a wrapper for [do_command][attack]
The new tag takes ids instead of needing coordinates. So instead of storing
units or hardcoding values, an attack can be done like this:

```
[test_do_attack_by_id]
	attacker=alice
	defender=bob
	weapon=0
[/test_do_attack_by_id]
```

Add a simpler unit for unit tests than the Elvish Archer / Orcish Grunt
combo, cherry-picked from gfgtdf's PR #7589. This is a unit with a 10x1
melee attack, and 0% defense on all terrains.

Remove the test race's undead_variation=
For testing custom plague abilities, this triggered a warning when
converting to any unit type that doesn't have variation_id=wolf,
restricting tests to using only Walking Corpse and Soulless.
2023-07-02 18:54:17 +02:00
newfrenchy83
f9a94e1312 [1.17] add [filter_ability] in [filter] events and [effect]remove_ability and [filter_ability_active] in [filter] events
see https://forums.wesnoth.org/viewtopic.php?p=681371#p681371 in forum

the type of ability used is also filtered.
2023-05-09 19:26:10 +02:00
gfgtdf
9530ad1bc7 add test for no [side]s in [scenario] 2023-05-09 16:50:50 +02:00
Steve Cotton
a9ed25e694 Reorder WML includes so manual tests can use the unit-test macros
Move the line that includes data/test/scenarios/manual_tests/ below the
line that includes data/test/macros/. This allows a manual test to use
the setup in COMMON_KEEP_A_B_C_D_UNIT_TEST, putting units in the right position
to test combat and leadership abilities.

Also improve comments in data/test/_main.cfg.
2023-05-08 10:58:22 +02:00
Steve Cotton
4da33cb7c5 Convert readme in data/test/scenarios to Markdown, and add docs
Add a new guideline that reserves test names containing `_fail_`
or ending `_fail` for tests that don't `PASS`. The rest is just
collecting knowledge already written elsewhere.
2023-05-07 11:10:06 +02:00