本文整理汇总了C++中unit::has_ability_by_id方法的典型用法代码示例。如果您正苦于以下问题:C++ unit::has_ability_by_id方法的具体用法?C++ unit::has_ability_by_id怎么用?C++ unit::has_ability_by_id使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类unit
的用法示例。
在下文中一共展示了unit::has_ability_by_id方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: internal_matches_filter
//.........这里部分代码省略.........
}
// The variation_type could be a comma separated list of types
if (!vcfg["variation"].empty())
{
std::vector<std::string> types = utils::split(vcfg["variation"]);
if (std::find(types.begin(), types.end(), u.variation()) == types.end()) {
return false;
}
}
// The has_variation_type could be a comma separated list of types
if (!vcfg["has_variation"].empty())
{
bool match = false;
// If this unit is a variation itself then search in the base unit's variations.
const unit_type* const type = u.variation().empty() ? &u.type() : unit_types.find(u.type().base_id());
assert(type);
for (const std::string& variation_id : utils::split(vcfg["has_variation"])) {
if (type->has_variation(variation_id)) {
match = true;
break;
}
}
if (!match) return false;
}
if (!vcfg["ability"].empty())
{
bool match = false;
for (const std::string& ability_id : utils::split(vcfg["ability"])) {
if (u.has_ability_by_id(ability_id)) {
match = true;
break;
}
}
if (!match) return false;
}
if (!vcfg["race"].empty()) {
std::vector<std::string> races = utils::split(vcfg["race"]);
if (std::find(races.begin(), races.end(), u.race()->id()) == races.end()) {
return false;
}
}
if (!vcfg["gender"].blank() && string_gender(vcfg["gender"]) != u.gender()) {
return false;
}
if (!vcfg["side"].empty() && vcfg["side"].to_int(-999) != u.side()) {
std::vector<std::string> sides = utils::split(vcfg["side"]);
const std::string u_side = std::to_string(u.side());
if (std::find(sides.begin(), sides.end(), u_side) == sides.end()) {
return false;
}
}
// handle statuses list
if (!vcfg["status"].empty()) {
bool status_found = false;
for (const std::string status : utils::split(vcfg["status"])) {
if(u.get_state(status)) {