def combatMessageBuilder(cdAttacker, cdDefender, iCombatOdds): combatMessage = "" if (cdAttacker.eOwner == cdAttacker.eVisualOwner): combatMessage += "%s's" % (gc.getPlayer(cdAttacker.eOwner).getName(), ) combatMessage += " %s (%.2f)" % ( cdAttacker.sUnitName, cdAttacker.iCurrCombatStr / 100.0, ) combatMessage += " " + localText.getText("TXT_KEY_COMBAT_MESSAGE_VS", ()) + " " if (cdDefender.eOwner == cdDefender.eVisualOwner): combatMessage += "%s's" % (gc.getPlayer(cdDefender.eOwner).getName(), ) combatMessage += "%s (%.2f)" % ( cdDefender.sUnitName, cdDefender.iCurrCombatStr / 100.0, ) CyInterface().addCombatMessage(cdAttacker.eOwner, combatMessage) CyInterface().addCombatMessage(cdDefender.eOwner, combatMessage) # CtHCombat.log start combatMessageVs = combatMessage # CtHCombat.log end combatMessage = "%s %.1f%%" % ( localText.getText("TXT_KEY_COMBAT_MESSAGE_ODDS", ()), iCombatOdds / 10.0, ) CyInterface().addCombatMessage(cdAttacker.eOwner, combatMessage) CyInterface().addCombatMessage(cdDefender.eOwner, combatMessage) combatDetailMessageBuilder(cdAttacker, cdAttacker.eOwner, -1) combatDetailMessageBuilder(cdDefender, cdAttacker.eOwner, 1) combatDetailMessageBuilder(cdAttacker, cdDefender.eOwner, -1) combatDetailMessageBuilder(cdDefender, cdDefender.eOwner, 1) # CtHCombat.log combatMessageOdds = combatMessage combatLogName = None if not CyGame().isPitbossHost(): isActivePlayer = gc.getGame().getActivePlayer() in [ cdDefender.eOwner, cdAttacker.eOwner ] if isActivePlayer: combatLogName = BugPath.join(BugPath.getRootDir(), "Combat.log") f = codecs.open(combatLogName, "a", 'utf-8') f.write(combatMessageVs + " \n") f.write(combatMessageOdds + " \n") f.close()
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)
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)
def getSaveDir(type=SINGLE, variant=None): if variant: return BugPath.join(_saveDir, type, variant) else: return BugPath.join(_saveDir, type)
def init(): global _saveDir _saveDir = BugPath.join(BugPath.getRootDir(), "Saves") if not _saveDir: BugUtil.error("Could not find Saves directory")
def log_path(): # filepath='D:\\DoC_Log\\' filepath = BugPath.join(BugPath.getRootDir(), 'Saves', 'logs', '') return filepath