const MUID MMatchRuleAssassinate::ChooseCommander(int nTeam) { MMatchStage* pStage = GetStage(); if (pStage == NULL) return MUID(0,0); int nRedAliveCount, nBlueAliveCount, nChooseTeamCount; if (GetAliveCount(&nRedAliveCount, &nBlueAliveCount) == false) return MUID(0,0); if (nTeam == MMT_RED) { if (nRedAliveCount <= 0) return MUID(0,0); nChooseTeamCount = nRedAliveCount; } if (nTeam == MMT_BLUE) { if (nBlueAliveCount <= 0) return MUID(0,0); nChooseTeamCount = nBlueAliveCount; } if( m_bIsAdminCommander == true ) { for(MUIDRefCache::iterator itor=pStage->GetObjBegin(); itor!=pStage->GetObjEnd(); itor++) { MMatchObject* pObj = (MMatchObject*)(*itor).second; if (pObj->GetEnterBattle() == false) continue; // 배틀참가하고 있는 플레이어만 체크 if (pObj->GetTeam() == nTeam && pObj->GetAccountInfo()->m_nUGrade == MMUG_ADMIN) { return pObj->GetUID(); } } } MTime time; int nChoose = time.MakeNumber(1, nChooseTeamCount); int nCount = 0; for(MUIDRefCache::iterator itor=pStage->GetObjBegin(); itor!=pStage->GetObjEnd(); itor++) { MMatchObject* pObj = (MMatchObject*)(*itor).second; if (pObj->GetEnterBattle() == false) continue; // 배틀참가하고 있는 플레이어만 체크 if (pObj->GetTeam() == nTeam) { nCount++; if (nCount == nChoose) { return pObj->GetUID(); } } } return MUID(0,0); }