mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-06 15:46:57 +00:00
Merge branch 'has_ally_master'
Conflicts: wml_test_schedule
This commit is contained in:
commit
6cb9c518c7
116
data/test/scenarios/has_ally.cfg
Normal file
116
data/test/scenarios/has_ally.cfg
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
# This test checks that the [has_ally] tag is working as expected.
|
||||||
|
|
||||||
|
#define TEST_HAS_ALLY_SCEN ID EVENTS
|
||||||
|
[test]
|
||||||
|
name = "Unit Test {ID}"
|
||||||
|
map_data = "{test/maps/move_skip_sighted.map}"
|
||||||
|
turns = 3
|
||||||
|
id = {ID}
|
||||||
|
random_start_time = no
|
||||||
|
|
||||||
|
{DAWN}
|
||||||
|
|
||||||
|
[side]
|
||||||
|
side=1
|
||||||
|
controller=human
|
||||||
|
name = "Alice"
|
||||||
|
type = Elvish Archer
|
||||||
|
id=alice
|
||||||
|
fog=no
|
||||||
|
team_name=West
|
||||||
|
[/side]
|
||||||
|
[side]
|
||||||
|
side=2
|
||||||
|
controller=human
|
||||||
|
name = "Bob"
|
||||||
|
type = Orcish Grunt
|
||||||
|
id=bob
|
||||||
|
fog=no
|
||||||
|
team_name=East
|
||||||
|
[/side]
|
||||||
|
[side]
|
||||||
|
side=3
|
||||||
|
controller=human
|
||||||
|
name = "Dave"
|
||||||
|
type = Dwarvish Fighter
|
||||||
|
id=dave
|
||||||
|
fog=no
|
||||||
|
team_name=East
|
||||||
|
[/side]
|
||||||
|
[side]
|
||||||
|
side=4
|
||||||
|
controller=human
|
||||||
|
name= "Charlie"
|
||||||
|
type = Chocobone
|
||||||
|
id=charlie
|
||||||
|
fog=no
|
||||||
|
team_name=West
|
||||||
|
[/side]
|
||||||
|
|
||||||
|
{EVENTS}
|
||||||
|
[/test]
|
||||||
|
#enddef
|
||||||
|
|
||||||
|
{TEST_HAS_ALLY_SCEN "has_ally" (
|
||||||
|
[event]
|
||||||
|
name=start
|
||||||
|
{ASSERT ([have_unit]
|
||||||
|
id=dave
|
||||||
|
[filter_side]
|
||||||
|
[has_ally]
|
||||||
|
[has_unit]
|
||||||
|
id=bob
|
||||||
|
[/has_unit]
|
||||||
|
[/has_ally]
|
||||||
|
[/filter_side]
|
||||||
|
[/have_unit]
|
||||||
|
)}
|
||||||
|
{ASSERT ([have_unit]
|
||||||
|
id=dave
|
||||||
|
[filter_side]
|
||||||
|
[has_enemy]
|
||||||
|
[has_unit]
|
||||||
|
id=alice
|
||||||
|
[/has_unit]
|
||||||
|
[/has_enemy]
|
||||||
|
[/filter_side]
|
||||||
|
[/have_unit]
|
||||||
|
)}
|
||||||
|
{ASSERT ([have_unit]
|
||||||
|
id=dave
|
||||||
|
[filter_side]
|
||||||
|
[not]
|
||||||
|
[has_ally]
|
||||||
|
[has_unit]
|
||||||
|
id=steve
|
||||||
|
[/has_unit]
|
||||||
|
[/has_ally]
|
||||||
|
[/not]
|
||||||
|
[/filter_side]
|
||||||
|
[/have_unit]
|
||||||
|
)}
|
||||||
|
{ASSERT ([have_unit]
|
||||||
|
id=dave
|
||||||
|
[filter_side]
|
||||||
|
[has_enemy]
|
||||||
|
side=1,4
|
||||||
|
[/has_enemy]
|
||||||
|
[/filter_side]
|
||||||
|
[/have_unit]
|
||||||
|
)}
|
||||||
|
{ASSERT ([not]
|
||||||
|
[have_unit]
|
||||||
|
id=dave
|
||||||
|
[filter_side]
|
||||||
|
[has_ally]
|
||||||
|
[has_unit]
|
||||||
|
id=charlie
|
||||||
|
[/has_unit]
|
||||||
|
[/has_ally]
|
||||||
|
[/filter_side]
|
||||||
|
[/have_unit]
|
||||||
|
[/not]
|
||||||
|
)}
|
||||||
|
{RETURN ([true][/true])}
|
||||||
|
[/event]
|
||||||
|
)}
|
@ -188,6 +188,39 @@ bool side_filter::match_internal(const team &t) const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const vconfig& has_enemy = cfg_.child("has_enemy");
|
||||||
|
if(!has_enemy.null()) {
|
||||||
|
if (!has_enemy_filter_)
|
||||||
|
has_enemy_filter_.reset(new side_filter(has_enemy, fc_));
|
||||||
|
const std::vector<int>& teams = has_enemy_filter_->get_teams();
|
||||||
|
bool found = false;
|
||||||
|
BOOST_FOREACH(const int side, teams) {
|
||||||
|
if((fc_->get_disp_context().teams())[side - 1].is_enemy(t.side()))
|
||||||
|
{
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const vconfig& has_ally = cfg_.child("has_ally");
|
||||||
|
if(!has_ally.null()) {
|
||||||
|
if (!has_ally_filter_)
|
||||||
|
has_ally_filter_.reset(new side_filter(has_ally, fc_));
|
||||||
|
const std::vector<int>& teams = has_ally_filter_->get_teams();
|
||||||
|
bool found = false;
|
||||||
|
BOOST_FOREACH(const int side, teams) {
|
||||||
|
if(!(fc_->get_disp_context().teams())[side - 1].is_enemy(t.side()))
|
||||||
|
{
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const config::attribute_value cfg_controller = cfg_["controller"];
|
const config::attribute_value cfg_controller = cfg_["controller"];
|
||||||
if (!cfg_controller.blank())
|
if (!cfg_controller.blank())
|
||||||
{
|
{
|
||||||
|
@ -65,6 +65,8 @@ private:
|
|||||||
mutable boost::scoped_ptr<unit_filter> ufilter_;
|
mutable boost::scoped_ptr<unit_filter> ufilter_;
|
||||||
mutable boost::scoped_ptr<side_filter> allied_filter_;
|
mutable boost::scoped_ptr<side_filter> allied_filter_;
|
||||||
mutable boost::scoped_ptr<side_filter> enemy_filter_;
|
mutable boost::scoped_ptr<side_filter> enemy_filter_;
|
||||||
|
mutable boost::scoped_ptr<side_filter> has_ally_filter_;
|
||||||
|
mutable boost::scoped_ptr<side_filter> has_enemy_filter_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -80,6 +80,7 @@
|
|||||||
0 event_handlers_in_events_7
|
0 event_handlers_in_events_7
|
||||||
0 event_handlers_in_events_8
|
0 event_handlers_in_events_8
|
||||||
0 filter_vision
|
0 filter_vision
|
||||||
|
0 has_ally
|
||||||
#
|
#
|
||||||
# Pathfinding
|
# Pathfinding
|
||||||
#
|
#
|
||||||
|
Loading…
x
Reference in New Issue
Block a user