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)
Exemplo n.º 2
0
	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)
Exemplo n.º 3
0
	def onBuildingBuilt(self, city, iPlayer, iBuilding):
		if iBuilding == iHinduTemple:
			if gc.getGame().isReligionFounded(iBuddhism): return
			self.foundBuddhism(city)
			
		if iBuilding == iOrthodoxCathedral:
			if gc.getGame().isReligionFounded(iCatholicism): return
		
			pOrthodoxHolyCity = gc.getGame().getHolyCity(iOrthodoxy)
		
			if pOrthodoxHolyCity.getOwner() != iPlayer:
				self.foundReligion((city.getX(), city.getY()), iCatholicism)
				pCatholicHolyCity = gc.getGame().getHolyCity(iCatholicism)
				self.schism(pOrthodoxHolyCity, pCatholicHolyCity, [], [city for city in utils.getAllCities() if city.isHasReligion(iOrthodoxy) and city.getOwner() != pOrthodoxHolyCity.getOwner()])
	def onBuildingBuilt(self, city, iPlayer, iBuilding):
		if iBuilding == iHinduTemple:
			if gc.getGame().isReligionFounded(iBuddhism): return
			self.foundBuddhism(city)

		if iBuilding == iConfucianTemple:
			if gc.getGame().isReligionFounded(iTaoism): return
			self.foundTaoism(city)

		if iBuilding == iOrthodoxCathedral:
			if gc.getGame().isReligionFounded(iCatholicism): return

			pOrthodoxHolyCity = gc.getGame().getHolyCity(iOrthodoxy)
			pCatholicHolyCity = gc.getGame().getHolyCity(iCatholicism)
		
			if pOrthodoxHolyCity.getOwner() != iPlayer:
				self.foundReligion((city.getX(), city.getY()), iCatholicism)
				self.schism(pOrthodoxHolyCity, pCatholicHolyCity, [], [city for city in utils.getAllCities() if city.isHasReligion(iOrthodoxy) and city.getOwner() != pOrthodoxHolyCity.getOwner()])
	def onBuildingBuilt(self, city, iPlayer, iBuilding):
		if iBuilding == iSaintSophia:
			for city in utils.getCityList(iPlayer):
				if city.plot().getSpreadFactor(iOrthodoxy) in [RegionSpreadTypes.REGION_SPREAD_CORE, RegionSpreadTypes.REGION_SPREAD_HISTORICAL]:
					city.spreadReligion(iOrthodoxy)
					
		if iBuilding == iHinduTemple:
			if gc.getGame().isReligionFounded(iBuddhism): return
			self.foundBuddhism(city)
			
		if iBuilding == iOrthodoxCathedral:
			if gc.getGame().isReligionFounded(iCatholicism): return
		
			pOrthodoxHolyCity = gc.getGame().getHolyCity(iOrthodoxy)
		
			if pOrthodoxHolyCity.getOwner() != iPlayer:
				self.foundReligion((city.getX(), city.getY()), iCatholicism)
				pCatholicHolyCity = gc.getGame().getHolyCity(iCatholicism)
				self.schism(pOrthodoxHolyCity, pCatholicHolyCity, [], [city for city in utils.getAllCities() if city.isHasReligion(iOrthodoxy) and city.getOwner() != pOrthodoxHolyCity.getOwner()])
Exemplo n.º 6
0
	def getUHVHelp(self, iPlayer, iGoal):
		"""Returns an array of help strings used by the Victory Screen table."""
		
		aHelp = []
		pPlayer = gc.getPlayer(iPlayer)
		iGameTurn = gc.getGame().getGameTurn()
		
		# the info is outdated or irrelevant once the goal has been accomplished or failed
		if sd.getGoal(iPlayer, iGoal) == 1:
			aHelp.append(self.getIcon(True) + localText.getText("TXT_KEY_VICTORY_GOAL_ACCOMPLISHED", ()))
			return aHelp
		elif sd.getGoal(iPlayer, iGoal) == 0:
			aHelp.append(self.getIcon(False) + localText.getText("TXT_KEY_VICTORY_GOAL_FAILED", ()))
			return aHelp
				
		
		if iPlayer == con.iCarthage:
			if iGoal == 0: 
				iTurnsLeft = abs(max(0, getTurnForYear(-350) - iGameTurn))
				iLuxuryCount = self.getNumLuxuries(con.iCarthage)
				iStrategicCount = self.getNumStrategicResources(con.iCarthage)
				aHelp.append(self.getIcon(iLuxuryCount >= 6 and iStrategicCount >= 6) + 'Luxury resources: ' + str(iLuxuryCount) + ' / 6' + self.getIcon(iStrategicCount >= 6) + 'Strategic resources: ' + str(iStrategicCount) + ' / 6')
				if iTurnsLeft > 0 and sd.getGoal(iPlayer, 0) == -1:
					aHelp.append(str(iTurnsLeft) + ' turns left')
					
			if iGoal == 1: 
				iTurnsLeft = abs(max(0, getTurnForYear(-300) - iGameTurn))
				bComplete = False
				iCarthageTrade = gc.getMap().plot(23, 33).getPlotCity().getTradeYield(YieldTypes.YIELD_COMMERCE)
				iBestTrade = 0
				for city in utils.getAllCities():
					if city.getX() != 23 and city.getY() != 33:
						iCityTrade = city.getTradeYield(YieldTypes.YIELD_COMMERCE)
						if iCityTrade > iBestTrade:
							iBestTrade = iCityTrade
							pBestCity = city
				aHelp.append('Top trade city: ' + pBestCity.getName() + 'Trade: ' + str(iBestTrade))
				if iCarthageTrade > iCityTrade:
					aHelp.append(self.getIcon(iCarthageTrade > iBestTrade) + 'Carthage top trade city')
				else:
					aHelp.append(self.getIcon(iCarthageTrade > iBestTrade) + pBestCity.getName() + ' top trade city')
							
				if iTurnsLeft > 0 and sd.getGoal(iPlayer, 0) == -1:
					aHelp.append(str(iTurnsLeft) + ' turns left')
					
			if iGoal == 2:  
				iTurnsLeft = abs(max(0, getTurnForYear(-200) - iGameTurn))
				bComplete = False
				if sd.getGoal(con.iCarthage, 1) == 1: bComplete = True
				aHelp.append(self.getIcon(bComplete) + 'Romans destroyed')
				if iTurnsLeft > 0 and sd.getGoal(iPlayer, 0) == -1:
					aHelp.append(str(iTurnsLeft) + ' turns left')
					
		if iPlayer == con.iAthens:
			if iGoal == 0:
				iTurnsLeft = abs(max(0, getTurnForYear(-350) - iGameTurn))
				iPorts = 0
				for city in utils.getCityList(iPlayer):
					if (city.getX(), city.getY()) in con.lAegeanPortTiles:
						iPorts += 1
				aHelp.append(self.getIcon(iPorts >= 5) + 'Aegean ports: ' + str(iPorts) + ' / 5')
				if iTurnsLeft > 0 and sd.getGoal(iPlayer, 0) == -1:
					aHelp.append(str(iTurnsLeft) + ' turns left')
						
			if iGoal == 1:
				bParthenon = self.getNumBuildings(iPlayer, con.iParthenon)
				bDionysis = self.getNumBuildings(iPlayer, con.iDionysis)
				bAcademy = self.getNumBuildings(iPlayer, con.iAcademy)
				aHelp.append(self.getIcon(bParthenon) + 'Parthenon, ' + self.getIcon(bDionysis) + 'Dionysis, ' + self.getIcon(bAcademy) + 'Academy')
				
			if iGoal == 2:
				iTurnsLeft = abs(max(0, getTurnForYear(-300) - iGameTurn))
				iCount = 0
				if pPlayer.getNumCities() > 0:
					capital = pPlayer.getCapitalCity()
					iCount = self.countGreatPeople((capital.getX(), capital.getY()))
				aHelp.append(self.getIcon(iCount >= 5) + 'Great people settled: ' + str(iCount) + ' / 5')
				if iTurnsLeft > 0 and sd.getGoal(iPlayer, 0) == -1:
					aHelp.append(str(iTurnsLeft) + ' turns left')
				
				
		if iPlayer == con.iNandas:
			if iGoal == 0:
				iTurnsLeft = abs(max(0, getTurnForYear(-330) - iGameTurn))
				bMagadha = utils.checkRegionControl(iPlayer, con.rMagadha, True)
				bAnga = utils.checkRegionControl(iPlayer, con.rAnga, True)
				bAvanti = utils.checkRegionControl(iPlayer, con.rAvanti, True)
				bPunjab = utils.checkRegionControl(iPlayer, con.rPunjab, True)
				aHelp.append(self.getIcon(bMagadha) + 'Magadha, ' + self.getIcon(bAnga) + 'Anga, ' + self.getIcon(bPunjab) + 'Punjab, ' + self.getIcon(bAvanti) + 'Avanti')
				if iTurnsLeft > 0 and sd.getGoal(iPlayer, 0) == -1:
					aHelp.append(str(iTurnsLeft) + ' turns left')
			if iGoal == 1:
				iTurnsLeft = abs(max(0, getTurnForYear(-330) - iGameTurn))
				iBestArmy = 0
				iNandaArmy = gc.getPlayer(iPlayer).getNumUnits()
				for iLoopPlayer in range(con.iNumPlayers):
					iLoopArmy = gc.getPlayer(iLoopPlayer).getNumUnits()
					if iLoopArmy > iBestArmy:
						iBestArmy = iLoopArmy
				aHelp.append(self.getIcon(iNandaArmy > iBestArmy) + 'Army size: ' + str(iNandaArmy) + '    Rival army size: ' + str(iBestArmy))
				if iTurnsLeft > 0 and sd.getGoal(iPlayer, 0) == -1:
					aHelp.append(str(iTurnsLeft) + ' turns left')
			if iGoal == 2:
				iTurnsLeft = abs(max(0, getTurnForYear(-330) - iGameTurn))
				iBestGold = 0
				iNandaGold = gc.getPlayer(iPlayer).getGold()
				for iLoopPlayer in range(con.iNumPlayers):
					iLoopGold = gc.getPlayer(iLoopPlayer).getGold()
					if iLoopGold > iBestGold:
						iBestGold = iLoopGold
				aHelp.append(self.getIcon(iNandaGold > iBestGold) + 'Gold: ' + str(iNandaGold) + '    Rival gold: ' + str(iBestGold))
				if iTurnsLeft > 0 and sd.getGoal(iPlayer, 0) == -1:
					aHelp.append(str(iTurnsLeft) + ' turns left')
		
		if iPlayer == con.iQin:
			if iGoal == 0: 
				iTurnsLeft = abs(max(0, getTurnForYear(-215) - iGameTurn))
				bWall = self.getNumBuildings(iPlayer, con.iGreatWall)
				bArmy = self.getNumBuildings(iPlayer, con.iTerracottaArmy)
				aHelp.append(self.getIcon(bWall) + 'The Great Wall, ' + self.getIcon(bArmy) + 'The Terracotta Army')
				if iTurnsLeft > 0 and sd.getGoal(iPlayer, 0) == -1:
					aHelp.append(str(iTurnsLeft) + ' turns left')
			if iGoal == 1:
				iTurnsLeft = abs(max(0, getTurnForYear(-210) - iGameTurn))
				bQin = utils.checkRegionControl(iPlayer, con.rQin)
				bHan = utils.checkRegionControl(iPlayer, con.rHan)
				bYan = utils.checkRegionControl(iPlayer, con.rYan)
				bZhao = utils.checkRegionControl(iPlayer, con.rZhao)
				bChu = utils.checkRegionControl(iPlayer, con.rChu)
				bNanYue = utils.checkRegionControl(iPlayer, con.rNanYue)
				bWu = utils.checkRegionControl(iPlayer, con.rWu)
				bQi = utils.checkRegionControl(iPlayer, con.rQi)
				aHelp.append(self.getIcon(bQin) + 'Qin, ' + self.getIcon(bHan) + 'Han, ' + self.getIcon(bYan) + 'Yan, ' + self.getIcon(bZhao) + 'Zhao, ' + self.getIcon(bChu) + 'Chu ' + self.getIcon(bNanYue) + 'Nan Yue, ' + self.getIcon(bQi) + 'Qi ' + self.getIcon(bWu) + 'Wu')
				if iTurnsLeft > 0 and sd.getGoal(iPlayer, 0) == -1:
					aHelp.append(str(iTurnsLeft) + ' turns left')
			if iGoal == 2:
				iTurnsLeft = abs(max(0, getTurnForYear(-100) - iGameTurn))
				iCount = self.getNumProvinces(iPlayer)
				aHelp.append(self.getIcon(iCount >= 9) + 'Provinces controlled: ' + str(iCount) + ' / 9')
				if iTurnsLeft > 0 and sd.getGoal(iPlayer, 0) == -1:
					aHelp.append(str(iTurnsLeft) + ' turns left')
				
		
				
				
		
		
		
		return aHelp
Exemplo n.º 7
0
	def checkPlayerTurn(self, iGameTurn, iPlayer):
		
		iHuman = utils.getHumanID()
		pPlayer = gc.getPlayer(iPlayer)
		
		# CARTHAGE
		if iPlayer == con.iCarthage:
				
			# Carthaginian UHV1: Obtain 6 luxury resources and 6 strategic resources by 350BC
			if sd.getGoal(iPlayer, 0) == -1:
				if iGameTurn <= getTurnForYear(-350):
					if self.getNumLuxuries(iPlayer) >= 6 and self.getNumStrategicResources(iPlayer) >= 6:
						sd.setGoal(iPlayer, 0, 1)
				else:
					sd.setGoal(iPlayer, 0, 0)
						
			# Carthaginian UHV2: Make Carthage the most prosperous trading city in the world in 300BC
			if iGameTurn <= getTurnForYear(-300):
				iCarthageTrade = gc.getMap().plot(23, 33).getPlotCity().getTradeYield(YieldTypes.YIELD_COMMERCE)
				iBestTrade = 0
				for city in utils.getAllCities():
					if city.getX() != 23 and city.getY() != 33:
						iCityTrade = city.getTradeYield(YieldTypes.YIELD_COMMERCE)
						if iCityTrade > iBestTrade:
							iBestTrade = iCityTrade
				if iCarthageTrade > iBestTrade:
					sd.setGoal(iPlayer, 1, 1)
				else:
					sd.setGoal(iPlayer, 1, 0)
		
		# ATHENS
		if iPlayer == con.iAthens:
		
			# Control five Aegean ports by 350BC
			if sd.getGoal(iPlayer, 0) == -1:
				if iGameTurn <= getTurnForYear(-350):
					iPorts = 0
					for city in utils.getCityList(iPlayer):
						if (city.getX(), city.getY()) in con.lAegeanPortTiles:
							iPorts += 1
					if iPorts >= 5:
						sd.setGoal(iPlayer, 0, 1)
				else:
					sd.setGoal(iPlayer, 0, 0)
					
			# Build the Parthenon, the Theatre of Dionysis and the Academy see onBuildingBuilt
			
			# Settle five Great People in your capital by 300BC
			if sd.getGoal(iPlayer, 2) == -1:
				if iGameTurn <= getTurnForYear(300):
					iCount = 0
					if pPlayer.getNumCities() > 0:
						capital = pPlayer.getCapitalCity()
						if self.countGreatPeople((capital.getX(), capital.getY())) >= 5:
							sd.setGoal(iPlayer, 2, 1)
				else:
					sd.setGoal(iPlayer, 2, 0)
					
		# NANDAS
		if iPlayer == con.iNandas:
			
			# Control northern India by 330BC
			if sd.getGoal(iPlayer, 0) == -1:
				if iGameTurn <= getTurnForYear(-330):
					bControl = true
					regionList = [con.rMagadha, con.rAnga, con.rAvanti, con.rPunjab]
					for regionID in regionList:
						if not utils.checkRegionControl(iPlayer, regionID, True):
							bControl = false
					if bControl:
						sd.setGoal(iPlayer, 0, 1)
				else:
					sd.setGoal(iPlayer, 0, 0)
						
			# Control the world's largest army by 330BC
			if sd.getGoal(iPlayer, 1) == -1:
				if iGameTurn <= getTurnForYear(-330):
					iBestArmy = 0
					iNandaArmy = gc.getPlayer(iPlayer).getNumUnits()
					for iLoopPlayer in range(con.iNumPlayers):
						iLoopArmy = gc.getPlayer(iLoopPlayer).getNumUnits()
						if iLoopArmy > iBestArmy:
							iBestArmy = iLoopArmy
					if iBestArmy > iNandaArmy:
						sd.setGoal(iPlayer, 1, 1)
				else:
					sd.setGoal(iPlayer, 1, 0)
					
			# Be the world's richest civilization in 330BC
			if iGameTurn == getTurnForYear(-330):
				iBestGold = 0
				iNandaGold = gc.getPlayer(iPlayer).getGold()
				for iLoopPlayer in range(con.iNumPlayers):
					iLoopGold = gc.getPlayer(iPlayer).getGold()
					if iLoopGold > iBestGold:
						iBestGold = iLoopGold
				if iNandaGold > iBestGold:
					sd.setGoal(iPlayer, 2, 1)
				else:
					sd.setGoal(iPlayer, 2, 0)
					
		# QIN
		if iPlayer == con.iQin:
		# Qin UHV1: Build the Great Wall and the Terracotta Army by 215BC see onBuildingBuilt
			if sd.getGoal(iPlayer, 0) == -1:
				if iGameTurn >= getTurnForYear(-215):
					sd.setGoal(iPlayer, 0, 0)
			
			# Qin UHV2: control central and north China by 210BC
			if sd.getGoal(iPlayer, 1) == -1:
				if iGameTurn <= getTurnForYear(-210):
					bControl = True
					regionList = [con.rQin, con.rHan, con.rYan, con.rZhao, con.rChu, con.rNanYue, con.rQi, con.rWu, con.rShu]
					for regionID in regionList:
						if not utils.checkRegionControl(iPlayer, regionID):
							bControl = False
					if bControl:
						sd.setGoal(iPlayer, 1, 1)
				else:
					sd.setGoal(iPlayer, 1, 0)
			
			# Qin UHV3: control at least 9 provinces in 100BC
			if sd.getGoal(iPlayer, 2) == -1:
				if iGameTurn == getTurnForYear(-100):
					if self.getNumProvinces(iPlayer) >= 9:
						sd.setGoal(iPlayer, 2, 1)
					else:
						sd.setGoal(iPlayer, 2, 0)
						
			
			
		
		# HISTORICAL VICTORY
		if gc.getGame().isVictoryValid(iHistoricalVictory):
		
			
			
			#generic checks
			if pPlayer.isAlive() and iPlayer < con.iNumPlayers:
				if sd.get2OutOf3(iPlayer) == False:
					if utils.countAchievedGoals(iPlayer) == 2:
						#intermediate bonus
						sd.set2OutOf3(iPlayer, True)
						if pPlayer.getNumCities() > 0: #this check is needed, otherwise game crashes
							pPlayer.changeGoldenAgeTurns(pPlayer.getGoldenAgeLength()) # edead
							iWarCounter = 0
							iRndnum = gc.getGame().getSorenRandNum(con.iNumPlayers, 'civs')
							iHandicap = gc.getGame().getHandicapType()
							for i in range(iRndnum, con.iNumPlayers + iRndnum):
								iCiv = i % con.iNumPlayers
								pCiv = gc.getPlayer(iCiv)
								if pCiv.isAlive() and pCiv.canContact(iPlayer):                                                                
									if pCiv.AI_getAttitude(iPlayer) <= 0:
										teamCiv = gc.getTeam(pCiv.getTeam())
										if not teamCiv.isAtWar(iPlayer) and not teamCiv.isDefensivePact(iPlayer) and not utils.isAVassal(iCiv):
											teamCiv.AI_setWarPlan(iPlayer, WarPlanTypes.WARPLAN_PREPARING_TOTAL) # edead: prepare for total war
											iWarCounter += 1
											if iWarCounter == 1 + max(1, iHandicap):
												break
			if gc.getGame().getWinner() == -1:
				if sd.getGoal(iPlayer, 0) == 1 and sd.getGoal(iPlayer, 1) == 1 and sd.getGoal(iPlayer, 2) == 1:
					gc.getGame().setWinner(iPlayer, iHistoricalVictory)
				
		# RELIGIOUS VICTORY
		if gc.getGame().isVictoryValid(iReligiousVictory) and iPlayer == iHuman:
			if iGameTurn >= getTurnForYear(con.tBirth[iPlayer]) and gc.getPlayer(iPlayer).getStateReligion() != -1:
				for i in range(3):
					if sd.getReligiousGoal(iPlayer, i) == -1:
						if self.getURV(iPlayer, i):
							sd.setReligiousGoal(iPlayer, i, 1)
				if gc.getGame().getWinner() == -1:
					if sd.getReligiousGoal(iPlayer, 0) == 1 and sd.getReligiousGoal(iPlayer, 1) == 1 and sd.getReligiousGoal(iPlayer, 2) == 1:
						gc.getGame().setWinner(iPlayer, iReligiousVictory)