I cant seem to beat this level
here is my cade
# If the peasant is damaged, the flowers will shrink!
enemy = hero.findNearestEnemy()
def summonSoldiers():
if hero.gold >= hero.costOf("soldier"):
hero.summon("soldier")
# Define the function: commandSoldiers
def commandSoldiers():
soldiers = hero.findByType("soldier")
for soldier in soldiers:
hero.command(soldier, "defend", peasant)
if enemy:
hero.command(soldier, "attack", enemy)
# Define the function: pickUpNearestCoin
def pickUpNearestCoin():
items = hero.findItems()
for item in items:
coin = hero.findNearestItem()
hero.move(coin.pos)
def attack():
if enemy:
hero.attack(enemy)
peasant = hero.findByType("peasant")[0]
def cleave():
if hero.isReady("cleave"):
hero.move(hero.pos)
hero.cleave(enemy)
while True:
attack()
cleave()
summonSoldiers()
# commandSoldiers()
commandSoldiers()
# pickUpNearestCoin()
pickUpNearestCoin()