- void CvPlayer::foundReligion(ReligionTypes eReligion, ReligionTypes eSlotReligion, bool bAward)
- {
- CvCity* pLoopCity;
- CvCity* pBestCity;
- UnitTypes eFreeUnit;
- bool bStarting;
- int iValue;
- int iBestValue;
- int iLoop;
- if (NO_RELIGION == eReligion)
- {
- return;
- }
- if (GC.getGameINLINE().isReligionFounded(eReligion))
- {
- if (isHuman())
- {
- CvPopupInfo* pInfo = new CvPopupInfo(BUTTONPOPUP_FOUND_RELIGION, eSlotReligion);
- if (NULL != pInfo)
- {
- gDLL->getInterfaceIFace()->addPopup(pInfo, getID());
- }
- }
- else
- {
- foundReligion(AI_chooseReligion(), eSlotReligion, bAward);
- }
- return;
- }
- GC.getGameINLINE().setReligionSlotTaken(eSlotReligion, true);
- bStarting = ((GC.getReligionInfo(eSlotReligion).getTechPrereq() == NO_TECH) || (GC.getTechInfo((TechTypes) GC.getReligionInfo(eSlotReligion).getTechPrereq()).getEra() < GC.getGameINLINE
- ().getStartEra()));
- iBestValue = 0;
- pBestCity = NULL;
- for (pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop))
- {
- if (!bStarting || !(pLoopCity->isHolyCity()))
- {
- iValue = 10;
- iValue += pLoopCity->getPopulation();
- iValue += GC.getGameINLINE().getSorenRandNum(GC.getDefineINT("FOUND_RELIGION_CITY_RAND"), "Found Religion");
- iValue /= (pLoopCity->getReligionCount() + 1);
- if (pLoopCity->isCapital())
- {
- iValue /= 8;
- }
- iValue = std::max(1, iValue);
- if (iValue > iBestValue)
- {
- iBestValue = iValue;
- pBestCity = pLoopCity;
- }
- }
- }
- if (pBestCity != NULL)
- {
- GC.getGameINLINE().setHolyCity(eReligion, pBestCity, true);
- if (bAward)
- {
- if (GC.getReligionInfo(eSlotReligion).getNumFreeUnits() > 0)
- {
- eFreeUnit = ((UnitTypes)(GC.getCivilizationInfo(getCivilizationType()).getCivilizationUnits(GC.getReligionInfo(eReligion).getFreeUnitClass())));
- if (eFreeUnit != NO_UNIT)
- {
- for (int i = 0; i < GC.getReligionInfo(eSlotReligion).getNumFreeUnits(); ++i)
- {
- initUnit(eFreeUnit, pBestCity->getX_INLINE(), pBestCity->getY_INLINE());
- }
- }
- }
- }
- }
- }
复制代码
T
[ 本帖最后由 Khyron 于 2008-8-6 17:37 编辑 ] |