Exemplo n.º 1
0
	def inviteToCongress(self):
		rank = lambda x: gc.getGame().getPlayerRank(x)
		lPossibleInvites = []
	
		if self.bPostWar:
			iLowestWinnerRank = rank(utils.getSortedList(self.lWinners, rank)[0])
			lPossibleInvites.extend(self.lWinners)
			lPossibleInvites.extend([iLoser for iLoser in self.lLosers if rank(iLoser) < iLowestWinnerRank])
			
		lPossibleInvites.extend(utils.getSortedList([iPlayer for iPlayer in range(iNumPlayers) if iPlayer not in lPossibleInvites], rank))
	
		self.lInvites = lPossibleInvites[:getNumInvitations()]
		
		lRemove = []
		for iLoopPlayer in self.lInvites:
			if not gc.getPlayer(iLoopPlayer).isAlive(): lRemove.append(iLoopPlayer)
			
		for iLoopPlayer in lRemove:
			self.lInvites.remove(iLoopPlayer)
		
		# Leoreth: America receives an invite if there are still claims in the west
		if iAmerica not in self.lInvites and not self.bPostWar and gc.getGame().getGameTurn() > tBirth[iAmerica]:
			lAmericanClaimCities = utils.getAreaCities(utils.getPlotList(tAmericanClaimsTL, tAmericanClaimsBR))
			if utils.satisfies(lAmericanClaimCities, lambda x: x.getOwner() != iAmerica):
				self.lInvites[len(self.lInvites)-1] = iAmerica
	def inviteToCongress(self):
		rank = lambda x: gc.getGame().getPlayerRank(x)
		lPossibleInvites = []
	
		if self.bPostWar:
			iLowestWinnerRank = rank(utils.getSortedList(self.lWinners, rank)[0])
			lPossibleInvites.extend(self.lWinners)
			lPossibleInvites.extend([iLoser for iLoser in self.lLosers if rank(iLoser) < iLowestWinnerRank])
			
		lPossibleInvites.extend(utils.getSortedList([iPlayer for iPlayer in range(iNumPlayers) if iPlayer not in lPossibleInvites], rank))
	
		self.lInvites = lPossibleInvites[:getNumInvitations()]
		
		lRemove = []
		for iLoopPlayer in self.lInvites:
			if not gc.getPlayer(iLoopPlayer).isAlive(): lRemove.append(iLoopPlayer)
			
		for iLoopPlayer in lRemove:
			self.lInvites.remove(iLoopPlayer)
		
		# Leoreth: America receives an invite if there are still claims in the west
		if iAmerica not in self.lInvites and not self.bPostWar and gc.getGame().getGameTurn() > tBirth[iAmerica]:
			lAmericanClaimCities = utils.getAreaCities(utils.getPlotList(tAmericanClaimsTL, tAmericanClaimsBR))
			if utils.satisfies(lAmericanClaimCities, lambda x: x.getOwner() != iAmerica):
				self.lInvites[len(self.lInvites)-1] = iAmerica
	def selectRandomCityArea(self, tTopLeft, tBottomRight): # Unused
		cityList = []
		for (x, y) in utils.getPlotList(tTopLeft, tBottomRight):
			pPlot = gc.getMap().plot(x, y)
			if pPlot.isCity():
				cityList.append((x, y))
		if cityList:
			return utils.getRandomEntry(cityList)
		return False
Exemplo n.º 4
0
	def selectRandomCityArea(self, tTopLeft, tBottomRight): # Unused
		cityList = []
		for (x, y) in utils.getPlotList(tTopLeft, tBottomRight):
			pPlot = gc.getMap().plot(x, y)
			if pPlot.isCity():
				cityList.append((x, y))
		if cityList:
			return utils.getRandomEntry(cityList)
		return False
	def selectRandomCityAreaCiv(self, tTopLeft, tBottomRight, iCiv = -1): # Unused
		cityList = []
		for (x, y) in utils.getPlotList(tTopLeft, tBottomRight):
			pPlot = gc.getMap().plot( x, y )
			if pPlot.isCity():
				if (iCiv != -1 and pPlot.getPlotCity().getOwner() != iCiv): continue
				cityList.append((x, y))
		if cityList:
			return utils.getRandomEntry(cityList)
		return False
Exemplo n.º 6
0
	def selectRandomCityAreaCiv(self, tTopLeft, tBottomRight, iCiv = -1): # Unused
		cityList = []
		for (x, y) in utils.getPlotList(tTopLeft, tBottomRight):
			pPlot = gc.getMap().plot( x, y )
			if pPlot.isCity():
				if (iCiv != -1 and pPlot.getPlotCity().getOwner() != iCiv): continue
				cityList.append((x, y))
		if cityList:
			return utils.getRandomEntry(cityList)
		return False
def exportAllCores():
	lAllCores = []
	lAllExceptions = []
	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"

		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))

		lAllCores.append("("+ str(BL) + ",\t" + str(TR) + "),\t# " + sName)
		if lExceptions:
			lAllExceptions.append("i" + sName + " : " + str(lExceptions) + ",")

	file = open(IMAGE_LOCATION + "\Cores\\AllCores.txt", 'wt')
	try:
		file.write("tCoreArea = (\n")
		for sString in lAllCores:
			file.write(sString + "\n")
		file.write(")")
		file.write("\n\ndCoreAreaExceptions = {\n")
		for sString in lAllExceptions:
			file.write(sString + "\n")
		file.write("}")
	finally:
		file.close()
	sText = "All core maps exported"
	popup = PyPopup.PyPopup()
	popup.setBodyString(sText)
	popup.launch(True, PopupStates.POPUPSTATE_IMMEDIATE)
Exemplo n.º 8
0
def exportAllCores():
	lAllCores = []
	lAllExceptions = []
	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"

		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))

		lAllCores.append("("+ str(BL) + ",\t" + str(TR) + "),\t# " + sName)
		if lExceptions:
			lAllExceptions.append("i" + sName + " : " + str(lExceptions) + ",")

	file = open(IMAGE_LOCATION + "\Cores\\AllCores.txt", 'wt')
	try:
		file.write("tCoreArea = (\n")
		for sString in lAllCores:
			file.write(sString + "\n")
		file.write(")")
		file.write("\n\ndCoreAreaExceptions = {\n")
		for sString in lAllExceptions:
			file.write(sString + "\n")
		file.write("}")
	finally:
		file.close()
	sText = "All core maps exported"
	popup = PyPopup.PyPopup()
	popup.setBodyString(sText)
	popup.launch(True, PopupStates.POPUPSTATE_IMMEDIATE)
	def isConquered(self, tConquest):
		iID, iPlayer, iPreferredTarget, tTL, tBR, iNumTargets, iYear, iIntervalTurns = tConquest
	
		iNumMinorCities = 0
		lAreaCities = utils.getAreaCities(utils.getPlotList(tTL, tBR))
		for city in lAreaCities:
			if city.getOwner() in [iIndependent, iIndependent2, iBarbarian, iNative]: iNumMinorCities += 1
			elif city.getOwner() != iPlayer: return False
			
		if 2 * iNumMinorCities > len(lAreaCities): return False
		
		return True
Exemplo n.º 10
0
	def isConquered(self, tConquest):
		iID, iPlayer, iPreferredTarget, tTL, tBR, iNumTargets, iYear, iIntervalTurns = tConquest
	
		iNumMinorCities = 0
		lAreaCities = utils.getAreaCities(utils.getPlotList(tTL, tBR))
		for city in lAreaCities:
			if city.getOwner() in [iIndependent, iIndependent2, iBarbarian, iNative]: iNumMinorCities += 1
			elif city.getOwner() != iPlayer: return False
			
		if 2 * iNumMinorCities > len(lAreaCities): return False
		
		return True
Exemplo n.º 11
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)
Exemplo n.º 12
0
 def possibleTiles(self,
                   tTL,
                   tBR,
                   bWater=False,
                   bTerritory=False,
                   bBorder=False,
                   bImpassable=False,
                   bNearCity=False):
     return [
         tPlot
         for tPlot in utils.getPlotList(tTL, tBR) if self.possibleTile(
             tPlot, bWater, bTerritory, bBorder, bImpassable, bNearCity)
     ]
Exemplo n.º 13
0
 def russianUP(self):
     #pRussia = gc.getPlayer(iRussia)
     #teamRussia = gc.getTeam(pRussia.getTeam())
     for (x, y) in utils.getPlotList(tRussianTopLeft, tRussianBottomRight):
         pPlot = gc.getMap().plot(x, y)
         if pPlot.getOwner() == iRussia:
             iNumUnitsInAPlot = pPlot.getNumUnits()
             if iNumUnitsInAPlot > 0:
                 for i in range(iNumUnitsInAPlot):
                     unit = pPlot.getUnit(i)
                     if teamRussia.isAtWar(unit.getOwner()):
                         ##								print("hp", unit.currHitPoints() )
                         ##								print("damage", unit.getDamage() )
                         unit.changeDamage(8, iRussia)
	def russianUP(self):
		#pRussia = gc.getPlayer(iRussia)
		#teamRussia = gc.getTeam(pRussia.getTeam())
		for (x, y) in utils.getPlotList(tRussianTopLeft, tRussianBottomRight):
			pPlot = gc.getMap().plot(x, y)
			if pPlot.getOwner() == iRussia:
				iNumUnitsInAPlot = pPlot.getNumUnits()
				if iNumUnitsInAPlot > 0:
					for i in range(iNumUnitsInAPlot):
						unit = pPlot.getUnit(i)
						if teamRussia.isAtWar(unit.getOwner()):
##								print("hp", unit.currHitPoints() )
##								print("damage", unit.getDamage() )
							unit.changeDamage(8, iRussia)
Exemplo n.º 15
0
	def selectHolyCity(self, tTL, tBR, tPreferredCity = None, bAIOnly = True):
		if tPreferredCity:
			x, y = tPreferredCity
			if gc.getMap().plot(x, y).isCity():
				if not bAIOnly or utils.getHumanID() != gc.getMap().plot(x, y).getPlotCity().getOwner():
					return tPreferredCity
		
		lCities = [city for city in utils.getAreaCities(utils.getPlotList(tTL, tBR)) if not bAIOnly or city.getOwner() != utils.getHumanID()]
		
		if lCities:
			city = utils.getRandomEntry(lCities)
			return (city.getX(), city.getY())
			
		return None
	def selectHolyCity(self, tTL, tBR, tPreferredCity = None, bAIOnly = True):
		if tPreferredCity:
			x, y = tPreferredCity
			if gc.getMap().plot(x, y).isCity():
				if not bAIOnly or utils.getHumanID() != gc.getMap().plot(x, y).getPlotCity().getOwner():
					return tPreferredCity
		
		lCities = [city for city in utils.getAreaCities(utils.getPlotList(tTL, tBR)) if not bAIOnly or city.getOwner() != utils.getHumanID()]
		
		if lCities:
			city = utils.getRandomEntry(lCities)
			return (city.getX(), city.getY())
			
		return None
Exemplo n.º 17
0
	def spawnConquerors(self, iPlayer, iPreferredTarget, tTL, tBR, iNumTargets, iYear, iIntervalTurns, iWarPlan = WarPlanTypes.WARPLAN_TOTAL):
		lCities = []
		for city in utils.getAreaCities(utils.getPlotList(tTL, tBR)):
			if city.getOwner() != iPlayer and not gc.getTeam(city.getOwner()).isVassal(iPlayer):
				lCities.append(city)
				
		capital = gc.getPlayer(iPlayer).getCapitalCity()
		
		lTargetCities = []
		for i in range(iNumTargets):
			if len(lCities) == 0: break
			
			targetCity = utils.getHighestEntry(lCities, lambda x: -utils.calculateDistance(x.getX(), x.getY(), capital.getX(), capital.getY()) + int(x.getOwner() == iPreferredTarget) * 1000)
			lTargetCities.append(targetCity)
			lCities.remove(targetCity)
			
		lOwners = []
		for city in lTargetCities:
			if city.getOwner() not in lOwners:
				lOwners.append(city.getOwner())
				
		if iPreferredTarget not in lOwners and gc.getPlayer(iPreferredTarget).isAlive():
			gc.getTeam(iPlayer).declareWar(iPreferredTarget, True, iWarPlan)
				
		for iOwner in lOwners:
			gc.getTeam(iPlayer).declareWar(iOwner, True, iWarPlan)
			CyInterface().addMessage(iOwner, False, iDuration, CyTranslator().getText("TXT_KEY_UP_CONQUESTS_TARGET", (gc.getPlayer(iPlayer).getCivilizationShortDescription(0),)), "", 0, "", ColorTypes(iWhite), -1, -1, True, True)
			
		for city in lTargetCities:
			iExtra = 0
			if utils.getHumanID() not in [iPlayer, city.getOwner()]: iExtra = 1 #max(1, gc.getPlayer(iPlayer).getCurrentEra())
			
			tPlot = utils.findNearestLandPlot((city.getX(), city.getY()), iPlayer)
			
			iBestInfantry = utils.getBestInfantry(iPlayer)
			iBestSiege = utils.getBestSiege(iPlayer)
			
			if iPlayer == iGreece:
				iBestInfantry = iHoplite
				iBestSiege = iCatapult
			
			utils.makeUnitAI(iBestInfantry, iPlayer, tPlot, UnitAITypes.UNITAI_ATTACK_CITY, 2 + iExtra)
			utils.makeUnitAI(iBestSiege, iPlayer, tPlot, UnitAITypes.UNITAI_ATTACK_CITY, 1 + 2*iExtra)
			
			if iPlayer == iTamils:
				utils.makeUnitAI(iWarElephant, iPlayer, tPlot, UnitAITypes.UNITAI_ATTACK_CITY, 1)
				
			if iPlayer == iSpain:
				utils.makeUnitAI(utils.getBestCavalry(iPlayer), iPlayer, tPlot, UnitAITypes.UNITAI_ATTACK_CITY, 2 * iExtra)
Exemplo n.º 18
0
	def spawnConquerors(self, iPlayer, iPreferredTarget, tTL, tBR, iNumTargets, iYear, iIntervalTurns, iWarPlan = WarPlanTypes.WARPLAN_TOTAL):
		lCities = []
		for city in utils.getAreaCities(utils.getPlotList(tTL, tBR)):
			if city.getOwner() != iPlayer and not gc.getTeam(city.getOwner()).isVassal(iPlayer):
				lCities.append(city)
				
		capital = gc.getPlayer(iPlayer).getCapitalCity()
		
		lTargetCities = []
		for i in range(iNumTargets):
			if len(lCities) == 0: break
			
			targetCity = utils.getHighestEntry(lCities, lambda x: -utils.calculateDistance(x.getX(), x.getY(), capital.getX(), capital.getY()) + int(x.getOwner() == iPreferredTarget) * 1000)
			lTargetCities.append(targetCity)
			lCities.remove(targetCity)
			
		lOwners = []
		for city in lTargetCities:
			if city.getOwner() not in lOwners:
				lOwners.append(city.getOwner())
				
		if iPreferredTarget not in lOwners and gc.getPlayer(iPreferredTarget).isAlive():
			gc.getTeam(iPlayer).declareWar(iPreferredTarget, True, iWarPlan)
				
		for iOwner in lOwners:
			gc.getTeam(iPlayer).declareWar(iOwner, True, iWarPlan)
			CyInterface().addMessage(iOwner, False, iDuration, CyTranslator().getText("TXT_KEY_UP_CONQUESTS_TARGET", (gc.getPlayer(iPlayer).getCivilizationShortDescription(0),)), "", 0, "", ColorTypes(iWhite), -1, -1, True, True)
			
		for city in lTargetCities:
			iExtra = 0
			if utils.getHumanID() not in [iPlayer, city.getOwner()]: iExtra = 1
			
			tPlot = utils.findNearestLandPlot((city.getX(), city.getY()), iPlayer)
			
			iBestInfantry = utils.getBestInfantry(iPlayer)
			iBestSiege = utils.getBestSiege(iPlayer)
			
			if iPlayer == iGreece:
				iBestInfantry = iGreekHoplite
				iBestSiege = iCatapult
			
			utils.makeUnitAI(iBestInfantry, iPlayer, tPlot, UnitAITypes.UNITAI_ATTACK_CITY, 2 + iExtra)
			utils.makeUnitAI(iBestSiege, iPlayer, tPlot, UnitAITypes.UNITAI_ATTACK_CITY, 1 + 2*iExtra)
			
			if iPlayer == iTamils:
				utils.makeUnitAI(iWarElephant, iPlayer, tPlot, UnitAITypes.UNITAI_ATTACK_CITY, 1)
Exemplo n.º 19
0
def exportAreaExport(lPlots, bWaterException, bPeakException):
    if lPlots:
        BL, TR = getTLBR(lPlots)
        lExceptions = [
            (x, y) for (x, y) in utils.getPlotList(BL, TR)
            if (x, y) not in lPlots and (
                bWaterException and gc.getMap().plot(x, y).isWater()) and (
                    bPeakException and gc.getMap().plot(x, y).isPeak())
        ]

        if bWaterException:
            lExceptions.extend([
                (x, y) for (x, y) in lPlots
                if gc.getMap().plot(x, y).isWater() and (x,
                                                         y) not in lExceptions
            ])
        if bPeakException:
            lExceptions.extend([
                (x, y) for (x, y) in lPlots
                if gc.getMap().plot(x, y).isPeak() and (x,
                                                        y) not in lExceptions
            ])

        file = open(IMAGE_LOCATION + "\Other\\NewArea.txt", 'wt')
        try:
            file.write("# tBL, tTR\n")
            file.write("(" + str(BL) + ",\t" + str(TR) + ")")
            if lExceptions:
                file.write("\n\n# lExceptions\n")
                file.write(str(lExceptions))
        finally:
            file.close()
        sText = "Area exported"
    else:
        sText = "No area selected"
    popup = PyPopup.PyPopup()
    popup.setBodyString(sText)
    popup.launch(True, PopupStates.POPUPSTATE_IMMEDIATE)
Exemplo n.º 20
0
    def checkTurn(self, iGameTurn):

        #handicap level modifier
        iHandicap = gc.getHandicapInfo(
            gc.getGame().getHandicapType()).getBarbarianSpawnModifier()

        # Leoreth: buff certain cities if independent / barbarian (imported from SoI)
        if iGameTurn % 20 == 10:
            for tMinorState in tMinorStates:
                iStartYear, iEndYear, tPlot, lUnitList = tMinorState
                if utils.isYearIn(iStartYear, iEndYear):
                    x, y = tPlot
                    plot = gc.getMap().plot(x, y)
                    iOwner = plot.getOwner()
                    if plot.isCity(
                    ) and plot.getNumUnits() < 4 and iOwner >= iNumPlayers:
                        iUnit = utils.getRandomEntry(lUnitList)
                        utils.makeUnit(iUnit, iOwner, tPlot, 1)

        if utils.isYearIn(-3000, -850):
            if iHandicap >= 0:
                self.checkSpawn(iBarbarian, iWarrior, 1, (76, 46), (99, 53),
                                self.spawnMinors, iGameTurn, 5, 0)

            self.checkSpawn(iBarbarian, iWolf, 1, (75, 54), (104, 64),
                            self.spawnNatives, iGameTurn, 5, 2)
            self.checkSpawn(iBarbarian, iBear, 1, (75, 54), (104, 64),
                            self.spawnNatives, iGameTurn, 5, 4)
            self.checkLimitedSpawn(iBarbarian, iLion, 1, 5, (55, 10), (72, 29),
                                   self.spawnNatives, iGameTurn, 5, 1)
            self.checkLimitedSpawn(iBarbarian, iPanther, 1, 5, (55, 10),
                                   (72, 29), self.spawnNatives, iGameTurn, 5,
                                   3)

        #celts
        if utils.isYearIn(-650, -110):
            self.checkSpawn(iCeltia, iGallicWarrior, 1, (49, 46), (65, 52),
                            self.spawnMinors, iGameTurn, 6, 0)
            if iHandicap >= 0:
                self.checkSpawn(iCeltia, iAxeman, 1, (49, 46), (65, 52),
                                self.spawnMinors, iGameTurn, 8, 5,
                                ["TXT_KEY_ADJECTIVE_GAUL"])

        #norse
        if utils.isYearIn(-650, 550):
            self.checkSpawn(iBarbarian, iGalley, 1, (50, 49), (61, 55),
                            self.spawnPirates, iGameTurn, 20, 0,
                            ["TXT_KEY_ADJECTIVE_NORSE"])

        #mongolia
        if utils.isYearIn(-210, 300):
            self.checkSpawn(iBarbarian, iHorseman, 3 + iHandicap, (94, 48),
                            (107, 54), self.spawnNomads, iGameTurn,
                            8 - iHandicap, 0, ["TXT_KEY_ADJECTIVE_XIONGNU"])
        elif utils.isYearIn(300, 900):
            iNumUnits = 2 + iHandicap
            self.checkSpawn(
                iBarbarian, iHorseArcher, iNumUnits, (91, 50), (107, 54),
                self.spawnNomads, iGameTurn, 7 - iHandicap, 0,
                ["TXT_KEY_ADJECTIVE_GOKTURK", "TXT_KEY_ADJECTIVE_UIGHUR"])
        elif utils.isYearIn(900, 1100):
            iNumUnits = 1 + iHandicap
            self.checkSpawn(
                iBarbarian, iKeshik, iNumUnits, (94, 48), (107, 54),
                self.spawnInvaders, iGameTurn, 6, 0,
                ["TXT_KEY_ADJECTIVE_JURCHEN", "TXT_KEY_ADJECTIVE_KHITAN"])

        #tibet
        if utils.isYearIn(-350, 200):
            self.checkSpawn(iBarbarian, iLightSwordsman, 1 + iHandicap,
                            (92, 41), (99, 45), self.spawnMinors, iGameTurn,
                            10 - iHandicap, 3, ["TXT_KEY_ADJECTIVE_TIBETAN"])
        elif utils.isYearIn(200, 1100):
            self.checkSpawn(iBarbarian, iSwordsman, 1 + iHandicap, (92, 41),
                            (99, 45), self.spawnMinors, iGameTurn,
                            10 - iHandicap, 3, ["TXT_KEY_ADJECTIVE_TIBETAN"])

        # Deccan barbarians
        if utils.isYearIn(-1000, 1200):
            iUnit = iArcher
            iStrength = iHandicap
            if iGameTurn >= getTurnForYear(-500): iUnit = iAxeman
            if iGameTurn >= getTurnForYear(0): iStrength += 1
            if iGameTurn >= getTurnForYear(200): iUnit = iSwordsman

            self.checkSpawn(iBarbarian, iUnit, iStrength, (87, 23), (96, 37),
                            self.spawnInvaders, iGameTurn, 8 - iHandicap, 0,
                            ["Hindi"])

        # elephants in india pre-khmer
        if utils.isYearIn(-210, 700):
            self.checkSpawn(iBarbarian, iWarElephant, 1, (86, 31), (100, 41),
                            self.spawnInvaders, iGameTurn, 8 - iHandicap, 4)

        #Indo-Scythians
        if utils.isYearIn(-200, 400):
            self.checkSpawn(iBarbarian, iHorseman, 2, (84, 40), (89, 43),
                            self.spawnNomads, iGameTurn, 8 - iHandicap, 4,
                            ["TXT_KEY_ADJECTIVE_INDO_SCYTHIAN"])

        #Kushana
        if utils.isYearIn(30, 220):
            self.checkSpawn(iBarbarian, iAsvaka, 3 + iHandicap, (84, 40),
                            (89, 43), self.spawnInvaders, iGameTurn, 8, 3,
                            ["TXT_KEY_ADJECTIVE_KUSHANA"])

        #Hephtalites
        if utils.isYearIn(400, 550):
            self.checkSpawn(iBarbarian, iHorseArcher, 2 + iHandicap, (84, 40),
                            (89, 43), self.spawnInvaders, iGameTurn,
                            5 - iHandicap, 2,
                            ["TXT_KEY_ADJECTIVE_HEPHTHALITE"])

        # Holkans in classical Mesoamerica
        if utils.isYearIn(100, 600):
            self.checkSpawn(iBarbarian, iHolkan, 1, (17, 31), (25, 37),
                            self.spawnUprising, iGameTurn, 6, 4)
        elif utils.isYearIn(600, 1000):
            self.checkSpawn(iBarbarian, iHolkan, 1, (17, 31), (25, 37),
                            self.spawnUprising, iGameTurn, 4, 2)

        #pirates in Mediterranean
        if utils.isYearIn(-210, 50):
            self.checkSpawn(iBarbarian, iWarGalley, 1, (49, 37), (72, 44),
                            self.spawnPirates, iGameTurn, 8, 0)
        #pirates in Barbary coast
        if not gc.getPlayer(iMoors).isAlive():
            if utils.isYearIn(-50, 700):
                self.checkSpawn(iBarbarian, iWarGalley, 1, (46, 30), (62, 39),
                                self.spawnPirates, iGameTurn, 18, 0)
            elif utils.isYearIn(700, 1400):
                self.checkSpawn(iBarbarian, iWarGalley, 1, (46, 30), (62, 39),
                                self.spawnPirates, iGameTurn, 8, 0)
        #pirates in Indian ocean
        if utils.isYearIn(-650, 700):
            self.checkSpawn(iBarbarian, iWarGalley, 1, (72, 20), (91, 36),
                            self.spawnPirates, iGameTurn, 18, 0)
        elif utils.isYearIn(700, 1700):
            self.checkSpawn(iBarbarian, iHeavyGalley, 1, (72, 20), (91, 36),
                            self.spawnPirates, iGameTurn, 10, 0)

        # Leoreth: Barbarians in Anatolia (Hittites), replace Hattusas spawn
        if utils.isYearIn(-2000, -800):
            self.checkSpawn(iBarbarian, iHuluganni, 1 + iHandicap, (68, 42),
                            (74, 45), self.spawnInvaders, iGameTurn, 16, 0,
                            ["TXT_KEY_ADJECTIVE_HITTITE"])

        #barbarians in europe
        if utils.isYearIn(-210, 470):
            self.checkSpawn(iBarbarian, iAxeman, 3 + iHandicap, (50, 45),
                            (63, 52), self.spawnInvaders, iGameTurn, 10, 0,
                            ["TXT_KEY_ADJECTIVE_GERMANIC"])
            self.checkSpawn(iBarbarian, iAxeman, 2 + iHandicap, (64, 49),
                            (69, 55), self.spawnInvaders, iGameTurn, 12, 2,
                            ["TXT_KEY_ADJECTIVE_GERMANIC"])
        # Leoreth: begins 100 AD instead of 50 AD
        if utils.isYearIn(100, 470):
            self.checkSpawn(iBarbarian, iSwordsman, 3, (58, 45), (70, 55),
                            self.spawnInvaders, iGameTurn, 8, 5,
                            ["TXT_KEY_ADJECTIVE_GERMANIC"])
        if utils.isYearIn(300, 550):
            self.checkSpawn(iBarbarian, iAxeman, 4 + iHandicap, (49, 41),
                            (56, 52), self.spawnInvaders, iGameTurn, 5, 4,
                            ["TXT_KEY_ADJECTIVE_VISIGOTHIC"])
            self.checkSpawn(iBarbarian, iSwordsman, 4 + iHandicap, (49, 41),
                            (57, 52), self.spawnInvaders, iGameTurn, 5, 2,
                            ["TXT_KEY_ADJECTIVE_VISIGOTHIC"])
            self.checkSpawn(iBarbarian, iHorseArcher, 3, (55, 49), (65, 53),
                            self.spawnInvaders, iGameTurn, 5, 0,
                            ["TXT_KEY_ADJECTIVE_HUNNIC"])
        if utils.isYearIn(300, 700):
            self.checkSpawn(iBarbarian, iHorseArcher, 3 + iHandicap, (58, 50),
                            (88, 53), self.spawnInvaders, iGameTurn, 3, 2,
                            ["TXT_KEY_ADJECTIVE_HUNNIC"])

        #Leoreth: barbarians in Balkans / Black Sea until the High Middle Ages (Bulgarians, Cumans, Pechenegs)
        if utils.isYearIn(680, 1000):
            self.checkSpawn(
                iBarbarian, iHorseArcher, 3 + iHandicap, (64, 45), (69, 49),
                self.spawnInvaders, iGameTurn, 6, 2,
                ["TXT_KEY_ADJECTIVE_AVAR", "TXT_KEY_ADJECTIVE_BULGAR"])
        if utils.isYearIn(900, 1200):
            self.checkSpawn(iBarbarian, iHorseArcher, 3 + iHandicap, (68, 48),
                            (78, 50), self.spawnInvaders, iGameTurn, 8, 5,
                            ["TXT_KEY_ADJECTIVE_CUMAN"])

        #barbarians in central asia
        if utils.isYearIn(-1600, -850):
            self.checkLimitedSpawn(iBarbarian, iVulture, 1, 3, (74, 34),
                                   (78, 44), self.spawnNomads, iGameTurn,
                                   8 - iHandicap, 2,
                                   ["TXT_KEY_ADJECTIVE_ASSYRIAN"])
        elif utils.isYearIn(-850, 300):
            self.checkLimitedSpawn(iBarbarian, iVulture, 1, 4, (73, 38),
                                   (78, 44), self.spawnNomads, iGameTurn,
                                   10 - iHandicap, 2,
                                   ["TXT_KEY_ADJECTIVE_ASSYRIAN"])
            self.checkSpawn(iBarbarian, iHorseman, 2 + iHandicap, (79, 41),
                            (84, 49), self.spawnInvaders, iGameTurn,
                            7 - iHandicap, 2, ["TXT_KEY_ADJECTIVE_PARTHIAN"])
        elif utils.isYearIn(300, 700):
            #if utils.getScenario() == i3000BC:  #late start condition
            self.checkSpawn(iBarbarian, iHorseArcher, 2 + iHandicap, (78, 42),
                            (88, 50), self.spawnNomads, iGameTurn,
                            8 - iHandicap, 2, ["TXT_KEY_ADJECTIVE_TURKIC"])
        elif utils.isYearIn(700, 1040):
            #if utils.getScenario() == i3000BC:  #late start condition
            self.checkSpawn(iBarbarian, iHorseArcher, 2 + iHandicap, (78, 42),
                            (90, 52), self.spawnNomads, iGameTurn,
                            6 - iHandicap, 2, ["TXT_KEY_ADJECTIVE_TURKIC"])

        # late Central Asian barbarians
        iSteppeUnit = iKeshik
        iExtra = iHandicap

        if utils.isYearIn(1200, 1600):
            if not utils.getAreaCitiesCiv(
                    iMongolia, utils.getPlotList((70, 48), (80, 59))):
                self.checkSpawn(
                    iBarbarian, iSteppeUnit, 1 + iExtra, (74, 47), (81, 47),
                    self.spawnNomads, iGameTurn, 10 - iHandicap, 5,
                    ["TXT_KEY_ADJECTIVE_TATAR", "TXT_KEY_ADJECTIVE_NOGAI"])
        if utils.isYearIn(1400, 1700):
            if utils.getAreaCities(utils.getPlotList((80, 47), (88, 53))):
                self.checkSpawn(
                    iBarbarian, iSteppeUnit, 1 + iExtra, (80, 47), (88, 53),
                    self.spawnNomads, iGameTurn, 10 - 2 * iHandicap, 2,
                    ["TXT_KEY_ADJECTIVE_UZBEK", "TXT_KEY_ADJECTIVE_KAZAKH"])

        #barbarians in Elam
        if utils.isYearIn(-1600, -1000):
            self.checkSpawn(iBarbarian, iChariot, 1, (81, 37), (87, 45),
                            self.spawnMinors, iGameTurn, 9 - iHandicap, 0,
                            ["TXT_KEY_ADJECTIVE_ELAMITE"])

        #barbarians in north africa
        if utils.isYearIn(-210, 50):
            self.checkSpawn(iBarbarian, iNumidianCavalry, 1, (54, 31),
                            (67, 35), self.spawnNomads, iGameTurn,
                            9 - iHandicap, 3, ["TXT_KEY_ADJECTIVE_BERBER"])
        elif utils.isYearIn(50, 900):
            if utils.getScenario() == i3000BC:  #late start condition
                self.checkSpawn(iBarbarian, iNumidianCavalry, 1 + iHandicap,
                                (54, 31), (67, 35), self.spawnNomads,
                                iGameTurn, 10 - iHandicap, 5,
                                ["TXT_KEY_ADJECTIVE_BERBER"])
        elif utils.isYearIn(900, 1800):
            self.checkSpawn(iBarbarian, iCamelArcher, 1, (54, 27), (67, 35),
                            self.spawnNomads, iGameTurn, 10 - iHandicap, 4,
                            ["TXT_KEY_ADJECTIVE_BERBER"])

        #camels in arabia
        if utils.isYearIn(190, 550):
            self.checkSpawn(iBarbarian, iCamelArcher, 1, (73, 30), (82, 36),
                            self.spawnNomads, iGameTurn, 9 - iHandicap, 7,
                            ["TXT_KEY_ADJECTIVE_BEDOUIN"])
        if utils.isYearIn(-800, 1300):
            iNumUnits = iHandicap
            if utils.getScenario() == i3000BC: iNumUnits += 1
            self.checkSpawn(iBarbarian, iMedjay, iNumUnits, (66, 28), (71, 34),
                            self.spawnUprising, iGameTurn, 12, 4,
                            ["TXT_KEY_ADJECTIVE_NUBIAN"])
        if utils.isYearIn(450, 1600):
            if utils.getScenario() == i3000BC:
                self.checkSpawn(iNative, iImpi, 2 + iHandicap, (60, 10),
                                (72, 27), self.spawnNatives, iGameTurn, 10, 4)
            else:
                self.checkSpawn(iNative, iImpi, 2 + iHandicap, (60, 10),
                                (72, 27), self.spawnNatives, iGameTurn, 15, 4)
        elif utils.isYearIn(1600, 1800):
            self.checkSpawn(iNative, iPombos, 2 + iHandicap, (60, 10),
                            (72, 27), self.spawnNatives, iGameTurn, 10, 4)

        #west africa
        if utils.isYearIn(450, 1700):
            if iGameTurn < getTurnForYear(1300):
                sAdj = ["TXT_KEY_ADJECTIVE_GHANAIAN"]
            else:
                sAdj = ["TXT_KEY_ADJECTIVE_SONGHAI"]
            self.checkSpawn(iNative, iImpi, 2, (48, 22), (63, 29),
                            self.spawnMinors, iGameTurn, 16, 10, sAdj)

        if utils.isYearIn(1200, 1700):
            self.checkSpawn(iBarbarian, iFarari, 1, (48, 26), (65, 37),
                            self.spawnMinors, iGameTurn, 16, 4, sAdj)

        #American natives
        if utils.isYearIn(600, 1100):
            self.checkSpawn(iNative, iDogSoldier, 1 + iHandicap, (15, 38),
                            (24, 47), self.spawnNatives, iGameTurn, 20, 0)
            if utils.getScenario() == i3000BC:  #late start condition
                self.checkSpawn(iNative, iJaguar, 3, (15, 38), (24, 47),
                                self.spawnNatives, iGameTurn,
                                16 - 2 * iHandicap, 10)
            else:  #late start condition
                self.checkSpawn(iNative, iJaguar, 2, (15, 38), (24, 47),
                                self.spawnNatives, iGameTurn,
                                16 - 2 * iHandicap, 10)
        if utils.isYearIn(1300, 1600):
            self.checkSpawn(iNative, iDogSoldier, 2 + iHandicap, (15, 38),
                            (24, 47), self.spawnNatives, iGameTurn, 8, 0)
        if utils.isYearIn(1400, 1800):
            self.checkSpawn(iNative, iDogSoldier, 1 + iHandicap, (11, 44),
                            (33, 51), self.spawnUprising, iGameTurn, 12, 0)
            self.checkSpawn(iNative, iDogSoldier, 1 + iHandicap, (11, 44),
                            (33, 51), self.spawnUprising, iGameTurn, 12, 6)
        if utils.isYearIn(1300, 1600):
            if iGameTurn % 18 == 0:
                if not gc.getMap().plot(27, 29).isUnit():
                    utils.makeUnitAI(iDogSoldier, iNative, (27, 29),
                                     UnitAITypes.UNITAI_ATTACK, 2 + iHandicap)
            elif iGameTurn % 18 == 9:
                if not gc.getMap().plot(30, 13).isUnit():
                    utils.makeUnitAI(iDogSoldier, iNative, (30, 13),
                                     UnitAITypes.UNITAI_ATTACK, 2 + iHandicap)

        if utils.isYearIn(1700, 1900):
            self.checkSpawn(iNative, iMountedBrave, 1 + iHandicap, (15, 44),
                            (24, 52), self.spawnUprising, iGameTurn,
                            12 - iHandicap, 2)

        if utils.isYearIn(1500, 1850):
            self.checkSpawn(iNative, iMohawk, 1, (24, 46), (30, 51),
                            self.spawnUprising, iGameTurn, 8, 4)

        #pirates in the Caribbean
        if utils.isYearIn(1600, 1800):
            self.checkSpawn(iNative, iPrivateer, 1, (24, 32), (35, 46),
                            self.spawnPirates, iGameTurn, 5, 0)
        #pirates in Asia
        if utils.isYearIn(1500, 1900):
            self.checkSpawn(iNative, iPrivateer, 1, (72, 24), (110, 36),
                            self.spawnPirates, iGameTurn, 8, 0)

        if iGameTurn < getTurnForYear(
                tMinorCities[len(tMinorCities) - 1][0]) + 10:
            self.foundMinorCities(iGameTurn)

        if iGameTurn == getTurnForYear(tBirth[iInca]):
            if utils.getHumanID() == iInca:
                utils.makeUnit(iAucac, iNative, (24, 26), 1)
                utils.makeUnit(iAucac, iNative, (25, 23), 1)
Exemplo n.º 21
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
Exemplo n.º 22
0
    def checkTurn(self, iGameTurn):

        #handicap level modifier
        iHandicap = gc.getHandicapInfo(
            gc.getGame().getHandicapType()).getBarbarianSpawnModifier()

        # Leoreth: buff certain cities if independent / barbarian (imported from SoI)
        if iGameTurn % 20 == 10:
            for tMinorState in tMinorStates:
                iStartYear, iEndYear, tPlot, lUnitList = tMinorState
                if utils.isYearIn(iStartYear, iEndYear):
                    x, y = tPlot
                    plot = gc.getMap().plot(x, y)
                    iOwner = plot.getOwner()
                    if plot.isCity(
                    ) and plot.getNumUnits() < 4 and iOwner >= iNumPlayers:
                        iUnit = utils.getRandomEntry(lUnitList)
                        utils.makeUnit(iUnit, iOwner, tPlot, 1)

        if utils.isYearIn(-100, 1600):
            # Brown Bear in Chukchi
            self.checkLimitedSpawn(iBarbarian, iPolarBear, 1, 5, (140, 65),
                                   (148, 76), self.spawnBears, iGameTurn, 10,
                                   1)
            # Brown Bear and American Black Bear in Alaska and Western Canada
            self.checkLimitedSpawn(iBarbarian, iPolarBear, 1, 5, (0, 67),
                                   (24, 77), self.spawnBears, iGameTurn, 5, 3)
            # Polar Bear in Greenland and Eastern Canada
            self.checkLimitedSpawn(iBarbarian, iPolarBear, 1, 5, (25, 63),
                                   (44, 77), self.spawnBears, iGameTurn, 5, 5)

        if utils.isYearIn(-3000, -850):
            if iHandicap >= 0:
                self.checkSpawn(iBarbarian, iWarrior, 1, (92, 53), (116, 62),
                                self.spawnMinors, iGameTurn, 5, 0)

            # Wolves and Brown Bears in Russia and Siberia
            self.checkSpawn(iBarbarian, iWolf, 1, (89, 66), (125, 75),
                            self.spawnNatives, iGameTurn, 5, 2)
            self.checkSpawn(iBarbarian, iBear, 1, (89, 66), (125, 75),
                            self.spawnNatives, iGameTurn, 5, 4)

            # Panthers, Hyenas, and Lions in South Africa
            self.checkSpawn(iBarbarian, iLion, 1, (67, 12), (84, 34),
                            self.spawnNatives, iGameTurn, 4, 1)
            self.checkSpawn(iBarbarian, iPanther, 1, (67, 12), (84, 34),
                            self.spawnNatives, iGameTurn, 4, 3)
            self.checkLimitedSpawn(iBarbarian, iHyena, 1, 5, (67, 12),
                                   (84, 34), self.spawnNatives, iGameTurn, 5,
                                   3)

            # Panthers and Tigers in India, South China, Indochina, and Indonesia
            self.checkLimitedSpawn(iBarbarian, iPanther, 1, 5, (101, 32),
                                   (130, 49), self.spawnNatives, iGameTurn, 5,
                                   1)
            self.checkLimitedSpawn(iBarbarian, iTiger, 1, 5, (101, 32),
                                   (130, 49), self.spawnNatives, iGameTurn, 5,
                                   1)

            #Asian Black Bears in China, Japan, Manchuria, Vietnam, and Korea
            self.checkLimitedSpawn(iBarbarian, iBear, 1, 5, (120, 35),
                                   (141, 66), self.spawnNatives, iGameTurn, 5,
                                   3)

            # Jaguars in Brazil, Colombia, and Mesoamerica
            self.checkLimitedSpawn(iBarbarian, iJaguarAnimal, 1, 5, (34, 24),
                                   (49, 36), self.spawnNatives, iGameTurn, 5,
                                   1)
            self.checkLimitedSpawn(iBarbarian, iJaguarAnimal, 1, 5, (26, 29),
                                   (40, 38), self.spawnNatives, iGameTurn, 5,
                                   3)
            self.checkLimitedSpawn(iBarbarian, iJaguarAnimal, 1, 5, (19, 36),
                                   (30, 45), self.spawnNatives, iGameTurn, 5,
                                   3)

        #celts
        if utils.isYearIn(-650, -110):
            self.checkSpawn(iBarbarian, iSwordsman, 1, (57, 56), (76, 61),
                            self.spawnMinors, iGameTurn, 6, 0)
            if iHandicap >= 0:
                self.checkSpawn(iBarbarian, iAxeman, 1, (57, 56), (76, 61),
                                self.spawnMinors, iGameTurn, 8, 5,
                                ["TXT_KEY_ADJECTIVE_GAUL"])

        #norse
        if utils.isYearIn(-650, 550):
            self.checkSpawn(iBarbarian, iGalley, 1, (55, 59), (66, 68),
                            self.spawnPirates, iGameTurn, 20, 0,
                            ["TXT_KEY_ADJECTIVE_NORSE"])

        #mongolia
        if utils.isYearIn(-210, 400):
            self.checkSpawn(iBarbarian, iHorseArcher, 3 + iHandicap, (118, 55),
                            (129, 58), self.spawnNomads, iGameTurn,
                            7 - iHandicap, 0, ["TXT_KEY_ADJECTIVE_XIONGNU"])
        elif utils.isYearIn(-210, 400):
            self.checkSpawn(iBarbarian, iHorseArcher, 1 + iHandicap, (106, 54),
                            (114, 59), self.spawnNomads, iGameTurn,
                            7 - iHandicap, 0, ["TXT_KEY_ADJECTIVE_XIONGNU"])
        elif utils.isYearIn(-210, 400):
            self.checkSpawn(iBarbarian, iHorseArcher, 1 + iHandicap, (114, 60),
                            (125, 65), self.spawnNomads, iGameTurn,
                            7 - iHandicap, 0, ["TXT_KEY_ADJECTIVE_XIONGNU"])
        elif utils.isYearIn(400, 900):
            iNumUnits = 3 + iHandicap
            self.checkSpawn(
                iBarbarian, iHorseArcher, iNumUnits, (110, 58), (129, 65),
                self.spawnNomads, iGameTurn, 6 - iHandicap, 0,
                ["TXT_KEY_ADJECTIVE_GOKTURK", "TXT_KEY_ADJECTIVE_UIGHUR"])
        elif utils.isYearIn(900, 1100):
            iNumUnits = 3 + iHandicap
            self.checkSpawn(
                iBarbarian, iKeshik, iNumUnits, (110, 58), (129, 65),
                self.spawnInvaders, iGameTurn, 6, 0,
                ["TXT_KEY_ADJECTIVE_JURCHEN", "TXT_KEY_ADJECTIVE_KHITAN"])

        #tibet
        if utils.isYearIn(-350, 200):
            self.checkSpawn(iBarbarian, iLightSwordsman, 1 + iHandicap,
                            (107, 48), (116, 52), self.spawnMinors, iGameTurn,
                            10 - iHandicap, 3, ["TXT_KEY_ADJECTIVE_TIBETAN"])
        elif utils.isYearIn(200, 1100):
            self.checkSpawn(iBarbarian, iSwordsman, 1 + iHandicap, (107, 48),
                            (116, 52), self.spawnMinors, iGameTurn,
                            10 - iHandicap, 3, ["TXT_KEY_ADJECTIVE_TIBETAN"])

        # Deccan barbarians
        if utils.isYearIn(-1000, 1200):
            iUnit = iArcher
            iStrength = iHandicap
            if iGameTurn >= getTurnForYear(-500): iUnit = iAxeman
            if iGameTurn >= getTurnForYear(0): iStrength += 1
            if iGameTurn >= getTurnForYear(200): iUnit = iSwordsman

            self.checkSpawn(iBarbarian, iUnit, iStrength, (101, 31), (111, 42),
                            self.spawnInvaders, iGameTurn, 8 - iHandicap, 0,
                            ["Hindi"])

        # elephants in india pre-khmer
        if utils.isYearIn(-210, 700):
            self.checkSpawn(iBarbarian, iWarElephant, 1, (103, 35), (117, 45),
                            self.spawnInvaders, iGameTurn, 8 - iHandicap, 4)

        # elephants in africa
        if utils.isYearIn(1110, 1450):
            self.checkSpawn(iBarbarian, iWarElephant, 2, (75, 18), (83, 25),
                            self.spawnInvaders, iGameTurn, 8 - iHandicap, 4)

        # Longbowman in africa
        if utils.isYearIn(1450, 1600):
            self.checkSpawn(iBarbarian, iLongbowman, 2, (75, 18), (83, 25),
                            self.spawnInvaders, iGameTurn, 8 - iHandicap, 4)

        # OromoWarrior in africa
        if utils.isYearIn(1610, 1850):
            self.checkSpawn(iBarbarian, iOromoWarrior, 2, (75, 18), (83, 25),
                            self.spawnInvaders, iGameTurn, 8 - iHandicap, 4)

        #Indo-Scythians
        if utils.isYearIn(-200, 400):
            self.checkSpawn(iBarbarian, iHorseman, 2, (97, 47), (104, 51),
                            self.spawnNomads, iGameTurn, 8 - iHandicap, 4,
                            ["TXT_KEY_ADJECTIVE_INDO_SCYTHIAN"])

        #Kushana
        if utils.isYearIn(30, 220):
            self.checkSpawn(iBarbarian, iHorseman, 3 + iHandicap, (97, 47),
                            (104, 51), self.spawnInvaders, iGameTurn, 8, 3,
                            ["TXT_KEY_ADJECTIVE_KUSHANA"])

        #Hephtalites
        if utils.isYearIn(400, 550):
            self.checkSpawn(iBarbarian, iHorseArcher, 2 + iHandicap, (97, 47),
                            (104, 51), self.spawnInvaders, iGameTurn,
                            5 - iHandicap, 2,
                            ["TXT_KEY_ADJECTIVE_HEPHTHALITE"])

        # Holkans in classical Mesoamerica
        if utils.isYearIn(-200, 100):
            self.checkSpawn(iBarbarian, iHolkan, 1, (15, 36), (27, 44),
                            self.spawnUprising, iGameTurn, 7, 5)
        if utils.isYearIn(100, 600):
            self.checkSpawn(iBarbarian, iHolkan, 1, (15, 36), (27, 44),
                            self.spawnUprising, iGameTurn, 6, 4)
        elif utils.isYearIn(600, 1000):
            self.checkSpawn(iBarbarian, iHolkan, 1, (15, 36), (27, 44),
                            self.spawnUprising, iGameTurn, 4, 2)

    # Picta Aucacs in pre-Incan Andes
        if utils.isYearIn(800, 1100):
            self.checkSpawn(iBarbarian, iPictaAucac, 1, (29, 17), (33, 24),
                            self.spawnUprising, iGameTurn, 4, 2)

        # Jaguars in classical Mesoamerica
        if utils.isYearIn(150, 500):
            self.checkSpawn(iBarbarian, iJaguar, 1, (15, 36), (27, 44),
                            self.spawnUprising, iGameTurn, 6, 4)
        elif utils.isYearIn(500, 1150):
            self.checkSpawn(iBarbarian, iJaguar, 1, (15, 36), (27, 44),
                            self.spawnUprising, iGameTurn, 4, 2)

        #pirates in Mediterranean
        if utils.isYearIn(-210, 50):
            self.checkSpawn(iBarbarian, iWarGalley, 1, (55, 44), (84, 54),
                            self.spawnPirates, iGameTurn, 8, 0)

        #pirates in Barbary coast
        if not gc.getPlayer(iMoors).isAlive():
            if utils.isYearIn(-50, 700):
                self.checkSpawn(iBarbarian, iWarGalley, 1, (52, 41), (72, 49),
                                self.spawnPirates, iGameTurn, 18, 0)
            elif utils.isYearIn(700, 1400):
                self.checkSpawn(iBarbarian, iWarGalley, 1, (52, 41), (72, 49),
                                self.spawnPirates, iGameTurn, 8, 0)
        #pirates in Indian ocean
        if utils.isYearIn(-650, 700):
            self.checkSpawn(iBarbarian, iWarGalley, 1, (84, 24), (106, 42),
                            self.spawnPirates, iGameTurn, 18, 0)
        elif utils.isYearIn(700, 1700):
            self.checkSpawn(iBarbarian, iHeavyGalley, 1, (84, 24), (106, 42),
                            self.spawnPirates, iGameTurn, 10, 0)

        # Leoreth: Barbarians in Anatolia (Hittites), replace Hattusas spawn
        #if utils.isYearIn(-2000, -800):
        #self.checkSpawn(iBarbarian, iHuluganni, 1 + iHandicap, (81, 51), (86, 55), self.spawnInvaders, iGameTurn, 16, 0, ["TXT_KEY_ADJECTIVE_HITTITE"])
        if utils.isYearIn(-2000, -800):
            self.checkSpawn(iBarbarian, iChariot, 1 + iHandicap, (81, 51),
                            (86, 55), self.spawnInvaders, iGameTurn, 16, 0)

        #barbarians in europe
        if utils.isYearIn(-210, 470):
            self.checkSpawn(iBarbarian, iAxeman, 3 + iHandicap, (57, 55),
                            (74, 61), self.spawnInvaders, iGameTurn, 10, 0,
                            ["TXT_KEY_ADJECTIVE_GERMANIC"])
            self.checkSpawn(iBarbarian, iAxeman, 2 + iHandicap, (74, 58),
                            (81, 66), self.spawnInvaders, iGameTurn, 12, 2,
                            ["TXT_KEY_ADJECTIVE_GERMANIC"])
        # Leoreth: begins 100 AD instead of 50 AD
        if utils.isYearIn(100, 470):
            self.checkSpawn(iBarbarian, iSwordsman, 4, (66, 55), (82, 66),
                            self.spawnInvaders, iGameTurn, 8, 5,
                            ["TXT_KEY_ADJECTIVE_GERMANIC"])
        if utils.isYearIn(300, 550):
            self.checkSpawn(iBarbarian, iAxeman, 4 + iHandicap, (55, 49),
                            (63, 61), self.spawnInvaders, iGameTurn, 5, 4,
                            ["TXT_KEY_ADJECTIVE_VISIGOTHIC"])
            self.checkSpawn(iBarbarian, iSwordsman, 4 + iHandicap, (55, 49),
                            (63, 61), self.spawnInvaders, iGameTurn, 5, 2,
                            ["TXT_KEY_ADJECTIVE_VISIGOTHIC"])
            self.checkSpawn(iBarbarian, iHorseArcher, 4, (62, 58), (76, 64),
                            self.spawnInvaders, iGameTurn, 5, 0,
                            ["TXT_KEY_ADJECTIVE_HUNNIC"])
        if utils.isYearIn(300, 700):
            self.checkSpawn(iBarbarian, iHorseArcher, 3 + iHandicap, (65, 60),
                            (106, 63), self.spawnInvaders, iGameTurn, 3, 2,
                            ["TXT_KEY_ADJECTIVE_HUNNIC"])

        #Leoreth: barbarians in Balkans / Black Sea until the High Middle Ages (Bulgarians, Cumans, Pechenegs)
        if utils.isYearIn(680, 1000):
            self.checkSpawn(
                iBarbarian, iHorseArcher, 3 + iHandicap, (73, 55), (81, 60),
                self.spawnInvaders, iGameTurn, 6, 2,
                ["TXT_KEY_ADJECTIVE_AVAR", "TXT_KEY_ADJECTIVE_BULGAR"])
        if utils.isYearIn(900, 1200):
            self.checkSpawn(iBarbarian, iHorseArcher, 3 + iHandicap, (79, 58),
                            (92, 61), self.spawnInvaders, iGameTurn, 8, 5,
                            ["TXT_KEY_ADJECTIVE_CUMAN"])

        #1SDAN: Qarmatians (Abu Tahir al-Jannabi)
        if utils.isYearIn(900, 1000):
            self.checkSpawn(iBarbarian, iHorseArcher, 1 + iHandicap, (91, 39),
                            (95, 41), self.spawnInvaders, iGameTurn, 3, 2,
                            ["TXT_KEY_ADJECTIVE_QARMATIAN"])

        #barbarians in central asia
        if utils.isYearIn(-1600, -850):
            self.checkLimitedSpawn(iBarbarian, iVulture, 1, 3, (84, 42),
                                   (90, 44), self.spawnNomads, iGameTurn,
                                   8 - iHandicap, 2,
                                   ["TXT_KEY_ADJECTIVE_ASSYRIAN"])
        elif utils.isYearIn(-850, -200):
            self.checkSpawn(iBarbarian, iHorseman, 1 + iHandicap, (80, 56),
                            (90, 60), self.spawnInvaders, iGameTurn,
                            10 - 2 * iHandicap, 3,
                            ["TXT_KEY_ADJECTIVE_SCYTHIAN"])
        elif utils.isYearIn(-200, 600):
            self.checkSpawn(iBarbarian, iHorseman, 2 + iHandicap, (92, 49),
                            (98, 59), self.spawnInvaders, iGameTurn,
                            7 - iHandicap, 2, ["TXT_KEY_ADJECTIVE_PARTHIAN"])
        elif utils.isYearIn(600, 900):
            #if utils.getScenario() == i3000BC:  #late start condition
            self.checkSpawn(iBarbarian, iOghuz, 2 + iHandicap, (91, 50),
                            (103, 58), self.spawnNomads, iGameTurn,
                            8 - iHandicap, 2)
        elif utils.isYearIn(900, 1040):
            #if utils.getScenario() == i3000BC:  #late start condition
            self.checkSpawn(iBarbarian, iOghuz, 2 + iHandicap, (91, 50),
                            (106, 62), self.spawnNomads, iGameTurn,
                            6 - iHandicap, 2)

        # late Central Asian barbarians
        if utils.isYearIn(1200, 1600):
            if not utils.getAreaCitiesCiv(
                    iMongolia, utils.getPlotList((82, 58), (95, 70))):
                self.checkSpawn(
                    iBarbarian, iKeshik, 1 + iHandicap, (88, 57), (94, 61),
                    self.spawnNomads, iGameTurn, 10 - iHandicap, 5,
                    ["TXT_KEY_ADJECTIVE_TATAR", "TXT_KEY_ADJECTIVE_NOGAI"])
        if utils.isYearIn(1400, 1700):
            if utils.getAreaCities(utils.getPlotList((91, 58), (106, 62))):
                self.checkSpawn(
                    iBarbarian, iKeshik, 1 + iHandicap, (91, 58), (106, 62),
                    self.spawnNomads, iGameTurn, 10 - 2 * iHandicap, 2,
                    ["TXT_KEY_ADJECTIVE_UZBEK", "TXT_KEY_ADJECTIVE_KAZAKH"])

        #barbarians in Elam
        if utils.isYearIn(-1600, -1000):
            self.checkSpawn(iBarbarian, iChariot, 1, (92, 43), (99, 50),
                            self.spawnMinors, iGameTurn, 9 - iHandicap, 0,
                            ["TXT_KEY_ADJECTIVE_ELAMITE"])

        #barbarians in north africa
        if utils.isYearIn(-210, 50):
            self.checkSpawn(iBarbarian, iCamelRider, 1, (60, 38), (78, 42),
                            self.spawnNomads, iGameTurn, 9 - iHandicap, 3,
                            ["TXT_KEY_ADJECTIVE_BERBER"])
        elif utils.isYearIn(50, 900):
            if utils.getScenario() == i3000BC:  #late start condition
                self.checkSpawn(iBarbarian, iCamelRider, 1 + iHandicap,
                                (60, 38), (78, 42), self.spawnNomads,
                                iGameTurn, 10 - iHandicap, 5,
                                ["TXT_KEY_ADJECTIVE_BERBER"])
        elif utils.isYearIn(900, 1800):
            self.checkSpawn(iBarbarian, iCamelArcher, 1, (60, 33), (78, 42),
                            self.spawnNomads, iGameTurn, 10 - iHandicap, 4,
                            ["TXT_KEY_ADJECTIVE_BERBER"])

        #camels in arabia
        if utils.isYearIn(190, 550):
            self.checkSpawn(iBarbarian, iCamelArcher, 1, (85, 36), (96, 42),
                            self.spawnNomads, iGameTurn, 9 - iHandicap, 7,
                            ["TXT_KEY_ADJECTIVE_BEDOUIN"])
        if utils.isYearIn(-800, 1300) and self.includesActiveHuman(
            [iEgypt, iMamluks, iArabia]):
            iNumUnits = iHandicap
            if utils.getScenario() == i3000BC: iNumUnits += 1
            self.checkSpawn(iBarbarian, iMedjay, iNumUnits, (78, 33), (82, 41),
                            self.spawnUprising, iGameTurn, 12, 4,
                            ["TXT_KEY_ADJECTIVE_NUBIAN"])
        if utils.isYearIn(450, 1600):
            if utils.getScenario() == i3000BC:
                self.checkSpawn(iNative, iImpi, 2 + iHandicap, (68, 12),
                                (85, 31), self.spawnNatives, iGameTurn, 10, 4)
            else:
                self.checkSpawn(iNative, iImpi, 2 + iHandicap, (68, 12),
                                (85, 31), self.spawnNatives, iGameTurn, 15, 4)
        elif utils.isYearIn(1600, 1800):
            self.checkSpawn(iNative, iPombos, 2 + iHandicap, (68, 12),
                            (85, 31), self.spawnNatives, iGameTurn, 10, 4)

        #west africa
        if utils.isYearIn(450, 1700):
            if iGameTurn < getTurnForYear(1300):
                sAdj = ["TXT_KEY_ADJECTIVE_GHANAIAN"]
            else:
                sAdj = ["TXT_KEY_ADJECTIVE_SONGHAI"]
            self.checkSpawn(iNative, iImpi, 2, (55, 28), (70, 34),
                            self.spawnMinors, iGameTurn, 16, 10, sAdj)

        if utils.isYearIn(1200, 1700):
            self.checkSpawn(iBarbarian, iFarari, 2, (54, 31), (76, 43),
                            self.spawnMinors, iGameTurn, 16, 4, sAdj)

        #bulala in Chad
        if utils.isYearIn(1210, 1571):
            self.checkSpawn(iNative, iLongbowman, 1, (70, 33), (75, 37),
                            self.spawnNatives, iGameTurn, 5, 2,
                            ["TXT_KEY_ADJECTIVE_BULALA"])

        #American natives
        if utils.isYearIn(-100, 400):
            self.checkSpawn(iNative, iDogSoldier, 2 + iHandicap, (13, 46),
                            (24, 56), self.spawnNatives, iGameTurn, 20, 0)
        if utils.isYearIn(400, 1100):
            self.checkSpawn(iNative, iDogSoldier, 1 + iHandicap, (13, 46),
                            (24, 56), self.spawnNatives, iGameTurn, 20, 0)
            if utils.getScenario() == i3000BC:  #late start condition
                self.checkSpawn(iNative, iJaguar, 3, (12, 45), (24, 55),
                                self.spawnNatives, iGameTurn,
                                16 - 2 * iHandicap, 10)
            else:  #late start condition
                self.checkSpawn(iNative, iJaguar, 2, (12, 45), (24, 55),
                                self.spawnNatives, iGameTurn,
                                16 - 2 * iHandicap, 10)
        if utils.isYearIn(1300, 1600):
            self.checkSpawn(iNative, iDogSoldier, 2 + iHandicap, (12, 45),
                            (24, 55), self.spawnNatives, iGameTurn, 8, 0)
        if utils.isYearIn(1400, 1800):
            self.checkSpawn(iNative, iDogSoldier, 1 + iHandicap, (8, 50),
                            (34, 60), self.spawnUprising, iGameTurn, 12, 0)
            self.checkSpawn(iNative, iDogSoldier, 1 + iHandicap, (8, 50),
                            (34, 60), self.spawnUprising, iGameTurn, 12, 6)
        if utils.isYearIn(1300, 1600):
            if iGameTurn % 18 == 0:
                if not gc.getMap().plot(28, 31).isUnit():
                    utils.makeUnitAI(iChimuSuchucChiquiAucac, iNative,
                                     (28, 31), UnitAITypes.UNITAI_ATTACK,
                                     2 + iHandicap)
            elif iGameTurn % 18 == 9:
                if not gc.getMap().plot(34, 20).isUnit():
                    utils.makeUnitAI(iChimuSuchucChiquiAucac, iNative,
                                     (34, 20), UnitAITypes.UNITAI_ATTACK,
                                     2 + iHandicap)

        if self.includesActiveHuman(
            [iAmerica, iEngland, iFrance, iMississippi]):
            if utils.isYearIn(1700, 1900):
                self.checkSpawn(iNative, iMountedBrave, 1 + iHandicap,
                                (14, 52), (23, 62), self.spawnNomads,
                                iGameTurn, 12 - iHandicap, 2)

            if utils.isYearIn(1500, 1850):
                self.checkSpawn(iNative, iMohawk, 1, (24, 54), (31, 61),
                                self.spawnUprising, iGameTurn, 8, 4)

        # if iGameTurn == getTurnForYear(-500):
        # 	gc.getMap().plot(19, 41).setImprovementType(iHut)
        # 	utils.makeUnitAI(iHolkan, iNative, (19, 41), UnitAITypes.UNITAI_ATTACK, 2)

        # Oromos in the Horn of Africa
        if utils.isYearIn(1500, 1700):
            iNumUnits = 1
            if pEthiopia.isAlive():
                iNumUnits += 1
                if utils.isYearIn(1650, 1800): iNumUnits += 1
            self.checkSpawn(iBarbarian, iOromoWarrior, iNumUnits, (80, 29),
                            (85, 32), self.spawnInvaders, iGameTurn, 8, 3)

        #pirates in the Caribbean
        if utils.isYearIn(1600, 1800):
            self.checkSpawn(iNative, iPrivateer, 1, (25, 37), (38, 53),
                            self.spawnPirates, iGameTurn, 5, 0)
        #pirates in Asia
        if utils.isYearIn(1500, 1900):
            self.checkSpawn(iNative, iPrivateer, 1, (83, 24), (133, 42),
                            self.spawnPirates, iGameTurn, 8, 0)

        if iGameTurn < getTurnForYear(
                tMinorCities[len(tMinorCities) - 1][0]) + 10:
            self.foundMinorCities(iGameTurn)

        if iGameTurn == getTurnForYear(-1200):
            pJerusalem = gc.getGame().getHolyCity(iJudaism)
            if pJerusalem and pJerusalem.getOwner() >= iNumMajorPlayers:
                pJerusalem.setHasRealBuilding(iJewishShrine, True)
    def checkConquest(self,
                      tConquest,
                      tPrereqConquest=(),
                      iWarPlan=WarPlanTypes.WARPLAN_TOTAL):
        iID, iPlayer, iPreferredTarget, tTL, tBR, iNumTargets, iYear, iIntervalTurns = tConquest

        iGameTurn = gc.getGame().getGameTurn()
        iStartTurn = getTurnForYear(iYear) - 5 + (data.iSeed % 5)
        if (iStartTurn - iGameTurn in range(0, 10)):  #mediv01  alert for AIWAR
            if (iID < 200):
                utils.log2(
                    "AI WAR [" + str(iID) + "] GAME TURN LEFT: " +
                    str(iStartTurn - iGameTurn), 'DoC_SmallMap_Log_AIWar')
                pass

        if iGameTurn <= getTurnForYear(tBirth[iPlayer]) + 3: return

        if not (iStartTurn <= iGameTurn <= iStartTurn + iIntervalTurns): return
        if tPrereqConquest and not self.isConquered(tPrereqConquest): return
        if (gc.getDefineINT("AIWAR_PY_CAN_USE_SUPER_AI_WAR") == 0
                and int(iID) >= 13):
            return  #参数控制
        if utils.getHumanID() == iPlayer and gc.getDefineINT(
                "AIWAR_PY_HUMAN_CAN_USE_AI_WAR") == 0:
            return  #人类可以使用AIWAR开关
        if ((not gc.getPlayer(iPlayer).isAlive()) and
                gc.getDefineINT("AIWAR_PY_DEAD_CIV_CANNOT_USE_AI_WAR") == 1):
            return  #参数控制
        #if not gc.getPlayer(iPlayer).isAlive() and iPlayer != iTurks: return  #mediv01

        if ((not gc.getPlayer(iPreferredTarget).isAlive()) and
                gc.getDefineINT("AIWAR_PY_CAN_USE_AI_WAR_TO_DEAD_CIV") == 0):
            return  #参数控制    #刷兵目标不存在,返回
        if gc.getTeam(gc.getPlayer(iPlayer).getTeam()).isDefensivePact(
                iPreferredTarget):
            return
        if gc.getDefineINT("PYTHON_NOAIWAR_WHEN_VASSAL"):
            if (gc.getTeam(gc.getPlayer(iPreferredTarget).getTeam()).isVassal(
                    iPlayer)):
                return
            if (gc.getTeam(gc.getPlayer(iPlayer).getTeam()).isVassal(
                    iPreferredTarget)):
                return

        if gc.getDefineINT(
                "PYTHON_NOAIWAR_WHEN_VASSAL_MASTER") or gc.getDefineINT(
                    "PYTHON_NOAIWAR_WHEN_VASSAL_TO_OTHER"):
            for iLoopPlayer in range(iNumPlayers):
                #AIWAR目标附庸他人时,无法发动战争
                if gc.getTeam(gc.getPlayer(
                        iPreferredTarget).getTeam()).isVassal(iLoopPlayer):
                    if (gc.getDefineINT("PYTHON_NOAIWAR_WHEN_VASSAL_TO_OTHER")
                        ):
                        return

                #附庸其他人时,无法发动AIWAR
                if gc.getTeam(
                        gc.getPlayer(iPlayer).getTeam()).isVassal(iLoopPlayer):
                    if (iLoopPlayer is not iPlayer and gc.getDefineINT(
                            "PYTHON_NOAIWAR_WHEN_VASSAL_MASTER")):
                        return
            pass

        if (iStartTurn - iGameTurn == 2
                and gc.getDefineINT("AIWAR_PY_HUMAN_AI_WAR_ALERT") == 1
                and utils.getHumanID()
                == iPreferredTarget):  #mediv01  alert for AIWAR
            tem_text = '&#35686;&#25253;&#65306;&#25932;&#22269;&#27491;&#22312;&#25105;&#22269;&#36793;&#22659;&#38598;&#32467;&#22823;&#20891;&#65281;&#25112;&#20105;&#30340;&#38452;&#20113;&#31548;&#32617;&#22312;&#25105;&#22269;&#19978;&#31354;&#65281;'  #警报:敌国正在我国边境集结大军!战争的阴云笼罩在我国上空!
            utils.show(tem_text)
            CyInterface().addMessage(gc.getGame().getActivePlayer(), False,
                                     iDuration, tem_text, "", 0, "",
                                     ColorTypes(iWhite), -1, -1, True, True)
            pass
        if (iStartTurn - iGameTurn == 2
                and gc.getDefineINT("AIWAR_PY_HUMAN_AI_WAR_ALERT") == 1
                and utils.getHumanID() == iPlayer):  #mediv01  alert for AIWAR

            tem_text = '&#35686;&#25253;&#65306;&#25932;&#20891;&#27491;&#22312;&#36793;&#22659;&#25361;&#34885;&#25105;&#26041;&#20891;&#38431;&#65292;&#25112;&#20105;&#30340;&#38452;&#20113;&#31548;&#32617;&#22312;&#25105;&#22269;&#19978;&#31354;&#65281;&#10;'  #警报:敌军正在边境挑衅我方军队,战争的阴云笼罩在我国上空!
            utils.show(tem_text)
            CyInterface().addMessage(gc.getGame().getActivePlayer(), False,
                                     iDuration, tem_text, "", 0, "",
                                     ColorTypes(iWhite), -1, -1, True, True)
            pass

        if (iID < len(data.lConquest)):
            if data.lConquest[iID]: return
        else:
            return
        if iPreferredTarget >= 0 and gc.getPlayer(iPreferredTarget).isAlive(
        ) and gc.getTeam(iPreferredTarget).isVassal(iPlayer):
            return

        import GlobalDefineAlt
        if (iID in GlobalDefineAlt.PYTHON_NO_AIWAR_ID): return

        if (iPlayer == iEngland and iYear <= 1250) or (
                iPlayer == iHolyRome
                and iYear <= 1250) or (iPlayer == iFrance
                                       and iYear <= 1250):  #耶路撒冷在天主教文明手里,则停止刷兵

            lAreaCities = utils.getAreaCities(
                utils.getPlotList(tCrusadesTL, tCrusadesBR))
            for city in lAreaCities:
                if city.getOwner() in [
                        iByzantium, iEngland, iGermany, iFrance, iVikings,
                        iHolyRome, iPoland, iSpain
                ]:
                    return
        data.lConquest[iID] = True
        if (gc.getDefineINT("PYTHON_LOG_ON_MAIN_AIWAR") == 1):
            utils.logwithid(
                iPlayer, ' Start AI WAR with ' + str(
                    gc.getPlayer(
                        iPreferredTarget).getCivilizationShortDescription(0)))
        self.spawnConquerors(iPlayer, iPreferredTarget, tTL, tBR, iNumTargets,
                             iYear, iIntervalTurns, iWarPlan)
    def spawnConquerors(self,
                        iPlayer,
                        iPreferredTarget,
                        tTL,
                        tBR,
                        iNumTargets,
                        iYear,
                        iIntervalTurns,
                        iWarPlan=WarPlanTypes.WARPLAN_TOTAL):
        if not gc.getPlayer(iPlayer).isAlive():
            for iTech in sta.getResurrectionTechs(iPlayer):
                gc.getTeam(gc.getPlayer(iPlayer).getTeam()).setHasTech(
                    iTech, True, iPlayer, False, False)

        lCities = []
        for city in utils.getAreaCities(utils.getPlotList(tTL, tBR)):
            if city.getOwner() != iPlayer and not gc.getTeam(
                    city.getOwner()).isVassal(iPlayer):
                if (gc.getDefineINT("AIWAR_PY_CANNOT_DO_AIWAR_TO_HUMAN") > 0
                        and (city.getOwner() == utils.getHumanID())):
                    pass
                else:
                    lCities.append(city)

        capital = gc.getPlayer(iPlayer).getCapitalCity()

        lTargetCities = []
        for i in range(iNumTargets):
            if len(lCities) == 0: break

            targetCity = utils.getHighestEntry(
                lCities, lambda x: -utils.calculateDistance(
                    x.getX(), x.getY(), capital.getX(), capital.getY()) + int(
                        x.getOwner() == iPreferredTarget) * 1000)
            lTargetCities.append(targetCity)
            lCities.remove(targetCity)

        lOwners = []
        for city in lTargetCities:
            if city.getOwner() not in lOwners:
                lOwners.append(city.getOwner())

        if iPreferredTarget >= 0 and iPreferredTarget not in lOwners and gc.getPlayer(
                iPreferredTarget).isAlive():
            if (gc.getDefineINT("AIWAR_PY_CANNOT_DO_AIWAR_TO_HUMAN") > 0
                    and (iPreferredTarget == utils.getHumanID())):
                pass
            else:
                self.declareWar(iPlayer, iPreferredTarget, iWarPlan)

        for iOwner in lOwners:
            self.declareWar(iPlayer, iOwner, iWarPlan)
            CyInterface().addMessage(
                iOwner, False, iDuration,
                CyTranslator().getText(
                    "TXT_KEY_UP_CONQUESTS_TARGET",
                    (gc.getPlayer(iPlayer).getCivilizationShortDescription(0),
                     )), "", 0, "", ColorTypes(iWhite), -1, -1, True, True)
#####修改开始#####
#消息传送区
        if (gc.getDefineINT("PYTHON_USE_ADVANCE_ALERT") == 1):  #参数控制
            if iPlayer == iGreece:
                tem_text = '&#19990;&#30028;&#20891;&#20107;&#36895;&#36882;&#65306;&#20122;&#21382;&#23665;&#22823;&#19996;&#24449;&#24320;&#22987;&#20102;&#65281;&#20854;&#40638;&#19979;&#30340;&#20891;&#38431;&#27491;&#22312;&#27178;&#25195;&#27431;&#20122;&#22823;&#38470;&#65281;'
                CyInterface().addMessage(gc.getGame().getActivePlayer(), False,
                                         iDuration, tem_text, "", 0, "",
                                         ColorTypes(iWhite), -1, -1, True,
                                         True)
    #			utils.show('&#20891;&#20107;&#36895;&#36882;&#65306;&#20122;&#21382;&#23665;&#22823;&#19996;&#24449;&#24320;&#22987;&#20102;&#65281;')
            if iPlayer == iRome:
                tem_text = '&#19990;&#30028;&#20891;&#20107;&#36895;&#36882;&#65306;&#32599;&#39532;&#24093;&#22269;&#27491;&#22312;&#23835;&#36215;&#65292;&#20854;&#20891;&#38431;&#25152;&#21521;&#25259;&#38753;&#65281;'
                CyInterface().addMessage(gc.getGame().getActivePlayer(), False,
                                         iDuration, tem_text, "", 0, "",
                                         ColorTypes(iWhite), -1, -1, True,
                                         True)
    #			utils.show('&#20891;&#20107;&#36895;&#36882;&#65306;&#32599;&#39532;&#24093;&#22269;&#27491;&#22312;&#23835;&#36215;&#65292;&#20854;&#20891;&#38431;&#25152;&#21521;&#25259;&#38753;&#65281;')
            if iPlayer == iMongolia:
                tem_text = '&#19990;&#30028;&#20891;&#20107;&#36895;&#36882;&#65306;&#33945;&#21476;&#24093;&#22269;&#27491;&#22312;&#23835;&#36215;&#65292;&#25104;&#21513;&#24605;&#27735;&#30340;&#20891;&#38431;&#25152;&#21521;&#25259;&#38753;&#65281;'
                CyInterface().addMessage(gc.getGame().getActivePlayer(), False,
                                         iDuration, tem_text, "", 0, "",
                                         ColorTypes(iWhite), -1, -1, True,
                                         True)
    #			utils.show('&#20891;&#20107;&#36895;&#36882;&#65306;&#33945;&#21476;&#24093;&#22269;&#27491;&#22312;&#23835;&#36215;&#65292;&#25104;&#21513;&#24605;&#27735;&#30340;&#20891;&#38431;&#25152;&#21521;&#25259;&#38753;&#65281;')
            if iPlayer == iTurks:
                tem_text = '&#19990;&#30028;&#20891;&#20107;&#36895;&#36882;&#65306;&#31361;&#21413;&#24093;&#22269;&#27491;&#22312;&#23835;&#36215;&#65292;&#20854;&#20891;&#38431;&#25152;&#21521;&#25259;&#38753;&#65281;'
                CyInterface().addMessage(gc.getGame().getActivePlayer(), False,
                                         iDuration, tem_text, "", 0, "",
                                         ColorTypes(iWhite), -1, -1, True,
                                         True)
    #			utils.show('&#20891;&#20107;&#36895;&#36882;&#65306;&#31361;&#21413;&#24093;&#22269;&#27491;&#22312;&#23835;&#36215;&#65292;&#20854;&#20891;&#38431;&#25152;&#21521;&#25259;&#38753;&#65281;')
    #百年战争
            if iPlayer == iEngland and iYear <= 1450 and iYear >= 1250:
                tem_text = '&#33521;&#27861;&#30334;&#24180;&#25112;&#20105;&#30340;&#33125;&#39118;&#34880;&#38632;&#27491;&#24335;&#25289;&#24320;&#24119;&#24149;&#65281;'
                CyInterface().addMessage(gc.getGame().getActivePlayer(), False,
                                         iDuration, tem_text, "", 0, "",
                                         ColorTypes(iWhite), -1, -1, True,
                                         True)
    #			utils.show('&#20891;&#20107;&#36895;&#36882;&#65306;&#31361;&#21413;&#24093;&#22269;&#27491;&#22312;&#23835;&#36215;&#65292;&#20854;&#20891;&#38431;&#25152;&#21521;&#25259;&#38753;&#65281;')
    #圣女贞德
            if iPlayer == iFrance and iYear <= 1550 and iYear >= 1350:
                tem_text = '&#22307;&#22899;&#36126;&#24503;&#21796;&#36215;&#20102;&#27861;&#22269;&#20154;&#27665;&#30340;&#27665;&#26063;&#24863;&#65292;&#27861;&#22269;&#20154;&#27665;&#20026;&#20102;&#25421;&#21355;&#23478;&#22253;&#32780;&#25112;&#65281;'
                CyInterface().addMessage(gc.getGame().getActivePlayer(), False,
                                         iDuration, tem_text, "", 0, "",
                                         ColorTypes(iWhite), -1, -1, True,
                                         True)
    #			utils.show('&#20891;&#20107;&#36895;&#36882;&#65306;&#31361;&#21413;&#24093;&#22269;&#27491;&#22312;&#23835;&#36215;&#65292;&#20854;&#20891;&#38431;&#25152;&#21521;&#25259;&#38753;&#65281;')
    #十字军
            if iPlayer == iEngland and iYear <= 1200 and iYear >= 1000:
                tem_text = '&#36720;&#21160;&#20013;&#19996;&#21644;&#27431;&#27954;&#30340;&#21313;&#23383;&#20891;&#19996;&#24449;&#24320;&#22987;&#20102;&#65281;'
                CyInterface().addMessage(gc.getGame().getActivePlayer(), False,
                                         iDuration, tem_text, "", 0, "",
                                         ColorTypes(iWhite), -1, -1, True,
                                         True)
    #			utils.show('&#20891;&#20107;&#36895;&#36882;&#65306;&#31361;&#21413;&#24093;&#22269;&#27491;&#22312;&#23835;&#36215;&#65292;&#20854;&#20891;&#38431;&#25152;&#21521;&#25259;&#38753;&#65281;')
    #萨拉丁
            if iPlayer == iEgypt and iYear <= 1300 and iYear >= 1100:
                tem_text = '&#24180;&#36731;&#30340;&#39046;&#34966;&#33832;&#25289;&#19969;&#29575;&#39046;&#20891;&#38431;&#21521;&#21313;&#23383;&#20891;&#21457;&#36215;&#29467;&#28872;&#30340;&#36827;&#25915;&#65281;'
                CyInterface().addMessage(gc.getGame().getActivePlayer(), False,
                                         iDuration, tem_text, "", 0, "",
                                         ColorTypes(iWhite), -1, -1, True,
                                         True)
    #			utils.show('&#20891;&#20107;&#36895;&#36882;&#65306;&#31361;&#21413;&#24093;&#22269;&#27491;&#22312;&#23835;&#36215;&#65292;&#20854;&#20891;&#38431;&#25152;&#21521;&#25259;&#38753;&#65281;')
    #拿破仑战争
            if iPlayer == iFrance and iYear <= 1900 and iYear >= 1700:
                tem_text = '&#25343;&#30772;&#20177;&#30340;&#20891;&#38431;&#27491;&#22312;&#27431;&#27954;&#25152;&#21521;&#25259;&#38753;&#65281;'
                CyInterface().addMessage(gc.getGame().getActivePlayer(), False,
                                         iDuration, tem_text, "", 0, "",
                                         ColorTypes(iWhite), -1, -1, True,
                                         True)
    #			utils.show('&#20891;&#20107;&#36895;&#36882;&#65306;&#31361;&#21413;&#24093;&#22269;&#27491;&#22312;&#23835;&#36215;&#65292;&#20854;&#20891;&#38431;&#25152;&#21521;&#25259;&#38753;&#65281;')
            if iYear <= 1930 and iYear >= 1900:
                tem_text = '&#31532;&#19968;&#27425;&#19990;&#30028;&#22823;&#25112;&#27491;&#22312;&#36827;&#34892;&#65281;'
                CyInterface().addMessage(gc.getGame().getActivePlayer(), False,
                                         iDuration, tem_text, "", 0, "",
                                         ColorTypes(iWhite), -1, -1, True,
                                         True)
    #			utils.show('&#20891;&#20107;&#36895;&#36882;&#65306;&#31361;&#21413;&#24093;&#22269;&#27491;&#22312;&#23835;&#36215;&#65292;&#20854;&#20891;&#38431;&#25152;&#21521;&#25259;&#38753;&#65281;')
            if iYear <= 1960 and iYear >= 1930:
                tem_text = '&#31532;&#20108;&#27425;&#19990;&#30028;&#22823;&#25112;&#27491;&#22312;&#36827;&#34892;&#65281;'
                CyInterface().addMessage(gc.getGame().getActivePlayer(), False,
                                         iDuration, tem_text, "", 0, "",
                                         ColorTypes(iWhite), -1, -1, True,
                                         True)

    #			utils.show('&#20891;&#20107;&#36895;&#36882;&#65306;&#31361;&#21413;&#24093;&#22269;&#27491;&#22312;&#23835;&#36215;&#65292;&#20854;&#20891;&#38431;&#25152;&#21521;&#25259;&#38753;&#65281;')

#####修改结束#####
####修改开始####
        for city in lTargetCities:
            iExtra = 0 + 2
            # 			if utils.getHumanID() not in [iPlayer, city.getOwner()]:
            # 				iExtra += 1 #max(1, gc.getPlayer(iPlayer).getCurrentEra())
            #
            # 			if iPlayer == iMongolia and utils.getHumanID() != iPlayer:
            # 				iExtra += 1

            tPlot = utils.findNearestLandPlot((city.getX(), city.getY()),
                                              iPlayer)
            if (tPlot):

                iBestInfantry = utils.getBestInfantry(iPlayer)
                iBestSiege = utils.getBestSiege(iPlayer)

                if iPlayer == iGreece:
                    iBestInfantry = iHoplite
                    iBestSiege = iCatapult
                if iPlayer == iMongolia:
                    iBestInfantry = iKeshik
                    iExtra += 2

                if iPlayer == iCarthage and iYear <= 150:
                    iExtra = 0
                    iBestInfantry = iWarElephant
                    tem_text = '&#36838;&#22826;&#22522;&#30340;&#27721;&#23612;&#25300;&#23558;&#20891;&#32763;&#36234;&#20102;&#38463;&#23572;&#21329;&#26031;&#23665;&#65292;&#20986;&#29616;&#22312;&#31859;&#20848;&#38468;&#36817;&#65281;'
                    CyInterface().addMessage(gc.getGame().getActivePlayer(),
                                             False, iDuration,
                                             tem_text, "", 0, "",
                                             ColorTypes(iWhite), -1, -1, True,
                                             True)
                if iPlayer == iBarbarian and iYear <= 150:
                    iExtra = -1
                    iBestInfantry = iMilitia
                    utils.makeUnitAI(iBestInfantry, iPlayer, tPlot,
                                     UnitAITypes.UNITAI_ATTACK_CITY, 1)
                    utils.makeUnitAI(iLightSwordsman, iPlayer, tPlot,
                                     UnitAITypes.UNITAI_ATTACK_CITY, 1)
                    tem_text = '&#26031;&#24052;&#36798;&#20811;&#26031;&#21561;&#21709;&#20102;&#21453;&#25239;&#32599;&#39532;&#30340;&#36215;&#20041;&#21495;&#35282;&#65281;'
                    CyInterface().addMessage(gc.getGame().getActivePlayer(),
                                             False, iDuration,
                                             tem_text, "", 0, "",
                                             ColorTypes(iWhite), -1, -1, True,
                                             True)
                if iPlayer == iEngland and iYear <= 1500:
                    iExtra -= 0
                    iBestInfantry = iLongbowman
    #				utils.makeUnitAI(iBestInfantry, iPlayer, tPlot, UnitAITypes.UNITAI_ATTACK_CITY, 2)
    #				iBestSiege = iCatapult
                if (iPlayer == iEngland and iYear <= 1250) or (
                        iPlayer == iHolyRome
                        and iYear <= 1250) or (iPlayer == iFrance
                                               and iYear <= 1250):
                    iExtra -= 1

    #				iBestInfantry = iLongbowman
    #				utils.makeUnitAI(iBestInfantry, iPlayer, tPlot, UnitAITypes.UNITAI_ATTACK_CITY, 2)
    #				iBestSiege = iCatapult
                if iPlayer == iTurks and iYear <= 1250:
                    iExtra -= 2

                if iYear >= 1800:
                    iExtra += 1
                if iYear >= 1900:
                    iExtra += 1
                if iYear >= 1930:
                    iExtra += 1
                if iPreferredTarget == utils.getHumanID() and iYear >= 1300:
                    iExtra = gc.getGame().getHandicapType() + 1

                utils.makeUnitAI(iBestInfantry, iPlayer, tPlot,
                                 UnitAITypes.UNITAI_ATTACK_CITY,
                                 max(2 + iExtra, 1))
                utils.makeUnitAI(iBestSiege, iPlayer, tPlot,
                                 UnitAITypes.UNITAI_ATTACK_CITY,
                                 max(1 + iExtra, 1))
                ####修改结束#####
                if iPlayer == iGreece:
                    utils.makeUnitAI(iCompanion, iPlayer, tPlot,
                                     UnitAITypes.UNITAI_ATTACK_CITY, 1)

                if iPlayer == iTamils:
                    utils.makeUnitAI(iWarElephant, iPlayer, tPlot,
                                     UnitAITypes.UNITAI_ATTACK_CITY, 1)

                if iPlayer == iSpain:
                    utils.makeUnitAI(utils.getBestCavalry(iPlayer), iPlayer,
                                     tPlot, UnitAITypes.UNITAI_ATTACK_CITY,
                                     2 * iExtra)

                if iPlayer == iTurks:
                    utils.makeUnitAI(utils.getBestCavalry(iPlayer), iPlayer,
                                     tPlot, UnitAITypes.UNITAI_ATTACK_CITY,
                                     2 + iExtra)
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)
Exemplo n.º 26
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)
Exemplo n.º 27
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)