本文整理汇总了C++中Country::getOwner方法的典型用法代码示例。如果您正苦于以下问题:C++ Country::getOwner方法的具体用法?C++ Country::getOwner怎么用?C++ Country::getOwner使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Country
的用法示例。
在下文中一共展示了Country::getOwner方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: calculateReinforcement
/*
* calculates the total reinforcements the player receives and stores that number
*/
void Reinforcement::calculateReinforcement(){
cout<< "Calculating Reinforcements for player \"" << currentplayer->getPlayerName() << "\"..." << endl;
int countryreinforcements=0, continentreinforcements=0;
for (int indexofcountries=0;indexofcountries<listofcountries.size();indexofcountries++)//checks ever
{
Country countryC = listofcountries[indexofcountries];
if (countryC.getOwner()->getPlayerName()==currentplayer->getPlayerName())
{
countryreinforcements++;
}
}
for (int indexofcontinents=0;indexofcontinents<listofcontinents.size();indexofcontinents++)//for all continent
{
int check=0;
for (int indexofcountriesincontinent=0;indexofcountriesincontinent<listofcontinents[indexofcontinents].getNumCountries();indexofcountriesincontinent++)//looks at each continent's countries
{
Continent continentC = listofcontinents[indexofcontinents];
Country countriesInContient = continentC.getCountries()[indexofcountriesincontinent];
string countryincontinent = countriesInContient.getName();
for (int indexofcountries=0;indexofcountries<listofcountries.size();indexofcountries++)
{
Country countryC = listofcountries[indexofcountries];
if (countryC.getName()==countryincontinent && countryC.getOwner()->getPlayerName()==currentplayer->getPlayerName())//checks to see if the player owns the country
{
check++;
}
}
}
if (check==listofcontinents[indexofcontinents].getNumCountries())//if the player owns all the countries of the continent, he receives the army bonus
{
continentreinforcements+=listofcontinents[indexofcontinents].getArmyBonus();
}
}
int actualcountryrein=max(3,countryreinforcements/3);//player receives reinforcements equal to his countries count/3 rounded down OR 3, whichever is higher
cout << currentplayer->getPlayerName() << " has received " << actualcountryrein << " reinforcements from their countries." <<endl;
cout << currentplayer->getPlayerName() << " has received " << continentreinforcements << " reinforcements from their continents." <<endl;
int totalreinforcements= (actualcountryrein +continentreinforcements);
this->reinforcements=totalreinforcements;
currentplayer->setCurrentReinforcements(totalreinforcements);
}