def areTwins(unit1, unit2):
name1 = unit1.id
name2 = unit2.id
if len(name1) != len(name2):
return False
for i in range(len(name1) - 1):
if name1[i] != name2[i]:
return False
return True
def findTwinPairs(units):
twins = []
for i in range(len(units)):
for j in range(i + 1, len(units)):
if areTwins(units[i], units[j]):
twins.append((units[i], units[j]))
return twins
def commandTwinsToPray():
paladins = hero.findByType("paladin")
hero.say("Found " + str(len(paladins)) + " paladins")
if len(paladins) < 2:
hero.say("Not enough paladins!")
return
twinPairs = findTwinPairs(paladins)
for twinPair in twinPairs:
if len(twinPair) != 2:
continue
paladin1, paladin2 = twinPair
if paladin1.canCast("heal") and paladin2.health < paladin2.maxHealth:
hero.command(paladin1, "cast", "heal", paladin2)
if paladin2.canCast("heal") and paladin1.health < paladin1.maxHealth:
hero.command(paladin2, "cast", "heal", paladin1)
while True:
commandTwinsToPray()
enemy = hero.findNearestEnemy()
if enemy:
hero.attack(enemy)
if hero.gold >= hero.costOf("soldier"):
hero.summon("soldier")
it keeps saying im running out of time
hey nvm, i figured out the solution!
2 Likes
This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.