本文整理汇总了C++中team::side方法的典型用法代码示例。如果您正苦于以下问题:C++ team::side方法的具体用法?C++ team::side怎么用?C++ team::side使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类team
的用法示例。
在下文中一共展示了team::side方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: calculate_team_data
team_data display_context::calculate_team_data(const team& tm) const
{
team_data res;
res.units = side_units(tm.side());
res.upkeep = side_upkeep(tm.side());
res.villages = tm.villages().size();
res.expenses = std::max<int>(0,res.upkeep - tm.support());
res.net_income = tm.total_income() - res.expenses;
res.gold = tm.gold();
res.teamname = tm.user_team_name();
return res;
}
示例2: check_side_number
static bool check_side_number(const team &t, const std::string &str)
{
std::vector<std::string> list = utils::split(str);
std::string side_number = str_cast(t.side());
if (std::find(list.begin(),list.end(),side_number)==list.end())
{
return false;
}
return true;
}
示例3: team_is_defeated
bool game_board::team_is_defeated(const team& t) const
{
switch(t.defeat_condition().v)
{
case team::DEFEAT_CONDITION::ALWAYS:
return true;
case team::DEFEAT_CONDITION::NO_LEADER:
return !units_.find_leader(t.side()).valid();
case team::DEFEAT_CONDITION::NO_UNITS:
for (const unit& u : units_)
{
if(u.side() == t.side())
return false;
}
return true;
case team::DEFEAT_CONDITION::NEVER:
default:
return false;
}
}
示例4: match_internal
bool side_filter::match_internal(const team &t) const
{
if (cfg_.has_attribute("side_in")) {
if (!check_side_number(t,cfg_["side_in"])) {
return false;
}
}
if (cfg_.has_attribute("side")) {
if (!check_side_number(t,cfg_["side"])) {
return false;
}
}
if (!side_string_.empty()) {
if (!check_side_number(t,side_string_)) {
return false;
}
}
config::attribute_value cfg_team_name = cfg_["team_name"];
if (!cfg_team_name.blank()) {
const std::string& that_team_name = cfg_team_name;
const std::string& this_team_name = t.team_name();
if(std::find(this_team_name.begin(), this_team_name.end(), ',') == this_team_name.end()) {
if(this_team_name != that_team_name) return false;
}
else {
const std::vector<std::string>& these_team_names = utils::split(this_team_name);
bool search_futile = true;
BOOST_FOREACH (const std::string& this_single_team_name, these_team_names) {
if(this_single_team_name == that_team_name) {
search_futile = false;
break;
}
}
if(search_futile) return false;
}
}
//Allow filtering on units
if(cfg_.has_child("has_unit")) {
const vconfig& unit_filter = cfg_.child("has_unit");
bool found = false;
for (unit_map::iterator it = resources::units->begin(); it != resources::units->end(); ++ it) {
unit* u = dynamic_cast<unit*>(&*it);
if (u->side() != t.side()) {
continue;
}
if (u->matches_filter(unit_filter, u->get_location(), flat_)) {
found = true;
break;
}
}
if (!found) {
return false;
}
}
const vconfig& enemy_of = cfg_.child("enemy_of");
if(!enemy_of.null()) {
side_filter s_filter(enemy_of);
const std::vector<int>& teams = s_filter.get_teams();
if(teams.empty()) return false;
BOOST_FOREACH (const int side, teams) {
if(!(*resources::teams)[side - 1].is_enemy(t.side()))
return false;
}
}