Improvement Building Question

TheLopez

Deity
Joined
Jan 16, 2006
Messages
2,525
Location
Oregon
Does anyone know how to determine who built an improvement when they are built? I know that the onImprovementBuilt method exists in the EventsManager.py file but the only arguments it provides are the x,y coordinates of the plot and what type of improvement was built.
 
You can get the turn from CyGlobalContext.getGame().getGameTurn(). Just remember it's 0 index'd and the turn we think of as the first turn is turn -1.

Secondly, improvements can not be built in enemy territory, so if pPlot has an owner, that's the builder.

Third, you can check the units in the square and compare the improvement built with the units their mp and their ability to build the improvement. That really aught to cover 99.999999999% of the situations.
 
See that's the problem, there can be two or more of the same type of units in the same square.
 
Lord Olleus said:
what if they both built an improvement at the same time (say one builds a road and the other a farm) on the same square.

There is no ambiguity in this case, both the road and the farm will have been built by the owner of the plot (because farms can't be built outside of cultural zones, and you can't build inside someone else's cultural zone).

I'm also not 100% sure roads trigger onImprovementBuilt, as they are features, IIR, not improvements.
 
Back
Top Bottom