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


C++ Country::getOwner方法代码示例

本文整理汇总了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);
}
开发者ID:mouadbroos,项目名称:COMP345-Risk,代码行数:48,代码来源:Reinforcement.cpp


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