Exemple #1
0
	def startCongress(self):
		self.bPostWar = (len(self.lWinners) > 0)
		
		utils.debugTextPopup('Congress takes place')

		self.inviteToCongress()
		
		if self.bPostWar:
			iHostPlayer = [iWinner for iWinner in self.lWinners if gc.getPlayer(iWinner).isAlive()][0]
		else:
			iHostPlayer = utils.getRandomEntry([iInvitee for iInvitee in self.lInvites if gc.getPlayer(iInvitee).getNumCities() > 0])
			
		# normal congresses during war time may be too small because all civilisations are tied up in global wars
		if len(self.lInvites) < 3:
			data.iCongressTurns /= 2
			data.currentCongress = None
			return
			
		# establish contact between all participants
		for iThisPlayer in self.lInvites:
			for iThatPlayer in self.lInvites:
				if iThisPlayer != iThatPlayer:
					tThisPlayer = gc.getTeam(iThisPlayer)
					if not tThisPlayer.canContact(iThatPlayer): tThisPlayer.meet(iThatPlayer, False)

		self.sHostCityName = utils.getRandomEntry(utils.getOwnedCoreCities(iHostPlayer, utils.getReborn(iHostPlayer))).getName()
		
		# moved selection of claims after the introduction event so claims and their resolution take place at the same time
		if utils.getHumanID() in self.lInvites:
			self.startIntroductionEvent(True)
				
		# procedure continues from the makeClaimHuman event
		
		bHumanInGlobalWar = False
		if isGlobalWar():
			lAttackers, lDefenders = determineAlliances(data.iGlobalWarAttacker, data.iGlobalWarDefender)
			bHumanInGlobalWar = utils.getHumanID() in lAttackers + lDefenders
		
		# unless the player isn't involved, in that case resolve from here
		if utils.getHumanID() not in self.lInvites:
			# since Congresses now can occur during autoplay, don't display these congresses to the player
			if gc.getGame().getGameTurn() >= getTurnForYear(tBirth[utils.getHumanID()]):
				self.startIntroductionEvent(False, bHumanInGlobalWar)
			else:
				# select claims first, then move on to voting directly since the player isn't involved
				for iLoopPlayer in self.lInvites:
					if not self.canClaim(iLoopPlayer): continue
					self.dPossibleClaims[iLoopPlayer] = self.selectClaims(iLoopPlayer)
					
				for iLoopPlayer in self.lInvites:
					if iLoopPlayer not in self.dPossibleClaims: continue
					
					if utils.getHumanID() != iLoopPlayer:
						self.makeClaimAI(iLoopPlayer)
						
				self.voteOnClaims()
    def spreadIslamIndonesia(self, iGameTurn):
        if not gc.getGame().isReligionFounded(iIslam): return
        if not pIndonesia.isAlive(): return
        if not (getTurnForYear(1300) <= iGameTurn <= getTurnForYear(1600)):
            return

        if iGameTurn % utils.getTurns(15) != utils.getTurns(4): return

        lIndonesianContacts = [
            iPlayer for iPlayer in range(iNumPlayers)
            if pIndonesia.canContact(iPlayer)
            and gc.getPlayer(iPlayer).getStateReligion() == iIslam
        ]
        if not lIndonesianContacts:
            return

        lIndonesianCities = utils.getRegionCities([rIndonesia])
        lPotentialCities = [
            city for city in lIndonesianCities
            if not city.isHasReligion(iIslam)
        ]

        iMaxCitiesMultiplier = 2
        if pIndonesia.getStateReligion() == iIslam: iMaxCitiesMultiplier = 5

        if len(lPotentialCities) * iMaxCitiesMultiplier >= len(
                lIndonesianCities):
            pSpreadCity = utils.getRandomEntry(lPotentialCities)
            if pSpreadCity:
                pSpreadCity.spreadReligion(iIslam)
    def checkChristianity(self, iGameTurn):
        if not gc.getGame().isReligionFounded(iJudaism): return
        if gc.getGame().isReligionFounded(iOrthodoxy): return

        iOffset = utils.getTurns(data.iSeed % 15)

        if iGameTurn == getTurnForYear(0) + iOffset:
            pHolyCity = gc.getGame().getHolyCity(iJudaism)

            if pHolyCity.getOwner() != utils.getHumanID() and gc.getGame(
            ).getSorenRandNum(2, "Holy city?") == 0:
                pChristianCity = pHolyCity
                self.foundReligion(
                    (pChristianCity.getX(), pChristianCity.getY()), iOrthodoxy)
                return

            lJewishCities = []
            for iPlayer in range(iNumTotalPlayersB):
                lJewishCities.extend([
                    city for city in utils.getCityList(iPlayer)
                    if city.isHasReligion(iJudaism)
                    and city.getOwner() != utils.getHumanID()
                ])

            if lJewishCities:
                pChristianCity = utils.getRandomEntry(lJewishCities)
                self.foundReligion(
                    (pChristianCity.getX(), pChristianCity.getY()), iOrthodoxy)
	def spawnPirates(self, iPlayer, iUnitType, iNumUnits, tTL, tBR, sAdj=""):
		'''Leoreth: spawns all ships at the same coastal spot, out to pillage and disrupt trade, can spawn inside borders'''
		
		lPlots = self.possibleTiles(tTL, tBR, bWater=True, bTerritory=False)
		tPlot = utils.getRandomEntry(lPlots)
		
		if tPlot:
			utils.makeUnitAI(iUnitType, iPlayer, tPlot, UnitAITypes.UNITAI_PIRATE_SEA, iNumUnits, sAdj)
 def setBillyTheBlackSheep(self):
     lPlots = [(x, y) for (x, y) in utils.getWorldPlotsList()
               if gc.getMap().plot(x, y).getBonusType(-1) == iSheep
               and gc.getMap().plot(x, y).getBonusVarietyType(-1) == -1]
     tSheepPlot = utils.getRandomEntry(lPlots)
     if tSheepPlot:
         gc.getMap().plot(tSheepPlot[0],
                          tSheepPlot[1]).setBonusVarietyType(iSheepBlack)
	def foundReligionInCore(self, iReligion):
		lCoreCities = [city for city in utils.getAllCities() if city.plot().getSpreadFactor(iReligion) == RegionSpreadTypes.REGION_SPREAD_CORE]
		
		if not lCoreCities: return
		
		city = utils.getRandomEntry(lCoreCities)
		
		self.foundReligion((city.getX(), city.getY()), iReligion)
	def checkSpawn(self, iPlayer, iUnitType, iNumUnits, tTL, tBR, spawnFunction, iTurn, iPeriod, iRest, lAdj=[]):
		if len(lAdj) == 0:
			sAdj = ""
		else:
			sAdj = utils.getRandomEntry(lAdj)
	
		if iTurn % utils.getTurns(iPeriod) == iRest:
			spawnFunction(iPlayer, iUnitType, iNumUnits, tTL, tBR, sAdj)
	def foundReligionInCore(self, iReligion):
		lCoreCities = [city for city in utils.getAllCities() if city.plot().getSpreadFactor(iReligion) == RegionSpreadTypes.REGION_SPREAD_CORE]
		
		if not lCoreCities: return
		
		city = utils.getRandomEntry(lCoreCities)
		
		self.foundReligion((city.getX(), city.getY()), iReligion)
	def startCongress(self):
		self.bPostWar = (len(self.lWinners) > 0)
		
		utils.debugTextPopup('Congress takes place')

		self.inviteToCongress()
		
		if self.bPostWar:
			iHostPlayer = self.lWinners[0]
		else:
			iHostPlayer = utils.getRandomEntry(self.lInvites)
			
		# establish contact between all participants
		for iThisPlayer in self.lInvites:
			for iThatPlayer in self.lInvites:
				if iThisPlayer != iThatPlayer:
					tThisPlayer = gc.getTeam(iThisPlayer)
					if not tThisPlayer.canContact(iThatPlayer): tThisPlayer.meet(iThatPlayer, False)
			
		self.sHostCityName = utils.getRandomEntry(utils.getCoreCityList(iHostPlayer, utils.getReborn(iHostPlayer))).getName()
		
		# moved selection of claims after the introduction event so claims and their resolution take place at the same time
		if utils.getHumanID() in self.lInvites:
			self.startIntroductionEvent(True)
				
		# procedure continues from the makeClaimHuman event
		
		# unless the player isn't involved, in that case resolve from here
		if utils.getHumanID() not in self.lInvites:
			# since Congresses now can occur during autoplay, don't display these congresses to the player
			if gc.getGame().getGameTurn() >= getTurnForYear(tBirth[utils.getHumanID()]):
				self.startIntroductionEvent(False)
			else:
				# select claims first, then move on to voting directly since the player isn't involved
				for iLoopPlayer in self.lInvites:
					if not self.canClaim(iLoopPlayer): continue
					self.dPossibleClaims[iLoopPlayer] = self.selectClaims(iLoopPlayer)
					
				for iLoopPlayer in self.lInvites:
					if iLoopPlayer not in self.dPossibleClaims: continue
					
					if utils.getHumanID() != iLoopPlayer:
						self.makeClaimAI(iLoopPlayer)
						
				self.voteOnClaims()
	def startCongress(self):
		self.bPostWar = (len(self.lWinners) > 0)
		
		utils.debugTextPopup('Congress takes place')

		self.inviteToCongress()
		
		if self.bPostWar:
			iHostPlayer = self.lWinners[0]
		else:
			iHostPlayer = utils.getRandomEntry(self.lInvites)
			
		# establish contact between all participants
		for iThisPlayer in self.lInvites:
			for iThatPlayer in self.lInvites:
				if iThisPlayer != iThatPlayer:
					tThisPlayer = gc.getTeam(iThisPlayer)
					if not tThisPlayer.canContact(iThatPlayer): tThisPlayer.meet(iThatPlayer, False)
			
		self.sHostCityName = utils.getRandomEntry(utils.getCoreCityList(iHostPlayer, utils.getReborn(iHostPlayer))).getName()
		
		# moved selection of claims after the introduction event so claims and their resolution take place at the same time
		if utils.getHumanID() in self.lInvites:
			self.startIntroductionEvent(True)
				
		# procedure continues from the makeClaimHuman event
		
		# unless the player isn't involved, in that case resolve from here
		if utils.getHumanID() not in self.lInvites:
			# since Congresses now can occur during autoplay, don't display these congresses to the player
			if gc.getGame().getGameTurn() >= getTurnForYear(tBirth[utils.getHumanID()]):
				self.startIntroductionEvent(False)
			else:
				# select claims first, then move on to voting directly since the player isn't involved
				for iLoopPlayer in self.lInvites:
					if not self.canClaim(iLoopPlayer): continue
					self.dPossibleClaims[iLoopPlayer] = self.selectClaims(iLoopPlayer)
					
				for iLoopPlayer in self.lInvites:
					if iLoopPlayer not in self.dPossibleClaims: continue
					
					if utils.getHumanID() != iLoopPlayer:
						self.makeClaimAI(iLoopPlayer)
						
				self.voteOnClaims()
	def selectRandomCityTargetCiv(self, iCiv): # Unused
		if gc.getPlayer(iCiv).isAlive():
			lCities = []
			for city in utils.getCityList(iCiv):
				if not city.isDisorder() and city.foodDifference(False) > 0:
					lCities.append(city)
			if lCities:
				return utils.getRandomEntry(lCities)
		return False
	def spawnMinors(self, iPlayer, iUnitType, iNumUnits, tTL, tBR, sAdj=""):
		'''Leoreth: represents minor states without ingame cities
			    outside of territory, not in jungles, in groups, passive'''
			    
		lPlots = self.possibleTiles(tTL, tBR, bTerritory=False)
		tPlot = utils.getRandomEntry(lPlots)
		
		if tPlot:
			utils.makeUnitAI(iUnitType, iPlayer, tPlot, UnitAITypes.UNITAI_ATTACK, iNumUnits, sAdj)
Exemple #13
0
 def selectRandomCityTargetCiv(self, iCiv):  # Unused
     if gc.getPlayer(iCiv).isAlive():
         lCities = []
         for city in utils.getCityList(iCiv):
             if not city.isDisorder() and city.foodDifference(False) > 0:
                 lCities.append(city)
         if lCities:
             return utils.getRandomEntry(lCities)
     return False
	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
Exemple #15
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 spawnInvaders(self, iPlayer, iUnitType, iNumUnits, tTL, tBR, sAdj=""):
		'''Leoreth: represents large invasion forces and migration movements
			    inside of territory, not in jungles, in groups, target cities'''
			    
		lPlots = self.possibleTiles(tTL, tBR, bTerritory=True, bBorder=True)
		tPlot = utils.getRandomEntry(lPlots)
		
		if tPlot:
			utils.makeUnitAI(iUnitType, iPlayer, tPlot, UnitAITypes.UNITAI_ATTACK, iNumUnits, sAdj)
	def spawnNomads(self, iPlayer, iUnitType, iNumUnits, tTL, tBR, sAdj=""):
		'''Leoreth: represents aggressive steppe nomads etc.
			    outside of territory, not in jungles, in small groups, target cities'''
		
		lPlots = self.possibleTiles(tTL, tBR, bTerritory=False)
		tPlot = utils.getRandomEntry(lPlots)
		
		if tPlot:
			utils.makeUnitAI(iUnitType, iPlayer, tPlot, UnitAITypes.UNITAI_ATTACK, iNumUnits, sAdj)
Exemple #18
0
 def selectRandomCitySourceCiv(self, iCiv):  # Unused
     if gc.getPlayer(iCiv).isAlive():
         cityList = [
             city for city in utils.getCityList(iCiv)
             if city.getPopulation() > 1
         ]
         if cityList:
             return utils.getRandomEntry(cityList)
     return False
    def decay(self, iCiv):
        teamCiv = gc.getTeam(gc.getPlayer(iCiv).getTeam())

        # Initialize list
        lContacts = [
            i for i in range(iNumPlayers) if gc.getPlayer(i).isAlive()
            and teamCiv.canContact(i) and teamCiv.canCutContact(i)
        ]

        # master/vassal relationships: if master can be seen, don't cut vassal contact and vice versa
        lRemove = []
        for iLoopPlayer in range(iNumPlayers):
            for iContact in lContacts:
                if gc.getTeam(iContact).isVassal(
                        iLoopPlayer) and iLoopPlayer not in lContacts:
                    lRemove.append(iContact)
                elif gc.getTeam(iLoopPlayer).isVassal(
                        iContact) and iLoopPlayer not in lContacts:
                    lRemove.append(iContact)

        # if there are still vassals in the list, their masters are too -> remove the vassals, and cut contact when their masters are chosen
        for iContact in lContacts:
            if gc.getTeam(iContact).isAVassal() and iContact not in lRemove:
                lRemove.append(iContact)

        # Phillipine UP: Cannot lose contact with civs with embassy
        if iCiv == iPhilippines:
            for iContact in lContacts:
                if iContact in data.lPhilippineEmbassies and iContact not in lRemove:
                    lRemove.append(iContact)

        for iLoopCiv in lRemove:
            if iLoopCiv in lContacts: lContacts.remove(iLoopCiv)

        # choose up to four random contacts to cut
        for i in range(4):
            if len(lContacts) == 0: break

            iContact = utils.getRandomEntry(lContacts)

            lOurCivs = [iCiv]
            lTheirCivs = [iContact]

            # remove contacts for all vassals on both sides as well
            for iLoopCiv in range(iNumPlayers):
                if gc.getTeam(iLoopCiv).isVassal(iCiv):
                    lOurCivs.append(iLoopCiv)
                elif gc.getTeam(iLoopCiv).isVassal(iContact):
                    lTheirCivs.append(iLoopCiv)

            for iOurCiv in lOurCivs:
                for iTheirCiv in lTheirCivs:
                    #utils.debugTextPopup('Cut contact between ' + gc.getPlayer(iOurCiv).getCivilizationShortDescription(0) + ' and ' + gc.getPlayer(iTheirCiv).getCivilizationShortDescription(0))
                    gc.getTeam(iOurCiv).cutContact(iTheirCiv)

            lContacts.remove(iContact)
	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
Exemple #21
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 spawnUprising(self, iPlayer, iUnitType, iNumUnits, tTL, tBR, sAdj=""):
		''' Leoreth: represents uprisings of Natives against colonial settlements, especially North America
			     spawns units in a free plot in the second ring of a random target city in the area
			     (also used for units from warring city states in classical Mesoamerica)'''
		
		lPlots = self.possibleTiles(tTL, tBR, bTerritory=True, bNearCity=True)
		tPlot = utils.getRandomEntry(lPlots)
		
		if tPlot:
			utils.makeUnitAI(iUnitType, iPlayer, tPlot, UnitAITypes.UNITAI_ATTACK, iNumUnits, sAdj)
	def selectRandomCityReligion(self, iReligion): # Unused
		if gc.getGame().isReligionFounded(iReligion):
			cityList = []
			for iPlayer in range(iNumPlayers):
				for city in utils.getCityList(iPlayer):
					if city.isHasReligion(iReligion):
						cityList.append(city)
			if cityList:
				iCity = utils.getRandomEntry(cityList)
				return (city.getX(), city.getY())
		return False
	def spawnNatives(self, iPlayer, iUnitType, iNumUnits, tTL, tBR, sAdj=""):
		'''Leoreth: outside of territory, in jungles, all dispersed on several plots, out to pillage'''
		
		lPlots = self.possibleTiles(tTL, tBR, bTerritory=False, bImpassable=True)
		
		for i in range(iNumUnits):
			tPlot = utils.getRandomEntry(lPlots)
			if not tPlot: break
			
			lPlots.remove(tPlot)
			utils.makeUnitAI(iUnitType, iPlayer, tPlot, UnitAITypes.UNITAI_ATTACK, 1, sAdj)
    def spawnRabbits(self, iPlayer, iUnitType, iNumUnits, tTL, tBR, sAdj=""):
        ''' Merijn: inside territory, dispersed over several plots, pillaging'''
        lPlots = self.possibleTiles(tTL, tBR, bTerritory=True, bNearCity=True)

        for i in range(iNumUnits):
            tPlot = utils.getRandomEntry(lPlots)
            if not tPlot: break

            lPlots.remove(tPlot)
            utils.makeUnitAI(iUnitType, iPlayer, tPlot,
                             UnitAITypes.UNITAI_PILLAGE, 1, sAdj)
Exemple #26
0
	def selectRandomCityReligion(self, iReligion): # Unused
		if gc.getGame().isReligionFounded(iReligion):
			cityList = []
			for iPlayer in range(iNumPlayers):
				for city in utils.getCityList(iPlayer):
					if city.isHasReligion(iReligion):
						cityList.append(city)
			if cityList:
				iCity = utils.getRandomEntry(cityList)
				return (city.getX(), city.getY())
		return False
Exemple #27
0
	def spreadReligionToRegion(self, iReligion, lRegions, iGameTurn, iStartDate, iInterval, iOffset):
		if not gc.getGame().isReligionFounded(iReligion): return
		if iGameTurn < getTurnForYear(iStartDate): return
		
		if iGameTurn % utils.getTurns(iInterval) != iOffset: return
		
		lRegionCities = utils.getRegionCities(lRegions)
		lReligionCities = [city for city in lRegionCities if city.isHasReligion(iReligion)]
		
		if 2 * len(lReligionCities) < len(lRegionCities):
			pSpreadCity = utils.getRandomEntry(self.getTargetCities(lRegionCities, iReligion))
			if pSpreadCity:
				pSpreadCity.spreadReligion(iReligion)
	def spreadJudaismMiddleEast(self, iGameTurn):
		if not gc.getGame().isReligionFounded(iJudaism): return
		if iGameTurn < getTurnForYear(600): return
		
		if iGameTurn % utils.getTurns(20) != utils.getTurns(5): return
		
		lMiddleEastCities = utils.getRegionCities([rMesopotamia, rAnatolia, rEgypt])
		lJewishCities = [city for city in lMiddleEastCities if city.isHasReligion(iJudaism)]
		
		if 2 * len(lJewishCities) < len(lMiddleEastCities):
			pSpreadCity = utils.getRandomEntry(self.getTargetCities(lMiddleEastCities, iJudaism))
			if pSpreadCity:
				pSpreadCity.spreadReligion(iJudaism)
	def spreadJudaismEurope(self, iGameTurn):
		if not gc.getGame().isReligionFounded(iJudaism): return
		if iGameTurn < getTurnForYear(1000): return
		
		if iGameTurn % utils.getTurns(10) != 0: return
	
		lEuropeanCities = utils.getRegionCities([rIberia, rEurope, rItaly, rBritain, rRussia, rBalkans])
		lJewishCities = [city for city in lEuropeanCities if city.isHasReligion(iJudaism)]
		
		if 2 * len(lJewishCities) < len(lEuropeanCities):
			pSpreadCity = utils.getRandomEntry(self.getTargetCities(lEuropeanCities, iJudaism))
			if pSpreadCity:
				pSpreadCity.spreadReligion(iJudaism)
Exemple #30
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
    def spreadJudaismMiddleEast(self, iGameTurn):
        if not gc.getGame().isReligionFounded(iJudaism): return
        if iGameTurn < getTurnForYear(600): return

        if iGameTurn % utils.getTurns(20) != utils.getTurns(5): return

        lMiddleEastCities = utils.getRegionCities(
            [rMesopotamia, rAnatolia, rEgypt])
        lJewishCities = [
            city for city in lMiddleEastCities if city.isHasReligion(iJudaism)
        ]

        if 2 * len(lJewishCities) < len(lMiddleEastCities):
            pSpreadCity = utils.getRandomEntry(
                self.getTargetCities(lMiddleEastCities, iJudaism))
            if pSpreadCity:
                pSpreadCity.spreadReligion(iJudaism)
    def spreadJudaismEurope(self, iGameTurn):
        if not gc.getGame().isReligionFounded(iJudaism): return
        if iGameTurn < getTurnForYear(1000): return

        if iGameTurn % utils.getTurns(10) != 0: return

        lEuropeanCities = utils.getRegionCities(
            [rIberia, rEurope, rItaly, rBritain, rRussia, rBalkans])
        lJewishCities = [
            city for city in lEuropeanCities if city.isHasReligion(iJudaism)
        ]

        if 2 * len(lJewishCities) < len(lEuropeanCities):
            pSpreadCity = utils.getRandomEntry(
                self.getTargetCities(lEuropeanCities, iJudaism))
            if pSpreadCity:
                pSpreadCity.spreadReligion(iJudaism)
	def decay(self, iCiv):
		teamCiv = gc.getTeam(gc.getPlayer(iCiv).getTeam())
		iCounter = 0
		
		# Initialize list
		lContacts = [i for i in range(iNumPlayers) if gc.getPlayer(i).isAlive() and teamCiv.canContact(i) and teamCiv.canCutContact(i)]
								
		# master/vassal relationships: if master can be seen, don't cut vassal contact and vice versa
		lRemove = []
		for iLoopPlayer in range(iNumPlayers):
			for iContact in lContacts:
				if gc.getTeam(iContact).isVassal(iLoopPlayer) and iLoopPlayer not in lContacts:
					lRemove.append(iContact)
				elif gc.getTeam(iLoopPlayer).isVassal(iContact) and iLoopPlayer not in lContacts:
					lRemove.append(iContact)
					
		# if there are still vassals in the list, their masters are too -> remove the vassals, and cut contact when their masters are chosen
		for iContact in lContacts:
			if gc.getTeam(iContact).isAVassal() and iContact not in lRemove:
				lRemove.append(iContact)
					
		for iLoopCiv in lRemove:
			if iLoopCiv in lContacts: lContacts.remove(iLoopCiv)
								
		# choose up to four random contacts to cut
		for i in range(4):
			if len(lContacts) == 0: break
			
			iContact = utils.getRandomEntry(lContacts)
			
			lOurCivs = [iCiv]
			lTheirCivs = [iContact]
			
			# remove contacts for all vassals on both sides as well
			for iLoopCiv in range(iNumPlayers):
				if gc.getTeam(iLoopCiv).isVassal(iCiv):
					lOurCivs.append(iLoopCiv)
				elif gc.getTeam(iLoopCiv).isVassal(iContact):
					lTheirCivs.append(iLoopCiv)
					
			for iOurCiv in lOurCivs:
				for iTheirCiv in lTheirCivs:
					#utils.debugTextPopup('Cut contact between ' + gc.getPlayer(iOurCiv).getCivilizationShortDescription(0) + ' and ' + gc.getPlayer(iTheirCiv).getCivilizationShortDescription(0))
					gc.getTeam(iOurCiv).cutContact(iTheirCiv)
					
			lContacts.remove(iContact)
	def canadianUP(self, city):
		iPopulation = 5 * city.getPopulation() / 2
		
		lProgress = []
		bAllZero = True
		for iSpecialist in [iGreatProphet, iGreatArtist, iGreatScientist, iGreatMerchant, iGreatEngineer, iGreatStatesman]:
			iProgress = city.getGreatPeopleUnitProgress(utils.getUniqueUnit(city.getOwner(), iSpecialist))
			if iProgress > 0: bAllZero = False
			lProgress.append(iProgress)
			
		if bAllZero:
			iGreatPerson = utils.getRandomEntry([iGreatProphet, iGreatArtist, iGreatScientist, iGreatMerchant, iGreatEngineer, iGreatStatesman])
		else:
			iGreatPerson = utils.getHighestIndex(lProgress) + iGreatProphet
			
		iGreatPerson = utils.getUniqueUnit(city.getOwner(), iGreatPerson)
		
		city.changeGreatPeopleProgress(iPopulation)
		city.changeGreatPeopleUnitProgress(iGreatPerson, iPopulation)
		
		if utils.getHumanID() == city.getOwner():
			CyInterface().addMessage(city.getOwner(), False, iDuration, CyTranslator().getText("TXT_KEY_UP_MULTICULTURALISM", (city.getName(), gc.getUnitInfo(iGreatPerson).getText(), iPopulation)), "", InterfaceMessageTypes.MESSAGE_TYPE_MINOR_EVENT, gc.getUnitInfo(iGreatPerson).getButton(), ColorTypes(iGreen), city.getX(), city.getY(), True, True)
	def canadianUP(self, city):
		iPopulation = 5 * city.getPopulation() / 2
		
		lProgress = []
		bAllZero = True
		for iSpecialist in [iGreatProphet, iGreatArtist, iGreatScientist, iGreatMerchant, iGreatEngineer, iGreatStatesman]:
			iProgress = city.getGreatPeopleUnitProgress(utils.getUniqueUnit(city.getOwner(), iSpecialist))
			if iProgress > 0: bAllZero = False
			lProgress.append(iProgress)
			
		if bAllZero:
			iGreatPerson = utils.getRandomEntry([iGreatProphet, iGreatArtist, iGreatScientist, iGreatMerchant, iGreatEngineer, iGreatStatesman])
		else:
			iGreatPerson = utils.getHighestIndex(lProgress) + iGreatProphet
			
		iGreatPerson = utils.getUniqueUnit(city.getOwner(), iGreatPerson)
		
		city.changeGreatPeopleProgress(iPopulation)
		city.changeGreatPeopleUnitProgress(iGreatPerson, iPopulation)
		
		if utils.getHumanID() == city.getOwner():
			CyInterface().addMessage(city.getOwner(), False, iDuration, CyTranslator().getText("TXT_KEY_UP_MULTICULTURALISM", (city.getName(), gc.getUnitInfo(iGreatPerson).getText(), iPopulation)), "", InterfaceMessageTypes.MESSAGE_TYPE_MINOR_EVENT, gc.getUnitInfo(iGreatPerson).getButton(), ColorTypes(iGreen), city.getX(), city.getY(), True, True)
	def checkChristianity(self, iGameTurn):
		if not gc.getGame().isReligionFounded(iJudaism): return
		if gc.getGame().isReligionFounded(iOrthodoxy): return
		
		iEthiopiaOffset = 0
		if utils.getHumanID() == iEthiopia: iEthiopiaOffset = utils.getTurns(10 + data.iSeed % 5)
		iOffset = utils.getTurns(data.iSeed % 15)
		
		if iGameTurn == getTurnForYear(0) + iOffset + iEthiopiaOffset:
			pHolyCity = gc.getGame().getHolyCity(iJudaism)
			
			if pHolyCity.getOwner() != utils.getHumanID() and gc.getGame().getSorenRandNum(2, "Holy city?") == 0:
				pChristianCity = pHolyCity
				self.foundReligion((pChristianCity.getX(), pChristianCity.getY()), iOrthodoxy)
				return

			lJewishCities = []
			for iPlayer in range(iNumTotalPlayersB):
				lJewishCities.extend([city for city in utils.getCityList(iPlayer) if city.isHasReligion(iJudaism) and city.getOwner() != utils.getHumanID()])
							
			if lJewishCities:
				pChristianCity = utils.getRandomEntry(lJewishCities)
				self.foundReligion((pChristianCity.getX(), pChristianCity.getY()), iOrthodoxy)
	def selectRandomCityCiv(self, iCiv): # Unused
		if gc.getPlayer(iCiv).isAlive():
			city = utils.getRandomEntry(utils.getCityList(iCiv))
			if city:
				return (city.getX(), city.getY())
		return False
    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)
Exemple #40
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
Exemple #41
0
    def doAliyah(self):

        # get available emigration cities
        lSourceCities = []
        # get target city: always the israeli capital
        pIsrael = gc.getPlayer(iIsrael)
        targetCity = pIsrael.getCapitalCity()

        for iPlayer in range(iNumPlayers):
            pPlayer = gc.getPlayer(iPlayer)

            # get Jewish cities of civs at war with Israel
            if gc.getTeam(pPlayer.getTeam()).isAtWar(iIsrael):
                for city in utils.getCityList(iPlayer):
                    if city.isHasReligion(iJudaism):
                        lSourceCities.append(city)

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

        iNumMigrations = 0
        if len(lSourceCities) > 0:
            iNumMigrations = (len(lSourceCities) / 4) + 1

        for iMigration in range(iNumMigrations):
            sourceCity = utils.getRandomEntry(lSourceCities)
            lSourceCities.remove(sourceCity)

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

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

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

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

            # remove Judaism from source city
            if sourceCity.isHasReligion(
                    iJudaism) and not sourceCity.isHolyCityByType(iJudaism):
                sourceCity.setHasReligion(iJudaism, False, True, True)

            # in the rare event that the Israeli capital is not Jewish, make it so
            if not targetCity.isHasReligion(iJudaism):
                targetCity.setHasReligion(iJudaism, True, True, True)

            # notify affected players
            if utils.getHumanID() == iSourcePlayer:
                CyInterface().addMessage(
                    iSourcePlayer, False, iDuration,
                    CyTranslator().getText("TXT_KEY_UP_EMIGRATION_ALIYAH",
                                           (sourceCity.getName(), )), "",
                    InterfaceMessageTypes.MESSAGE_TYPE_MINOR_EVENT,
                    gc.getUnitInfo(iSettler).getButton(), ColorTypes(iYellow),
                    sourceCity.getX(), sourceCity.getY(), True, True)
            elif utils.getHumanID() == iTargetPlayer:
                CyInterface().addMessage(
                    iTargetPlayer, False, iDuration,
                    CyTranslator().getText(
                        "TXT_KEY_UP_IMMIGRATION_ALIYAH",
                        (sourceCity.getName(), gc.getPlayer(iSourcePlayer).
                         getCivilizationShortDescriptionKey(),
                         targetCity.getName())), "",
                    InterfaceMessageTypes.MESSAGE_TYPE_MINOR_EVENT,
                    gc.getUnitInfo(iSettler).getButton(), ColorTypes(iYellow),
                    x, y, True, True)
    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)
Exemple #43
0
	def selectRandomCityCiv(self, iCiv): # Unused
		if gc.getPlayer(iCiv).isAlive():
			city = utils.getRandomEntry(utils.getCityList(iCiv))
			if city:
				return (city.getX(), city.getY())
		return False