def onGreatPersonBorn(self, argsList): 'Great Person Born' pUnit, iPlayer, pCity = argsList gp.onGreatPersonBorn(pUnit, iPlayer, pCity) vic.onGreatPersonBorn(iPlayer, pUnit) sta.onGreatPersonBorn(iPlayer)
def onFirstContact(self, argsList): iTeamX,iHasMetTeamY = argsList if iTeamX < iNumPlayers: self.rnf.onFirstContact(iTeamX, iHasMetTeamY) self.pla.onFirstContact(iTeamX, iHasMetTeamY) vic.onFirstContact(iTeamX, iHasMetTeamY)
def onFirstContact(self, argsList): iTeamX, iHasMetTeamY = argsList if iTeamX < iNumPlayers: self.rnf.onFirstContact(iTeamX, iHasMetTeamY) self.pla.onFirstContact(iTeamX, iHasMetTeamY) vic.onFirstContact(iTeamX, iHasMetTeamY)
def onGameStart(self, argsList): 'Called at the start of the game' sd.setup() # edead self.rnf.setup() self.rel.setup() self.pla.setup() self.dc.setup() self.aiw.setup() vic.setup() cong.setup() # area debug #sContinentDebug = "" #for y in range(con.iWorldY-1, 0, -1): # for x in range(con.iWorldX): # sContinentDebug += str(gc.getMap().plot(x, y).getArea()) + ", " # sContinentDebug += "\n" ##print sContinentDebug # Leoreth: set DLL core values for x in range(124): for y in range(68): plot = gc.getMap().plot(x, y) if plot.isWater(): continue for iPlayer in range(con.iNumPlayers): if utils.isPlotInArea((x, y), con.tCoreAreasTL[0][iPlayer], con.tCoreAreasBR[0][iPlayer], con.tExceptions[0][iPlayer]): plot.setCore(iPlayer, False, True) if utils.isPlotInArea((x, y), con.tCoreAreasTL[1][iPlayer], con.tCoreAreasBR[1][iPlayer], con.tExceptions[1][iPlayer]): plot.setCore(iPlayer, True, True) return 0
def onUnitPillage(self, argsList): unit, iImprovement, iRoute, iPlayer, iGold = argsList iUnit = unit.getUnitType() if (iPlayer == iVikings or iPlayer == iMoors ) and iGold > 0 and iImprovement != -1 and iGold < 1000: vic.onUnitPillage(iPlayer, iGold, iUnit)
def onCombatResult(self, argsList): self.up.aztecUP(argsList) self.rnf.immuneMode(argsList) self.up.vikingUP(argsList) # includes Moorish Corsairs pWinningUnit, pLosingUnit = argsList vic.onCombatResult(pWinningUnit, pLosingUnit) iUnitPower = 0 pLosingUnitInfo = gc.getUnitInfo(pLosingUnit.getUnitType()) if pLosingUnitInfo.getUnitCombatType() != gc.getInfoTypeForString("UNITCOMBAT_SIEGE"): iUnitPower = pLosingUnitInfo.getPowerValue() sta.onCombatResult(pWinningUnit.getOwner(), pLosingUnit.getOwner(), iUnitPower) # catch slaves by defeating native and barbarian Pombos or Impis if pLosingUnit.getOwner() in [con.iBarbarian, con.iNative] and pLosingUnit.getUnitType() in [con.iZuluImpi, con.iKongoPombos]: if gc.getMap().plot(pLosingUnit.getX(), pLosingUnit.getY()).getOwner() == pWinningUnit.getOwner(): if gc.getPlayer(pWinningUnit.getOwner()).getCivics(2) == con.iCivicSlavery: iRand = gc.getGame().getSorenRandNum(5, "Caught slaves?") if iRand == 1: iNewUnit = utils.getUniqueUnitType(pWinningUnit.getOwner(), gc.getUnitInfo(con.iSlave).getUnitClassType()) utils.makeUnit(iNewUnit, pWinningUnit.getOwner(), (pWinningUnit.getX(), pWinningUnit.getY()), 1) CyInterface().addMessage(pWinningUnit.getOwner(),True,15,CyTranslator().getText("TXT_KEY_UP_ENSLAVE_WIN", ()),'SND_REVOLTEND',1,'Art/Units/slave/button_slave.dds',ColorTypes(8),pWinningUnit.getX(),pWinningUnit.getY(),True,True) # Maya Holkans give food to closest city on victory if pWinningUnit.getUnitType() == con.iMayaHolkan: iOwner = pWinningUnit.getOwner() city = gc.getMap().findCity(pWinningUnit.getX(), pWinningUnit.getY(), iOwner, TeamTypes.NO_TEAM, False, False, TeamTypes.NO_TEAM, DirectionTypes.NO_DIRECTION, CyCity()) if city: city.changeFood(5) sAdjective = gc.getPlayer(pLosingUnit.getOwner()).getCivilizationAdjectiveKey() CyInterface().addMessage(iOwner, False, con.iDuration, CyTranslator().getText("TXT_KEY_MAYA_HOLKAN_EFFECT", (sAdjective, pLosingUnit.getNameKey(), 5, city.getName())), "", 0, "", ColorTypes(con.iWhite), -1, -1, True, True)
def onCombatResult(self, argsList): self.up.aztecUP(argsList) self.rnf.immuneMode(argsList) self.up.vikingUP(argsList) # includes Moorish Corsairs pWinningUnit, pLosingUnit = argsList vic.onCombatResult(pWinningUnit, pLosingUnit) iUnitPower = 0 pLosingUnitInfo = gc.getUnitInfo(pLosingUnit.getUnitType()) if pLosingUnitInfo.getUnitCombatType() != gc.getInfoTypeForString("UNITCOMBAT_SIEGE"): iUnitPower = pLosingUnitInfo.getPowerValue() sta.onCombatResult(pWinningUnit.getOwner(), pLosingUnit.getOwner(), iUnitPower) # catch slaves by defeating native and barbarian Pombos or Impis if pLosingUnit.getOwner() in [iBarbarian, iNative] and pLosingUnit.getUnitType() in [iZuluImpi, iCongolesePombos]: if gc.getMap().plot(pLosingUnit.getX(), pLosingUnit.getY()).getOwner() == pWinningUnit.getOwner(): if gc.getPlayer(pWinningUnit.getOwner()).getCivics(2) == iCivicSlavery: iRand = gc.getGame().getSorenRandNum(5, "Caught slaves?") if iRand == 1: iNewUnit = utils.getUniqueUnitType(pWinningUnit.getOwner(), gc.getUnitInfo(iSlave).getUnitClassType()) utils.makeUnit(iNewUnit, pWinningUnit.getOwner(), (pWinningUnit.getX(), pWinningUnit.getY()), 1) CyInterface().addMessage(pWinningUnit.getOwner(),True,15,CyTranslator().getText("TXT_KEY_UP_ENSLAVE_WIN", ()),'SND_REVOLTEND',1,'Art/Units/slave/button_slave.dds',ColorTypes(8),pWinningUnit.getX(),pWinningUnit.getY(),True,True) # Maya Holkans give food to closest city on victory if pWinningUnit.getUnitType() == iMayanHolkan: iOwner = pWinningUnit.getOwner() city = gc.getMap().findCity(pWinningUnit.getX(), pWinningUnit.getY(), iOwner, TeamTypes.NO_TEAM, False, False, TeamTypes.NO_TEAM, DirectionTypes.NO_DIRECTION, CyCity()) if city: city.changeFood(5) sAdjective = gc.getPlayer(pLosingUnit.getOwner()).getCivilizationAdjectiveKey() CyInterface().addMessage(iOwner, False, iDuration, CyTranslator().getText("TXT_KEY_MAYA_HOLKAN_EFFECT", (sAdjective, pLosingUnit.getNameKey(), 5, city.getName())), "", 0, "", ColorTypes(iWhite), -1, -1, True, True)
def onGreatPersonBorn(self, argsList): 'Great Person Born' pUnit, iPlayer, pCity = argsList player = PyPlayer(iPlayer) iUnitType = pUnit.getUnitType() iUnitClassType = pUnit.getUnitClassType() sName = pUnit.getName() # Leoreth: replace graphics for female GP names if sName[0] == "f": pUnit.setName(sName[1:]) pUnit = utils.replace(pUnit, con.dFemaleGreatPeople[utils.getBaseUnit(iUnitType)]) # Leoreth: display notification if iPlayer not in [con.iIndependent, con.iIndependent2, con.iBarbarian]: pDisplayCity = pCity if pDisplayCity.isNone(): pDisplayCity = gc.getMap().findCity(pUnit.getX(), pUnit.getY(), PlayerTypes.NO_PLAYER, TeamTypes.NO_TEAM, False, False, TeamTypes.NO_TEAM, DirectionTypes.NO_DIRECTION, CyCity()) sCity = "%s (%s)" % (pDisplayCity.getName(), gc.getPlayer(pDisplayCity.getOwner()).getCivilizationShortDescription(0)) sMessage = localText.getText("TXT_KEY_MISC_GP_BORN", (pUnit.getName(), sCity)) sUnrevealedMessage = localText.getText("TXT_KEY_MISC_GP_BORN_SOMEWHERE", (pUnit.getName(),)) if pCity.isNone(): sMessage = localText.getText("TXT_KEY_MISC_GP_BORN_OUTSIDE", (pUnit.getName(), sCity)) for iLoopPlayer in range(con.iNumPlayers): if gc.getPlayer(iLoopPlayer).isAlive(): if pUnit.plot().isRevealed(gc.getPlayer(iLoopPlayer).getTeam(), False): CyInterface().addMessage(iLoopPlayer, False, con.iDuration, sMessage, "AS2D_UNIT_GREATPEOPLE", InterfaceMessageTypes.MESSAGE_TYPE_MAJOR_EVENT, pUnit.getButton(), ColorTypes(gc.getInfoTypeForString("COLOR_UNIT_TEXT")), pUnit.getX(), pUnit.getY(), True, True) else: CyInterface().addMessage(iLoopPlayer, False, con.iDuration, sUnrevealedMessage, "AS2D_UNIT_GREATPEOPLE", InterfaceMessageTypes.MESSAGE_TYPE_MAJOR_EVENT, "", ColorTypes(gc.getInfoTypeForString("COLOR_UNIT_TEXT")), -1, -1, False, False) vic.onGreatPersonBorn(iPlayer, pUnit) sta.onGreatPersonBorn(iPlayer)
def onCombatResult(self, argsList): self.rnf.immuneMode(argsList) self.up.vikingUP(argsList) # includes Moorish Corsairs pWinningUnit, pLosingUnit = argsList iWinningPlayer = pWinningUnit.getOwner() iLosingPlayer = pLosingUnit.getOwner() vic.onCombatResult(pWinningUnit, pLosingUnit) iUnitPower = 0 pLosingUnitInfo = gc.getUnitInfo(pLosingUnit.getUnitType()) if pLosingUnitInfo.getUnitCombatType() != gc.getInfoTypeForString( "UNITCOMBAT_SIEGE"): iUnitPower = pLosingUnitInfo.getPowerValue() sta.onCombatResult(iWinningPlayer, iLosingPlayer, iUnitPower) # capture slaves if iWinningPlayer == iAztecs and not pAztecs.isReborn(): utils.captureUnit(pLosingUnit, pWinningUnit, iAztecSlave, 35) elif iLosingPlayer == iNative: if iWinningPlayer not in lCivBioNewWorld or True in data.lFirstContactConquerors: if gc.getPlayer(iWinningPlayer).isSlavery() or gc.getPlayer( iWinningPlayer).isColonialSlavery(): utils.captureUnit(pLosingUnit, pWinningUnit, iSlave, 35) # Maya Holkans give food to closest city on victory if pWinningUnit.getUnitType() == iHolkan: iOwner = pWinningUnit.getOwner() if gc.getPlayer(iOwner).getNumCities() > 0: city = gc.getMap().findCity(pWinningUnit.getX(), pWinningUnit.getY(), iOwner, TeamTypes.NO_TEAM, False, False, TeamTypes.NO_TEAM, DirectionTypes.NO_DIRECTION, CyCity()) if city: city.changeFood(5) if utils.getHumanID() == pWinningUnit.getOwner(): data.iTeotlSacrifices += 1 sAdjective = gc.getPlayer( pLosingUnit.getOwner()).getCivilizationAdjectiveKey() CyInterface().addMessage( iOwner, False, iDuration, CyTranslator().getText( "TXT_KEY_MAYA_HOLKAN_EFFECT", (sAdjective, pLosingUnit.getNameKey(), 5, city.getName())), "", 0, "", ColorTypes(iWhite), -1, -1, True, True) # Brandenburg Gate effect if gc.getPlayer(iLosingPlayer).isHasBuildingEffect(iBrandenburgGate): for iPromotion in range(gc.getNumPromotionInfos()): if gc.getPromotionInfo(iPromotion).isLeader( ) and pLosingUnit.isHasPromotion(iPromotion): gc.getPlayer(iLosingPlayer).restoreGeneralThreshold()
def onCityRazed(self, argsList): city, iPlayer = argsList dc.onCityRazed(city.getOwner()) self.pla.onCityRazed(city, iPlayer) #Plague vic.onCityRazed(iPlayer, city) sta.onCityRazed(iPlayer, city)
def onCityRazed(self, argsList): city, iPlayer = argsList self.dc.onCityRazed(argsList) self.pla.onCityRazed(city,iPlayer) #Plague vic.onCityRazed(iPlayer, city) sta.onCityRazed(iPlayer, city)
def onBuildingBuilt(self, argsList): city, iBuildingType = argsList iOwner = city.getOwner() tCity = (city.getX(), city.getY()) vic.onBuildingBuilt(iOwner, iBuildingType) self.rel.onBuildingBuilt(city, iOwner, iBuildingType) if iOwner < iNumPlayers: self.com.onBuildingBuilt(iOwner, iBuildingType, city) if isWorldWonderClass(gc.getBuildingInfo(iBuildingType).getBuildingClassType()): sta.onWonderBuilt(iOwner, iBuildingType) if iBuildingType == iPalace: sta.onPalaceMoved(iOwner) dc.onPalaceMoved(iOwner) if city.isHasRealBuilding(iAdministrativeCenter): city.setHasRealBuilding(iAdministrativeCenter, False) # Leoreth: in case human Phoenicia moves palace to Carthage if iOwner == iCarthage and tCity == (58, 39): utils.setReborn(iCarthage, True) # Leoreth: update trade routes when Porcelain Tower is built to start its effect if iBuildingType == iPorcelainTower: gc.getPlayer(iOwner).updateTradeRoutes() # Leoreth/Voyhkah: Empire State Building if iBuildingType == iEmpireStateBuilding: iPop = city.getPopulation() city.setBuildingCommerceChange(gc.getInfoTypeForString("BUILDINGCLASS_EMPIRE_STATE_BUILDING"), 0, iPop) # Leoreth: Machu Picchu if iBuildingType == iMachuPicchu: iNumPeaks = 0 for i in range(21): if city.getCityIndexPlot(i).isPeak(): iNumPeaks += 1 city.setBuildingCommerceChange(gc.getInfoTypeForString("BUILDINGCLASS_MACHU_PICCHU"), 0, iNumPeaks * 2) # Leoreth: Great Wall if iBuildingType == iGreatWall: for iPlot in range(gc.getMap().numPlots()): plot = gc.getMap().plotByIndex(iPlot) if plot.getOwner() == iOwner and not plot.isWater(): plot.setWithinGreatWall(True) # Leoreth: La Mezquita if iBuildingType == iMezquita: lGPList = [0, 0, 0, 0, 0, 0, 0] for city in utils.getCityList(iOwner): for i in range(7): iSpecialistUnit = utils.getUniqueUnit(iOwner, iGreatProphet + i) lGPList[i] += city.getGreatPeopleUnitProgress(iSpecialistUnit) iGPType = utils.getUniqueUnit(iOwner, iGreatProphet + utils.getHighestIndex(lGPList)) utils.makeUnit(iGPType, iOwner, tCity, 1) CyInterface().addMessage(iOwner, False, iDuration, CyTranslator().getText("TXT_KEY_MEZQUITA_FREE_GP", (gc.getUnitInfo(iGPType).getText(), city.getName())), "", InterfaceMessageTypes.MESSAGE_TYPE_MINOR_EVENT, gc.getUnitInfo(iGPType).getButton(), ColorTypes(iWhite), city.getX(), city.getY(), True, True)
def onReligionFounded(self, argsList): 'Religion Founded' iReligion, iFounder = argsList if gc.getGame().getGameTurn() == utils.getScenarioStartTurn(): return vic.onReligionFounded(iFounder, iReligion) self.rel.onReligionFounded(iReligion, iFounder)
def onPlayerChangeStateReligion(self, argsList): 'Player changes his state religion' iPlayer, iNewReligion, iOldReligion = argsList if iPlayer < iNumPlayers: dc.onPlayerChangeStateReligion(iPlayer, iNewReligion) sta.onPlayerChangeStateReligion(iPlayer) vic.onPlayerChangeStateReligion(iPlayer, iNewReligion)
def onProjectBuilt(self, argsList): city, iProjectType = argsList vic.onProjectBuilt(city.getOwner(), iProjectType) # Space Elevator effect: +5 commerce per space projectBuilt if gc.getProjectInfo(iProjectType).isSpaceship(): city = utils.getBuildingEffectCity(iSpaceElevator) if city: city.changeBuildingYieldChange( gc.getBuildingInfo(iSpaceElevator).getBuildingClassType(), YieldTypes.YIELD_COMMERCE, 5)
def onBuildingBuilt(self, argsList): city, iBuildingType = argsList iOwner = city.getOwner() tCity = (city.getX(), city.getY()) vic.onBuildingBuilt(iOwner, iBuildingType) self.rel.onBuildingBuilt(city, iOwner, iBuildingType) self.up.onBuildingBuilt(city, iOwner, iBuildingType) if iOwner < iNumPlayers: self.com.onBuildingBuilt(iOwner, iBuildingType, city) if isWorldWonderClass( gc.getBuildingInfo(iBuildingType).getBuildingClassType()): sta.onWonderBuilt(iOwner, iBuildingType) if iBuildingType == iPalace: sta.onPalaceMoved(iOwner) dc.onPalaceMoved(iOwner) if city.isHasRealBuilding(iAdministrativeCenter): city.setHasRealBuilding(iAdministrativeCenter, False) # Leoreth: in case human Phoenicia moves palace to Carthage if iOwner == iCarthage and tCity == (58, 39): utils.setReborn(iCarthage, True) # Leoreth: update trade routes when Porcelain Tower is built to start its effect if iBuildingType == iPorcelainTower: gc.getPlayer(iOwner).updateTradeRoutes() # Leoreth/Voyhkah: Empire State Building if iBuildingType == iEmpireStateBuilding: iPop = city.getPopulation() city.setBuildingCommerceChange( gc.getBuildingInfo( iEmpireStateBuilding).getBuildingClassType(), 0, iPop) # Leoreth: Machu Picchu if iBuildingType == iMachuPicchu: iNumPeaks = 0 for i in range(21): if city.getCityIndexPlot(i).isPeak(): iNumPeaks += 1 city.setBuildingCommerceChange( gc.getBuildingInfo(iMachuPicchu).getBuildingClassType(), 0, iNumPeaks * 2) # Leoreth: Great Wall if iBuildingType == iGreatWall: for iPlot in range(gc.getMap().numPlots()): plot = gc.getMap().plotByIndex(iPlot) if plot.getOwner() == iOwner and not plot.isWater(): plot.setWithinGreatWall(True)
def onCityRazed(self, argsList): city, iPlayer = argsList dc.onCityRazed(city.getPreviousOwner()) self.pla.onCityRazed(city, iPlayer) #Plague vic.onCityRazed(iPlayer, city) sta.onCityRazed(iPlayer, city) # Israeli UP if city.isHasReligion(iJudaism): self.up.computeAliyahBonus()
def onChangeWar(self, argsList): bWar, iTeam, iOtherTeam = argsList sta.onChangeWar(bWar, iTeam, iOtherTeam) self.up.onChangeWar(bWar, iTeam, iOtherTeam) vic.onChangeWar(bWar, iTeam, iOtherTeam) if iTeam < iNumPlayers and iOtherTeam < iNumPlayers: cong.onChangeWar(bWar, iTeam, iOtherTeam) # don't start AIWars if they get involved in natural wars if bWar and iTeam < iNumPlayers and iOtherTeam < iNumPlayers: data.players[iTeam].iAggressionLevel = 0 data.players[iOtherTeam].iAggressionLevel = 0
def onUnitBuilt(self, argsList): city, unit = argsList vic.onUnitBuilt(city, unit) if unit.getUnitType() == iSettler and city.getOwner( ) == iChina and utils.getHumanID() != iChina: utils.handleChineseCities(unit) # Leoreth: help AI by moving new slaves to the new world if unit.getUnitType() == iSlave and city.getRegionID() in [ rIberia, rBritain, rEurope, rScandinavia, rRussia, rItaly, rBalkans, rMaghreb, rAnatolia ] and utils.getHumanID() != city.getOwner(): utils.moveSlaveToNewWorld(city.getOwner(), unit)
def onBeginPlayerTurn(self, argsList): iGameTurn, iPlayer = argsList #if utils.getHumanID() == iPlayer: # utils.debugTextPopup('Can contact: ' + str([gc.getPlayer(i).getCivilizationShortDescription(0) for i in range(con.iNumPlayers) if gc.getTeam(iPlayer).canContact(i)])) if (self.rnf.getDeleteMode(0) != -1): self.rnf.deleteMode(iPlayer) self.pla.checkPlayerTurn(iGameTurn, iPlayer) if (gc.getPlayer(iPlayer).isAlive()): vic.checkTurn(iGameTurn, iPlayer) if (gc.getPlayer(iPlayer).isAlive() and iPlayer < con.iNumPlayers and not gc.getPlayer(iPlayer).isHuman()): self.rnf.checkPlayerTurn(iGameTurn, iPlayer) #for leaders switch
def onBeginPlayerTurn(self, argsList): iGameTurn, iPlayer = argsList #if utils.getHumanID() == iPlayer: # utils.debugTextPopup('Can contact: ' + str([gc.getPlayer(i).getCivilizationShortDescription(0) for i in range(iNumPlayers) if gc.getTeam(iPlayer).canContact(i)])) if (data.lDeleteMode[0] != -1): self.rnf.deleteMode(iPlayer) self.pla.checkPlayerTurn(iGameTurn, iPlayer) if gc.getPlayer(iPlayer).isAlive(): vic.checkTurn(iGameTurn, iPlayer) if iPlayer < iNumPlayers and not gc.getPlayer(iPlayer).isHuman(): self.rnf.checkPlayerTurn(iGameTurn, iPlayer) #for leaders switch
def __init__(self, parent): wx.Panel.__init__(self, parent) panel = wx.Panel(self, size=(WINDOW_WIDTH, WINDOW_HEIGHT)) nb = wx.Notebook(panel) sl = ScreensList(nb) ed = EditorScreens(nb) nt = Intro(nb) en = Ending(nb) st = StoryMode(nb) vt = Victory(nb) ib = IntroBattle(nb) tr = Transitions(nb) nb.AddPage(sl, "Screen Lists") nb.AddPage(ed, "Editor") nb.AddPage(st, "Story Mode") nb.AddPage(nt, "Intro") nb.AddPage(en, "Ending") nb.AddPage(vt, "Victory") nb.AddPage(ib, "Intro Battle") nb.AddPage(tr, "Transitions") sizer = wx.BoxSizer() sizer.Add(nb, 1, wx.EXPAND) self.SetSizer(sizer)
def onCityCaptureGold(self, argsList): city, iPlayer, iGold = argsList if iGold > 0: if gc.getPlayer(iPlayer).isHasBuildingEffect(iGurEAmir): for loopCity in utils.getCityList(iPlayer): if loopCity.isHasRealBuilding(iGurEAmir): CyInterface().addMessage( iPlayer, False, iDuration, CyTranslator().getText( "TXT_KEY_BUILDING_GUR_E_AMIR_EFFECT", (iGold, city.getName(), loopCity.getName())), "", 0, "", ColorTypes(iWhite), -1, -1, True, True) loopCity.changeCulture(iPlayer, iGold, True) break if iPlayer == iVikings and iGold > 0: vic.onCityCaptureGold(iPlayer, iGold)
def __init__(self, eventManager): self.lastRegionID = -1 self.bStabilityOverlay = False self.EventKeyDown = 6 self.EventKeyUp = 7 self.eventManager = eventManager # initialize base class eventManager.addEventHandler("GameStart", self.onGameStart) eventManager.addEventHandler("OnLoad", self.onLoadGame) eventManager.addEventHandler("OnPreSave", self.onPreSave) eventManager.addEventHandler("BeginGameTurn", self.onBeginGameTurn) eventManager.addEventHandler("EndGameTurn", self.onEndGameTurn) eventManager.addEventHandler("BeginPlayerTurn", self.onBeginPlayerTurn) eventManager.addEventHandler("EndPlayerTurn", self.onEndPlayerTurn) eventManager.addEventHandler("firstContact", self.onFirstContact) eventManager.addEventHandler("cityAcquired", self.onCityAcquired) eventManager.addEventHandler("goldenAge", self.onGoldenAge) # srpt eventManager.addEventHandler("corporationSpread", self.onCorporationSpread) # srpt eventManager.addEventHandler("cityAcquiredAndKept", self.onCityAcquiredAndKept) eventManager.addEventHandler("cityRazed", self.onCityRazed) eventManager.addEventHandler("cityBuilt", self.onCityBuilt) eventManager.addEventHandler("combatResult", self.onCombatResult) eventManager.addEventHandler("buildingBuilt", self.onBuildingBuilt) eventManager.addEventHandler("projectBuilt", self.onProjectBuilt) eventManager.addEventHandler("techAcquired", self.onTechAcquired) eventManager.addEventHandler("religionSpread", self.onReligionSpread) eventManager.addEventHandler("unitSpreadReligionAttempt", self.onUnitSpreadReligionAttempt) eventManager.addEventHandler("playerChangeStateReligion", self.onPlayerChangeStateReligion) eventManager.addEventHandler("vassalState", self.onVassalState) eventManager.addEventHandler("changeWar", self.onChangeWar) eventManager.addEventHandler("unitBuilt", self.onUnitBuilt) eventManager.addEventHandler("revolution", self.onRevolution) eventManager.addEventHandler("setPlayerAlive", self.onSetPlayerAlive) eventManager.addEventHandler("greatPersonBorn", self.onGreatPersonBorn) eventManager.addEventHandler("kbdEvent", self.onKbdEvent) self.rnf = RiseAndFall.RiseAndFall() self.cnm = CityNameManager.CityNameManager() self.res = Resources.Resources() self.rel = Religions.Religions() self.barb = Barbs.Barbs() self.aiw = AIWars.AIWars() self.vic = Victory.Victory() #self.pla = Plague.Plague() self.com = Communications.Communications() self.dc = DynamicCivs.DynamicCivs() self.corp = Companies.Companies() self.rfccwaiw = RFCCWAIWars.RFCCWAIWars()
def onUnitBuilt(self, argsList): city, unit = argsList vic.onUnitBuilt(city, unit) if unit.getUnitType() == iSettler and city.getOwner( ) == iChina and utils.getHumanID() != iChina: utils.handleChineseCities(unit) # Leoreth: help AI by moving new slaves to the new world if unit.getUnitType() == iSlave and city.getRegionID() in [ rIberia, rBritain, rEurope, rScandinavia, rRussia, rItaly, rBalkans, rMaghreb, rAnatolia ] and utils.getHumanID() != city.getOwner(): utils.moveSlaveToNewWorld(city.getOwner(), unit) # Space Elevator effect: +1 commerce per satellite built if unit.getUnitType() == iSatellite: city = utils.getBuildingEffectCity(iSpaceElevator) if city: city.changeBuildingYieldChange( gc.getBuildingInfo(iSpaceElevator).getBuildingClassType(), YieldTypes.YIELD_COMMERCE, 1)
def onGameStart(self, argsList): 'Called at the start of the game' data.setup() self.rnf.setup() self.pla.setup() dc.setup() self.aiw.setup() vic.setup() cong.setup() # Leoreth: set DLL core values Modifiers.init() Areas.init() SettlerMaps.init() WarMaps.init() RegionMap.init() Civilizations.init() AIParameters.init() return 0
def onGameStart(self, argsList): 'Called at the start of the game' data.setup() self.rnf.setup() self.pla.setup() dc.setup() self.aiw.setup() self.up.setup() vic.setup() cong.setup() # Leoreth: set DLL core values Modifiers.init() Areas.init() SettlerMaps.init() WarMaps.init() RegionMap.init() Civilizations.init() AIParameters.init() return 0
def onCityAcquired(self, argsList): iOwner, iPlayer, city, bConquest, bTrade = argsList tCity = (city.getX(), city.getY()) cnm.onCityAcquired(city, iPlayer) if bConquest: sta.onCityAcquired(city, iOwner, iPlayer) if iPlayer == iArabia: self.up.arabianUP(city) if iPlayer == iMongolia and bConquest and utils.getHumanID( ) != iPlayer: self.up.mongolUP(city) # relocate capitals if utils.getHumanID() != iPlayer: if iPlayer == iOttomans and tCity == (68, 45): utils.moveCapital(iOttomans, tCity) # Kostantiniyye elif iPlayer == iMongolia and tCity == (102, 47): utils.moveCapital(iMongolia, tCity) # Khanbaliq elif iPlayer == iTurks and utils.isAreaControlled( iTurks, Areas.tCoreArea[iPersia][0], Areas.tCoreArea[iPersia][1]): capital = pTurks.getCapitalCity() if not utils.isPlotInArea((capital.getX(), capital.getY()), Areas.tCoreArea[iPersia][0], Areas.tCoreArea[iPersia][1]): newCapital = utils.getRandomEntry( utils.getAreaCitiesCiv( iTurks, utils.getPlotList(Areas.tCoreArea[iPersia][0], Areas.tCoreArea[iPersia][1]))) if newCapital: utils.moveCapital( iTurks, (newCapital.getX(), newCapital.getY())) # remove slaves if unable to practice slavery if not gc.getPlayer(iPlayer).canUseSlaves(): utils.removeSlaves(city) else: utils.freeSlaves(city, iPlayer) if city.isCapital(): if city.isHasRealBuilding(iAdministrativeCenter): city.setHasRealBuilding(iAdministrativeCenter, False) # Leoreth: relocate capital for AI if reacquired: if utils.getHumanID() != iPlayer and iPlayer < iNumPlayers: if data.players[iPlayer].iResurrections == 0: if Areas.getCapital(iPlayer) == tCity: utils.relocateCapital(iPlayer, city) else: if Areas.getRespawnCapital(iPlayer) == tCity: utils.relocateCapital(iPlayer, city) # Leoreth: conquering Constantinople adds it to the Turkish core + Rumelia if iPlayer == iOttomans and tCity == (68, 45): utils.setReborn(iOttomans, True) if iPlayer == iTurks: if utils.isAreaControlled(iPlayer, Areas.tCoreArea[iPersia][0], Areas.tCoreArea[iPersia][1]): utils.setReborn(iTurks, True) else: utils.setReborn(iTurks, False) # Leoreth: help Byzantium/Constantinople if iPlayer == iByzantium and tCity == Areas.getCapital( iByzantium ) and gc.getGame().getGameTurn() <= getTurnForYear(330) + 3: if city.getPopulation() < 5: city.setPopulation(5) city.setHasRealBuilding(iBarracks, True) city.setHasRealBuilding(iWalls, True) city.setHasRealBuilding(iLibrary, True) city.setHasRealBuilding(iMarket, True) city.setHasRealBuilding(iGranary, True) city.setHasRealBuilding(iHarbor, True) city.setHasRealBuilding(iForge, True) city.setName("Konstantinoupolis", False) city.setHasRealBuilding( iTemple + 4 * gc.getPlayer(iPlayer).getStateReligion(), True) if bConquest: # Colombian UP: no resistance in conquered cities in Latin America if iPlayer == iMaya and utils.isReborn(iMaya): if utils.isPlotInArea(tCity, tSouthCentralAmericaTL, tSouthCentralAmericaBR): city.setOccupationTimer(0) # Statue of Zeus effect: no city resistance on conquest if gc.getPlayer(iPlayer).isHasBuildingEffect(iStatueOfZeus): city.setOccupationTimer(0) # Byzantium reduced to four cities: core shrinks to Constantinople if iOwner == iByzantium and gc.getPlayer( iByzantium).getNumCities <= 4: utils.setReborn(iByzantium, True) if bTrade: for i in range(iNumBuildings): iNationalWonder = i if isNationalWonderClass( gc.getBuildingInfo(iNationalWonder). getBuildingClassType()) and city.hasBuilding( iNationalWonder): city.setHasRealBuilding(iNationalWonder, False) # Leoreth: Escorial effect if gc.getPlayer(iPlayer).isHasBuildingEffect(iEscorial): if city.isColony(): capital = gc.getPlayer(iPlayer).getCapitalCity() iGold = utils.getTurns(10 + utils.calculateDistance( capital.getX(), capital.getY(), city.getX(), city.getY())) CyInterface().addMessage( iPlayer, False, iDuration, CyTranslator().getText("TXT_KEY_BUILDING_ESCORIAL_EFFECT", (iGold, city.getName())), "", 0, "", ColorTypes(iWhite), -1, -1, True, True) gc.getPlayer(iPlayer).changeGold(iGold) self.pla.onCityAcquired(iOwner, iPlayer, city) # Plague self.com.onCityAcquired(city) # Communications self.corp.onCityAcquired(argsList) # Companies dc.onCityAcquired(iOwner, iPlayer) # DynamicCivs vic.onCityAcquired(iPlayer, iOwner, city, bConquest) lTradingCompanyList = [ iSpain, iFrance, iEngland, iPortugal, iNetherlands ] if bTrade and iPlayer in lTradingCompanyList and ( city.getX(), city.getY() ) in tTradingCompanyPlotLists[lTradingCompanyList.index(iPlayer)]: self.up.tradingCompanyCulture(city, iPlayer, iOwner) return 0
def onPlayerSlaveTrade(self, argsList): iPlayer, iGold = argsList if iPlayer == iCongo: vic.onPlayerSlaveTrade(iPlayer, iGold)
def onTradeMission(self, argsList): iUnitType, iPlayer, iX, iY, iGold = argsList if iPlayer in [iTamils, iMali]: vic.onTradeMission(iPlayer, iX, iY, iGold)
def onCityBuilt(self, argsList): city = argsList[0] iOwner = city.getOwner() if iOwner < con.iNumActivePlayers: cnm.onCityBuilt(city) # starting workers if gc.getPlayer(iOwner).getNumCities() == 1: self.rnf.createStartingWorkers(iOwner, (city.getX(), city.getY())) #Rhye - delete culture of barbs and minor civs to prevent weird unhappiness pCurrent = gc.getMap().plot( city.getX(), city.getY() ) for i in range(con.iNumTotalPlayers - con.iNumActivePlayers): iMinorCiv = i + con.iNumActivePlayers pCurrent.setCulture(iMinorCiv, 0, True) pCurrent.setCulture(con.iBarbarian, 0, True) if iOwner < iNumMajorPlayers: utils.spreadMajorCulture(iOwner, city.getX(), city.getY()) if gc.getPlayer(iOwner).getNumCities() < 2: gc.getPlayer(iOwner).AI_updateFoundValues(False); # fix for settler maps not updating after 1st city is founded if iOwner == con.iTurkey: self.up.turkishUP(city, iOwner, -1) if iOwner == con.iCarthage: if city.getX() == 58 and city.getY() == 39: if not gc.getPlayer(con.iCarthage).isHuman(): x = gc.getPlayer(con.iCarthage).getCapitalCity().getX() y = gc.getPlayer(con.iCarthage).getCapitalCity().getY() carthage = gc.getMap().plot(58,39).getPlotCity() carthage.setHasRealBuilding(con.iPalace, True) gc.getMap().plot(x,y).getPlotCity().setHasRealBuilding(con.iPalace, False) carthage.setPopulation(3) utils.makeUnitAI(con.iWorkboat, con.iCarthage, (58, 39), UnitAITypes.UNITAI_WORKER_SEA, 1) utils.makeUnitAI(con.iGalley, con.iCarthage, (57, 40), UnitAITypes.UNITAI_SETTLER_SEA, 1) utils.makeUnitAI(con.iSettler, con.iCarthage, (57, 40), UnitAITypes.UNITAI_SETTLE, 1) if not utils.isReborn(iOwner): gc.getPlayer(con.iCarthage).setReborn(True) self.dc.setCivAdjective(iOwner, "TXT_KEY_CIV_CARTHAGE_ADJECTIVE") self.dc.setCivShortDesc(iOwner, "TXT_KEY_CIV_CARTHAGE_SHORT_DESC") if iOwner == con.iByzantium and (city.getX(), city.getY()) == con.tCapitals[0][con.iByzantium] and gc.getGame().getGameTurn() <= getTurnForYear(330)+3: if city.getPopulation() < 5: city.setPopulation(5) city.setHasRealBuilding(con.iBarracks, True) city.setHasRealBuilding(con.iWalls, True) city.setHasRealBuilding(con.iLibrary, True) city.setHasRealBuilding(con.iMarket, True) city.setHasRealBuilding(con.iGranary, True) city.setHasRealBuilding(con.iHarbor, True) city.setHasRealBuilding(con.iForge, True) city.setHasRealBuilding(con.iJewishTemple + 4*gc.getPlayer(iOwner).getStateReligion(), True) if iOwner == con.iNetherlands and (city.getX(), city.getY()) == con.tCapitals[0][con.iNetherlands] and gc.getGame().getGameTurn() <= getTurnForYear(1580)+3: city.setPopulation(9) for iBuilding in [con.iLibrary, con.iBarracks, con.iGrocer, con.iBank, con.iColosseum, con.iTheatre, con.iJewishTemple+4*gc.getPlayer(con.iNetherlands).getStateReligion()]: city.setHasRealBuilding(iBuilding, True) gc.getPlayer(con.iNetherlands).AI_updateFoundValues(False) if iOwner == con.iItaly and (city.getX(), city.getY()) == con.tCapitals[0][con.iItaly] and gc.getGame().getGameTurn() <= getTurnForYear(con.tBirth[con.iItaly])+3: city.setPopulation(7) for iBuilding in [con.iLibrary, con.iGrocer, con.iTemple+4*gc.getPlayer(con.iItaly).getStateReligion(), con.iMarket, con.iItalianArtStudio, con.iAqueduct, con.iCourthouse, con.iWalls]: city.setHasRealBuilding(iBuilding, True) gc.getPlayer(con.iItaly).AI_updateFoundValues(False) vic.onCityBuilt(iOwner, city) if iOwner < con.iNumPlayers: self.dc.onCityBuilt(iOwner) if iOwner == con.iArabia: if not gc.getGame().isReligionFounded(con.iIslam): if (city.getX(), city.getY()) == (75, 33): self.rel.foundReligion((75, 33), con.iIslam) # Leoreth: free defender and worker for AI colonies if iOwner in con.lCivGroups[0]: if city.getRegionID() not in con.mercRegions[con.iArea_Europe]: if utils.getHumanID() != iOwner: x = city.getX() y = city.getY() utils.createGarrisons((x,y), iOwner, 1) utils.makeUnit(con.iWorker, iOwner, (x,y), 1) # Holy Rome founds its capital if iOwner == con.iHolyRome: if gc.getPlayer(con.iHolyRome).getNumCities() == 1: self.rnf.holyRomanSpawn()
def onPeaceBrokered(self, argsList): iBroker, iPlayer1, iPlayer2 = argsList vic.onPeaceBrokered(iBroker, iPlayer1, iPlayer2)
def onBlockade(self, argsList): iPlayer, iGold = argsList vic.onBlockade(iPlayer, iGold)
def onTechAcquired(self, argsList): iTech, iTeam, iPlayer, bAnnounce = argsList iHuman = utils.getHumanID() iEra = gc.getTechInfo(iTech).getEra() if utils.getScenario() == i600AD and gc.getGame().getGameTurn() == getTurnForYear(600): #late start condition return if utils.getScenario() == i1700AD and gc.getGame().getGameTurn() == getTurnForYear(1700): return sta.onTechAcquired(iPlayer, iTech) AIParameters.onTechAcquired(iPlayer, iTech) if gc.getGame().getGameTurn() > getTurnForYear(tBirth[iPlayer]): vic.onTechAcquired(iPlayer, iTech) cnm.onTechAcquired(argsList[2]) if gc.getPlayer(iPlayer).isAlive() and gc.getGame().getGameTurn() > getTurnForYear(tBirth[iPlayer]) and iPlayer < iNumPlayers: self.rel.onTechAcquired(argsList[0], argsList[2]) if (gc.getGame().getGameTurn() > getTurnForYear(1700)): self.aiw.forgetMemory(argsList[0], argsList[2]) if iTech == iAstronomy: if iPlayer in [iSpain, iFrance, iEngland, iGermany, iVikings, iNetherlands, iPortugal]: data.players[iPlayer].iAstronomyTurn = gc.getGame().getGameTurn() elif iTech == iCompass: if iPlayer == iVikings: gc.getMap().plot(49, 62).setTerrainType(iCoast, True, True) elif iTech == iMedicine: self.pla.onTechAcquired(argsList[0], argsList[2]) elif iTech == iRailroad: self.rnf.onRailroadDiscovered(argsList[2]) if iTech in [iAstronomy, iGunpowder]: teamPlayer = gc.getTeam(iPlayer) if teamPlayer.isHasTech(iAstronomy) and teamPlayer.isHasTech(iGunpowder): self.rnf.earlyTradingCompany(iPlayer) if iTech in [iEconomics, iRifling]: teamPlayer = gc.getTeam(iPlayer) if teamPlayer.isHasTech(iEconomics) and teamPlayer.isHasTech(iRifling): self.rnf.lateTradingCompany(iPlayer) if utils.getHumanID() != iPlayer: if iPlayer == iJapan and iEra == iIndustrial: utils.moveCapital(iPlayer, (116, 47)) # Toukyou elif iPlayer == iItaly and iEra == iIndustrial: utils.moveCapital(iPlayer, (60, 44)) # Roma elif iPlayer == iVikings and iEra == iRenaissance: utils.moveCapital(iPlayer, (63, 59)) # Stockholm elif iPlayer == iHolyRome and iEra == iRenaissance: utils.moveCapital(iPlayer, (62, 49)) # Wien # Spain's core extends when reaching the Renaissance and there are no Moors in Iberia # at the same time, the Moorish core relocates to Africa if iPlayer == iSpain and iEra == iRenaissance and not utils.isReborn(iSpain): bNoMoors = True if gc.getPlayer(iMoors).isAlive(): for city in utils.getCityList(iMoors): if city.plot().getRegionID() == rIberia: bNoMoors = False if bNoMoors: utils.setReborn(iSpain, True) utils.setReborn(iMoors, True) # Italy's core extends when reaching the Industrial era if iPlayer == iItaly and iEra == iIndustrial: utils.setReborn(iItaly, True) # Arabia's core moves to Iraq when Philosophy is discovered if iPlayer == iArabia and iTech == iPhilosophy: utils.setReborn(iArabia, True) # Japan's core extends when reaching the Industrial era if iPlayer == iJapan and iEra == iIndustrial: utils.setReborn(iJapan, True) # Germany's core shrinks when reaching the Modern era if iPlayer == iGermany and iEra == iModern: utils.setReborn(iGermany, True)
def onPlayerGoldTrade(self, argsList): iFromPlayer, iToPlayer, iGold = argsList if iToPlayer == iTamils: vic.onPlayerGoldTrade(iToPlayer, iGold)
def onTradeMission(self, argsList): iUnitType, iPlayer, iX, iY, iGold = argsList if iPlayer in [iTamils, iMali]: vic.onTradeMission(iPlayer, iX, iY, iGold, iUnitType)
def onUnitPillage(self, argsList): unit, iImprovement, iRoute, iPlayer, iGold = argsList if iPlayer == con.iVikings and iGold > 0 and iImprovement != -1 and iGold < 1000: vic.onUnitPillage(iPlayer, iGold)
def onCityBuilt(self, argsList): city = argsList[0] iOwner = city.getOwner() tCity = (city.getX(), city.getY()) x, y = tCity if iOwner < iNumActivePlayers: cnm.onCityBuilt(city) # starting workers if city.isCapital(): self.rnf.createStartingWorkers(iOwner, tCity) #Rhye - delete culture of barbs and minor civs to prevent weird unhappiness pPlot = gc.getMap().plot(x, y) for i in range(iNumTotalPlayers - iNumActivePlayers): iMinorCiv = i + iNumActivePlayers pPlot.setCulture(iMinorCiv, 0, True) pPlot.setCulture(iBarbarian, 0, True) if iOwner < iNumMajorPlayers: utils.spreadMajorCulture(iOwner, tCity) if gc.getPlayer(iOwner).getNumCities() < 2: gc.getPlayer(iOwner).AI_updateFoundValues(False) # fix for settler maps not updating after 1st city is founded if iOwner == iOttomans: self.up.ottomanUP(city, iOwner, -1) if iOwner == iCarthage: if tCity == (58, 39): if not gc.getPlayer(iCarthage).isHuman(): x = gc.getPlayer(iCarthage).getCapitalCity().getX() y = gc.getPlayer(iCarthage).getCapitalCity().getY() carthage = gc.getMap().plot(58, 39).getPlotCity() carthage.setHasRealBuilding(iPalace, True) gc.getMap().plot(x, y).getPlotCity().setHasRealBuilding( iPalace, False) dc.onPalaceMoved(iCarthage) carthage.setPopulation(3) utils.makeUnitAI(iWorkboat, iCarthage, (58, 39), UnitAITypes.UNITAI_WORKER_SEA, 1) utils.makeUnitAI(iGalley, iCarthage, (57, 40), UnitAITypes.UNITAI_SETTLER_SEA, 1) utils.makeUnitAI(iSettler, iCarthage, (57, 40), UnitAITypes.UNITAI_SETTLE, 1) # additional defenders and walls to make human life not too easy if utils.getHumanID() == iRome: carthage.setHasRealBuilding(iWalls, True) utils.makeUnitAI(iArcher, iCarthage, (58, 39), UnitAITypes.UNITAI_CITY_DEFENSE, 2) utils.makeUnit(iNumidianCavalry, iCarthage, (58, 39), 3) utils.makeUnitAI(iWarElephant, iCarthage, (58, 39), UnitAITypes.UNITAI_CITY_COUNTER, 2) if utils.getOwnedCoreCities(iCarthage) > 0: utils.setReborn(iCarthage, True) if iOwner == iByzantium and tCity == Areas.getCapital( iByzantium ) and gc.getGame().getGameTurn() <= getTurnForYear(330) + 3: if city.getPopulation() < 5: city.setPopulation(5) city.setHasRealBuilding(iBarracks, True) city.setHasRealBuilding(iWalls, True) city.setHasRealBuilding(iLibrary, True) city.setHasRealBuilding(iMarket, True) city.setHasRealBuilding(iGranary, True) city.setHasRealBuilding(iHarbor, True) city.setHasRealBuilding(iForge, True) city.setHasRealBuilding( iTemple + 4 * gc.getPlayer(iOwner).getStateReligion(), True) if iOwner == iPortugal and tCity == Areas.getCapital( iPortugal) and gc.getGame().getGameTurn() <= getTurnForYear( tBirth[iPortugal]) + 3: city.setPopulation(5) for iBuilding in [ iLibrary, iMarket, iHarbor, iLighthouse, iForge, iWalls, iTemple + 4 * gc.getPlayer(iPortugal).getStateReligion() ]: city.setHasRealBuilding(iBuilding, True) if iOwner == iNetherlands and tCity == Areas.getCapital( iNetherlands ) and gc.getGame().getGameTurn() <= getTurnForYear(1580) + 3: city.setPopulation(9) for iBuilding in [ iLibrary, iMarket, iWharf, iLighthouse, iBarracks, iPharmacy, iBank, iArena, iTheatre, iTemple + 4 * gc.getPlayer(iNetherlands).getStateReligion() ]: city.setHasRealBuilding(iBuilding, True) gc.getPlayer(iNetherlands).AI_updateFoundValues(False) if iOwner == iItaly and tCity == Areas.getCapital( iItaly) and gc.getGame().getGameTurn() <= getTurnForYear( tBirth[iItaly]) + 3: city.setPopulation(7) for iBuilding in [ iLibrary, iPharmacy, iTemple + 4 * gc.getPlayer(iItaly).getStateReligion(), iMarket, iArtStudio, iAqueduct, iCourthouse, iWalls ]: city.setHasRealBuilding(iBuilding, True) gc.getPlayer(iItaly).AI_updateFoundValues(False) vic.onCityBuilt(iOwner, city) if iOwner < iNumPlayers: dc.onCityBuilt(iOwner) if iOwner == iArabia: if not gc.getGame().isReligionFounded(iIslam): if tCity == (75, 33): self.rel.foundReligion(tCity, iIslam) # Leoreth: free defender and worker for AI colonies if iOwner in lCivGroups[0]: if city.getRegionID() not in mercRegions[iArea_Europe]: if utils.getHumanID() != iOwner: utils.createGarrisons(tCity, iOwner, 1) utils.makeUnit(iWorker, iOwner, tCity, 1) # Holy Rome founds its capital if iOwner == iHolyRome: if gc.getPlayer(iHolyRome).getNumCities() == 1: self.rnf.holyRomanSpawn() # Leoreth: Escorial effect if gc.getPlayer(iOwner).isHasBuildingEffect(iEscorial): if city.isColony(): capital = gc.getPlayer(iOwner).getCapitalCity() iGold = utils.getTurns(10 + utils.calculateDistance( capital.getX(), capital.getY(), city.getX(), city.getY())) CyInterface().addMessage( iOwner, False, iDuration, CyTranslator().getText("TXT_KEY_BUILDING_ESCORIAL_EFFECT", (iGold, city.getName())), "", 0, "", ColorTypes(iWhite), -1, -1, True, True) gc.getPlayer(iOwner).changeGold(iGold) # Leoreth: free defender and worker for cities founded by American Pioneer in North America if iOwner == iAmerica: if city.getRegionID() in [rUnitedStates, rCanada, rAlaska]: utils.createGarrisons(tCity, iOwner, 1) utils.makeUnit(iWorker, iOwner, tCity, 1)
def onCityCaptureGold(self, argsList): city, iPlayer, iGold = argsList if iPlayer == iVikings and iGold > 0: vic.onCityCaptureGold(iPlayer, iGold)
def onUnitPillage(self, argsList): unit, iImprovement, iRoute, iPlayer, iGold = argsList iUnit = unit.getUnitType() if iImprovement >= 0: vic.onUnitPillage(iPlayer, iGold, iUnit)
def onUnitPillage(self, argsList): unit, iImprovement, iRoute, iPlayer, iGold = argsList iUnit = unit.getUnitType() if (iPlayer == iVikings or iPlayer == iMoors) and iGold > 0 and iImprovement != -1 and iGold < 1000: vic.onUnitPillage(iPlayer, iGold, iUnit)
def onCityBuilt(self, argsList): city = argsList[0] iOwner = city.getOwner() tCity = (city.getX(), city.getY()) x, y = tCity if iOwner < iNumActivePlayers: cnm.onCityBuilt(city) # starting workers if city.isCapital(): self.rnf.createStartingWorkers(iOwner, tCity) #Rhye - delete culture of barbs and minor civs to prevent weird unhappiness pPlot = gc.getMap().plot(x, y) for i in range(iNumTotalPlayers - iNumActivePlayers): iMinorCiv = i + iNumActivePlayers pPlot.setCulture(iMinorCiv, 0, True) pPlot.setCulture(iBarbarian, 0, True) if iOwner < iNumMajorPlayers: utils.spreadMajorCulture(iOwner, tCity) if gc.getPlayer(iOwner).getNumCities() < 2: gc.getPlayer(iOwner).AI_updateFoundValues(False); # fix for settler maps not updating after 1st city is founded if iOwner == iTurkey: self.up.turkishUP(city, iOwner, -1) if iOwner == iCarthage: if tCity == (58, 39): if not gc.getPlayer(iCarthage).isHuman(): x = gc.getPlayer(iCarthage).getCapitalCity().getX() y = gc.getPlayer(iCarthage).getCapitalCity().getY() carthage = gc.getMap().plot(58, 39).getPlotCity() carthage.setHasRealBuilding(iPalace, True) gc.getMap().plot(x, y).getPlotCity().setHasRealBuilding(iPalace, False) dc.onPalaceMoved(iCarthage) carthage.setPopulation(3) utils.makeUnitAI(iWorkboat, iCarthage, (58, 39), UnitAITypes.UNITAI_WORKER_SEA, 1) utils.makeUnitAI(iPhoenicianBireme, iCarthage, (57, 40), UnitAITypes.UNITAI_SETTLER_SEA, 1) utils.makeUnitAI(iSettler, iCarthage, (57, 40), UnitAITypes.UNITAI_SETTLE, 1) utils.setReborn(iCarthage, True) if iOwner == iByzantium and tCity == Areas.getCapital(iByzantium) and gc.getGame().getGameTurn() <= getTurnForYear(330)+3: if city.getPopulation() < 5: city.setPopulation(5) city.setHasRealBuilding(iBarracks, True) city.setHasRealBuilding(iWalls, True) city.setHasRealBuilding(iLibrary, True) city.setHasRealBuilding(iMarket, True) city.setHasRealBuilding(iGranary, True) city.setHasRealBuilding(iHarbor, True) city.setHasRealBuilding(iForge, True) city.setHasRealBuilding(iTemple + 4*gc.getPlayer(iOwner).getStateReligion(), True) if iOwner == iNetherlands and tCity == Areas.getCapital(iNetherlands) and gc.getGame().getGameTurn() <= getTurnForYear(1580)+3: city.setPopulation(9) for iBuilding in [iLibrary, iBarracks, iGrocer, iBank, iAmphitheatre, iTheatre, iTemple+4*gc.getPlayer(iNetherlands).getStateReligion()]: city.setHasRealBuilding(iBuilding, True) gc.getPlayer(iNetherlands).AI_updateFoundValues(False) if iOwner == iItaly and tCity == Areas.getCapital(iItaly) and gc.getGame().getGameTurn() <= getTurnForYear(tBirth[iItaly])+3: city.setPopulation(7) for iBuilding in [iLibrary, iGrocer, iTemple+4*gc.getPlayer(iItaly).getStateReligion(), iMarket, iItalianArtStudio, iAqueduct, iCourthouse, iWalls]: city.setHasRealBuilding(iBuilding, True) gc.getPlayer(iItaly).AI_updateFoundValues(False) vic.onCityBuilt(iOwner, city) if iOwner < iNumPlayers: dc.onCityBuilt(iOwner) if iOwner == iArabia: if not gc.getGame().isReligionFounded(iIslam): if tCity == (75, 33): self.rel.foundReligion(tCity, iIslam) # Leoreth: free defender and worker for AI colonies if iOwner in lCivGroups[0]: if city.getRegionID() not in mercRegions[iArea_Europe]: if utils.getHumanID() != iOwner: utils.createGarrisons(tCity, iOwner, 1) utils.makeUnit(iWorker, iOwner, tCity, 1) # Holy Rome founds its capital if iOwner == iHolyRome: if gc.getPlayer(iHolyRome).getNumCities() == 1: self.rnf.holyRomanSpawn()
def onCityAcquired(self, argsList): iOwner, iPlayer, city, bConquest, bTrade = argsList tCity = (city.getX(), city.getY()) cnm.onCityAcquired(city, iPlayer) if bConquest: sta.onCityAcquired(city, iOwner, iPlayer) if iPlayer == iArabia: self.up.arabianUP(city) # elif iPlayer == iMughals and utils.getHumanID() != iMughals: # self.up.mughalUP(city) # elif iPlayer == iSeljuks: # self.up.seljukUP(city) if iPlayer == iMongolia and bConquest and utils.getHumanID() != iPlayer: self.up.mongolUP(city) if iPlayer < iNumMajorPlayers: utils.spreadMajorCulture(iPlayer, tCity) # relocate capitals if utils.getHumanID() != iPlayer: if iPlayer == iTurkey and tCity == (68, 45): utils.moveCapital(iTurkey, tCity) # Kostantiniyye elif iPlayer == iMongolia and tCity == (102, 47): utils.moveCapital(iMongolia, tCity) # Khanbaliq # remove slaves if unable to practice slavery if gc.getPlayer(iPlayer).getCivics(1) == iCivicEgalitarianism: utils.removeSlaves(city) else: utils.freeSlaves(city, iPlayer) # kill Seljuks #if iOwner == iSeljuks and gc.getPlayer(iSeljuks).isAlive() and gc.getGame().getGameTurnYear() >= 1250: # if city.isCapital() or gc.getPlayer(iSeljuks).getNumCities() <= 2: # sta.completeCollapse(iSeljuks) #utils.killAndFragmentCiv(iSeljuks, iIndependent, iIndependent2, -1, False) # Leoreth: relocate capital for AI if reacquired: if utils.getHumanID() != iPlayer and iPlayer < iNumPlayers: if data.players[iPlayer].iResurrections == 0: if Areas.getCapital(iPlayer) == tCity: utils.relocateCapital(iPlayer, city) else: if Areas.getRespawnCapital(iPlayer) == tCity: utils.relocateCapital(iPlayer, city) # Leoreth: conquering Constantinople adds it to the Turkish core + Rumelia if iPlayer == iTurkey and tCity == (68, 45): utils.setReborn(iTurkey, True) # Leoreth: help Byzantium/Constantinople if iPlayer == iByzantium and tCity == Areas.getCapital(iByzantium) and gc.getGame().getGameTurn() <= getTurnForYear(330)+3: if city.getPopulation() < 5: city.setPopulation(5) city.setHasRealBuilding(iBarracks, True) city.setHasRealBuilding(iWalls, True) city.setHasRealBuilding(iLibrary, True) city.setHasRealBuilding(iMarket, True) city.setHasRealBuilding(iGranary, True) city.setHasRealBuilding(iHarbor, True) city.setHasRealBuilding(iForge, True) city.setName("Konstantinoupolis", False) city.setHasRealBuilding(iTemple + 4*gc.getPlayer(iPlayer).getStateReligion(), True) if bConquest: # Colombian UP: no resistance in conquered cities in Latin America if iPlayer == iMaya and utils.isReborn(iMaya): if utils.isPlotInArea(tCity, tSouthCentralAmericaTL, tSouthCentralAmericaBR): city.setOccupationTimer(0) # Statue of Zeus effect: no city resistance on conquest if gc.getPlayer(iPlayer).countNumBuildings(iStatueOfZeus) > 0 and not gc.getTeam(iPlayer).isHasTech(iTheology): city.setOccupationTimer(0) # Byzantium reduced to four cities: core shrinks to Constantinople if iOwner == iByzantium and gc.getPlayer(iByzantium).getNumCities <= 4: utils.setReborn(iByzantium, True) if bTrade: for i in range(iNumBuildings): iNationalWonder = i if isNationalWonderClass(gc.getBuildingInfo(iNationalWonder).getBuildingClassType()) and city.hasBuilding(iNationalWonder): city.setHasRealBuilding(iNationalWonder, False) self.pla.onCityAcquired(iOwner, iPlayer, city) # Plague self.com.onCityAcquired(city) # Communications self.corp.onCityAcquired(argsList) # Companies dc.onCityAcquired(iOwner, iPlayer) # DynamicCivs vic.onCityAcquired(iPlayer, iOwner, city, bConquest) return 0
def onGreatPersonBorn(self, argsList): 'Great Person Born' pUnit, iPlayer, pCity = argsList gp.onGreatPersonBorn(pUnit, iPlayer, pCity) vic.onGreatPersonBorn(iPlayer, pUnit) sta.onGreatPersonBorn(iPlayer) # Leoreth: Silver Tree Fountain effect if gc.getUnitInfo(pUnit.getUnitType()).getLeaderExperience( ) > 0 and gc.getPlayer(iPlayer).isHasBuildingEffect( iSilverTreeFountain): city = utils.getHighestEntry( utils.getCityList(iPlayer), lambda city: city.getGreatPeopleProgress()) if city and city.getGreatPeopleProgress() > 0: iGreatPerson = utils.getHighestEntry( range(iNumUnits), lambda iUnit: city.getGreatPeopleUnitProgress(iUnit)) if iGreatPerson >= 0: gc.getPlayer(iPlayer).createGreatPeople( iGreatPerson, False, False, city.getX(), city.getY()) # Leoreth: Nobel Prize effect if gc.getGame().getBuildingClassCreatedCount( gc.getBuildingInfo(iNobelPrize).getBuildingClassType()) > 0: if gc.getUnitInfo(pUnit.getUnitType()).getLeaderExperience( ) == 0 and gc.getUnitInfo( pUnit.getUnitType()).getEspionagePoints() == 0: for iLoopPlayer in range(iNumPlayers): if gc.getPlayer(iLoopPlayer).isHasBuildingEffect( iNobelPrize): if pUnit.getOwner() != iLoopPlayer and gc.getPlayer( pUnit.getOwner()).AI_getAttitude( iLoopPlayer ) >= AttitudeTypes.ATTITUDE_PLEASED: for pLoopCity in utils.getCityList(iLoopPlayer): if pLoopCity.isHasBuildingEffect(iNobelPrize): iGreatPersonType = pUnit.getUnitType() if iGreatPersonType in dFemaleGreatPeople.values( ): for iLoopGreatPerson in dFemaleGreatPeople: if iGreatPersonType == dFemaleGreatPeople[ iLoopGreatPerson]: iGreatPersonType = iLoopGreatPerson break iGreatPeoplePoints = max( 4, gc.getPlayer(iLoopPlayer). getGreatPeopleCreated()) pLoopCity.changeGreatPeopleProgress( iGreatPeoplePoints) pLoopCity.changeGreatPeopleUnitProgress( iGreatPersonType, iGreatPeoplePoints) CyInterface().setDirty( InterfaceDirtyBits. MiscButtons_DIRTY_BIT, True) CyInterface().addMessage( iLoopPlayer, False, iDuration, CyTranslator().getText( "TXT_KEY_BUILDING_NOBEL_PRIZE_EFFECT", (gc.getPlayer(pUnit.getOwner( )).getCivilizationAdjective(0), pUnit.getName(), pLoopCity.getName(), iGreatPeoplePoints)), "", 0, "", ColorTypes(iWhite), -1, -1, True, True) break break
def onBuildingBuilt(self, argsList): city, iBuildingType = argsList iOwner = city.getOwner() vic.onBuildingBuilt(iOwner, iBuildingType) if iOwner < con.iNumPlayers: self.com.onBuildingBuilt(iOwner, iBuildingType, city) if isWorldWonderClass(gc.getBuildingInfo(iBuildingType).getBuildingClassType()): sta.onWonderBuilt(iOwner, iBuildingType) if iBuildingType == con.iPalace: sta.onPalaceMoved(iOwner) if city.isHasRealBuilding(con.iSummerPalace): city.setHasRealBuilding(con.iSummerPalace, False) # Leoreth: Apostolic Palace moves holy city if iBuildingType == con.iApostolicPalace: self.rel.foundOrthodoxy(iOwner) # Leoreth: build shrine in 3000 BC scenario during HRE autoplay to provide a challenge if utils.getScenario() == con.i3000BC and utils.getHumanID() == con.iHolyRome and gc.getGame().getGameTurnYear() < 840: gc.getGame().getHolyCity().setHasRealBuilding(con.iChristianShrine, True) gc.getGame().setHolyCity(con.iChristianity, city, False) # Leoreth: update trade routes when Porcelain Tower is built to start its effect if iBuildingType == con.iPorcelainTower: gc.getPlayer(iOwner).updateTradeRoutes() # Leoreth/Voyhkah: Empire State Building if iBuildingType == con.iEmpireState: iPop = city.getPopulation() city.setBuildingCommerceChange(gc.getInfoTypeForString("BUILDINGCLASS_EMPIRE_STATE"), 0, iPop) # Leoreth: Machu Picchu if iBuildingType == con.iMachuPicchu: iNumPeaks = 0 for i in range(21): if city.getCityIndexPlot(i).isPeak(): iNumPeaks += 1 city.setBuildingCommerceChange(gc.getInfoTypeForString("BUILDINGCLASS_MACHU_PICCHU"), 0, iNumPeaks * 2) # Leoreth: Great Wall if iBuildingType == con.iGreatWall: for iPlot in range(gc.getMap().numPlots()): plot = gc.getMap().plotByIndex(iPlot) if plot.getOwner() == iOwner and not plot.isWater(): plot.setWithinGreatWall(True) # Leoreth: La Mezquita if iBuildingType == con.iMezquita: lGPList = [0, 0, 0, 0, 0, 0, 0] for city in utils.getCityList(iOwner): for i in range(7): iSpecialistUnit = utils.getUniqueUnit(iOwner, con.iProphet + i) lGPList[i] += city.getGreatPeopleUnitProgress(iSpecialistUnit) iGPType = utils.getUniqueUnit(iOwner, con.iProphet + utils.getHighestIndex(lGPList)) utils.makeUnit(iGPType, iOwner, (city.getX(), city.getY()), 1) CyInterface().addMessage(iOwner, False, con.iDuration, CyTranslator().getText("TXT_KEY_MEZQUITA_FREE_GP", (gc.getUnitInfo(iGPType).getText(), city.getName())), "", InterfaceMessageTypes.MESSAGE_TYPE_MINOR_EVENT, gc.getUnitInfo(iGPType).getButton(), ColorTypes(con.iWhite), city.getX(), city.getY(), True, True) # Leoreth: found Buddhism when a Hindu temple is built if iBuildingType == con.iHinduTemple: self.rel.foundBuddhism(city) # Leoreth: in case human Phoenicia moves palace to Carthage if iBuildingType == con.iPalace: if iOwner == con.iCarthage and city.getX() == 58 and city.getY() == 39: if not utils.isReborn(iOwner): gc.getPlayer(con.iCarthage).setReborn(True)
def onTechAcquired(self, argsList): iTech, iTeam, iPlayer, bAnnounce = argsList iHuman = utils.getHumanID() iEra = gc.getTechInfo(iTech).getEra() iGameTurn = gc.getGame().getGameTurn() if iGameTurn == utils.getScenarioStartTurn(): return sta.onTechAcquired(iPlayer, iTech) AIParameters.onTechAcquired(iPlayer, iTech) if iGameTurn > getTurnForYear(tBirth[iPlayer]): vic.onTechAcquired(iPlayer, iTech) cnm.onTechAcquired(iPlayer) dc.onTechAcquired(iPlayer, iTech) if gc.getPlayer(iPlayer).isAlive() and iGameTurn > getTurnForYear( tBirth[iPlayer]) and iPlayer < iNumPlayers: self.rel.onTechAcquired(iTech, iPlayer) if iGameTurn > getTurnForYear(1700): self.aiw.forgetMemory(iTech, iPlayer) if iTech == iExploration: if iPlayer in [ iSpain, iFrance, iEngland, iGermany, iVikings, iNetherlands, iPortugal ]: data.players[iPlayer].iExplorationTurn = iGameTurn elif iTech == iCompass: if iPlayer == iVikings: gc.getMap().plot(49, 62).setTerrainType(iCoast, True, True) elif iTech == iMicrobiology: self.pla.onTechAcquired(iTech, iPlayer) elif iTech == iRailroad: self.rnf.onRailroadDiscovered(iPlayer) if iTech in [iExploration, iFirearms]: teamPlayer = gc.getTeam(iPlayer) if teamPlayer.isHasTech(iExploration) and teamPlayer.isHasTech( iFirearms): self.rnf.earlyTradingCompany(iPlayer) if iTech in [iEconomics, iReplaceableParts]: teamPlayer = gc.getTeam(iPlayer) if teamPlayer.isHasTech(iEconomics) and teamPlayer.isHasTech( iReplaceableParts): self.rnf.lateTradingCompany(iPlayer) if utils.getHumanID() != iPlayer: if iPlayer == iJapan and iEra == iIndustrial: utils.moveCapital(iPlayer, (116, 47)) # Toukyou elif iPlayer == iItaly and iEra == iIndustrial: utils.moveCapital(iPlayer, (60, 44)) # Roma elif iPlayer == iVikings and iEra == iRenaissance: utils.moveCapital(iPlayer, (63, 59)) # Stockholm elif iPlayer == iHolyRome and iEra == iRenaissance: utils.moveCapital(iPlayer, (62, 49)) # Wien # Maya UP: +20 food when a tech is discovered before the medieval era if iPlayer == iMaya and not pMaya.isReborn() and iEra < iMedieval: if pMaya.getNumCities() > 0: iFood = 20 / pMaya.getNumCities() for city in utils.getCityList(iMaya): city.changeFood(iFood) CyInterface().addMessage( iPlayer, False, iDuration, CyTranslator().getText( "TXT_KEY_MAYA_UP_EFFECT", (gc.getTechInfo(iTech).getText(), iFood)), "", 0, "", ColorTypes(iWhite), -1, -1, True, True) # Spain's core extends when reaching the Renaissance and there are no Moors in Iberia # at the same time, the Moorish core relocates to Africa if iPlayer == iSpain and iEra == iRenaissance and not utils.isReborn( iSpain): bNoMoors = True if gc.getPlayer(iMoors).isAlive(): for city in utils.getCityList(iMoors): if city.plot().getRegionID() == rIberia: bNoMoors = False if bNoMoors: utils.setReborn(iSpain, True) utils.setReborn(iMoors, True) # Italy's core extends when reaching the Industrial era if iPlayer == iItaly and iEra == iIndustrial: utils.setReborn(iItaly, True) # Japan's core extends when reaching the Industrial era if iPlayer == iJapan and iEra == iIndustrial: utils.setReborn(iJapan, True) # Germany's core shrinks when reaching the Digital era if iPlayer == iGermany and iEra == iDigital: utils.setReborn(iGermany, True)
def onProjectBuilt(self, argsList): city, iProjectType = argsList vic.onProjectBuilt(city.getOwner(), iProjectType)