Hi,
I am currently trying to add a little modification (stealing techs when capturing cities). I figured that the right place to do that is probably the onCityAcquired hook in CvEventManager.py.
First I get the player/team of the previous and the new owner
then I try to create a list with techs that might possibly be stolen
Unfortunately, the latter doesn't seem to work, the method doesn't finish anymore (I added a little popup add the end to see that).
I also tried using more conventional code style:
but no success either. But I noticed another odd thing: I can use append outside the for loop, but not inside.
Since I don't know a great deal about pyhton and it's variable scopes and so on, I created a similar test-class outside of civ where I did a similar thing an it worked instantly...
I would really appreciate any help on this... is it a general python issue or some civ-specific thing? Sorry for posting such a lengthy question and thanks in advance!
greetings,
jonas
I am currently trying to add a little modification (stealing techs when capturing cities). I figured that the right place to do that is probably the onCityAcquired hook in CvEventManager.py.
First I get the player/team of the previous and the new owner
Code:
newOwner = gc.getPlayer(iNewOwner)
newTeam = gc.getTeam(newOwner.getTeam())
previousOwner = gc.getPlayer(iPreviousOwner)
previousTeam = gc.getTeam(previousOwner.getTeam())
then I try to create a list with techs that might possibly be stolen
Code:
# create a list with all techs owned by previous but not by current player
possibleTechs= [i for i in range(gc.getNumTechInfos() if previousTeam.isHasTech(i) and not newTeam.isHasTech(i)]
Unfortunately, the latter doesn't seem to work, the method doesn't finish anymore (I added a little popup add the end to see that).
I also tried using more conventional code style:
Code:
possibleTechs = []
for i in range(gc.getNumTechInfos()):
if (previousTeam.isHasTech(i) and not newTeam.isHasTech(i)):
possibleTechs.append(i)
but no success either. But I noticed another odd thing: I can use append outside the for loop, but not inside.
Since I don't know a great deal about pyhton and it's variable scopes and so on, I created a similar test-class outside of civ where I did a similar thing an it worked instantly...
I would really appreciate any help on this... is it a general python issue or some civ-specific thing? Sorry for posting such a lengthy question and thanks in advance!
greetings,
jonas