def showRevoltDictPopup( self ) : bodStr = "" for idx in range(0,gc.getMAX_PLAYERS()): if( gc.getPlayer(idx).isEverAlive() ) : ePlayer = idx bodStr += "%d "%(idx) bodStr += "<color=%d,%d,%d,%d>" %(gc.getPlayer(ePlayer).getPlayerTextColorR(), gc.getPlayer(ePlayer).getPlayerTextColorG(), gc.getPlayer(ePlayer).getPlayerTextColorB(), gc.getPlayer(ePlayer).getPlayerTextColorA()) bodStr += "%s"%(gc.getPlayer(idx).getCivilizationShortDescription(0)) if( SDTK.sdObjectExists( 'BarbarianCiv', gc.getPlayer(idx) ) ) : bodStr += " BARB (%d)"%(SDTK.sdObjectGetVal( 'BarbarianCiv', gc.getPlayer(idx), "SpawnTurn" )) elif( not RevData.revObjectGetVal( gc.getPlayer(idx), 'RevolutionTurn' ) == None ): bodStr += " REB (%d)"%(RevData.revObjectGetVal( gc.getPlayer(idx), 'RevolutionTurn' )) bodStr += ": " for revData in RevData.revObjectGetVal( gc.getPlayer(idx), 'RevoltDict' ).values() : bodStr += "%d,%d ; "%(revData.iRevTurn,revData.dict.get('iRevPlayer',-1)) bodStr += "</color>" bodStr += "\n" # if( RevolutionInit.RevolutionInst == None ) : # bodStr += "RevolutionInit.RevInst is None\n" # else : # bodStr += "RevolutionInit.RevInst is initialized\n" popup = PyPopup.PyPopup() popup.setBodyString( bodStr ) popup.launch()
def onKbdEvent(self, argsList): 'keypress handler' eventType, key, mx, my, px, py = argsList if (eventType == RevDefs.EventKeyDown): theKey = int(key) if (theKey == int(InputTypes.KB_X) and self.customEM.bShift and self.customEM.bCtrl): # Get it? Shift ... control ... to the AI #------------------------------------------------------------------------------------------------- # Lemmy101 RevolutionMP edit #------------------------------------------------------------------------------------------------- if (game.getAIAutoPlay(game.getActivePlayer()) > 0): try: bCanCancelAuto = SdToolKitCustom.sdObjectGetVal( "AIAutoPlay", game, "bCanCancelAuto") if (bCanCancelAuto is None): bCanCancelAuto = True SdToolKitCustom.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(game.getActivePlayer()) self.disableMultiCheck(game.getActivePlayer()) #------------------------------------------------------------------------------------------------- # END Lemmy101 RevolutionMP edit #------------------------------------------------------------------------------------------------- self.checkPlayer() else: self.toAIChooser() if (theKey == int(InputTypes.KB_M) and self.customEM.bShift and self.customEM.bCtrl): # Toggle auto moves if (self.LOG_DEBUG): CyInterface().addImmediateMessage("Moving your units...", "") #self.playerID = gc.getActivePlayer().getID() game.setAIAutoPlay(game.getActivePlayer(), 1) if (theKey == int(InputTypes.KB_O) and self.customEM.bShift and self.customEM.bCtrl): RevUtils.doRefortify(game.getActivePlayer())
def onGameLoad( self, argsList ) : # Init things which require a game object or other game data to exist if( not SdToolKitCustom.sdObjectExists( "AIAutoPlay", game ) ) : SdToolKitCustom.sdObjectInit( "AIAutoPlay", game, {} ) SdToolKitCustom.sdObjectSetVal( "AIAutoPlay", game, "bCanCancelAuto", True ) elif( SdToolKitCustom.sdObjectGetVal( "AIAutoPlay", game, "bCanCancelAuto" ) == None ) : SdToolKitCustom.sdObjectSetVal( "AIAutoPlay", game, "bCanCancelAuto", True )
def revLoad(object): cyTable = SdToolKitCustom.sdLoad(object) if ('Revolution' in cyTable): return cyTable['Revolution'] else: return {}
def revLoad( object ): cyTable = SdToolKitCustom.sdLoad( object ) if( 'Revolution' in cyTable ) : return cyTable['Revolution'] else : return {}
def onTechAcquired(argsList): 'Tech Acquired' iTechType, iTeam, iPlayer, bAnnounce = argsList # Note that iPlayer may be NULL (-1) and not a refer to a player object if( (iTeam >= 0) and (iTeam <= gc.getMAX_CIV_TEAMS()) ) : teamI = gc.getTeam(iTeam) if(teamI.isAlive()) : if( teamI.isMinorCiv() and gc.getTechInfo(iTechType).isOpenBordersTrading() ) : if( SDTK.sdObjectExists( 'BarbarianCiv', game ) ) : for idx in range(0,gc.getMAX_CIV_PLAYERS()) : playerI = gc.getPlayer(idx) if( playerI.isAlive() and (playerI.getTeam() == iTeam ) ) : if( idx in SDTK.sdObjectGetVal( "BarbarianCiv", game, "AlwaysMinorList" ) ) : # Keep scenario minors defined in RevDefs as always minor return # if( gc.getGame().isOption(GameOptionTypes.GAMEOPTION_START_AS_MINORS) ) : if (2 < 1): for idx in range(0,gc.getMAX_CIV_PLAYERS()) : playerI = gc.getPlayer(idx) if( playerI.getTeam() == iTeam and playerI.isAlive() ) : if( SDTK.sdObjectExists( 'BarbarianCiv', playerI ) ) : if( SDTK.sdObjectGetVal( 'BarbarianCiv', playerI, 'SettleTurn' ) == None ) : # Use BarbarianCiv logic return if( LOG_DEBUG ) : CvUtil.pyPrint("SAM - Settled barb civ %s now has Writing"%(playerI.getCivilizationDescription(0))) if( LOG_DEBUG ) : CvUtil.pyPrint("SAM - clearing minor status for team %d with Writing"%(iTeam)) teamI.setIsMinorCiv(False, False) for idx in range(0,gc.getMAX_CIV_PLAYERS()) : playerI = gc.getPlayer(idx) if( gc.getPlayer(idx).getTeam() == iTeam and playerI.isAlive() ) : if( not RevInstances.DynamicCivNamesInst == None ) : RevInstances.DynamicCivNamesInst.setNewNameByCivics( iPlayer ) CyInterface().addMessage(iPlayer, false, gc.getDefineINT("EVENT_MESSAGE_TIME"), localText.getText("TXT_KEY_BARBCIV_DISCOVER_WRITING", ()), None, InterfaceMessageTypes.MESSAGE_TYPE_MAJOR_EVENT, None, gc.getInfoTypeForString("COLOR_HIGHLIGHT_TEXT"), -1, -1, False, False) gc.getMap().verifyUnitValidPlot()
def onKbdEvent( self, argsList ) : 'keypress handler' eventType,key,mx,my,px,py = argsList if ( eventType == RevDefs.EventKeyDown ): theKey=int(key) if( theKey == int(InputTypes.KB_X) and self.customEM.bShift and self.customEM.bCtrl ) : # Get it? Shift ... control ... to the AI #------------------------------------------------------------------------------------------------- # Lemmy101 RevolutionMP edit #------------------------------------------------------------------------------------------------- if( game.getAIAutoPlay(game.getActivePlayer()) > 0 ) : try : bCanCancelAuto = SdToolKitCustom.sdObjectGetVal( "AIAutoPlay", game, "bCanCancelAuto" ) if( bCanCancelAuto is None ) : bCanCancelAuto = True SdToolKitCustom.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( game.getActivePlayer() ) self.disableMultiCheck(game.getActivePlayer()) #------------------------------------------------------------------------------------------------- # END Lemmy101 RevolutionMP edit #------------------------------------------------------------------------------------------------- self.checkPlayer() else : self.toAIChooser() if( theKey == int(InputTypes.KB_M) and self.customEM.bShift and self.customEM.bCtrl ) : # Toggle auto moves if( self.LOG_DEBUG ) : CyInterface().addImmediateMessage("Moving your units...","") #self.playerID = gc.getActivePlayer().getID() game.setAIAutoPlay( game.getActivePlayer(), 1 ) if( theKey == int(InputTypes.KB_O) and self.customEM.bShift and self.customEM.bCtrl ) : RevUtils.doRefortify( game.getActivePlayer() )
def onGameLoad( self, argsList ) : # Init things which require a game object or other game data to exist if( not SdToolKitCustom.sdObjectExists( "AIAutoPlay", game ) ) : SdToolKitCustom.sdObjectInit( "AIAutoPlay", game, {} ) SdToolKitCustom.sdObjectSetVal( "AIAutoPlay", game, "bCanCancelAuto", True ) elif( SdToolKitCustom.sdObjectGetVal( "AIAutoPlay", game, "bCanCancelAuto" ) == None ) : SdToolKitCustom.sdObjectSetVal( "AIAutoPlay", game, "bCanCancelAuto", True ) for idx in range(0,gc.getMAX_CIV_PLAYERS()) : playerI = gc.getPlayer(idx) if(playerI.isHumanDisabled()): if(not game.isForcedAIAutoPlay(idx)): game.setAIAutoPlay(idx, 1)
def abdicate( self, playerID, numTurns = -1, voluntary = False ) : 'Turn over control to the AI' if( numTurns > 0 ) : self.TurnsToAuto[playerID] = numTurns if( self.TurnsToAuto[playerID] < 1 ) : return #if( voluntary and self.SHOW_NEW_LEADER_POPUP and game.getActivePlayer()==playerID ) : # popup = PyPopup.PyPopup(RevDefs.abdicatePopup,contextType = EventContextTypes.EVENTCONTEXT_ALL) # popup.setHeaderString( localText.getText("TXT_KEY_AIAUTOPLAY_NEW_LEADER", ()) ) # if( voluntary ) : # bodStr = localText.getText("TXT_KEY_AIAUTOPLAY_ABDICATE", ()) # else : # bodStr = localText.getText("TXT_KEY_AIAUTOPLAY_USURPATOR", ()) # bodStr = bodStr + localText.getText("TXT_KEY_AIAUTOPLAY_GOOD_NEWS", ()) %(self.TurnsToAuto[playerID]) # popup.setBodyString( bodStr ) # popup.launch() #else : if( voluntary ) : SdToolKitCustom.sdObjectSetVal( "AIAutoPlay", game, "bCanCancelAuto", True ) game.setAIAutoPlay( playerID, self.TurnsToAuto[playerID] )
def abdicate(self, playerID, numTurns=-1, voluntary=False): 'Turn over control to the AI' if (numTurns > 0): self.TurnsToAuto[playerID] = numTurns if (self.TurnsToAuto[playerID] < 1): return #if( voluntary and self.SHOW_NEW_LEADER_POPUP and game.getActivePlayer()==playerID ) : # popup = PyPopup.PyPopup(RevDefs.abdicatePopup,contextType = EventContextTypes.EVENTCONTEXT_ALL) # popup.setHeaderString( localText.getText("TXT_KEY_AIAUTOPLAY_NEW_LEADER", ()) ) # if( voluntary ) : # bodStr = localText.getText("TXT_KEY_AIAUTOPLAY_ABDICATE", ()) # else : # bodStr = localText.getText("TXT_KEY_AIAUTOPLAY_USURPATOR", ()) # bodStr = bodStr + localText.getText("TXT_KEY_AIAUTOPLAY_GOOD_NEWS", ()) %(self.TurnsToAuto[playerID]) # popup.setBodyString( bodStr ) # popup.launch() #else : if (voluntary): SdToolKitCustom.sdObjectSetVal("AIAutoPlay", game, "bCanCancelAuto", True) game.setAIAutoPlay(playerID, self.TurnsToAuto[playerID])
def onGameLoad(self, argsList): # Init things which require a game object or other game data to exist if (not SdToolKitCustom.sdObjectExists("AIAutoPlay", game)): SdToolKitCustom.sdObjectInit("AIAutoPlay", game, {}) SdToolKitCustom.sdObjectSetVal("AIAutoPlay", game, "bCanCancelAuto", True) elif (SdToolKitCustom.sdObjectGetVal("AIAutoPlay", game, "bCanCancelAuto") == None): SdToolKitCustom.sdObjectSetVal("AIAutoPlay", game, "bCanCancelAuto", True) for idx in range(0, gc.getMAX_CIV_PLAYERS()): playerI = gc.getPlayer(idx) if (playerI.isHumanDisabled()): if (not game.isForcedAIAutoPlay(idx)): game.setAIAutoPlay(idx, 1)
def revObjectSetVal(object, var, val): 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 return SdToolKitCustom.sdObjectSetVal('Revolution', object, var, val)
def revObjectSetVal( object, var, val ): 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 return SdToolKitCustom.sdObjectSetVal( 'Revolution', object, var, val )
def onBeginPlayerTurn( self, argsList ) : iGameTurn, iPlayer = argsList # 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.getBARBARIAN_PLAYER() ) : iPlayer = iPrevPlayer pPlayer = gc.getPlayer( iPlayer ) if( pPlayer.isAlive() and SDTK.sdObjectExists( "Revolution", pPlayer ) ) : #CvUtil.pyPrint(" Name - Object exists %d"%(iPlayer)) prevCivics = SDTK.sdObjectGetVal( "Revolution", pPlayer, 'CivicList' ) if( not prevCivics == None ) : for i in range(0,gc.getNumCivicOptionInfos()): if( not prevCivics[i] == pPlayer.getCivics(i) ) : self.setNewNameByCivics(iPlayer) return revTurn = SDTK.sdObjectGetVal( "Revolution", pPlayer, 'RevolutionTurn' ) if( not revTurn == 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( not barbTurn == None and game.getGameTurn() - barbTurn == 30 ) : # "Graduate" from barb civ name self.setNewNameByCivics(iPlayer) return if( pPlayer.isAlive() and not SDTK.sdObjectExists( "BarbarianCiv", pPlayer )) : if( 'Tribe' in pPlayer.getCivilizationDescription(0) ) : if( pPlayer.getCurrentEra() > 0 or pPlayer.getTotalPopulation() >= 3 ) : # Graduate from game start name CvUtil.pyPrint(" Name - Graduating from game start name Player %d"%(iPlayer)) self.setNewNameByCivics(iPlayer) return # lfgr: Alliances if( pPlayer.isAlive() and gc.getTeam( pPlayer.getTeam() ).getNumMembers() == 2 ) : if( not "Alliance" in pPlayer.getCivilizationDescription(0) ) : CvUtil.pyPrint( " Name - Changing name from Alliance of Player %d"%( iPlayer ) ) self.setNewNameByCivics( iPlayer )
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 SdToolKitCustom.sdObjectGetVal( 'Revolution', object, var )
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 SdToolKitCustom.sdObjectGetVal('Revolution', object, var)
def revObjectInit(object, VarDictionary={}): return SdToolKitCustom.sdObjectInit('Revolution', object, VarDictionary)
def onBeginPlayerTurn(self, argsList): iGameTurn, iPlayer = argsList # 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.getBARBARIAN_PLAYER()): iPlayer = iPrevPlayer pPlayer = gc.getPlayer(iPlayer) if (pPlayer.isAlive() and SDTK.sdObjectExists("Revolution", pPlayer)): #CvUtil.pyPrint(" Name - Object exists %d"%(iPlayer)) prevCivics = SDTK.sdObjectGetVal("Revolution", pPlayer, 'CivicList') if (not prevCivics == None): for i in range(0, gc.getNumCivicOptionInfos()): if (not prevCivics[i] == pPlayer.getCivics(i)): self.setNewNameByCivics(iPlayer) return revTurn = SDTK.sdObjectGetVal("Revolution", pPlayer, 'RevolutionTurn') if (not revTurn == 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 (not barbTurn == None and game.getGameTurn() - barbTurn == 30): # "Graduate" from barb civ name self.setNewNameByCivics(iPlayer) return if (pPlayer.isAlive() and not SDTK.sdObjectExists("BarbarianCiv", pPlayer)): if ('Tribe' in pPlayer.getCivilizationDescription(0)): if (pPlayer.getCurrentEra() > 0 or pPlayer.getTotalPopulation() >= 3): # Graduate from game start name CvUtil.pyPrint( " Name - Graduating from game start name Player %d" % (iPlayer)) self.setNewNameByCivics(iPlayer) return # lfgr: Alliances if (pPlayer.isAlive() and gc.getTeam(pPlayer.getTeam()).getNumMembers() == 2): if (not "Alliance" in pPlayer.getCivilizationDescription(0)): CvUtil.pyPrint( " Name - Changing name from Alliance of Player %d" % (iPlayer)) self.setNewNameByCivics(iPlayer)
def revObjectUpdateVal(object, var, val): return SdToolKitCustom.sdObjectUpdateVal('Revolution', object, var, val)
def revObjectChangeVal(object, var, delta): return SdToolKitCustom.sdObjectChangeVal('Revolution', object, var, delta)
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_CIV_PLAYERS()): if (gc.getPlayer(i).getCurrentEra() > currentEra): currentEra = gc.getPlayer(i).getCurrentEra() curDesc = pPlayer.getCivilizationDescription(0) curShort = pPlayer.getCivilizationShortDescription(0) curAdj = pPlayer.getCivilizationAdjective(0) # lfgr if (pPlayer.getCivilizationType() == self.iClan): curAdj = "Orcish" # lfgr end 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') if (self.LOG_DEBUG): CvUtil.pyPrint("Names - player is rebel") 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: # lfgr # old # 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) 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) # lfgr end # lfgr commented out # 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( self.LOG_DEBUG ) : CvUtil.pyPrint("Names - player is barbciv") # # 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", ()) + 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", ()) + cityString # # lfgr end else: if (game.getGameTurn() == game.getStartTurn() and game.getCurrentEra() < 1): # Name civs at beginning of game if (self.LOG_DEBUG): CvUtil.pyPrint("Names - Giving game start name") newName = localText.getText("TXT_KEY_MOD_DCN_TRIBE", ()) % (curAdj) return [newName, curShort, curAdj] if (self.LOG_DEBUG): CvUtil.pyPrint( "Names - player not of special type, naming by civics") return self.newNameByCivics(iPlayer) # lfgr: revert "Orcish" curAdj = pPlayer.getCivilizationAdjective(0) # lfgr end return [newName, curShort, curAdj]
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( not capital == None and not capital.isNone() ) : 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) civInfo = gc.getCivilizationInfo(pPlayer.getCivilizationType()) origDesc = civInfo.getDescription() eGovCivic = pPlayer.getCivics(gc.getInfoTypeForString("CIVICOPTION_GOVERNMENT")) bNoRealElections = (gc.getInfoTypeForString("CIVIC_HEREDITARY_RULE") == eGovCivic or gc.getInfoTypeForString("CIVIC_HEREDITARY_RULE") == eGovCivic or gc.getInfoTypeForString("CIVIC_DESPOTISM") == eGovCivic or gc.getInfoTypeForString("CIVIC_FASCIST") == eGovCivic) 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() ) : if( self.LOG_DEBUG and bVerbose ) : CvUtil.pyPrint("Names - player is not alive") newName = localText.getText("TXT_KEY_MOD_DCN_REFUGEES", ())%(curAdj) return [newName, curShort, curAdj] if( pPlayer.isRebel() ) : # Maintain name of rebels from Revolution Mod if( self.LOG_DEBUG and bVerbose ) : CvUtil.pyPrint("Names - player is rebel, keeping current name") if( bForceUpdate ) : return self.nameForNewPlayer(iPlayer) else : return [curDesc, curShort, curAdj] elif( pPlayer.isMinorCiv() and not barbTurn == None ) : # Maintain minor civ name if( self.LOG_DEBUG and bVerbose ) : CvUtil.pyPrint("Names - player is Minor Barb Civ, keeping current 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( self.LOG_DEBUG and bVerbose ) : CvUtil.pyPrint("Names - player is BarbCiv, keeping current name") 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( self.LOG_DEBUG and bVerbose ) : CvUtil.pyPrint("Names - Multiple players on team") if( self.LOG_DEBUG and bVerbose and pTeam.getPermanentAllianceTradingCount() > 0 ) : CvUtil.pyPrint("Names - Player in Permanent Alliance") if( pTeam.getNumMembers() == 2 ) : iLeader = pTeam.getLeaderID() newName = gc.getPlayer(iLeader).getCivilizationAdjective(0) + "-" for idx in range(0,gc.getMAX_CIV_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_CIV_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() # Main naming conditions if( RevUtils.isCommunism(iPlayer) ) : if( self.LOG_DEBUG and bVerbose ) : CvUtil.pyPrint("Names - player is communist") if( RevUtils.isCanDoElections(iPlayer) and not bNoRealElections) : if( not bForceUpdate and (sSocRep in curDesc or sPeoplesRep in curDesc) ) : if( self.LOG_DEBUG and bVerbose ) : CvUtil.pyPrint("Names - keeping prior name") 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) : if( self.LOG_DEBUG and bVerbose ) : CvUtil.pyPrint("Names - player can do elections") 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)) ) : if( self.LOG_DEBUG and bVerbose ) : CvUtil.pyPrint("Names - keeping prior name") 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 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 : if( self.LOG_DEBUG and bVerbose ) : CvUtil.pyPrint("Names - keeping prior name") newName = curDesc elif( 50 > game.getSorenRandNum(100,'Rev: Naming') ) : newName = localText.getText("TXT_KEY_MOD_DCN_REPUBLIC", ())%(curAdj) 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 ) : if( self.LOG_DEBUG and bVerbose ) : CvUtil.pyPrint("Names - player is police state") 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 ) : if( self.LOG_DEBUG and bVerbose ) : CvUtil.pyPrint("Names - keeping prior name") 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 : newName = curAdj + ' ' + empString else : sGreat = localText.getText("TXT_KEY_MOD_DCN_GREAT_KINGDOM", ()).replace('%s','').strip() sKingdom = localText.getText("TXT_KEY_MOD_DCN_KINGDOM", ()) if( RevUtils.getDemocracyLevel(iPlayer)[0] == -6 ) : if( pTeam.isAVassal() ) : if( self.LOG_DEBUG and bVerbose ) : CvUtil.pyPrint("Names - player is a vassal") 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( self.LOG_DEBUG and bVerbose ) : CvUtil.pyPrint("Names - player is in monarchy") 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 : newName = localText.getText("TXT_KEY_MOD_DCN_BLANK_OF_CITY", ())%(sKingdom,curAdj,cityString) 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')) ) : 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) ) : if( self.LOG_DEBUG and bVerbose ) : CvUtil.pyPrint("Names - keeping prior name") newName = curDesc elif( 50 > game.getSorenRandNum(100,'Rev: Naming') ) : 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 ) : if( self.LOG_DEBUG and bVerbose ) : CvUtil.pyPrint("Names - player has one city in early era") empString = localText.getText("TXT_KEY_MOD_DCN_PLAIN_CITY_STATE", ()) if( pTeam.isAVassal() ) : if( self.LOG_DEBUG and bVerbose ) : CvUtil.pyPrint("Names - player is a vassal") empString = localText.getText("TXT_KEY_MOD_DCN_FIEFDOM", ()) if( self.LOG_DEBUG and bVerbose ) : CvUtil.pyPrint("Names - player is in despotism") if( not bForceUpdate and empString in curDesc and not game.getGameTurn() == 0 ) : if( self.LOG_DEBUG and bVerbose ) : CvUtil.pyPrint("Names - keeping prior name") newName = curDesc elif( 50 > game.getSorenRandNum(100,'Rev: Naming') ) : newName = curAdj + ' ' + empString else : newName = localText.getText("TXT_KEY_MOD_DCN_THE_BLANK_OF", ())%(empString,curShort) else : if( self.LOG_DEBUG and bVerbose ) : CvUtil.pyPrint("Names - Error: player fits no government category ... ") return [curDesc,curShort,curAdj] sHoly = localText.getText("TXT_KEY_MOD_DCN_HOLY", ()) + ' ' if( RevUtils.getReligiousFreedom(iPlayer)[0] < -9 ) : if( self.LOG_DEBUG and bVerbose ) : CvUtil.pyPrint("Names - player is theocracy") 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):] return [newName, curShort, curAdj]
def newNameByCivics( self, iPlayer, bVerbose = True, bForceUpdate = False ) : # Assigns a new name to a player based on their civics choices # TODO: performance pPlayer = gc.getPlayer( iPlayer ) pCapital = pPlayer.getCapitalCity() playerEra = pPlayer.getCurrentEra() iTeam = pPlayer.getTeam() pTeam = gc.getTeam( iTeam ) sCpt = None if( not pCapital == None and not pCapital.isNone() ) : try : # Silly game to force ascii encoding now sCpt = pPlayer.getCivilizationDescription(0) sCpt += "&" + CvUtil.convertToStr(pCapital.getName()) sCpt = sCpt.split('&',1)[-1] except : pass sDsc = pPlayer.getCivilizationDescription(0) sSrt = pPlayer.getCivilizationShortDescription(0) sAdj = pPlayer.getCivilizationAdjective(0) iCiv = pPlayer.getCivilizationType() pCiv = gc.getCivilizationInfo( iCiv ) sOrgDsc = pCiv.getDescription() if( not game.isOption(GameOptionTypes.GAMEOPTION_LEAD_ANY_CIV) ) : if( pPlayer.getLeaderType() in LeaderCivNames.LeaderCivNames.keys() ) : [sDsc,sSrt,sAdj] = LeaderCivNames.LeaderCivNames[pPlayer.getLeaderType()] newName = sDsc 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() ) : if( self.LOG_DEBUG and bVerbose ) : CvUtil.pyPrint("Names - player is not alive") newName = localText.getText("TXT_KEY_MOD_DCN_REFUGEES", ())%(sAdj) return [newName, sSrt, sAdj] ######################################################################### # Rebel # ######################################################################### if( pPlayer.isRebel() ) : # Maintain name of rebels from Revolution Mod if( self.LOG_DEBUG and bVerbose ) : CvUtil.pyPrint("Names - player is rebel, keeping current name") if( bForceUpdate ) : return self.nameForNewPlayer(iPlayer) else : return [sDsc, sSrt, sAdj] ######################################################################### # Teams/Permanent Alliances # ######################################################################### # Special options for teams and permanent alliances if( self.bTeamNaming and pTeam.getNumMembers() > 1 ) : # and pTeam.getPermanentAllianceTradingCount() > 0 ) : if( self.LOG_DEBUG and bVerbose ) : CvUtil.pyPrint("Names - Multiple players on team") if( self.LOG_DEBUG and bVerbose and pTeam.getPermanentAllianceTradingCount() > 0 ) : CvUtil.pyPrint("Names - Player in Permanent Alliance") iLeader = pTeam.getLeaderID() sNewName = gc.getPlayer(iLeader).getCivilizationAdjective(0) for iLoopPlayer in range( 0, gc.getMAX_CIV_PLAYERS() ) : if( iLoopPlayer != iLeader and gc.getPlayer( iLoopPlayer ).getTeam() == pTeam.getID() ) : sLoopAdj = gc.getPlayer( iLoopPlayer ).getCivilizationAdjective(0) if( not sLoopAdj in sNewName ) : # prevent Luchuirp-Luchuirp Alliance sNewName += "-" + sLoopAdj sNewName += " " + localText.getText("TXT_KEY_MOD_DCN_ALLIANCE", ()) return [sNewName,sSrt,sAdj] ######################################################################### # From Civics # ######################################################################### if( self.LOG_DEBUG ) : CvUtil.pyPrint("Names - Start computing name") # parameters sLeaderName = pPlayer.getName() iNumCities = pPlayer.getNumCities() # Eras dont work this same way in FFH2 # bAncient = ( playerEra == 1 ) iMxc = 0 # (e.g. "ADJ EMP of CAPITAL" when NumCities <= iMxc) if (iNumCities == 1): sEmp = "Lands" sAltEmp = "Stronghold" else: sEmp = "Empire" sAltEmp = "Territories" sPre = "" # Prefix sAltPre = "" bBof = False # Block "of" (e.g. never "PRE EMP of SRT", but "PRE ADJ EMP") bFof = False # Force "of" (e.g. never "PRE ADJ EMP", but "PRE EMP of SRT") bGood = pPlayer.getAlignment() == self.iGood bEvil = pPlayer.getAlignment() == self.iEvil # Traits bCharismatic = pPlayer.hasTrait(gc.getInfoTypeForString('TRAIT_CHARISMATIC')) bInsane = pPlayer.hasTrait(gc.getInfoTypeForString('TRAIT_INSANE')) #Civics bDespotism = pPlayer.isCivic( self.iDespotism ) bCityStates = pPlayer.isCivic( self.iCityStates ) bGodKing = pPlayer.isCivic( self.iGodKing ) bAristocracy = pPlayer.isCivic( self.iAristocracy ) bTheocracy = pPlayer.isCivic( self.iTheocracy ) bRepublic = pPlayer.isCivic( self.iRepublic ) bReligion = pPlayer.isCivic( self.iReligion ) bPacifism = pPlayer.isCivic( self.iPacifism ) bLiberty = pPlayer.isCivic( self.iLiberty ) bTribalism = pPlayer.isCivic( self.iTribalism ) bMilitaryState = pPlayer.isCivic( self.iMilitaryState ) bConquest = pPlayer.isCivic( self.iConquest ) bCrusade = pPlayer.isCivic( self.iCrusade ) bGuilds = pPlayer.isCivic ( self.iGuilds ) bSlavery = pPlayer.isCivic ( self.iSlavery ) bArete = pPlayer.isCivic ( self.iArete ) bGuardian = pPlayer.isCivic ( self.iGuardian ) bForeignTrade = pPlayer.isCivic ( self.iForeignTrade ) bSacrifice = pPlayer.isCivic ( self.iSacrifice ) bDecentralization = pPlayer.isCivic ( self.iDecentralization ) # Misc bPuppet = pPlayer.isPuppetState() bHolyShrine = false if pPlayer.getStateReligion() >= 0: if pPlayer.hasHolyCity(pPlayer.getStateReligion()): bHolyShrine = true bVeil = pPlayer.getStateReligion() == self.iVeil bEmpyrean = pPlayer.getStateReligion() == self.iEmpyrean bOrder = pPlayer.getStateReligion() == self.iOrder bKilmorph = pPlayer.getStateReligion() == self.iKilmorph bCalabim = iCiv == self.iCalabim bClan = iCiv == self.iClan if( bClan ) : sSrt = "Embers" sAdj = "Orcish" bNoShuffle = False sPost = "" if( iNumCities == 0 ) : sEmp = "Tribe" sAltEmp = "Peoples" #Note: Never used due to next line return ["%s %s"%( sAdj, sEmp ), sSrt,sAdj] if bCharismatic: sPre = "Beloved" elif bInsane: sPre = "Deranged" if( bDespotism ) : iMxc = 2 if( bClan ) : sEmp = "Clan" sAltEmp = "Clan" # elif( bAncient ) : # sEmp = "Chiefdom" # sAltEmp = "Empire" else : sAltEmp = "Chiefdom" if( bGood ) : sEmp = "Autocracy" elif( bEvil ) : sEmp = "Tyranny" # else: Default elif( bCityStates ) : if bMilitaryState: sEmp = "Hegemony" sAltEmp = "Hegemony" iMxc = 1 if( iNumCities == 1 ) : sEmp = "City" sAltEmp = "City State" else : sEmp = "Federation" sAltEmp = "League" sPost = "City States" if bSlavery: sPost = "Slavers" if bForeignTrade: sPre = "" sEmp = "Confederation" elif bDecentralization: if iNumCities == 1: sEmp = "Independent State" else: sEmp = "Independent Alliance" elif( bGodKing ) : iMxc = 4 if bReligion: sEmp = "Cult" sAltEmp = "Followers" bFof = True elif bPacifism: sPre = "Benevolent" else: sEmp = "Monarchy" sAltEmp = "Sovereignty" if( bClan ) : sEmp = "Clan" sAltEmp = "Clan" elif( bAristocracy ) : iMxc = 3 if( bCalabim ) : sEmp = "Principalities" sAltEmp = "Kingdom" if bGuilds: sEmp = "Imperium" elif bSlavery: sEmp = "Dynasty" bFof = True elif bMilitaryState: sEmp = "Monarchy" else: sEmp = "Kingdom" sAltEmp = "Realm" if bConquest: sPre = "Imperial" sAltPre = "Majestic" elif bArete: sEmp = "Plutocracy" else: sPre = "Royal" sAltPre = "Noble" elif( bTheocracy ) : iMxc = 2 sPre = "Divine" sAltPre = "Chosen" # sEmp = "Divinity" elif( bRepublic ) : iMxc = 1 sAltPre = "Democratic" if( bEvil ) : sEmp = "Ochlocracy" sAltEmp = "Republic" else : sEmp = "Republic" if( bReligion ) : if sPre == "": sPre = "Sacred" sAltPre = "Holy" if( bGodKing and iNumCities <= iMxc ) : sPre = "Sacred" sEmp = "See" elif( bTheocracy): sEmp = "Caliphate" sAltPre = "Theocratic" if ( bVeil ) : if bHolyShrine: return ["Chosen of Agares", sSrt,sAdj] sPre = "The Ashen" elif( bEmpyrean ) : sPre = "Illuminated" elif( bOrder ) : sPre = "Righteous" elif( bPacifism ) : if( bCityStates and iNumCities > iMxc ) : sEmp = "Commune" bFof = True elif( bLiberty ) : sPre = "Free" sAltPre = "Liberated" if( bAristocracy ) : bNoShuffle = True sEmp = "Imperial Estates" bFof = True elif( bTribalism and bDespotism ) : sPre = "Tribal" # even if era not ancient sAltEmp = "Chiefdom" if bCrusade: sPre = "Righteous" sAltPre = "Righteous" elif bGuilds: sPre = "Technocratic" if bMilitaryState: if bConquest: if bAristocracy: bEmp = "Dynasty" else: sEmp = "Junta" bFof = true elif bRepublic: sEmp = "Regime" if bPuppet: iMxc = 5 # TODO: puppet states have no capital sPre = "" sAltPre = "" sEmp = "Satrapy" sAltEmp = "Satrapy" if bMilitaryState: sEmp = "Prefecture" sAltEmp = "Prefecture" if bAristocracy: sEmp = "Province" sAltEmp = "Province" if bReligion or bTheocracy: sEmp = "Diocese" sAltEmp = "Diocese" return ["%s %s"%( sAdj, sEmp ), sSrt,sAdj] if pCapital != -1: pCapitalPlot = pCapital.plot() pCapitalLatitude = pCapitalPlot.getLatitude() if pCapitalLatitude > 50: map = CyMap() iMapHeight = map.getGridHeight() if pCapitalPlot.getY() < (iMapHeight / 2): sPre = "Southern" else: sPre = "Northern" if (bArete and bHolyShrine): sPre = "Golden" sAltPre = "Golden" elif bGuardian: sEmp = "Fellowship" sAltEmp = "Fellowship" elif bSacrifice: sPre = "Demonic" sAltPre = "Demonic" if( sPost != "" ) : return ["%s %s of %s %s"%(sPre, sEmp, sAdj, sPost), sSrt,sAdj] if( sPre != "" ) : sPre += " " if( sAltPre != "" ) : sAltPre += " " sTheSrt = sSrt if( not bClan ) : sTheSrt = "the " + sTheSrt # if( not bNoShuffle ) : # if( game.getSorenRandNum( 100, "DCN Shuffle" ) >= 50 ) : # sTmp = sPre # sPre = sAltPre # sAltPre = sTmp # if( game.getSorenRandNum( 100, "DCN Shuffle" ) >= 50 ) : # sTmp = sEmp # sEmp = sAltEmp # sAltEmp = sEmp lsDescs = list() if( not bBof and iNumCities <= iMxc and sEmp != "Clan" and sCpt != None ) : # Sacred Empire of Golden Lane sNewDesc = "%s%s of %s"%( sPre, sEmp, sCpt ) lsDescs.append( sNewDesc ) if( not bFof and sEmp != "Clan" ) : sNewDesc = "%s%s %s"%( sPre, sAdj, sEmp ) # Sacred Malakim Empire lsDescs.append( sNewDesc ) if( not bBof ) : sNewDesc = "%s%s of %s"%( sPre, sEmp, sTheSrt ) # Sacred Empire of the Malakim lsDescs.append( sNewDesc ) if ( bGodKing ) : sNewDesc = "%s%s of %s"%( sPre, sEmp, sLeaderName ) # Holy Cult of Tholal lsDescs.append( sNewDesc ) # try alternate prefix if( not bBof and iNumCities <= iMxc and sEmp != "Clan" and sCpt != None ) : # Holy Empire of Golden Lane sNewDesc = "%s%s of %s"%( sAltPre, sEmp, sCpt ) lsDescs.append( sNewDesc ) if( not bFof and sEmp != "Clan" ) : sNewDesc = "%s%s %s"%( sAltPre, sAdj, sEmp ) # Holy Malakim Empire lsDescs.append( sNewDesc ) if( not bBof ) : sNewDesc = "%s%s of %s"%( sAltPre, sEmp, sTheSrt ) # Holy Empire of the Malakim lsDescs.append( sNewDesc ) if ( bGodKing ) : sNewDesc = "%s%s of %s"%( sAltPre, sEmp, sLeaderName ) # Sovereignty of Tholal lsDescs.append( sNewDesc ) # try alternate empire if( not bBof and iNumCities <= iMxc and sAltEmp != "Clan" and sCpt != None ) : # Sacred Realm of Golden Lane sNewDesc = "%s%s of %s"%( sPre, sAltEmp, sCpt ) lsDescs.append( sNewDesc ) if( not bFof and sAltEmp != "Clan" ) : sNewDesc = "%s%s %s"%( sPre, sAdj, sAltEmp ) # Sacred Malakim Realm lsDescs.append( sNewDesc ) if( not bBof ) : sNewDesc = "%s%s of %s"%( sPre, sAltEmp, sTheSrt ) # Sacred Realm of the Malakim lsDescs.append( sNewDesc ) if ( bGodKing ) : sNewDesc = "%s%s of %s"%( sPre, sAltEmp, sLeaderName ) # Sovereignty of Tholal lsDescs.append( sNewDesc ) # try alternate prefix and empire if( not bBof and iNumCities <= iMxc and sAltEmp != "Clan" and sCpt != None ) : # Holy Realm of Golden Lane sNewDesc = "%s%s of %s"%( sAltPre, sAltEmp, sCpt ) lsDescs.append( sNewDesc ) if( not bFof and sAltEmp != "Clan" ) : sNewDesc = "%s%s %s"%( sAltPre, sAdj, sAltEmp ) # Holy Malakim Realm lsDescs.append( sNewDesc ) if( not bBof ) : sNewDesc = "%s%s of %s"%( sAltPre, sAltEmp, sTheSrt ) # Holy Realm of the Malakim lsDescs.append( sNewDesc ) if ( bGodKing ) : sNewDesc = "%s%s of %s"%( sAltPre, sAltEmp, sLeaderName ) # Sovereignty of Tholal lsDescs.append( sNewDesc ) if( self.LOG_DEBUG ) : CvUtil.pyPrint( " Names - WARNING: No unused Names for Player #%d!"%( iPlayer ) ) if( sDsc in lsDescs ) : print "MODIFIED DCN - Keeping name \"%s\"" % ( sDsc ) return [sDsc, sSrt, sAdj] random.shuffle(lsDescs) # shuffle the name options so we dont end up all using the same style for sNewDesc in lsDescs : if( self.isUnused( iPlayer, sNewDesc ) ) : print "MODIFIED DCN - Old name: \"%s\", New name: \"%s\"" % ( sDsc, sNewDesc ) return [sNewDesc, sSrt, sAdj] else : print "MODIFIED DCN - Name \"%s\" already used!" % ( sDsc ) return ["%s%s %s"%( sPre, sAdj, sEmp ),sSrt,sAdj] # keep current name
def revObjectWipe(object): return SdToolKitCustom.sdObjectWipe('Revolution', object)
def revObjectExists( object ): return SdToolKitCustom.sdObjectExists( 'Revolution', object )
def revObjectWipe( object ): return SdToolKitCustom.sdObjectWipe( 'Revolution', object )
def newNameByCivics(self, iPlayer, bVerbose=True, bForceUpdate=False): # Assigns a new name to a player based on their civics choices # TODO: performance pPlayer = gc.getPlayer(iPlayer) pCapital = pPlayer.getCapitalCity() playerEra = pPlayer.getCurrentEra() iTeam = pPlayer.getTeam() pTeam = gc.getTeam(iTeam) sCpt = None if (not pCapital == None and not pCapital.isNone()): try: # Silly game to force ascii encoding now sCpt = pPlayer.getCivilizationDescription(0) sCpt += "&" + CvUtil.convertToStr(pCapital.getName()) sCpt = sCpt.split('&', 1)[-1] except: pass sDsc = pPlayer.getCivilizationDescription(0) sSrt = pPlayer.getCivilizationShortDescription(0) sAdj = pPlayer.getCivilizationAdjective(0) iCiv = pPlayer.getCivilizationType() pCiv = gc.getCivilizationInfo(iCiv) sOrgDsc = pCiv.getDescription() if (not game.isOption(GameOptionTypes.GAMEOPTION_LEAD_ANY_CIV)): if (pPlayer.getLeaderType() in LeaderCivNames.LeaderCivNames.keys()): [sDsc, sSrt, sAdj] = LeaderCivNames.LeaderCivNames[pPlayer.getLeaderType()] newName = sDsc 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()): if (self.LOG_DEBUG and bVerbose): CvUtil.pyPrint("Names - player is not alive") newName = localText.getText("TXT_KEY_MOD_DCN_REFUGEES", ()) % (sAdj) return [newName, sSrt, sAdj] ######################################################################### # Rebel # ######################################################################### if (pPlayer.isRebel()): # Maintain name of rebels from Revolution Mod if (self.LOG_DEBUG and bVerbose): CvUtil.pyPrint("Names - player is rebel, keeping current name") if (bForceUpdate): return self.nameForNewPlayer(iPlayer) else: return [sDsc, sSrt, sAdj] ######################################################################### # Teams/Permanent Alliances # ######################################################################### # Special options for teams and permanent alliances if (self.bTeamNaming and pTeam.getNumMembers() > 1): # and pTeam.getPermanentAllianceTradingCount() > 0 ) : if (self.LOG_DEBUG and bVerbose): CvUtil.pyPrint("Names - Multiple players on team") if (self.LOG_DEBUG and bVerbose and pTeam.getPermanentAllianceTradingCount() > 0): CvUtil.pyPrint("Names - Player in Permanent Alliance") iLeader = pTeam.getLeaderID() sNewName = gc.getPlayer(iLeader).getCivilizationAdjective(0) for iLoopPlayer in range(0, gc.getMAX_CIV_PLAYERS()): if (iLoopPlayer != iLeader and gc.getPlayer(iLoopPlayer).getTeam() == pTeam.getID()): sLoopAdj = gc.getPlayer( iLoopPlayer).getCivilizationAdjective(0) if (not sLoopAdj in sNewName): # prevent Luchuirp-Luchuirp Alliance sNewName += "-" + sLoopAdj sNewName += " " + localText.getText("TXT_KEY_MOD_DCN_ALLIANCE", ()) return [sNewName, sSrt, sAdj] ######################################################################### # From Civics # ######################################################################### if (self.LOG_DEBUG): CvUtil.pyPrint("Names - Start computing name") # parameters sLeaderName = pPlayer.getName() iNumCities = pPlayer.getNumCities() # Eras dont work this same way in FFH2 # bAncient = ( playerEra == 1 ) iMxc = 0 # (e.g. "ADJ EMP of CAPITAL" when NumCities <= iMxc) if (iNumCities == 1): sEmp = "Lands" sAltEmp = "Stronghold" else: sEmp = "Empire" sAltEmp = "Territories" sPre = "" # Prefix sAltPre = "" bBof = False # Block "of" (e.g. never "PRE EMP of SRT", but "PRE ADJ EMP") bFof = False # Force "of" (e.g. never "PRE ADJ EMP", but "PRE EMP of SRT") bGood = pPlayer.getAlignment() == self.iGood bEvil = pPlayer.getAlignment() == self.iEvil # Traits bCharismatic = pPlayer.hasTrait( gc.getInfoTypeForString('TRAIT_CHARISMATIC')) bInsane = pPlayer.hasTrait(gc.getInfoTypeForString('TRAIT_INSANE')) #Civics bDespotism = pPlayer.isCivic(self.iDespotism) bCityStates = pPlayer.isCivic(self.iCityStates) bGodKing = pPlayer.isCivic(self.iGodKing) bAristocracy = pPlayer.isCivic(self.iAristocracy) bTheocracy = pPlayer.isCivic(self.iTheocracy) bRepublic = pPlayer.isCivic(self.iRepublic) bReligion = pPlayer.isCivic(self.iReligion) bPacifism = pPlayer.isCivic(self.iPacifism) bLiberty = pPlayer.isCivic(self.iLiberty) bTribalism = pPlayer.isCivic(self.iTribalism) bMilitaryState = pPlayer.isCivic(self.iMilitaryState) bConquest = pPlayer.isCivic(self.iConquest) bCrusade = pPlayer.isCivic(self.iCrusade) bGuilds = pPlayer.isCivic(self.iGuilds) bSlavery = pPlayer.isCivic(self.iSlavery) bArete = pPlayer.isCivic(self.iArete) bGuardian = pPlayer.isCivic(self.iGuardian) bForeignTrade = pPlayer.isCivic(self.iForeignTrade) bSacrifice = pPlayer.isCivic(self.iSacrifice) bDecentralization = pPlayer.isCivic(self.iDecentralization) # Misc bPuppet = pPlayer.isPuppetState() bHolyShrine = false if pPlayer.getStateReligion() >= 0: if pPlayer.hasHolyCity(pPlayer.getStateReligion()): bHolyShrine = true bVeil = pPlayer.getStateReligion() == self.iVeil bEmpyrean = pPlayer.getStateReligion() == self.iEmpyrean bOrder = pPlayer.getStateReligion() == self.iOrder bKilmorph = pPlayer.getStateReligion() == self.iKilmorph bCalabim = iCiv == self.iCalabim bClan = iCiv == self.iClan if (bClan): sSrt = "Embers" sAdj = "Orcish" bNoShuffle = False sPost = "" if (iNumCities == 0): sEmp = "Tribe" sAltEmp = "Peoples" #Note: Never used due to next line return ["%s %s" % (sAdj, sEmp), sSrt, sAdj] if bCharismatic: sPre = "Beloved" elif bInsane: sPre = "Deranged" if (bDespotism): iMxc = 2 if (bClan): sEmp = "Clan" sAltEmp = "Clan" # elif( bAncient ) : # sEmp = "Chiefdom" # sAltEmp = "Empire" else: sAltEmp = "Chiefdom" if (bGood): sEmp = "Autocracy" elif (bEvil): sEmp = "Tyranny" # else: Default elif (bCityStates): if bMilitaryState: sEmp = "Hegemony" sAltEmp = "Hegemony" iMxc = 1 if (iNumCities == 1): sEmp = "City" sAltEmp = "City State" else: sEmp = "Federation" sAltEmp = "League" sPost = "City States" if bSlavery: sPost = "Slavers" if bForeignTrade: sPre = "" sEmp = "Confederation" elif bDecentralization: if iNumCities == 1: sEmp = "Independent State" else: sEmp = "Independent Alliance" elif (bGodKing): iMxc = 4 if bReligion: sEmp = "Cult" sAltEmp = "Followers" bFof = True elif bPacifism: sPre = "Benevolent" else: sEmp = "Monarchy" sAltEmp = "Sovereignty" if (bClan): sEmp = "Clan" sAltEmp = "Clan" elif (bAristocracy): iMxc = 3 if (bCalabim): sEmp = "Principalities" sAltEmp = "Kingdom" if bGuilds: sEmp = "Imperium" elif bSlavery: sEmp = "Dynasty" bFof = True elif bMilitaryState: sEmp = "Monarchy" else: sEmp = "Kingdom" sAltEmp = "Realm" if bConquest: sPre = "Imperial" sAltPre = "Majestic" elif bArete: sEmp = "Plutocracy" else: sPre = "Royal" sAltPre = "Noble" elif (bTheocracy): iMxc = 2 sPre = "Divine" sAltPre = "Chosen" # sEmp = "Divinity" elif (bRepublic): iMxc = 1 sAltPre = "Democratic" if (bEvil): sEmp = "Ochlocracy" sAltEmp = "Republic" else: sEmp = "Republic" if (bReligion): if sPre == "": sPre = "Sacred" sAltPre = "Holy" if (bGodKing and iNumCities <= iMxc): sPre = "Sacred" sEmp = "See" elif (bTheocracy): sEmp = "Caliphate" sAltPre = "Theocratic" if (bVeil): if bHolyShrine: return ["Chosen of Agares", sSrt, sAdj] sPre = "The Ashen" elif (bEmpyrean): sPre = "Illuminated" elif (bOrder): sPre = "Righteous" elif (bPacifism): if (bCityStates and iNumCities > iMxc): sEmp = "Commune" bFof = True elif (bLiberty): sPre = "Free" sAltPre = "Liberated" if (bAristocracy): bNoShuffle = True sEmp = "Imperial Estates" bFof = True elif (bTribalism and bDespotism): sPre = "Tribal" # even if era not ancient sAltEmp = "Chiefdom" if bCrusade: sPre = "Righteous" sAltPre = "Righteous" elif bGuilds: sPre = "Technocratic" if bMilitaryState: if bConquest: if bAristocracy: bEmp = "Dynasty" else: sEmp = "Junta" bFof = true elif bRepublic: sEmp = "Regime" if bPuppet: iMxc = 5 # TODO: puppet states have no capital sPre = "" sAltPre = "" sEmp = "Satrapy" sAltEmp = "Satrapy" if bMilitaryState: sEmp = "Prefecture" sAltEmp = "Prefecture" if bAristocracy: sEmp = "Province" sAltEmp = "Province" if bReligion or bTheocracy: sEmp = "Diocese" sAltEmp = "Diocese" return ["%s %s" % (sAdj, sEmp), sSrt, sAdj] if pCapital != -1: pCapitalPlot = pCapital.plot() pCapitalLatitude = pCapitalPlot.getLatitude() if pCapitalLatitude > 50: map = CyMap() iMapHeight = map.getGridHeight() if pCapitalPlot.getY() < (iMapHeight / 2): sPre = "Southern" else: sPre = "Northern" if (bArete and bHolyShrine): sPre = "Golden" sAltPre = "Golden" elif bGuardian: sEmp = "Fellowship" sAltEmp = "Fellowship" elif bSacrifice: sPre = "Demonic" sAltPre = "Demonic" if (sPost != ""): return ["%s %s of %s %s" % (sPre, sEmp, sAdj, sPost), sSrt, sAdj] if (sPre != ""): sPre += " " if (sAltPre != ""): sAltPre += " " sTheSrt = sSrt if (not bClan): sTheSrt = "the " + sTheSrt # if( not bNoShuffle ) : # if( game.getSorenRandNum( 100, "DCN Shuffle" ) >= 50 ) : # sTmp = sPre # sPre = sAltPre # sAltPre = sTmp # if( game.getSorenRandNum( 100, "DCN Shuffle" ) >= 50 ) : # sTmp = sEmp # sEmp = sAltEmp # sAltEmp = sEmp lsDescs = list() if (not bBof and iNumCities <= iMxc and sEmp != "Clan" and sCpt != None): # Sacred Empire of Golden Lane sNewDesc = "%s%s of %s" % (sPre, sEmp, sCpt) lsDescs.append(sNewDesc) if (not bFof and sEmp != "Clan"): sNewDesc = "%s%s %s" % (sPre, sAdj, sEmp) # Sacred Malakim Empire lsDescs.append(sNewDesc) if (not bBof): sNewDesc = "%s%s of %s" % (sPre, sEmp, sTheSrt ) # Sacred Empire of the Malakim lsDescs.append(sNewDesc) if (bGodKing): sNewDesc = "%s%s of %s" % (sPre, sEmp, sLeaderName ) # Holy Cult of Tholal lsDescs.append(sNewDesc) # try alternate prefix if (not bBof and iNumCities <= iMxc and sEmp != "Clan" and sCpt != None): # Holy Empire of Golden Lane sNewDesc = "%s%s of %s" % (sAltPre, sEmp, sCpt) lsDescs.append(sNewDesc) if (not bFof and sEmp != "Clan"): sNewDesc = "%s%s %s" % (sAltPre, sAdj, sEmp) # Holy Malakim Empire lsDescs.append(sNewDesc) if (not bBof): sNewDesc = "%s%s of %s" % (sAltPre, sEmp, sTheSrt ) # Holy Empire of the Malakim lsDescs.append(sNewDesc) if (bGodKing): sNewDesc = "%s%s of %s" % (sAltPre, sEmp, sLeaderName ) # Sovereignty of Tholal lsDescs.append(sNewDesc) # try alternate empire if (not bBof and iNumCities <= iMxc and sAltEmp != "Clan" and sCpt != None): # Sacred Realm of Golden Lane sNewDesc = "%s%s of %s" % (sPre, sAltEmp, sCpt) lsDescs.append(sNewDesc) if (not bFof and sAltEmp != "Clan"): sNewDesc = "%s%s %s" % (sPre, sAdj, sAltEmp ) # Sacred Malakim Realm lsDescs.append(sNewDesc) if (not bBof): sNewDesc = "%s%s of %s" % (sPre, sAltEmp, sTheSrt ) # Sacred Realm of the Malakim lsDescs.append(sNewDesc) if (bGodKing): sNewDesc = "%s%s of %s" % (sPre, sAltEmp, sLeaderName ) # Sovereignty of Tholal lsDescs.append(sNewDesc) # try alternate prefix and empire if (not bBof and iNumCities <= iMxc and sAltEmp != "Clan" and sCpt != None): # Holy Realm of Golden Lane sNewDesc = "%s%s of %s" % (sAltPre, sAltEmp, sCpt) lsDescs.append(sNewDesc) if (not bFof and sAltEmp != "Clan"): sNewDesc = "%s%s %s" % (sAltPre, sAdj, sAltEmp ) # Holy Malakim Realm lsDescs.append(sNewDesc) if (not bBof): sNewDesc = "%s%s of %s" % (sAltPre, sAltEmp, sTheSrt ) # Holy Realm of the Malakim lsDescs.append(sNewDesc) if (bGodKing): sNewDesc = "%s%s of %s" % (sAltPre, sAltEmp, sLeaderName ) # Sovereignty of Tholal lsDescs.append(sNewDesc) if (self.LOG_DEBUG): CvUtil.pyPrint( " Names - WARNING: No unused Names for Player #%d!" % (iPlayer)) if (sDsc in lsDescs): print "MODIFIED DCN - Keeping name \"%s\"" % (sDsc) return [sDsc, sSrt, sAdj] random.shuffle( lsDescs ) # shuffle the name options so we dont end up all using the same style for sNewDesc in lsDescs: if (self.isUnused(iPlayer, sNewDesc)): print "MODIFIED DCN - Old name: \"%s\", New name: \"%s\"" % ( sDsc, sNewDesc) return [sNewDesc, sSrt, sAdj] else: print "MODIFIED DCN - Name \"%s\" already used!" % (sDsc) return ["%s%s %s" % (sPre, sAdj, sEmp), sSrt, sAdj] # keep current name
def onTechAcquired(argsList): 'Tech Acquired' iTechType, iTeam, iPlayer, bAnnounce = argsList # Note that iPlayer may be NULL (-1) and not a refer to a player object if ((iTeam >= 0) and (iTeam <= gc.getMAX_CIV_TEAMS())): teamI = gc.getTeam(iTeam) if (teamI.isAlive()): if (teamI.isMinorCiv() and gc.getTechInfo(iTechType).isOpenBordersTrading()): if (SDTK.sdObjectExists('BarbarianCiv', game)): for idx in range(0, gc.getMAX_CIV_PLAYERS()): playerI = gc.getPlayer(idx) if (playerI.isAlive() and (playerI.getTeam() == iTeam)): if (idx in SDTK.sdObjectGetVal( "BarbarianCiv", game, "AlwaysMinorList")): # Keep scenario minors defined in RevDefs as always minor return # if( gc.getGame().isOption(GameOptionTypes.GAMEOPTION_START_AS_MINORS) ) : if (2 < 1): for idx in range(0, gc.getMAX_CIV_PLAYERS()): playerI = gc.getPlayer(idx) if (playerI.getTeam() == iTeam and playerI.isAlive()): if (SDTK.sdObjectExists('BarbarianCiv', playerI)): if (SDTK.sdObjectGetVal( 'BarbarianCiv', playerI, 'SettleTurn') == None): # Use BarbarianCiv logic return if (LOG_DEBUG): CvUtil.pyPrint( "SAM - Settled barb civ %s now has Writing" % (playerI.getCivilizationDescription(0)) ) if (LOG_DEBUG): CvUtil.pyPrint( "SAM - clearing minor status for team %d with Writing" % (iTeam)) teamI.setIsMinorCiv(False, False) for idx in range(0, gc.getMAX_CIV_PLAYERS()): playerI = gc.getPlayer(idx) if (gc.getPlayer(idx).getTeam() == iTeam and playerI.isAlive()): if (not RevInstances.DynamicCivNamesInst == None): RevInstances.DynamicCivNamesInst.setNewNameByCivics( iPlayer) CyInterface().addMessage( iPlayer, false, gc.getDefineINT("EVENT_MESSAGE_TIME"), localText.getText( "TXT_KEY_BARBCIV_DISCOVER_WRITING", ()), None, InterfaceMessageTypes.MESSAGE_TYPE_MAJOR_EVENT, None, gc.getInfoTypeForString( "COLOR_HIGHLIGHT_TEXT"), -1, -1, False, False) gc.getMap().verifyUnitValidPlot()
def revObjectUpdateVal( object, var, val ): return SdToolKitCustom.sdObjectUpdateVal( 'Revolution', object, var, val )
def revObjectExists(object): return SdToolKitCustom.sdObjectExists('Revolution', object)
def revObjectChangeVal( object, var, delta ): return SdToolKitCustom.sdObjectChangeVal( 'Revolution', object, var, delta )
def revObjectInit (object, VarDictionary = {}): return SdToolKitCustom.sdObjectInit( 'Revolution', object, VarDictionary )
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_CIV_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' ) if( self.LOG_DEBUG ) : CvUtil.pyPrint("Names - player is rebel") 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( self.LOG_DEBUG ) : CvUtil.pyPrint("Names - player is barbciv") 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 if( self.LOG_DEBUG ) : CvUtil.pyPrint("Names - Giving game start name") newName = localText.getText("TXT_KEY_MOD_DCN_TRIBE", ())%(curAdj) return [newName, curShort, curAdj] if( self.LOG_DEBUG ) : CvUtil.pyPrint("Names - player not of special type, naming by civics") return self.newNameByCivics( iPlayer ) return [newName, curShort, curAdj]