Three questions...
1) Is there a way to do a PyPerTurn function on a city, leader, civilization, or building level? None of those XML files contains a PyPerTurn tag, but I'm guessing there might be a global function that would accomplish the same thing. What I'm doing is creating a new summonable fallow civ where their city population will depend on the number of particular resources in the BFC. The way I was planning to do it was to loop through their cities each turn, count the resources, set the pop cap, and then tell it to grow one size. Any advice on how to do that, or a better way to do it?
2) How are stackable promotions handled. That is, do they sit on the unit as multiple promotions, or as one promotion with an integer that detemines how many of it there are? The main reason is, if I put a PyPerTurn on a stackable promotion, will it get called once, or one time for each "instance" of the promotion? I think it's just one instance, because stackable promotions with a 100% chance to wear off, don't. Instead of all 10 (or whatever) promotions wearing off, 1 wears off each turn, leading me to believe that it just decrements the counter (using setHasPromotion(PROMO, false)) when the promotion is supposed to wear off. This is actually good for what I'm trying to do, but it requires a little bit of jumping through hoops to have a stackable promotion that is granted by a spell (otherwise n casters could apply it every turn, one would wear off, thus a unit could have (n-1)*t + n applications on at a time, where I'm planning to limit it to n (by disabling casting while the caster maintains it and checking in the PyPerTurn that the instances of the promotion don't exceed the number of maintaining casters in the stack).
3) Maybe I'm still dense, but there's something about modular python that I just can't grasp, which is how functions with a return value can possibly work. Frex, in canBuild, you have
Code:
def canBuild(self,argsList):
//a bunch of stuff...
//i.e.:
if eCiv == Civ["Malakim"]:
pPlot = CyMap().plot(iX, iY)
if (iBuild == Improvement["Road"]):
if (pPlot.getTerrainType() == Terrain["Desert"]):
return 0
//more returns etc...
//then
## *******************
## Modular Python: ANW 29-may-2010
for module in command['canBuild']:
module.canBuild(self, argsList)
## Modular Python End
## *******************
return -1
# Returning -1 means ignore; 0 means Build cannot be performed; 1 or greater means it can
How does this manage to do anything but ignore the return value? If I were to set something in a modular canBuild() function, assuming that it gets to that point in the function and doesn't return a 1 or 0 earlier, then no matter what I return, it's just going to ignore it and proceed down to the return -1 statement, isn't it? Am I missing something?