def onCombatResult(self, argsList):
####################################
# My naive try to change something #
####################################
'Combat Result'
pWinner,pLoser = argsList
playerX = PyPlayer(pWinner.getOwner())
unitX = PyInfo.UnitInfo(pWinner.getUnitType())
playerY = PyPlayer(pLoser.getOwner())
unitY = PyInfo.UnitInfo(pLoser.getUnitType())
if playerX and playerX and unitX and playerY:
CvUtil.pyPrint('Player %d Civilization %s Unit %s has defeated Player %d Civilization %s Unit %s'
%(playerX.getID(), playerX.getCivilizationName(), unitX.getDescription(),
playerY.getID(), playerY.getCivilizationName(), unitY.getDescription()))
xType = unitX.getUnitCombatType()
yType = unitY.getUnitCombatType()
player = gc.getActivePlayer()
unitSlave = gc.getInfoTypeForString("UNIT_SLAVE")
if (yType != gc.getInfoTypeForString("UNITCOMBAT_SIEGE") and yType != gc.getInfoTypeForString("UNITCOMBAT_ARMOR") and yType != gc.getInfoTypeForString("UNITCOMBAT_HELICOPTER") and yType != gc.getInfoTypeForString("UNITCOMBAT_NAVAL") and yType != gc.getInfoTypeForString("NONE")):
if (xType != gc.getInfoTypeForString("UNITCOMBAT_HELICOPTER") and xType != gc.getInfoTypeForString("NONE")):
iRand = random.randint(1, 100)
if (iRand >=1):
if (player.isCivic(gc.getInfoTypeForString("CIVIC_SLAVERY"))):
newUnit = playerX.player.initUnit(unitSlave, pWinner.getX(), pWinner.getY(), UnitAITypes.NO_UNITAI)
newUnit.finishMoves()
#################
# End of my try #
#################
if (AutologOpt.isLogCombat()):
self.UnitKilled = 1
pWinner,pLoser = argsList
if (pWinner.getOwner() == CyGame().getActivePlayer()
or pLoser.getOwner() == CyGame().getActivePlayer()):
playerX = PyPlayer(pWinner.getOwner())
playerY = PyPlayer(pLoser.getOwner())
winnerHealth = float(pWinner.baseCombatStr()) * float(pWinner.currHitPoints()) / float(pWinner.maxHitPoints())
zsBattleLocn = self.getUnitLocation(pWinner)
playerXDesc = PyPlayer(pWinner.getVisualOwner()).getCivilizationAdjective()
playerYDesc = PyPlayer(pLoser.getVisualOwner()).getCivilizationAdjective()
if (pWinner.getOwner() == CyGame().getActivePlayer()):
if (self.bHumanPlaying):
message = BugUtil.getText("TXT_KEY_AUTOLOG_WHILE_ATTACKING_DEFEATS", (zsBattleLocn, pWinner.getNameKey(), BugUtil.formatFloat(winnerHealth, 2), pWinner.baseCombatStr(), playerYDesc, pLoser.getNameKey(), BugUtil.formatFloat(self.fOdds, 1), lPercent))
self.iBattleWonAttacking = self.iBattleWonAttacking + 1
else:
self.fOdds = 100 - self.fOdds
message = BugUtil.getText("TXT_KEY_AUTOLOG_WHILE_DEFENDING_DEFEATS", (zsBattleLocn, pWinner.getNameKey(), BugUtil.formatFloat(winnerHealth, 2), pWinner.baseCombatStr(), playerYDesc, pLoser.getNameKey(), BugUtil.formatFloat(self.fOdds, 1), lPercent))
self.iBattleWonDefending = self.iBattleWonDefending + 1
Logger.writeLog(message, vColor="DarkRed")
else:
if (self.bHumanPlaying):
message = BugUtil.getText("TXT_KEY_AUTOLOG_WHILE_ATTACKING_LOSES", (zsBattleLocn, pLoser.getNameKey(), playerXDesc, pWinner.getNameKey(), BugUtil.formatFloat(winnerHealth, 2), pWinner.baseCombatStr(), BugUtil.formatFloat(self.fOdds, 1), lPercent))
self.iBattleLostAttacking = self.iBattleLostAttacking + 1
else:
self.fOdds = 100 - self.fOdds
message = BugUtil.getText("TXT_KEY_AUTOLOG_WHILE_DEFENDING_LOSES", (zsBattleLocn, pLoser.getNameKey(), playerXDesc, pWinner.getNameKey(), BugUtil.formatFloat(winnerHealth, 2), pWinner.baseCombatStr(), BugUtil.formatFloat(self.fOdds, 1), lPercent))
self.iBattleLostDefending = self.iBattleLostDefending + 1
Logger.writeLog(message, vColor="Red")