def onReligionSpread(self, argsList):
        iReligion, iOwner, pSpreadCity = argsList

        cnm.onReligionSpread(iReligion, iOwner, pSpreadCity)

        # Israeli UP
        if iReligion == iJudaism:
            self.up.computeAliyahBonus()
    def onRevolution(self, argsList):
        'Called at the start of a revolution'
        iPlayer = argsList[0]

        sta.onRevolution(iPlayer)

        if iPlayer < iNumPlayers:
            dc.onRevolution(iPlayer)
            cnm.onRevolution(iPlayer)

        utils.checkSlaves(iPlayer)
示例#3
0
        def onReligionSpread(self, argsList):
            
                iReligion, iOwner, pSpreadCity = argsList
		
		cnm.onReligionSpread(iReligion, iOwner, pSpreadCity)

		#Leoreth: if state religion spreads, pagan temples are replaced with its temple. For other religions, they're simply removed.         
		if pSpreadCity.isHasBuilding(con.iObelisk):
			pSpreadCity.setHasRealBuilding(con.iObelisk, False)
			if gc.getPlayer(iOwner).getCivics(4) != con.iCivicPantheon and gc.getPlayer(iOwner).getStateReligion() == iReligion and gc.getTeam(iOwner).isHasTech(con.iPriesthood):
				pSpreadCity.setHasRealBuilding(con.iJewishTemple+4*iReligion, True)
                                CyInterface().addMessage(iOwner, True, con.iDuration, CyTranslator().getText("TXT_KEY_PAGAN_TEMPLE_REPLACED", (str(gc.getReligionInfo(iReligion).getText()), str(pSpreadCity.getName()), str(gc.getBuildingInfo(con.iJewishTemple+4*iReligion).getText()))), "", 0, "", ColorTypes(con.iWhite), -1, -1, True, True)
			else:
				CyInterface().addMessage(iOwner, True, con.iDuration, CyTranslator().getText("TXT_KEY_PAGAN_TEMPLE_REMOVED", (str(gc.getReligionInfo(iReligion).getText()), str(pSpreadCity.getName()))), "", 0, "", ColorTypes(con.iWhite), -1, -1, True, True)
示例#4
0
	def onRevolution(self, argsList):
		'Called at the start of a revolution'
		iPlayer = argsList[0]
		
		sta.onRevolution(iPlayer)
		
		if iPlayer < iNumPlayers:
			self.dc.onRevolution(iPlayer)
			
		if gc.getPlayer(iPlayer).getCivics(1) == con.iCivicEgalitarianism:
			utils.clearSlaves(iPlayer)
			
		if iPlayer in [con.iEgypt]:
			cnm.onRevolution(iPlayer)
	def onRevolution(self, argsList):
		'Called at the start of a revolution'
		iPlayer = argsList[0]
		
		sta.onRevolution(iPlayer)
		
		if iPlayer < iNumPlayers:
			dc.onRevolution(iPlayer)
			
		if gc.getPlayer(iPlayer).getCivics(1) == iCivicEgalitarianism:
			utils.clearSlaves(iPlayer)
			
		if iPlayer in [iEgypt]:
			cnm.onRevolution(iPlayer)
	def startVoteCityEvent(self, iClaimant, tPlot):
		x, y = tPlot
		plot = gc.getMap().plot(x, y)
		
		if plot.isRevealed(utils.getHumanID(), False):
			plot.cameraLookAt()
		
		popup = CyPopupInfo()
		popup.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON)
		popup.setOnClickedPythonCallback("applyVoteCityEvent")
		popup.setData1(iClaimant)
		popup.setData2(plot.getOwner())
		
		sClaimant = gc.getPlayer(iClaimant).getCivilizationShortDescription(0)
		
		if plot.isCity():
			popup.setText(localText.getText("TXT_KEY_CONGRESS_REQUEST_CITY", (sClaimant, gc.getPlayer(plot.getOwner()).getCivilizationAdjective(0), plot.getPlotCity().getName())))
		elif plot.isOwned():
			popup.setText(localText.getText("TXT_KEY_CONGRESS_REQUEST_SETTLE_OWNED", (sClaimant, gc.getPlayer(plot.getOwner()).getCivilizationAdjective(0), cnm.getFoundName(iClaimant, tPlot))))
		else:
			popup.setText(localText.getText("TXT_KEY_CONGRESS_REQUEST_SETTLE", (sClaimant, cnm.getFoundName(iClaimant, tPlot))))
			
		popup.addPythonButton(localText.getText("TXT_KEY_POPUP_VOTE_YES", ()), gc.getInterfaceArtInfo(gc.getInfoTypeForString("INTERFACE_EVENT_BULLET")).getPath())
		popup.addPythonButton(localText.getText("TXT_KEY_POPUP_ABSTAIN", ()), gc.getInterfaceArtInfo(gc.getInfoTypeForString("INTERFACE_EVENT_BULLET")).getPath())
		popup.addPythonButton(localText.getText("TXT_KEY_POPUP_VOTE_NO", ()), gc.getInterfaceArtInfo(gc.getInfoTypeForString("INTERFACE_EVENT_BULLET")).getPath())
		
		popup.addPopup(utils.getHumanID())
	def startVoteCityEvent(self, iClaimant, tPlot):
		x, y = tPlot
		plot = gc.getMap().plot(x, y)
		
		if plot.isRevealed(utils.getHumanID(), False):
			plot.cameraLookAt()
		
		popup = CyPopupInfo()
		popup.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON)
		popup.setOnClickedPythonCallback("applyVoteCityEvent")
		popup.setData1(iClaimant)
		popup.setData2(plot.getOwner())
		
		sClaimant = gc.getPlayer(iClaimant).getCivilizationShortDescription(0)
		
		if plot.isCity():
			popup.setText(localText.getText("TXT_KEY_CONGRESS_REQUEST_CITY", (sClaimant, gc.getPlayer(plot.getOwner()).getCivilizationAdjective(0), plot.getPlotCity().getName())))
		elif plot.isOwned():
			popup.setText(localText.getText("TXT_KEY_CONGRESS_REQUEST_SETTLE_OWNED", (sClaimant, gc.getPlayer(plot.getOwner()).getCivilizationAdjective(0), cnm.getFoundName(iClaimant, tPlot))))
		else:
			popup.setText(localText.getText("TXT_KEY_CONGRESS_REQUEST_SETTLE", (sClaimant, cnm.getFoundName(iClaimant, tPlot))))
			
		popup.addPythonButton(localText.getText("TXT_KEY_POPUP_VOTE_YES", ()), gc.getInterfaceArtInfo(gc.getInfoTypeForString("INTERFACE_EVENT_BULLET")).getPath())
		popup.addPythonButton(localText.getText("TXT_KEY_POPUP_ABSTAIN", ()), gc.getInterfaceArtInfo(gc.getInfoTypeForString("INTERFACE_EVENT_BULLET")).getPath())
		popup.addPythonButton(localText.getText("TXT_KEY_POPUP_VOTE_NO", ()), gc.getInterfaceArtInfo(gc.getInfoTypeForString("INTERFACE_EVENT_BULLET")).getPath())
		
		popup.addPopup(utils.getHumanID())
def getCityName(argsList):
    iPlayer, x, y = argsList

    result = cnm.getFoundName(iPlayer, (x, y))

    if result == -1:
        return ""
    else:
        return result
def getCityName(argsList):
	iPlayer, x, y = argsList
	
	result = cnm.getFoundName(iPlayer, (x,y))
	
	if result == -1:
		return ""
	else:
		return result
示例#10
0
    def __init__(self, eventManager):

        self.lastRegionID = -1
        self.bStabilityOverlay = False
        self.EventKeyDown = 6
        self.EventKeyUp = 7
        self.eventManager = eventManager

        # initialize base class
        eventManager.addEventHandler("GameStart", self.onGameStart)
        eventManager.addEventHandler("OnLoad", self.onLoadGame)
        eventManager.addEventHandler("OnPreSave", self.onPreSave)
        eventManager.addEventHandler("BeginGameTurn", self.onBeginGameTurn)
        eventManager.addEventHandler("EndGameTurn", self.onEndGameTurn)
        eventManager.addEventHandler("BeginPlayerTurn", self.onBeginPlayerTurn)
        eventManager.addEventHandler("EndPlayerTurn", self.onEndPlayerTurn)
        eventManager.addEventHandler("firstContact", self.onFirstContact)
        eventManager.addEventHandler("cityAcquired", self.onCityAcquired)
        eventManager.addEventHandler("goldenAge", self.onGoldenAge)  # srpt
        eventManager.addEventHandler("corporationSpread",
                                     self.onCorporationSpread)  # srpt
        eventManager.addEventHandler("cityAcquiredAndKept",
                                     self.onCityAcquiredAndKept)
        eventManager.addEventHandler("cityRazed", self.onCityRazed)
        eventManager.addEventHandler("cityBuilt", self.onCityBuilt)
        eventManager.addEventHandler("combatResult", self.onCombatResult)
        eventManager.addEventHandler("buildingBuilt", self.onBuildingBuilt)
        eventManager.addEventHandler("projectBuilt", self.onProjectBuilt)
        eventManager.addEventHandler("techAcquired", self.onTechAcquired)
        eventManager.addEventHandler("religionSpread", self.onReligionSpread)
        eventManager.addEventHandler("unitSpreadReligionAttempt",
                                     self.onUnitSpreadReligionAttempt)
        eventManager.addEventHandler("playerChangeStateReligion",
                                     self.onPlayerChangeStateReligion)
        eventManager.addEventHandler("vassalState", self.onVassalState)
        eventManager.addEventHandler("changeWar", self.onChangeWar)
        eventManager.addEventHandler("unitBuilt", self.onUnitBuilt)
        eventManager.addEventHandler("revolution", self.onRevolution)
        eventManager.addEventHandler("setPlayerAlive", self.onSetPlayerAlive)
        eventManager.addEventHandler("greatPersonBorn", self.onGreatPersonBorn)
        eventManager.addEventHandler("kbdEvent", self.onKbdEvent)

        self.rnf = RiseAndFall.RiseAndFall()
        self.cnm = CityNameManager.CityNameManager()
        self.res = Resources.Resources()
        self.rel = Religions.Religions()
        self.barb = Barbs.Barbs()
        self.aiw = AIWars.AIWars()
        self.vic = Victory.Victory()
        #self.pla = Plague.Plague()
        self.com = Communications.Communications()
        self.dc = DynamicCivs.DynamicCivs()
        self.corp = Companies.Companies()
        self.rfccwaiw = RFCCWAIWars.RFCCWAIWars()
def getCityName(argsList):
    iPlayer, x, y = argsList

    result = cnm.getFoundName(iPlayer, (x, y))
    if result:
        #result=result.decode('utf-8').encode("utf-8")
        #utils.log2(result,'test.log')
        pass
    if result == -1:
        return ""
    else:
        return result
	def startClaimCityEvent(self):
		popup = CyPopupInfo()
		popup.setText(localText.getText("TXT_KEY_CONGRESS_CLAIM_CITY", (self.sHostCityName,)))
		popup.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON)
		popup.setOnClickedPythonCallback("applyClaimCityEvent")
		
		for tCity in self.dPossibleClaims[utils.getHumanID()]:
			x, y, iValue = tCity
			plot = gc.getMap().plot(x, y)
			if plot.isCity():
				popup.addPythonButton(plot.getPlotCity().getName(), gc.getCivilizationInfo(gc.getPlayer(plot.getPlotCity().getOwner()).getCivilizationType()).getButton())
			else:
				popup.addPythonButton(cnm.getFoundName(utils.getHumanID(), (x, y)), 'Art/Interface/Buttons/Actions/FoundCity.dds')
			
		popup.addPythonButton(localText.getText("TXT_KEY_CONGRESS_NO_REQUEST", ()), 'Art/Interface/Buttons/Actions/Cancel.dds')
		popup.addPopup(utils.getHumanID())
	def startClaimCityEvent(self):
		popup = CyPopupInfo()
		popup.setText(localText.getText("TXT_KEY_CONGRESS_CLAIM_CITY", (self.sHostCityName,)))
		popup.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON)
		popup.setOnClickedPythonCallback("applyClaimCityEvent")
		
		for tCity in self.dPossibleClaims[utils.getHumanID()]:
			x, y, iValue = tCity
			plot = gc.getMap().plot(x, y)
			if plot.isCity():
				popup.addPythonButton(plot.getPlotCity().getName(), gc.getCivilizationInfo(gc.getPlayer(plot.getPlotCity().getOwner()).getCivilizationType()).getButton())
			else:
				popup.addPythonButton(cnm.getFoundName(utils.getHumanID(), (x, y)), 'Art/Interface/Buttons/Actions/FoundCity.dds')
			
		popup.addPythonButton(localText.getText("TXT_KEY_CONGRESS_NO_REQUEST", ()), 'Art/Interface/Buttons/Actions/Cancel.dds')
		popup.addPopup(utils.getHumanID())
	def applyVotes(self):
		dResults = {}
		
		for iClaimant in self.dCityClaims:
			x, y, iValue = self.dCityClaims[iClaimant]
			if self.dVotes[iClaimant] > 0:
				# only one player may receive a plot/city in case multiple civs claimed it (most votes)
				if (x, y) not in dResults:
					dResults[(x, y)] = (iClaimant, self.dVotes[iClaimant])
				else:
					iOtherClaimant, iVotes = dResults[(x, y)]
					if self.dVotes[iClaimant] > iVotes: dResults[(x, y)] = (iClaimant, self.dVotes[iClaimant])
					
		for tAssignedPlot in dResults:
			x, y = tAssignedPlot
			iClaimant, iVotes = dResults[tAssignedPlot]
			plot = gc.getMap().plot(x, y)
			
			bCanRefuse = (plot.getOwner() == utils.getHumanID() and utils.getHumanID() not in self.dVotedFor[iClaimant] and not (self.bPostWar and utils.getHumanID() in self.lLosers))
			
			if plot.isCity():
				self.lAssignments.append((plot.getPlotCity().getName(), plot.getOwner(), iClaimant))
				if bCanRefuse:
					self.lHumanAssignments.append((iClaimant, (x, y)))
				else:
					self.assignCity(iClaimant, plot.getOwner(), (x, y))
			else:
				self.lColonies.append((cnm.getFoundName(iClaimant, (x, y)), plot.getOwner(), iClaimant))
				if bCanRefuse:
					self.lHumanAssignments.append((iClaimant, (x, y)))
				else:
					self.foundColony(iClaimant, (x, y))
					
		# allow human player to refuse in case his cities were claimed -> last decision leads to result event
		if len(self.lHumanAssignments) > 0:
			iClaimant, tPlot = self.lHumanAssignments[0]
			self.startRefusalEvent(iClaimant, tPlot)
		else:
			# without human cities affected, finish the congress immediately
			self.finishCongress()
	def applyVotes(self):
		dResults = {}
		
		for iClaimant in self.dCityClaims:
			x, y, iValue = self.dCityClaims[iClaimant]
			if self.dVotes[iClaimant] > 0:
				# only one player may receive a plot/city in case multiple civs claimed it (most votes)
				if (x, y) not in dResults:
					dResults[(x, y)] = (iClaimant, self.dVotes[iClaimant])
				else:
					iOtherClaimant, iVotes = dResults[(x, y)]
					if self.dVotes[iClaimant] > iVotes: dResults[(x, y)] = (iClaimant, self.dVotes[iClaimant])
					
		for tAssignedPlot in dResults:
			x, y = tAssignedPlot
			iClaimant, iVotes = dResults[tAssignedPlot]
			plot = gc.getMap().plot(x, y)
			
			bCanRefuse = (plot.getOwner() == utils.getHumanID() and utils.getHumanID() not in self.dVotedFor[iClaimant] and not (self.bPostWar and utils.getHumanID() in self.lLosers))
			
			if plot.isCity():
				self.lAssignments.append((plot.getPlotCity().getName(), plot.getOwner(), iClaimant))
				if bCanRefuse:
					self.lHumanAssignments.append((iClaimant, (x, y)))
				else:
					self.assignCity(iClaimant, plot.getOwner(), (x, y))
			else:
				self.lColonies.append((cnm.getFoundName(iClaimant, (x, y)), plot.getOwner(), iClaimant))
				if bCanRefuse:
					self.lHumanAssignments.append((iClaimant, (x, y)))
				else:
					self.foundColony(iClaimant, (x, y))
					
		# allow human player to refuse in case his cities were claimed -> last decision leads to result event
		if len(self.lHumanAssignments) > 0:
			iClaimant, tPlot = self.lHumanAssignments[0]
			self.startRefusalEvent(iClaimant, tPlot)
		else:
			# without human cities affected, finish the congress immediately
			self.finishCongress()
示例#16
0
    def onCityBuilt(self, argsList):
        city = argsList[0]
        iOwner = city.getOwner()
        tCity = (city.getX(), city.getY())
        x, y = tCity

        if iOwner < iNumActivePlayers:
            cnm.onCityBuilt(city)

        # starting workers
        if city.isCapital():
            self.rnf.createStartingWorkers(iOwner, tCity)

        #Rhye - delete culture of barbs and minor civs to prevent weird unhappiness
        pPlot = gc.getMap().plot(x, y)
        for i in range(iNumTotalPlayers - iNumActivePlayers):
            iMinorCiv = i + iNumActivePlayers
            pPlot.setCulture(iMinorCiv, 0, True)
        pPlot.setCulture(iBarbarian, 0, True)

        if iOwner < iNumMajorPlayers:
            utils.spreadMajorCulture(iOwner, tCity)
            if gc.getPlayer(iOwner).getNumCities() < 2:
                gc.getPlayer(iOwner).AI_updateFoundValues(False)
                # fix for settler maps not updating after 1st city is founded

        if iOwner == iOttomans:
            self.up.ottomanUP(city, iOwner, -1)

        if iOwner == iCarthage:
            if tCity == (58, 39):
                if not gc.getPlayer(iCarthage).isHuman():
                    x = gc.getPlayer(iCarthage).getCapitalCity().getX()
                    y = gc.getPlayer(iCarthage).getCapitalCity().getY()
                    carthage = gc.getMap().plot(58, 39).getPlotCity()
                    carthage.setHasRealBuilding(iPalace, True)
                    gc.getMap().plot(x, y).getPlotCity().setHasRealBuilding(
                        iPalace, False)
                    dc.onPalaceMoved(iCarthage)

                    carthage.setPopulation(3)

                    utils.makeUnitAI(iWorkboat, iCarthage, (58, 39),
                                     UnitAITypes.UNITAI_WORKER_SEA, 1)
                    utils.makeUnitAI(iGalley, iCarthage, (57, 40),
                                     UnitAITypes.UNITAI_SETTLER_SEA, 1)
                    utils.makeUnitAI(iSettler, iCarthage, (57, 40),
                                     UnitAITypes.UNITAI_SETTLE, 1)

                    # additional defenders and walls to make human life not too easy
                    if utils.getHumanID() == iRome:
                        carthage.setHasRealBuilding(iWalls, True)
                        utils.makeUnitAI(iArcher, iCarthage, (58, 39),
                                         UnitAITypes.UNITAI_CITY_DEFENSE, 2)
                        utils.makeUnit(iNumidianCavalry, iCarthage, (58, 39),
                                       3)
                        utils.makeUnitAI(iWarElephant, iCarthage, (58, 39),
                                         UnitAITypes.UNITAI_CITY_COUNTER, 2)

                if utils.getOwnedCoreCities(iCarthage) > 0:
                    utils.setReborn(iCarthage, True)

        if iOwner == iByzantium and tCity == Areas.getCapital(
                iByzantium
        ) and gc.getGame().getGameTurn() <= getTurnForYear(330) + 3:
            if city.getPopulation() < 5:
                city.setPopulation(5)

            city.setHasRealBuilding(iBarracks, True)
            city.setHasRealBuilding(iWalls, True)
            city.setHasRealBuilding(iLibrary, True)
            city.setHasRealBuilding(iMarket, True)
            city.setHasRealBuilding(iGranary, True)
            city.setHasRealBuilding(iHarbor, True)
            city.setHasRealBuilding(iForge, True)

            city.setHasRealBuilding(
                iTemple + 4 * gc.getPlayer(iOwner).getStateReligion(), True)

        if iOwner == iPortugal and tCity == Areas.getCapital(
                iPortugal) and gc.getGame().getGameTurn() <= getTurnForYear(
                    tBirth[iPortugal]) + 3:
            city.setPopulation(5)

            for iBuilding in [
                    iLibrary, iMarket, iHarbor, iLighthouse, iForge, iWalls,
                    iTemple + 4 * gc.getPlayer(iPortugal).getStateReligion()
            ]:
                city.setHasRealBuilding(iBuilding, True)

        if iOwner == iNetherlands and tCity == Areas.getCapital(
                iNetherlands
        ) and gc.getGame().getGameTurn() <= getTurnForYear(1580) + 3:
            city.setPopulation(9)

            for iBuilding in [
                    iLibrary, iMarket, iWharf, iLighthouse, iBarracks,
                    iPharmacy, iBank, iArena, iTheatre, iTemple +
                    4 * gc.getPlayer(iNetherlands).getStateReligion()
            ]:
                city.setHasRealBuilding(iBuilding, True)

            gc.getPlayer(iNetherlands).AI_updateFoundValues(False)

        if iOwner == iItaly and tCity == Areas.getCapital(
                iItaly) and gc.getGame().getGameTurn() <= getTurnForYear(
                    tBirth[iItaly]) + 3:
            city.setPopulation(7)

            for iBuilding in [
                    iLibrary, iPharmacy,
                    iTemple + 4 * gc.getPlayer(iItaly).getStateReligion(),
                    iMarket, iArtStudio, iAqueduct, iCourthouse, iWalls
            ]:
                city.setHasRealBuilding(iBuilding, True)

            gc.getPlayer(iItaly).AI_updateFoundValues(False)

        vic.onCityBuilt(iOwner, city)

        if iOwner < iNumPlayers:
            dc.onCityBuilt(iOwner)

        if iOwner == iArabia:
            if not gc.getGame().isReligionFounded(iIslam):
                if tCity == (75, 33):
                    self.rel.foundReligion(tCity, iIslam)

        # Leoreth: free defender and worker for AI colonies
        if iOwner in lCivGroups[0]:
            if city.getRegionID() not in mercRegions[iArea_Europe]:
                if utils.getHumanID() != iOwner:
                    utils.createGarrisons(tCity, iOwner, 1)
                    utils.makeUnit(iWorker, iOwner, tCity, 1)

        # Holy Rome founds its capital
        if iOwner == iHolyRome:
            if gc.getPlayer(iHolyRome).getNumCities() == 1:
                self.rnf.holyRomanSpawn()

        # Leoreth: Escorial effect
        if gc.getPlayer(iOwner).isHasBuildingEffect(iEscorial):
            if city.isColony():
                capital = gc.getPlayer(iOwner).getCapitalCity()
                iGold = utils.getTurns(10 + utils.calculateDistance(
                    capital.getX(), capital.getY(), city.getX(), city.getY()))
                CyInterface().addMessage(
                    iOwner, False, iDuration,
                    CyTranslator().getText("TXT_KEY_BUILDING_ESCORIAL_EFFECT",
                                           (iGold, city.getName())), "", 0, "",
                    ColorTypes(iWhite), -1, -1, True, True)
                gc.getPlayer(iOwner).changeGold(iGold)

        # Leoreth: free defender and worker for cities founded by American Pioneer in North America
        if iOwner == iAmerica:
            if city.getRegionID() in [rUnitedStates, rCanada, rAlaska]:
                utils.createGarrisons(tCity, iOwner, 1)
                utils.makeUnit(iWorker, iOwner, tCity, 1)
示例#17
0
    def onCityAcquired(self, argsList):
        iOwner, iPlayer, city, bConquest, bTrade = argsList
        tCity = (city.getX(), city.getY())

        cnm.onCityAcquired(city, iPlayer)

        if bConquest:
            sta.onCityAcquired(city, iOwner, iPlayer)

        if iPlayer == iArabia:
            self.up.arabianUP(city)

        if iPlayer == iMongolia and bConquest and utils.getHumanID(
        ) != iPlayer:
            self.up.mongolUP(city)

        # relocate capitals
        if utils.getHumanID() != iPlayer:
            if iPlayer == iOttomans and tCity == (68, 45):
                utils.moveCapital(iOttomans, tCity)  # Kostantiniyye
            elif iPlayer == iMongolia and tCity == (102, 47):
                utils.moveCapital(iMongolia, tCity)  # Khanbaliq
            elif iPlayer == iTurks and utils.isAreaControlled(
                    iTurks, Areas.tCoreArea[iPersia][0],
                    Areas.tCoreArea[iPersia][1]):
                capital = pTurks.getCapitalCity()
                if not utils.isPlotInArea((capital.getX(), capital.getY()),
                                          Areas.tCoreArea[iPersia][0],
                                          Areas.tCoreArea[iPersia][1]):
                    newCapital = utils.getRandomEntry(
                        utils.getAreaCitiesCiv(
                            iTurks,
                            utils.getPlotList(Areas.tCoreArea[iPersia][0],
                                              Areas.tCoreArea[iPersia][1])))
                    if newCapital:
                        utils.moveCapital(
                            iTurks, (newCapital.getX(), newCapital.getY()))

        # remove slaves if unable to practice slavery
        if not gc.getPlayer(iPlayer).canUseSlaves():
            utils.removeSlaves(city)
        else:
            utils.freeSlaves(city, iPlayer)

        if city.isCapital():
            if city.isHasRealBuilding(iAdministrativeCenter):
                city.setHasRealBuilding(iAdministrativeCenter, False)

        # Leoreth: relocate capital for AI if reacquired:
        if utils.getHumanID() != iPlayer and iPlayer < iNumPlayers:
            if data.players[iPlayer].iResurrections == 0:
                if Areas.getCapital(iPlayer) == tCity:
                    utils.relocateCapital(iPlayer, city)
            else:
                if Areas.getRespawnCapital(iPlayer) == tCity:
                    utils.relocateCapital(iPlayer, city)

        # Leoreth: conquering Constantinople adds it to the Turkish core + Rumelia
        if iPlayer == iOttomans and tCity == (68, 45):
            utils.setReborn(iOttomans, True)

        if iPlayer == iTurks:
            if utils.isAreaControlled(iPlayer, Areas.tCoreArea[iPersia][0],
                                      Areas.tCoreArea[iPersia][1]):
                utils.setReborn(iTurks, True)
            else:
                utils.setReborn(iTurks, False)

        # Leoreth: help Byzantium/Constantinople
        if iPlayer == iByzantium and tCity == Areas.getCapital(
                iByzantium
        ) and gc.getGame().getGameTurn() <= getTurnForYear(330) + 3:
            if city.getPopulation() < 5:
                city.setPopulation(5)

            city.setHasRealBuilding(iBarracks, True)
            city.setHasRealBuilding(iWalls, True)
            city.setHasRealBuilding(iLibrary, True)
            city.setHasRealBuilding(iMarket, True)
            city.setHasRealBuilding(iGranary, True)
            city.setHasRealBuilding(iHarbor, True)
            city.setHasRealBuilding(iForge, True)

            city.setName("Konstantinoupolis", False)

            city.setHasRealBuilding(
                iTemple + 4 * gc.getPlayer(iPlayer).getStateReligion(), True)

        if bConquest:

            # Colombian UP: no resistance in conquered cities in Latin America
            if iPlayer == iMaya and utils.isReborn(iMaya):
                if utils.isPlotInArea(tCity, tSouthCentralAmericaTL,
                                      tSouthCentralAmericaBR):
                    city.setOccupationTimer(0)

            # Statue of Zeus effect: no city resistance on conquest
            if gc.getPlayer(iPlayer).isHasBuildingEffect(iStatueOfZeus):
                city.setOccupationTimer(0)

            # Byzantium reduced to four cities: core shrinks to Constantinople
            if iOwner == iByzantium and gc.getPlayer(
                    iByzantium).getNumCities <= 4:
                utils.setReborn(iByzantium, True)

        if bTrade:
            for i in range(iNumBuildings):
                iNationalWonder = i
                if isNationalWonderClass(
                        gc.getBuildingInfo(iNationalWonder).
                        getBuildingClassType()) and city.hasBuilding(
                            iNationalWonder):
                    city.setHasRealBuilding(iNationalWonder, False)

        # Leoreth: Escorial effect
        if gc.getPlayer(iPlayer).isHasBuildingEffect(iEscorial):
            if city.isColony():
                capital = gc.getPlayer(iPlayer).getCapitalCity()
                iGold = utils.getTurns(10 + utils.calculateDistance(
                    capital.getX(), capital.getY(), city.getX(), city.getY()))
                CyInterface().addMessage(
                    iPlayer, False, iDuration,
                    CyTranslator().getText("TXT_KEY_BUILDING_ESCORIAL_EFFECT",
                                           (iGold, city.getName())), "", 0, "",
                    ColorTypes(iWhite), -1, -1, True, True)
                gc.getPlayer(iPlayer).changeGold(iGold)

        self.pla.onCityAcquired(iOwner, iPlayer, city)  # Plague
        self.com.onCityAcquired(city)  # Communications
        self.corp.onCityAcquired(argsList)  # Companies
        dc.onCityAcquired(iOwner, iPlayer)  # DynamicCivs

        vic.onCityAcquired(iPlayer, iOwner, city, bConquest)

        lTradingCompanyList = [
            iSpain, iFrance, iEngland, iPortugal, iNetherlands
        ]

        if bTrade and iPlayer in lTradingCompanyList and (
                city.getX(), city.getY()
        ) in tTradingCompanyPlotLists[lTradingCompanyList.index(iPlayer)]:
            self.up.tradingCompanyCulture(city, iPlayer, iOwner)

        return 0
示例#18
0
    def onTechAcquired(self, argsList):
        iTech, iTeam, iPlayer, bAnnounce = argsList

        iHuman = utils.getHumanID()

        iEra = gc.getTechInfo(iTech).getEra()

        if gc.getGame().getGameTurn() == utils.getScenarioStartTurn():
            return

        sta.onTechAcquired(iPlayer, iTech)
        AIParameters.onTechAcquired(iPlayer, iTech)

        if gc.getGame().getGameTurn() > getTurnForYear(tBirth[iPlayer]):
            vic.onTechAcquired(iPlayer, iTech)
            cnm.onTechAcquired(iPlayer)
            dc.onTechAcquired(iPlayer, iTech)

        if gc.getPlayer(iPlayer).isAlive() and gc.getGame().getGameTurn(
        ) > getTurnForYear(tBirth[iPlayer]) and iPlayer < iNumPlayers:
            self.rel.onTechAcquired(iTech, iPlayer)
            if (gc.getGame().getGameTurn() > getTurnForYear(1700)):
                self.aiw.forgetMemory(iTech, iPlayer)

        if iTech == iExploration:
            if iPlayer in [
                    iSpain, iFrance, iEngland, iGermany, iVikings,
                    iNetherlands, iPortugal
            ]:
                data.players[iPlayer].iExplorationTurn = gc.getGame(
                ).getGameTurn()

        elif iTech == iCompass:
            if iPlayer == iVikings:
                gc.getMap().plot(49, 62).setTerrainType(iCoast, True, True)

        elif iTech == iMicrobiology:
            self.pla.onTechAcquired(iTech, iPlayer)

        elif iTech == iRailroad:
            self.rnf.onRailroadDiscovered(iPlayer)

        if iTech in [iExploration, iFirearms]:
            teamPlayer = gc.getTeam(iPlayer)
            if teamPlayer.isHasTech(iExploration) and teamPlayer.isHasTech(
                    iFirearms):
                self.rnf.earlyTradingCompany(iPlayer)

        if iTech in [iEconomics, iReplaceableParts]:
            teamPlayer = gc.getTeam(iPlayer)
            if teamPlayer.isHasTech(iEconomics) and teamPlayer.isHasTech(
                    iReplaceableParts):
                self.rnf.lateTradingCompany(iPlayer)

        if utils.getHumanID() != iPlayer:
            if iPlayer == iJapan and iEra == iIndustrial:
                utils.moveCapital(iPlayer, (116, 47))  # Toukyou
            elif iPlayer == iItaly and iEra == iIndustrial:
                utils.moveCapital(iPlayer, (60, 44))  # Roma
            elif iPlayer == iVikings and iEra == iRenaissance:
                utils.moveCapital(iPlayer, (63, 59))  # Stockholm
            elif iPlayer == iHolyRome and iEra == iRenaissance:
                utils.moveCapital(iPlayer, (62, 49))  # Wien

        # Spain's core extends when reaching the Renaissance and there are no Moors in Iberia
        # at the same time, the Moorish core relocates to Africa
        if iPlayer == iSpain and iEra == iRenaissance and not utils.isReborn(
                iSpain):
            bNoMoors = True
            if gc.getPlayer(iMoors).isAlive():
                for city in utils.getCityList(iMoors):
                    if city.plot().getRegionID() == rIberia:
                        bNoMoors = False
            if bNoMoors:
                utils.setReborn(iSpain, True)
                utils.setReborn(iMoors, True)

        # Italy's core extends when reaching the Industrial era
        if iPlayer == iItaly and iEra == iIndustrial:
            utils.setReborn(iItaly, True)

        # Arabia's core moves to Iraq when Education is discovered
        if iPlayer == iArabia and iTech == iEducation:
            utils.setReborn(iArabia, True)

        # Japan's core extends when reaching the Industrial era
        if iPlayer == iJapan and iEra == iIndustrial:
            utils.setReborn(iJapan, True)

        # Germany's core shrinks when reaching the Digital era
        if iPlayer == iGermany and iEra == iDigital:
            utils.setReborn(iGermany, True)
示例#19
0
    def onCityBuilt(self, argsList):
        city = argsList[0]
        iOwner = city.getOwner()
        tCity = (city.getX(), city.getY())
        x, y = tCity

        if iOwner < iNumActivePlayers:
            cnm.onCityBuilt(city)

        # starting workers
        if city.isCapital():
            self.rnf.createStartingWorkers(iOwner, tCity)

        #Rhye - delete culture of barbs and minor civs to prevent weird unhappiness
        pPlot = gc.getMap().plot(x, y)
        for i in range(iNumTotalPlayers - iNumActivePlayers):
            iMinorCiv = i + iNumActivePlayers
            pPlot.setCulture(iMinorCiv, 0, True)
        pPlot.setCulture(iBarbarian, 0, True)

        if iOwner < iNumMajorPlayers:
            utils.spreadMajorCulture(iOwner, tCity)
            if gc.getPlayer(iOwner).getNumCities() < 2:
                gc.getPlayer(iOwner).AI_updateFoundValues(False)
                # fix for settler maps not updating after 1st city is founded

        if iOwner == iTurkey:
            self.up.turkishUP(city, iOwner, -1)
        elif iOwner == iBoers:
            self.up.boersUP(city)

        if iOwner == iCarthage:
            if tCity == (58, 39):
                if not gc.getPlayer(iCarthage).isHuman():
                    x = gc.getPlayer(iCarthage).getCapitalCity().getX()
                    y = gc.getPlayer(iCarthage).getCapitalCity().getY()
                    carthage = gc.getMap().plot(58, 39).getPlotCity()
                    carthage.setHasRealBuilding(iPalace, True)
                    gc.getMap().plot(x, y).getPlotCity().setHasRealBuilding(
                        iPalace, False)
                    dc.onPalaceMoved(iCarthage)

                    carthage.setPopulation(3)

                    utils.makeUnitAI(iWorkboat, iCarthage, (58, 39),
                                     UnitAITypes.UNITAI_WORKER_SEA, 1)
                    utils.makeUnitAI(iGalley, iCarthage, (57, 40),
                                     UnitAITypes.UNITAI_SETTLER_SEA, 1)
                    utils.makeUnitAI(iSettler, iCarthage, (57, 40),
                                     UnitAITypes.UNITAI_SETTLE, 1)

                utils.setReborn(iCarthage, True)

        if iOwner == iByzantium and tCity == Areas.getCapital(
                iByzantium
        ) and gc.getGame().getGameTurn() <= getTurnForYear(330) + 3:
            if city.getPopulation() < 5:
                city.setPopulation(5)

            city.setHasRealBuilding(iBarracks, True)
            city.setHasRealBuilding(iWalls, True)
            city.setHasRealBuilding(iLibrary, True)
            city.setHasRealBuilding(iMarket, True)
            city.setHasRealBuilding(iGranary, True)
            city.setHasRealBuilding(iHarbor, True)
            city.setHasRealBuilding(iForge, True)

            city.setHasRealBuilding(
                iTemple + 4 * gc.getPlayer(iOwner).getStateReligion(), True)

        if iOwner == iPortugal and tCity == Areas.getCapital(
                iPortugal) and gc.getGame().getGameTurn() <= getTurnForYear(
                    tBirth[iPortugal]) + 3:
            city.setPopulation(5)

            for iBuilding in [
                    iLibrary, iMarket, iHarbor, iLighthouse, iForge, iWalls,
                    iTemple + 4 * gc.getPlayer(iPortugal).getStateReligion()
            ]:
                city.setHasRealBuilding(iBuilding, True)

        if iOwner == iNetherlands and tCity == Areas.getCapital(
                iNetherlands
        ) and gc.getGame().getGameTurn() <= getTurnForYear(1580) + 3:
            city.setPopulation(9)

            for iBuilding in [
                    iLibrary, iMarket, iWharf, iLighthouse, iBarracks,
                    iPharmacy, iBank, iAmphitheatre, iTheatre, iTemple +
                    4 * gc.getPlayer(iNetherlands).getStateReligion()
            ]:
                city.setHasRealBuilding(iBuilding, True)

            gc.getPlayer(iNetherlands).AI_updateFoundValues(False)

        if iOwner == iItaly and tCity == Areas.getCapital(
                iItaly) and gc.getGame().getGameTurn() <= getTurnForYear(
                    tBirth[iItaly]) + 3:
            city.setPopulation(7)

            for iBuilding in [
                    iLibrary, iPharmacy,
                    iTemple + 4 * gc.getPlayer(iItaly).getStateReligion(),
                    iMarket, iArtStudio, iAqueduct, iCourthouse, iWalls
            ]:
                city.setHasRealBuilding(iBuilding, True)

            gc.getPlayer(iItaly).AI_updateFoundValues(False)

        vic.onCityBuilt(iOwner, city)

        if iOwner < iNumPlayers:
            dc.onCityBuilt(iOwner)

        if iOwner == iArabia:
            if not gc.getGame().isReligionFounded(iIslam):
                if tCity == (75, 33):
                    self.rel.foundReligion(tCity, iIslam)

        # Leoreth: free defender and worker for AI colonies
        if iOwner in lCivGroups[0]:
            if city.getRegionID() not in mercRegions[iArea_Europe]:
                if utils.getHumanID() != iOwner:
                    utils.createGarrisons(tCity, iOwner, 1)
                    utils.makeUnit(iWorker, iOwner, tCity, 1)

        # Holy Rome founds its capital
        if iOwner == iHolyRome:
            if gc.getPlayer(iHolyRome).getNumCities() == 1:
                self.rnf.holyRomanSpawn()
	def onTechAcquired(self, argsList):
		iTech, iTeam, iPlayer, bAnnounce = argsList

		iHuman = utils.getHumanID()
		
		iEra = gc.getTechInfo(iTech).getEra()
		
		if utils.getScenario() == i600AD and gc.getGame().getGameTurn() == getTurnForYear(600): #late start condition
			return
			
		if utils.getScenario() == i1700AD and gc.getGame().getGameTurn() == getTurnForYear(1700):
			return
			
		sta.onTechAcquired(iPlayer, iTech)
		AIParameters.onTechAcquired(iPlayer, iTech)
		
		if gc.getGame().getGameTurn() > getTurnForYear(tBirth[iPlayer]):
			vic.onTechAcquired(iPlayer, iTech)
			cnm.onTechAcquired(argsList[2])

		if gc.getPlayer(iPlayer).isAlive() and gc.getGame().getGameTurn() > getTurnForYear(tBirth[iPlayer]) and iPlayer < iNumPlayers:
			self.rel.onTechAcquired(argsList[0], argsList[2])
			if (gc.getGame().getGameTurn() > getTurnForYear(1700)):
				self.aiw.forgetMemory(argsList[0], argsList[2])

		if iTech == iAstronomy:
			if iPlayer in [iSpain, iFrance, iEngland, iGermany, iVikings, iNetherlands, iPortugal]:
				data.players[iPlayer].iAstronomyTurn = gc.getGame().getGameTurn()
				
		elif iTech == iCompass:
			if iPlayer == iVikings:
				gc.getMap().plot(49, 62).setTerrainType(iCoast, True, True)
				
		elif iTech == iMedicine:
			self.pla.onTechAcquired(argsList[0], argsList[2])

		elif iTech == iRailroad:
			self.rnf.onRailroadDiscovered(argsList[2])
			
		if iTech in [iAstronomy, iGunpowder]:
			teamPlayer = gc.getTeam(iPlayer)
			if teamPlayer.isHasTech(iAstronomy) and teamPlayer.isHasTech(iGunpowder):
				self.rnf.earlyTradingCompany(iPlayer)
			
		if iTech in [iEconomics, iRifling]:
			teamPlayer = gc.getTeam(iPlayer)
			if teamPlayer.isHasTech(iEconomics) and teamPlayer.isHasTech(iRifling):
				self.rnf.lateTradingCompany(iPlayer)
	
		if utils.getHumanID() != iPlayer:
			if iPlayer == iJapan and iEra == iIndustrial:
				utils.moveCapital(iPlayer, (116, 47)) # Toukyou
			elif iPlayer == iItaly and iEra == iIndustrial:
				utils.moveCapital(iPlayer, (60, 44)) # Roma
			elif iPlayer == iVikings and iEra == iRenaissance:
				utils.moveCapital(iPlayer, (63, 59)) # Stockholm
			elif iPlayer == iHolyRome and iEra == iRenaissance:
				utils.moveCapital(iPlayer, (62, 49)) # Wien
				
		# Spain's core extends when reaching the Renaissance and there are no Moors in Iberia
		# at the same time, the Moorish core relocates to Africa
		if iPlayer == iSpain and iEra == iRenaissance and not utils.isReborn(iSpain):
			bNoMoors = True
			if gc.getPlayer(iMoors).isAlive():
				for city in utils.getCityList(iMoors):
					if city.plot().getRegionID() == rIberia:
						bNoMoors = False
			if bNoMoors:
				utils.setReborn(iSpain, True)
				utils.setReborn(iMoors, True)
				
		# Italy's core extends when reaching the Industrial era
		if iPlayer == iItaly and iEra == iIndustrial:
			utils.setReborn(iItaly, True)
			
		# Arabia's core moves to Iraq when Philosophy is discovered
		if iPlayer == iArabia and iTech == iPhilosophy:
			utils.setReborn(iArabia, True)
			
		# Japan's core extends when reaching the Industrial era
		if iPlayer == iJapan and iEra == iIndustrial:
			utils.setReborn(iJapan, True)
			
		# Germany's core shrinks when reaching the Modern era
		if iPlayer == iGermany and iEra == iModern:
			utils.setReborn(iGermany, True)
	def onCityBuilt(self, argsList):
		city = argsList[0]
		iOwner = city.getOwner()
		tCity = (city.getX(), city.getY())
		x, y = tCity
		
		if iOwner < iNumActivePlayers: 
			cnm.onCityBuilt(city)
			
		# starting workers
		if city.isCapital():
			self.rnf.createStartingWorkers(iOwner, tCity)

		#Rhye - delete culture of barbs and minor civs to prevent weird unhappiness
		pPlot = gc.getMap().plot(x, y)
		for i in range(iNumTotalPlayers - iNumActivePlayers):
			iMinorCiv = i + iNumActivePlayers
			pPlot.setCulture(iMinorCiv, 0, True)
		pPlot.setCulture(iBarbarian, 0, True)

		if iOwner < iNumMajorPlayers:
			utils.spreadMajorCulture(iOwner, tCity)
			if gc.getPlayer(iOwner).getNumCities() < 2:
				gc.getPlayer(iOwner).AI_updateFoundValues(False); # fix for settler maps not updating after 1st city is founded

		if iOwner == iTurkey:
			self.up.turkishUP(city, iOwner, -1)
			
		if iOwner == iCarthage:
			if tCity == (58, 39):
				if not gc.getPlayer(iCarthage).isHuman():
					x = gc.getPlayer(iCarthage).getCapitalCity().getX()
					y = gc.getPlayer(iCarthage).getCapitalCity().getY()
					carthage = gc.getMap().plot(58, 39).getPlotCity()
					carthage.setHasRealBuilding(iPalace, True)
					gc.getMap().plot(x, y).getPlotCity().setHasRealBuilding(iPalace, False)
					dc.onPalaceMoved(iCarthage)
					
					carthage.setPopulation(3)
					
					utils.makeUnitAI(iWorkboat, iCarthage, (58, 39), UnitAITypes.UNITAI_WORKER_SEA, 1)
					utils.makeUnitAI(iPhoenicianBireme, iCarthage, (57, 40), UnitAITypes.UNITAI_SETTLER_SEA, 1)
					utils.makeUnitAI(iSettler, iCarthage, (57, 40), UnitAITypes.UNITAI_SETTLE, 1)
					
				utils.setReborn(iCarthage, True)
				
		if iOwner == iByzantium and tCity == Areas.getCapital(iByzantium) and gc.getGame().getGameTurn() <= getTurnForYear(330)+3:
			if city.getPopulation() < 5:
				city.setPopulation(5)
				
			city.setHasRealBuilding(iBarracks, True)
			city.setHasRealBuilding(iWalls, True)
			city.setHasRealBuilding(iLibrary, True)
			city.setHasRealBuilding(iMarket, True)
			city.setHasRealBuilding(iGranary, True)
			city.setHasRealBuilding(iHarbor, True)
			city.setHasRealBuilding(iForge, True)
			
			city.setHasRealBuilding(iTemple + 4*gc.getPlayer(iOwner).getStateReligion(), True)
			
		if iOwner == iNetherlands and tCity == Areas.getCapital(iNetherlands) and gc.getGame().getGameTurn() <= getTurnForYear(1580)+3:
			city.setPopulation(9)
			
			for iBuilding in [iLibrary, iBarracks, iGrocer, iBank, iAmphitheatre, iTheatre, iTemple+4*gc.getPlayer(iNetherlands).getStateReligion()]:
				city.setHasRealBuilding(iBuilding, True)
				
			gc.getPlayer(iNetherlands).AI_updateFoundValues(False)
			
		if iOwner == iItaly and tCity == Areas.getCapital(iItaly) and gc.getGame().getGameTurn() <= getTurnForYear(tBirth[iItaly])+3:
			city.setPopulation(7)
			
			for iBuilding in [iLibrary, iGrocer, iTemple+4*gc.getPlayer(iItaly).getStateReligion(), iMarket, iItalianArtStudio, iAqueduct, iCourthouse, iWalls]:
				city.setHasRealBuilding(iBuilding, True)
				
			gc.getPlayer(iItaly).AI_updateFoundValues(False)

		vic.onCityBuilt(iOwner, city)
			
		if iOwner < iNumPlayers:
			dc.onCityBuilt(iOwner)

		if iOwner == iArabia:
			if not gc.getGame().isReligionFounded(iIslam):
				if tCity == (75, 33):
					self.rel.foundReligion(tCity, iIslam)
				
		# Leoreth: free defender and worker for AI colonies
		if iOwner in lCivGroups[0]:
			if city.getRegionID() not in mercRegions[iArea_Europe]:
				if utils.getHumanID() != iOwner:
					utils.createGarrisons(tCity, iOwner, 1)
					utils.makeUnit(iWorker, iOwner, tCity, 1)
					
		# Holy Rome founds its capital
		if iOwner == iHolyRome:
			if gc.getPlayer(iHolyRome).getNumCities() == 1:
				self.rnf.holyRomanSpawn()
	def onCityAcquired(self, argsList):
		iOwner, iPlayer, city, bConquest, bTrade = argsList
		tCity = (city.getX(), city.getY())
		
		cnm.onCityAcquired(city, iPlayer)
		
		if bConquest:
			sta.onCityAcquired(city, iOwner, iPlayer)
			
		if iPlayer == iArabia:
			self.up.arabianUP(city)
		# elif iPlayer == iMughals and utils.getHumanID() != iMughals:
			# self.up.mughalUP(city)
		# elif iPlayer == iSeljuks:
			# self.up.seljukUP(city)
			
		if iPlayer == iMongolia and bConquest and utils.getHumanID() != iPlayer:
			self.up.mongolUP(city)
			
		if iPlayer < iNumMajorPlayers:
			utils.spreadMajorCulture(iPlayer, tCity)
		
		# relocate capitals
		if utils.getHumanID() != iPlayer:
			if iPlayer == iTurkey and tCity == (68, 45):
				utils.moveCapital(iTurkey, tCity) # Kostantiniyye
			elif iPlayer == iMongolia and tCity == (102, 47):
				utils.moveCapital(iMongolia, tCity) # Khanbaliq
				
		# remove slaves if unable to practice slavery
		if gc.getPlayer(iPlayer).getCivics(1) == iCivicEgalitarianism:
			utils.removeSlaves(city)
		else:
			utils.freeSlaves(city, iPlayer)
					
							
		# kill Seljuks
		#if iOwner == iSeljuks and gc.getPlayer(iSeljuks).isAlive() and gc.getGame().getGameTurnYear() >= 1250:
		#	if city.isCapital() or gc.getPlayer(iSeljuks).getNumCities() <= 2:
		#		sta.completeCollapse(iSeljuks)
				#utils.killAndFragmentCiv(iSeljuks, iIndependent, iIndependent2, -1, False)
				
		# Leoreth: relocate capital for AI if reacquired:
		if utils.getHumanID() != iPlayer and iPlayer < iNumPlayers:
			if data.players[iPlayer].iResurrections == 0:
				if Areas.getCapital(iPlayer) == tCity:
					utils.relocateCapital(iPlayer, city)
			else:
				if Areas.getRespawnCapital(iPlayer) == tCity:
					utils.relocateCapital(iPlayer, city)
					
		# Leoreth: conquering Constantinople adds it to the Turkish core + Rumelia
		if iPlayer == iTurkey and tCity == (68, 45):
			utils.setReborn(iTurkey, True)
					
		# Leoreth: help Byzantium/Constantinople
		if iPlayer == iByzantium and tCity == Areas.getCapital(iByzantium) and gc.getGame().getGameTurn() <= getTurnForYear(330)+3:
			if city.getPopulation() < 5:
				city.setPopulation(5)
				
			city.setHasRealBuilding(iBarracks, True)
			city.setHasRealBuilding(iWalls, True)
			city.setHasRealBuilding(iLibrary, True)
			city.setHasRealBuilding(iMarket, True)
			city.setHasRealBuilding(iGranary, True)
			city.setHasRealBuilding(iHarbor, True)
			city.setHasRealBuilding(iForge, True)
			
			city.setName("Konstantinoupolis", False)
			
			city.setHasRealBuilding(iTemple + 4*gc.getPlayer(iPlayer).getStateReligion(), True)
			
		if bConquest:

			# Colombian UP: no resistance in conquered cities in Latin America
			if iPlayer == iMaya and utils.isReborn(iMaya):
				if utils.isPlotInArea(tCity, tSouthCentralAmericaTL, tSouthCentralAmericaBR):
					city.setOccupationTimer(0)
					
			# Statue of Zeus effect: no city resistance on conquest
			if gc.getPlayer(iPlayer).countNumBuildings(iStatueOfZeus) > 0 and not gc.getTeam(iPlayer).isHasTech(iTheology):
				city.setOccupationTimer(0)
				
			# Byzantium reduced to four cities: core shrinks to Constantinople
			if iOwner == iByzantium and gc.getPlayer(iByzantium).getNumCities <= 4:
				utils.setReborn(iByzantium, True)
					
		if bTrade:
			for i in range(iNumBuildings):
				iNationalWonder = i
				if isNationalWonderClass(gc.getBuildingInfo(iNationalWonder).getBuildingClassType()) and city.hasBuilding(iNationalWonder):
					city.setHasRealBuilding(iNationalWonder, False)
					
		self.pla.onCityAcquired(iOwner, iPlayer, city) # Plague
		self.com.onCityAcquired(city) # Communications
		self.corp.onCityAcquired(argsList) # Companies
		dc.onCityAcquired(iOwner, iPlayer) # DynamicCivs
		
		vic.onCityAcquired(iPlayer, iOwner, city, bConquest)
		
		return 0
示例#23
0
        def onTechAcquired(self, argsList):
		iTech, iTeam, iPlayer, bAnnounce = argsList

                iHuman = utils.getHumanID()
		
		iEra = gc.getTechInfo(iTech).getEra()
                
                if (utils.getScenario() == con.i600AD and gc.getGame().getGameTurn() == getTurnForYear(600)): #late start condition
                        return
			
		if utils.getScenario() == con.i1700AD and gc.getGame().getGameTurn() == getTurnForYear(1700):
			return
			
		sta.onTechAcquired(iPlayer, iTech)
		
                if (gc.getGame().getGameTurn() > getTurnForYear(con.tBirth[iPlayer])):
                	vic.onTechAcquired(iPlayer, iTech)
                        cnm.onTechAcquired(argsList[2])

                if (gc.getPlayer(iPlayer).isAlive() and gc.getGame().getGameTurn() > getTurnForYear(con.tBirth[iPlayer]) and iPlayer < con.iNumPlayers):
                        self.rel.onTechAcquired(argsList[0], argsList[2])
                
                if (gc.getPlayer(iPlayer).isAlive() and gc.getGame().getGameTurn() > getTurnForYear(con.tBirth[iPlayer]) and iPlayer < con.iNumPlayers):
                        if (gc.getGame().getGameTurn() > getTurnForYear(1700)):
                                self.aiw.forgetMemory(argsList[0], argsList[2])

                if (argsList[0] == con.iAstronomy):
			if iPlayer in [con.iSpain, con.iFrance, con.iEngland, con.iGermany, con.iVikings, con.iNetherlands, con.iPortugal]:
				self.rnf.setAstronomyTurn(iPlayer, gc.getGame().getGameTurn())
				
                if (argsList[0] == con.iCompass):
                        if (iPlayer == con.iVikings):
                                gc.getMap().plot(49, 62).setTerrainType(con.iCoast, True, True)
				
                if (argsList[0] == con.iMedicine):
                        self.pla.onTechAcquired(argsList[0], argsList[2])

		if argsList[0] == con.iRailroad:
			self.rnf.onRailroadDiscovered(argsList[2])
			
		if iTech in [con.iAstronomy, con.iGunpowder]:
			teamPlayer = gc.getTeam(iPlayer)
			if teamPlayer.isHasTech(con.iAstronomy) and teamPlayer.isHasTech(con.iGunpowder):
				self.rnf.earlyTradingCompany(iPlayer)
			
		if iTech in [con.iEconomics, con.iRifling]:
			teamPlayer = gc.getTeam(iPlayer)
			if teamPlayer.isHasTech(con.iEconomics) and teamPlayer.isHasTech(con.iRifling):
				self.rnf.lateTradingCompany(iPlayer)
	
		if utils.getHumanID() != iPlayer:
			if iPlayer == con.iJapan and iEra == con.iIndustrial:
				utils.moveCapital(iPlayer, (116, 46)) # Toukyou
			elif iPlayer == con.iItaly and iEra == con.iIndustrial:
				utils.moveCapital(iPlayer, (60, 44)) # Roma
			elif iPlayer == con.iVikings and iEra == con.iRenaissance:
				utils.moveCapital(iPlayer, (63, 59)) # Stockholm
			elif iPlayer == con.iHolyRome and iEra == con.iRenaissance:
				utils.moveCapital(iPlayer, (62, 49)) # Wien
				
		# Spain's core extends when reaching the Renaissance and there are no Moors in Iberia
		# at the same time, the Moorish core relocates to Africa
		if iPlayer == con.iSpain and iEra == con.iRenaissance:
			bNoMoors = True
			if gc.getPlayer(con.iMoors).isAlive():
				for city in utils.getCityList(iMoors):
					if city.plot().getRegionID() == con.rIberia:
						bNoMoors = False
			if bNoMoors:
				gc.getPlayer(con.iSpain).setReborn(True)
				gc.getPlayer(con.iMoors).setReborn(True)
				
		# Italy's core extends when reaching the Industrial era
		if iPlayer == con.iItaly and iEra == con.iIndustrial:
			gc.getPlayer(con.iItaly).setReborn(True)
			
		# Arabia's core moves to Iraq when Philosophy is discovered
		if iPlayer == con.iArabia and iTech == con.iPhilosophy:
			gc.getPlayer(con.iArabia).setReborn(True)
			
		# Japan's core extends when reaching the Industrial era
		if iPlayer == con.iJapan and iEra == con.iIndustrial:
			gc.getPlayer(con.iJapan).setReborn(True)
			
		# Germany's core shrinks when reaching the Modern era
		if iPlayer == con.iGermany and iEra == con.iModern:
			gc.getPlayer(con.iGermany).setReborn(True)
示例#24
0
    def onReligionSpread(self, argsList):
        iReligion, iOwner, pSpreadCity = argsList

        cnm.onReligionSpread(iReligion, iOwner, pSpreadCity)
示例#25
0
    def onTechAcquired(self, argsList):
        iTech, iTeam, iPlayer, bAnnounce = argsList

        iHuman = utils.getHumanID()

        iEra = gc.getTechInfo(iTech).getEra()
        iGameTurn = gc.getGame().getGameTurn()

        if iGameTurn == utils.getScenarioStartTurn():
            return

        sta.onTechAcquired(iPlayer, iTech)
        AIParameters.onTechAcquired(iPlayer, iTech)

        if iGameTurn > getTurnForYear(tBirth[iPlayer]):
            vic.onTechAcquired(iPlayer, iTech)
            cnm.onTechAcquired(iPlayer)
            dc.onTechAcquired(iPlayer, iTech)

        if gc.getPlayer(iPlayer).isAlive() and iGameTurn > getTurnForYear(
                tBirth[iPlayer]) and iPlayer < iNumPlayers:
            self.rel.onTechAcquired(iTech, iPlayer)
            if iGameTurn > getTurnForYear(1700):
                self.aiw.forgetMemory(iTech, iPlayer)

        if iTech == iExploration:
            if iPlayer in [
                    iSpain, iFrance, iEngland, iGermany, iVikings,
                    iNetherlands, iPortugal
            ]:
                data.players[iPlayer].iExplorationTurn = iGameTurn

        elif iTech == iCompass:
            if iPlayer == iVikings:
                gc.getMap().plot(49, 62).setTerrainType(iCoast, True, True)

        elif iTech == iMicrobiology:
            self.pla.onTechAcquired(iTech, iPlayer)

        elif iTech == iRailroad:
            self.rnf.onRailroadDiscovered(iPlayer)

        if iTech in [iExploration, iFirearms]:
            teamPlayer = gc.getTeam(iPlayer)
            if teamPlayer.isHasTech(iExploration) and teamPlayer.isHasTech(
                    iFirearms):
                self.rnf.earlyTradingCompany(iPlayer)

        if iTech in [iEconomics, iReplaceableParts]:
            teamPlayer = gc.getTeam(iPlayer)
            if teamPlayer.isHasTech(iEconomics) and teamPlayer.isHasTech(
                    iReplaceableParts):
                self.rnf.lateTradingCompany(iPlayer)

        if utils.getHumanID() != iPlayer:
            if iPlayer == iJapan and iEra == iIndustrial:
                utils.moveCapital(iPlayer, (116, 47))  # Toukyou
            elif iPlayer == iItaly and iEra == iIndustrial:
                utils.moveCapital(iPlayer, (60, 44))  # Roma
            elif iPlayer == iVikings and iEra == iRenaissance:
                utils.moveCapital(iPlayer, (63, 59))  # Stockholm
            elif iPlayer == iHolyRome and iEra == iRenaissance:
                utils.moveCapital(iPlayer, (62, 49))  # Wien

        # Maya UP: +20 food when a tech is discovered before the medieval era
        if iPlayer == iMaya and not pMaya.isReborn() and iEra < iMedieval:
            if pMaya.getNumCities() > 0:
                iFood = 20 / pMaya.getNumCities()
                for city in utils.getCityList(iMaya):
                    city.changeFood(iFood)
                CyInterface().addMessage(
                    iPlayer, False, iDuration,
                    CyTranslator().getText(
                        "TXT_KEY_MAYA_UP_EFFECT",
                        (gc.getTechInfo(iTech).getText(), iFood)), "", 0, "",
                    ColorTypes(iWhite), -1, -1, True, True)

        # Spain's core extends when reaching the Renaissance and there are no Moors in Iberia
        # at the same time, the Moorish core relocates to Africa
        if iPlayer == iSpain and iEra == iRenaissance and not utils.isReborn(
                iSpain):
            bNoMoors = True
            if gc.getPlayer(iMoors).isAlive():
                for city in utils.getCityList(iMoors):
                    if city.plot().getRegionID() == rIberia:
                        bNoMoors = False
            if bNoMoors:
                utils.setReborn(iSpain, True)
                utils.setReborn(iMoors, True)

        # Italy's core extends when reaching the Industrial era
        if iPlayer == iItaly and iEra == iIndustrial:
            utils.setReborn(iItaly, True)

        # Japan's core extends when reaching the Industrial era
        if iPlayer == iJapan and iEra == iIndustrial:
            utils.setReborn(iJapan, True)

        # Germany's core shrinks when reaching the Digital era
        if iPlayer == iGermany and iEra == iDigital:
            utils.setReborn(iGermany, True)
示例#26
0
        def onCityBuilt(self, argsList):
                city = argsList[0]
                iOwner = city.getOwner()
                
                if iOwner < con.iNumActivePlayers: 
                        cnm.onCityBuilt(city)
			
		# starting workers
		if gc.getPlayer(iOwner).getNumCities() == 1:
			self.rnf.createStartingWorkers(iOwner, (city.getX(), city.getY()))

		#Rhye - delete culture of barbs and minor civs to prevent weird unhappiness
                pCurrent = gc.getMap().plot( city.getX(), city.getY() )
                for i in range(con.iNumTotalPlayers - con.iNumActivePlayers):
                        iMinorCiv = i + con.iNumActivePlayers
                        pCurrent.setCulture(iMinorCiv, 0, True)
                pCurrent.setCulture(con.iBarbarian, 0, True)

                if iOwner < iNumMajorPlayers:
                        utils.spreadMajorCulture(iOwner, city.getX(), city.getY())
			if gc.getPlayer(iOwner).getNumCities() < 2:
				gc.getPlayer(iOwner).AI_updateFoundValues(False); # fix for settler maps not updating after 1st city is founded

		if iOwner == con.iTurkey:
                        self.up.turkishUP(city, iOwner, -1)
			
		if iOwner == con.iCarthage:
			if city.getX() == 58 and city.getY() == 39:
				if not gc.getPlayer(con.iCarthage).isHuman():
					x = gc.getPlayer(con.iCarthage).getCapitalCity().getX()
					y = gc.getPlayer(con.iCarthage).getCapitalCity().getY()
					carthage = gc.getMap().plot(58,39).getPlotCity()
					carthage.setHasRealBuilding(con.iPalace, True)
					gc.getMap().plot(x,y).getPlotCity().setHasRealBuilding(con.iPalace, False)
					
					carthage.setPopulation(3)
					
					utils.makeUnitAI(con.iWorkboat, con.iCarthage, (58, 39), UnitAITypes.UNITAI_WORKER_SEA, 1)
					utils.makeUnitAI(con.iGalley, con.iCarthage, (57, 40), UnitAITypes.UNITAI_SETTLER_SEA, 1)
					utils.makeUnitAI(con.iSettler, con.iCarthage, (57, 40), UnitAITypes.UNITAI_SETTLE, 1)
					
				if not utils.isReborn(iOwner): gc.getPlayer(con.iCarthage).setReborn(True)
					
				self.dc.setCivAdjective(iOwner, "TXT_KEY_CIV_CARTHAGE_ADJECTIVE")
				self.dc.setCivShortDesc(iOwner, "TXT_KEY_CIV_CARTHAGE_SHORT_DESC")
				
		if iOwner == con.iByzantium and (city.getX(), city.getY()) == con.tCapitals[0][con.iByzantium] and gc.getGame().getGameTurn() <= getTurnForYear(330)+3:
			if city.getPopulation() < 5:
				city.setPopulation(5)
				
			city.setHasRealBuilding(con.iBarracks, True)
			city.setHasRealBuilding(con.iWalls, True)
			city.setHasRealBuilding(con.iLibrary, True)
			city.setHasRealBuilding(con.iMarket, True)
			city.setHasRealBuilding(con.iGranary, True)
			city.setHasRealBuilding(con.iHarbor, True)
			city.setHasRealBuilding(con.iForge, True)
			
			city.setHasRealBuilding(con.iJewishTemple + 4*gc.getPlayer(iOwner).getStateReligion(), True)
			
		if iOwner == con.iNetherlands and (city.getX(), city.getY()) == con.tCapitals[0][con.iNetherlands] and gc.getGame().getGameTurn() <= getTurnForYear(1580)+3:
			city.setPopulation(9)
			
			for iBuilding in [con.iLibrary, con.iBarracks, con.iGrocer, con.iBank, con.iColosseum, con.iTheatre, con.iJewishTemple+4*gc.getPlayer(con.iNetherlands).getStateReligion()]:
				city.setHasRealBuilding(iBuilding, True)
				
			gc.getPlayer(con.iNetherlands).AI_updateFoundValues(False)
			
		if iOwner == con.iItaly and (city.getX(), city.getY()) == con.tCapitals[0][con.iItaly] and gc.getGame().getGameTurn() <= getTurnForYear(con.tBirth[con.iItaly])+3:
			city.setPopulation(7)
			
			for iBuilding in [con.iLibrary, con.iGrocer, con.iTemple+4*gc.getPlayer(con.iItaly).getStateReligion(), con.iMarket, con.iItalianArtStudio, con.iAqueduct, con.iCourthouse, con.iWalls]:
				city.setHasRealBuilding(iBuilding, True)
				
			gc.getPlayer(con.iItaly).AI_updateFoundValues(False)

		vic.onCityBuilt(iOwner, city)
			
                if iOwner < con.iNumPlayers:
			self.dc.onCityBuilt(iOwner)

		if iOwner == con.iArabia:
			if not gc.getGame().isReligionFounded(con.iIslam):
				if (city.getX(), city.getY()) == (75, 33):
					self.rel.foundReligion((75, 33), con.iIslam)
				
		# Leoreth: free defender and worker for AI colonies
		if iOwner in con.lCivGroups[0]:
			if city.getRegionID() not in con.mercRegions[con.iArea_Europe]:
				if utils.getHumanID() != iOwner:
					x = city.getX()
					y = city.getY()
					utils.createGarrisons((x,y), iOwner, 1)
					utils.makeUnit(con.iWorker, iOwner, (x,y), 1)
					
		# Holy Rome founds its capital
		if iOwner == con.iHolyRome:
			if gc.getPlayer(con.iHolyRome).getNumCities() == 1:
				self.rnf.holyRomanSpawn()
	def selectClaims(self, iPlayer):
		pPlayer = gc.getPlayer(iPlayer)
		iGameTurn = gc.getGame().getGameTurn()
		iNumPlayersAlive = gc.getGame().countCivPlayersAlive()
		lPlots = []
		
		for iLoopPlayer in range(iNumTotalPlayers+1):
			if iLoopPlayer == iPlayer: continue
			if not gc.getPlayer(iLoopPlayer).isAlive(): continue
			
			# after a war: winners can only claim from losers and vice versa
			if self.bPostWar:
				if iPlayer in self.lWinners and iLoopPlayer not in self.lLosers: continue
				if iPlayer in self.lLosers and iLoopPlayer not in self.lWinners: continue
				
			# AI civs: cannot claim cities from friends
			if utils.getHumanID() != iPlayer and pPlayer.AI_getAttitude(iLoopPlayer) >= AttitudeTypes.ATTITUDE_FRIENDLY: continue
			
			# recently born
			if iGameTurn < getTurnForYear(tBirth[iLoopPlayer]) + utils.getTurns(20): continue
			
			# recently resurrected
			if iGameTurn < pPlayer.getLatestRebellionTurn() + utils.getTurns(20): continue
			
			# recently reborn
			if utils.isReborn(iLoopPlayer) and tRebirth != -1 and iGameTurn < getTurnForYear(tRebirth[iLoopPlayer]) + utils.getTurns(20): continue
			
			# exclude master/vassal relationships
			if gc.getTeam(iPlayer).isVassal(iLoopPlayer): continue
			if gc.getTeam(iLoopPlayer).isVassal(iPlayer): continue
			
			# cannot demand cities while at war
			if gc.getTeam(iPlayer).isAtWar(iLoopPlayer): continue
			
			for city in utils.getCityList(iLoopPlayer):
				x, y = city.getX(), city.getY()
				plot = gc.getMap().plot(x, y)
				iSettlerMapValue = plot.getSettlerValue(iPlayer)
				iValue = 0
				
				if not plot.isRevealed(iPlayer, False): continue
				if city.isCapital(): continue
				
				# after a war: losers can only claim previously owned cities
				if self.bPostWar and iPlayer in self.lLosers:
					if city.getGameTurnPlayerLost(iPlayer) < gc.getGame().getGameTurn() - utils.getTurns(25): continue
				
				# city culture
				iTotalCulture = city.countTotalCultureTimes100()
				if iTotalCulture > 0:
					iCultureRatio = city.getCultureTimes100(iPlayer) * 100 / iTotalCulture
					if iCultureRatio > 20:
						if iLoopPlayer != iAmerica:
							iValue += iCultureRatio / 20
							
				# ever owned
				if city.isEverOwned(iPlayer):
					iValue += 3
						
				# own core
				if plot.isCore(iPlayer):
					iValue += 5
							
				# colonies
				if iPlayer in lCivGroups[0]:
					if iLoopPlayer >= iNumPlayers or (iLoopPlayer not in lCivGroups[0] and utils.getStabilityLevel(iLoopPlayer) < iStabilityShaky) or (iLoopPlayer in lCivGroups[0] and utils.getHumanID() != iLoopPlayer and pPlayer.AI_getAttitude(iLoopPlayer) < AttitudeTypes.ATTITUDE_PLEASED):
						if plot.getRegionID() not in lEurope and plot.getRegionID() not in lMiddleEast:
							if iSettlerMapValue > 90:
								iValue += max(1, iSettlerMapValue / 100)
									
				# weaker and collapsing empires
				if iLoopPlayer < iNumPlayers:
					if gc.getGame().getPlayerRank(iLoopPlayer) > iNumPlayersAlive / 2 and gc.getGame().getPlayerRank(iLoopPlayer) < iNumPlayersAlive / 2:
						if data.players[iLoopPlayer].iStabilityLevel == iStabilityCollapsing:
							if iSettlerMapValue >= 90:
								iValue += max(1, iSettlerMapValue / 100)
									
				# close to own empire
				closestCity = gc.getMap().findCity(x, y, iPlayer, TeamTypes.NO_TEAM, False, False, TeamTypes.NO_TEAM, DirectionTypes.NO_DIRECTION, city)
				iDistance = stepDistance(x, y, closestCity.getX(), closestCity.getY())
				if iDistance < 5:
					iValue += 5-iDistance
					
				# after war: war targets
				if self.bPostWar:
					iValue += plot.getWarValue(iPlayer) / 2
					
				# AI America receives extra value for claims in the west
				if iPlayer == iAmerica and utils.getHumanID() != iPlayer:
					if utils.isPlotInArea((x, y), tAmericanClaimsTL, tAmericanClaimsBR):
						iValue += 5
						
				# help Canada gain Labrador and Newfoundland
				if iPlayer == iCanada:
					if utils.isPlotInArea((x, y), tNewfoundlandTL, tNewfoundlandBR):
						iValue += 5
					
				if iValue > 0:
					lPlots.append((x, y, iValue))
		
		# extra spots for colonial civs -> will be settled
		# not available after wars because these congresses are supposed to reassign cities
		if iPlayer in lCivGroups[0] and not self.bPostWar:
			for (x, y) in utils.getWorldPlotsList():
				if utils.getHumanID() == iPlayer and not plot.isRevealed(iPlayer, False): continue
				plot = gc.getMap().plot(x, y)
				if not plot.isCity() and not plot.isPeak() and not plot.isWater() and pPlayer.canFound(x, y):
					if plot.getRegionID() in [rWestAfrica, rSouthAfrica, rEthiopia, rAustralia, rOceania]:
						iSettlerMapValue = plot.getSettlerValue(iPlayer)
						if iSettlerMapValue >= 90 and cnm.getFoundName(iPlayer, (x, y)):
							closestCity = gc.getMap().findCity(x, y, PlayerTypes.NO_PLAYER, TeamTypes.NO_TEAM, False, False, TeamTypes.NO_TEAM, DirectionTypes.NO_DIRECTION, CyCity())
							if stepDistance(x, y, closestCity.getX(), closestCity.getY()) > 2:
								lPlots.append((x, y, max(1, iSettlerMapValue / 100 - 1)))
						
		lPlots = utils.getSortedList(lPlots, lambda x: x[2] + gc.getGame().getSorenRandNum(3, 'Randomize city value'), True)
		return lPlots[:10]
示例#28
0
    def onCityAcquired(self, argsList):
        iOwner, iPlayer, city, bConquest, bTrade = argsList
        tCity = (city.getX(), city.getY())

        cnm.onCityAcquired(city, iPlayer)

        if bConquest:
            sta.onCityAcquired(city, iOwner, iPlayer)

        if iPlayer == iArabia:
            self.up.arabianUP(city)
        # elif iPlayer == iMughals and utils.getHumanID() != iMughals:
        # self.up.mughalUP(city)
        # elif iPlayer == iSeljuks:
        # self.up.seljukUP(city)

        if iPlayer == iMongolia and bConquest and utils.getHumanID(
        ) != iPlayer:
            self.up.mongolUP(city)

        if iPlayer < iNumMajorPlayers:
            utils.spreadMajorCulture(iPlayer, tCity)

        # relocate capitals
        if utils.getHumanID() != iPlayer:
            if iPlayer == iTurkey and tCity == (68, 45):
                utils.moveCapital(iTurkey, tCity)  # Kostantiniyye
            elif iPlayer == iMongolia and tCity == (102, 47):
                utils.moveCapital(iMongolia, tCity)  # Khanbaliq

        # remove slaves if unable to practice slavery
        if not gc.getPlayer(iPlayer).isColonialSlavery():
            utils.removeSlaves(city)
        else:
            utils.freeSlaves(city, iPlayer)

        if city.isCapital():
            if city.isHasRealBuilding(iAdministrativeCenter):
                city.setHasRealBuilding(iAdministrativeCenter, False)

        # kill Seljuks
        #if iOwner == iSeljuks and gc.getPlayer(iSeljuks).isAlive() and gc.getGame().getGameTurnYear() >= 1250:
        #	if city.isCapital() or gc.getPlayer(iSeljuks).getNumCities() <= 2:
        #		sta.completeCollapse(iSeljuks)
        #utils.killAndFragmentCiv(iSeljuks, iIndependent, iIndependent2, -1, False)

        # Leoreth: relocate capital for AI if reacquired:
        if utils.getHumanID() != iPlayer and iPlayer < iNumPlayers:
            if data.players[iPlayer].iResurrections == 0:
                if Areas.getCapital(iPlayer) == tCity:
                    utils.relocateCapital(iPlayer, city)
            else:
                if Areas.getRespawnCapital(iPlayer) == tCity:
                    utils.relocateCapital(iPlayer, city)

        # Leoreth: conquering Constantinople adds it to the Turkish core + Rumelia
        if iPlayer == iTurkey and tCity == (68, 45):
            utils.setReborn(iTurkey, True)

        # Leoreth: help Byzantium/Constantinople
        if iPlayer == iByzantium and tCity == Areas.getCapital(
                iByzantium
        ) and gc.getGame().getGameTurn() <= getTurnForYear(330) + 3:
            if city.getPopulation() < 5:
                city.setPopulation(5)

            city.setHasRealBuilding(iBarracks, True)
            city.setHasRealBuilding(iWalls, True)
            city.setHasRealBuilding(iLibrary, True)
            city.setHasRealBuilding(iMarket, True)
            city.setHasRealBuilding(iGranary, True)
            city.setHasRealBuilding(iHarbor, True)
            city.setHasRealBuilding(iForge, True)

            city.setName("Konstantinoupolis", False)

            city.setHasRealBuilding(
                iTemple + 4 * gc.getPlayer(iPlayer).getStateReligion(), True)

        if bConquest:

            # Colombian UP: no resistance in conquered cities in Latin America
            if iPlayer == iMaya and utils.isReborn(iMaya):
                if utils.isPlotInArea(tCity, tSouthCentralAmericaTL,
                                      tSouthCentralAmericaBR):
                    city.setOccupationTimer(0)

            # Statue of Zeus effect: no city resistance on conquest
            if gc.getPlayer(iPlayer).isHasBuildingEffect(iStatueOfZeus):
                city.setOccupationTimer(0)

            # Byzantium reduced to four cities: core shrinks to Constantinople
            if iOwner == iByzantium and gc.getPlayer(
                    iByzantium).getNumCities <= 4:
                utils.setReborn(iByzantium, True)

        if bTrade:
            for i in range(iNumBuildings):
                iNationalWonder = i
                if isNationalWonderClass(
                        gc.getBuildingInfo(iNationalWonder).
                        getBuildingClassType()) and city.hasBuilding(
                            iNationalWonder):
                    city.setHasRealBuilding(iNationalWonder, False)

        self.pla.onCityAcquired(iOwner, iPlayer, city)  # Plague
        self.com.onCityAcquired(city)  # Communications
        self.corp.onCityAcquired(argsList)  # Companies
        dc.onCityAcquired(iOwner, iPlayer)  # DynamicCivs

        vic.onCityAcquired(iPlayer, iOwner, city, bConquest)

        return 0
	def selectClaims(self, iPlayer):
		pPlayer = gc.getPlayer(iPlayer)
		iGameTurn = gc.getGame().getGameTurn()
		iNumPlayersAlive = gc.getGame().countCivPlayersAlive()
		lPlots = []
		
		for iLoopPlayer in range(iNumTotalPlayers+1):
			if iLoopPlayer == iPlayer: continue
			if not gc.getPlayer(iLoopPlayer).isAlive(): continue
			
			# after a war: winners can only claim from losers and vice versa
			if self.bPostWar:
				if iPlayer in self.lWinners and iLoopPlayer not in self.lLosers: continue
				if iPlayer in self.lLosers and iLoopPlayer not in self.lWinners: continue
				
			# AI civs: cannot claim cities from friends
			if utils.getHumanID() != iPlayer and pPlayer.AI_getAttitude(iLoopPlayer) >= AttitudeTypes.ATTITUDE_FRIENDLY: continue
			
			# recently born
			if iGameTurn < getTurnForYear(tBirth[iLoopPlayer]) + utils.getTurns(20): continue
			
			# recently resurrected
			if iGameTurn < pPlayer.getLatestRebellionTurn() + utils.getTurns(20): continue
			
			# recently reborn
			if utils.isReborn(iLoopPlayer) and tRebirth != -1 and iGameTurn < getTurnForYear(tRebirth[iLoopPlayer]) + utils.getTurns(20): continue
			
			# exclude master/vassal relationships
			if gc.getTeam(iPlayer).isVassal(iLoopPlayer): continue
			if gc.getTeam(iLoopPlayer).isVassal(iPlayer): continue
			
			# cannot demand cities while at war
			if gc.getTeam(iPlayer).isAtWar(iLoopPlayer): continue
			
			for city in utils.getCityList(iLoopPlayer):
				x, y = city.getX(), city.getY()
				plot = gc.getMap().plot(x, y)
				iSettlerMapValue = plot.getSettlerValue(iPlayer)
				iValue = 0
				
				if not plot.isRevealed(iPlayer, False): continue
				if city.isCapital(): continue
				
				# after a war: losers can only claim previously owned cities
				if self.bPostWar and iPlayer in self.lLosers:
					if city.getGameTurnPlayerLost(iPlayer) < gc.getGame().getGameTurn() - utils.getTurns(25): continue
				
				# city culture
				iTotalCulture = city.countTotalCultureTimes100()
				if iTotalCulture > 0:
					iCultureRatio = city.getCultureTimes100(iPlayer) * 100 / iTotalCulture
					if iCultureRatio > 20:
						if iLoopPlayer != iAmerica:
							iValue += iCultureRatio / 20
							
				# ever owned
				if city.isEverOwned(iPlayer):
					iValue += 3
						
				# own core
				if plot.isCore(iPlayer):
					iValue += 5
							
				# colonies
				if iPlayer in lCivGroups[0]:
					if iLoopPlayer >= iNumPlayers or (iLoopPlayer not in lCivGroups[0] and utils.getStabilityLevel(iLoopPlayer) < iStabilityShaky) or (iLoopPlayer in lCivGroups[0] and utils.getHumanID() != iLoopPlayer and pPlayer.AI_getAttitude(iLoopPlayer) < AttitudeTypes.ATTITUDE_PLEASED):
						if plot.getRegionID() not in lEurope and plot.getRegionID() not in lMiddleEast:
							if iSettlerMapValue > 90:
								iValue += max(1, iSettlerMapValue / 100)
									
				# weaker and collapsing empires
				if iLoopPlayer < iNumPlayers:
					if gc.getGame().getPlayerRank(iLoopPlayer) > iNumPlayersAlive / 2 and gc.getGame().getPlayerRank(iLoopPlayer) < iNumPlayersAlive / 2:
						if data.players[iLoopPlayer].iStabilityLevel == iStabilityCollapsing:
							if iSettlerMapValue >= 90:
								iValue += max(1, iSettlerMapValue / 100)
									
				# close to own empire
				closestCity = gc.getMap().findCity(x, y, iPlayer, TeamTypes.NO_TEAM, False, False, TeamTypes.NO_TEAM, DirectionTypes.NO_DIRECTION, city)
				iDistance = stepDistance(x, y, closestCity.getX(), closestCity.getY())
				if iDistance < 5:
					iValue += 5-iDistance
					
				# after war: war targets
				if self.bPostWar:
					iValue += plot.getWarValue(iPlayer) / 2
					
				# AI America receives extra value for claims in the west
				if iPlayer == iAmerica and utils.getHumanID() != iPlayer:
					if utils.isPlotInArea((x, y), tAmericanClaimsTL, tAmericanClaimsBR):
						iValue += 5
						
				# help AI Australia gain Australia
				if iPlayer == iAustralia and utils.getHumanID() != iPlayer:
					if utils.isPlotInArea((x, y), tAustraliaTL, tAustraliaBR):
						iValue += 5
						
				# help Canada gain Labrador and Newfoundland
				if iPlayer == iCanada:
					if utils.isPlotInArea((x, y), tNewfoundlandTL, tNewfoundlandBR):
						iValue += 5
					
				if iValue > 0:
					lPlots.append((x, y, iValue))
		
		# extra spots for colonial civs -> will be settled
		# not available after wars because these congresses are supposed to reassign cities
		if iPlayer in lCivGroups[0] and not self.bPostWar:
			for (x, y) in utils.getWorldPlotsList():
				if utils.getHumanID() == iPlayer and not plot.isRevealed(iPlayer, False): continue
				plot = gc.getMap().plot(x, y)
				if not plot.isCity() and not plot.isPeak() and not plot.isWater() and pPlayer.canFound(x, y):
					if plot.getRegionID() in [rWestAfrica, rSouthAfrica, rEthiopia] or (plot.getRegionID() == [rAustralia, rOceania] and gc.getGame().getGameTurn() < tBirth[iAustralia]) or (plot.getRegionID() == rSouthAfrica and gc.getGame().getGameTurn() < tBirth[iBoers]):
						iSettlerMapValue = plot.getSettlerValue(iPlayer)
						if iSettlerMapValue >= 90 and cnm.getFoundName(iPlayer, (x, y)):
							closestCity = gc.getMap().findCity(x, y, PlayerTypes.NO_PLAYER, TeamTypes.NO_TEAM, False, False, TeamTypes.NO_TEAM, DirectionTypes.NO_DIRECTION, CyCity())
							if stepDistance(x, y, closestCity.getX(), closestCity.getY()) > 2:
								lPlots.append((x, y, max(1, iSettlerMapValue / 100 - 1)))
						
		lPlots = utils.getSortedList(lPlots, lambda x: x[2] + gc.getGame().getSorenRandNum(3, 'Randomize city value'), True)
		return lPlots[:10]
	def onReligionSpread(self, argsList):
		iReligion, iOwner, pSpreadCity = argsList
		
		cnm.onReligionSpread(iReligion, iOwner, pSpreadCity)