Help needed for changing population of a city

Alrik2002

Warlord
Joined
May 24, 2012
Messages
214
Location
Berlin, Germany
Hi,

I´ve implented the settlers-Mod, which has differnt kinds of settlers, which build a city with more population than 1 and some buildings. This works fine but now I want to add a check if the player hat the trait expansive. If yes, the population should be +1 compared to the other players. I couldn´t make it. Could anyone help me please?

Here is the original code (the parts in red need the additional check):
Code:
def addBuildings(iOwner, iCityID, iUnitClass):
        city = gc.getPlayer(iOwner).getCity(iCityID)

        #if iUnitClass == gc.getInfoTypeForString("UNITCLASS_SETTLER"):
        #	## Do Nothing
        #	pass

        if iUnitClass == gc.getInfoTypeForString("UNITCLASS_COLONIST"):
[COLOR="Red"]                city.setPopulation(3)[/COLOR]
                _addBuilding(city, "BUILDINGCLASS_BARRACKS")
                _addBuilding(city, "BUILDINGCLASS_GRANARY")
                _addBuilding(city, "BUILDINGCLASS_FORGE")
                _addBuilding(city, "BUILDINGCLASS_MARKET")
                if city.plot().isCoastalLand():
                        _addBuilding(city, "BUILDINGCLASS_HARBOR")
                        _addBuilding(city, "BUILDINGCLASS_LIGHTHOUSE")
                        _addBuilding(city, "BUILDINGCLASS_FISHERMAN_HUT")

        elif iUnitClass == gc.getInfoTypeForString("UNITCLASS_PIONEER"):
[COLOR="Red"]                city.setPopulation(4)[/COLOR]
                _addBuilding(city, "BUILDINGCLASS_GARRISON")
                _addBuilding(city, "BUILDINGCLASS_GRANARY")
                _addBuilding(city, "BUILDINGCLASS_FORGE")
                _addBuilding(city, "BUILDINGCLASS_COURTHOUSE")
                _addBuilding(city, "BUILDINGCLASS_MARKET")
                _addBuilding(city, "BUILDINGCLASS_STABLE")
                _addBuilding(city, "BUILDINGCLASS_GROCER")
                _addBuilding(city, "BUILDINGCLASS_DOCTOR")
                _addBuilding(city, "BUILDINGCLASS_BANK")
                _addBuilding(city, "BUILDINGCLASS_LIBRARY")
                if city.plot().isCoastalLand():
                        _addBuilding(city, "BUILDINGCLASS_PORT")
                        _addBuilding(city, "BUILDINGCLASS_LIGHTHOUSE")
                        _addBuilding(city, "BUILDINGCLASS_FISHERMAN_HUT")

        elif iUnitClass == gc.getInfoTypeForString("UNITCLASS_ARCHITECT"):
        	_addBuilding(city, "BUILDINGCLASS_BARRACKS")
        	_addBuilding(city, "BUILDINGCLASS_GRANARY")
        	_addBuilding(city, "BUILDINGCLASS_COURTHOUSE")
        	_addBuilding(city, "BUILDINGCLASS_MARKET")
        	_addBuilding(city, "BUILDINGCLASS_STABLE")
        	_addBuilding(city, "BUILDINGCLASS_GROCER")
        	_addBuilding(city, "BUILDINGCLASS_AQUEDUCT")
        	_addBuilding(city, "BUILDINGCLASS_BANK")
        	_addBuilding(city, "BUILDINGCLASS_FORGE")
        	_addBuilding(city, "BUILDINGCLASS_LIBRARY")
        	_addBuilding(city, "BUILDINGCLASS_JAIL")
        	_addBuilding(city, "BUILDINGCLASS_OBSERVATORY")
        	_addBuilding(city, "BUILDINGCLASS_THEATRE")
        	_addBuilding(city, "BUILDINGCLASS_CUSTOM_HOUSE")
        	_addBuilding(city, "BUILDINGCLASS_INDUSTRIAL_PARK")
        	_addBuilding(city, "BUILDINGCLASS_LEVEE")
        	_addBuilding(city, "BUILDINGCLASS_PUBLIC_TRANSPORTATION")
        	if city.plot().isCoastalLand():
        		_addBuilding(city, "BUILDINGCLASS_HARBOR")
        		_addBuilding(city, "BUILDINGCLASS_LIGHTHOUSE")

Thank you very much.
 
Code:
		pPlayer = gc.getPlayer(iOwner)
		if pPlayer.hasTrait(gc.getInfoTypeForString("TRAIT_EXPANSIVE")):
			city.changePopulation(1)

Park this as the 2nd line
Adjust indentation accordingly
 
Back
Top Bottom