当前位置: 首页>>代码示例>>C++>>正文


C++ team::is_enemy方法代码示例

本文整理汇总了C++中team::is_enemy方法的典型用法代码示例。如果您正苦于以下问题:C++ team::is_enemy方法的具体用法?C++ team::is_enemy怎么用?C++ team::is_enemy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在team的用法示例。


在下文中一共展示了team::is_enemy方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

pathfind::teleport_map::teleport_map(
		  const std::vector<teleport_group>& groups
		, const unit& u
		, const team &viewing_team
		, const bool see_all
		, const bool ignore_units)
	: teleport_map_()
	, sources_()
	, targets_()
{

	foreach(const teleport_group& group, groups) {

		teleport_pair locations;
		group.get_teleport_pair(locations, u, ignore_units);
		if (!see_all && !group.always_visible() && viewing_team.is_enemy(u.side())) {
			teleport_pair filter_locs;
			foreach(const map_location &loc, locations.first)
				if(!viewing_team.fogged(loc))
					filter_locs.first.insert(loc);
			foreach(const map_location &loc, locations.second)
				if(!viewing_team.fogged(loc))
					filter_locs.second.insert(loc);
			locations.first.swap(filter_locs.first);
			locations.second.swap(filter_locs.second);
		}
开发者ID:blackberry,项目名称:Wesnoth,代码行数:26,代码来源:teleport.cpp

示例2: on_create

void strategy_formulation_with_rca::on_create()
{
	const std::vector<team> teams = *resources::teams;
	const int own_side = this->get_side();
	const team own_team = teams[own_side-1];

	rca_->on_create();

	for(size_t i = 0; i != teams.size(); ++i){
		if(own_side+i <= teams.size()){
			enemy_this_turn_.push_back(own_team.is_enemy(own_side+i));
		} else {
			enemy_this_turn_.push_back(own_team.is_enemy((own_side+i)%teams.size()));
		}
	}

	enemy_this_turn_.push_back(false);
}
开发者ID:Kanac,项目名称:wesnoth,代码行数:18,代码来源:stage_sf_with_rca.cpp

示例3: create_jamming_map

/**
 * Sets @a jamming to the (newly calculated) "jamming" map for @a view_team.
 */
static void create_jamming_map(std::map<map_location, int> & jamming,
                               const team & view_team)
{
	// Reset the map.
	jamming.clear();

	// Build the map.
	for (const unit &u : resources::gameboard->units())
	{
		if ( u.jamming() < 1  ||  !view_team.is_enemy(u.side()) )
			continue;

		pathfind::jamming_path jam_path(u, u.get_location());
		for (const pathfind::paths::step& st : jam_path.destinations) {
			if ( jamming[st.curr] < st.move_left )
				jamming[st.curr] = st.move_left;
		}
	}
}
开发者ID:GregoryLundberg,项目名称:wesnoth,代码行数:22,代码来源:vision.cpp

示例4:

std::set<map_location> get_teleport_locations(const unit &u,
	const unit_map &units, const team &viewing_team,
	bool see_all, bool ignore_units)
{
	std::set<map_location> res;
	if (!u.get_ability_bool("teleport")) return res;

	const team &current_team = (*resources::teams)[u.side() - 1];
	const map_location &loc = u.get_location();
	foreach (const map_location &l, current_team.villages())
	{
		// This must be a vacant village (or occupied by the unit)
		// to be able to teleport.
		if (!see_all && viewing_team.is_enemy(u.side()) && viewing_team.fogged(l))
			continue;
		if (!ignore_units && l != loc &&
		    get_visible_unit(units, l, viewing_team, see_all))
			continue;
		res.insert(l);
	}
	return res;
}
开发者ID:oys0317,项目名称:opensanguo,代码行数:22,代码来源:pathfind.cpp

示例5: mark_route

marked_route mark_route(const plain_route &rt,
	const std::vector<map_location>& waypoints, const unit &u,
	const team &viewing_team, const unit_map &units,
	const std::vector<team> &teams, const gamemap &map)
{
	marked_route res;

	if (rt.steps.empty()) return res;
	res.steps = rt.steps;

	int turns = 0;
	int movement = u.movement_left();
	const team& unit_team = teams[u.side()-1];
	bool zoc = false;

	std::vector<map_location>::const_iterator i = rt.steps.begin(),
			w = waypoints.begin();

	// TODO fix the name confusion with waypoints and route.waypoints
	for (; i !=rt.steps.end(); i++) {
		bool last_step = (i+1 == rt.steps.end());

		// move_cost of the next step is irrelevant for the last step
		assert(last_step || map.on_board(*(i+1)));
		const int move_cost = last_step ? 0 : u.movement_cost(map[*(i+1)]);
		bool capture = false;
		bool pass_here = false;
		if (w != waypoints.end() && *i == *w) {
			w++;
			pass_here = true;
		}

		if (last_step || zoc || move_cost > movement) {
			// check if we stop an a village and so maybe capture it
			// if it's an enemy unit and a fogged village, we assume a capture
			// (if he already owns it, we can't know that)
			// if it's not an enemy, we can always know if he owns the village
			bool capture = map.is_village(*i) && ( !unit_team.owns_village(*i)
				 || (viewing_team.is_enemy(u.side()) && viewing_team.fogged(*i)) );

			++turns;

			bool invisible = u.invisible(*i,units,teams,false);

			res.waypoints[*i] = marked_route::waypoint(turns, pass_here, zoc, capture, invisible);

			if (last_step) break; // finished and we used dummy move_cost

			movement = u.total_movement();
			if(move_cost > movement) {
				return res; //we can't reach destination
			}
		} else if (pass_here) {
			bool invisible = u.invisible(*i,units,teams,false);
			res.waypoints[*i] = marked_route::waypoint(0, pass_here, zoc, false, invisible);
		}

		zoc = enemy_zoc(units, teams, *(i + 1), viewing_team,u.side())
					&& !u.get_ability_bool("skirmisher", *(i+1));

		if (zoc || capture) {
			movement = 0;
		} else {
			movement -= move_cost;
		}
	}

	return res;
}
开发者ID:oys0317,项目名称:opensanguo,代码行数:69,代码来源:pathfind.cpp

示例6: generate_report


//.........这里部分代码省略.........
		break;
	}
	case TACTIC: {
		int tactic_point = viewing_team.tactic_point();
		if (current_side != playing_side) {
			str << font::GRAY_TEXT;
		} else if (tactic_point >= game_config::max_tactic_point) {
			str << font::RED_TEXT;
		} else if (tactic_point > game_config::max_tactic_point * 2 / 3) {
			str << "<255,255,0>";
		} else {
			str << font::GOOD_TEXT;
		}

		str << viewing_team.tactic_point();
		break;
	}
	case TERRAIN: {
		if(!map.on_board(mouseover) || viewing_team.shrouded(mouseover))
			break;

		const t_translation::t_terrain terrain = map.get_terrain(mouseover);
		if (terrain == t_translation::OFF_MAP_USER)
			break;

		const t_translation::t_list& underlying = map.underlying_union_terrain(terrain);

		if(map.is_village(mouseover)) {
			int owner = village_owner(mouseover, teams) + 1;
			if(owner == 0 || viewing_team.fogged(mouseover)) {
				str << map.get_terrain_info(terrain).income_description();
			} else if(owner == current_side) {
				str << map.get_terrain_info(terrain).income_description_own();
			} else if(viewing_team.is_enemy(owner)) {
				str << map.get_terrain_info(terrain).income_description_enemy();
			} else {
				str << map.get_terrain_info(terrain).income_description_ally();
			}
			str << " ";
		} else {
		        str << map.get_terrain_info(terrain).description();
		}

		if(underlying.size() != 1 || underlying.front() != terrain) {
			str << " (";

			for(t_translation::t_list::const_iterator i =
					underlying.begin(); i != underlying.end(); ++i) {

			str << map.get_terrain_info(*i).name();
				if(i+1 != underlying.end()) {
					str << ",";
				}
			}
			str << ")";
		}
		break;
	}
	case POSITION: {
		// coordinate  [terrain] resitance
		if (!map.on_board(mouseover)) {
			break;
		}

		const t_translation::t_terrain terrain = map[mouseover];
开发者ID:,项目名称:,代码行数:66,代码来源:

示例7: clear_loc

/**
 * Clears shroud from a single location.
 * This also records sighted events for later firing.
 *
 * In a few cases, this will also clear corner hexes that otherwise would
 * not normally get cleared.
 * @param tm               The team whose fog/shroud is affected.
 * @param loc              The location to clear.
 * @param view_loc         The location viewer is assumed at (for sighted events).
 * @param event_non_loc    The unit at this location cannot be sighted
 *                         (used to prevent a unit from sighting itself).
 * @param viewer_id        The underlying ID of the unit doing the sighting (for events).
 * @param check_units      If false, there is no checking for an uncovered unit.
 * @param enemy_count      Incremented if an enemy is uncovered.
 * @param friend_count     Incremented if a friend is uncovered.
 * @param spectator        Will be told if a unit is uncovered.
 *
 * @return whether or not information was uncovered (i.e. returns true if
 *         the specified location was fogged/ shrouded under shared vision/maps).
 */
bool shroud_clearer::clear_loc(team &tm, const map_location &loc,
                               const map_location &view_loc,
                               const map_location &event_non_loc,
                               std::size_t viewer_id, bool check_units,
                               std::size_t &enemy_count, std::size_t &friend_count,
                               move_unit_spectator * spectator)
{
	const gamemap &map = resources::gameboard->map();
	// This counts as clearing a tile for the return value if it is on the
	// board and currently fogged under shared vision. (No need to explicitly
	// check for shrouded since shrouded implies fogged.)
	bool was_fogged = tm.fogged(loc);
	bool result = was_fogged && map.on_board(loc);

	// Clear the border as well as the board, so that the half-hexes
	// at the edge can also be cleared of fog/shroud.
	if ( map.on_board_with_border(loc) ) {
		// Both functions should be executed so don't use || which
		// uses short-cut evaluation.
		// (This is different than the return value because shared vision does
		// not apply here.)
		if ( tm.clear_shroud(loc) | tm.clear_fog(loc) ) {
			// If we are near a corner, the corner might also need to be cleared.
			// This happens at the lower-left corner and at either the upper- or
			// lower- right corner (depending on the width).

			// Lower-left corner:
			if ( loc.x == 0  &&  loc.y == map.h()-1 ) {
				const map_location corner(-1, map.h());
				tm.clear_shroud(corner);
				tm.clear_fog(corner);
			}
			// Lower-right corner, odd width:
			else if ( is_odd(map.w())  &&  loc.x == map.w()-1  &&  loc.y == map.h()-1 ) {
				const map_location corner(map.w(), map.h());
				tm.clear_shroud(corner);
				tm.clear_fog(corner);
			}
			// Upper-right corner, even width:
			else if ( is_even(map.w())  &&  loc.x == map.w()-1  &&  loc.y == 0) {
				const map_location corner(map.w(), -1);
				tm.clear_shroud(corner);
				tm.clear_fog(corner);
			}
		}
	}

	// Possible screen invalidation.
	if ( was_fogged ) {
		display::get_singleton()->invalidate(loc);
		// Need to also invalidate adjacent hexes to get rid of the
		// "fog edge" graphics.
		adjacent_loc_array_t adjacent;
		get_adjacent_tiles(loc, adjacent.data());
		for (unsigned i = 0; i < adjacent.size(); ++i )
			display::get_singleton()->invalidate(adjacent[i]);
	}

	// Check for units?
	if ( result  &&  check_units  &&  loc != event_non_loc ) {
		// Uncovered a unit?
		unit_map::const_iterator sight_it = resources::gameboard->find_visible_unit(loc, tm);
		if ( sight_it.valid() ) {
			record_sighting(*sight_it, loc, viewer_id, view_loc);

			// Track this?
			if ( !sight_it->get_state(unit::STATE_PETRIFIED) ) {
				if ( tm.is_enemy(sight_it->side()) ) {
					++enemy_count;
					if ( spectator )
						spectator->add_seen_enemy(sight_it);
				} else {
					++friend_count;
					if ( spectator )
						spectator->add_seen_friend(sight_it);
				}
			}
		}
	}

//.........这里部分代码省略.........
开发者ID:GregoryLundberg,项目名称:wesnoth,代码行数:101,代码来源:vision.cpp

示例8: do_attack_analysis

void aspect_attacks::do_attack_analysis(
    const map_location& loc,
    const move_map& srcdst, const move_map& dstsrc,
    const move_map& fullmove_srcdst, const move_map& fullmove_dstsrc,
    const move_map& enemy_srcdst, const move_map& enemy_dstsrc,
    const map_location* tiles, bool* used_locations,
    std::vector<map_location>& units,
    std::vector<attack_analysis>& result,
    attack_analysis& cur_analysis,
    const team &current_team
) const
{
    // This function is called fairly frequently, so interact with the user here.

    ai::manager::raise_user_interact();
    const int default_attack_depth = 5;
    if(cur_analysis.movements.size() >= size_t(default_attack_depth)) {
        //std::cerr << "ANALYSIS " << cur_analysis.movements.size() << " >= " << get_attack_depth() << "\n";
        return;
    }
    gamemap &map_ = *resources::game_map;
    unit_map &units_ = *resources::units;
    std::vector<team> &teams_ = *resources::teams;


    const size_t max_positions = 1000;
    if(result.size() > max_positions && !cur_analysis.movements.empty()) {
        LOG_AI << "cut analysis short with number of positions\n";
        return;
    }

    for(size_t i = 0; i != units.size(); ++i) {
        const map_location current_unit = units[i];

        unit_map::iterator unit_itor = units_.find(current_unit);
        assert(unit_itor != units_.end());

        // See if the unit has the backstab ability.
        // Units with backstab will want to try to have a
        // friendly unit opposite the position they move to.
        //
        // See if the unit has the slow ability -- units with slow only attack first.
        bool backstab = false, slow = false;
        std::vector<attack_type>& attacks = unit_itor->attacks();
        for(std::vector<attack_type>::iterator a = attacks.begin(); a != attacks.end(); ++a) {
            a->set_specials_context(map_location(), map_location(), units_, true, NULL);
            if(a->get_special_bool("backstab")) {
                backstab = true;
            }

            if(a->get_special_bool("slow")) {
                slow = true;
            }
        }

        if(slow && cur_analysis.movements.empty() == false) {
            continue;
        }

        // Check if the friendly unit is surrounded,
        // A unit is surrounded if it is flanked by enemy units
        // and at least one other enemy unit is nearby
        // or if the unit is totaly surrounded by enemies
        // with max. one tile to escape.
        bool is_surrounded = false;
        bool is_flanked = false;
        int enemy_units_around = 0;
        int accessible_tiles = 0;
        map_location adj[6];
        get_adjacent_tiles(current_unit, adj);

        size_t tile;
        for(tile = 0; tile != 3; ++tile) {

            const unit_map::const_iterator tmp_unit = units_.find(adj[tile]);
            bool possible_flanked = false;

            if(map_.on_board(adj[tile]))
            {
                accessible_tiles++;
                if (tmp_unit != units_.end() && current_team.is_enemy(tmp_unit->side()))
                {
                    enemy_units_around++;
                    possible_flanked = true;
                }
            }

            const unit_map::const_iterator tmp_opposite_unit = units_.find(adj[tile + 3]);
            if(map_.on_board(adj[tile + 3]))
            {
                accessible_tiles++;
                if (tmp_opposite_unit != units_.end() && current_team.is_enemy(tmp_opposite_unit->side()))
                {
                    enemy_units_around++;
                    if(possible_flanked)
                    {
                        is_flanked = true;
                    }
                }
            }
//.........这里部分代码省略.........
开发者ID:ehsan,项目名称:wesnoth,代码行数:101,代码来源:aspect_attacks.cpp

示例9: generate_report


//.........这里部分代码省略.........
				effdmg = at.damage();
			}
			tooltip << effdmg   << ' ' << _n("tooltip^damage", "damage",  effdmg) << ", ";
			tooltip << nattacks << ' ' << _n("tooltip^attack", "attacks", nattacks);

			int accuracy = at.accuracy();
			if(accuracy) {
				// Help xgettext with a directive to recognise the string as a non C printf-like string
				// xgettext:no-c-format
				tooltip << " " << (accuracy > 0 ? "+" : "") << accuracy << _("tooltip^% accuracy");
			}

			int parry = at.parry();
			if(parry) {
				// xgettext:no-c-format
				tooltip << " " << (parry > 0 ? "+" : "") << parry << _("tooltip^% parry");
			}

			str << "</span>\n";
			res.add_text(flush(str), flush(tooltip));

			std::string range = gettext(at.range().c_str());
			str << span_color(font::weapon_details_color) << "  "
				<< range << "--" << lang_type << "</span>\n";

			tooltip << _("weapon range: ") << range <<"\n";
			tooltip << _("damage type: ")  << lang_type << "\n";
			// Find all the unit types on the map, and
			// show this weapon's bonus against all the different units.
			// Don't show invisible units, except if they are in our team or allied.
			std::set<std::string> seen_units;
			std::map<int,std::vector<std::string> > resistances;
			for(unit_map::const_iterator u_it = units.begin(); u_it != units.end(); ++u_it) {
				if(teams[team_index].is_enemy(u_it->second.side()) &&
				   !current_team.fogged(u_it->first) &&
				   seen_units.count(u_it->second.type_id()) == 0 &&
				   ( !current_team.is_enemy(u_it->second.side()) ||
				     !u_it->second.invisible(u_it->first,units,teams)))
				{
					seen_units.insert(u_it->second.type_id());
					int resistance = u_it->second.resistance_against(at, false, u_it->first) - 100;
					resistances[resistance].push_back(u_it->second.type_name());
				}
			}

			for(std::map<int,std::vector<std::string> >::reverse_iterator resist = resistances.rbegin(); resist != resistances.rend(); ++resist) {
				std::sort(resist->second.begin(),resist->second.end());
				tooltip << (resist->first >= 0 ? "+" : "") << resist->first << "% " << _("vs") << " ";
				for(std::vector<std::string>::const_iterator i = resist->second.begin(); i != resist->second.end(); ++i) {
					if(i != resist->second.begin()) {
						tooltip << ", ";
					}

					tooltip << *i;
				}
				tooltip << "\n";
			}

			res.add_text(flush(str), flush(tooltip));


			const std::vector<t_string> &specials = at.special_tooltips();

			if(! specials.empty()) {
				for(std::vector<t_string>::const_iterator sp_it = specials.begin(); sp_it != specials.end(); ++sp_it) {
					str << span_color(font::weapon_details_color)
开发者ID:oys0317,项目名称:opensanguo,代码行数:67,代码来源:generate_report.cpp


注:本文中的team::is_enemy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。