Example #1
0
// Finds biggest team that has bots; if two teams are tied for largest, will return index of the first
S32 Game::findLargestTeamWithBots() const
{
   countTeamPlayers();

   S32 largestTeamCount = 0;
   S32 largestTeamIndex = NONE;

   for(S32 i = 0; i < getTeamCount(); i++)
   {
      TNLAssert(dynamic_cast<Team *>(getTeam(i)), "Invalid team");
      Team *team = static_cast<Team *>(getTeam(i));

      // Must have at least one bot to be the largest team with bots!
      if(team->getPlayerBotCount() > largestTeamCount && team->getBotCount() > 0)
      {
         largestTeamCount = team->getPlayerBotCount();
         largestTeamIndex = i;
      }
   }

   return largestTeamIndex;
}