# Your goal is to collect coins / gems.
# This level is repeatable. If you win, the difficulty and rewards will increase.
# If you fail, you have to wait a day to resubmit.
# This level is an optional challenge level. You don't need to beat it to continue the campaign!
'''
def collect():
peasants = hero.findByType("peasant")
for peasant in peasants:
if peasant and peasant.team == hero.team:
item = peasant.findNearestItem()
if item:
hero.command(peasant, "move", item.pos)
hero.cast("summon-burl")
hero.cast("summon-undead")
burl = hero.findByType("burl")[0]
hero.cast("sacrifice", burl, hero)
while True:
enemy = hero.findNearestEnemy()
burls = hero.findByType("burl")
undeads = hero.findByType("skeleton")
collect()
for burl in burls:
if burl and hero.canCast("sacrifice", burl):
hero.cast("sacrifice", burl, hero)
if enemy:
if hero.canCast("devour", enemy):
hero.cast("devour", enemy)
elif hero.canCast("poison-cloud", enemy):
hero.cast("poison-cloud", enemy)
elif hero.canCast("chain-lightning", enemy):
hero.cast("chain-lightning", enemy)
elif hero.canCast("drain-life", enemy):
hero.cast("drain-life", enemy)
elif hero.canCast("fear", enemy):
hero.cast("fear", enemy)
elif enemy.target == hero and hero.isReady("shape-shift"):
pet.shapeShift()
hero.attack(enemy)
if hero.isReady("summon-burl"):
hero.cast("summon-burl")
if hero.isReady("summon-undead"):
hero.cast("summon-undead")
'''
'''
def findStrongestEnemy():
strongest = None
strongestHealth = 0
enemies = hero.findEnemies()
for enemy in enemies:
if enemy.health > strongestHealth:
strongestHealth = enemy.health
strongest = enemy
return strongest
def onSpawn():
while True:
pet.moveXY(76, 107)
pet.shapeShift()
def collect():
peasants = hero.findByType("peasant")
for peasant in peasants:
if peasant and peasant.team == hero.team:
item = peasant.findNearestItem()
if item:
hero.command(peasant, "move", item.pos)
hero.cast("summon-burl")
hero.cast("summon-undead")
burl = hero.findByType("burl")[0]
hero.cast("sacrifice", burl, hero)
pet.on("spawn", onSpawn)
while True:
enemy = hero.findNearestEnemy()
enemies = hero.findEnemies()
burls = hero.findByType("burl")
undeads = hero.findByType("skeleton")
collect()
for undead in undeads:
if undead and hero.canCast("sacrifice", undead):
hero.cast("sacrifice", undead, hero)
for burl in burls:
if burl and hero.canCast("sacrifice", burl):
hero.cast("sacrifice", burl, hero)
if enemy:
if hero.canCast("devour", findStrongestEnemy()):
hero.cast("devour",findStrongestEnemy())
elif hero.canCast("poison-cloud", findStrongestEnemy()):
hero.cast("poison-cloud", findStrongestEnemy())
elif hero.canCast("chain-lightning", findStrongestEnemy()):
hero.cast("chain-lightning", findStrongestEnemy())
elif hero.canCast("drain-life", findStrongestEnemy()):
hero.cast("drain-life", findStrongestEnemy())
elif hero.canCast("fear", findStrongestEnemy()):
hero.cast("fear", findStrongestEnemy())
hero.attack(findStrongestEnemy())
if hero.isReady("summon-burl"):
hero.cast("summon-burl")
if hero.isReady("summon-undead"):
hero.cast("summon-undead")
for dead in hero.findCorpses():
if dead and hero.distanceTo(dead) < 20 and hero.canCast("raise-dead"):
hero.cast("raise-dead")
else:
if dead and hero.canCast("raise-dead"):
hero.move(dead.pos)
hero.cast("raise-dead")
peasants = hero.findByType("peasant")
for peasant in peasants:
if hero.gold >= 25 and enemy:
hero.command(peasant, "buildXY","decoy", peasant.pos.x, peasant.pos.y)
'''
# Your goal is to collect coins / gems.
# This level is repeatable. If you win, the difficulty and rewards will increase.
# If you fail, you have to wait a day to resubmit.
# This level is an optional challenge level. You don't need to beat it to continue the campaign!
'''
def collect():
peasants = hero.findByType("peasant")
for peasant in peasants:
if peasant and peasant.team == hero.team:
item = peasant.findNearestItem()
if item:
hero.command(peasant, "move", item.pos)
hero.cast("summon-burl")
hero.cast("summon-undead")
burl = hero.findByType("burl")[0]
hero.cast("sacrifice", burl, hero)
while True:
enemy = hero.findNearestEnemy()
burls = hero.findByType("burl")
undeads = hero.findByType("skeleton")
collect()
for burl in burls:
if burl and hero.canCast("sacrifice", burl):
hero.cast("sacrifice", burl, hero)
if enemy:
if hero.canCast("devour", enemy):
hero.cast("devour", enemy)
elif hero.canCast("poison-cloud", enemy):
hero.cast("poison-cloud", enemy)
elif hero.canCast("chain-lightning", enemy):
hero.cast("chain-lightning", enemy)
elif hero.canCast("drain-life", enemy):
hero.cast("drain-life", enemy)
elif hero.canCast("fear", enemy):
hero.cast("fear", enemy)
elif enemy.target == hero and hero.isReady("shape-shift"):
pet.shapeShift()
hero.attack(enemy)
if hero.isReady("summon-burl"):
hero.cast("summon-burl")
if hero.isReady("summon-undead"):
hero.cast("summon-undead")
'''
def findStrongestEnemy():
strongest = None
strongestHealth = 0
enemies = hero.findEnemies()
for enemy in enemies:
if enemy.health > strongestHealth:
strongestHealth = enemy.health
strongest = enemy
return strongest
def onSpawn():
while True:
pet.moveXY(76, 107)
pet.shapeShift()
def collect():
peasants = hero.findByType("peasant")
for peasant in peasants:
if peasant and peasant.team == hero.team:
item = peasant.findNearestItem()
if item:
hero.command(peasant, "move", item.pos)
hero.cast("summon-burl")
hero.cast("summon-undead")
burl = hero.findByType("burl")[0]
hero.cast("sacrifice", burl, hero)
pet.on("spawn", onSpawn)
while True:
enemy = hero.findNearestEnemy()
enemies = hero.findEnemies()
burls = hero.findByType("burl")
undeads = hero.findByType("skeleton")
collect()
for undead in undeads:
if undead and hero.canCast("sacrifice", undead):
hero.cast("sacrifice", undead, hero)
for burl in burls:
if burl and hero.canCast("sacrifice", burl):
hero.cast("sacrifice", burl, hero)
if enemy:
if hero.canCast("devour", findStrongestEnemy()):
hero.cast("devour",findStrongestEnemy())
elif hero.canCast("poison-cloud", findStrongestEnemy()):
hero.cast("poison-cloud", findStrongestEnemy())
elif hero.canCast("chain-lightning", findStrongestEnemy()):
hero.cast("chain-lightning", findStrongestEnemy())
elif hero.canCast("drain-life", findStrongestEnemy()):
hero.cast("drain-life", findStrongestEnemy())
elif hero.canCast("fear", findStrongestEnemy()):
hero.cast("fear", findStrongestEnemy())
hero.attack(findStrongestEnemy())
if hero.isReady("summon-burl"):
hero.cast("summon-burl")
if hero.isReady("summon-undead"):
hero.cast("summon-undead")
for dead in hero.findCorpses():
if dead and hero.distanceTo(dead) < 20 and hero.canCast("raise-dead"):
hero.cast("raise-dead")
else:
if dead and hero.canCast("raise-dead"):
hero.move(dead.pos)
hero.cast("raise-dead")
peasants = hero.findByType("peasant")
for peasant in peasants:
if hero.gold >= 25 and enemy and enemy.target == hero or enemy.target == peasant:
hero.command(peasant, "buildXY","decoy", peasant.pos.x, peasant.pos.y)