ripple01
Emperor
I'm writing some Python code and am in need of a little assistance. I am trying to achieve the effect of when a player with the Enlightened trait enters the Classical era, they get to pick a new technology.
My code now quasi works, but what happens is that when you select your free tech, the onTechAcquired tech fires before the era change, giving you another free tech, and so on. Could anyone give me a nudge in the right direction about how to fix this?
My code now quasi works, but what happens is that when you select your free tech, the onTechAcquired tech fires before the era change, giving you another free tech, and so on. Could anyone give me a nudge in the right direction about how to fix this?
Code:
def onTechAcquired(self,argsList):
'Tech Acquired'
iTechType, iTeam, iPlayer, bAnnounce = argsList
# Note that iPlayer may be NULL (-1) and not a refer to a player object
pPlayer = gc.getPlayer(iPlayer)
## Enlightened Trait Start ##
iTrait = CvUtil.findInfoTypeNum(gc.getTraitInfo,gc.getNumTraitInfos(),'TRAIT_ENLIGHTENED')
if (pPlayer.hasTrait(iTrait)):
iTechEra = gc.getTechInfo(iTechType).getEra()
iPlayerEra = CyPlayer().getCurrentEra()
if iTechEra != iPlayerEra:
if iTechEra == 1:
szTitle = localText.getText( "TXT_KEY_SCI_TRAIT_FREE_TECH", ( ) )
if (pPlayer.isHuman):
pPlayer.chooseTech(1,szTitle,True)
if (not pPlayer.isHuman()):
techs = []
team = gc.getTeam(pPlayer.getTeam())
for iTech in range(gc.getNumTechInfos()):
if pPlayer.canResearch(iTech, false):
iCost = team.getResearchLeft(iTech)
if iCost > 0:
techs.append((-iCost, iTech))
if techs:
techs.sort()
iTech = techs[0][1]
team.setHasTech(iTech, True, iPlayer, false, false)