Can this work?

hrochland

Prince
Joined
Apr 9, 2006
Messages
2,511
Location
Czech Kingdom
Those of you who understand python, please tell me can this work?
I need in a new victory type count how many has player the number one resource type.

PHP:
					iRow = screen.appendTableRow(szTable)
          iBonus = pPlot.getBonusType(-1)
					screen.setTableText(szTable, 0, iRow, gc.getBonusInfo(gc.getInfoTypeForString("BONUS_WHEAT")).getDescription(), gc.getBonusInfo(gc.getInfoTypeForString("BONUS_WHEAT")).getButton(), WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
					screen.setTableText(szTable, 2, iRow, pTeam.getName() + ":", sLeaderButton, WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
					screen.setTableText(szTable, 3, iRow, str(pTeam.getBonusClassCount(gc.getInfoTypeForString("BONUS_WHEAT"))), "", WidgetTypes.WIDGET_GENERAL, -1, -1, CvUtil.FONT_LEFT_JUSTIFY)
 
The purpose of the code is an attempt to remake one of the new victory by Platyping to calculate the amount of a bonus to the amount determined to win. (Bonuses will be of course more and will not WHEAT as in try code.)
I'm not a programmer, and unfortunately Platy is not programming in this time and without this victory is not my work from last month meaningful. If anyone can help with the code, I'll be very happy. thanks
hroch
 
I'm not sure, But you could use something like this code:

Code:
def isResourceVictory(iPlayer):
	
	iVictoryThreshold = 20
	pPlayer = gc.getPlayer(iPlayer)
	bVictory = False
	
	for iBonus in range(gc.getNumBonusInfos()):
		if pLayer.hasBonus(iBonus):
			if pPlayer.getNumTradeableBonuses(iBonus) > iVictoryThreshold:
				bVictory = True
				break
				
	return bVictory

The code loops through all the bonuses and if the player has a large number of a specific bonus available for trade then victory is achieved. You can set the threshold number required for the victory. For example: If a player has 21 wheat available to trade, then the function returns true. A return true can be used to trigger the victory.
 
Back
Top Bottom