PYTHON: how to get info on how much culture a city is producing?

Maniac

Apolyton Sage
Joined
Nov 27, 2004
Messages
5,589
Location
Gent, Belgium
Instead of the flat 1 happy face per 10% culture spending, I'd like to return to the old system of x culture = 1 happiness. For that I need to know how in python I can get to know how much culture a city is producing.

Basically I was thinking of writing an event under def onCityDoTurn that would check the culture production, and based on that place a building in a city that gives a certain # of happy faces.

Can anyone help with my question?
 
I'm afraid I don't understand what that means. Could you give a concrete example? I learn python by basically copying and pasting parts of different events together. So concretely, what am I supposed to write after:

CvEventManager.py :

Code:
	def onCityDoTurn(self, argsList):
		'City Production'
		pCity = argsList[0]
		iPlayer = argsList[1]
		pPlot = pCity.plot()
		pPlayer = gc.getPlayer(iPlayer)

		if pCity. ...
...has for instance a culture production between 10 and 20, then...
pCity.setHasRealBuilding(gc.getInfoTypeForString('BUILDING_SOMETHING'), bKeep)
?

Edit: I suppose you mean something like this?

"if pCity.getCulture(pCity.getOwner()) > x"

I'm wondering though, does that mean the city's current culture production, or the city's total accumulated culture? I'd need the first.
Edit2: I just tested it. It looks at the total accumulated culture, not the current culture production.

Edit3: What do these INTs do?

INT getCityCulture()
int ()

INT countTotalCulture()
int ()

INT cultureStrength(PlayerType ePlayer)
int (ePlayer)
 
Edit: I suppose you mean something like this?

"if pCity.getCulture(pCity.getOwner()) > x"

I'm wondering though, does that mean the city's current culture production, or the city's total accumulated culture? I'd need the first.
Edit2: I just tested it. It looks at the total accumulated culture, not the current culture production.

What you'll want to use is pCity.getCommerceRate(CommerceTypes.COMMERCE_CULTURE) > x or if you want to be a bit more precise, you can use pCity.getCommerceRateTimes100(CommerceTypes.COMMERCE_CULTURE) / 100 > x

The reason for the difference is that getCommerceRate is coming from the SDK which only sends back an int. Based on current SpeedInfo (Blitz, Normal, Marathon, etc.), it could be a non-integer and getCommerceRateTimes100 gives you two decimals of precision.

If you look in CvMainInterface.py, you can see where this is used to put up the Culture Rate Bar in the City Interface screen.
 
Top Bottom