def onGreatPersonBorn(self, argsList): 'Great Person Born' pUnit, iPlayer, pCity = argsList player = gc.getPlayer(iPlayer) #if (not g_bGreatPersonModFeaturesEnabled): # return # Check if we should even show the popup: if (pUnit.isNone() or pCity.isNone()): return #If Person doesn't have unique name, give him a random one if (len(pUnit.getNameNoDesc()) == 0): iCivilizationType = player.getCivilizationType() pUnit.setName(RandomNameUtils.getRandomCivilizationName(iCivilizationType)) #Show fancy lil popup if a human got the great person: if (iPlayer == gc.getGame().getActivePlayer() and player.isHuman()): popupInfo = CyPopupInfo() popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN) popupInfo.setData1(iPlayer) popupInfo.setData2(pUnit.getID()) popupInfo.setData3(pCity.getID()) popupInfo.setText(u"showGreatPersonScreen") popupInfo.addPopup(iPlayer)
def getUnitName(self, sUnitNameConv, pUnit, pCity, bIncrementCounter): iPlayer = pUnit.getOwner() pPlayer = gc.getPlayer(iPlayer) zsCiv = pPlayer.getCivilizationAdjective(0) zsLeader = pPlayer.getName() zsUnitCombat = self.getUnitCombat(pUnit) zsUnitDomain = BugUtil.getPlainText("TXT_KEY_BUG_UNIT_NAMING_" + gc.getDomainInfo(pUnit.getDomainType()).getType()) zsUnit = gc.getUnitInfo(pUnit.getUnitType()).getDescription() zsCity = pCity.getName() #BUGPrint("Civ(%s)" % (zsCiv)) #BUGPrint("Leader(%s)" % (zsLeader)) #BUGPrint("Combat(%s)" % (zsUnitCombat)) #BUGPrint("Domain(%s)" % (zsUnitDomain)) #BUGPrint("Unit(%s)" % (zsUnit)) #BUGPrint("City(%s)" % (zsCity)) zsName = sUnitNameConv #if zsName == "": #zsName = "^ut^ ^cnt[r]^ Div ^tt1[s][5:7]^ : ^ct^ ^tt2[o][101]^" #BUGPrint("UnitNameEM-A [" + zsName + "]") ## - ^civ4^ - no naming convention, uses standard civ4 # check if Civ4 naming convention is required if not (zsName.find("^civ4^") == -1): return "" ## - ^rd^ - random name # check if random naming convention is required if not (zsName.find("^rd^") == -1): zsRandomName = RandomNameUtils.getRandomName() zsName = zsName.replace("^rd^", zsRandomName) #BUGPrint("UnitNameEM-B") ## - ^rc^ - random civ related name # check if random civ related naming convention is required if not (zsName.find("^rc^") == -1): zsRandomName = RandomNameUtils.getRandomCivilizationName(pPlayer.getCivilizationType()) zsName = zsName.replace("^rc^", zsRandomName) #BUGPrint("UnitNameEM-C [" + zsName + "]") ## - ^ct^ - City ## - ^cv^ - Civilization ## - ^ut^ - unit (eg Archer) ## - ^cb^ - combat type (Melee) ## - ^dm^ - domain (Water) ## - ^ld^ - leader # replace the fixed items in the naming conv zsName = zsName.replace("^ct^", zsCity) zsName = zsName.replace("^cv^", zsCiv) zsName = zsName.replace("^ut^", zsUnit) zsName = zsName.replace("^cb^", zsUnitCombat) zsName = zsName.replace("^dm^", zsUnitDomain) zsName = zsName.replace("^ld^", zsLeader) #BUGPrint("UnitNameEM-D [" + zsName + "]") # check if there are any more codes to swap out, return if not counters = BugData.getGameData().getTable(SD_MOD_ID) while zsName.find("^cnt") != -1: # determine what I am counting across zsSDKey = self.getCounter(zsName) if zsSDKey == "UNIT": zsSDKey = zsSDKey + zsUnit elif zsSDKey == "COMBAT": zsSDKey = zsSDKey + zsUnitCombat elif zsSDKey == "CITY": zsSDKey = zsSDKey + zsCity elif zsSDKey == "UNITCITY": zsSDKey = zsSDKey + zsUnit + zsCity elif zsSDKey == "DOMAIN": zsSDKey = zsSDKey + zsUnitDomain #BUGPrint("UnitNameEM-E [" + zsSDKey + "]") # see if we have already started this counter if (not counters.hasTable(zsSDKey)): #Since no record create entries ziCnt = 0 ziTT1 = self.getTotal1(zsName) ziTT2 = self.getTotal2(zsName) counter = counters.getTable(zsSDKey) else: # get the count values counter = counters.getTable(zsSDKey) ziCnt = counter["cnt"] ziTT1 = counter["tt1"] ziTT2 = counter["tt2"] #BUGPrint("UnitNameEM-F [" + str(ziCnt) + "] [" + str(ziTT1) + "] [" + str(ziTT2) + "]") # increment count, adjust totals if required if bIncrementCounter: ziCnt = ziCnt + 1 if (ziCnt > ziTT1 and ziTT1 > 0): ziCnt = 1 ziTT1 = self.getTotal1(zsName) ziTT2 = ziTT2 + 1 # store the new values counter["cnt"] = ziCnt counter["tt1"] = ziTT1 counter["tt2"] = ziTT2 # swap out the count code items for count value zsName = self.swapCountCode(zsName, "^cnt", ziCnt) zsName = self.swapCountCode(zsName, "^tt1", ziTT1) zsName = self.swapCountCode(zsName, "^tt2", ziTT2) return zsName
def getUnitName(self, sUnitNameConv, pUnit, pCity, bIncrementCounter): iPlayer = pUnit.getOwner() pPlayer = gc.getPlayer(iPlayer) zsEra = gc.getEraInfo(pPlayer.getCurrentEra()).getType() zsCiv = gc.getPlayer(iPlayer).getCivilizationShortDescription(0) zsLeader = gc.getPlayer(iPlayer).getName() zsUnitCombat = self.getUnitCombat(pUnit) zsUnitClass = gc.getUnitClassInfo(pUnit.getUnitClassType()).getType() zsUnitType = gc.getUnitInfo(pUnit.getUnitType()).getType() zsUnitDomain = gc.getDomainInfo(pUnit.getDomainType()).getType() zsUnit = PyInfo.UnitInfo(pUnit.getUnitType()).getDescription() zsCity = pCity.getName() # BUGPrint("ERA(%s)" % (zsEra)) # BUGPrint("Civ(%s)" % (zsCiv)) # BUGPrint("Leader(%s)" % (zsLeader)) # BUGPrint("Combat(%s)" % (zsUnitCombat)) # BUGPrint("Class(%s)" % (zsUnitClass)) # BUGPrint("Type(%s)" % (zsUnitType)) # BUGPrint("Domain(%s)" % (zsUnitDomain)) # BUGPrint("Unit(%s)" % (zsUnit)) # BUGPrint("City(%s)" % (zsCity)) zsName = sUnitNameConv #if zsName == "": #zsName = "^ut^ ^cnt[r]^ Div ^tt1[s][5:7]^ : ^ct^ ^tt2[o][101]^" # BUGPrint("UnitNameEM-A [" + zsName + "]") ## - ^civ4^ - no naming convention, uses standard civ4 # check if Civ4 naming convention is required if not (zsName.find("^civ4^") == -1): return "" ## - ^rd^ - random name # check if random naming convention is required if not (zsName.find("^rd^") == -1): return RandomNameUtils.getRandomName() # BUGPrint("UnitNameEM-B") ## - ^rc^ - random civ related name # check if random civ related naming convention is required if not (zsName.find("^rc^") == -1): return RandomNameUtils.getRandomCivilizationName(pPlayer.getCivilizationType()) # BUGPrint("UnitNameEM-C [" + zsName + "]") ## - ^ct^ - City ## - ^cv^ - Civilization ## - ^ut^ - unit (eg Archer) ## - ^cb^ - combat type (Melee) ## - ^dm^ - domain (Water) ## - ^ld^ - leader # replace the fixed items in the naming conv zsName = zsName.replace("^ct^", zsCity) zsName = zsName.replace("^cv^", zsCiv) zsName = zsName.replace("^ut^", zsUnit) zsName = zsName.replace("^cb^", zsUnitCombat) zsName = zsName.replace("^dm^", zsUnitDomain) zsName = zsName.replace("^ld^", zsLeader) # BUGPrint("UnitNameEM-D [" + zsName + "]") # check if there are any more codes to swap out, return if not if (zsName.find("^") == -1): return zsName # determine what I am counting across zsSDKey = self.getCounter(zsName) if zsSDKey == "UNIT": zsSDKey = zsSDKey + zsUnit elif zsSDKey == "COMBAT": zsSDKey = zsSDKey + zsUnitCombat elif zsSDKey == "CITY": zsSDKey = zsSDKey + zsCity elif zsSDKey == "UNITCITY": zsSDKey = zsSDKey + zsUnit + zsCity elif zsSDKey == "DOMAIN": zsSDKey = zsSDKey + zsUnitDomain # BUGPrint("UnitNameEM-E [" + zsSDKey + "]") # see if we have already started this counter if (sdEntityExists(sdGroup, zsSDKey) == False): #Since no record create entries ziTT1 = self.getTotal1(zsName) ziTT2 = self.getTotal2(zsName) zDic = {'cnt':0, 'tt1':ziTT1, 'tt2':ziTT2} sdEntityInit(sdGroup, zsSDKey, zDic) # get the count values ziCnt = sdGetVal(sdGroup, zsSDKey, "cnt") ziTT1 = sdGetVal(sdGroup, zsSDKey, "tt1") ziTT2 = sdGetVal(sdGroup, zsSDKey, "tt2") # BUGPrint("UnitNameEM-F [" + str(ziCnt) + "] [" + str(ziTT1) + "] [" + str(ziTT2) + "]") # increment count, adjust totals if required if bIncrementCounter: ziCnt = ziCnt + 1 if (ziCnt > ziTT1 and ziTT1 > 0): ziCnt = 1 ziTT1 = self.getTotal1(zsName) ziTT2 = ziTT2 + 1 # store the new values sdSetVal(sdGroup, zsSDKey, "cnt", ziCnt) sdSetVal(sdGroup, zsSDKey, "tt1", ziTT1) sdSetVal(sdGroup, zsSDKey, "tt2", ziTT2) # swap out the count code items for count value zsName = self.swapCountCode(zsName, "^cnt", ziCnt) zsName = self.swapCountCode(zsName, "^tt1", ziTT1) zsName = self.swapCountCode(zsName, "^tt2", ziTT2) return zsName
def getUnitName(self, sUnitNameConv, pUnit, pCity, bIncrementCounter): iPlayer = pUnit.getOwner() pPlayer = gc.getPlayer(iPlayer) zsCiv = pPlayer.getCivilizationAdjective(0) zsLeader = pPlayer.getName() zsUnitCombat = self.getUnitCombat(pUnit) zsUnitDomain = BugUtil.getPlainText("TXT_KEY_BUG_UNIT_NAMING_" + gc.getDomainInfo(pUnit.getDomainType()).getType()) zsUnit = PyInfo.UnitInfo(pUnit.getUnitType()).getDescription() zsCity = pCity.getName() #BUGPrint("Civ(%s)" % (zsCiv)) #BUGPrint("Leader(%s)" % (zsLeader)) #BUGPrint("Combat(%s)" % (zsUnitCombat)) #BUGPrint("Domain(%s)" % (zsUnitDomain)) #BUGPrint("Unit(%s)" % (zsUnit)) #BUGPrint("City(%s)" % (zsCity)) zsName = sUnitNameConv #if zsName == "": #zsName = "^ut^ ^cnt[r]^ Div ^tt1[s][5:7]^ : ^ct^ ^tt2[o][101]^" #BUGPrint("UnitNameEM-A [" + zsName + "]") ## - ^civ4^ - no naming convention, uses standard civ4 # check if Civ4 naming convention is required if not (zsName.find("^civ4^") == -1): return "" ## - ^rd^ - random name # check if random naming convention is required if not (zsName.find("^rd^") == -1): zsRandomName = RandomNameUtils.getRandomName() zsName = zsName.replace("^rd^", zsRandomName) #BUGPrint("UnitNameEM-B") ## - ^rc^ - random civ related name # check if random civ related naming convention is required if not (zsName.find("^rc^") == -1): zsRandomName = RandomNameUtils.getRandomCivilizationName(pPlayer.getCivilizationType()) zsName = zsName.replace("^rc^", zsRandomName) #BUGPrint("UnitNameEM-C [" + zsName + "]") ## - ^ct^ - City ## - ^cv^ - Civilization ## - ^ut^ - unit (eg Archer) ## - ^cb^ - combat type (Melee) ## - ^dm^ - domain (Water) ## - ^ld^ - leader # replace the fixed items in the naming conv zsName = zsName.replace("^ct^", zsCity) zsName = zsName.replace("^cv^", zsCiv) zsName = zsName.replace("^ut^", zsUnit) zsName = zsName.replace("^cb^", zsUnitCombat) zsName = zsName.replace("^dm^", zsUnitDomain) zsName = zsName.replace("^ld^", zsLeader) #BUGPrint("UnitNameEM-D [" + zsName + "]") # check if there are any more codes to swap out, return if not counters = BugData.getGameData().getTable(SD_MOD_ID) while zsName.find("^cnt") != -1: # determine what I am counting across zsSDKey = self.getCounter(zsName) if zsSDKey == "UNIT": zsSDKey = zsSDKey + zsUnit elif zsSDKey == "COMBAT": zsSDKey = zsSDKey + zsUnitCombat elif zsSDKey == "CITY": zsSDKey = zsSDKey + zsCity elif zsSDKey == "UNITCITY": zsSDKey = zsSDKey + zsUnit + zsCity elif zsSDKey == "DOMAIN": zsSDKey = zsSDKey + zsUnitDomain #BUGPrint("UnitNameEM-E [" + zsSDKey + "]") # see if we have already started this counter if (not counters.hasTable(zsSDKey)): #Since no record create entries ziCnt = 0 ziTT1 = self.getTotal1(zsName) ziTT2 = self.getTotal2(zsName) counter = counters.getTable(zsSDKey) else: # get the count values counter = counters.getTable(zsSDKey) ziCnt = counter["cnt"] ziTT1 = counter["tt1"] ziTT2 = counter["tt2"] #BUGPrint("UnitNameEM-F [" + str(ziCnt) + "] [" + str(ziTT1) + "] [" + str(ziTT2) + "]") # increment count, adjust totals if required if bIncrementCounter: ziCnt = ziCnt + 1 if (ziCnt > ziTT1 and ziTT1 > 0): ziCnt = 1 ziTT1 = self.getTotal1(zsName) ziTT2 = ziTT2 + 1 # store the new values counter["cnt"] = ziCnt counter["tt1"] = ziTT1 counter["tt2"] = ziTT2 # swap out the count code items for count value zsName = self.swapCountCode(zsName, "^cnt", ziCnt) zsName = self.swapCountCode(zsName, "^tt1", ziTT1) zsName = self.swapCountCode(zsName, "^tt2", ziTT2) return zsName