def aztecUP(self, argsList): #Real Slavery by Sevo
		if not pAztecs.isAlive(): return
		if utils.isReborn(iAztecs): return
		
		pWinningUnit, pLosingUnit = argsList
		
		iWinningPlayer = pWinningUnit.getOwner()
		pWinningPlayer = gc.getPlayer(iWinningPlayer)
		
		iLosingPlayer = pLosingUnit.getOwner()
		iLosingUnit = pLosingUnit.getUnitType()
		
		if iWinningPlayer != iAztecs:
			return
			

		# Only enslave land units!!
		if pLosingUnit.isAnimal() or not (pLosingUnit.getDomainType() == DomainTypes.DOMAIN_LAND and gc.getUnitInfo(iLosingUnit).getCombat() > 0):
			return
		
		iRandom = gc.getGame().getSorenRandNum(100, 'capture chance')
		if iRandom < 35:
			pNewUnit = pWinningPlayer.initUnit(iAztecSlave, pWinningUnit.getX(), pWinningUnit.getY(), UnitAITypes.UNITAI_ENGINEER, DirectionTypes.DIRECTION_SOUTH)
			CyInterface().addMessage(iWinningPlayer, True, 15, CyTranslator().getText("TXT_KEY_UP_ENSLAVE_WIN", ()), 'SND_REVOLTEND', 1, 'Art/Units/slave/button_slave.dds', ColorTypes(8), pWinningUnit.getX(), pWinningUnit.getY(), True, True)
			CyInterface().addMessage(iLosingPlayer, True, 15, CyTranslator().getText("TXT_KEY_UP_ENSLAVE_LOSE", ()), 'SND_REVOLTEND', 1, 'Art/Units/slave/button_slave.dds', ColorTypes(7), pWinningUnit.getX(), pWinningUnit.getY(), True, True)
			if pLosingUnit.getOwner() not in lCivGroups[5] and pLosingUnit.getOwner() < iNumPlayers: # old world civs now
				data.iAztecSlaves += 1
	def aztecUP(self, argsList): #Real Slavery by Sevo
		if not pAztecs.isAlive(): return
		if utils.isReborn(iAztecs): return
		
		pWinningUnit, pLosingUnit = argsList
		
		iWinningPlayer = pWinningUnit.getOwner()
		pWinningPlayer = gc.getPlayer(iWinningPlayer)
		
		iLosingPlayer = pLosingUnit.getOwner()
		iLosingUnit = pLosingUnit.getUnitType()
		
		if iWinningPlayer != iAztecs:
			return
			

		# Only enslave land units!!
		if pLosingUnit.isAnimal() or not (pLosingUnit.getDomainType() == DomainTypes.DOMAIN_LAND and gc.getUnitInfo(iLosingUnit).getCombat() > 0):
			return
		
		iRandom = gc.getGame().getSorenRandNum(100, 'capture chance')
		if iRandom < 35:
			pNewUnit = pWinningPlayer.initUnit(iAztecSlave, pWinningUnit.getX(), pWinningUnit.getY(), UnitAITypes.UNITAI_ENGINEER, DirectionTypes.DIRECTION_SOUTH)
			CyInterface().addMessage(iWinningPlayer, True, 15, CyTranslator().getText("TXT_KEY_UP_ENSLAVE_WIN", ()), 'SND_REVOLTEND', 1, 'Art/Units/slave/button_slave.dds', ColorTypes(8), pWinningUnit.getX(), pWinningUnit.getY(), True, True)
			CyInterface().addMessage(iLosingPlayer, True, 15, CyTranslator().getText("TXT_KEY_UP_ENSLAVE_LOSE", ()), 'SND_REVOLTEND', 1, 'Art/Units/slave/button_slave.dds', ColorTypes(7), pWinningUnit.getX(), pWinningUnit.getY(), True, True)
			if pLosingUnit.getOwner() not in lCivGroups[5] and pLosingUnit.getOwner() < iNumPlayers: # old world civs now
				data.iAztecSlaves += 1
示例#3
0
def exportCore(iPlayer, bForce=False):
    iCiv = gc.getPlayer(iPlayer).getCivilizationType()
    sName = gc.getCivilizationInfo(iCiv).getShortDescription(0)
    if iPlayer == iHolyRome:
        sName = "HolyRome"
    elif iPlayer == iAztecs:
        sName = "Aztecs"

    lCorePlotList = Areas.getCoreArea(iPlayer)
    bCoreChanged = bForce
    if not bCoreChanged:
        for (x, y) in utils.getWorldPlotsList():
            bOldCore = (x, y) in lCorePlotList
            if gc.getMap().plot(x, y).isCore(iPlayer) != bOldCore:
                bCoreChanged = True
                break
    if bCoreChanged:
        lCorePlots = [(x, y) for (x, y) in utils.getWorldPlotsList()
                      if gc.getMap().plot(x, y).isCore(iPlayer)]
        BL, TR = getTLBR(lCorePlots)

        lExceptions = []
        for (x, y) in utils.getPlotList(BL, TR):
            plot = gc.getMap().plot(x, y)
            if not plot.isCore(iPlayer) and not (
                    plot.isWater() or (plot.isPeak() and
                                       (x, y) not in Areas.lPeakExceptions)):
                lExceptions.append((x, y))

        file = open(IMAGE_LOCATION + "\Cores\\" + sName + ".txt", 'wt')
        try:
            if not utils.isReborn(iPlayer):
                file.write("# tCoreArea\n")
                file.write("(" + str(BL) + ",\t" + str(TR) + "),\t# " + sName)
                if lExceptions:
                    file.write("\n\n# dCoreAreaExceptions\n")
                    file.write("i" + sName + " : " + str(lExceptions) + ",")
            else:
                file.write("# dChangedCoreArea\n")
                file.write("i" + sName + " : "
                           "(" + str(BL) + ",\t" + str(TR) + "),")
                if lExceptions:
                    file.write("\n\n# dChangedCoreAreaExceptions\n")
                    file.write("i" + sName + " : " + str(lExceptions) + ",")
        finally:
            file.close()
        sText = "Core map of %s exported" % sName
    else:
        sText = "No changes between current core and core defined in python"
    popup = PyPopup.PyPopup()
    popup.setBodyString(sText)
    popup.launch(True, PopupStates.POPUPSTATE_IMMEDIATE)
示例#4
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
示例#5
0
    def doImmigration(self):

        # get available migration and immigration cities
        lSourceCities = []
        lTargetCities = []

        for iPlayer in range(iNumPlayers):
            if iPlayer in lCivBioNewWorld and not utils.isReborn(iPlayer):
                continue  # no immigration to natives
            pPlayer = gc.getPlayer(iPlayer)
            lCities = []
            bNewWorld = pPlayer.getCapitalCity().getRegionID() in lNewWorld
            for city in utils.getCityList(iPlayer):
                iFoodDifference = city.foodDifference(False)
                iHappinessDifference = city.happyLevel() - city.unhappyLevel(0)
                if city.getRegionID() in lNewWorld and bNewWorld:
                    if iFoodDifference <= 0 or iHappinessDifference <= 0:
                        continue
                    iNorthAmericaBonus = 0
                    if city.getRegionID() in [rCanada, rUnitedStates]:
                        iNorthAmericaBonus = 5
                    lCities.append(
                        (city, iHappinessDifference + iFoodDifference / 2 +
                         city.getPopulation() / 2 + iNorthAmericaBonus))
                elif city.getRegionID() not in lNewWorld and not bNewWorld:
                    iValue = 0
                    if iFoodDifference < 0:
                        iValue -= iFoodDifference / 2
                    if iHappinessDifference < 0:
                        iValue -= iHappinessDifference
                    if iValue > 0:
                        lCities.append((city, iValue))

            if lCities:
                lCities.sort(key=itemgetter(1), reverse=True)

                if bNewWorld:
                    lTargetCities.append(lCities[0])
                else:
                    lSourceCities.append(lCities[0])

        # sort highest to lowest for happiness/unhappiness
        lSourceCities.sort(key=itemgetter(1), reverse=True)
        lTargetCities.sort(key=itemgetter(1), reverse=True)

        #utils.debugTextPopup(str([(x.getName(), y) for (x,y) in lTargetCities]))
        #utils.debugTextPopup("Target city: "+targetCity.getName())
        #utils.debugTextPopup("Source city: "+sourceCity.getName())

        iNumMigrations = min(len(lSourceCities) / 4, len(lTargetCities))

        for iMigration in range(iNumMigrations):
            sourceCity = lSourceCities[iMigration][0]
            targetCity = lTargetCities[iMigration][0]

            sourceCity.changePopulation(-1)
            targetCity.changePopulation(1)

            if sourceCity.getPopulation() >= 9:
                sourceCity.changePopulation(-1)
                targetCity.changePopulation(1)

            # extra cottage growth for target city's vicinity
            x = targetCity.getX()
            y = targetCity.getY()
            for (i, j) in utils.surroundingPlots((x, y), 2):
                pCurrent = gc.getMap().plot(i, j)
                if pCurrent.getWorkingCity() == targetCity:
                    pCurrent.changeUpgradeProgress(utils.getTurns(10))

            # migration brings culture
            targetPlot = gc.getMap().plot(x, y)
            iTargetPlayer = targetCity.getOwner()
            iSourcePlayer = sourceCity.getOwner()
            iCultureChange = targetPlot.getCulture(
                iTargetPlayer) / targetCity.getPopulation()
            targetPlot.changeCulture(iSourcePlayer, iCultureChange, False)

            # chance to spread state religion if in source city
            if gc.getPlayer(iSourcePlayer).isStateReligion():
                iReligion = gc.getPlayer(iSourcePlayer).getStateReligion()
                if sourceCity.isHasReligion(
                        iReligion) and not targetCity.isHasReligion(iReligion):
                    iRandom = gc.getGame().getSorenRandNum(
                        3, 'random religion spread')
                    if iRandom == 0:
                        targetCity.setHasReligion(iReligion, True, True, True)

            # notify affected players
            if utils.getHumanID() == iSourcePlayer:
                CyInterface().addMessage(
                    iSourcePlayer, False, iDuration,
                    CyTranslator().getText("TXT_KEY_UP_EMIGRATION",
                                           (sourceCity.getName(), )), "",
                    InterfaceMessageTypes.MESSAGE_TYPE_MINOR_EVENT,
                    gc.getUnitInfo(iSettler).getButton(), ColorTypes(iYellow),
                    sourceCity.getX(), sourceCity.getY(), True, True)
            elif utils.getHumanID() == iTargetPlayer:
                CyInterface().addMessage(
                    iTargetPlayer, False, iDuration,
                    CyTranslator().getText("TXT_KEY_UP_IMMIGRATION",
                                           (targetCity.getName(), )), "",
                    InterfaceMessageTypes.MESSAGE_TYPE_MINOR_EVENT,
                    gc.getUnitInfo(iSettler).getButton(), ColorTypes(iYellow),
                    x, y, True, True)

            if iTargetPlayer == iCanada:
                self.canadianUP(targetCity)
def getUHVTileInfo(argsList):
    x = argsList[0]
    y = argsList[1]
    iPlayer = argsList[2]

    if iPlayer == iGreece:
        if (x, y) in Areas.getNormalArea(iEgypt, False):
            return 0

        if (x, y) in Areas.getNormalArea(iCarthage, False):
            return 1

        if (x, y) in Areas.getNormalArea(iBabylonia, False):
            return 2

        if (x, y) in Areas.getNormalArea(iPersia, False):
            return 3

    elif iPlayer == iPersia and CyGlobalContext().getPlayer(
            iPersia).isReborn():
        if utils.isPlotInArea((x, y), vic.tSafavidMesopotamiaTL,
                              vic.tSafavidMesopotamiaBR):
            return 4

        if utils.isPlotInArea((x, y), vic.tTransoxaniaTL, vic.tTransoxaniaBR):
            return 5

        if utils.isPlotInArea((x, y), vic.tNWIndiaTL, vic.tNWIndiaBR,
                              vic.tNWIndiaExceptions):
            return 6

    elif iPlayer == iCarthage:
        if utils.isPlotInArea((x, y), Areas.tNormalArea[iItaly][0],
                              Areas.tNormalArea[iItaly][1],
                              [(62, 47), (63, 47), (63, 46)]):
            return 37

        if (x, y) in Areas.getNormalArea(iSpain, False):
            return 8

    elif iPlayer == iItaly:
        if utils.isPlotInArea(
            (x, y), vic.tMediterraneanTL, vic.tMediterraneanBR, vic.
                tMediterraneanExceptions) and CyGlobalContext().getMap().plot(
                    x, y).isCoastalLand():
            return 7

    elif iPlayer == iRome:
        if (x, y) in Areas.getNormalArea(iSpain, False):
            return 8

        if utils.isPlotInArea((x, y), vic.tFranceTL,
                              Areas.tNormalArea[iFrance][1]):
            return 9

        if (x, y) in Areas.getCoreArea(iEngland, False):
            return 10

        if utils.isPlotInArea((x, y), vic.tCarthageTL, vic.tCarthageBR):
            return 11

        if (x, y) in Areas.getCoreArea(iByzantium, False):
            return 12

        if (x, y) in Areas.getCoreArea(iEgypt, False):
            return 13

    elif iPlayer == iJapan:
        if utils.isPlotInArea((x, y), vic.tKoreaTL, vic.tKoreaBR):
            return 14

        if utils.isPlotInArea((x, y), vic.tManchuriaTL, vic.tManchuriaBR):
            return 15

        if utils.isPlotInArea((x, y), vic.tChinaTL, vic.tChinaBR):
            return 16

        if utils.isPlotInArea((x, y), vic.tIndochinaTL, vic.tIndochinaBR,
                              vic.tIndochinaExceptions):
            return 17

        if utils.isPlotInArea((x, y), vic.tIndonesiaTL, vic.tIndonesiaBR):
            return 18

        if utils.isPlotInArea((x, y), vic.tPhilippinesTL, vic.tPhilippinesBR):
            return 19

    elif iPlayer == iEthiopia:
        if gc.getMap().plot(x, y).getRegionID() in lAfrica:
            return 33

    elif iPlayer == iByzantium:
        if utils.isPlotInArea((x, y), vic.tBalkansTL, vic.tBalkansBR):
            return 21

        if utils.isPlotInArea((x, y), vic.tNorthAfricaTL, vic.tNorthAfricaBR):
            return 22

        if utils.isPlotInArea((x, y), vic.tNearEastTL, vic.tNearEastBR):
            return 23

    elif iPlayer == iArabia:
        if (x, y) in Areas.getCoreArea(iEgypt, False):
            return 24

        if utils.isPlotInArea((x, y), vic.tCarthageTL, vic.tCarthageBR):
            return 25

        if (x, y) in Areas.getCoreArea(iBabylonia, False):
            return 26

        if (x, y) in Areas.getCoreArea(iPersia, False):
            return 27

        if (x, y) in Areas.getNormalArea(iSpain, False):
            return 28

    elif iPlayer == iSpain:
        if utils.isPlotInArea((x, y), vic.tEuropeTL, vic.tEuropeBR): return 29
        elif utils.isPlotInArea((x, y), vic.tEasternEuropeTL,
                                vic.tEasternEuropeBR):
            return 29

    elif iPlayer == iFrance:
        if utils.isPlotInArea((x, y), vic.tEuropeTL, vic.tEuropeBR): return 29
        elif utils.isPlotInArea((x, y), vic.tEasternEuropeTL,
                                vic.tEasternEuropeBR):
            return 29

        if utils.isPlotInArea((x, y), vic.tNorthAmericaTL,
                              vic.tNorthAmericaBR):
            return 30

    elif iPlayer == iEngland:
        if utils.isPlotInArea((x, y), vic.tNorthAmericaTL,
                              vic.tNorthAmericaBR):
            return 31

        if utils.isPlotInArea((x, y), vic.tSouthCentralAmericaTL,
                              vic.tSouthCentralAmericaBR):
            return 32

        if utils.isPlotInArea((x, y), vic.tAfricaTL, vic.tAfricaBR):
            return 33

        if utils.isPlotInArea((x, y), vic.tAsiaTL, vic.tAsiaBR):
            return 34

        if utils.isPlotInArea((x, y), vic.tOceaniaTL, vic.tOceaniaBR):
            return 35

    elif iPlayer == iGermany:
        if (x, y) in Areas.getNormalArea(iFrance, False):
            return 36

        if (x, y) in Areas.getNormalArea(iItaly, False):
            return 37

        if (x, y) in Areas.getNormalArea(iRussia, False):
            return 38

        if (x, y) in Areas.getNormalArea(iEngland, False):
            return 39

        if (x, y) in Areas.getNormalArea(iVikings, False):
            return 40

    elif iPlayer == iRussia:
        if utils.isPlotInArea((x, y), vic.tSiberiaTL, vic.tSiberiaBR):
            return 41

    elif iPlayer == iInca:
        if (x, y) in vic.lAndeanCoast:
            return 42

        if utils.isPlotInArea((x, y), vic.tSAmericaTL, vic.tSAmericaBR,
                              vic.tSouthAmericaExceptions):
            return 43

    elif iPlayer == iOttomans:
        if (x, y) in vic.lEasternMediterranean:
            return 47

        if (x, y) in vic.lBlackSea:
            return 48

        if (x, y) in utils.surroundingPlots(vic.tCairo):
            return 49

        if (x, y) in utils.surroundingPlots(vic.tMecca):
            return 50

        if (x, y) in utils.surroundingPlots(vic.tBaghdad):
            return 51

        if (x, y) in utils.surroundingPlots(vic.tVienna):
            return 52

    elif iPlayer == iThailand:
        if utils.isPlotInArea((x, y), vic.tSouthAsiaTL, vic.tSouthAsiaBR):
            return 53

    elif iPlayer == iAmerica:
        if utils.isPlotInArea((x, y), vic.tNCAmericaTL, vic.tNCAmericaBR):
            return 54

    elif iPlayer == iTamils:
        if utils.isPlotInArea((x, y), vic.tDeccanTL, vic.tDeccanBR):
            return 55

        if utils.isPlotInArea((x, y), vic.tSrivijayaTL, vic.tSrivijayaBR):
            return 56

    elif iPlayer == iMoors:
        if utils.isPlotInArea((x, y), vic.tIberiaTL, vic.tIberiaBR):
            return 57

        if utils.isPlotInArea((x, y), vic.tMaghrebTL, vic.tMaghrebBR):
            return 58

        if utils.isPlotInArea((x, y), vic.tWestAfricaTL, vic.tWestAfricaBR):
            return 59

    elif iPlayer == iPortugal:
        if utils.isPlotInArea((x, y), vic.tAfricaTL, vic.tAfricaBR):
            return 33

        if utils.isPlotInArea((x, y), vic.tAsiaTL, vic.tAsiaBR):
            return 34

        if utils.isPlotInArea((x, y), vic.tBrazilTL, vic.tBrazilBR):
            return 60

    elif iPlayer == iMaya:
        if utils.isReborn(iPlayer):
            if utils.isPlotInArea((x, y), vic.tPeruTL, vic.tPeruBR):
                return 43

            if utils.isPlotInArea((x, y), vic.tGranColombiaTL,
                                  vic.tGranColombiaBR):
                return 44

            if utils.isPlotInArea((x, y), vic.tGuayanasTL, vic.tGuayanasBR):
                return 45

            if utils.isPlotInArea((x, y), vic.tCaribbeanTL, vic.tCaribbeanBR):
                return 46

            if utils.isPlotInArea((x, y), vic.tSAmericaTL, vic.tSAmericaBR,
                                  vic.tSouthAmericaExceptions):
                return 61

    elif iPlayer == iCanada:
        if (x, y) in vic.lAtlanticCoast:
            return 63

        if (x, y) in vic.lPacificCoast:
            return 64

        if utils.isPlotInArea((x, y), vic.tCanadaWestTL, vic.tCanadaWestBR,
                              vic.tCanadaWestExceptions) or utils.isPlotInArea(
                                  (x, y), vic.tCanadaEastTL, vic.tCanadaEastBR,
                                  vic.tCanadaEastExceptions):
            return 62

    elif iPlayer == iPolynesia:
        if utils.isPlotInArea((x, y), vic.tHawaiiTL, vic.tHawaiiBR):
            return 65

        if utils.isPlotInArea((x, y), vic.tNewZealandTL, vic.tNewZealandBR):
            return 66

        if utils.isPlotInArea((x, y), vic.tMarquesasTL, vic.tMarquesasBR):
            return 67

        if utils.isPlotInArea((x, y), vic.tEasterIslandTL,
                              vic.tEasterIslandBR):
            return 68

    elif iPlayer == iMongolia:
        if (x, y) in Areas.getNormalArea(iChina, False):
            return 69

    elif iPlayer == iTurks:
        if (x, y) in vic.lMediterraneanPorts:
            return 70

        if utils.isPlotInArea((x, y), vic.tChinaTL, vic.tChinaBR):
            return 71

        # free IDs: 20
        # continue with ID 72

    return -1
	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 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
示例#9
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)
示例#10
0
def isDecline(iPlayer):
    return utils.getHumanID() != iPlayer and not utils.isReborn(
        iPlayer) and gc.getGame().getGameTurn() >= getTurnForYear(
            tFall[iPlayer])
示例#11
0
def exportFlip(iPlayer, dFlipZoneEdits):
	if iPlayer not in dFlipZoneEdits.keys():
		sText = "No changes between current flipzone and flipzone defined in python"
		popup = PyPopup.PyPopup()
		popup.setBodyString(sText)
		popup.launch(True, PopupStates.POPUPSTATE_IMMEDIATE)
		return

	iCiv = gc.getPlayer(iPlayer).getCivilizationType()
	sName = gc.getCivilizationInfo(iCiv).getShortDescription(0)
	if iPlayer == iHolyRome:
		sName = "HolyRome"
	elif iPlayer == iAztecs:
		sName = "Aztecs"

	lNewFlipPlotList, lNewAIPlotList = dFlipZoneEdits[iPlayer]
	if utils.isReborn(iPlayer):
		lOldFlipPlotList = Areas.getRebirthArea(iPlayer)
	else:
		lOldFlipPlotList = Areas.getBirthArea(iPlayer)
	bFlipChanged = len(lOldFlipPlotList) != len(lNewFlipPlotList)
	if not bFlipChanged:
		for tPlot in lNewFlipPlotList:
			if tPlot not in lOldFlipPlotList:
				bFlipChanged = True
				break
		else:
			if iPlayer in Areas.dChangedBirthArea:
				tTL, tBR = Areas.getBirthRectangle(iPlayer, True)
				lOldAIPlotList = [tPlot for tPlot in utils.getPlotList(tTL, tBR, utils.getOrElse(Areas.dBirthAreaExceptions, iPlayer, [])) if tPlot not in lOldFlipPlotList]
			else:
				lOldAIPlotList = []
			bFlipChanged = len(lOldAIPlotList) != len(lNewAIPlotList)
			if not bFlipChanged:
				for tPlot in lNewAIPlotList:
					if tPlot not in lOldAIPlotList:
						bFlipChanged = True
						break

	if bFlipChanged:
		Bottom = iWorldY
		Top = 0
		Left = iWorldX
		Right = 0
		for (x, y) in lNewFlipPlotList:
			if (x, y) in lNewAIPlotList: continue
			if x < Left:
				Left = x
			if x > Right:
				Right = x
			if y < Bottom:
				Bottom = y
			if y > Top:
				Top = y
		BL = (Left, Bottom)
		TR = (Right, Top)

		lExceptions = []
		for tPlot in utils.getPlotList(BL, TR):
			if tPlot not in lNewFlipPlotList:
				lExceptions.append(tPlot)

		if lNewAIPlotList:
			BottomAI = iWorldY
			TopAI = 0
			LeftAI = iWorldX
			RightAI = 0
			for (x, y) in lNewAIPlotList+lNewFlipPlotList:
				if x < LeftAI:
					LeftAI = x
				if x > RightAI:
					RightAI = x
				if y < BottomAI:
					BottomAI = y
				if y > TopAI:
					TopAI = y
			BLAI = (LeftAI, BottomAI)
			TRAI = (RightAI, TopAI)

		file = open(IMAGE_LOCATION + "\FlipZones\\" + sName + ".txt", 'wt')
		try:
			if not utils.isReborn(iPlayer):
				file.write("# tBirthArea\n")
				file.write("("+ str(BL) + ",\t" + str(TR) + "),\t# " + sName)
				if lExceptions:
					file.write("\n\n# dBirthAreaExceptions\n")
					file.write("i" + sName + " : " + str(lExceptions) + ",")
			else:
				file.write("# dRebirthArea\n")
				file.write("i" + sName + " : " "("+ str(BL) + ",\t" + str(TR) + "),")
				if lExceptions:
					file.write("\n\n# dRebirthAreaExceptions\n")
					file.write("i" + sName + " : " + str(lExceptions) + ",")

			if lNewAIPlotList:
				if not utils.isReborn(iPlayer):
					file.write("\n\n# dChangedBirthArea\n")
					file.write("("+ str(BLAI) + ",\t" + str(TRAI) + "),\t# " + sName)
		finally:
			file.close()
		sText = "Flipzone map of %s exported" %sName
	else:
		sText = "No changes between current flipzone and flipzone defined in python"
	popup = PyPopup.PyPopup()
	popup.setBodyString(sText)
	popup.launch(True, PopupStates.POPUPSTATE_IMMEDIATE)
示例#12
0
def exportAllFlip(dFlipZoneEdits):
	lAllFlips = []
	lAllExceptions = []
	lAllAIPlots = []
	for iPlayer in range(iNumPlayers):
		iCiv = gc.getPlayer(iPlayer).getCivilizationType()
		sName = gc.getCivilizationInfo(iCiv).getShortDescription(0)
		if iPlayer == iHolyRome:
			sName = "HolyRome"
		elif iPlayer == iAztecs:
			sName = "Aztecs"
			
		if iPlayer in dFlipZoneEdits.keys():
			lNewFlipPlotList, lNewAIPlotList = dFlipZoneEdits[iPlayer]
		else:
			if utils.isReborn(iPlayer):
				lNewFlipPlotList = Areas.getRebirthArea(iPlayer)
			else:
				lNewFlipPlotList = Areas.getBirthArea(iPlayer)
			if iPlayer in Areas.dChangedBirthArea:
				tTL, tBR = Areas.getBirthRectangle(iPlayer, True)
				lNewAIPlotList = [tPlot for tPlot in utils.getPlotList(tTL, tBR, utils.getOrElse(Areas.dBirthAreaExceptions, iPlayer, [])) if tPlot not in lNewFlipPlotList]
			else:
				lNewAIPlotList = []

		Bottom = iWorldY
		Top = 0
		Left = iWorldX
		Right = 0
		for (x, y) in lNewFlipPlotList:
			if (x, y) in lNewAIPlotList: continue
			if x < Left:
				Left = x
			if x > Right:
				Right = x
			if y < Bottom:
				Bottom = y
			if y > Top:
				Top = y
		BL = (Left, Bottom)
		TR = (Right, Top)

		lExceptions = []
		for tPlot in utils.getPlotList(BL, TR):
			if tPlot not in lNewFlipPlotList:
				lExceptions.append(tPlot)

		if lNewAIPlotList:
			BottomAI = iWorldY
			TopAI = 0
			LeftAI = iWorldX
			RightAI = 0
			for (x, y) in lNewAIPlotList+lNewFlipPlotList:
				if (x, y) in lExceptions: continue
				if x < LeftAI:
					LeftAI = x
				if x > RightAI:
					RightAI = x
				if y < BottomAI:
					BottomAI = y
				if y > TopAI:
					TopAI = y
			BLAI = (LeftAI, BottomAI)
			TRAI = (RightAI, TopAI)

		lAllFlips.append("("+ str(BL) + ",\t" + str(TR) + "),\t# " + sName)
		if lExceptions:
			lAllExceptions.append("i" + sName + " : " + str(lExceptions) + ",")
		if lNewAIPlotList:
			lAllAIPlots.append("i" + sName + " : (" + str(BLAI) + ",\t" + str(TRAI) + "),")

	file = open(IMAGE_LOCATION + "\FlipZones\\AllFlipZones.txt", 'wt')
	try:
		file.write("tBirthArea = (\n")
		for sString in lAllFlips:
			file.write(sString + "\n")
		file.write(")")
		if lAllAIPlots:
			file.write("\n\ndChangedBirthArea = {\n")
			for sString in lAllAIPlots:
				file.write(sString + "\n")
			file.write("}")
		if lAllExceptions:
			file.write("\n\ndBirthAreaExceptions = {\n")
			for sString in lAllExceptions:
				file.write(sString + "\n")
			file.write("}")
	finally:
		file.close()
	sText = "All flipzone maps exported"
	popup = PyPopup.PyPopup()
	popup.setBodyString(sText)
	popup.launch(True, PopupStates.POPUPSTATE_IMMEDIATE)
def exportCore(iPlayer, bForce = False):
	iCiv = gc.getPlayer(iPlayer).getCivilizationType()
	sName = gc.getCivilizationInfo(iCiv).getShortDescription(0)
	if iPlayer == iHolyRome:
		sName = "HolyRome"
	elif iPlayer == iAztecs:
		sName = "Aztecs"

	lCorePlotList = Areas.getCoreArea(iPlayer)
	bCoreChanged = bForce
	if not bCoreChanged:
		for (x, y) in utils.getWorldPlotsList():
			bOldCore = (x, y) in lCorePlotList
			if gc.getMap().plot(x, y).isCore(iPlayer) != bOldCore:
				bCoreChanged = True
				break
	if bCoreChanged:
		Bottom = iWorldY
		Top = 0
		Left = iWorldX
		Right = 0
		for (x, y) in utils.getWorldPlotsList():
			if gc.getMap().plot(x, y).isCore(iPlayer):
				if x < Left:
					Left = x
				if x > Right:
					Right = x
				if y < Bottom:
					Bottom = y
				if y > Top:
					Top = y
		BL = (Left, Bottom)
		TR = (Right, Top)

		lExceptions = []
		for (x, y) in utils.getPlotList(BL, TR):
			plot = gc.getMap().plot(x, y)
			if not plot.isCore(iPlayer) and not (plot.isWater() or (plot.isPeak() and (x, y) not in Areas.lPeakExceptions)):
				lExceptions.append((x, y))

		file = open(IMAGE_LOCATION + "\Cores\\" + sName + ".txt", 'wt')
		try:
			if not utils.isReborn(iPlayer):
				file.write("# tCoreArea\n")
				file.write("("+ str(BL) + ",\t" + str(TR) + "),\t# " + sName)
				if lExceptions:
					file.write("\n\n# dCoreAreaExceptions\n")
					file.write("i" + sName + " : " + str(lExceptions) + ",")
			else:
				file.write("# dChangedCoreArea\n")
				file.write("i" + sName + " : " "("+ str(BL) + ",\t" + str(TR) + "),")
				if lExceptions:
					file.write("\n\n# dChangedCoreAreaExceptions\n")
					file.write("i" + sName + " : " + str(lExceptions) + ",")
		finally:
			file.close()
		sText = "Core map of %s exported" %sName
	else:
		sText = "No changes between current core and core defined in python"
	popup = PyPopup.PyPopup()
	popup.setBodyString(sText)
	popup.launch(True, PopupStates.POPUPSTATE_IMMEDIATE)
	def doImmigration(self):
	
		# get available migration and immigration cities
		lSourceCities = []
		lTargetCities = []
		
		for iPlayer in range(iNumPlayers):
			if iPlayer in lCivBioNewWorld and not utils.isReborn(iPlayer): continue # no immigration to natives
			pPlayer = gc.getPlayer(iPlayer)
			lCities = []
			bNewWorld = pPlayer.getCapitalCity().getRegionID() in lNewWorld
			for city in utils.getCityList(iPlayer):
				iFoodDifference = city.foodDifference(False)
				iHappinessDifference = city.happyLevel() - city.unhappyLevel(0)
				if city.getRegionID() in lNewWorld and bNewWorld:
					if iFoodDifference <= 0 or iHappinessDifference <= 0: continue
					iNorthAmericaBonus = 0
					if city.getRegionID() in [rCanada, rUnitedStates]: iNorthAmericaBonus = 5
					lCities.append((city, iHappinessDifference + iFoodDifference / 2 + city.getPopulation() / 2 + iNorthAmericaBonus))
				elif city.getRegionID() not in lNewWorld and not bNewWorld:
					iValue = 0
					if iFoodDifference < 0:
						iValue -= iFoodDifference / 2
					if iHappinessDifference < 0:
						iValue -= iHappinessDifference
					if iValue > 0:
						lCities.append((city, iValue))
			
			if lCities:
				lCities.sort(key=itemgetter(1), reverse=True)
			
				if bNewWorld:
					lTargetCities.append(lCities[0])
				else:
					lSourceCities.append(lCities[0])
				
		# sort highest to lowest for happiness/unhappiness
		lSourceCities.sort(key=itemgetter(1), reverse=True)
		lTargetCities.sort(key=itemgetter(1), reverse=True)
		
		#utils.debugTextPopup(str([(x.getName(), y) for (x,y) in lTargetCities]))
		#utils.debugTextPopup("Target city: "+targetCity.getName())
		#utils.debugTextPopup("Source city: "+sourceCity.getName())
		
		iNumMigrations = min(len(lSourceCities) / 4, len(lTargetCities))
		
		for iMigration in range(iNumMigrations):
			sourceCity = lSourceCities[iMigration][0]
			targetCity = lTargetCities[iMigration][0]
		
			sourceCity.changePopulation(-1)
			targetCity.changePopulation(1)
			
			if sourceCity.getPopulation() >= 9:
				sourceCity.changePopulation(-1)
				targetCity.changePopulation(1)
				
			# extra cottage growth for target city's vicinity
			x = targetCity.getX()
			y = targetCity.getY()
			for (i, j) in utils.surroundingPlots((x, y), 2):
				pCurrent = gc.getMap().plot(i, j)
				if pCurrent.getWorkingCity() == targetCity:
					pCurrent.changeUpgradeProgress(utils.getTurns(10))
						
			# migration brings culture
			targetPlot = gc.getMap().plot(x, y)
			iTargetPlayer = targetCity.getOwner()
			iSourcePlayer = sourceCity.getOwner()
			iCultureChange = targetPlot.getCulture(iTargetPlayer) / targetCity.getPopulation()
			targetPlot.setCulture(iSourcePlayer, iCultureChange, False)
			
			# chance to spread state religion if in source city
			if gc.getPlayer(iSourcePlayer).isStateReligion():
				iReligion = gc.getPlayer(iSourcePlayer).getStateReligion()
				if sourceCity.isHasReligion(iReligion) and not targetCity.isHasReligion(iReligion):
					iRandom = gc.getGame().getSorenRandNum(3, 'random religion spread')
					if iRandom == 0:
						targetCity.setHasReligion(iReligion, True, True, True)
						
			# notify affected players
			if utils.getHumanID() == iSourcePlayer:
				CyInterface().addMessage(iSourcePlayer, False, iDuration, CyTranslator().getText("TXT_KEY_UP_EMIGRATION", (sourceCity.getName(),)), "", InterfaceMessageTypes.MESSAGE_TYPE_MINOR_EVENT, gc.getUnitInfo(iSettler).getButton(), ColorTypes(iYellow), sourceCity.getX(), sourceCity.getY(), True, True)
			elif utils.getHumanID() == iTargetPlayer:
				CyInterface().addMessage(iTargetPlayer, False, iDuration, CyTranslator().getText("TXT_KEY_UP_IMMIGRATION", (targetCity.getName(),)), "", InterfaceMessageTypes.MESSAGE_TYPE_MINOR_EVENT, gc.getUnitInfo(iSettler).getButton(), ColorTypes(iYellow), x, y, True, True)
	
			if iTargetPlayer == iCanada:
				self.canadianUP(targetCity)
示例#15
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)
示例#16
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
	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]
	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]
示例#19
0
def getUHVTileInfo(argsList):
    x = argsList[0]
    y = argsList[1]
    iPlayer = argsList[2]

    plot = gc.getMap().plot(x, y)

    if iPlayer == iGreece:
        if (x, y) in Areas.getNormalArea(iEgypt, False):
            return 0

        if (x, y) in Areas.getNormalArea(iCarthage, False):
            return 1

        if (x, y) in Areas.getNormalArea(iBabylonia, False):
            return 2

        if (x, y) in Areas.getNormalArea(iPersia, False):
            return 3

    elif iPlayer == iPersia and CyGlobalContext().getPlayer(
            iPersia).isReborn():
        if utils.isPlotInArea((x, y), vic.tSafavidMesopotamiaTL,
                              vic.tSafavidMesopotamiaBR):
            return 4

        if utils.isPlotInArea((x, y), vic.tTransoxaniaTL, vic.tTransoxaniaBR):
            return 5

        if utils.isPlotInArea((x, y), vic.tNWIndiaTL, vic.tNWIndiaBR,
                              vic.tNWIndiaExceptions):
            return 6

    elif iPlayer == iCarthage:
        if utils.isPlotInArea((x, y), Areas.tNormalArea[iItaly][0],
                              Areas.tNormalArea[iItaly][1],
                              [(62, 47), (63, 47), (63, 46)]):
            return 37

        if (x, y) in Areas.getNormalArea(iSpain, False):
            return 8

    elif iPlayer == iItaly:
        if utils.isPlotInArea(
            (x, y), vic.tMediterraneanTL, vic.tMediterraneanBR, vic.
                tMediterraneanExceptions) and CyGlobalContext().getMap().plot(
                    x, y).isCoastalLand():
            return 7

    elif iPlayer == iRome:
        if (x, y) in Areas.getNormalArea(iSpain, False):
            return 8

        if utils.isPlotInArea((x, y), vic.tFranceTL,
                              Areas.tNormalArea[iFrance][1]):
            return 9

        if (x, y) in Areas.getCoreArea(iEngland, False):
            return 10

        if utils.isPlotInArea((x, y), vic.tCarthageTL, vic.tCarthageBR):
            return 11

        if (x, y) in Areas.getCoreArea(iByzantium, False):
            return 12

        if (x, y) in Areas.getCoreArea(iEgypt, False):
            return 13

    elif iPlayer == iJapan:
        if utils.isPlotInArea((x, y), vic.tKoreaTL, vic.tKoreaBR):
            return 14

        if utils.isPlotInArea((x, y), vic.tManchuriaTL, vic.tManchuriaBR):
            return 15

        if utils.isPlotInArea((x, y), vic.tChinaTL, vic.tChinaBR):
            return 16

        if utils.isPlotInArea((x, y), vic.tIndochinaTL, vic.tIndochinaBR,
                              vic.tIndochinaExceptions):
            return 17

        if utils.isPlotInArea((x, y), vic.tIndonesiaTL, vic.tIndonesiaBR):
            return 18

        if utils.isPlotInArea((x, y), vic.tPhilippinesTL, vic.tPhilippinesBR):
            return 19

    elif iPlayer == iEthiopia:
        if gc.getMap().plot(x, y).getRegionID() in lAfrica:
            return 33

    elif iPlayer == iByzantium:
        if utils.isPlotInArea((x, y), vic.tBalkansTL, vic.tBalkansBR):
            return 21

        if utils.isPlotInArea((x, y), vic.tNorthAfricaTL, vic.tNorthAfricaBR):
            return 22

        if utils.isPlotInArea((x, y), vic.tNearEastTL, vic.tNearEastBR):
            return 23

    elif iPlayer == iArabia:
        if (x, y) in Areas.getCoreArea(iEgypt, False):
            return 24

        if utils.isPlotInArea((x, y), vic.tCarthageTL, vic.tCarthageBR):
            return 25

        if (x, y) in Areas.getCoreArea(iBabylonia, False):
            return 26

        if (x, y) in Areas.getCoreArea(iPersia, False):
            return 27

        if (x, y) in Areas.getNormalArea(iSpain, False):
            return 28

    elif iPlayer == iSpain:
        if utils.isPlotInArea((x, y), vic.tEuropeTL, vic.tEuropeBR): return 29
        elif utils.isPlotInArea((x, y), vic.tEasternEuropeTL,
                                vic.tEasternEuropeBR):
            return 29

    elif iPlayer == iFrance:
        if utils.isPlotInArea((x, y), vic.tEuropeTL, vic.tEuropeBR): return 29
        elif utils.isPlotInArea((x, y), vic.tEasternEuropeTL,
                                vic.tEasternEuropeBR):
            return 29

        if utils.isPlotInArea((x, y), vic.tNorthAmericaTL,
                              vic.tNorthAmericaBR):
            return 30

    elif iPlayer == iEngland:
        if plot.getRegionID() in lNorthAmerica:
            return 31

        if plot.getRegionID() in lSouthAmerica:
            return 32

        if plot.getRegionID() in lAfrica:
            return 33

        if plot.getRegionID() in lAsia:
            return 34

        if plot.getRegionID() in lOceania:
            return 35

    elif iPlayer == iGermany:
        if (x, y) in Areas.getNormalArea(iFrance, False):
            return 36

        if (x, y) in Areas.getNormalArea(iItaly, False):
            return 37

        if (x, y) in Areas.getNormalArea(iRussia, False):
            return 38

        if (x, y) in Areas.getNormalArea(iEngland, False):
            return 39

        if (x, y) in Areas.getNormalArea(iVikings, False):
            return 40

    elif iPlayer == iBurma:
        if utils.isPlotInArea((x, y), vic.tIndochinaTL, vic.tIndochinaBR,
                              vic.tIndochinaExceptions):
            return 17

    elif iPlayer == iKhazars:
        if (x, y) in vic.lDanube:
            return 87

        if (x, y) in vic.lZaysan:
            return 88

    elif iPlayer == iChad:
        if utils.isPlotInArea((x, y), vic.tCameroonTL, vic.tCameroonBR):
            return 102
        if utils.isPlotInArea((x, y), vic.tNigeriaTL, vic.tNigeriaBR):
            return 103
        if utils.isPlotInArea((x, y), vic.tLibyaTL, vic.tLibyaBR):
            return 104

    elif iPlayer == iRussia:
        if utils.isPlotInArea((x, y), vic.tSiberiaTL, vic.tSiberiaBR):
            return 41

    elif iPlayer == iInca:
        if (x, y) in vic.lAndeanCoast:
            return 42

        if utils.isPlotInArea((x, y), vic.tSAmericaTL, vic.tSAmericaBR,
                              vic.tSouthAmericaExceptions):
            return 43

    elif iPlayer == iOttomans:
        if (x, y) in vic.lEasternMediterranean:
            return 47

        if (x, y) in vic.lBlackSea:
            return 48

        if (x, y) in utils.surroundingPlots(vic.tCairo):
            return 49

        if (x, y) in utils.surroundingPlots(vic.tMecca):
            return 50

        if (x, y) in utils.surroundingPlots(vic.tBaghdad):
            return 51

        if (x, y) in utils.surroundingPlots(vic.tVienna):
            return 52

    elif iPlayer in [iThailand, iVietnam]:
        if utils.isPlotInArea((x, y), vic.tSouthAsiaTL, vic.tSouthAsiaBR):
            return 53

    elif iPlayer == iAmerica:
        if utils.isPlotInArea((x, y), vic.tNCAmericaTL, vic.tNCAmericaBR):
            return 54

    elif iPlayer == iTamils:
        if utils.isPlotInArea((x, y), vic.tDeccanTL, vic.tDeccanBR):
            return 55

        if utils.isPlotInArea((x, y), vic.tSrivijayaTL, vic.tSrivijayaBR):
            return 56

    elif iPlayer == iMoors:
        if utils.isPlotInArea((x, y), vic.tIberiaTL, vic.tIberiaBR):
            return 57

        if utils.isPlotInArea((x, y), vic.tMaghrebTL, vic.tMaghrebBR):
            return 58

        if utils.isPlotInArea((x, y), vic.tWestAfricaTL, vic.tWestAfricaBR):
            return 59

    elif iPlayer == iPortugal:
        if plot.getRegionID() in lAfrica:
            return 33

        if plot.getRegionID() in lAsia:
            return 34

        if utils.isPlotInArea((x, y), vic.tBrazilTL, vic.tBrazilBR):
            return 60

    elif iPlayer == iMaya:
        if utils.isReborn(iPlayer):
            if utils.isPlotInArea((x, y), vic.tPeruTL, vic.tPeruBR):
                return 43

            if utils.isPlotInArea((x, y), vic.tGranColombiaTL,
                                  vic.tGranColombiaBR):
                return 44

            if utils.isPlotInArea((x, y), vic.tGuayanasTL, vic.tGuayanasBR):
                return 45

            if utils.isPlotInArea((x, y), vic.tCaribbeanTL, vic.tCaribbeanBR):
                return 46

            if utils.isPlotInArea((x, y), vic.tSAmericaTL, vic.tSAmericaBR,
                                  vic.tSouthAmericaExceptions):
                return 61

    elif iPlayer == iCanada:
        if (x, y) in vic.lAtlanticCoast:
            return 63

        if (x, y) in vic.lPacificCoast:
            return 64

        if utils.isPlotInArea((x, y), vic.tCanadaWestTL, vic.tCanadaWestBR,
                              vic.tCanadaWestExceptions) or utils.isPlotInArea(
                                  (x, y), vic.tCanadaEastTL, vic.tCanadaEastBR,
                                  vic.tCanadaEastExceptions):
            return 62

    elif iPlayer == iPolynesia:
        if utils.isPlotInArea((x, y), vic.tHawaiiTL, vic.tHawaiiBR):
            return 65

        if utils.isPlotInArea((x, y), vic.tNewZealandTL, vic.tNewZealandBR):
            return 66

        if utils.isPlotInArea((x, y), vic.tMarquesasTL, vic.tMarquesasBR):
            return 67

        if utils.isPlotInArea((x, y), vic.tEasterIslandTL,
                              vic.tEasterIslandBR):
            return 68

    elif iPlayer == iMongolia:
        if (x, y) in Areas.getNormalArea(iChina, False):
            return 69

    elif iPlayer == iTurks:
        if (x, y) in vic.lMediterraneanPorts:
            return 70

        if utils.isPlotInArea((x, y), vic.tChinaTL, vic.tChinaBR):
            return 71

    elif iPlayer == iTeotihuacan:
        if utils.isPlotInArea((x, y), vic.tMesoamericaTL, vic.tMesoamericaBR):
            return 86

    elif iPlayer == iSweden:
        if (x, y) in vic.lSkagerrak or (x, y) in vic.lSkagerrak:
            return 72

        if (x, y) in vic.lBalticSea or (x, y) in vic.lBalticSea:
            return 73

    elif iPlayer == iAustralia:
        if utils.isPlotInArea((x, y), vic.tAustraliaTL, vic.tAustraliaBR):
            return 74

        if utils.isPlotInArea((x, y), vic.tNewZealandTL, vic.tNewZealandBR):
            return 66

        if utils.isPlotInArea((x, y), vic.tNewGuineaTL, vic.tNewGuineaBR):
            return 75

        if utils.isPlotInArea(
            (x, y), vic.tPacific1TL, vic.tPacific1BR) or utils.isPlotInArea(
                (x, y), vic.tPacific2TL,
                vic.tPacific2BR) or utils.isPlotInArea(
                    (x, y), vic.tPacific3TL,
                    vic.tPacific3BR) or utils.isPlotInArea(
                        (x, y), vic.tHawaiiTL, vic.tHawaiiBR):
            return 76

    elif iPlayer == iMamluks:
        if utils.isPlotInArea(
            (x, y), vic.tLowerNileTL, vic.tLowerNileBR) and gc.getMap().plot(
                x, y).isRiver():
            if utils.isPlotInArea((x, y), vic.tNorthAfricaTL,
                                  vic.tNorthAfricaBR):
                return 80
            return 79

        if utils.isPlotInArea((x, y), vic.tNorthAfricaTL, vic.tNorthAfricaBR):
            return 22

        if utils.isPlotInArea((x, y), vic.tHejazTL, vic.tHejazBR,
                              vic.tHejazExceptions):
            return 77

        if utils.isPlotInArea((x, y), vic.tLevantTL, vic.tLevantBR):
            return 78

        if (x, y) in Areas.getCoreArea(iBabylonia, False):
            return 4

    elif iPlayer == iManchuria:
        if gc.getMap().plot(x, y).getSettlerValue(iManchuria) >= 90:
            return 81

    elif iPlayer == iBoers:
        if utils.isPlotInArea((x, y), vic.tBoerAfricaTL, vic.tBoerAfricaBR):
            return 82

    elif iPlayer == iZimbabwe:
        if utils.isPlotInArea((x, y), vic.tSubeqAfricaTL, vic.tSubeqAfricaBR):
            return 83

        if utils.isPlotInArea((x, y), vic.tSubSaharaTL, vic.tSubSaharaBR,
                              vic.tSubSaharaExceptions):
            return 84

    elif iPlayer == iSwahili:
        if gc.getMap().plot(x, y).getRegionID() == rAustralia:
            return 74

    elif iPlayer == iKievanRus:
        if (x, y) in vic.lMediterraneanCoast:
            return 7

        if (x, y) in vic.lBarents:
            return 85

    elif iPlayer == iHungary:
        if gc.getMap().plot(
                x, y).getRegionID() in [rIberia, rEurope, rItaly, rBalkans]:
            return 29

    elif iPlayer == iCeltia:
        if utils.isPlotInArea(
            (x, y), vic.tFranceTL,
                Areas.tNormalArea[iFrance][1]) or (x, y) == (56, 46):
            return 89

        if utils.isPlotInArea((x, y), vic.tGermaniaTL, vic.tGermaniaBR):
            return 90

        if gc.getMap().plot(x, y).getRegionID() == rItaly:
            return 91

        if gc.getMap().plot(x, y).getRegionID() == rBritain:
            return 92

        if gc.getMap().plot(x, y).getRegionID() == rIberia:
            return 8

    elif iPlayer == iNorteChico:
        if utils.isReborn(iPlayer):
            if (x, y) in Areas.getCoreArea(iInca, False):
                return 95

            if (x, y) in utils.isPlotInArea((x, y), vic.tChimuTL,
                                            vic.tChimuBR):
                return 96

    elif iPlayer == iMississippi:
        if (x, y) in vic.lMississippiRiver:
            if (x, y) in vic.lOhioRiver:
                return 99
            elif (x, y) in vic.lGreatLakes:
                return 101
            return 98
        elif (x, y) in vic.lGreatLakes:
            return 100
        elif (x, y) in vic.lOhioRiver:
            return 97

    elif iPlayer == iInuit:
        if (x, y) in vic.lKivalliq:
            return 105

        if utils.isPlotInArea((x, y), vic.tNunavikTL, vic.tNunavikBR,
                              vic.tNunavikExceptions):
            return 106

        if utils.isPlotInArea((x, y), vic.tQikiqtaalukTL, vic.tQikiqtaalukBR,
                              vic.tQikiqtaalukExceptions):
            return 107

        if utils.isPlotInArea((x, y), vic.tKalaallitNunaatTL,
                              vic.tKalaallitNunaatBR,
                              vic.tKalaallitNunaatExceptions):
            return 108

    elif iPlayer == iYuezhi:
        if (x, y) in Areas.getCoreArea(iYuezhi, True) and y <= 43:
            return 109

    elif iPlayer == iXiongnu:
        if (x, y) in utils.getRegionPlots(lEurope):
            return 29
        if (x, y) in utils.getRegionPlots(lIndia):
            return 110

        # continue with 111
    return -1