I've been reading lots of Python tutorials and getting more familiar with the Civ4 API but sometimes I come across something that I can't work out. This section is one such case:
What do PyPlayer and PyInfo do and why are they used here? They're not listed in the Python API. What's the difference between PyPlayer(pWinner.getOwner()) and gc.getPlayer(pWinner.getOwner()) for example?
Why does pLoser.getUnitCombatType() not work here? After a painful amount of trial and error I got unitY.info.getUnitCombatType() to work instead but I'd really like to understand why.
Code:
def onCombatResult(self, argsList):
'Combat Result'
pWinner,pLoser = argsList
playerX = PyPlayer(pWinner.getOwner())
unitX = PyInfo.UnitInfo(pWinner.getUnitType())
playerY = PyPlayer(pLoser.getOwner())
unitY = PyInfo.UnitInfo(pLoser.getUnitType())
if (not self.__LOG_COMBAT):
return
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()))
What do PyPlayer and PyInfo do and why are they used here? They're not listed in the Python API. What's the difference between PyPlayer(pWinner.getOwner()) and gc.getPlayer(pWinner.getOwner()) for example?
Why does pLoser.getUnitCombatType() not work here? After a painful amount of trial and error I got unitY.info.getUnitCombatType() to work instead but I'd really like to understand why.