mirror of
https://github.com/wesnoth/wesnoth
synced 2025-04-25 21:50:25 +00:00
Prevent duplicate advancements from being added to unit type (#7743)
* Add myself to Miscellaneous Contributors * types: Add unit tests over adding advancements
This commit is contained in:
parent
b50a8012ea
commit
71e83f7b85
2
changelog_entries/duplicate_advancements.md
Normal file
2
changelog_entries/duplicate_advancements.md
Normal file
@ -0,0 +1,2 @@
|
||||
### Miscellaneous and Bug Fixes
|
||||
* Prevent duplicate advancements from being added to unit type. (issue #7009)
|
@ -1199,6 +1199,9 @@
|
||||
name = "Chusslove Illich (caslav.ilic)"
|
||||
comment = "wmlxgetext improvements"
|
||||
[/entry]
|
||||
[entry]
|
||||
name = "Cody Burchell (nullmoose)"
|
||||
[/entry]
|
||||
[entry]
|
||||
name = "David Slabý (blaf)"
|
||||
[/entry]
|
||||
|
@ -0,0 +1,73 @@
|
||||
#####
|
||||
# API(s) being tested: [modify_unit_type][add_advancement]
|
||||
##
|
||||
# Actions:
|
||||
# Modify the horseman unit type to add the lancer advancement.
|
||||
# Spawn a horseman unit.
|
||||
##
|
||||
# Expected end state:
|
||||
# The spawned horseman should only have the lancer advancement listed once in advances_to.
|
||||
#####
|
||||
{GENERIC_UNIT_TEST "no_duplicate_advancements" (
|
||||
[modify_unit_type]
|
||||
type="Horseman"
|
||||
add_advancement="Lancer"
|
||||
[/modify_unit_type]
|
||||
[event]
|
||||
name=start
|
||||
[unit]
|
||||
x = 1
|
||||
y = 1
|
||||
type = Horseman
|
||||
side = 1
|
||||
id = charlie
|
||||
canrecruit = no
|
||||
[/unit]
|
||||
[store_unit]
|
||||
variable=horseman
|
||||
[filter]
|
||||
id = charlie
|
||||
[/filter]
|
||||
[/store_unit]
|
||||
{ASSERT ({VARIABLE_CONDITIONAL horseman.advances_to equals "Knight,Lancer"})}
|
||||
|
||||
{SUCCEED}
|
||||
[/event]
|
||||
)}
|
||||
|
||||
#####
|
||||
# API(s) being tested: [modify_unit_type][add_advancement]
|
||||
##
|
||||
# Actions:
|
||||
# Modify the horseman unit type to add the cavalier advancement.
|
||||
# Spawn a horseman unit.
|
||||
##
|
||||
# Expected end state:
|
||||
# The spawned horseman should have the cavalier advancement listed in advances_to.
|
||||
#####
|
||||
{GENERIC_UNIT_TEST "add_advancement" (
|
||||
[modify_unit_type]
|
||||
type="Horseman"
|
||||
add_advancement="Cavalier"
|
||||
[/modify_unit_type]
|
||||
[event]
|
||||
name=start
|
||||
[unit]
|
||||
x = 1
|
||||
y = 1
|
||||
type = Horseman
|
||||
side = 1
|
||||
id = charlie
|
||||
canrecruit = no
|
||||
[/unit]
|
||||
[store_unit]
|
||||
variable=horseman
|
||||
[filter]
|
||||
id = charlie
|
||||
[/filter]
|
||||
[/store_unit]
|
||||
{ASSERT ({VARIABLE_CONDITIONAL horseman.advances_to equals "Knight,Lancer,Cavalier"})}
|
||||
|
||||
{SUCCEED}
|
||||
[/event]
|
||||
)}
|
@ -1367,7 +1367,9 @@ void unit_type::apply_scenario_fix(const config& cfg)
|
||||
}
|
||||
if(auto attr = cfg.get("add_advancement")) {
|
||||
for(const auto& str : utils::split(attr->str())) {
|
||||
advances_to_.push_back(str);
|
||||
if(!utils::contains(advances_to_, str)) {
|
||||
advances_to_.push_back(str);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(auto attr = cfg.get("remove_advancement")) {
|
||||
|
@ -214,6 +214,8 @@
|
||||
0 has_achievement
|
||||
0 test_movement_used
|
||||
0 test_attacks_used
|
||||
0 no_duplicate_advancements
|
||||
0 add_advancement
|
||||
# Terrain mask tests
|
||||
0 test_terrain_mask_simple_nop
|
||||
0 test_terrain_mask_simple_set
|
||||
|
Loading…
x
Reference in New Issue
Block a user