Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team

The two flowers help please

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

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

# Define the function: commandSoldiers
def commandSoldiers():
    for soldier in hero.findFriends():
        enemy = soldier.findNearestEnemy()
        if enemy:
            hero.command(soldier, "attack", enemy)
# Define the function: pickUpNearestCoin
def pickUpNearestCoin():
    items = hero.findItems()
    nearestCoin = hero.findNearest(items)
    if nearestCoin:
peasant = hero.findByType("peasant")[0]

while True:


You haven’t stated what’s wrong but looking at your code I’m figuring that the soldiers aren’t attacking. Is this correct?


Yes, I just ran your code. Soldier is not defined. Try defining friend first and then (after the for statement) using if friend.type == soldier.

You’re really close and the for statement should have friend as well, not soldier.