def reqRepair(pCaster, iAmount = 30, eSpell=-1):
pPlot = pCaster.plot()
sRetrofit = 'SPELL_RETROFIT_GOLEM'
iGolem = gc.getInfoTypeForString('PROMOTION_GOLEM')
iRusted = gc.getInfoTypeForString('PROMOTION_RUSTED')
lCombats = [gc.getInfoTypeForString('UNITCOMBAT_NAVAL'), gc.getInfoTypeForString('UNITCOMBAT_SIEGE')]
for i in xrange(pPlot.getNumUnits()):
pUnit = pPlot.getUnit(i)
if pUnit.getDuration() > 0:continue
if pUnit.isHasPromotion(iRusted):
return True
iRace = pUnit.getRace()
if iRace == iGolem:
if reqRetrofitGolem(pUnit, sRetrofit):
return True
if pUnit.getDamage() > 0:
return True
if iRace == iGolem:
return True
elif iRace == -1:
if pUnit.getUnitCombatType() in lCombats:
if pUnit.getDamage() > 0:
return True
return False
def spellRepair(pCaster, iAmount = 30, eSpell=-1):
pPlot = pCaster.plot()
sRetrofit = 'SPELL_RETROFIT_GOLEM'
iRusted = gc.getInfoTypeForString('PROMOTION_RUSTED')
iGolem = gc.getInfoTypeForString('PROMOTION_GOLEM')
lCombats = [gc.getInfoTypeForString('UNITCOMBAT_NAVAL'), gc.getInfoTypeForString('UNITCOMBAT_SIEGE')]
for i in xrange(pPlot.getNumUnits()):
pUnit = pPlot.getUnit(i)
if pUnit.getDuration() > 0:continue
if pUnit.getDamage() == 0:continue
iRace = pUnit.getRace()
if iRace == iGolem:
pUnit.changeDamage(-iAmount, PlayerTypes.NO_PLAYER)
pUnit.setHasPromotion(iRusted, False)
if reqRetrofitGolem(pUnit, sRetrofit):
spellRetrofitGolem(pUnit, sRetrofit)
elif iRace == -1:
if pUnit.getUnitCombatType() in lCombats:
pUnit.changeDamage(-iAmount, PlayerTypes.NO_PLAYER)
pUnit.setHasPromotion(iRusted, False)
def helpRepair(lpUnits, iAmount = 30, eSpell=-1):
szBuffer = ''
pCaster = lpUnits[0]
iCount = 0
lTargets= []
lRusted = []
lRetrofit = []
pPlot = pCaster.plot()
sRetrofit = gc.getInfoTypeForString('SPELL_RETROFIT_GOLEM')
iRusted = gc.getInfoTypeForString('PROMOTION_RUSTED')
iGolem = gc.getInfoTypeForString('PROMOTION_GOLEM')
lCombats = [gc.getInfoTypeForString('UNITCOMBAT_NAVAL'), gc.getInfoTypeForString('UNITCOMBAT_SIEGE')]
for i in xrange(pPlot.getNumUnits()):
pUnit = pPlot.getUnit(i)
if pUnit.getDuration() > 0:continue
if pUnit.isHasPromotion(iRusted):
lRusted.append(pUnit)
iRace = pUnit.getRace()
if iRace == iGolem:
if reqRetrofitGolem(pUnit, sRetrofit):
lRetrofit.append(pUnit)
elif pUnit.getDamage() == 0:continue
iCount += 1
lTargets.append(pUnit)
elif iRace == -1:
if pUnit.getDamage() == 0:continue
if pUnit.getUnitCombatType() in lCombats:
iCount += 1
lTargets.append(pUnit)
lTargets = list(set(lTargets))
if len(lRetrofit) > 0:
szBuffer += helpRetrofitGolem(lRetrofit, sRetrofit)
iCount = len(lRusted)
if iCount > 0:
szBuffer += helpTogglePromotionsSpecificUnits(lRusted, eSpell, [], ['PROMOTION_RUSTED'], False)
iCount = len(lTargets)
if iCount > 0:
if iCount == 1:
pUnit = lTargets.pop(0)
pPlayer = gc.getPlayer(pUnit.getOwner())
sList = "<color=%d,%d,%d,%d>%s</color>" %(pPlayer.getPlayerTextColorR(), pPlayer.getPlayerTextColorG(), pPlayer.getPlayerTextColorB(), pPlayer.getPlayerTextColorA(), pUnit.getName() )
szBuffer += localText.getText("TXT_KEY_HELP_SPELL_TARGETS_THIS", ( sList, ))
elif iCount > 0:
sList = ''
while len(lTargets) > 0:
pUnit = lTargets.pop(0)
pPlayer = gc.getPlayer(pUnit.getOwner())
sList += "<color=%d,%d,%d,%d>%s</color>" %(pPlayer.getPlayerTextColorR(), pPlayer.getPlayerTextColorG(), pPlayer.getPlayerTextColorB(), pPlayer.getPlayerTextColorA(), pUnit.getName() )
if len(lTargets) > 0:
if len(lTargets) == 1:
sList += " and "
else:
sList += ", "
szBuffer += localText.getText("TXT_KEY_HELP_SPELL_TARGETS_THESE_COUNT_LIST", (iCount, sList, ))
return szBuffer