Commit graph

377 commits

Author SHA1 Message Date
Steve Cotton
72863e578b Add a unit test for resistances (using the standard 6 damage types)
I'm working on a bugfix for the [resistance_defaults] tag, for which the
unit test is going to be out-of-tree until we support some method of testing
it without affecting other tests. The version here is the part of that which
can be in-tree, because it doesn't change the core unit's stats.
2020-11-29 22:30:14 +01:00
Steve Cotton
ffeb80f6ca Add a unit test for the behavior of [unit]id= recalling units
Answers a question raised in PR #4999. This also passes on 1.14.
2020-11-19 16:07:47 +01:00
Steve Cotton
b8f03c40e6 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.
2020-10-28 22:10:46 +01:00
Pentarctagon
5af1f129cd Mass convert of *^Uf terrain for SP. 2020-09-15 09:26:00 -05:00
Pentarctagon
9a0b95f9a0 Separate unit test results from scenario victory/defeat.
This adds an additional `test_result` attribute to [endlevel], intended for use with the automated unit tests. This allows for the unit tests to differentiate a pass/fail result separately from scenario victory or defeat, which allows for more accurately determining the outcome of a test as well as addresses the potential, for example, for a scenario to be expect to pass because of the {SUCCEED} macro but instead passes because the scenario ended as a victory through some other method.

Additional unit tests which were the original motivation for this change are also added as part of this.  They test, as much as possible, that events are executed at all, and are then also executed in the expected order.
2020-04-07 16:45:34 -05:00
newfrenchy83
ce4fb82173 Filter weapon in [filter student/opponent/etc] rework (pr #4678)
All weapon specials can now be used in [abilities] to effect all weapons of the unit that pass the filter given in [filter_student][filter_weapon].

Explanation: filter_student filters on the unit that is  under the effect of the ability (which is usually the unit itself, but not always if [affect_adjacent] is used).  [filter_student][filter_weapon] filters on the active weapon of that unit (the student) in a specific combat.

[filter_weapon] is now supported in all filter_opponent, filter_student, filter_attacker, filter_defender

Note that constructs like [filter_student][or][filter_weapon] are not suported, [filter_weapon] must be a direct subtag of the four just mentioned tags.
 
[filter_second_weapon] is no longer used for abilities that come from weapon specials.

implements #4629 , #4475 , #4389

Co-authored-by: gfgtdf <daniel.gfgtdf@gmail.com>
2020-01-05 00:27:55 +01:00
Steve Cotton
7359fddecb
Separate unit test statuses for WML exceptions and strict warnings (#4599)
This is part of working out whether a subset of the "fail" tests could be run
in one Wesnoth instance. To run a test that returns TEST_FAIL_BROKE_STRICT with
any other test would require a mechanism to reset lg::broke_strict()'s flag.

All tests that fail with an {ASSERT} will also set the lg::broke_strict() flag,
the tests with the new status are only those that would pass without the strict
flag.

In the SUF tests, change a test from fail-on-success to breaks-strict, rename
the formula tests and add some comments. The rename is because "fai" is
"Formula AI", an obsolete name for WFL.
2019-12-22 19:11:48 +01:00
Steve Cotton
4588af1b81 Update test_relative_dir (which is not a unit test) for the tag being renamed
This isn't a unit test, it's just meant to be run interactively. And it's been
broken since 3103fe2561, so maybe it should just
be deleted.
2019-12-17 21:22:35 +01:00
Celtic Minstrel
55fa2759a1 Fix the test_move_unit_in_circle test
Just needed to extract the unit earlier, so that it wouldn't be counted as blocking itself

Closes #4635
2019-12-14 12:12:29 -05:00
Steve Cotton
de92d17a6d WIP: Test [move_unit] moving back to the starting hex 2019-12-14 11:31:55 -05:00
Celtic Minstrel
3303be6c91 Restore the dir+count test for move_unit and add the syntax to the schema 2019-12-14 11:28:37 -05:00
Steve Cotton
b479d6f7ac Remove tests of move_unit's count and move-unit-to-its-own-hex functionality
The count is undocumented on the wiki, and it's causing the schema validation
to fail. The functionality makes sense and I hope it continues to be supported,
but for now let's have a minimal unbreak-the-build change.

Trying to move a unit to the hex occupied by itself causes it to move to a vacant
adjacent hex instead; splitting the move into two separate [move_unit] calls
passes as expected. That sounds reasonable implementation-defined behavior, but
will make a PR to discuss it.
2019-12-12 08:47:53 +01: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
Steve Cotton
4e92cc46ad Fix move_unit's parsing of to_x and to_y (fixes the unit-test timeout)
Also extend the unit test to at least check the end result of comma-separated
values, as there was previously nothing testing the effect of providing more
than one value.
2019-12-07 18:41:32 +01:00
Celtic Minstrel
732b7942bb Replace all references to deprecated functions in the helper module
(and remove the require if this meant it was no longer used)
2019-12-02 01:10:34 -05:00
Steve Cotton
e50fd80d53
Convert some fail-on-success unit tests to pass-on-success (#4597) 2019-11-25 14:28:03 +01:00
Celtic Minstrel
3734bce276 Lua: Replace uses of deprecated (moved) sides functions 2019-11-23 14:41:03 -05:00
Steve Cotton
16f93cd24c Add a unit test for wesnoth.create_side 2019-11-18 21:00:26 +01:00
Celtic Minstrel
24b11221cf Use wml.array_variables instead of wml.array_access.get/set 2019-11-16 13:09:04 -05:00
nemaara
50629f28cb Change dunefolk units in faction definitions and pathfinding tests 2019-11-08 16:44:13 -05:00
Severin Glöckner
6da85e9042 switch from map_data to map_file in SP 2019-10-02 02:54:25 +02: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
1c123fb3fa Allow '1-infinity' in ranges, and tighten the schema's validation of ranges
Fixes #4253.

The schema's validation of ranges now rejects negative numbers, because the C++
code doesn't support them (both before and after this commit):
* utils::parse_range("-7") will return {0,0}, because std::stoi("") throws invalid_argument.
* src/map/location.cpp will parse it as -7, but that will never match an on-map coordinate
2019-08-29 22:28:22 +02:00
FranPrin
4819846910 Dunefolk faction rework by various people
Changelog provided by @ghype below. Additional credits at the end.
=================================================================================================

*Art*
Most of units were reworked - some more some less - but our goal was to make them fit for mainline all together.
If any changes are needed to any unit, then we gladly execute those. There have been months worth of progress
documented in the according art thread for this project.

Base Units: https://forums.wesnoth.org/viewtopic.php?f=9&t=49075
Extra Units: https://forums.wesnoth.org/viewtopic.php?f=9&t=49625

*Balance*
The main reason why this project started in the first place. Here as well we have all the progress for balancing
Dunefolk documented and all developers and users interested in this project and seemed to agree on the current
state of balance. Thats the reason why we will not enlist all the changes here. If there are any problems with
the balance, then we too are willing to provide alternatives that can be discussed either here or on forum.

Balance Thread: https://forums.wesnoth.org/viewtopic.php?f=15&t=49627

*Alignment*
The balance of this faction was based on the newly proposed liminal alignment which works as +0/+0/+25/+0/+0/+25
instead of the old -25/-25/+0/-25/-25/+0

*Weapon Portraits*
As Dunefolk features entirely new units, we found some weapon portraits that fits the attacks of certain units.
The portrait - called „blade-curved“ is a franken but a convincing one. As the current blow pipe for UtbS is a
franken as well, this new weapon portrait should good enough to be mainlined as well. If this request get’s denied,
then we are free to provide alternatives as well. It just fits very well the theme of exotic Naga weapon
craftsmanship without relying on the orcish theme. It used for the following two units:

Lv2 Naga Bladewhirler
Lv3 Naga Dervish

*Descriptions*
New unit concepts require changes and new units require entirely new descriptions. We enlisted all problems and
inconsistencies that resulted with the rework and provided either solutions for them or new descriptions. Yumi
already started doing them but for those who want to see the initial conflicts, here you can find all the problems
displayed:

Unit Descriptions: https://forums.wesnoth.org/viewtopic.php?f=32&t=49867#p642698

*Female Dunefolk Names*
With the introduction of female units to this faction, we would require female names as well. Apparently this was
already coded in mainline, but simple not used.

*Future Plans - Animations*
There are some recourses from past works that allow us to - more or less - easily animate most of Dunefolk units.
The animations range from idle to attack-only, while other units will be fully animated. Some of the units that
are harder to animate will first receive single attack/defend frames until animation concepts were agreed upon.
Our goal is to make Dunefolk as alive as possible.

*Future Plans - Theme, Sound FX*
Rather unimportant to most people but I am interested to add some new sound fx that can start with different hit/death
sounds or new weapon sounds for scimitars. Those are just example and I do not know what I will end up with. But I know
that I will compose a Dunefolk Theme at some point. Using your feedback, I am sure I can manage to create something that
fits the faction the best.

*Future Plans - Wyvern Rider*
This is the only unit is the only one that did not get touched or reworked. The wyvern on it self looks amazing an does
not need any rework but the rider does not really fit thematically anymore, not to mention the weapon is too oversized
and not the usual Wesnoth style. But I won’t touch this sprite until it actually will be needed, most likely - IF -
there is ever going to be a mainline Dunefolk campaign.

*Credits*
I don’t know how detailed you need this to be but here all contributors.
ghype, Hejnewar, Krogen, The_Gnat, Lordlewis, EarthCake, Tom_Of_Wesnoth

It is however important to mention that the amount of contributions of each varies a lot in different categories. I will
organise it a bit and you make use of this info how ever you want. The names are in order of the amount of work put in.

Art: ghype, The_Gnat, Lordlewis
Balance: Hejnewar, Krogen, ghype, The_Gnat
Descriptions: Tom_Of_Wesnoth, Hejnewar

Earthcake joined us in the end and helped us finishing this project by cleaning/finishing the codes and doing all the git
stuff together with The_Gnat. Although none of his work can be categorised in one of the three categories, he still deserves
to be credit in one way or another.

Thanks for your time and efforts.
2019-08-11 07:02:58 +11: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
Jyrki Vesterinen
81d0d2214a Lua API: Allow WML tags with leading underscore (#3877)
@gfgtdf said that it's more consistent to allow them across the board,
which IMHO is a strong enough argument for the API change in master.
2019-01-19 15:02:10 +02:00
mattsc
afb394c4b1
Merge pull request #3723 from mattsc/rca_ai_changes
Default AI changes
2018-12-02 08:42:42 -08:00
pentarctagon
7034c8f97b Run WML schema validation in travis. Fixes #3709
This adds running the WML schema validation in travis.  It also updates the schema itself and fixes a few WML errors so that core and all campaigns under all difficulties pass the schema validation.
2018-11-24 10:35:22 -06:00
mattsc
f901a0fd81 Unit tests: change attack_depth to leader_value for aspect tests
attack_depth has been removed
2018-11-16 06:48:01 -08:00
Celtic Minstrel
639787e1c9 Merge pull request #2562 from wesnoth/schema 2018-11-11 13:52:19 -05:00
Toom
53be0fef39 Add WML unit test for unupgradable (#3336)
* Add WML unit test for unupgradable

* Follow [do_command] requirements

(cherry picked from commit 739df85e1d)
2018-10-28 02:53:08 +00:00
josteph
2f266dde90 Add test for #3663 2018-10-27 20:40:03 +00: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
josteph
00c2ed6aa9 Healing: Perform rest healing on turn 2. 2018-10-21 17:35:59 +00:00
josteph
2f62302dc7 Healing: Add a unit test. 2018-10-21 17:34:52 +00:00
Jyrki Vesterinen
21999b1fc9 Extend the first CVE-2018-1999023 unit test to also try loadstring()
Like @gfgtdf pointed out, loadstring() is still supported by Lua in the
name of backwards compatibility, even though it was deprecated in Lua 5.2
and is no longer mentioned in Lua manual. Thus, as of committing this it's
actually possible to load Lua bytecode.

Let's unit test this to ensure that we don't reintroduce this
vulnerability.

(cherry-picked from commit aa73b83600)
2018-10-07 03:23:50 +00:00
Jyrki Vesterinen
81d6970195 check_utf8.sh: don't check the Lua bytecode file
This avoids one of the two files which are currently causing macOS SCons
builds to fail in the master branch.

(cherry-picked from commit 8dc60ae98f)
2018-10-07 03:23:46 +00:00
gfgtdf
a414703946 wml test for cve-2018-1999023
this test whether we succesfully prevent the exceution and parsing of
precompiled lua chunks, which can be used to break the lua sandbox.
This test does not cover all affected functions in particular not the ai
code that loads lua chunks.

(cherry-picked from commit 6b13a63bb0)
2018-10-07 03:23:46 +00:00
gfgtdf
2709456d2f disallow attacking with disabled attacks via [do_command]
this fixes some rare cheats in mp.

(cherry-picked from commit 26b5ca55e4)
2018-10-07 03:23:03 +00:00
Pentarctagon
d6833d76d0 Remove unused test file and images.
(cherry-picked from commit 0a7ed44c08)
2018-10-07 03:22:49 +00:00
mattsc
841e5c6b06 Replace remaining uses of FOREACH macro
(cherry-picked from commit 66b9e11a2d)
2018-10-07 03:21:12 +00:00
mattsc
1c88a6d8c8 Do not load helper.lua where it is not used any more
(cherry-picked from commit 4b6681a300)
2018-10-07 03:21:10 +00:00
mattsc
cb1bc56478 Remove unnecessary inclusions of helper.set_wml_action_metatable {}
(cherry-picked from commit 1684e2f5da)
2018-10-07 03:21:10 +00:00
mattsc
f48f566afd Lua code: replace deprecated helper.[gs]et_variable_array() calls
(cherry-picked from commit 3c792fc7d7)
2018-10-07 03:21:09 +00:00
mattsc
a0decde7b9 Lua code: replace deprecated wesnoth.get_all_vars() calls
(cherry-picked from commit 64f7ad2560)
2018-10-07 03:21:08 +00:00
mattsc
0e017d9f7c Lua code: replace deprecated wesnoth.set_variable() calls
(cherry-picked from commit ce7faae4f4)
2018-10-07 03:21:07 +00:00
mattsc
05d5afa6a9 Lua code: replace deprecated wesnoth.get_variable() calls
(cherry-picked from commit f1764d182f)
2018-10-07 03:21:06 +00:00
Celtic Minstrel
1123c8a707 Remove some uses of set_wml_tag_metatable
(cherry-picked from commit 3939c332b9)
2018-10-07 03:18:29 +00:00
Charles Dang
0cb9f0d622 Data/Test: wmlindent run
[ci skip]

Addresses some of the whitespace issues mentioned in #2613
2018-03-09 11:22:00 +11:00
sigurdfdragon
dfdf8ccacd Update ids to match type changes in 91e0bb4911 2018-02-16 17:51:00 -05:00