def onBeginPlayerTurn(self, argsList): #iGameTurn = argsList[0] iPlayer = argsList[1] # Stuff at end of previous players turn iPrevPlayer = iPlayer - 1 while iPrevPlayer >= 0 and not GC.getPlayer(iPrevPlayer).isAlive(): iPrevPlayer -= 1 if iPrevPlayer < 0: iPrevPlayer = GC.getBARBARIAN_PLAYER() if iPrevPlayer >= 0 and iPrevPlayer < GC.getMAX_PC_PLAYERS(): iPlayer = iPrevPlayer pPlayer = GC.getPlayer(iPlayer) if pPlayer.isAnarchy(): self.setNewNameByCivics(iPlayer) return if pPlayer.isAlive() and SDTK.sdObjectExists( "Revolution", pPlayer): prevCivics = SDTK.sdObjectGetVal("Revolution", pPlayer, 'CivicList') if not prevCivics == None: for i in xrange(GC.getNumCivicOptionInfos()): if not prevCivics[i] == pPlayer.getCivics(i): self.setNewNameByCivics(iPlayer) return revTurn = SDTK.sdObjectGetVal("Revolution", pPlayer, 'RevolutionTurn') if revTurn is not None and GAME.getGameTurn( ) - revTurn == 30 and pPlayer.getNumCities() > 0: # "Graduate" from rebel name self.setNewNameByCivics(iPlayer) return if pPlayer.isAlive() and SDTK.sdObjectExists( "BarbarianCiv", pPlayer): barbTurn = SDTK.sdObjectGetVal("BarbarianCiv", pPlayer, 'SpawnTurn') if barbTurn is not None and GAME.getGameTurn( ) - barbTurn == 30: # "Graduate" from barb civ name self.setNewNameByCivics(iPlayer) return if (pPlayer.isAlive() and not SDTK.sdObjectExists("BarbarianCiv", pPlayer) and 'Tribe' in pPlayer.getCivilizationDescription(0) and (pPlayer.getCurrentEra() > 0 or pPlayer.getTotalPopulation() >= 3)): # Graduate from game start name self.setNewNameByCivics(iPlayer) return
def checkPlayer(self): iPlayer = GAME.getActivePlayer() CyPlayer = GC.getActivePlayer() if CyPlayer and not CyPlayer.isAlive(): if GAME.getAIAutoPlay(iPlayer) > 0: try: bCanCancelAuto = SdToolKit.sdObjectGetVal( "AIAutoPlay", GAME, "bCanCancelAuto") if bCanCancelAuto is None: bCanCancelAuto = True SdToolKit.sdObjectSetVal("AIAutoPlay", GAME, "bCanCancelAuto", True) except: print "Error! AIAutoPlay: Can't find bCanCancelAuto, assuming it would be True" bCanCancelAuto = True if bCanCancelAuto: if self.refortify: RevUtils.doRefortify(iPlayer) self.disableMultiCheck(iPlayer) self.checkPlayer() popup = PyPopup.PyPopup( RevDefs.pickHumanPopup, contextType=EventContextTypes.EVENTCONTEXT_ALL, bDynamic=False) popup.setHeaderString( TRNSLTR.getText("TXT_KEY_AIAUTOPLAY_PICK_CIV", ())) popup.setBodyString( TRNSLTR.getText("TXT_KEY_AIAUTOPLAY_CIV_DIED", ())) popup.addSeparator() popup.createPythonPullDown( TRNSLTR.getText("TXT_KEY_AIAUTOPLAY_TAKE_CONTROL_CIV", ()), 1) for iPlayerX in range(GC.getMAX_PC_PLAYERS()): if iPlayerX == iPlayer: continue CyPlayerX = GC.getPlayer(iPlayerX) if CyPlayerX.isAlive(): popup.addPullDownString( TRNSLTR.getText("TXT_KEY_AIAUTOPLAY_OF_THE", ()) % (CyPlayerX.getName(), CyPlayerX.getCivilizationDescription(0)), iPlayerX, 1) popup.popup.setSelectedPulldownID(iPlayer, 1) popup.addSeparator() popup.addButton(TRNSLTR.getText("TXT_KEY_AIAUTOPLAY_NONE", ())) print 'Launching pick human popup' popup.launch() for i in range(GC.getMAX_PC_TEAMS()): CyPlayer.setEspionageSpendingWeightAgainstTeam( i, CyPlayer.getEspionageSpendingWeightAgainstTeam(i) / 10)
def onGameLoad(self, argsList): # Init things which require a game object or other game data to exist if not SdToolKit.sdObjectExists("AIAutoPlay", GAME): SdToolKit.sdObjectInit("AIAutoPlay", GAME, {}) SdToolKit.sdObjectSetVal("AIAutoPlay", GAME, "bCanCancelAuto", True) elif SdToolKit.sdObjectGetVal("AIAutoPlay", GAME, "bCanCancelAuto") is None: SdToolKit.sdObjectSetVal("AIAutoPlay", GAME, "bCanCancelAuto", True) for i in range(GC.getMAX_PC_PLAYERS()): CyPlayer = GC.getPlayer(i) if CyPlayer.isHumanDisabled() and not GAME.isForcedAIAutoPlay(i): GAME.setAIAutoPlay(i, 1)
def onCombatResult(argsList): CyUnitW, CyUnitL = argsList # Spartacus Capture Event if CyUnitW.getUnitClassType() == giSparticus: # Capture % Random # 0 to 3 or 25% if not GAME.getSorenRandNum(4, "Gods"): pClearPlot = findClearPlot(CyUnitL) CyPlot = CyUnitL.plot() if pClearPlot != -1 and CyPlot.getNumUnits() == 1: CyPlot = CyUnitL.plot() CyUnitL.setXY(pClearPlot.getX(), pClearPlot.getY(), False, True, True) else: CyPlot = CyUnitW.plot() iPlayer = CyUnitW.getOwner() GC.getPlayer(iPlayer).initUnit(giGladiator, CyPlot.getX(), CyPlot.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH).finishMoves() CyUnitL.setDamage(100000, False) msg = TRNSLTR.getText("TXT_KEY_SPARTACUS_CAPTURE_SUCCESS",()) icon = ',Art/Interface/Buttons/Units/ICBM.dds,Art/Interface/Buttons/Warlords_Atlas_1.dds,3,11' CvUtil.sendMessage(msg, iPlayer, 15, icon, ColorTypes(44), CyUnitL.getX(), CyUnitL.getY(), True, True, 0, "", False) # Field Medic if CyUnitW.isHasPromotion(giFieldMedic): # 10% chance if not GAME.getSorenRandNum(10, "Gods"): if not SDTK.sdObjectExists('Heroes', CyUnitW): iHealTurn = -1 else: iHealTurn = SDTK.sdObjectGetVal( 'Heroes', CyUnitW, 'HealTurn' ) if iHealTurn == None or GAME.getGameTurn() > iHealTurn: CyUnitW.setDamage(0, False) if not SDTK.sdObjectExists('Heroes', CyUnitW): SDTK.sdObjectInit('Heroes', CyUnitW, {}) SDTK.sdObjectSetVal('Heroes', CyUnitW, 'HealTurn', GAME.getGameTurn())
def revObjectGetVal(object, var): if (not revObjectExists(object)): if (isinstance(object, CvPythonExtensions.CyPlayer)): print "RevData: Initializing player object" initPlayer(object) elif (isinstance(object, CvPythonExtensions.CyCity)): print "RevData: Initializing city object" initCity(object) else: # SDTK will fail print "ERROR: Not recognized: ", object pass #TODO: remove this once all have been put into data structure defs if (isinstance(object, CvPythonExtensions.CyPlayer) and not var in RevDefs.playerData.keys()): print "WARNING: Unrecognized player variable ", var elif (isinstance(object, CvPythonExtensions.CyCity) and not var in RevDefs.cityData.keys()): print "WARNING: Unrecognized city variable ", var return SdToolKit.sdObjectGetVal('Revolution', object, var)
def onKbdEvent(self, argsList): eventType, key, mx, my, px, py = argsList if eventType == 6 and self.customEM.bShift and self.customEM.bCtrl: if key == InputTypes.KB_X: iPlayer = GAME.getActivePlayer() if GAME.getAIAutoPlay(iPlayer) > 0: try: bCanCancelAuto = SdToolKit.sdObjectGetVal( "AIAutoPlay", GAME, "bCanCancelAuto") if bCanCancelAuto is None: bCanCancelAuto = True SdToolKit.sdObjectSetVal("AIAutoPlay", GAME, "bCanCancelAuto", True) except: print "Error! AIAutoPlay: Can't find bCanCancelAuto, assuming it would be True" bCanCancelAuto = True if bCanCancelAuto: if self.refortify: RevUtils.doRefortify(iPlayer) self.disableMultiCheck(iPlayer) self.checkPlayer() else: self.toAIChooser() elif key == InputTypes.KB_M: # Toggle auto moves if self.LOG_DEBUG: CyInterface().addImmediateMessage( TRNSLTR.getText("TXT_KEY_AIAUTOPLAY_MOVING", ()), "") GAME.setAIAutoPlay(GAME.getActivePlayer(), 1) elif key == InputTypes.KB_O: RevUtils.doRefortify(GAME.getActivePlayer())
def newNameByCivics(self, iPlayer, bVerbose=True, bForceUpdate=False): # Assigns a new name to a player based on their civics choices pPlayer = gc.getPlayer(iPlayer) capital = pPlayer.getCapitalCity() playerEra = pPlayer.getCurrentEra() pTeam = gc.getTeam(pPlayer.getTeam()) cityString = None if capital: try: # Silly game to force ascii encoding now cityString = pPlayer.getCivilizationDescription(0) cityString += "&" + CvUtil.convertToStr(capital.getName()) cityString = cityString.split('&', 1)[-1] except: pass curDesc = pPlayer.getCivilizationDescription(0) curShort = pPlayer.getCivilizationShortDescription(0) curAdj = pPlayer.getCivilizationAdjective(0) origDesc = "" if (pPlayer.getCivilizationType() >= 0): civInfo = gc.getCivilizationInfo(pPlayer.getCivilizationType()) origDesc = civInfo.getDescription() eLeader = pPlayer.getLeaderType() bFemaleLeader = self.isFemaleLeader(eLeader) iLanguage = gc.getGame().getCurrentLanguage() bFrench = iLanguage == 1 #0 - English, 1 - French, 2 - German, 3 - Italian, 4 - Spanish eGovCivic = pPlayer.getCivics( gc.getInfoTypeForString("CIVICOPTION_GOVERNMENT")) ePowerCivic = pPlayer.getCivics( gc.getInfoTypeForString("CIVICOPTION_POWER")) bNoRealElections = ( gc.getInfoTypeForString("CIVIC_MONARCHY") == eGovCivic or gc.getInfoTypeForString("CIVIC_MONARCHY") == eGovCivic or gc.getInfoTypeForString("CIVIC_DESPOTISM") == eGovCivic or gc.getInfoTypeForString("CIVIC_TOTALITARIANISM") == eGovCivic) bFederal = (gc.getInfoTypeForString("CIVIC_FEDERALISM") == eGovCivic and (ePowerCivic == gc.getInfoTypeForString("CIVIC_LEGISLATURE"))) bConfederation = (not bFederal and (gc.getInfoTypeForString("CIVIC_FEDERALISM") == eGovCivic)) bPacifist = (pPlayer.getCivics( gc.getInfoTypeForString("CIVICOPTION_MILITARY")) == gc.getInfoTypeForString("CIVIC_PACIFISM")) if (not game.isOption(GameOptionTypes.GAMEOPTION_LEAD_ANY_CIV)): if (pPlayer.getLeaderType() in LeaderCivNames.LeaderCivNames.keys()): [curDesc, curShort, curAdj ] = LeaderCivNames.LeaderCivNames[pPlayer.getLeaderType()] newName = curDesc if (SDTK.sdObjectExists("Revolution", pPlayer)): revTurn = SDTK.sdObjectGetVal("Revolution", pPlayer, 'RevolutionTurn') else: revTurn = None if (SDTK.sdObjectExists("BarbarianCiv", pPlayer)): barbTurn = SDTK.sdObjectGetVal("BarbarianCiv", pPlayer, 'SpawnTurn') else: barbTurn = None if (not pPlayer.isAlive()): newName = localText.getText("TXT_KEY_MOD_DCN_REFUGEES", ()) % (curAdj) return [newName, curShort, curAdj] if pPlayer.isRebel(): # Maintain name of rebels from Revolution Mod if bForceUpdate: return self.nameForNewPlayer(iPlayer) else: return [curDesc, curShort, curAdj] elif (pPlayer.isMinorCiv() and not barbTurn == None): # Maintain minor civ name if bForceUpdate: return self.nameForNewPlayer(iPlayer) else: return [curDesc, curShort, curAdj] elif (not barbTurn == None and game.getGameTurn() - barbTurn < 20 and pPlayer.getNumCities() < 4): # Maintain name of BarbarianCiv created player if bForceUpdate: return self.nameForNewPlayer(iPlayer) else: return [curDesc, curShort, curAdj] # Special options for teams and permanent alliances if (self.bTeamNaming and pTeam.getNumMembers() > 1): # and pTeam.getPermanentAllianceTradingCount() > 0 ) : if (pTeam.getNumMembers() == 2): iLeader = pTeam.getLeaderID() newName = gc.getPlayer(iLeader).getCivilizationAdjective( 0) + "-" for idx in range(0, gc.getMAX_PC_PLAYERS()): if (not idx == iLeader and gc.getPlayer(idx).getTeam() == pTeam.getID()): newName += gc.getPlayer(idx).getCivilizationAdjective( 0) break newName += u" " + localText.getText("TXT_KEY_MOD_DCN_ALLIANCE", ()) return [newName, curShort, curAdj] else: iLeader = pTeam.getLeaderID() newName = gc.getPlayer(iLeader).getCivilizationAdjective( 0)[0:4] for idx in range(0, gc.getMAX_PC_PLAYERS()): if not idx == iLeader and gc.getPlayer( idx).getTeam() == pTeam.getID(): newName += gc.getPlayer(idx).getCivilizationAdjective( 0)[0:3] newName += u" " + localText.getText("TXT_KEY_MOD_DCN_ALLIANCE", ()) return [newName, curShort, curAdj] sSocRep = localText.getText("TXT_KEY_MOD_DCN_SOC_REP", ()).replace('%s', '').strip() sPeoplesRep = localText.getText("TXT_KEY_MOD_DCN_PEOPLES_REP", ()).replace('%s', '').strip() # Anarchy Naming if pPlayer.isAnarchy and pPlayer.getAnarchyTurns() > 1: if 75 > game.getSorenRandNum(100, 'Rev: Naming'): newName = localText.getText("TXT_KEY_MOD_DCN_PROVISIONAL_GOV", ()) % (curAdj) else: newName = localText.getText("TXT_KEY_MOD_DCN_PROVISIONAL_AUTH", ()) % (curAdj) return [newName, curShort, curAdj] if (not pPlayer.isAnarchy or pPlayer.getAnarchyTurns() < 2) and "Provisional" in curDesc: if gc.getInfoTypeForString("CIVIC_MONARCHY") == eGovCivic: newName = curAdj + ' ' + localText.getText( "TXT_KEY_MOD_DCN_KINGDOM", ()) elif (gc.getInfoTypeForString("CIVIC_REPUBLIC") == eGovCivic): newName = localText.getText("TXT_KEY_MOD_DCN_REPUBLIC", ()) % (curAdj) else: newName = curAdj + ' Nation' return [newName, curShort, curAdj] # Main naming conditions if RevUtils.isCommunism(iPlayer): if RevUtils.isCanDoElections(iPlayer) and not bNoRealElections: if not bForceUpdate and (sSocRep in curDesc or sPeoplesRep in curDesc): newName = curDesc elif 50 > game.getSorenRandNum(100, 'Rev: Naming'): newName = localText.getText("TXT_KEY_MOD_DCN_SOC_REP", ()) % (curShort) else: newName = localText.getText("TXT_KEY_MOD_DCN_PEOPLES_REP", ()) % (curShort) elif (RevUtils.getDemocracyLevel(iPlayer)[0] == -8): if (localText.getText("TXT_KEY_MOD_DCN_RUSSIAN_MATCH", ()) in curAdj): curAdj = localText.getText("TXT_KEY_MOD_DCN_SOVIET", ()) newName = localText.getText("TXT_KEY_MOD_DCN_UNION", ()) % (curAdj) else: newName = localText.getText("TXT_KEY_MOD_DCN_PEOPLES_REP", ()) % (curShort) elif (RevUtils.isCanDoElections(iPlayer) and not bNoRealElections): sRepOf = localText.getText("TXT_KEY_MOD_DCN_REPUBLIC_OF", ()).replace('%s', '').strip() sRepublic = localText.getText("TXT_KEY_MOD_DCN_REPUBLIC", ()) if pPlayer.getNumCities() == 1: if (not bForceUpdate and (curDesc.startswith( localText.getText("TXT_KEY_MOD_DCN_FREE", ())) or ((sRepOf in curDesc or sRepublic in curDesc) and cityString in curDesc))): newName = curDesc elif 40 > game.getSorenRandNum(100, 'Rev: Naming'): newName = localText.getText("TXT_KEY_MOD_DCN_FREE_STATE", ()) % (curAdj) else: if (not cityString == None and len(cityString) < 10 and len(cityString) > 0): if (cityString in curAdj or cityString in curShort): newName = localText.getText( "TXT_KEY_MOD_DCN_THE_REPUBLIC_OF_CITY", ()) % (cityString) else: newName = localText.getText( "TXT_KEY_MOD_DCN_REPUBLIC_OF_CITY", ()) % (curAdj, cityString) else: newName = localText.getText( "TXT_KEY_MOD_DCN_FREE_REPUBLIC", ()) % (curAdj) else: if (not bFederal and not bConfederation and not bForceUpdate and (sRepublic in curDesc and not sPeoplesRep in curDesc and not sSocRep in curDesc and curDesc.startswith( localText.getText("TXT_KEY_MOD_DCN_FREE", ())))): if (len(curDesc) < 17 and 20 > game.getSorenRandNum(100, 'Rev: Naming') and not localText.getText("TXT_KEY_MOD_DCN_NEW", ()) in curDesc): newName = localText.getText("TXT_KEY_MOD_DCN_NEW", ()) + curDesc else: newName = curDesc elif bFederal: if (pPlayer.getCivilizationType() == gc.getInfoTypeForString( "CIVILIZATION_UNITED_STATES")): newName = localText.getText( "TXT_KEY_MOD_DCN_UNITED_STATES", ()) % (curShort) elif 50 > game.getSorenRandNum(100, 'Rev: Naming'): newName = localText.getText( "TXT_KEY_MOD_DCN_FEDERATED_STATES", ()) % (curShort) else: newName = localText.getText( "TXT_KEY_MOD_DCN_FEDERATION", ()) % (curAdj) elif (bConfederation): if (50 > game.getSorenRandNum(100, 'Rev: Naming')): newName = localText.getText( "TXT_KEY_MOD_DCN_CONFEDERATION", ()) % (curAdj) else: newName = localText.getText( "TXT_KEY_MOD_DCN_CONFEDERATION_STATES", ()) % (curShort) elif (50 > game.getSorenRandNum(100, 'Rev: Naming')): newName = localText.getText("TXT_KEY_MOD_DCN_REPUBLIC", ()) % (curAdj) elif (33 > game.getSorenRandNum(100, 'Rev: Naming')): newName = localText.getText( "TXT_KEY_MOD_DCN_THE_COMMONWEALTH_OF", ()) % (curShort) else: newName = localText.getText( "TXT_KEY_MOD_DCN_THE_REPUBLIC_OF", ()) % (curShort) if (RevUtils.isFreeSpeech(iPlayer) and RevUtils.getLaborFreedom(iPlayer)[0] > 9): if (len(newName) < 16 and not localText.getText("TXT_KEY_MOD_DCN_FREE", ()) in newName and not localText.getText("TXT_KEY_MOD_DCN_NEW", ()) in newName): newName = localText.getText("TXT_KEY_MOD_DCN_FREE", ()) + ' ' + newName elif (RevUtils.getDemocracyLevel(iPlayer)[0] == -8): empString = localText.getText("TXT_KEY_MOD_DCN_PLAIN_EMPIRE", ()) if (localText.getText("TXT_KEY_MOD_DCN_GERMAN_MATCH", ()) in curAdj): empString = localText.getText("TXT_KEY_MOD_DCN_REICH", ()) if (not bForceUpdate and empString in curDesc): newName = curDesc elif (70 > game.getSorenRandNum(100, 'Rev: Naming') and not localText.getText("TXT_KEY_MOD_DCN_REICH", ()) in empString): newName = localText.getText("TXT_KEY_MOD_DCN_THE_BLANK_OF", ()) % (empString, curShort) else: if (bFrench): newName = empString + ' ' + curAdj else: newName = curAdj + ' ' + empString else: sGreat = localText.getText("TXT_KEY_MOD_DCN_GREAT_KINGDOM", ()).replace('%s', '').strip() iMinCitiesKingdom = 3 if (pPlayer.getNumCities() >= iMinCitiesKingdom): if (bFemaleLeader): sKingdom = localText.getText("TXT_KEY_MOD_DCN_QUEENDOM", ()) else: sKingdom = localText.getText("TXT_KEY_MOD_DCN_KINGDOM", ()) else: sKingdom = localText.getText("TXT_KEY_MOD_DCN_PRINCIPALITY", ()) if RevUtils.getDemocracyLevel(iPlayer)[0] == -6: if pTeam.isAVassal(): sKingdom = localText.getText("TXT_KEY_MOD_DCN_DUCHY", ()) else: if (localText.getText("TXT_KEY_MOD_DCN_PERSIAN_MATCH", ()) in curAdj or localText.getText( "TXT_KEY_MOD_DCN_OTTOMAN_MATCH", ()) in curAdj or localText.getText( "TXT_KEY_MOD_DCN_SUMERIAN_MATCH", ()) in curAdj): sKingdom = localText.getText( "TXT_KEY_MOD_DCN_SULTANATE", ()) elif (localText.getText("TXT_KEY_MOD_DCN_ARABIAN_MATCH", ()) in curAdj): sKingdom = localText.getText( "TXT_KEY_MOD_DCN_CALIPHATE", ()) if pPlayer.getNumCities() < 4: if not cityString == None and len(cityString) < 10 and len( cityString) > 0: if (cityString in curAdj or cityString in curShort): newName = localText.getText( "TXT_KEY_MOD_DCN_THE_BLANK_OF_CITY", ()) % (sKingdom, cityString) else: if bFrench: newName = localText.getText( "TXT_KEY_MOD_DCN_BLANK_OF_CITY", ()) % (sKingdom, curAdj, cityString) else: newName = localText.getText( "TXT_KEY_MOD_DCN_BLANK_OF_CITY", ()) % (curAdj, sKingdom, cityString) else: if bFrench: newName = sKingdom + ' ' + curAdj else: newName = curAdj + ' ' + sKingdom elif (game.getPlayerRank(iPlayer) < game.countCivPlayersAlive() / 7 and not pTeam.isAVassal() and (sGreat in curDesc or 40 > game.getSorenRandNum(100, 'Rev: Naming'))): if bFrench: newName = localText.getText( "TXT_KEY_MOD_DCN_GREAT_KINGDOM", ()) % (sKingdom, curAdj) else: newName = localText.getText( "TXT_KEY_MOD_DCN_GREAT_KINGDOM", ()) % (curAdj, sKingdom) else: sOf = localText.getText("TXT_KEY_MOD_DCN_THE_BLANK_OF", ()).replace('%s', '') if (not bForceUpdate and sKingdom in curDesc and (not sOf in curDesc or pPlayer.getNumCities < 6) and (not sGreat in curDesc)): newName = curDesc elif 50 > game.getSorenRandNum(100, 'Rev: Naming'): if bFrench: newName = sKingdom + ' ' + curAdj else: newName = curAdj + ' ' + sKingdom else: newName = localText.getText( "TXT_KEY_MOD_DCN_THE_BLANK_OF", ()) % (sKingdom, curShort) elif RevUtils.getDemocracyLevel( iPlayer)[0] == -10 or playerEra == 0: empString = localText.getText("TXT_KEY_MOD_DCN_PLAIN_EMPIRE", ()) if playerEra < 2 and pPlayer.getNumCities() < 3: empString = localText.getText( "TXT_KEY_MOD_DCN_PLAIN_CITY_STATE", ()) if pTeam.isAVassal(): if 50 > game.getSorenRandNum(100, 'Rev: Naming'): empString = localText.getText( "TXT_KEY_MOD_DCN_FIEFDOM", ()) elif 50 > game.getSorenRandNum(100, 'Rev: Naming'): empString = localText.getText( "TXT_KEY_MOD_DCN_PROTECTORATE", ()) else: empString = localText.getText( "TXT_KEY_MOD_DCN_TERRITORY", ()) if not bForceUpdate and empString in curDesc and not game.getGameTurn( ) == 0: newName = curDesc elif (50 > game.getSorenRandNum(100, 'Rev: Naming')): if (bFrench): newName = empString + ' ' + curAdj else: newName = curAdj + ' ' + empString else: newName = localText.getText("TXT_KEY_MOD_DCN_THE_BLANK_OF", ()) % (empString, curShort) sHoly = localText.getText("TXT_KEY_MOD_DCN_HOLY", ()) + ' ' if (RevUtils.getReligiousFreedom(iPlayer)[0] < -9): if (len(newName) < 16 and not sHoly in newName and not sGreat in newName and not newName.startswith( localText.getText("TXT_KEY_MOD_DCN_HOLY_HRE_MATCH", ()))): newName = sHoly + newName elif newName.startswith(sHoly) and not origDesc.startswith(sHoly): # Cut off any inappropriately saved 'Holy ' prefix newName = newName[len(sHoly):] if bPacifist: szPacifist = localText.getText("TXT_KEY_MOD_DCN_PACIFIST", ()) if not szPacifist in newName and 50 > game.getSorenRandNum( 100, 'Rev: Naming'): szPacifist = localText.getText("TXT_KEY_MOD_DCN_PEACEFUL", ()) if not szPacifist in newName: if bFrench: newName = newName + ' ' + szPacifist else: newName = szPacifist + ' ' + newName return [newName, curShort, curAdj]
def nameForNewPlayer(self, iPlayer): # Assigns a new name to a recently created player from either # BarbarianCiv or Revolution components pPlayer = gc.getPlayer(iPlayer) currentEra = 0 for i in range(0, gc.getMAX_PC_PLAYERS()): if (gc.getPlayer(i).getCurrentEra() > currentEra): currentEra = gc.getPlayer(i).getCurrentEra() curDesc = pPlayer.getCivilizationDescription(0) curShort = pPlayer.getCivilizationShortDescription(0) curAdj = pPlayer.getCivilizationAdjective(0) civInfo = gc.getCivilizationInfo(pPlayer.getCivilizationType()) origDesc = civInfo.getDescription() if (not game.isOption(GameOptionTypes.GAMEOPTION_LEAD_ANY_CIV)): if (pPlayer.getLeaderType() in LeaderCivNames.LeaderCivNames.keys()): [curDesc, curShort, curAdj ] = LeaderCivNames.LeaderCivNames[pPlayer.getLeaderType()] newName = curDesc if SDTK.sdObjectExists("Revolution", pPlayer): revTurn = SDTK.sdObjectGetVal("Revolution", pPlayer, 'RevolutionTurn') else: revTurn = None if SDTK.sdObjectExists("BarbarianCiv", pPlayer): barbTurn = SDTK.sdObjectGetVal("BarbarianCiv", pPlayer, 'SpawnTurn') else: barbTurn = None if not pPlayer.isAlive(): newName = localText.getText("TXT_KEY_MOD_DCN_REFUGEES", ()) % (curAdj) elif pPlayer.isRebel(): # To name rebels in Revolution mod cityString = SDTK.sdObjectGetVal("Revolution", pPlayer, 'CapitalName') sLiberation = localText.getText("TXT_KEY_MOD_DCN_LIBERATION_FRONT", ()).replace('%s', '').strip() sGuerillas = localText.getText("TXT_KEY_MOD_DCN_GUERILLAS", ()).replace('%s', '').strip() sRebels = localText.getText("TXT_KEY_MOD_DCN_REBELS", ()).replace('%s', '').strip() if (sLiberation in curDesc or sGuerillas in curDesc or sRebels in curDesc): newName = curDesc else: if (currentEra > 5 and 30 > game.getSorenRandNum(100, 'Rev: Naming')): newName = localText.getText( "TXT_KEY_MOD_DCN_LIBERATION_FRONT", ()) % (curAdj) elif (currentEra > 4 and 30 > game.getSorenRandNum(100, 'Rev: Naming')): newName = localText.getText("TXT_KEY_MOD_DCN_GUERILLAS", ()) % (curAdj) else: if (not cityString == None and len(cityString) < 10): try: if (cityString in curAdj or cityString in curShort): newName = localText.getText( "TXT_KEY_MOD_DCN_THE_REBELS_OF", ()) % (CvUtil.convertToStr(cityString)) else: newName = localText.getText( "TXT_KEY_MOD_DCN_REBELS_OF", ()) % (curAdj, CvUtil.convertToStr(cityString)) except: newName = localText.getText( "TXT_KEY_MOD_DCN_REBELS", ()) % (curAdj) else: newName = localText.getText("TXT_KEY_MOD_DCN_REBELS", ()) % (curAdj) elif (not barbTurn == None and game.getGameTurn() - barbTurn < 20): # To name BarbarianCiv created civs numCities = SDTK.sdObjectGetVal("BarbarianCiv", pPlayer, 'NumCities') cityString = SDTK.sdObjectGetVal("BarbarianCiv", pPlayer, 'CapitalName') if (pPlayer.isMinorCiv()): if (currentEra < 2): if (70 - 40 * currentEra > game.getSorenRandNum( 100, "Naming")): newName = localText.getText("TXT_KEY_MOD_DCN_TRIBE", ()) % (curAdj) else: newName = localText.getText( "TXT_KEY_MOD_DCN_CITY_STATE", ()) % (curAdj) elif (currentEra < 3): newName = localText.getText("TXT_KEY_MOD_DCN_CITY_STATE", ()) % (curAdj) else: newName = localText.getText("TXT_KEY_MOD_DCN_NATION", ()) % (curAdj) elif (currentEra < 4): # Early era barbs if (SDTK.sdObjectGetVal('BarbarianCiv', pPlayer, 'BarbStyle') == 'Military'): if (pPlayer.getNumMilitaryUnits() > 7 * numCities): newName = localText.getText("TXT_KEY_MOD_DCN_HORDE", ()) % (curAdj) else: if (not cityString == None and len(cityString) < 10): if (cityString in curAdj or cityString in curShort): newName = localText.getText( "TXT_KEY_MOD_DCN_THE_WARRIORS_OF", ()) % (cityString) else: newName = localText.getText( "TXT_KEY_MOD_DCN_WARRIORS_OF", ()) % (curAdj, cityString) else: newName = localText.getText( "TXT_KEY_MOD_DCN_WARRIOR_STATE", ()) % (curAdj) else: if (numCities == 1): newName = localText.getText( "TXT_KEY_MOD_DCN_CITY_STATE", ()) % (curAdj) else: newName = localText.getText("TXT_KEY_MOD_DCN_EMPIRE", ()) % (curAdj) if (numCities < 3): if (not cityString == None and len(cityString) < 10): newName += localText.getText( "TXT_KEY_MOD_DCN_OF_CITY", ()) % (cityString) else: newName = localText.getText("TXT_KEY_MOD_DCN_EMPIRE", ()) % (curAdj) if (numCities < 3 and not cityString == None and len(cityString) < 10): newName += localText.getText("TXT_KEY_MOD_DCN_OF_CITY", ()) % (cityString) else: if (game.getGameTurn() == game.getStartTurn() and game.getCurrentEra() < 1): # Name civs at beginning of game newName = localText.getText("TXT_KEY_MOD_DCN_TRIBE", ()) % (curAdj) return [newName, curShort, curAdj] return self.newNameByCivics(iPlayer) return [newName, curShort, curAdj]
def nameForNewPlayer(self, iPlayer): # Assigns a new name to a recently created player from either # BarbarianCiv or Revolution components pPlayer = GC.getPlayer(iPlayer) if (not GAME.isOption(GameOptionTypes.GAMEOPTION_LEAD_ANY_CIV) and pPlayer.getLeaderType() in LeaderCivNames.LeaderCivNames.keys()): curDesc, curShort, curAdj = LeaderCivNames.LeaderCivNames[ pPlayer.getLeaderType()] else: curShort = pPlayer.getCivilizationShortDescription(0) curDesc = pPlayer.getCivilizationDescription(0) curAdj = pPlayer.getCivilizationAdjective(0) if not pPlayer.isAlive(): return [ TRNSLTR.getText("TXT_KEY_MOD_DCN_REFUGEES", ()) % (curAdj), curShort, curAdj ] currentEra = 0 for i in xrange(GC.getMAX_PC_PLAYERS()): if GC.getPlayer(i).getCurrentEra() > currentEra: currentEra = GC.getPlayer(i).getCurrentEra() if pPlayer.isRebel(): # To name rebels in Revolution mod sLiberation = TRNSLTR.getText("TXT_KEY_MOD_DCN_LIBERATION_FRONT", ()).replace('%s', '').strip() sGuerillas = TRNSLTR.getText("TXT_KEY_MOD_DCN_GUERILLAS", ()).replace('%s', '').strip() sRebels = TRNSLTR.getText("TXT_KEY_MOD_DCN_REBELS", ()).replace('%s', '').strip() if sLiberation in curDesc or sGuerillas in curDesc or sRebels in curDesc: newName = curDesc elif currentEra > 5 and 30 > GAME.getSorenRandNum( 100, 'Rev: Naming'): newName = TRNSLTR.getText("TXT_KEY_MOD_DCN_LIBERATION_FRONT", ()) % (curAdj) elif currentEra > 4 and 30 > GAME.getSorenRandNum( 100, 'Rev: Naming'): newName = TRNSLTR.getText("TXT_KEY_MOD_DCN_GUERILLAS", ()) % (curAdj) else: cityString = SDTK.sdObjectGetVal("Revolution", pPlayer, 'CapitalName') if cityString is not None and len(cityString) < 10: try: if cityString in curAdj or cityString in curShort: newName = TRNSLTR.getText( "TXT_KEY_MOD_DCN_THE_REBELS_OF", ()) % (CvUtil.convertToStr(cityString)) else: newName = TRNSLTR.getText( "TXT_KEY_MOD_DCN_REBELS_OF", ()) % (curAdj, CvUtil.convertToStr(cityString)) except: newName = TRNSLTR.getText("TXT_KEY_MOD_DCN_REBELS", ()) % (curAdj) else: newName = TRNSLTR.getText("TXT_KEY_MOD_DCN_REBELS", ()) % (curAdj) return [newName, curShort, curAdj] if SDTK.sdObjectExists("BarbarianCiv", pPlayer): barbTurn = SDTK.sdObjectGetVal("BarbarianCiv", pPlayer, 'SpawnTurn') else: barbTurn = None if barbTurn is not None and GAME.getGameTurn() - barbTurn < 20: # To name BarbarianCiv created civs numCities = SDTK.sdObjectGetVal("BarbarianCiv", pPlayer, 'NumCities') cityString = SDTK.sdObjectGetVal("BarbarianCiv", pPlayer, 'CapitalName') if pPlayer.isMinorCiv(): if currentEra > 2: newName = TRNSLTR.getText("TXT_KEY_MOD_DCN_NATION", ()) % (curAdj) elif currentEra == 2: newName = TRNSLTR.getText("TXT_KEY_MOD_DCN_CITY_STATE", ()) % (curAdj) elif 70 - 40 * currentEra > GAME.getSorenRandNum( 100, "Naming"): newName = TRNSLTR.getText("TXT_KEY_MOD_DCN_TRIBE", ()) % (curAdj) else: newName = TRNSLTR.getText("TXT_KEY_MOD_DCN_CITY_STATE", ()) % (curAdj) elif currentEra < 4: # Early era barbs if SDTK.sdObjectGetVal('BarbarianCiv', pPlayer, 'BarbStyle') != 'Military': if numCities == 1: newName = TRNSLTR.getText("TXT_KEY_MOD_DCN_CITY_STATE", ()) % (curAdj) else: newName = TRNSLTR.getText("TXT_KEY_MOD_DCN_EMPIRE", ()) % (curAdj) if numCities < 3 and cityString is not None and len( cityString) < 10: newName += TRNSLTR.getText("TXT_KEY_MOD_DCN_OF_CITY", ()) % (cityString) elif pPlayer.getNumMilitaryUnits() > 7 * numCities: newName = TRNSLTR.getText("TXT_KEY_MOD_DCN_HORDE", ()) % (curAdj) elif cityString is None or len(cityString) > 9: newName = TRNSLTR.getText("TXT_KEY_MOD_DCN_WARRIOR_STATE", ()) % (curAdj) elif cityString in curAdj or cityString in curShort: newName = TRNSLTR.getText( "TXT_KEY_MOD_DCN_THE_WARRIORS_OF", ()) % (cityString) else: newName = TRNSLTR.getText("TXT_KEY_MOD_DCN_WARRIORS_OF", ()) % (curAdj, cityString) else: newName = TRNSLTR.getText("TXT_KEY_MOD_DCN_EMPIRE", ()) % (curAdj) if numCities < 3 and cityString is not None and len( cityString) < 10: newName += TRNSLTR.getText("TXT_KEY_MOD_DCN_OF_CITY", ()) % (cityString) return [newName, curShort, curAdj] if GAME.getGameTurn() == GAME.getStartTurn( ) and GAME.getCurrentEra() < 1: # Name civs at beginning of game return [ TRNSLTR.getText("TXT_KEY_MOD_DCN_TRIBE", ()) % (curAdj), curShort, curAdj ] return self.newNameByCivics(iPlayer)