adding specialist in capital

Chrill

Chieftain
Joined
Aug 19, 2002
Messages
26
Location
Sweden
1.
I want a function in python that adds a Specialist for free in the capital under a certain civic. Kindow straight forward to add the specialist, the problems start when switching of the civic condition, i just try to "reverse" add the specialists in an unsophisticated manner... and I get a typeerror that totally perplexes me:

File "CvEventManager", line 522, in onBeginPlayerTurn
TypeError: this constructor takes no arguments
(that is the last line of the code posted below)

the code looks perfect to me, but python says otherwise...

Code:
		pPlayer = gc.getPlayer(iPlayer)
		if (player.isCivic(gc.getInfoTypeForString("CIVIC_OLIGARCHY"))):
			for iCity in range(pPlayer.getNumCities()):
				ppCity = pPlayer.getCity(iCity)
				if ppCity.isGovernmentCenter():
					if ppCity.getNumRealBuilding(gc.getInfoTypeForString("BUILDING_DRILL")) > 0: 
						pPlayer.getCity(ppCity).setFreeSpecialistCount(gc.getInfoTypeForString("SPECIALIST_GENERAL"), 2)
					else: 
						pPlayer.getCity(ppCity).setFreeSpecialistCount(gc.getInfoTypeForString("SPECIALIST_GENERAL"), 1)					
		else:
			for iCity in range(pPlayer.getNumCities()):
				ppCity = pPlayer.getCity(iCity)
				if ppCity.isGovernmentCenter():
					if ppCity.getNumRealBuilding(gc.getInfoTypeForString("BUILDING_DRILL")) > 0: 
						pPlayer.getCity(ppCity).setFreeSpecialistCount(gc.getInfoTypeForString("SPECIALIST_GENERAL"), 1)
					else: 
						pPlayer.getCity(ppCity).setFreeSpecialistCount(gc.getInfoTypeForString("SPECIALIST_GENERAL"), 0)

2.
if the above problem was easy to solve perhaps someone would know how to make the Specialist random for X amount of turns (say 5), I have absolutly no idea how to solve the randomness idea in terms of removing the specialist ...
 
actually i got it to work after I redid it all, dunno what caused the bug though...but it's 03.00 am so anything goes...

either way if anyone would know how to make the Specialist random instead of static i would be very glad :)

Code:
		# Oligarchy Capital General (random???)
		player = gc.getActivePlayer()
		if (player.isCivic(gc.getInfoTypeForString("CIVIC_OLIGARCHY"))):
			for a in range(player.getNumCities()):
				ppCity = player.getCity(a)
				if ppCity.isGovernmentCenter():
					if not (ppCity.getNumRealBuilding(gc.getInfoTypeForString("BUILDING_DRILL")) > 0):
						player.getCity(a).setFreeSpecialistCount(gc.getInfoTypeForString("SPECIALIST_GENERAL"), 1)
					else: player.getCity(a).setFreeSpecialistCount(gc.getInfoTypeForString("SPECIALIST_GENERAL"), 2)
		else:
			for b in range(player.getNumCities()):
				ppCity = player.getCity(b)
				if ppCity.isGovernmentCenter(): 
					if not (ppCity.getNumRealBuilding(gc.getInfoTypeForString("BUILDING_DRILL")) > 0):
						player.getCity(b).setFreeSpecialistCount(gc.getInfoTypeForString("SPECIALIST_GENERAL"), 0)
					else: player.getCity(b).setFreeSpecialistCount(gc.getInfoTypeForString("SPECIALIST_GENERAL"), 1)
 
either way if anyone would know how to make the Specialist random instead of static i would be very glad :)

I don't know how to write it syntactically. Conceptually this is how I would go about it: have the function do a game.getSorenRandNum call, then divide that by the number of specialists available. Take the remainder and use it to set the specialist according to the specialistID.
 
Back
Top Bottom