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


C++ Town::mobilize_town_people方法代码示例

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


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

示例1: think_succeed_king


//.........这里部分代码省略.........

      if( firmPtr->firm_id == FIRM_CAMP )
      {
         Worker* workerPtr = firmPtr->worker_array;

         for(int j=1 ; j<=firmPtr->worker_count ; j++, workerPtr++ )
         {
            if( !workerPtr->race_id )
               continue;

            curRating = 0;

            if( workerPtr->race_id == race_id )
               curRating += 50;

				if( workerPtr->rank_id == RANK_GENERAL )
               curRating += 50;

            if( workerPtr->skill_id == SKILL_LEADING )
               curRating += workerPtr->skill_level;

            if( curRating > bestRating )
            {
               bestRating   = curRating;
               bestUnitPtr  = NULL;
               bestFirmPtr  = firmPtr;
               bestWorkerId = j;
            }
         }
      }
   }

   //------- if the best successor is a mobile unit -------//

   if( bestUnitPtr )
   {
      //-- if the unit is in a command base or seat of power, mobilize it --//

      if( !bestUnitPtr->is_visible() )
      {
         err_when( bestUnitPtr->unit_mode != UNIT_MODE_OVERSEE );

         firm_array[bestUnitPtr->unit_mode_para]->mobilize_overseer();

         err_when( bestUnitPtr->skill.combat_level<= 0 );
      }

      //---------- succeed the king -------------//

      if( bestUnitPtr->is_visible() )     // it may still be not visible if there is no space for the unit to be mobilized
      {
         if( bestUnitPtr->spy_recno && bestUnitPtr->true_nation_recno() == nation_recno )    // if this is a spy and he's our spy
            spy_array[bestUnitPtr->spy_recno]->drop_spy_identity();                          // revert the spy to a normal unit

         succeed_king( bestUnitPtr->sprite_recno );
         return 1;
      }
   }

   //------- if the best successor is a soldier in a camp -------//

   if( bestFirmPtr )
   {
		int unitRecno = bestFirmPtr->mobilize_worker(bestWorkerId, COMMAND_AI);

      if( unitRecno )
      {
         succeed_king( unitRecno );
         return 1;
      }
   }

   //--- if stil not found here, then try to locate the sucessor from villages ---//

   Town* townPtr;

   for( i=town_array.size() ; i>0 ; i-- )
   {
		if( town_array.is_deleted(i) )
         continue;

      townPtr = town_array[i];

      if( townPtr->nation_recno != nation_recno )
         continue;

      if( townPtr->recruitable_race_pop(race_id, 0) > 0 )   // if this town has people with the same race as the original king
      {
         int unitRecno = townPtr->mobilize_town_people(race_id, 1, 0);     // 1-dec pop, 0-don't mobilize spies

			if( unitRecno )
			{
				succeed_king( unitRecno );
				return 1;
			}
		}
	}

	return 0;
}
开发者ID:artur-kink,项目名称:7kaa,代码行数:101,代码来源:OAI_MAIN.cpp


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