Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

[SOLVED] Two flowers stuck


#1
# If the peasant is damaged, the flowers will shrink!

def summonSoldiers():
    if hero.gold >= hero.costOf("soldier"):
        hero.summon("soldier")
    

# Define the function: commandSoldiers
def commandSoldiers():
    friends = hero.findByType("soldier")
    for friend in friends:
        enemy = hero.findNearestEnemy()
        if enemy:
            hero.command(friend, "attack", enemy)
            # Define the function: pickUpNearestCoin
def pickUpNearestCoin():
    item = hero.findNearestItem()
    if item:
        hero.move(item.pos)
peasant = hero.findByType("peasant")[0]

while True:
    castable = hero.canCast("haste", self)
    enemy = hero.findNearestEnemy()
    castable2 = hero.canCast("chain-lightning", enemy)
    
    if castable:
        hero.cast("haste", self)
    else:
        hero.resetCooldown("haste")
    summonSoldiers()
    # commandSoldiers()
    # pickUpNearestCoin()
    commandSoldiers()
    pickUpNearestCoin()

How do I solve this, Hector keep dying but I think my code is correct. Can someone help me?


#2

Try removing the casting part.


#3

Thanks! Maybe that will work.