PHP-Code:
# Cultivates eBonus on current plot (80% chance). Unit does not need to stand on pPlot (cultivation from city)
def doCultivateBonus(pPlot, pUnit, eBonus):
global lCultivatable
if pPlot == None or pPlot.isNone(): return False
iPlayer = pUnit.getOwner()
pPlayer = gc.getPlayer(iPlayer)
iChance = getBonusCultivationChance(iPlayer, pPlot, eBonus)
ePlotBonus = pPlot.getBonusType(-1)
# If there is an invisible (tech reveal), uncultivatable bonus on pPlot, doCultivateBonus can be called, but the chance is nullified.
# Player receives NO unique message, just the normal one ("cultivation failed").
if ePlotBonus != -1 and ePlotBonus not in lCultivatable: iChance = 0
#CyInterface().addMessage(iPlayer, True, 10, str(eBonus), None, 2, None, ColorTypes(7), pPlot.getX(), pPlot.getY(), True, True)
if iChance > CvEventInterface.getEventManager().myRandom(100, None):
pPlot.setBonusType(eBonus)
if pPlayer.isHuman():
CyInterface().addMessage(iPlayer, True, 10, CyTranslator().getText("TXT_KEY_POPUP_BONUSVERBREITUNG_DONE",(gc.getBonusInfo(eBonus).getDescription(),)), None, 2, gc.getBonusInfo(eBonus).getButton(), ColorTypes(8), pPlot.getX(), pPlot.getY(), True, True)
pUnit.kill(1, iPlayer)
else:
# remove bonus string from script data
sScriptDataString = CvUtil.getScriptData(pUnit, ["cultivationBonuses"], "")
lBonusList = convertStringToIntList(sScriptDataString)
lBonusList.remove(eBonus)
CvUtil.addScriptData(pUnit, "cultivationBonuses", convertIntListToString(lBonusList))
if pPlayer.isHuman():
if pPlot.isCity(): pCity = pPlot.getPlotCity()
else: pCity = pPlot.getWorkingCity()
CyInterface().addMessage(iPlayer, True, 10, CyTranslator().getText("TXT_KEY_INFO_BONUSVERBREITUNG_NEG",(gc.getBonusInfo(eBonus).getDescription(),pCity.getName())), None, 2, gc.getBonusInfo(eBonus).getButton(), ColorTypes(7), pPlot.getX(), pPlot.getY(), True, True)