예제 #1
0
	def setNewNameByCivics( self, iPlayer ) :
		[newCivDesc, newCivShort, newCivAdj] = self.newNameByCivics( iPlayer )

		if( gc.getPlayer(iPlayer).isHuman() or game.getActivePlayer() == iPlayer ) :
			if( self.bLeaveHumanName ) :
				CvUtil.pyPrint("  Name - Leaving name for human player")
				return
			else :
				#CvUtil.pyPrint("  Name - Changing name for human player!")
				pass

		newDesc  = CvUtil.convertToStr(newCivDesc)
		newShort = CvUtil.convertToStr(newCivShort)
		newAdj   = CvUtil.convertToStr(newCivAdj)

		newDesc = remove_diacriticals(newDesc)
		newShort = remove_diacriticals(newShort)
		newAdj = remove_diacriticals(newAdj)
		
		if( not newDesc == gc.getPlayer(iPlayer).getCivilizationDescription(0) ) :
			szMessage = BugUtil.getText("TXT_KEY_MOD_DCN_NEWCIV_NAME_DESC", newDesc)
			CyInterface().addMessage(iPlayer, false, gc.getDefineINT("EVENT_MESSAGE_TIME"), szMessage, None, InterfaceMessageTypes.MESSAGE_TYPE_INFO, None, gc.getInfoTypeForString("COLOR_HIGHLIGHT_TEXT"), -1, -1, False, False)
			if( self.LOG_DEBUG ) :
				CvUtil.pyPrint("  Name - Setting civ name due to civics to %s"%(newDesc))
		
		gc.getPlayer(iPlayer).setCivName( newDesc, newShort, newAdj )
		
		return
예제 #2
0
    def setNewNameByCivics(self, iPlayer):
        [newCivDesc, newCivShort, newCivAdj] = self.newNameByCivics(iPlayer)

        if gc.getPlayer(
                iPlayer).isHuman() or game.getActivePlayer() == iPlayer:
            if self.bLeaveHumanName:
                CvUtil.pyPrint("  Name - Leaving name for human player")
                return

        newDesc = CvUtil.convertToStr(newCivDesc)
        newShort = CvUtil.convertToStr(newCivShort)
        newAdj = CvUtil.convertToStr(newCivAdj)

        newDesc = CvUtil.remove_diacriticals(newDesc)
        newShort = CvUtil.remove_diacriticals(newShort)
        newAdj = CvUtil.remove_diacriticals(newAdj)

        if not newDesc == gc.getPlayer(iPlayer).getCivilizationDescription(0):
            szMessage = BugUtil.getText("TXT_KEY_MOD_DCN_NEWCIV_NAME_DESC",
                                        newDesc)
            CyInterface().addMessage(
                iPlayer, False, gc.getEVENT_MESSAGE_TIME(), szMessage, None,
                InterfaceMessageTypes.MESSAGE_TYPE_INFO, None,
                gc.getInfoTypeForString("COLOR_HIGHLIGHT_TEXT"), -1, -1, False,
                False)

        gc.getPlayer(iPlayer).setCivName(newDesc, newShort, newAdj)

        return
예제 #3
0
	def onSetPlayerAlive( self, argsList ) :

		iPlayerID = argsList[0]
		bNewValue = argsList[1]
		if( bNewValue == True and iPlayerID < gc.getMAX_CIV_PLAYERS() ) :
			pPlayer = gc.getPlayer( iPlayerID )

			if( pPlayer.isHuman() or game.getActivePlayer() == iPlayerID ) :
				if( self.bLeaveHumanName ) :
					CvUtil.pyPrint("  Name - Leaving name for human player")
					return
			 
			[newCivDesc, newCivShort, newCivAdj] = self.nameForNewPlayer( iPlayerID )
			
			newDesc  = CvUtil.convertToStr(newCivDesc)
			newShort = CvUtil.convertToStr(newCivShort)
			newAdj   = CvUtil.convertToStr(newCivAdj)

			newDesc = remove_diacriticals(newDesc)
			newShort = remove_diacriticals(newShort)
			newAdj = remove_diacriticals(newAdj)

			if( self.LOG_DEBUG ) :
				CvUtil.pyPrint("  Name - Setting civ name for new civ to %s"%(newDesc))
					
			# Pass to pPlayer seems to require a conversion to 'ascii'
			pPlayer.setCivName( newDesc, newShort, newAdj )
예제 #4
0
    def resetName(self, iPlayer, bVerbose=True):

        pPlayer = gc.getPlayer(iPlayer)

        civInfo = gc.getCivilizationInfo(pPlayer.getCivilizationType())
        origDesc = civInfo.getDescription()
        origShort = civInfo.getShortDescription(0)
        origAdj = civInfo.getAdjective(0)

        if (not game.isOption(GameOptionTypes.GAMEOPTION_LEAD_ANY_CIV)):
            if (not self.bLeaveHumanName
                    or not (pPlayer.isHuman()
                            or game.getActivePlayer() == iPlayer)):
                if (pPlayer.getLeaderType()
                        in LeaderCivNames.LeaderCivNames.keys()):
                    [origDesc, origShort, origAdj
                     ] = LeaderCivNames.LeaderCivNames[pPlayer.getLeaderType()]

        newDesc = CvUtil.convertToStr(origDesc)
        newShort = CvUtil.convertToStr(origShort)
        newAdj = CvUtil.convertToStr(origAdj)

        if (self.LOG_DEBUG):
            CvUtil.pyPrint("  Name - Re-setting civ name for player %d to %s" %
                           (iPlayer, newDesc))

        gc.getPlayer(iPlayer).setCivName(newDesc, newShort, newAdj)
예제 #5
0
    def setNewNameByCivics(self, iPlayer):
        [newCivDesc, newCivShort, newCivAdj] = self.newNameByCivics(iPlayer)

        if (gc.getPlayer(iPlayer).isHuman()
                or game.getActivePlayer() == iPlayer):
            if (self.bLeaveHumanName):
                CvUtil.pyPrint("  Name - Leaving name for human player")
                return
            else:
                #CvUtil.pyPrint("  Name - Changing name for human player!")
                pass

        newDesc = CvUtil.convertToStr(newCivDesc)
        newShort = CvUtil.convertToStr(newCivShort)
        newAdj = CvUtil.convertToStr(newCivAdj)

        if (not newDesc
                == gc.getPlayer(iPlayer).getCivilizationDescription(0)):
            CyInterface().addMessage(
                iPlayer, false, gc.getDefineINT("EVENT_MESSAGE_TIME"),
                "Your civilization is now known as the %s" % (newDesc), None,
                InterfaceMessageTypes.MESSAGE_TYPE_INFO, None,
                gc.getInfoTypeForString("COLOR_HIGHLIGHT_TEXT"), -1, -1, False,
                False)
            if (self.LOG_DEBUG):
                CvUtil.pyPrint(
                    "  Name - Setting civ name due to civics to %s" %
                    (newCivDesc))

        gc.getPlayer(iPlayer).setCivName(newDesc, newShort, newAdj)

        return
예제 #6
0
    def resetName(self, iPlayer, bVerbose=True):
        pPlayer = gc.getPlayer(iPlayer)
        civInfo = gc.getCivilizationInfo(pPlayer.getCivilizationType())

        origDesc = civInfo.getDescription()
        origShort = civInfo.getShortDescription(0)
        origAdj = civInfo.getAdjective(0)

        if not game.isOption(GameOptionTypes.GAMEOPTION_LEAD_ANY_CIV):
            if not self.bLeaveHumanName or not (
                    pPlayer.isHuman() or game.getActivePlayer() == iPlayer):
                if pPlayer.getLeaderType(
                ) in LeaderCivNames.LeaderCivNames.keys():
                    [origDesc, origShort, origAdj
                     ] = LeaderCivNames.LeaderCivNames[pPlayer.getLeaderType()]

        newDesc = CvUtil.convertToStr(origDesc)
        newShort = CvUtil.convertToStr(origShort)
        newAdj = CvUtil.convertToStr(origAdj)

        newDesc = CvUtil.remove_diacriticals(newDesc)
        newShort = CvUtil.remove_diacriticals(newShort)
        newAdj = CvUtil.remove_diacriticals(newAdj)

        gc.getPlayer(iPlayer).setCivName(newDesc, newShort, newAdj)
예제 #7
0
	def resetName( self, iPlayer, bVerbose = True ) :
		
		pPlayer = gc.getPlayer(iPlayer)
		
		civInfo = gc.getCivilizationInfo(pPlayer.getCivilizationType())
		origDesc  = civInfo.getDescription()
		origShort = civInfo.getShortDescription(0)
		origAdj   = civInfo.getAdjective(0)

		if( not game.isOption(GameOptionTypes.GAMEOPTION_LEAD_ANY_CIV) ) :
			if( not self.bLeaveHumanName or not (pPlayer.isHuman() or game.getActivePlayer() == iPlayer) ) :
				if( pPlayer.getLeaderType() in LeaderCivNames.LeaderCivNames.keys() ) :
					[origDesc,origShort,origAdj] = LeaderCivNames.LeaderCivNames[pPlayer.getLeaderType()]

		newDesc  = CvUtil.convertToStr(origDesc)
		newShort = CvUtil.convertToStr(origShort)
		newAdj   = CvUtil.convertToStr(origAdj)
			
		newDesc = remove_diacriticals(newDesc)
		newShort = remove_diacriticals(newShort)
		newAdj = remove_diacriticals(newAdj)

		if( self.LOG_DEBUG ) :
			CvUtil.pyPrint("  Name - Re-setting civ name for player %d to %s"%(iPlayer,newDesc))
		
		gc.getPlayer(iPlayer).setCivName( newDesc, newShort, newAdj )
예제 #8
0
    def onSetPlayerAlive(self, argsList):

        iPlayerID = argsList[0]
        bNewValue = argsList[1]
        if (bNewValue == True and iPlayerID < gc.getMAX_CIV_PLAYERS()):
            pPlayer = gc.getPlayer(iPlayerID)

            if (pPlayer.isHuman() or game.getActivePlayer() == iPlayerID):
                if (self.bLeaveHumanName):
                    CvUtil.pyPrint("  Name - Leaving name for human player")
                    return

            [newCivDesc, newCivShort,
             newCivAdj] = self.nameForNewPlayer(iPlayerID)

            if (self.LOG_DEBUG):
                CvUtil.pyPrint("  Name - Setting civ name for new civ to %s" %
                               (newCivDesc))

            newDesc = CvUtil.convertToStr(newCivDesc)
            newShort = CvUtil.convertToStr(newCivShort)
            newAdj = CvUtil.convertToStr(newCivAdj)

            # Pass to pPlayer seems to require a conversion to 'ascii'
            pPlayer.setCivName(newDesc, newShort, newAdj)
	def __eventWBLandmarkPopupApply(self, playerID, userData, popupReturn):
		sScript = popupReturn.getEditBoxString(0)
		pPlot = CyMap().plot(userData[0], userData[1])
		iPlayer = userData[2]
		if userData[3] > -1:
			pSign = CyEngine().getSignByIndex(userData[3])
			iPlayer = pSign.getPlayerType()
			CyEngine().removeSign(pPlot, iPlayer)
		if len(sScript):
			if iPlayer == gc.getBARBARIAN_PLAYER():
				CyEngine().addLandmark(pPlot, CvUtil.convertToStr(sScript))
			else:
				CyEngine().addSign(pPlot, iPlayer, CvUtil.convertToStr(sScript))
		WBPlotScreen.iCounter = 10
		return
예제 #10
0
	def __eventWBLandmarkPopupApply(self, playerID, userData, popupReturn):
		sScript = popupReturn.getEditBoxString(0)
		pPlot = CyMap().plot(userData[0], userData[1])
		iPlayer = userData[2]
		if userData[3] > -1:
			pSign = CyEngine().getSignByIndex(userData[3])
			iPlayer = pSign.getPlayerType()
			CyEngine().removeSign(pPlot, iPlayer)
		if len(sScript):
			if iPlayer == gc.getBARBARIAN_PLAYER():
				CyEngine().addLandmark(pPlot, CvUtil.convertToStr(sScript))
			else:
				CyEngine().addSign(pPlot, iPlayer, CvUtil.convertToStr(sScript))
		WBPlotScreen.iCounter = 10
		return
예제 #11
0
def handleDeleteProfileButtonInput ( argsList ):
	"Handles Delete Profile Button clicked input"
	szName = argsList
	
	szProfileName =CvUtil.convertToStr(getOptionsScreen().getProfileEditCtrlText())
	
	if (UserProfile.deleteProfileFile(szProfileName)):    # Note that this function automatically checks to see if the string passed is a valid file to be deleted (it must have the proper file extension though)
		
		# Recalculate list of stuff
		UserProfile.loadProfileFileNames()
		
		# create popup
		popup = PyPopup.PyPopup()
		popup.setHeaderString("")
		popup.setBodyString(localText.getText("TXT_KEY_OPTIONS_DELETED_PROFILE", (szProfileName, )))
		popup.launch()
		
		bSuccess = True
		
		if (szProfileName == UserProfile.getProfileName()):
			
			UserProfile.setProfileName("")
				
			# Load other file
			szFilename = UserProfile.getProfileFileName(0)
			szProfile = szFilename[szFilename.find("PROFILES\\")+9:-4]
			
			bSuccess = loadProfile(szProfile)
		
		refresh()
		
		return bSuccess
		
	return 0
예제 #12
0
def handleCustomMusicPathCheckboxInput ( argsList ): 
	"Handles Custom Music Path text changed input"
	bValue, szName = argsList
	
	if (bValue):
		UserProfile.setMusicPath(CvUtil.convertToStr(getOptionsScreen().getMusicPath()))
	else:
		UserProfile.setMusicPath("")
	
	return 1
예제 #13
0
def getSaveFileName(pathName):
    if pathName:
        activePlayer = PlayerUtil.getActivePlayer()
        if not MapFinder.isActive() and options.isUsePlayerName():
            fileName = activePlayer.getName()
            turnYear = CyGameTextMgr().getTimeStr(gc.getGame().getGameTurn(),
                                                  False)
            fileName += '_' + turnYear.replace(" ", "-")
        else:
            objLeaderHead = gc.getLeaderHeadInfo(
                activePlayer.getLeaderType()).getText()

            game = gc.getGame()
            map = gc.getMap()

            difficulty = gc.getHandicapInfo(
                activePlayer.getHandicapType()).getText()
            mapType = os.path.basename(map.getMapScriptName())
            mapSize = gc.getWorldInfo(map.getWorldSize()).getText()
            mapClimate = gc.getClimateInfo(map.getClimate()).getText()
            mapLevel = gc.getSeaLevelInfo(map.getSeaLevel()).getText()
            era = gc.getEraInfo(game.getStartEra()).getText()
            speed = gc.getGameSpeedInfo(game.getGameSpeedType()).getText()
            turnYear = CyGameTextMgr().getTimeStr(game.getGameTurn(), False)
            turnYear = turnYear.replace(" ", "-")
            turnYear = turnYear.replace(",", "-")

            fileName = objLeaderHead[0:3]
            fileName += '_' + difficulty[0:3]
            fileName += '_' + mapSize[0:3]
            fileName += '_' + mapType[0:3]
            fileName += '_' + speed[0:3]
            fileName += '_' + era[0:3]
            fileName += '_' + turnYear
            fileName += '_' + mapClimate[0:3]
            fileName += '_' + mapLevel[0:3]

        fileName = BugPath.join(pathName, fileName)
        baseFileName = CvUtil.convertToStr(fileName)
        fileName = CvUtil.convertToStr(fileName + '_' +
                                       time.strftime("%b-%d-%Y_%H-%M-%S"))

        return (fileName, baseFileName)
예제 #14
0
def handleCustomMusicPathCheckboxInput(argsList):
    "Handles Custom Music Path text changed input"
    bValue, szName = argsList

    if bValue:
        UserProfile.setMusicPath(CvUtil.convertToStr(getOptionsScreen().getMusicPath()))
    else:
        UserProfile.setMusicPath("")

    return 1
예제 #15
0
 def closeEditBox(self, screen, bOk):
     if bOk:
         self.szScriptData = screen.getEditBoxString("ScriptEditBox")
         import CvUtil
         self.GAME.setScriptData(CvUtil.convertToStr(self.szScriptData))
     screen.hide("ScriptEditBG")
     screen.hide("ScriptEditBox")
     screen.hide("ScriptEditHeader")
     screen.hide("ScriptData|Ok0")
     screen.hide("ScriptData|Cancel0")
     self.bInEditBox = False
예제 #16
0
def remove_diacriticals(text):

    #BugUtil.debug(text)
    text = CvUtil.convertToStr(text)

    accent = [
        'é', 'è', 'ê', 'à', 'ù', 'û', 'ç', 'ô', 'î', 'ï', 'â', 'õ', 'ä', 'ö',
        'ü'
    ]
    sans_accent = [
        'e', 'e', 'e', 'a', 'u', 'u', 'c', 'o', 'i', 'i', 'a', 'o', 'a', 'o',
        'u'
    ]

    #BugUtil.debug(text)
    for i in xrange(len(accent)):
        text = text.replace(accent[i], sans_accent[i])
    #BugUtil.debug(text)

    return CvUtil.convertToStr(text)
예제 #17
0
파일: AutoSave.py 프로젝트: AP-ML/DTM
def getSaveFileName(pathName):
	if pathName:
		activePlayer = PlayerUtil.getActivePlayer()
		if not MapFinder.isActive() and options.isUsePlayerName():
			fileName = activePlayer.getName()
			turnYear = CyGameTextMgr().getTimeStr(gc.getGame().getGameTurn(), False)
			fileName += '_' + turnYear.replace(" ", "-")
		else:
			objLeaderHead = gc.getLeaderHeadInfo (activePlayer.getLeaderType()).getText()
			
			game = gc.getGame()
			map = gc.getMap()
			
			difficulty = gc.getHandicapInfo(activePlayer.getHandicapType()).getText()
			mapType = os.path.basename(map.getMapScriptName())
			mapSize = gc.getWorldInfo(map.getWorldSize()).getText()
			mapClimate = gc.getClimateInfo(map.getClimate()).getText()
			mapLevel = gc.getSeaLevelInfo(map.getSeaLevel()).getText()
			era = gc.getEraInfo(game.getStartEra()).getText()
			speed = gc.getGameSpeedInfo(game.getGameSpeedType()).getText()
			turnYear = CyGameTextMgr().getTimeStr(game.getGameTurn(), False)
			turnYear = turnYear.replace(" ", "-")
			turnYear = turnYear.replace(",", "-")

			fileName = objLeaderHead[0:3]
			fileName += '_' + difficulty[0:3]
			fileName += '_' + mapSize[0:3]
			fileName += '_' + mapType[0:3]
			fileName += '_' + speed[0:3]
			fileName += '_' + era[0:3]
			fileName += '_' + turnYear
			fileName += '_' + mapClimate[0:3]
			fileName += '_' + mapLevel[0:3]

		fileName = BugPath.join(pathName, fileName)
		baseFileName = CvUtil.convertToStr(fileName)
		fileName = CvUtil.convertToStr(fileName + '_' + time.strftime("%b-%d-%Y_%H-%M-%S"))

		return (fileName, baseFileName)
예제 #18
0
    def onSetPlayerAlive(self, argsList):
        iPlayerID = argsList[0]
        bNewValue = argsList[1]
        if bNewValue and iPlayerID < gc.getMAX_PC_PLAYERS():
            pPlayer = gc.getPlayer(iPlayerID)

            if (pPlayer.isHuman() or game.getActivePlayer() == iPlayerID):
                if (self.bLeaveHumanName):
                    CvUtil.pyPrint("  Name - Leaving name for human player")
                    return

            [newCivDesc, newCivShort,
             newCivAdj] = self.nameForNewPlayer(iPlayerID)

            newDesc = CvUtil.convertToStr(newCivDesc)
            newShort = CvUtil.convertToStr(newCivShort)
            newAdj = CvUtil.convertToStr(newCivAdj)

            newDesc = CvUtil.remove_diacriticals(newDesc)
            newShort = CvUtil.remove_diacriticals(newShort)
            newAdj = CvUtil.remove_diacriticals(newAdj)

            # Pass to pPlayer seems to require a conversion to 'ascii'
            pPlayer.setCivName(newDesc, newShort, newAdj)
 def placeWormhole(self, x, y, iWormholeType):
     gc = CyGlobalContext()
     engine = CyEngine()
     mmap = gc.getMap()
     xStart = x - 2
     xEnd = x + 3
     yStart = y - 2
     yEnd = y + 3
     for yy in range(yStart,yEnd):
         for xx in range(xStart,xEnd):
             if (yy == yStart or yy == yEnd - 1) and (xx == xStart or xx == xEnd - 1):
                 continue #skipping corners
             plot = mmap.plot(xx,yy)
             if x == xx and y == yy:
                 plot.setFeatureType(iWormholeType,0)
                 if mmap.getCustomMapOption(0) == 0:
                     engine.addLandmark(plot, CvUtil.convertToStr(gc.getFeatureInfo(plot.getFeatureType()).getDescription()))
             else:
                 plot.setFeatureType(self.featurePlaceHolder,0)
def handleDeleteProfileButtonInput ( argsList ):
	"Handles Delete Profile Button clicked input"
	szName = argsList

	szProfileName =CvUtil.convertToStr(getOptionsScreen().getProfileEditCtrlText())

	if (UserProfile.deleteProfileFile(szProfileName)):    # Note that this function automatically checks to see if the string passed is a valid file to be deleted (it must have the proper file extension though)

		# Recalculate list of stuff
		UserProfile.loadProfileFileNames()

		# create popup
		popup = PyPopup.PyPopup()
		popup.setHeaderString("")
# >>> CYBERFRONT // profile:
#		popup.setBodyString(localText.getText("TXT_KEY_OPTIONS_DELETED_PROFILE", (szProfileName, )))
		popup.setBodyString(localText.getText("TXT_KEY_OPTIONS_DELETED_PROFILE", (CvUtil.convertToUnicode(szProfileName), )))
# <<< CYBERFRONT
		popup.launch()

		bSuccess = true

		if (szProfileName == UserProfile.getProfileName()):

			UserProfile.setProfileName("")

			# Load other file
			szFilename = UserProfile.getProfileFileName(0)
			szProfile = szFilename[szFilename.find("PROFILES\\")+9:-4]

			bSuccess = loadProfile(szProfile)

		refresh()

		return bSuccess

	return 0
 def placeWormhole(self, x, y, iWormholeType):
     gc = CyGlobalContext()
     engine = CyEngine()
     mmap = gc.getMap()
     xStart = x - 2
     xEnd = x + 3
     yStart = y - 2
     yEnd = y + 3
     for yy in range(yStart, yEnd):
         for xx in range(xStart, xEnd):
             if (yy == yStart or yy == yEnd - 1) and (xx == xStart
                                                      or xx == xEnd - 1):
                 continue  #skipping corners
             plot = mmap.plot(xx, yy)
             if x == xx and y == yy:
                 plot.setFeatureType(iWormholeType, 0)
                 if mmap.getCustomMapOption(0) == 0:
                     engine.addLandmark(
                         plot,
                         CvUtil.convertToStr(
                             gc.getFeatureInfo(
                                 plot.getFeatureType()).getDescription()))
             else:
                 plot.setFeatureType(self.featurePlaceHolder, 0)
예제 #22
0
    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
예제 #23
0
    def drawAudioOptionsTab(self):

        tab = self.pTabControl

        tab.attachVBox("AudioForm", "AudioVBox")

        tab.attachScrollPanel("AudioVBox", "AudioPanel")
        tab.setLayoutFlag("AudioPanel", "LAYOUT_SIZE_HEXPANDING")
        tab.setLayoutFlag("AudioPanel", "LAYOUT_SIZE_VEXPANDING")

        tab.attachVBox("AudioPanel", "AudioPanelVBox")
        tab.setLayoutFlag("AudioPanelHBox", "LAYOUT_SPACING_FORM")
        tab.setLayoutFlag("AudioPanelHBox", "LAYOUT_SIZE_HEXPANDING")
        tab.setLayoutFlag("AudioPanelHBox", "LAYOUT_SIZE_VEXPANDING")

        ######################### Create the 6 volume slider/checkboxes #########################

        tab.attachVBox("AudioPanelVBox", "VolumeVBox")
        tab.setLayoutFlag("VolumeVBox", "LAYOUT_SIZE_HEXPANDING")
        tab.setLayoutFlag("VolumeVBox", "LAYOUT_SIZE_VEXPANDING")

        #tab.attachLabel("VolumeVBox", "VolumeLabel", "VOLUME")

        tab.attachPanel("VolumeVBox", "VolumePanel")
        tab.setStyle("VolumePanel", "Panel_Tan15_Style")
        tab.setLayoutFlag("VolumePanel", "LAYOUT_SIZE_HEXPANDING")
        tab.setLayoutFlag("VolumePanel", "LAYOUT_SIZE_VEXPANDING")

        tab.attachVBox("VolumePanel", "VolumePanelVBox")
        tab.setLayoutFlag("VolumePanelVBox", "LAYOUT_SIZE_HEXPANDING")
        tab.setLayoutFlag("VolumePanelVBox", "LAYOUT_SIZE_VEXPANDING")

        tab.attachScrollPanel("VolumePanelVBox", "VolumeScrollPanel")
        tab.setLayoutFlag("VolumeScrollPanel", "LAYOUT_SIZE_HEXPANDING")
        tab.setLayoutFlag("VolumeScrollPanel", "LAYOUT_SIZE_VEXPANDING")

        tab.attachHBox("VolumeScrollPanel", "VolumePanelHBox")
        tab.setLayoutFlag("VolumePanelHBox", "LAYOUT_HEVENSTRETCH")
        tab.setLayoutFlag("VolumePanelHBox", "LAYOUT_SIZE_VEXPANDING")

        for iWidgetNum in range(6):

            # SLIDER

            if (iWidgetNum == 0):  # Master Volume
                szWidgetDesc = localText.getText(
                    "TXT_KEY_OPTIONS_MASTERVOLUME", ())
                iInitialVal = 20 - UserProfile.getMasterVolume() - 1
                bNoSoundTrue = UserProfile.isMasterNoSound()
            elif (iWidgetNum == 1):  # Music Volume
                szWidgetDesc = localText.getText("TXT_KEY_OPTIONS_MUSICVOLUME",
                                                 ())
                iInitialVal = 20 - UserProfile.getMusicVolume() - 1
                bNoSoundTrue = UserProfile.isMusicNoSound()
            elif (iWidgetNum == 2):  # Sound Effects Volume
                szWidgetDesc = localText.getText(
                    "TXT_KEY_OPTIONS_EFFECTSVOLUME", ())
                iInitialVal = 20 - UserProfile.getSoundEffectsVolume() - 1
                bNoSoundTrue = UserProfile.isSoundEffectsNoSound()
            elif (iWidgetNum == 3):  # Speech Volume
                szWidgetDesc = localText.getText(
                    "TXT_KEY_OPTIONS_SPEECHVOLUME", ())
                iInitialVal = 20 - UserProfile.getSpeechVolume() - 1
                bNoSoundTrue = UserProfile.isSpeechNoSound()
            elif (iWidgetNum == 4):  # Ambience Volume
                szWidgetDesc = localText.getText(
                    "TXT_KEY_OPTIONS_AMBIENCEVOLUME", ())
                iInitialVal = 20 - UserProfile.getAmbienceVolume() - 1
                bNoSoundTrue = UserProfile.isAmbienceNoSound()
            elif (iWidgetNum == 5):  # Interface Volume
                szWidgetDesc = localText.getText(
                    "TXT_KEY_OPTIONS_INTERFACEVOLUME", ())
                iInitialVal = 20 - UserProfile.getInterfaceVolume() - 1
                bNoSoundTrue = UserProfile.isInterfaceNoSound()

            islider = str(iWidgetNum)

            vbox = "VolumeSliderVBox" + islider
            tab.attachVBox("VolumePanelHBox", vbox)

            # Volume Slider
            szSliderDesc = szWidgetDesc
            szWidgetName = "VolumeSliderLabel" + islider
            tab.attachLabel(vbox, szWidgetName, szSliderDesc)
            tab.setLayoutFlag(szWidgetName, "LAYOUT_HCENTER")

            szCallbackFunction = "handleVolumeSlidersInput"
            szWidgetName = "VolumeSlider_" + str(iWidgetNum)
            iMin = 0
            iMax = UserProfile.getVolumeStops()
            # iInitialVal set above
            tab.attachVSlider(vbox, szWidgetName, self.callbackIFace,
                              szCallbackFunction, szWidgetName, iMin, iMax,
                              iInitialVal)
            tab.setLayoutFlag(szWidgetName, "LAYOUT_SIZE_VEXPANDING")
            tab.setControlFlag(szWidgetName, "CF_SLIDER_FILL_DOWN")

            # CHECKBOX

            szOptionDesc = localText.getText("TXT_KEY_OPTIONS_NO_SOUND", ())
            szCallbackFunction = "handleVolumeCheckboxesInput"
            szWidgetName = "VolumeNoSoundCheckbox_" + str(iWidgetNum)
            # bNoSoundTrue set above
            tab.attachCheckBox(vbox, szWidgetName, szOptionDesc,
                               self.callbackIFace, szCallbackFunction,
                               szWidgetName, bNoSoundTrue)
            tab.setLayoutFlag(szWidgetName, "LAYOUT_HCENTER")

        tab.attachHSeparator("VolumePanelVBox", "SoundSeparator")

        tab.attachHBox("VolumePanelVBox", "SoundPanelHBox")
        tab.setLayoutFlag("SoundPanelHBox", "LAYOUT_SIZE_HPREFERREDEXPANDING")
        tab.setLayoutFlag("SoundPanelHBox", "LAYOUT_SIZE_VPREFERRED")

        ######################### Voice Config Section #########################

        tab.attachVBox("SoundPanelHBox", "VoiceVBox")

        # Checkbox
        szOptionDesc = localText.getText("TXT_KEY_OPTIONS_VOICE", ())
        szCallbackFunction = "handleVoiceCheckboxInput"
        self.szVoiceCheckboxName = "VoiceCheckbox"
        szWidgetName = "VoiceChatCheckbox"
        bUseVoice = UserProfile.useVoice()
        tab.attachCheckBox("VoiceVBox", szWidgetName, szOptionDesc,
                           self.callbackIFace, szCallbackFunction,
                           szWidgetName, bUseVoice)

        # Capture Device Dropdown
        tab.attachLabel(
            "VoiceVBox", "VoiceCaptureLabel",
            localText.getText("TXT_KEY_OPTIONS_CAPTURE_DEVICE", ()))
        szDropdownDesc = "CaptureDeviceDropdownBox"
        aszDropdownElements = ()
        for iCaptureDevice in range(UserProfile.getNumCaptureDevices()):
            aszDropdownElements = aszDropdownElements + (
                UserProfile.getCaptureDeviceDesc(iCaptureDevice), )
        szCallbackFunction = "handleCaptureDeviceDropdownInput"
        szWidgetName = "CaptureDeviceDropdownBox"
        iInitialSelection = UserProfile.getCaptureDeviceIndex()
        tab.attachDropDown("VoiceVBox", szWidgetName, szDropdownDesc,
                           aszDropdownElements, self.callbackIFace,
                           szCallbackFunction, szWidgetName, iInitialSelection)

        # Capture Volume Slider
        szSliderDesc = localText.getText("TXT_KEY_OPTIONS_CAPTUREVOLUME", ())
        szCallbackFunction = "handleCaptureVolumeSliderInput"
        szWidgetName = "CaptureVolumeSlider"
        iMin = 0
        iMax = UserProfile.getMaxCaptureVolume()
        #		iInitialVal = iMax - UserProfile.getCaptureVolume()
        iInitialVal = UserProfile.getCaptureVolume()
        tab.attachHSlider("VoiceVBox", szWidgetName, self.callbackIFace,
                          szCallbackFunction, szWidgetName, iMin, iMax,
                          iInitialVal)
        tab.setControlFlag(szWidgetName, "CF_SLIDER_FILL_UP")

        # Playback Device Dropdown
        tab.attachLabel("VoiceVBox", "VoicePlaybackLabel",
                        localText.getText("TXT_KEY_OPTIONS_PLAYBACK_DEVICE",
                                          ()))  # Label
        szDropdownDesc = "PlaybackDeviceDropdownBox"
        aszDropdownElements = ()
        for iPlaybackDevice in range(UserProfile.getNumPlaybackDevices()):
            aszDropdownElements = aszDropdownElements + (
                UserProfile.getPlaybackDeviceDesc(iPlaybackDevice), )
        szCallbackFunction = "handlePlaybackDeviceDropdownInput"
        szWidgetName = "PlaybackDeviceDropdownBox"
        iInitialSelection = UserProfile.getPlaybackDeviceIndex()
        tab.attachDropDown("VoiceVBox", szWidgetName, szDropdownDesc,
                           aszDropdownElements, self.callbackIFace,
                           szCallbackFunction, szWidgetName, iInitialSelection)

        # Playback Volume Slider
        szSliderDesc = localText.getText("TXT_KEY_OPTIONS_PLAYBACKVOLUME", ())
        szCallbackFunction = "handlePlaybackVolumeSliderInput"
        szWidgetName = "PlaybackVolumeSlider"
        iMin = 0
        iMax = UserProfile.getMaxPlaybackVolume()
        #		iInitialVal = iMax - UserProfile.getPlaybackVolume()
        iInitialVal = UserProfile.getPlaybackVolume()
        tab.attachHSlider("VoiceVBox", szWidgetName, self.callbackIFace,
                          szCallbackFunction, szWidgetName, iMin, iMax,
                          iInitialVal)
        tab.setControlFlag(szWidgetName, "CF_SLIDER_FILL_UP")

        ######################### Speaker Config Dropdown #########################

        tab.attachVSeparator("SoundPanelHBox", "SoundVSeparator")

        tab.attachVBox("SoundPanelHBox", "SoundConfigVBox")

        tab.attachImage(
            "SoundConfigVBox", "SoundBlasterLogo",
            CyArtFileMgr().getMiscArtInfo("SOUND_BLASTER_LOGO").getPath())

        tab.attachLabel("SoundConfigVBox", "SpeakerConfigLabel",
                        localText.getText("TXT_KEY_OPTIONS_SPEAKERS",
                                          ()))  # Label
        szDropdownDesc = "SpeakerConfigDropdownBox"
        aszDropdownElements = ()
        iInitialSelection = 0
        for iSpeakerConfigLoop in range(15):
            szActiveConfigKey = UserProfile.getSpeakerConfigFromList(
                iSpeakerConfigLoop)
            szActiveConfig = localText.getText(szActiveConfigKey, ())
            aszDropdownElements = aszDropdownElements + (szActiveConfig, )
            if (UserProfile.getSpeakerConfig() == szActiveConfigKey):
                iInitialSelection = iSpeakerConfigLoop

        szCallbackFunction = "handleSpeakerConfigDropdownInput"
        szWidgetName = "SpeakerConfigDropdownBox"
        # iInitialSelection set above
        tab.attachDropDown("SoundConfigVBox", szWidgetName, szDropdownDesc,
                           aszDropdownElements, self.callbackIFace,
                           szCallbackFunction, szWidgetName, iInitialSelection)
        tab.setLayoutFlag(szWidgetName, "LAYOUT_SIZE_HFIXEDEXPANDING")
        tab.setLayoutFlag(szWidgetName, "LAYOUT_LEFT")

        ######################### Custom Audio Path #########################

        tab.attachHSeparator("SoundConfigVBox", "SoundSeparator")

        tab.attachHBox("SoundConfigVBox", "CustomPanelHBox")
        tab.setLayoutFlag("CustomPanelHBox", "LAYOUT_SIZE_HPREFERREDEXPANDING")
        tab.setLayoutFlag("CustomPanelHBox", "LAYOUT_SIZE_VPREFERRED")

        # Checkbox
        szOptionDesc = localText.getText("TXT_KEY_OPTIONS_CUSTOM_MUSIC", ())
        szCallbackFunction = "handleCustomMusicPathCheckboxInput"
        self.szCustomMusicCheckboxName = "CustomMusicPathCheckbox"
        szWidgetName = CvUtil.convertToStr(self.szCustomMusicCheckboxName)
        bUseCustomMusicPath = false
        if (UserProfile.getMusicPath() != ""):
            bUseCustomMusicPath = true
        tab.attachCheckBox("CustomPanelHBox", szWidgetName, szOptionDesc,
                           self.callbackIFace, szCallbackFunction,
                           szWidgetName, bUseCustomMusicPath)

        tab.attachHBox("CustomPanelHBox", "AudioPathHBox")
        tab.setLayoutFlag("AudioPathHBox", "LAYOUT_SIZE_HFIXEDEXPANDING")

        # Browse Button
        szOptionDesc = localText.getText("TXT_KEY_OPTIONS_BROWSE", ())
        szCallbackFunction = "handleCustomMusicPathButtonInput"
        szWidgetName = "CustomMusicPathButton"
        tab.attachButton("AudioPathHBox", szWidgetName, szOptionDesc,
                         self.callbackIFace, szCallbackFunction, szWidgetName)

        # Edit Box
        szEditBoxDesc = u""
        if (UserProfile.getMusicPath() != ""):
            szEditBoxDesc = CvUtil.convertToUnicode(UserProfile.getMusicPath())
        szWidgetName = "CustomMusicEditBox"
        szCallbackFunction = "DummyCallback"

        tab.attachEdit("AudioPathHBox", szWidgetName, szEditBoxDesc,
                       self.callbackIFace, szCallbackFunction, szWidgetName)

        ########## EXIT

        tab.attachHSeparator("AudioVBox", "AudioExitSeparator")

        tab.attachHBox("AudioVBox", "LowerHBox")
        tab.setLayoutFlag("LowerHBox", "LAYOUT_HCENTER")

        szOptionDesc = localText.getText("TXT_KEY_OPTIONS_RESET", ())
        szCallbackFunction = "handleAudioReset"
        szWidgetName = "AudioOptionsResetButton"
        tab.attachButton("LowerHBox", szWidgetName, szOptionDesc,
                         self.callbackIFace, szCallbackFunction, szWidgetName)

        szOptionDesc = localText.getText("TXT_KEY_PEDIA_SCREEN_EXIT", ())
        szCallbackFunction = "handleExitButtonInput"
        szWidgetName = "AudioOptionsExitButton"
        tab.attachButton("LowerHBox", szWidgetName, szOptionDesc,
                         self.callbackIFace, szCallbackFunction, szWidgetName)
        tab.setLayoutFlag(szWidgetName, "LAYOUT_HCENTER")
예제 #24
0
def writeLog():
	playername = CvUtil.convertToStr(gc.getPlayer(gc.getGame().getActivePlayer()).getName())
	szNewFilename = "%s - Player %s - " % (playername, gc.getGame().getActivePlayer()) + "OOSLog - Turn " + "%s" % (gc.getGame().getGameTurn()) + ".txt"
	pFile = open(szNewFilename, "w")

	#
	# Global data
	#
	pFile.write(SEPERATOR)
	pFile.write(SEPERATOR)

	pFile.write("  GLOBALS  \n")

	pFile.write(SEPERATOR)
	pFile.write(SEPERATOR)
	pFile.write("\n\n")

	pFile.write("Next Map Rand Value: %d\n" % CyGame().getMapRand().get(10000, "OOS Log"))
	pFile.write("Next Soren Rand Value: %d\n" % CyGame().getSorenRand().get(10000, "OOS Log"))

	pFile.write("Total num cities: %d\n" % CyGame().getNumCities() )
	pFile.write("Total population: %d\n" % CyGame().getTotalPopulation() )
	pFile.write("Total Deals: %d\n" % CyGame().getNumDeals() )

	pFile.write("Total owned plots: %d\n" % CyMap().getOwnedPlots() )
	pFile.write("Total num areas: %d\n" % CyMap().getNumAreas() )

	pFile.write("\n\n")

	#
	# Player data
	#
	iPlayer = 0
	for iPlayer in range(gc.getMAX_PLAYERS()):
		pPlayer = gc.getPlayer(iPlayer)
		if (pPlayer.isEverAlive()):
			pFile.write(SEPERATOR)
			pFile.write(SEPERATOR)

			pFile.write("  PLAYER %d: %s  \n" % (iPlayer, CvUtil.convertToStr(pPlayer.getName())))
			pFile.write("  Civilizations: %s  \n" % (CvUtil.convertToStr(pPlayer.getCivilizationDescriptionKey())))

			pFile.write(SEPERATOR)
			pFile.write(SEPERATOR)
			pFile.write("\n\n")

			pFile.write("Basic data:\n")
			pFile.write("-----------\n")
			pFile.write("Player %d Score: %d\n" % (iPlayer, gc.getGame().getPlayerScore(iPlayer) ))

			pFile.write("Player %d Population: %d\n" % (iPlayer, pPlayer.getTotalPopulation() ) )
			pFile.write("Player %d Total Land: %d\n" % (iPlayer, pPlayer.getTotalLand() ) )
			pFile.write("Player %d Gold: %d\n" % (iPlayer, pPlayer.getGold() ) )
			pFile.write("Player %d Assets: %d\n" % (iPlayer, pPlayer.getAssets() ) )
			pFile.write("Player %d Power: %d\n" % (iPlayer, pPlayer.getPower() ) )
			pFile.write("Player %d Num Cities: %d\n" % (iPlayer, pPlayer.getNumCities() ) )
			pFile.write("Player %d Num Units: %d\n" % (iPlayer, pPlayer.getNumUnits() ) )
			pFile.write("Player %d Num Selection Groups: %d\n" % (iPlayer, pPlayer.getNumSelectionGroups() ) )
			pFile.write("Player %d Difficulty: %d\n" % (iPlayer, pPlayer.getHandicapType() ))

			pFile.write("\n\n")

			pFile.write("Yields:\n")
			pFile.write("-------\n")
			for iYield in range( int(YieldTypes.NUM_YIELD_TYPES) ):
				pFile.write("Player %d %s Total Yield: %d\n" % (iPlayer, gc.getYieldInfo(iYield).getDescription(), pPlayer.calculateTotalYield(iYield) ))

			pFile.write("\n\n")

			pFile.write("Commerce:\n")
			pFile.write("---------\n")
			for iCommerce in range( int(CommerceTypes.NUM_COMMERCE_TYPES) ):
				pFile.write("Player %d %s Total Commerce: %d\n" % (iPlayer, gc.getCommerceInfo(iCommerce).getDescription(), pPlayer.getCommerceRate(CommerceTypes(iCommerce)) ))

			pFile.write("\n\n")

			pFile.write("Bonus Info:\n")
			pFile.write("-----------\n")
			for iBonus in range(gc.getNumBonusInfos()):
				pFile.write("Player %d, %s, Number Available: %d\n" % (iPlayer, gc.getBonusInfo(iBonus).getDescription(), pPlayer.getNumAvailableBonuses(iBonus) ))
				pFile.write("Player %d, %s, Import: %d\n" % (iPlayer, gc.getBonusInfo(iBonus).getDescription(), pPlayer.getBonusImport(iBonus) ))
				pFile.write("Player %d, %s, Export: %d\n" % (iPlayer, gc.getBonusInfo(iBonus).getDescription(), pPlayer.getBonusExport(iBonus) ))
				pFile.write("\n")

			pFile.write("\n\n")

			pFile.write("Improvement Info:\n")
			pFile.write("-----------------\n")
			for iImprovement in range(gc.getNumImprovementInfos()):
				pFile.write("Player %d, %s, Improvement count: %d\n" % (iPlayer, CvUtil.convertToStr(gc.getImprovementInfo(iImprovement).getDescription()), pPlayer.getImprovementCount(iImprovement) ))

			pFile.write("\n\n")

			pFile.write("Building Class Info:\n")
			pFile.write("--------------------\n")
			for iBuildingClass in range(gc.getNumBuildingClassInfos()):
				pFile.write("Player %d, %s, Building class count plus building: %d\n" % (iPlayer, CvUtil.convertToStr(gc.getBuildingClassInfo(iBuildingClass).getDescription()), pPlayer.getBuildingClassCountPlusMaking(iBuildingClass) ))

			pFile.write("\n\n")

			pFile.write("Unit Class Info:\n")
			pFile.write("--------------------\n")
			for iUnitClass in range(gc.getNumUnitClassInfos()):
				pFile.write("Player %d, %s, Unit class count plus training: %d\n" % (iPlayer, CvUtil.convertToStr(gc.getUnitClassInfo(iUnitClass).getDescription()), pPlayer.getUnitClassCountPlusMaking(iUnitClass) ))

			pFile.write("\n\n")

			pFile.write("UnitAI Types Info:\n")
			pFile.write("------------------\n")
			for iUnitAIType in range(int(UnitAITypes.NUM_UNITAI_TYPES)):
				pFile.write("Player %d, %s, Unit AI Type count: %d\n" % (iPlayer, gc.getUnitAIInfo(iUnitAIType).getDescription(), pPlayer.AI_totalUnitAIs(UnitAITypes(iUnitAIType)) ))
			

			pFile.write("\n\n")

			pFile.write("City Info:\n")
			pFile.write("----------\n")
			iNumCities = pPlayer.getNumCities()

			if (iNumCities == 0):
				pFile.write("No Cities")
			else:
				pLoopCityTuple = pPlayer.firstCity(False)
				while (pLoopCityTuple[0] != None):
					pCity = pLoopCityTuple[0]
					#pFile.write("Player %d, City ID: %d, %s, Plot Radius: %d\n" % (iPlayer, pCity.getID(), CvUtil.convertToStr(pCity.getName()), pCity.getPlotRadius() ))

					pFile.write("X: %d, Y: %d\n" % (pCity.getX(), pCity.getY()) )
					pFile.write("Founded: %d\n" % pCity.getGameTurnFounded() )
					pFile.write("Population: %d\n" % pCity.getPopulation() )
					pFile.write("Buildings: %d\n" % pCity.getNumBuildings() )
					pFile.write("Improved Plots: %d\n" % pCity.countNumImprovedPlots() )
					pFile.write("Producing: %s\n" % pCity.getProductionName() )
					pFile.write("%d Tiles Worked, %d Specialists, %d Great People\n" % (pCity.getWorkingPopulation(), pCity.getSpecialistPopulation(), pCity.getNumGreatPeople()) )

					pLoopCityTuple = pPlayer.nextCity(pLoopCityTuple[1], False)
					pFile.write("\n")


			pFile.write("\n\n")

			pFile.write("Unit Info:\n")
			pFile.write("----------\n")
			iNumUnits = pPlayer.getNumUnits()

			if (iNumUnits == 0):
				pFile.write("No Units")
			else:
				pLoopUnitTuple = pPlayer.firstUnit(False)
				while (pLoopUnitTuple[0] != None):
					pUnit = pLoopUnitTuple[0]
					pFile.write("Player %d, Unit ID: %d, %s\n" % (iPlayer, pUnit.getID(), CvUtil.convertToStr(pUnit.getName()) ))
					pFile.write("X: %d, Y: %d\n" % (pUnit.getX(), pUnit.getY()) )
					pFile.write("Damage: %d\n" % pUnit.getDamage() )
					#pFile.write("Experience: %d\n" % pUnit.getExperienceTimes100() )
					pFile.write("Experience: %d\n" % pUnit.getExperience() )
					pFile.write("Level: %d\n" % pUnit.getLevel() )

					pLoopUnitTuple = pPlayer.nextUnit(pLoopUnitTuple[1], False)
					pFile.write("\n")
				

			# Space at end of player's info
			pFile.write("\n\n")
		
	# Close file

	pFile.close()
def loadProfile(szProfile):

# >>> CYBERFRONT // profile:
#	bReadSuccessful = UserProfile.readFromFile(szProfile)
	bReadSuccessful = UserProfile.readFromFile(CvUtil.convertToStr(szProfile))
# <<< CYBERFRONT

	if (bReadSuccessful):
		UserProfile.recalculateAudioSettings()

		getOptionsScreen().setProfileEditCtrlText(szProfile)

		########### Now we have to update everything we loaded since nothing is done except the serialization on load ###########

		# Game Options
		for iOptionLoop in range(PlayerOptionTypes.NUM_PLAYEROPTION_TYPES):
			bValue = UserProfile.getPlayerOption(iOptionLoop)
			CyMessageControl().sendPlayerOption(iOptionLoop, bValue)

		# Graphics Options
		for iOptionLoop in range(GraphicOptionTypes.NUM_GRAPHICOPTION_TYPES):
			bValue = UserProfile.getGraphicOption(iOptionLoop)
			UserProfile.setGraphicOption(iOptionLoop, bValue)

		# Beware! These guys aren't safe to change:
		UserProfile.setAntiAliasing(UserProfile.getAntiAliasing())
		UserProfile.setResolution(UserProfile.getResolution())

		# Audio Options
		UserProfile.setSpeakerConfig(UserProfile.getSpeakerConfig())
		UserProfile.setMusicPath(UserProfile.getMusicPath())
		UserProfile.setUseVoice(UserProfile.useVoice())
		UserProfile.setCaptureDevice(UserProfile.getCaptureDeviceIndex())
		UserProfile.setPlaybackDevice(UserProfile.getPlaybackDeviceIndex())
		UserProfile.setCaptureVolume(UserProfile.getCaptureVolume())
		UserProfile.setPlaybackVolume(UserProfile.getPlaybackVolume())

		# Clock Options
		UserProfile.setClockOn(UserProfile.isClockOn())

		#################

		# create popup
		popup = PyPopup.PyPopup()
		popup.setHeaderString("")
		popup.setBodyString(localText.getText("TXT_KEY_OPTIONS_LOADED_PROFILE", (szProfile, )))
		popup.launch()

		# Refresh options screen with updated values
		refresh()

		return 1

	# Load failed
	else:

		# create popup
		popup = PyPopup.PyPopup()
		popup.setHeaderString("")
		popup.setBodyString(localText.getText("TXT_KEY_OPTIONS_LOAD_PROFILE_FAIL", ()))
		popup.launch()

		return 0
예제 #26
0
	def __eventWBPlotScriptPopupApply(self, playerID, userData, popupReturn):
		sScript = popupReturn.getEditBoxString(0)
		pPlot = CyMap().plot(userData[0], userData[1])
		pPlot.setScriptData(CvUtil.convertToStr(sScript))
		WBPlotScreen.WBPlotScreen(CvPlatyBuilderScreen.CvWorldBuilderScreen()).placeScript()
		return
예제 #27
0
	def __eventWBUnitScriptPopupApply(self, playerID, userData, popupReturn):
		sScript = popupReturn.getEditBoxString(0)
		pUnit = gc.getPlayer(userData[0]).getUnit(userData[1])
		pUnit.setScriptData(CvUtil.convertToStr(sScript))
		WBUnitScreen.WBUnitScreen(CvPlatyBuilderScreen.CvWorldBuilderScreen()).placeScript()
		return
예제 #28
0
    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)
예제 #29
0
	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
예제 #30
0
def writeLog():

    if CyGame().isPitbossHost():
        playername = "PitBoss"
    else:
        # advc: Prepend id b/c player names can be the same (that happens easily when testing on a single machine)
        activePlayer = gc.getPlayer(gc.getGame().getActivePlayer())
        playername = str(activePlayer.getID()) + CvUtil.convertToStr(
            activePlayer.getName())
    szNewFilename = BugPath.getRootDir() + "\\Logs\\" + "OOSLog - %s - " % (
        playername) + "Turn %s" % (gc.getGame().getGameTurn()) + ".log"
    # <advc> Replacement for the bWroteLog mechanism above
    if os.path.isfile(szNewFilename):
        return  # </advc>
    pFile = open(szNewFilename, "w")

    # Backup current language
    iLanguage = CyGame().getCurrentLanguage()
    # Force english language for logs
    CyGame().setCurrentLanguage(0)

    #
    # Global data
    #
    pFile.write(SEPERATOR)
    pFile.write(SEPERATOR)

    #pFile.write(CvUtil.convertToStr(CyTranslator().getText("TXT_KEY_VERSION", ())))
    #pFile.write("\n\n")

    # The log follows the order in CvGame::calculateSyncChecksum()

    pFile.write("  GLOBALS  \n")

    pFile.write(SEPERATOR)
    pFile.write(SEPERATOR)
    pFile.write("\n\n")
    # advc: Call getSeed instead of get -- don't want to change the state of the RNGs here.
    pFile.write("Last Map Rand Value: %d\n" % CyGame().getMapRand().getSeed())
    pFile.write("Last Soren Rand Value: %d\n" %
                CyGame().getSorenRand().getSeed())

    pFile.write("Total cities: %d\n" % CyGame().getNumCities())
    pFile.write("Total population: %d\n" % CyGame().getTotalPopulation())
    pFile.write("Total deals: %d\n" % CyGame().getNumDeals())

    pFile.write("Total owned plots: %d\n" % CyMap().getOwnedPlots())
    pFile.write("Total number of areas: %d\n" % CyMap().getNumAreas())

    #pFile.write("Global counter: %d\n" % CyGame().getGlobalCounter() )
    #pFile.write("Total civilization cities: %d\n" % CyGame().getNumCivCities() )

    pFile.write("Turn slice: %d\n" % (CyGame().getTurnSlice() % 8))

    pFile.write("\n\n")

    #
    # Player data
    #
    iPlayer = 0
    for iPlayer in range(gc.getMAX_PLAYERS()):
        pPlayer = gc.getPlayer(iPlayer)
        if (pPlayer.isEverAlive()):
            pFile.write(SEPERATOR)
            pFile.write(SEPERATOR)

            pFile.write("  PLAYER %d: %s  \n" %
                        (iPlayer, CvUtil.convertToStr(pPlayer.getName())))
            #pFile.write("  Civilization: %s  \n" % (CvUtil.convertToStr(pPlayer.getCivilizationDescriptionKey())))

            pFile.write(SEPERATOR)
            pFile.write(SEPERATOR)
            pFile.write("\n\n")

            pFile.write("Basic data:\n")
            pFile.write("-----------\n")
            pFile.write("Player %d Score: %d\n" %
                        (iPlayer, gc.getGame().getPlayerScore(iPlayer)))

            pFile.write("Player %d Population: %d\n" %
                        (iPlayer, pPlayer.getTotalPopulation()))
            pFile.write("Player %d Total Land: %d\n" %
                        (iPlayer, pPlayer.getTotalLand()))
            pFile.write("Player %d Gold: %d\n" % (iPlayer, pPlayer.getGold()))
            pFile.write("Player %d Assets: %d\n" %
                        (iPlayer, pPlayer.getAssets()))
            pFile.write("Player %d Power: %d\n" %
                        (iPlayer, pPlayer.getPower()))
            pFile.write("Player %d Num Cities: %d\n" %
                        (iPlayer, pPlayer.getNumCities()))
            pFile.write("Player %d Num Units: %d\n" %
                        (iPlayer, pPlayer.getNumUnits()))
            pFile.write("Player %d Num Selection Groups: %d\n" %
                        (iPlayer, pPlayer.getNumSelectionGroups()))
            #pFile.write("Player %d Difficulty: %d\n" % (iPlayer, pPlayer.getHandicapType() ))
            #pFile.write("Player %d Religion: %s\n" % (iPlayer, CvUtil.convertToStr(pPlayer.getStateReligionKey()) ))
            #.pFile.write("Player %d Total culture: %d\n" % (iPlayer, pPlayer.countTotalCulture() ))

            pFile.write("\n\n")

            pFile.write("Yields:\n")
            pFile.write("-------\n")
            for iYield in range(int(YieldTypes.NUM_YIELD_TYPES)):
                pFile.write("Player %d %s Total Yield: %d\n" %
                            (iPlayer, gc.getYieldInfo(iYield).getDescription(),
                             pPlayer.calculateTotalYield(iYield)))

            pFile.write("\n\n")

            pFile.write("Commerce:\n")
            pFile.write("---------\n")
            for iCommerce in range(int(CommerceTypes.NUM_COMMERCE_TYPES)):
                pFile.write(
                    "Player %d %s Total Commerce: %d\n" %
                    (iPlayer, gc.getCommerceInfo(iCommerce).getDescription(),
                     pPlayer.getCommerceRate(CommerceTypes(iCommerce))))

            pFile.write("\n\n")

            pFile.write("Bonus Info:\n")
            pFile.write("-----------\n")
            for iBonus in range(gc.getNumBonusInfos()):
                pFile.write("Player %d, %s, Number Available: %d\n" %
                            (iPlayer, gc.getBonusInfo(iBonus).getDescription(),
                             pPlayer.getNumAvailableBonuses(iBonus)))
                pFile.write("Player %d, %s, Import: %d\n" %
                            (iPlayer, gc.getBonusInfo(iBonus).getDescription(),
                             pPlayer.getBonusImport(iBonus)))
                pFile.write("Player %d, %s, Export: %d\n" %
                            (iPlayer, gc.getBonusInfo(iBonus).getDescription(),
                             pPlayer.getBonusExport(iBonus)))
                pFile.write("\n")

            pFile.write("\n\n")

            pFile.write("Improvement Info:\n")
            pFile.write("-----------------\n")
            for iImprovement in range(gc.getNumImprovementInfos()):
                pFile.write(
                    "Player %d, %s, Improvement count: %d\n" %
                    (iPlayer,
                     CvUtil.convertToStr(
                         gc.getImprovementInfo(iImprovement).getDescription()),
                     pPlayer.getImprovementCount(iImprovement)))

            pFile.write("\n\n")

            pFile.write("Building Class Info:\n")
            pFile.write("--------------------\n")
            for iBuildingClass in range(gc.getNumBuildingClassInfos()):
                pFile.write(
                    "Player %d, %s, Building class count plus making: %d\n" %
                    (iPlayer,
                     CvUtil.convertToStr(
                         gc.getBuildingClassInfo(
                             iBuildingClass).getDescription()),
                     pPlayer.getBuildingClassCountPlusMaking(iBuildingClass)))

            pFile.write("\n\n")

            pFile.write("Unit Class Info:\n")
            pFile.write("--------------------\n")
            for iUnitClass in range(gc.getNumUnitClassInfos()):
                pFile.write(
                    "Player %d, %s, Unit class count plus training: %d\n" %
                    (iPlayer,
                     CvUtil.convertToStr(
                         gc.getUnitClassInfo(iUnitClass).getDescription()),
                     pPlayer.getUnitClassCountPlusMaking(iUnitClass)))

            pFile.write("\n\n")

            pFile.write("UnitAI Types Info:\n")
            pFile.write("------------------\n")
            for iUnitAIType in range(int(UnitAITypes.NUM_UNITAI_TYPES)):
                pFile.write(
                    "Player %d, %s, Unit AI Type count: %d\n" %
                    (iPlayer, gc.getUnitAIInfo(iUnitAIType).getDescription(),
                     pPlayer.AI_totalUnitAIs(UnitAITypes(iUnitAIType))))

            pFile.write("\n\n")

            pFile.write("Unit Info:\n")
            pFile.write("----------\n")
            iNumUnits = pPlayer.getNumUnits()

            if (iNumUnits == 0):
                pFile.write("No Units")
            else:
                pLoopUnitTuple = pPlayer.firstUnit(False)
                while (pLoopUnitTuple[0] != None):
                    pUnit = pLoopUnitTuple[0]
                    pFile.write("Player %d, Unit ID: %d, %s\n" %
                                (iPlayer, pUnit.getID(),
                                 CvUtil.convertToStr(pUnit.getName())))

                    pFile.write("X: %d, Y: %d\n" %
                                (pUnit.getX(), pUnit.getY()))
                    pFile.write("Damage: %d\n" % pUnit.getDamage())
                    #pFile.write("Experience: %d\n" % pUnit.getExperienceTimes100() )
                    pFile.write("Experience: %d\n" % pUnit.getExperience())
                    pFile.write("Level: %d\n" % pUnit.getLevel())
                    #pFile.write("Promotions:\n")
                    #for j in range(gc.getNumPromotionInfos()):
                    #	if (pUnit.isHasPromotion(j)):
                    #		pFile.write("%s\n" % (CvUtil.convertToStr(gc.getPromotionInfo(j).getDescription()) ))

                    pLoopUnitTuple = pPlayer.nextUnit(pLoopUnitTuple[1], False)
                    pFile.write("\n")

            if not pPlayer.isBarbarian():  # advc.003n
                pFile.write("\n\n")
                pFile.write("Attitude Info:\n")
                pFile.write("----------\n")

                iLoopPlayer = 0
                # <advc.003n> was MAX_PLAYERS
                for iLoopPlayer in range(gc.getMAX_CIV_PLAYERS()):
                    if iPlayer == iLoopPlayer:
                        continue  # </advc.003n>
                    pLoopPlayer = gc.getPlayer(iLoopPlayer)
                    pFile.write(
                        "Players %d - %d, Attitude: %d (Note, actual attitudeval number is used for the OOS checksum.)\n"
                        % (iPlayer, iLoopPlayer,
                           pPlayer.AI_getAttitude(iLoopPlayer)))

            pFile.write("\n\n")

            pFile.write("City Info:\n")
            pFile.write("----------\n")
            iNumCities = pPlayer.getNumCities()

            if (iNumCities == 0):
                pFile.write("No Cities")
            else:  # advc: Don't print this for each city
                pFile.write(
                    "(Events that have occurred are also used for the checksum.)\n"
                )
                pLoopCityTuple = pPlayer.firstCity(False)
                while (pLoopCityTuple[0] != None):
                    pCity = pLoopCityTuple[0]
                    pFile.write("Player %d, City ID: %d, %s, X: %d, Y: %d\n" %
                                (iPlayer, pCity.getID(),
                                 CvUtil.convertToStr(pCity.getName()),
                                 pCity.getX(), pCity.getY()))

                    pFile.write(
                        "Religions and corporations present are also used for the checksum.\n"
                    )
                    #pFile.write("Founded: %d\n" % pCity.getGameTurnFounded() )
                    #pFile.write("Population: %d\n" % pCity.getPopulation() )
                    #pFile.write("Buildings: %d\n" % pCity.getNumBuildings() )
                    #pFile.write("Improved Plots: %d\n" % pCity.countNumImprovedPlots() )
                    #pFile.write("Producing: %s\n" % pCity.getProductionName() )
                    #pFile.write("Turns remaining for production: %d\n" % pCity.getProductionTurnsLeft() )
                    pFile.write(
                        "%d happiness, %d unhappiness, %d health, %d unhealth, %d food\n"
                        % (pCity.happyLevel(), pCity.unhappyLevel(0),
                           pCity.goodHealth(), pCity.badHealth(False),
                           pCity.getFood()))
                    # advc.007:
                    pFile.write("Needed floating defenders: %d\n" %
                                pCity.AI_neededFloatingDefenders())
                    #pFile.write("%d Tiles Worked, %d Specialists, %d Great People\n" % (pCity.getWorkingPopulation(), pCity.getSpecialistPopulation(), pCity.getNumGreatPeople()) )
                    #pFile.write("City radius: %d\n" % pCity.getPlotRadius() )

                    pLoopCityTuple = pPlayer.nextCity(pLoopCityTuple[1], False)
                    pFile.write("\n")

            # Space at end of player's info
            pFile.write("\n\n")

    # Restore current language
    CyGame().setCurrentLanguage(iLanguage)

    # Close file

    pFile.close()
예제 #31
0
    def updateInfoPanel(self, argsList=None):
        screen = self.getScreen()

        if argsList:
            actions = argsList
        else:
            actions = cs.getActions(self.iLeftPlayer)

        if self.iActivePlayer == self.iLeftPlayer:
            sPlayerName = self.sRightName
        else:
            sPlayerName = self.sLeftName

        nbActions = len(actions)
        if nbActions > 1: actions.reverse()

        i = 0
        for act in actions:
            szTextID = self.TEXT_INFO_IDS[i]
            szText = u""
            sActTag = act[0]

            if sActTag == "gameStart":
                iPlayerAction = act[1]
                if self.iActivePlayer == iPlayerAction:
                    sDrawCard = CvUtil.convertToStr(
                        localText.getText("TXT_KEY_SOMNIUM_DRAW", ()))
                    szText = localText.getText(
                        "TXT_KEY_SOMNIUM_WIN_TOSS", ()
                    ) + self.colorLight + u". " + u"</color>" + localText.getText(
                        "TXT_KEY_SOMNIUM_PRESS_BUTTON", (sDrawCard, ))
                else:
                    szText = localText.getText(
                        "TXT_KEY_SOMNIUM_WIN_TOSS_PLAYER", (sPlayerName, ))
                    if self.gameMP:
                        szText += self.colorLight + u"." + u"</color>"
                    else:
                        szText += self.colorLight + u". " + u"</color>"
                        sEndTurn = CvUtil.convertToStr(
                            localText.getText("TXT_KEY_SOMNIUM_END_TURN", ()))
                        szText += localText.getText(
                            "TXT_KEY_SOMNIUM_PRESS_BUTTON", (sEndTurn, ))

            elif sActTag == "drawCard":
                iPlayerAction = act[1]
                iCardType = act[2]
                iCardNumber = act[3]

                lArgs = []
                if iCardType > 9:
                    lArgs.append(
                        CvUtil.convertToStr(
                            localText.getText(
                                "TXT_KEY_SOMNIUM_TYPE_%d" % iCardType, ())))
                    if self.iActivePlayer == iPlayerAction:
                        sTxtKey = "TXT_KEY_SOMNIUM_DRAW_SPECIAL_CARD_INFO"
                    else:
                        sTxtKey = "TXT_KEY_SOMNIUM_DRAW_SPECIAL_CARD_INFO_PLAYER"
                        lArgs.append(sPlayerName)
                else:
                    lArgs.append(iCardNumber)
                    lArgs.append(
                        CvUtil.convertToStr(
                            localText.getText(
                                "TXT_KEY_SOMNIUM_TYPE_%d" % iCardType, ())))
                    if self.iActivePlayer == iPlayerAction:
                        sTxtKey = "TXT_KEY_SOMNIUM_DRAW_CARD_INFO"
                    else:
                        sTxtKey = "TXT_KEY_SOMNIUM_DRAW_CARD_INFO_PLAYER"
                        lArgs.append(sPlayerName)
                szText = localText.getText(sTxtKey, tuple(lArgs))

            elif sActTag == "DiscardDeath":
                iPlayerAction = act[1]
                sDeath = CvUtil.convertToStr(
                    localText.getText("TXT_KEY_SOMNIUM_TYPE_11", ()))
                if self.iActivePlayer == iPlayerAction:
                    szText = localText.getText("TXT_KEY_SOMNIUM_DEATH_DISCARD",
                                               (sDeath, ))
                else:
                    szText = localText.getText(
                        "TXT_KEY_SOMNIUM_DEATH_DISCARD_PLAYER",
                        (sDeath, sPlayerName))

            elif sActTag == "EndGame":
                iLooser = act[1]
                if iLooser == -1:
                    szText = localText.getText(
                        "TXT_KEY_SOMNIUM_DRAW_GAME_INFO", (sPlayerName, ))
                elif self.iActivePlayer == iLooser:
                    szText = localText.getText(
                        "TXT_KEY_SOMNIUM_LOOSE_GAME_INFO", ())
                else:
                    szText = localText.getText("TXT_KEY_SOMNIUM_WIN_GAME_INFO",
                                               ())

            elif sActTag == "BeginTurn":
                iPlayerBegin = act[1]
                if self.iActivePlayer == iPlayerBegin:
                    sDrawCard = CvUtil.convertToStr(
                        localText.getText("TXT_KEY_SOMNIUM_DRAW", ()))
                    szText = localText.getText("TXT_KEY_SOMNIUM_BEGIN_TURN",
                                               ())
                    szText += self.colorLight + u" " + u"</color>"
                    szText += localText.getText("TXT_KEY_SOMNIUM_PRESS_BUTTON",
                                                (sDrawCard, ))
                else:
                    szText = localText.getText(
                        "TXT_KEY_SOMNIUM_BEGIN_TURN_PLAYER", (sPlayerName, ))

            elif sActTag == "JokerSteal":
                iStealPlayer, iStolenPlayer, iCardType, iCardValue = act[1:]
                sJoker = CvUtil.convertToStr(
                    localText.getText("TXT_KEY_SOMNIUM_TYPE_10", ()))
                sCardType = CvUtil.convertToStr(
                    localText.getText("TXT_KEY_SOMNIUM_TYPE_%d" % iCardType,
                                      ()))
                if self.iActivePlayer == iStolenPlayer:
                    szText = localText.getText(
                        "TXT_KEY_SOMNIUM_JOKER_STEAL_PLAYER",
                        (sCardType, iCardValue, sJoker, sPlayerName))
                else:
                    szText = localText.getText(
                        "TXT_KEY_SOMNIUM_JOKER_STEAL",
                        (sCardType, iCardValue, sJoker, sPlayerName))

            elif sActTag == "JokerNoUse":
                iJokPlayer = act[1]
                sJoker = CvUtil.convertToStr(
                    localText.getText("TXT_KEY_SOMNIUM_TYPE_10", ()))
                if self.iActivePlayer == iJokPlayer:
                    szText = localText.getText("TXT_KEY_SOMNIUM_JOKER_NO_USE",
                                               (sJoker, sPlayerName))
                else:
                    szText = localText.getText(
                        "TXT_KEY_SOMNIUM_JOKER_NO_USE_PLAYER",
                        (sJoker, sPlayerName))

            elif sActTag == "DiscardSameType":
                iDiscardPlayer, iCardType = act[1:]
                sCardType = CvUtil.convertToStr(
                    localText.getText("TXT_KEY_SOMNIUM_TYPE_%d" % iCardType,
                                      ()))
                if self.iActivePlayer == iDiscardPlayer:
                    szText = localText.getText(
                        "TXT_KEY_SOMNIUM_SAME_TYPE_DISCARD", (sCardType, ))
                else:
                    szText = localText.getText(
                        "TXT_KEY_SOMNIUM_SAME_TYPE_DISCARD_PLAYER",
                        (sCardType, sPlayerName))

            elif sActTag == "BankCard":
                iBankPlayer, iPoints = act[1:]
                if self.iActivePlayer == iBankPlayer:
                    szText = localText.getText("TXT_KEY_SOMNIUM_BANK_CARDS",
                                               (iPoints, ))
                else:
                    szText = localText.getText(
                        "TXT_KEY_SOMNIUM_BANK_CARDS_PLAYER",
                        (iPoints, sPlayerName))

            elif sActTag == "HUJokerPickCard":
                iPickPlayer = act[1]
                if self.iActivePlayer == iPickPlayer:
                    szText = localText.getText(
                        "TXT_KEY_SOMNIUM_JOKER_PICK_CARD", (sPlayerName, ))
                else:
                    szText = localText.getText(
                        "TXT_KEY_SOMNIUM_JOKER_PICK_CARD_PLAYER",
                        (sPlayerName, ))

            else:
                continue

            szText = u"<font=3>" + szText + u"</font>"
            screen.modifyLabel(szTextID, u"", CvUtil.FONT_LEFT_JUSTIFY)
            screen.modifyLabel(szTextID, szText, CvUtil.FONT_LEFT_JUSTIFY)
            i += 1
            if i == 5: break

        if i < 5:
            for j in range(i, 5):
                szTextID = self.TEXT_INFO_IDS[j]
                szText = u""
                screen.modifyLabel(szTextID, szText, CvUtil.FONT_LEFT_JUSTIFY)
예제 #32
0
def updateRevolutionIndices( argsList ) :
	owner,playerType,pCity,bConquest,bTrade = argsList

	newOwnerID = pCity.getOwner()
	newOwner = GC.getPlayer(newOwnerID)
	newOwnerCiv = newOwner.getCivilizationType()
	oldOwnerID = pCity.getPreviousOwner()
	orgOwnerID = pCity.getOriginalOwner()

	if( newOwner.isNPC() ) :
		return

	newRevIdx = 400
	changeRevIdx = -40

	if( bConquest ) :
		# Occupied cities also rack up rev points each turn
		newRevIdx += pCity.getRevolutionIndex()/4
		newRevIdx = min( [newRevIdx, 600] )

		if( pCity.plot().calculateCulturePercent( newOwnerID ) > 90 ) :
			changeRevIdx -= 75
			newRevIdx -= 100
		elif( pCity.plot().calculateCulturePercent( newOwnerID ) > 40 ) :
			changeRevIdx -= 35
			newRevIdx -= 60
		elif( pCity.plot().calculateCulturePercent( newOwnerID ) > 20 ) :
			changeRevIdx -= 30

	elif( bTrade ) :
		newRevIdx += pCity.getRevolutionIndex()/3
		newRevIdx = min( [newRevIdx, 650] )

		if( pCity.plot().calculateCulturePercent( newOwnerID ) > 90 ) :
			newRevIdx -= 50

	else :
		# Probably cultural conversion
		newRevIdx -= 100
		if( pCity.plot().calculateCulturePercent( newOwnerID ) > 50 ) :
			changeRevIdx -= 25


	if( newOwner.isRebel() and newOwnerCiv == RevData.getCityVal(pCity, 'RevolutionCiv') ) :
		changeRevIdx -= 50
		newRevIdx -= 200
	elif( newOwnerID == pCity.getOriginalOwner() ) :
		changeRevIdx -= 25
		newRevIdx -= 100

	if( pCity.getHighestPopulation() < 6 ) :
		changeRevIdx += 20
		newRevIdx -= 50

	changeRevIdx = int(math.floor( cityAcquiredModifier*changeRevIdx + .5 ))

	print "	Revolt - Acquisition of %s by %s reduces rev indices by %d" %(pCity.getName(), newOwner.getCivilizationDescription(0), changeRevIdx)

	iCityID = pCity.getID()
	for pListCity in newOwner.cities():
		if pListCity.getID() != iCityID:
			pListCity.changeRevolutionIndex(changeRevIdx)
			revIdxHist = RevData.getCityVal(pListCity,'RevIdxHistory')
			revIdxHist['Events'][0] += changeRevIdx
			RevData.updateCityVal(pListCity, 'RevIdxHistory', revIdxHist)

	print "	Revolt - New rev idx for %s is %d" %(pCity.getName(), newRevIdx)

	pCity.setRevolutionIndex( newRevIdx )
	pCity.setRevIndexAverage( newRevIdx )
	pCity.setRevolutionCounter( acquiredTurns )
	pCity.setReinforcementCounter( 0 )
	RevData.updateCityVal( pCity, 'RevIdxHistory', RevDefs.initRevIdxHistory() )

	if newOwner.isRebel():
		if newOwner.getNumCities() > 1 and RevData.revObjectGetVal(newOwner, 'CapitalName') == CvUtil.convertToStr(pCity.getName()):
			# Rebel has captured their instigator city, make this their capital
			print "[REV] Rebel %s have captured their instigator city, %s!  Moving capital." %(newOwner.getCivilizationDescription(0), pCity.getName())
			if newOwner.isHuman():
				# TODO: support this with a popup question
				pass
			else:
				eCapitalBuilding = GC.getInfoTypeForString(RevDefs.sXMLPalace)
				oldCapital = newOwner.getCapitalCity()
				oldCapital.setNumRealBuilding(eCapitalBuilding, 0)
				pCity.setNumRealBuilding(eCapitalBuilding, 1)

		# Ripple effects through other rebellious cities
		for cityX in GC.getPlayer(oldOwnerID).cities():
			reinfCount = cityX.getReinforcementCounter()
			if reinfCount > 2 and RevData.getCityVal(cityX, 'RevolutionCiv') == newOwner.getCivilizationType():
				if reinfCount < 5:
					reinfCount = 2
				else: reinfCount -= 2

				print "[REV] Accelerating reinforcement in " + cityX.getName()
				# Setting below two will turn off reinforcement
				if reinfCount < 2: reinfCount = 2
				cityX.setReinforcementCounter(reinfCount)
예제 #33
0
	def addFeatures(self):
		# First add the fractal-based features: Nebula, Asteroids, Radiation.
		for iX in range(self.iGridW):
			for iY in range(self.iGridH):
				self.addFeaturesAtPlot(iX, iY)
		
		# Now add the blunt force random features: Holes, Novas, Systems.
		#
		# These values control the rate of incidence for Hole, Nova, System.
		# As of this writing, all are determined strictly by ratio of total plot count.
		# Some randomness could be introduced by adding dice rolls to the formulae.
		#
		
		# Custom Map Option Stuff
		iStarSystemDensity = self.map.getCustomMapOption(0)
		iStarSystemMod = 0
		if (iStarSystemDensity == 0):	# Very High Density
			iStarSystemMod = -25
		elif (iStarSystemDensity == 1):	# High Density
			iStarSystemMod = -10
		elif (iStarSystemDensity == 2):	# Normal Density
			iStarSystemMod = -5
		elif (iStarSystemDensity == 3):	# Low Density
			iStarSystemMod = 50
		
		iHostileFeatureDensity = self.map.getCustomMapOption(2)
		iHostileFeatureMod = 0
		if (iHostileFeatureDensity == 0):	# Very High Density
			iHostileFeatureMod = -150
		elif (iHostileFeatureDensity == 1):	# High Density
			iHostileFeatureMod = 0
		elif (iHostileFeatureDensity == 2):	# Normal Density
			iHostileFeatureMod = 250
		elif (iHostileFeatureDensity == 3):	# Low Density
			iHostileFeatureMod = 400
		
		iNumPlots = self.iGridW * self.iGridH
#		iNumSolarSystems = int(iNumPlots / (90 + iStarSystemMod))
		iNumSolarSystems = int(iNumPlots / (120 + iStarSystemMod))
		iNumBlackHoles = int(iNumPlots / (600 + iHostileFeatureMod))
		iNumSupernovas = int(iNumPlots / (400 + iHostileFeatureMod))
		#print('------------------------')
		#print('Solar Systems: ', iNumSolarSystems)
		#print('Black Holes: ', iNumBlackHoles)
		#print('Supernovas: ', iNumSupernovas)
		#print('------------------------')
		
		# Reset globals which have to do with player starting positions
#		#print("Clearing global arrays when new map is made")
		global g_apSolarSystemPlotList
		global g_aiPickedPlotForPlayer
		g_apSolarSystemPlotList = []
		g_aiPickedPlotForPlayer = []
#		#print("g_apSolarSystemPlotList")
#		#print("g_aiPickedPlotForPlayer")
#		#print(g_apSolarSystemPlotList)
#		#print(g_aiPickedPlotForPlayer)
		
		engine = CyEngine()
		game = CyGame()
		
		#Define wormhole order based on map option
		iWormholeOrder = self.map.getCustomMapOption(4)
		if iWormholeOrder == 0:
			iTinyWormhole = self.featureWormhole
			iStandardWormhole = self.featureRedWormhole
			iHugeWormhole = self.featurePurpleWormhole
		if iWormholeOrder == 1:
			iTinyWormhole = self.featureWormhole
			iStandardWormhole = self.featurePurpleWormhole
			iHugeWormhole = self.featureRedWormhole
		if iWormholeOrder == 2:
			iTinyWormhole = self.featureRedWormhole
			iStandardWormhole = self.featureWormhole
			iHugeWormhole = self.featurePurpleWormhole
		if iWormholeOrder == 3:
			iTinyWormhole = self.featureRedWormhole
			iStandardWormhole = self.featurePurpleWormhole
			iHugeWormhole = self.featureWormhole
		if iWormholeOrder == 4:
			iTinyWormhole = self.featurePurpleWormhole
			iStandardWormhole = self.featureWormhole
			iHugeWormhole = self.featureWormhole
		if iWormholeOrder == 5:
			iTinyWormhole = self.featurePurpleWormhole
			iStandardWormhole = self.featureRedWormhole
			iHugeWormhole = self.featureWormhole
		
		# Solar Systems
		for iLoop in range(iNumSolarSystems):
			iAttemptsLeft = 400
			while iAttemptsLeft > 0:
				iUsableWidth = self.iGridW - 4
				iUsableHeight = self.iGridH - 4
				iX = 2 + self.mapRand.get(iUsableWidth, "Solar System X Check - Final Frontier PYTHON")
				iY = 2 + self.mapRand.get(iUsableHeight, "Solar System Y Check - Final Frontier PYTHON")
				
				iStartS = 3
				iStartL = 4
				
				if (iStarSystemDensity == 0): # High density, have to pack Star Systems in closer with stuff to fit everything in
					iStartS -= 1
					iStartL -= 1
				
				# Must not only check the plot itself, but also every plot in its fat cross.
				bAllow = True
				for iSolarX in range((iX - iStartS), (iX + iStartL)):
					if bAllow == False: break
					for iSolarY in range((iY - iStartS), (iY + iStartL)):
						if ((iSolarX == iX - iStartS) or (iSolarX == iX + iStartS)) and ((iSolarY == iY - iStartS) or (iSolarY == iY + iStartS)):
							continue #Skip the four corners.
						else:
							pPlot = self.map.sPlot(iSolarX, iSolarY)
							if (pPlot.getFeatureType() == self.featureFloodPlain or pPlot.getFeatureType() == self.featureIce or pPlot.getFeatureType() == self.featureSupernovaArea or pPlot.getFeatureType() == self.featureGravField):
								bAllow = False
								break
				if bAllow == False:
					iAttemptsLeft -= 1
					continue
				else: # Can place solar system here!
					#print("Adding Solar System to %d, %d" %(pPlot.getX(), pPlot.getY()))
					CyMap().plot(iX, iY).setFeatureType(self.featureSolarSystem, 0)
					#print('+++', 'Solar System placed at', iX, iY, '---', 'Attempts used: ', (401 - iAttemptsLeft), '+++')
					
					for xLoop in range((iX - iStartS), (iX + iStartL)):
						for yLoop in range((iY - iStartS), (iY + iStartL)):
							if ((xLoop == iX - iStartS) or (xLoop == iX + iStartS)) and ((yLoop == iY - iStartS) or (yLoop == iY + iStartS)):
								continue #Skip the four corners.
							elif xLoop == iX and yLoop == iY:
								continue #Don't overwrite the original feature!
							else:
								pEffectPlot = self.map.sPlot(xLoop, yLoop)
								pPlot.setFeatureType(self.featureFloodPlain, 0)
					break #Solar System placed, effects placed, break loop.
#			else:
				#print('Failed to place Solar System Number', (iLoop + 1))
		#print('------------------------')
#Wormholes!
		#Wormholes
		if not self.map.getWorldSize() == self.gc.getInfoTypeForString("WORLDSIZE_DUEL"):
			for iLoop in range(2):
				iAttemptsLeft = 20000
				while iAttemptsLeft > 0:
					iUsableWidth = self.iGridW - 6
					iUsableHeight = self.iGridH - 6
					iX = 3 + self.mapRand.get(iUsableWidth, "Black Hole X Check - Final Frontier PYTHON")
					iY = 3 + self.mapRand.get(iUsableHeight, "Black Hole Y Check - Final Frontier PYTHON")

					bAllow = self.checkWormholeRoom(self.map.plot(iX, iY), iTinyWormhole)

					if bAllow == False:
						iAttemptsLeft -= 1
						continue

					pPlot = self.map.sPlot(iX, iY)
					if (pPlot.getFeatureType() == FeatureTypes.NO_FEATURE): #Place Wormhole here.
						pPlot.setFeatureType(iTinyWormhole, 0)
						if self.map.getCustomMapOption(3) == 0:
							engine.addLandmark(pPlot, CvUtil.convertToStr(self.gc.getFeatureInfo(pPlot.getFeatureType()).getDescription()))
						#print('+++', 'Wormhole placed at', iX, iY, '---', 'Attempts used: ', (201 - iAttemptsLeft), '+++')
						for xLoop in range((iX - 2), (iX + 3)):
							for yLoop in range((iY - 2), (iY + 3)):
								if ((xLoop == iX - 2) or (xLoop == iX + 2)) and ((yLoop == iY - 2) or (yLoop == iY + 2)):
									continue #Skip the four corners.
								elif xLoop == iX and yLoop == iY:
									continue #Don't overwrite the original feature!
								else:
									pEffectPlot = self.map.sPlot(xLoop, yLoop)
									pPlot.setFeatureType(self.featureFloodPlain, 0)
						break #Wormhole placed, effects placed, break loop.
					else:
						iAttemptsLeft -= 1
		#Red Wormholes
		if (self.map.getWorldSize() == self.gc.getInfoTypeForString("WORLDSIZE_HUGE") or self.map.getWorldSize() == self.gc.getInfoTypeForString("WORLDSIZE_LARGE") or self.map.getWorldSize() == self.gc.getInfoTypeForString("WORLDSIZE_STANDARD")):
			for iLoop in range(2):
				iAttemptsLeft = 20000
				while iAttemptsLeft > 0:
					iUsableWidth = self.iGridW - 6
					iUsableHeight = self.iGridH - 6
					iX = 3 + self.mapRand.get(iUsableWidth, "Black Hole X Check - Final Frontier PYTHON")
					iY = 3 + self.mapRand.get(iUsableHeight, "Black Hole Y Check - Final Frontier PYTHON")

					bAllow = self.checkWormholeRoom(self.map.plot(iX, iY), iStandardWormhole)

					if bAllow == False:
						iAttemptsLeft -= 1
						continue

					pPlot = self.map.sPlot(iX, iY)
					if (pPlot.getFeatureType() == FeatureTypes.NO_FEATURE): #Place Red Wormhole here.
						pPlot.setFeatureType(iStandardWormhole, 0)
						if self.map.getCustomMapOption(3) == 0:
							engine.addLandmark(pPlot, CvUtil.convertToStr(self.gc.getFeatureInfo(pPlot.getFeatureType()).getDescription()))
						#print('+++', 'Black Hole placed at', iX, iY, '---', 'Attempts used: ', (201 - iAttemptsLeft), '+++')
						for xLoop in range((iX - 2), (iX + 3)):
							for yLoop in range((iY - 2), (iY + 3)):
								if ((xLoop == iX - 2) or (xLoop == iX + 2)) and ((yLoop == iY - 2) or (yLoop == iY + 2)):
									continue #Skip the four corners.
								elif xLoop == iX and yLoop == iY:
									continue #Don't overwrite the original feature!
								else:
									pEffectPlot = self.map.sPlot(xLoop, yLoop)
									pPlot.setFeatureType(self.featureFloodPlain, 0)
						break #Red Wormhole placed, effects placed, break loop.
					else:
						iAttemptsLeft -= 1
		#Purple Wormholes
		if self.map.getWorldSize() == self.gc.getInfoTypeForString("WORLDSIZE_HUGE"):
			for iLoop in range(2):
				iAttemptsLeft = 20000
				while iAttemptsLeft > 0:
					iUsableWidth = self.iGridW - 6
					iUsableHeight = self.iGridH - 6
					iX = 3 + self.mapRand.get(iUsableWidth, "Black Hole X Check - Final Frontier PYTHON")
					iY = 3 + self.mapRand.get(iUsableHeight, "Black Hole Y Check - Final Frontier PYTHON")

					# Must not only check the plot itself, but also every plot in its fat cross.
					bAllow = self.checkWormholeRoom(self.map.plot(iX, iY), iHugeWormhole)

					if bAllow == False:
						iAttemptsLeft -= 1
						continue

					pPlot = self.map.sPlot(iX, iY)
					if (pPlot.getFeatureType() == FeatureTypes.NO_FEATURE): #Place Purple Wormhole here.
						pPlot.setFeatureType(iHugeWormhole, 0)
						if self.map.getCustomMapOption(3) == 0:
							engine.addLandmark(pPlot, CvUtil.convertToStr(self.gc.getFeatureInfo(pPlot.getFeatureType()).getDescription()))
						#print('+++', 'Black Hole placed at', iX, iY, '---', 'Attempts used: ', (201 - iAttemptsLeft), '+++')
						for xLoop in range((iX - 2), (iX + 3)):
							for yLoop in range((iY - 2), (iY + 3)):
								if ((xLoop == iX - 2) or (xLoop == iX + 2)) and ((yLoop == iY - 2) or (yLoop == iY + 2)):
									continue #Skip the four corners.
								elif xLoop == iX and yLoop == iY:
									continue #Don't overwrite the original feature!
								else:
									pEffectPlot = self.map.sPlot(xLoop, yLoop)
									pPlot.setFeatureType(self.featureFloodPlain, 0)
						break #Purple Wormhole placed, effects placed, break loop.
					else:
						iAttemptsLeft -= 1
#End of wormholes!
		# Black Holes
		for iLoop in range(iNumBlackHoles):
			iAttemptsLeft = 200
			while iAttemptsLeft > 0:
				iUsableWidth = self.iGridW - 6
				iUsableHeight = self.iGridH - 6
				iX = 3 + self.mapRand.get(iUsableWidth, "Black Hole X Check - Final Frontier PYTHON")
				iY = 3 + self.mapRand.get(iUsableHeight, "Black Hole Y Check - Final Frontier PYTHON")

				# Must not only check the plot itself, but also every plot in its fat cross.
				bAllow = True
				for iHoleX in range((iX - 2), (iX + 3)):
					if bAllow == False: break
					for iHoleY in range((iY - 2), (iY + 3)):
						if ((iHoleX == iX - 2) or (iHoleX == iX + 2)) and ((iHoleY == iY - 2) or (iHoleY == iY + 2)):
							continue #Skip the four corners.
						else:
							pPlot = self.map.sPlot(iHoleX, iHoleY)
							if (pPlot.getFeatureType() == self.featureFloodPlain or pPlot.getFeatureType() == self.featureIce or pPlot.getFeatureType() == self.featureSupernovaArea or pPlot.getFeatureType() == self.featureGravField):
								bAllow = False
								break
				if bAllow == False:
					iAttemptsLeft -= 1
					continue

				pPlot = self.map.sPlot(iX, iY)
				if (pPlot.getFeatureType() == FeatureTypes.NO_FEATURE): #Place Black Hole here.
					pPlot.setFeatureType(self.featureOasis, 0)
					#print('+++', 'Black Hole placed at', iX, iY, '---', 'Attempts used: ', (201 - iAttemptsLeft), '+++')
					for xLoop in range((iX - 2), (iX + 3)):
						for yLoop in range((iY - 2), (iY + 3)):
							if ((xLoop == iX - 2) or (xLoop == iX + 2)) and ((yLoop == iY - 2) or (yLoop == iY + 2)):
								continue #Skip the four corners.
							elif xLoop == iX and yLoop == iY:
								continue #Don't overwrite the original feature!
							else:
								pEffectPlot = self.map.sPlot(xLoop, yLoop)
								pPlot.setFeatureType(self.featureGravField, 0)
					break #Black Hole placed, effects placed, break loop.
				else:
					iAttemptsLeft -= 1
#			else:
				#print('Failed to place Black Hole Number', (iLoop + 1))
		#print('------------------------')
		
		# Supernovas
		for iLoop in range(iNumSupernovas):
			iAttemptsLeft = 300
			while iAttemptsLeft > 0:
				iUsableWidth = self.iGridW - 4
				iUsableHeight = self.iGridH - 4
				iX = 2 + self.mapRand.get(iUsableWidth, "Supernova X Check - Final Frontier PYTHON")
				iY = 2 + self.mapRand.get(iUsableHeight, "Supernova Y Check - Final Frontier PYTHON")

				# Must not only check the plot itself, but also every plot in its fat cross.
				bAllow = True
				for iNovaX in range((iX - 2), (iX + 3)):
					if bAllow == False: break
					for iNovaY in range((iY - 2), (iY + 3)):
						if ((iNovaX == iX - 2) or (iNovaX == iX + 2)) and ((iNovaY == iY - 2) or (iNovaY == iY + 2)):
							continue #Skip the four corners.
						else:
							pPlot = self.map.sPlot(iNovaX, iNovaY)
							if (pPlot.getFeatureType() == self.featureFloodPlain or pPlot.getFeatureType() == self.featureIce or pPlot.getFeatureType() == self.featureSupernovaArea or pPlot.getFeatureType() == self.featureGravField):
								bAllow = False
								break
				if bAllow == False:
					iAttemptsLeft -= 1
					continue

				pPlot = self.map.sPlot(iX, iY)
				if (pPlot.getFeatureType() == FeatureTypes.NO_FEATURE): #Place Supernova here.
					pPlot.setFeatureType(self.featureJungle, 0)
					#print('+++', 'Supernova placed at', iX, iY, '---', 'Attempts used: ', (301 - iAttemptsLeft), '+++')
					for xLoop in range((iX - 2), (iX + 3)):
						for yLoop in range((iY - 2), (iY + 3)):
							if ((xLoop == iX - 2) or (xLoop == iX + 2)) and ((yLoop == iY - 2) or (yLoop == iY + 2)):
								continue #Skip the four corners.
							elif xLoop == iX and yLoop == iY:
								continue #Don't overwrite the original feature!
							else:
								pEffectPlot = self.map.sPlot(xLoop, yLoop)
								pEffectPlot.setFeatureType(self.featureSupernovaArea, 0)
#								#print("Adding Supernova Damage Zone to (%d, %d)" %(xLoop, yLoop))
					break #Supernova placed, effects placed, break loop.
				else:
					iAttemptsLeft -= 1
#			else:
				#print('Failed to place Supernova Number', (iLoop + 1))
		#print('------------------------')
		
		# Now remove all the placeholder Flood Plains.
		#print('-')
		#print('------------------------')
		for iPlotLoop in range(CyMap().numPlots()):
			pPlot = CyMap().plotByIndex(iPlotLoop)
			if (pPlot.getFeatureType() == self.featureFloodPlain):
				pPlot.setFeatureType(-1, -1)
예제 #34
0
	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]
예제 #35
0
	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]
예제 #36
0
	def __eventWBPlotScriptPopupApply(self, playerID, userData, popupReturn):
		sScript = popupReturn.getEditBoxString(0)
		pPlot = CyMap().plot(userData[0], userData[1])
		pPlot.setScriptData(CvUtil.convertToStr(sScript))
		WBPlotScreen.WBPlotScreen().placeScript()
		return
예제 #37
0
def writeLog():
    import SystemPaths as SP
    import CvUtil
    GC = CyGlobalContext()
    MAP = GC.getMap()
    GAME = GC.getGame()
    iPlayer = GAME.getActivePlayer()
    szName = CvUtil.convertToStr(GC.getActivePlayer().getName())
    szName = SP.userDir + "\\Logs\\%s - Player %d - Turn %d OOSLog.txt" % (
        szName, iPlayer, GAME.getGameTurn())
    pFile = open(szName, "w")

    SEP = "-----------------------------------------------------------------\n"

    # Backup current language
    iLanguage = GAME.getCurrentLanguage()
    # Force english language for logs
    GAME.setCurrentLanguage(0)

    # Global data
    pFile.write(2 * SEP + "\tGLOBALS\n" + 2 * SEP + "\n")

    pFile.write("Last MapRand Value: %d\n" % GAME.getMapRand().getSeed())
    pFile.write("Last SorenRand Value: %d\n" % GAME.getSorenRand().getSeed())

    pFile.write("Total num cities: %d\n" % GAME.getNumCities())
    pFile.write("Total population: %d\n" % GAME.getTotalPopulation())
    pFile.write("Total Deals: %d\n" % GAME.getNumDeals())

    pFile.write("Total owned plots: %d\n" % MAP.getOwnedPlots())
    pFile.write("Total num areas: %d\n\n\n" % MAP.getNumAreas())

    # Player data
    for iPlayer in xrange(GC.getMAX_PLAYERS()):
        pPlayer = GC.getPlayer(iPlayer)
        if pPlayer.isEverAlive():

            pFile.write(2 * SEP + "%s player %d: %s\n" %
                        (['NPC', 'Human'][pPlayer.isHuman()], iPlayer,
                         CvUtil.convertToStr(pPlayer.getName())))
            pFile.write(
                "  Civilization: %s\n" %
                CvUtil.convertToStr(pPlayer.getCivilizationDescriptionKey()))
            pFile.write("  Alive: %s\n" % pPlayer.isAlive())

            pFile.write(2 * SEP + "\n\nBasic data:\n-----------\n")

            pFile.write("Player %d Score: %d\n" %
                        (iPlayer, GAME.getPlayerScore(iPlayer)))
            pFile.write("Player %d Population: %d\n" %
                        (iPlayer, pPlayer.getTotalPopulation()))
            pFile.write("Player %d Total Land: %d\n" %
                        (iPlayer, pPlayer.getTotalLand()))
            pFile.write("Player %d Gold: %d\n" % (iPlayer, pPlayer.getGold()))
            pFile.write("Player %d Assets: %d\n" %
                        (iPlayer, pPlayer.getAssets()))
            pFile.write("Player %d Power: %d\n" %
                        (iPlayer, pPlayer.getPower()))
            pFile.write("Player %d Num Cities: %d\n" %
                        (iPlayer, pPlayer.getNumCities()))
            pFile.write("Player %d Num Units: %d\n" %
                        (iPlayer, pPlayer.getNumUnits()))
            pFile.write("Player %d Num Selection Groups: %d\n" %
                        (iPlayer, pPlayer.getNumSelectionGroups()))
            pFile.write("Player %d Difficulty: %d\n" %
                        (iPlayer, pPlayer.getHandicapType()))
            pFile.write(
                "Player %d State Religion: %s\n" %
                (iPlayer, CvUtil.convertToStr(pPlayer.getStateReligionKey())))
            pFile.write("Player %d Culture: %d\n" %
                        (iPlayer, pPlayer.getCulture()))

            pFile.write("\n\nYields:\n-------\n")

            for iYield in xrange(YieldTypes.NUM_YIELD_TYPES):
                pFile.write("Player %d %s Total Yield: %d\n" %
                            (iPlayer,
                             CvUtil.convertToStr(
                                 GC.getYieldInfo(iYield).getDescription()),
                             pPlayer.calculateTotalYield(iYield)))

            pFile.write("\n\nCommerce:\n---------\n")

            for iCommerce in xrange(CommerceTypes.NUM_COMMERCE_TYPES):
                pFile.write(
                    "Player %d %s Total Commerce: %d\n" %
                    (iPlayer,
                     CvUtil.convertToStr(
                         GC.getCommerceInfo(iCommerce).getDescription()),
                     pPlayer.getCommerceRate(CommerceTypes(iCommerce))))

            pFile.write("\n\nCity event history:\n-----------\n")

            if pPlayer.getNumCities():
                pCity, i = pPlayer.firstCity(False)
                while pCity:
                    bFirst = True
                    for iEvent in xrange(GC.getNumEventInfos()):
                        if pCity.isEventOccured(iEvent):
                            if bFirst:
                                pFile.write(
                                    "City: %s\n" %
                                    CvUtil.convertToStr(pCity.getName()))
                                bFirst = False
                            pFile.write("\t" + CvUtil.convertToStr(
                                GC.getEventInfo(iEvent).getDescription()) +
                                        "\n")
                    pCity, i = pPlayer.nextCity(i, False)

            pFile.write("\n\nCity Info:\n----------\n")

            if pPlayer.getNumCities():
                pCity, i = pPlayer.firstCity(False)
                while pCity:
                    pFile.write("City: %s\n" %
                                CvUtil.convertToStr(pCity.getName()))
                    pFile.write("X: %d, Y: %d\n" %
                                (pCity.getX(), pCity.getY()))
                    pFile.write("Population: %d\n" % (pCity.getPopulation()))
                    pFile.write("Buildings: %d\n" %
                                (pCity.getNumRealBuildings()))
                    pFile.write("Improved Plots: %d\n" %
                                (pCity.countNumImprovedPlots()))
                    pFile.write("Tiles Worked: %d, Specialists: %d\n" %
                                (pCity.getWorkingPopulation(),
                                 pCity.getSpecialistPopulation()))
                    pFile.write("Great People: %d\n" %
                                pCity.getNumGreatPeople())
                    pFile.write("Good Health: %d, Bad Health: %d\n" %
                                (pCity.goodHealth(), pCity.badHealth(False)))
                    pFile.write("Happy Level: %d, Unhappy Level: %d\n" %
                                (pCity.happyLevel(), pCity.unhappyLevel(0)))
                    pFile.write("Food: %d\n" % pCity.getFood())
                    pCity, i = pPlayer.nextCity(i, False)
            else:
                pFile.write("No Cities")

            pFile.write("\n\nBonus Info:\n-----------\n")

            for iBonus in xrange(GC.getNumBonusInfos()):
                szTemp = CvUtil.convertToStr(
                    GC.getBonusInfo(iBonus).getDescription())
                pFile.write(
                    "Player %d, %s, Number Available: %d\n" %
                    (iPlayer, szTemp, pPlayer.getNumAvailableBonuses(iBonus)))
                pFile.write("Player %d, %s, Import: %d\n" %
                            (iPlayer, szTemp, pPlayer.getBonusImport(iBonus)))
                pFile.write("Player %d, %s, Export: %d\n\n" %
                            (iPlayer, szTemp, pPlayer.getBonusExport(iBonus)))

            pFile.write("\n\nImprovement Info:\n-----------------\n")

            for iImprovement in xrange(GC.getNumImprovementInfos()):
                pFile.write(
                    "Player %d, %s, Improvement count: %d\n" %
                    (iPlayer,
                     CvUtil.convertToStr(
                         GC.getImprovementInfo(iImprovement).getDescription()),
                     pPlayer.getImprovementCount(iImprovement)))

            pFile.write("\n\nBuilding Info:\n--------------------\n")

            for iBuilding in xrange(GC.getNumBuildingInfos()):
                pFile.write(
                    "Player %d, %s, Building class count plus making: %d\n" %
                    (iPlayer,
                     CvUtil.convertToStr(
                         GC.getBuildingInfo(iBuilding).getDescription()),
                     pPlayer.getBuildingCountPlusMaking(iBuilding)))

            pFile.write("\n\nUnit Class Info:\n--------------------\n")

            for iUnit in xrange(GC.getNumUnitInfos()):
                pFile.write(
                    "Player %d, %s, Unit class count plus training: %d\n" %
                    (iPlayer,
                     CvUtil.convertToStr(
                         GC.getUnitInfo(iUnit).getDescription()),
                     pPlayer.getUnitCountPlusMaking(iUnit)))

            pFile.write("\n\nUnitAI Types Info:\n------------------\n")

            for iUnitAIType in xrange(int(UnitAITypes.NUM_UNITAI_TYPES)):
                pFile.write(
                    "Player %d, %s, Unit AI Type count: %d\n" %
                    (iPlayer, GC.getUnitAIInfo(iUnitAIType).getType(),
                     pPlayer.AI_totalUnitAIs(UnitAITypes(iUnitAIType))))

            pFile.write("\n\nCity Religions:\n-----------\n")

            if pPlayer.getNumCities():
                pCity, i = pPlayer.firstCity(False)
                while pCity:
                    bFirst = True
                    for iReligion in xrange(GC.getNumReligionInfos()):
                        if pCity.isHasReligion(iReligion):
                            if bFirst:
                                pFile.write(
                                    "City: %s\n" %
                                    CvUtil.convertToStr(pCity.getName()))
                                bFirst = False
                            pFile.write("\t" + CvUtil.convertToStr(
                                GC.getReligionInfo(iReligion).getDescription())
                                        + "\n")
                    pCity, i = pPlayer.nextCity(i, False)

            pFile.write("\n\nCity Corporations:\n-----------\n")

            if pPlayer.getNumCities():
                pCity, i = pPlayer.firstCity(False)
                while pCity:
                    bFirst = True
                    for iCorporation in xrange(GC.getNumCorporationInfos()):
                        if pCity.isHasCorporation(iCorporation):
                            if bFirst:
                                pFile.write(
                                    "City: %s\n" %
                                    CvUtil.convertToStr(pCity.getName()))
                                bFirst = False
                            pFile.write("\t" + CvUtil.convertToStr(
                                GC.getCorporationInfo(
                                    iCorporation).getDescription()) + "\n")
                    pCity, i = pPlayer.nextCity(i, False)

            pFile.write("\n\nUnit Info:\n----------\n")

            if pPlayer.getNumUnits():
                for pUnit in pPlayer.units():
                    pFile.write("Player %d, Unit ID: %d, %s\n" %
                                (iPlayer, pUnit.getID(),
                                 CvUtil.convertToStr(pUnit.getName())))
                    pFile.write(
                        "X: %d, Y: %d\nDamage: %d\n" %
                        (pUnit.getX(), pUnit.getY(), pUnit.getDamage()))
                    pFile.write("Experience: %d\nLevel: %d\n" %
                                (pUnit.getExperience(), pUnit.getLevel()))
                    bFirst = True
                    for j in xrange(GC.getNumPromotionInfos()):
                        if pUnit.isHasPromotion(j):
                            if bFirst:
                                pFile.write("Promotions:\n")
                                bFirst = False
                            pFile.write("\t" + CvUtil.convertToStr(
                                GC.getPromotionInfo(j).getDescription()) +
                                        "\n")
                    bFirst = True
                    for j in xrange(GC.getNumUnitCombatInfos()):
                        if pUnit.isHasUnitCombat(j):
                            if bFirst:
                                pFile.write("UnitCombats:\n")
                                bFirst = False
                            pFile.write("\t" + CvUtil.convertToStr(
                                GC.getUnitCombatInfo(j).getDescription()) +
                                        "\n")
            else:
                pFile.write("No Units")
            # Space at end of player's info
            pFile.write("\n\n")
    # Close file
    pFile.close()

    # Restore current language
    GAME.setCurrentLanguage(iLanguage)
예제 #38
0
	def __eventWBGameScriptPopupApply(self, playerID, userData, popupReturn):
		sScript = popupReturn.getEditBoxString(0)
		CyGame().setScriptData(CvUtil.convertToStr(sScript))
		WBGameDataScreen.WBGameDataScreen(CvPlatyBuilderScreen.CvWorldBuilderScreen()).placeScript()
		return
예제 #39
0
	def __eventWBGameScriptPopupApply(self, playerID, userData, popupReturn):
		sScript = popupReturn.getEditBoxString(0)
		CyGame().setScriptData(CvUtil.convertToStr(sScript))
		WBGameDataScreen.WBGameDataScreen(CvPlatyBuilderScreen.CvWorldBuilderScreen()).placeScript()
		return
예제 #40
0
    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]
예제 #41
0
        def updateInfoPanel(self, argsList = None):
		screen = self.getScreen()

		if argsList :
                        actions = argsList
                else :
                        actions = cs.getActions(self.iLeftPlayer)

                if self.iActivePlayer == self.iLeftPlayer :
                        sPlayerName = self.sRightName
                else :
                        sPlayerName = self.sLeftName

		nbActions = len(actions)
		if nbActions > 1 : actions.reverse()

		i = 0
                for act in actions :
                        szTextID = self.TEXT_INFO_IDS[i]
                        szText = u""
                        sActTag = act[0]

                        if sActTag == "gameStart" :
                                iPlayerAction = act[1]
                                if self.iActivePlayer == iPlayerAction :
                                        sDrawCard = CvUtil.convertToStr(localText.getText("TXT_KEY_SOMNIUM_DRAW", ()))
                                        szText = localText.getText("TXT_KEY_SOMNIUM_WIN_TOSS", ()) + self.colorLight + u". " + u"</color>" + localText.getText("TXT_KEY_SOMNIUM_PRESS_BUTTON", (sDrawCard, ))
                                else :
                                        szText = localText.getText("TXT_KEY_SOMNIUM_WIN_TOSS_PLAYER", (sPlayerName, ))
                                        if self.gameMP :
                                                szText += self.colorLight + u"." + u"</color>"
                                        else :
                                                szText += self.colorLight + u". " + u"</color>"
                                                sEndTurn = CvUtil.convertToStr(localText.getText("TXT_KEY_SOMNIUM_END_TURN", ()))
                                                szText += localText.getText("TXT_KEY_SOMNIUM_PRESS_BUTTON", (sEndTurn, ))

                        elif sActTag == "drawCard" :
                                iPlayerAction = act[1]
                                iCardType = act[2]
                                iCardNumber = act[3]

                                lArgs = []
                                if iCardType > 9 :
                                        lArgs.append(CvUtil.convertToStr(localText.getText("TXT_KEY_SOMNIUM_TYPE_%d" %iCardType, ())))
                                        if self.iActivePlayer == iPlayerAction :
                                                sTxtKey = "TXT_KEY_SOMNIUM_DRAW_SPECIAL_CARD_INFO"
                                        else :
                                                sTxtKey = "TXT_KEY_SOMNIUM_DRAW_SPECIAL_CARD_INFO_PLAYER"
                                                lArgs.append(sPlayerName)
                                else :
                                        lArgs.append(iCardNumber)
                                        lArgs.append(CvUtil.convertToStr(localText.getText("TXT_KEY_SOMNIUM_TYPE_%d" %iCardType, ())))
                                        if self.iActivePlayer == iPlayerAction :
                                                sTxtKey = "TXT_KEY_SOMNIUM_DRAW_CARD_INFO"
                                        else :
                                                sTxtKey = "TXT_KEY_SOMNIUM_DRAW_CARD_INFO_PLAYER"
                                                lArgs.append(sPlayerName)
                                szText = localText.getText(sTxtKey, tuple(lArgs))

                        elif sActTag == "DiscardDeath" :
                                iPlayerAction = act[1]
                                sDeath = CvUtil.convertToStr(localText.getText("TXT_KEY_SOMNIUM_TYPE_11", ()))
                                if self.iActivePlayer == iPlayerAction :
                                        szText = localText.getText("TXT_KEY_SOMNIUM_DEATH_DISCARD", (sDeath, ))
                                else :
                                        szText = localText.getText("TXT_KEY_SOMNIUM_DEATH_DISCARD_PLAYER", (sDeath, sPlayerName))

                        elif sActTag == "EndGame" :
                                iLooser = act[1]
                                if iLooser == -1 :
                                        szText = localText.getText("TXT_KEY_SOMNIUM_DRAW_GAME_INFO", (sPlayerName, ))
                                elif self.iActivePlayer == iLooser :
                                        szText = localText.getText("TXT_KEY_SOMNIUM_LOOSE_GAME_INFO", ())
                                else :
                                        szText = localText.getText("TXT_KEY_SOMNIUM_WIN_GAME_INFO", ())

                        elif sActTag == "BeginTurn" :
                                iPlayerBegin = act[1]
                                if self.iActivePlayer == iPlayerBegin :
                                        sDrawCard = CvUtil.convertToStr(localText.getText("TXT_KEY_SOMNIUM_DRAW", ()))
                                        szText = localText.getText("TXT_KEY_SOMNIUM_BEGIN_TURN", ())
                                        szText += self.colorLight + u" " + u"</color>"
                                        szText += localText.getText("TXT_KEY_SOMNIUM_PRESS_BUTTON", (sDrawCard, ))
                                else :
                                        szText = localText.getText("TXT_KEY_SOMNIUM_BEGIN_TURN_PLAYER", (sPlayerName, ))

                        elif sActTag == "JokerSteal" :
                                iStealPlayer, iStolenPlayer, iCardType, iCardValue = act[1:]
                                sJoker = CvUtil.convertToStr(localText.getText("TXT_KEY_SOMNIUM_TYPE_10", ()))
                                sCardType = CvUtil.convertToStr(localText.getText("TXT_KEY_SOMNIUM_TYPE_%d" %iCardType, ()))
                                if self.iActivePlayer == iStolenPlayer :
                                        szText = localText.getText("TXT_KEY_SOMNIUM_JOKER_STEAL_PLAYER", (sCardType, iCardValue, sJoker, sPlayerName))
                                else :
                                        szText = localText.getText("TXT_KEY_SOMNIUM_JOKER_STEAL", (sCardType, iCardValue, sJoker, sPlayerName))

                        elif sActTag == "JokerNoUse" :
                                iJokPlayer = act[1]
                                sJoker = CvUtil.convertToStr(localText.getText("TXT_KEY_SOMNIUM_TYPE_10", ()))
                                if self.iActivePlayer == iJokPlayer :
                                        szText = localText.getText("TXT_KEY_SOMNIUM_JOKER_NO_USE", (sJoker, sPlayerName))
                                else :
                                        szText = localText.getText("TXT_KEY_SOMNIUM_JOKER_NO_USE_PLAYER", (sJoker, sPlayerName))

                        elif sActTag == "DiscardSameType" :
                                iDiscardPlayer, iCardType = act[1:]
                                sCardType = CvUtil.convertToStr(localText.getText("TXT_KEY_SOMNIUM_TYPE_%d" %iCardType, ()))
                                if self.iActivePlayer == iDiscardPlayer :
                                        szText = localText.getText("TXT_KEY_SOMNIUM_SAME_TYPE_DISCARD", (sCardType, ))
                                else :
                                        szText = localText.getText("TXT_KEY_SOMNIUM_SAME_TYPE_DISCARD_PLAYER", (sCardType, sPlayerName))

                        elif sActTag == "BankCard" :
                                iBankPlayer, iPoints = act[1:]
                                if self.iActivePlayer == iBankPlayer :
                                        szText = localText.getText("TXT_KEY_SOMNIUM_BANK_CARDS", (iPoints, ))
                                else :
                                        szText = localText.getText("TXT_KEY_SOMNIUM_BANK_CARDS_PLAYER", (iPoints, sPlayerName))

                        elif sActTag == "HUJokerPickCard" :
                                iPickPlayer = act[1]
                                if self.iActivePlayer == iPickPlayer :
                                        szText = localText.getText("TXT_KEY_SOMNIUM_JOKER_PICK_CARD", (sPlayerName, ))
                                else :
                                        szText = localText.getText("TXT_KEY_SOMNIUM_JOKER_PICK_CARD_PLAYER", (sPlayerName, ))

                        else :
                                continue
                                
                        szText = u"<font=3>" + szText + u"</font>"
                        screen.modifyLabel( szTextID, u"", CvUtil.FONT_LEFT_JUSTIFY )
                        screen.modifyLabel( szTextID, szText, CvUtil.FONT_LEFT_JUSTIFY )
                        i += 1
                        if i == 5 : break

                if i < 5 :
                        for j in range(i, 5) :
                                szTextID = self.TEXT_INFO_IDS[j]
                                szText = u""
                                screen.modifyLabel( szTextID, szText, CvUtil.FONT_LEFT_JUSTIFY )
예제 #42
0
    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]
예제 #43
0
	def __eventWBUnitScriptPopupApply(self, playerID, userData, popupReturn):
		sScript = popupReturn.getEditBoxString(0)
		pUnit = gc.getPlayer(userData[0]).getUnit(userData[1])
		pUnit.setScriptData(CvUtil.convertToStr(sScript))
		WBUnitScreen.WBUnitScreen(CvPlatyBuilderScreen.CvWorldBuilderScreen()).placeScript()
		return
예제 #44
0
	def __eventWBCityScriptPopupApply(self, playerID, userData, popupReturn):
		sScript = popupReturn.getEditBoxString(0)
		pCity = gc.getPlayer(userData[0]).getCity(userData[1])
		pCity.setScriptData(CvUtil.convertToStr(sScript))
		WBCityEditScreen.WBCityEditScreen().placeScript()
		return
예제 #45
0
def writeLog():
    playername = CvUtil.convertToStr(
        gc.getPlayer(gc.getGame().getActivePlayer()).getName())
    szNewFilename = BugPath.getRootDir() + "\\Logs\\" + "OOSLog - %s - " % (
        playername) + "Turn %s" % (gc.getGame().getGameTurn()) + ".txt"
    pFile = open(szNewFilename, "w")

    # Backup current language
    iLanguage = CyGame().getCurrentLanguage()
    # Force english language for logs
    CyGame().setCurrentLanguage(0)

    #
    # Global data
    #
    pFile.write(SEPERATOR)
    pFile.write(SEPERATOR)

    pFile.write("  GLOBALS  \n")

    pFile.write(SEPERATOR)
    pFile.write(SEPERATOR)
    pFile.write("\n\n")

    pFile.write("Next Map Rand Value: %d\n" %
                CyGame().getMapRand().get(10000, "OOS Log"))
    pFile.write("Next Soren Rand Value: %d\n" %
                CyGame().getSorenRand().get(10000, "OOS Log"))

    pFile.write("Total num cities: %d\n" % CyGame().getNumCities())
    pFile.write("Total population: %d\n" % CyGame().getTotalPopulation())
    pFile.write("Total Deals: %d\n" % CyGame().getNumDeals())

    pFile.write("Total owned plots: %d\n" % CyMap().getOwnedPlots())
    pFile.write("Total num areas: %d\n" % CyMap().getNumAreas())

    pFile.write("\n\n")

    #
    # Player data
    #
    iPlayer = 0
    for iPlayer in range(gc.getMAX_PLAYERS()):
        pPlayer = gc.getPlayer(iPlayer)
        if (pPlayer.isEverAlive()):
            pFile.write(SEPERATOR)
            pFile.write(SEPERATOR)

            pFile.write("  PLAYER %d: %s  \n" %
                        (iPlayer, CvUtil.convertToStr(pPlayer.getName())))
            pFile.write(
                "  Civilizations: %s  \n" %
                (CvUtil.convertToStr(pPlayer.getCivilizationDescriptionKey())))

            pFile.write(SEPERATOR)
            pFile.write(SEPERATOR)
            pFile.write("\n\n")

            pFile.write("Basic data:\n")
            pFile.write("-----------\n")
            pFile.write("Player %d Score: %d\n" %
                        (iPlayer, gc.getGame().getPlayerScore(iPlayer)))

            pFile.write("Player %d Population: %d\n" %
                        (iPlayer, pPlayer.getTotalPopulation()))
            pFile.write("Player %d Total Land: %d\n" %
                        (iPlayer, pPlayer.getTotalLand()))
            pFile.write("Player %d Gold: %d\n" % (iPlayer, pPlayer.getGold()))
            pFile.write("Player %d Assets: %d\n" %
                        (iPlayer, pPlayer.getAssets()))
            pFile.write("Player %d Power: %d\n" %
                        (iPlayer, pPlayer.getPower()))
            pFile.write("Player %d Num Cities: %d\n" %
                        (iPlayer, pPlayer.getNumCities()))
            pFile.write("Player %d Num Units: %d\n" %
                        (iPlayer, pPlayer.getNumUnits()))
            pFile.write("Player %d Num Selection Groups: %d\n" %
                        (iPlayer, pPlayer.getNumSelectionGroups()))
            pFile.write("Player %d Difficulty: %d\n" %
                        (iPlayer, pPlayer.getHandicapType()))

            pFile.write("\n\n")

            pFile.write("Yields:\n")
            pFile.write("-------\n")
            for iYield in range(int(YieldTypes.NUM_YIELD_TYPES)):
                pFile.write("Player %d %s Total Yield: %d\n" %
                            (iPlayer, gc.getYieldInfo(iYield).getDescription(),
                             pPlayer.calculateTotalYield(iYield)))

            pFile.write("\n\n")

            pFile.write("Commerce:\n")
            pFile.write("---------\n")
            for iCommerce in range(int(CommerceTypes.NUM_COMMERCE_TYPES)):
                pFile.write(
                    "Player %d %s Total Commerce: %d\n" %
                    (iPlayer, gc.getCommerceInfo(iCommerce).getDescription(),
                     pPlayer.getCommerceRate(CommerceTypes(iCommerce))))

            pFile.write("\n\n")

            pFile.write("Bonus Info:\n")
            pFile.write("-----------\n")
            for iBonus in range(gc.getNumBonusInfos()):
                pFile.write("Player %d, %s, Number Available: %d\n" %
                            (iPlayer, gc.getBonusInfo(iBonus).getDescription(),
                             pPlayer.getNumAvailableBonuses(iBonus)))
                pFile.write("Player %d, %s, Import: %d\n" %
                            (iPlayer, gc.getBonusInfo(iBonus).getDescription(),
                             pPlayer.getBonusImport(iBonus)))
                pFile.write("Player %d, %s, Export: %d\n" %
                            (iPlayer, gc.getBonusInfo(iBonus).getDescription(),
                             pPlayer.getBonusExport(iBonus)))
                pFile.write("\n")

            pFile.write("\n\n")

            pFile.write("Improvement Info:\n")
            pFile.write("-----------------\n")
            for iImprovement in range(gc.getNumImprovementInfos()):
                pFile.write(
                    "Player %d, %s, Improvement count: %d\n" %
                    (iPlayer,
                     CvUtil.convertToStr(
                         gc.getImprovementInfo(iImprovement).getDescription()),
                     pPlayer.getImprovementCount(iImprovement)))

            pFile.write("\n\n")

            pFile.write("Building Class Info:\n")
            pFile.write("--------------------\n")
            for iBuildingClass in range(gc.getNumBuildingClassInfos()):
                pFile.write(
                    "Player %d, %s, Building class count plus building: %d\n" %
                    (iPlayer,
                     CvUtil.convertToStr(
                         gc.getBuildingClassInfo(
                             iBuildingClass).getDescription()),
                     pPlayer.getBuildingClassCountPlusMaking(iBuildingClass)))

            pFile.write("\n\n")

            pFile.write("Unit Class Info:\n")
            pFile.write("--------------------\n")
            for iUnitClass in range(gc.getNumUnitClassInfos()):
                pFile.write(
                    "Player %d, %s, Unit class count plus training: %d\n" %
                    (iPlayer,
                     CvUtil.convertToStr(
                         gc.getUnitClassInfo(iUnitClass).getDescription()),
                     pPlayer.getUnitClassCountPlusMaking(iUnitClass)))

            pFile.write("\n\n")

            pFile.write("UnitAI Types Info:\n")
            pFile.write("------------------\n")
            for iUnitAIType in range(int(UnitAITypes.NUM_UNITAI_TYPES)):
                pFile.write(
                    "Player %d, %s, Unit AI Type count: %d\n" %
                    (iPlayer, gc.getUnitAIInfo(iUnitAIType).getDescription(),
                     pPlayer.AI_totalUnitAIs(UnitAITypes(iUnitAIType))))

            pFile.write("\n\n")

            pFile.write("City Info:\n")
            pFile.write("----------\n")
            iNumCities = pPlayer.getNumCities()

            if (iNumCities == 0):
                pFile.write("No Cities")
            else:
                pLoopCityTuple = pPlayer.firstCity(False)
                while (pLoopCityTuple[0] != None):
                    pCity = pLoopCityTuple[0]
                    #pFile.write("Player %d, City ID: %d, %s, Plot Radius: %d\n" % (iPlayer, pCity.getID(), CvUtil.convertToStr(pCity.getName()), pCity.getPlotRadius() ))

                    pFile.write("X: %d, Y: %d\n" %
                                (pCity.getX(), pCity.getY()))
                    pFile.write("Founded: %d\n" % pCity.getGameTurnFounded())
                    pFile.write("Population: %d\n" % pCity.getPopulation())
                    pFile.write("Buildings: %d\n" % pCity.getNumBuildings())
                    pFile.write("Improved Plots: %d\n" %
                                pCity.countNumImprovedPlots())
                    pFile.write("Producing: %s\n" % pCity.getProductionName())
                    pFile.write(
                        "%d Tiles Worked, %d Specialists, %d Great People\n" %
                        (pCity.getWorkingPopulation(),
                         pCity.getSpecialistPopulation(),
                         pCity.getNumGreatPeople()))

                    pLoopCityTuple = pPlayer.nextCity(pLoopCityTuple[1], False)
                    pFile.write("\n")

            pFile.write("\n\n")

            pFile.write("Unit Info:\n")
            pFile.write("----------\n")
            iNumUnits = pPlayer.getNumUnits()

            if (iNumUnits == 0):
                pFile.write("No Units")
            else:
                pLoopUnitTuple = pPlayer.firstUnit(False)
                while (pLoopUnitTuple[0] != None):
                    pUnit = pLoopUnitTuple[0]
                    pFile.write("Player %d, Unit ID: %d, %s\n" %
                                (iPlayer, pUnit.getID(),
                                 CvUtil.convertToStr(pUnit.getName())))
                    pFile.write("X: %d, Y: %d\n" %
                                (pUnit.getX(), pUnit.getY()))
                    pFile.write("Damage: %d\n" % pUnit.getDamage())
                    #pFile.write("Experience: %d\n" % pUnit.getExperienceTimes100() )
                    pFile.write("Experience: %d\n" % pUnit.getExperience())
                    pFile.write("Level: %d\n" % pUnit.getLevel())
                    pFile.write("Promotions:\n")
                    for j in range(gc.getNumPromotionInfos()):
                        if (pUnit.isHasPromotion(j)):
                            pFile.write("%s\n" % (CvUtil.convertToStr(
                                gc.getPromotionInfo(j).getDescription())))

                    pLoopUnitTuple = pPlayer.nextUnit(pLoopUnitTuple[1], False)
                    pFile.write("\n")

            # Space at end of player's info
            pFile.write("\n\n")

    # Restore current language
    CyGame().setCurrentLanguage(iLanguage)

    # Close file

    pFile.close()
예제 #46
0
	def drawAudioOptionsTab(self):
		
		tab = self.pTabControl
		
		tab.attachVBox("AudioForm", "AudioVBox")		
					
		tab.attachScrollPanel("AudioVBox", "AudioPanel")
		tab.setLayoutFlag("AudioPanel", "LAYOUT_SIZE_HEXPANDING")
		tab.setLayoutFlag("AudioPanel", "LAYOUT_SIZE_VEXPANDING")
		
		tab.attachVBox("AudioPanel", "AudioPanelVBox")
		tab.setLayoutFlag("AudioPanelHBox", "LAYOUT_SPACING_FORM")
		tab.setLayoutFlag("AudioPanelHBox", "LAYOUT_SIZE_HEXPANDING")
		tab.setLayoutFlag("AudioPanelHBox", "LAYOUT_SIZE_VEXPANDING")
	
			
		######################### Create the 6 volume slider/checkboxes #########################
		
		tab.attachVBox("AudioPanelVBox", "VolumeVBox")
		tab.setLayoutFlag("VolumeVBox", "LAYOUT_SIZE_HEXPANDING")
		tab.setLayoutFlag("VolumeVBox", "LAYOUT_SIZE_VEXPANDING")
		
		#tab.attachLabel("VolumeVBox", "VolumeLabel", "VOLUME")

		tab.attachPanel("VolumeVBox", "VolumePanel")
		tab.setStyle("VolumePanel", "Panel_Tan15_Style")
		tab.setLayoutFlag("VolumePanel", "LAYOUT_SIZE_HEXPANDING")
		tab.setLayoutFlag("VolumePanel", "LAYOUT_SIZE_VEXPANDING")

		tab.attachVBox("VolumePanel", "VolumePanelVBox")
		tab.setLayoutFlag("VolumePanelVBox", "LAYOUT_SIZE_HEXPANDING")
		tab.setLayoutFlag("VolumePanelVBox", "LAYOUT_SIZE_VEXPANDING")

		tab.attachScrollPanel("VolumePanelVBox", "VolumeScrollPanel")
		tab.setLayoutFlag("VolumeScrollPanel", "LAYOUT_SIZE_HEXPANDING")
		tab.setLayoutFlag("VolumeScrollPanel", "LAYOUT_SIZE_VEXPANDING")
		
		tab.attachHBox("VolumeScrollPanel", "VolumePanelHBox")
		tab.setLayoutFlag("VolumePanelHBox", "LAYOUT_HEVENSTRETCH")
		tab.setLayoutFlag("VolumePanelHBox", "LAYOUT_SIZE_VEXPANDING")
		
		for iWidgetNum in range(6):
						
			# SLIDER
			
			if (iWidgetNum == 0):		# Master Volume
				szWidgetDesc = localText.getText("TXT_KEY_OPTIONS_MASTERVOLUME", ())
				iInitialVal = 20-UserProfile.getMasterVolume()-1
				bNoSoundTrue = UserProfile.isMasterNoSound()
			elif (iWidgetNum == 1):		# Music Volume
				szWidgetDesc = localText.getText("TXT_KEY_OPTIONS_MUSICVOLUME", ())
				iInitialVal = 20-UserProfile.getMusicVolume()-1
				bNoSoundTrue = UserProfile.isMusicNoSound()
			elif (iWidgetNum == 2):		# Sound Effects Volume
				szWidgetDesc = localText.getText("TXT_KEY_OPTIONS_EFFECTSVOLUME", ())
				iInitialVal = 20-UserProfile.getSoundEffectsVolume()-1
				bNoSoundTrue = UserProfile.isSoundEffectsNoSound()
			elif (iWidgetNum == 3):		# Speech Volume
				szWidgetDesc = localText.getText("TXT_KEY_OPTIONS_SPEECHVOLUME", ())
				iInitialVal = 20-UserProfile.getSpeechVolume()-1
				bNoSoundTrue = UserProfile.isSpeechNoSound()
			elif (iWidgetNum == 4):		# Ambience Volume
				szWidgetDesc = localText.getText("TXT_KEY_OPTIONS_AMBIENCEVOLUME", ())
				iInitialVal = 20-UserProfile.getAmbienceVolume()-1
				bNoSoundTrue = UserProfile.isAmbienceNoSound()
			elif (iWidgetNum == 5):		# Interface Volume
				szWidgetDesc = localText.getText("TXT_KEY_OPTIONS_INTERFACEVOLUME", ())
				iInitialVal = 20-UserProfile.getInterfaceVolume()-1
				bNoSoundTrue = UserProfile.isInterfaceNoSound()
			
			islider = str(iWidgetNum)
			
			vbox = "VolumeSliderVBox"+islider
			tab.attachVBox("VolumePanelHBox", vbox)
			
			# Volume Slider
			szSliderDesc = szWidgetDesc
			szWidgetName = "VolumeSliderLabel"+islider
			tab.attachLabel(vbox, szWidgetName, szSliderDesc)
			tab.setLayoutFlag(szWidgetName, "LAYOUT_HCENTER")
			
			szCallbackFunction = "handleVolumeSlidersInput"
			szWidgetName = "VolumeSlider_" + str(iWidgetNum)
			iMin = 0
			iMax = UserProfile.getVolumeStops()
			# iInitialVal set above
			tab.attachVSlider(vbox, szWidgetName, self.callbackIFace, szCallbackFunction, szWidgetName, iMin, iMax, iInitialVal)
			tab.setLayoutFlag(szWidgetName, "LAYOUT_SIZE_VEXPANDING")
			tab.setControlFlag(szWidgetName, "CF_SLIDER_FILL_DOWN")
			
			# CHECKBOX
			
			szOptionDesc = localText.getText("TXT_KEY_OPTIONS_NO_SOUND", ())
			szCallbackFunction = "handleVolumeCheckboxesInput"
			szWidgetName = "VolumeNoSoundCheckbox_" + str(iWidgetNum)
			# bNoSoundTrue set above
			tab.attachCheckBox(vbox, szWidgetName, szOptionDesc, self.callbackIFace, szCallbackFunction, szWidgetName, bNoSoundTrue)
			tab.setLayoutFlag(szWidgetName, "LAYOUT_HCENTER")

			
		tab.attachHSeparator("VolumePanelVBox", "SoundSeparator")
				
		tab.attachHBox("VolumePanelVBox", "SoundPanelHBox")
		tab.setLayoutFlag("SoundPanelHBox", "LAYOUT_SIZE_HPREFERREDEXPANDING")
		tab.setLayoutFlag("SoundPanelHBox", "LAYOUT_SIZE_VPREFERRED")
						
		######################### Voice Config Section #########################
		
		tab.attachVBox("SoundPanelHBox", "VoiceVBox")

		# Checkbox
		szOptionDesc = localText.getText("TXT_KEY_OPTIONS_VOICE", ())
		szCallbackFunction = "handleVoiceCheckboxInput"
		self.szVoiceCheckboxName = "VoiceCheckbox"
		szWidgetName = "VoiceChatCheckbox"
		bUseVoice = UserProfile.useVoice()
		tab.attachCheckBox("VoiceVBox", szWidgetName, szOptionDesc, self.callbackIFace, szCallbackFunction, szWidgetName, bUseVoice)

		# Capture Device Dropdown
		tab.attachLabel("VoiceVBox", "VoiceCaptureLabel", localText.getText("TXT_KEY_OPTIONS_CAPTURE_DEVICE", ()))
		szDropdownDesc = "CaptureDeviceDropdownBox"
		aszDropdownElements = ()
		for iCaptureDevice in range(UserProfile.getNumCaptureDevices()):
			aszDropdownElements = aszDropdownElements + (UserProfile.getCaptureDeviceDesc(iCaptureDevice),)
		szCallbackFunction = "handleCaptureDeviceDropdownInput"
		szWidgetName = "CaptureDeviceDropdownBox"
		iInitialSelection = UserProfile.getCaptureDeviceIndex()
		tab.attachDropDown("VoiceVBox", szWidgetName, szDropdownDesc, aszDropdownElements, self.callbackIFace, szCallbackFunction, szWidgetName, iInitialSelection)
		
		# Capture Volume Slider
		szSliderDesc = localText.getText("TXT_KEY_OPTIONS_CAPTUREVOLUME", ())
		szCallbackFunction = "handleCaptureVolumeSliderInput"
		szWidgetName = "CaptureVolumeSlider"
		iMin = 0
		iMax = UserProfile.getMaxCaptureVolume()
#		iInitialVal = iMax - UserProfile.getCaptureVolume()
		iInitialVal = UserProfile.getCaptureVolume()
		tab.attachHSlider("VoiceVBox", szWidgetName, self.callbackIFace, szCallbackFunction, szWidgetName, iMin, iMax, iInitialVal)
		tab.setControlFlag(szWidgetName, "CF_SLIDER_FILL_UP")
		
		# Playback Device Dropdown
		tab.attachLabel("VoiceVBox", "VoicePlaybackLabel", localText.getText("TXT_KEY_OPTIONS_PLAYBACK_DEVICE", ()))	# Label
		szDropdownDesc = "PlaybackDeviceDropdownBox"
		aszDropdownElements = ()
		for iPlaybackDevice in range(UserProfile.getNumPlaybackDevices()):
			aszDropdownElements = aszDropdownElements + (UserProfile.getPlaybackDeviceDesc(iPlaybackDevice),)
		szCallbackFunction = "handlePlaybackDeviceDropdownInput"
		szWidgetName = "PlaybackDeviceDropdownBox"
		iInitialSelection = UserProfile.getPlaybackDeviceIndex()
		tab.attachDropDown("VoiceVBox", szWidgetName, szDropdownDesc, aszDropdownElements, self.callbackIFace, szCallbackFunction, szWidgetName, iInitialSelection)
		
		# Playback Volume Slider
		szSliderDesc = localText.getText("TXT_KEY_OPTIONS_PLAYBACKVOLUME", ())
		szCallbackFunction = "handlePlaybackVolumeSliderInput"
		szWidgetName = "PlaybackVolumeSlider"
		iMin = 0
		iMax = UserProfile.getMaxPlaybackVolume()
#		iInitialVal = iMax - UserProfile.getPlaybackVolume()
		iInitialVal = UserProfile.getPlaybackVolume()
		tab.attachHSlider("VoiceVBox", szWidgetName, self.callbackIFace, szCallbackFunction, szWidgetName, iMin, iMax, iInitialVal)
		tab.setControlFlag(szWidgetName, "CF_SLIDER_FILL_UP")
								
		######################### Speaker Config Dropdown #########################
		
		tab.attachVSeparator("SoundPanelHBox", "SoundVSeparator")

		tab.attachVBox("SoundPanelHBox", "SoundConfigVBox")

		tab.attachImage("SoundConfigVBox", "SoundBlasterLogo", CyArtFileMgr().getMiscArtInfo("SOUND_BLASTER_LOGO").getPath())

		tab.attachLabel("SoundConfigVBox", "SpeakerConfigLabel", localText.getText("TXT_KEY_OPTIONS_SPEAKERS", ()))	# Label
		szDropdownDesc = "SpeakerConfigDropdownBox"
		aszDropdownElements = ()
		iInitialSelection = 0
		for iSpeakerConfigLoop in range(15):
			szActiveConfigKey = UserProfile.getSpeakerConfigFromList(iSpeakerConfigLoop)
			szActiveConfig = localText.getText(szActiveConfigKey, ())
			aszDropdownElements = aszDropdownElements + (szActiveConfig,)
			if (UserProfile.getSpeakerConfig() == szActiveConfigKey):
				iInitialSelection = iSpeakerConfigLoop
			
		szCallbackFunction = "handleSpeakerConfigDropdownInput"
		szWidgetName = "SpeakerConfigDropdownBox"
		# iInitialSelection set above
		tab.attachDropDown("SoundConfigVBox", szWidgetName, szDropdownDesc, aszDropdownElements, self.callbackIFace, szCallbackFunction, szWidgetName, iInitialSelection)
		tab.setLayoutFlag(szWidgetName, "LAYOUT_SIZE_HFIXEDEXPANDING")
		tab.setLayoutFlag(szWidgetName, "LAYOUT_LEFT")
			
		######################### Custom Audio Path #########################
		
		tab.attachHSeparator("SoundConfigVBox", "SoundSeparator")

		tab.attachHBox("SoundConfigVBox", "CustomPanelHBox")
		tab.setLayoutFlag("CustomPanelHBox", "LAYOUT_SIZE_HPREFERREDEXPANDING")
		tab.setLayoutFlag("CustomPanelHBox", "LAYOUT_SIZE_VPREFERRED")
										
		# Checkbox
		szOptionDesc = localText.getText("TXT_KEY_OPTIONS_CUSTOM_MUSIC", ())
		szCallbackFunction = "handleCustomMusicPathCheckboxInput"
		self.szCustomMusicCheckboxName = "CustomMusicPathCheckbox"
		szWidgetName = CvUtil.convertToStr(self.szCustomMusicCheckboxName)
		bUseCustomMusicPath = false
		if (UserProfile.getMusicPath() != ""):
			bUseCustomMusicPath = true
		tab.attachCheckBox("CustomPanelHBox", szWidgetName, szOptionDesc, self.callbackIFace, szCallbackFunction, szWidgetName, bUseCustomMusicPath)
				
		tab.attachHBox("CustomPanelHBox", "AudioPathHBox")
		tab.setLayoutFlag("AudioPathHBox", "LAYOUT_SIZE_HFIXEDEXPANDING")
		
		# Browse Button
		szOptionDesc = localText.getText("TXT_KEY_OPTIONS_BROWSE", ())
		szCallbackFunction = "handleCustomMusicPathButtonInput"
		szWidgetName = "CustomMusicPathButton"
		tab.attachButton("AudioPathHBox", szWidgetName, szOptionDesc, self.callbackIFace, szCallbackFunction, szWidgetName)

		# Edit Box
		szEditBoxDesc = u""
		if (UserProfile.getMusicPath() != ""):
			szEditBoxDesc = CvUtil.convertToUnicode(UserProfile.getMusicPath())
		szWidgetName = "CustomMusicEditBox"
		szCallbackFunction = "DummyCallback"
		
		tab.attachEdit("AudioPathHBox", szWidgetName, szEditBoxDesc, self.callbackIFace, szCallbackFunction, szWidgetName)

		########## EXIT

		tab.attachHSeparator("AudioVBox", "AudioExitSeparator")
		
		tab.attachHBox("AudioVBox", "LowerHBox")
		tab.setLayoutFlag("LowerHBox", "LAYOUT_HCENTER")
		
		szOptionDesc = localText.getText("TXT_KEY_OPTIONS_RESET", ())
		szCallbackFunction = "handleAudioReset"
		szWidgetName = "AudioOptionsResetButton"
		tab.attachButton("LowerHBox", szWidgetName, szOptionDesc, self.callbackIFace, szCallbackFunction, szWidgetName)
		
		szOptionDesc = localText.getText("TXT_KEY_PEDIA_SCREEN_EXIT", ())
		szCallbackFunction = "handleExitButtonInput"
		szWidgetName = "AudioOptionsExitButton"
		tab.attachButton("LowerHBox", szWidgetName, szOptionDesc, self.callbackIFace, szCallbackFunction, szWidgetName)
		tab.setLayoutFlag(szWidgetName, "LAYOUT_HCENTER")