jkp1187
Unindicted Co-Conspirator
Hello again. Just wondering if someone could help me understand how this code works. Couldn't see anything relating to this in the SDK nor in the API.
The code starts off with this function and follows with what appears to be a list of resources with varying numbers (abbreviated for space) from CvEventManager.py:
Then it follows up with what appears to be the code controlling when the resources deplete:
My question is: how can I adjust the likelihood of a resource depleting? I figure that this code was written more or less with the scenario in mind, not so much the epic-style game....so I probably want to make the resources LESS likely to deplete. I further assume that the numbers next to the resource names weigh on this factor -- but does a higher number mean a higher chance of depletion?
Anything that can be offered to help me understand this would be appreciated!
The code starts off with this function and follows with what appears to be a list of resources with varying numbers (abbreviated for space) from CvEventManager.py:
Code:
def doCheckDepletion(self):
self.doCheckWorkedResource("BONUS_ALUMINUM", "IMPROVEMENT_MINE", 880)
self.doCheckWorkedResource("BONUS_COAL", "IMPROVEMENT_MINE", 880)
self.doCheckWorkedResource("BONUS_COPPER", "IMPROVEMENT_MINE", 880)
self.doCheckWorkedResource("BONUS_CORN", "IMPROVEMENT_FARM", 1120)
self.doCheckWorkedResource("BONUS_MARBLE", "IMPROVEMENT_QUARRY", 880)
self.doCheckWorkedResource("BONUS_OIL", "IMPROVEMENT_WELL", 880)
self.doCheckWorkedResource("BONUS_OIL", "IMPROVEMENT_OFFSHORE_PLATFORM", 880)
self.doCheckWorkedResource("BONUS_PIG", self.doCheckWorkedResource("BONUS_URANIUM", "IMPROVEMENT_MINE", 880)
self.doCheckWorkedResource("BONUS_WHALE", "IMPROVEMENT_WHALING_BOATS", 560)
self.doCheckWorkedResource("BONUS_WHEAT", "IMPROVEMENT_FARM", 1120)
self.doCheckWorkedResource("BONUS_WINE", "IMPROVEMENT_WINERY", 1120)
Then it follows up with what appears to be the code controlling when the resources deplete:
Code:
def doCheckWorkedResource(self, bonus, improvement, randomInt):
iBonus = CvUtil.findInfoTypeNum(gc.getBonusInfo, gc.getNumBonusInfos(), bonus)
if (iBonus == -1):
return
lValidPlots = self.getPlotListbyBonus(iBonus)
if len(lValidPlots) == 0:
return
for plot in lValidPlots:
if plot.getImprovementType() == CvUtil.findInfoTypeNum(gc.getImprovementInfo, gc.getNumImprovementInfos(), improvement):
if self.getRandomNumber(randomInt) == 0:
pBonusInfo = gc.getBonusInfo(iBonus)
plot.setBonusType(-1)
szTitle = localText.getText("TEXT_KEY_NEXT_WAR_RESOURCE_DEPLETED_TITLE", ())
#szText = localText.getText("TEXT_KEY_NEXT_WAR_RESOURCE_DEPLETED", (pBonusInfo.getDescription(), plot.getX(), plot.getY()))
CyInterface().addMessage(plot.getOwner(), False, gc.getEVENT_MESSAGE_TIME(), szTitle, "AS2D_DISCOVERBONUS", InterfaceMessageTypes.MESSAGE_TYPE_MINOR_EVENT, pBonusInfo.getButton(), gc.getInfoTypeForString("COLOR_GREEN"), plot.getX(), plot.getY(), True, True)
def getPlotListbyBonus(self, iBonus):
lPlots = []
totalPlots = gc.getMap().numPlots()
for i in range(totalPlots):
plot = gc.getMap().plotByIndex(i)
iOwner = plot.getOwner()
if (iOwner != -1):
if plot.getBonusType(gc.getPlayer(iOwner).getTeam()) == iBonus:
lPlots.append(plot)
return lPlots
def getRandomNumber(self, int):
return CyGame().getSorenRandNum(int, "Next War")
My question is: how can I adjust the likelihood of a resource depleting? I figure that this code was written more or less with the scenario in mind, not so much the epic-style game....so I probably want to make the resources LESS likely to deplete. I further assume that the numbers next to the resource names weigh on this factor -- but does a higher number mean a higher chance of depletion?
Anything that can be offered to help me understand this would be appreciated!