/** * Given the location of a village, will return the 0-based index * of the team that currently owns it, and -1 if it is unowned. */ int display_context::village_owner(const map_location& loc) const { const std::vector<team> & t = teams(); for(size_t i = 0; i != t.size(); ++i) { if(t[i].owns_village(loc)) return i; } return -1; }
/** * Determine if we are an observer, by checking if every team is not locally controlled */ bool display_context::is_observer() const { for (const team &t : teams()) { if (t.is_local()) return false; } return true; }
void NewTableDialog::okClicked() { if (teams().size() == 0 || stages().size() == 0) { QMessageBox::critical(this, "Ошибка", "Вы должны добавить хотя " "бы одну команду и один конкурс!"); } else { accept(); } }
TEST(MessageConnection, Send) { const int size = 8; vector<string> teams(size); string teamsA[size] = { "ohio","michigan","alaska","test-sample", "fail","random","maine","huskies" }; for (int x = 0; x < size; x++) teams[x] = teamsA[x]; MessageInterface mi(NULL); string message = mi.format(teams); string expected_string = "ohio:michigan:alaska:test-sample" ":fail:random:maine:huskies"; EXPECT_EQ(expected_string,message); }
const team& display_context::get_team(int side) const { return teams().at(side - 1); }
bool has_team(int side) const { return side > 0 && side <= static_cast<int>(teams().size()); }
vector<Population> make_teams(size_t numTeams, size_t teamSize, PopulationLayout& pl) { vector<Population> teams(numTeams); size_t teamID = 0; std::generate(teams.begin(), teams.end(), [&]() { return make_population(teamID++, pl); }); return teams; }
void game_board::check_victory(bool & continue_level, bool & found_player, bool & found_network_player, bool & cleared_villages, std::set<unsigned> & not_defeated, bool remove_from_carryover_on_defeat) { continue_level = true; found_player = false; found_network_player = false; cleared_villages = false; not_defeated = std::set<unsigned>(); for (const unit & i : units()) { DBG_EE << "Found a unit: " << i.id() << " on side " << i.side() << std::endl; const team& tm = teams()[i.side()-1]; DBG_EE << "That team's defeat condition is: " << tm.defeat_condition() << std::endl; if (i.can_recruit() && tm.defeat_condition() == team::DEFEAT_CONDITION::NO_LEADER) { not_defeated.insert(i.side()); } else if (tm.defeat_condition() == team::DEFEAT_CONDITION::NO_UNITS) { not_defeated.insert(i.side()); } } for (team& tm : teams_) { if(tm.defeat_condition() == team::DEFEAT_CONDITION::NEVER) { not_defeated.insert(tm.side()); } // Clear villages for teams that have no leader and // mark side as lost if it should be removed from carryover. if (not_defeated.find(tm.side()) == not_defeated.end()) { tm.clear_villages(); // invalidate_all() is overkill and expensive but this code is // run rarely so do it the expensive way. cleared_villages = true; if (remove_from_carryover_on_defeat) { tm.set_lost(true); } } else if(remove_from_carryover_on_defeat) { tm.set_lost(false); } } for (std::set<unsigned>::iterator n = not_defeated.begin(); n != not_defeated.end(); ++n) { size_t side = *n - 1; DBG_EE << "Side " << (side+1) << " is a not-defeated team" << std::endl; std::set<unsigned>::iterator m(n); for (++m; m != not_defeated.end(); ++m) { if (teams()[side].is_enemy(*m)) { return; } DBG_EE << "Side " << (side+1) << " and " << *m << " are not enemies." << std::endl; } if (teams()[side].is_local_human()) { found_player = true; } if (teams()[side].is_network_human()) { found_network_player = true; } } continue_level = false; }