# 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.findFriends()
for soldier in hero.findFriends():
enemy = soldier.findNearestEnemy()
soldiers = hero.findByType("soldier")
if enemy:
hero.command(soldier, "attack", enemy)
# This function commands your soldiers to attack their nearest enemy.
# Define the function: pickUpNearestCoin
def pickUpNearestCoin():
items = hero.findItems()
nearestCoin = hero.findNearest(items)
if nearestCoin:
hero.move(nearestCoin.pos)
while True:
summonSoldiers()
# commandSoldiers()
# pickUpNearestCoin()
commandSoldiers()
pickUpNearestCoin()
Error Message: Line 14: ArgumentError: command’s argument minion should have type unit, but got object: Hector.
# 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():
soldiers = hero.findByType("soldier")
for soldier in soldiers():
enemy = soldier.findNearestEnemy()
soldiers = hero.findByType("soldier")
if enemy:
hero.command(soldier, "attack", enemy)
# This function commands your soldiers to attack their nearest enemy.
# Define the function: pickUpNearestCoin
def pickUpNearestCoin():
items = hero.findItems()
nearestCoin = hero.findNearest(items)
if nearestCoin:
hero.move(nearestCoin.pos)
while True:
summonSoldiers()
# commandSoldiers()
# pickUpNearestCoin()
commandSoldiers()
pickUpNearestCoin()
# 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():
soldiers = hero.findByType("soldier")
for soldier in soldiers():
friends = hero.findFriends()
if enemy:
hero.command(soldier, "attack", enemy)
# This function commands your soldiers to attack their nearest enemy.
# Define the function: pickUpNearestCoin
def pickUpNearestCoin():
items = hero.findItems()
nearestCoin = hero.findNearest(items)
if nearestCoin:
hero.move(nearestCoin.pos)
while True:
summonSoldiers()
# commandSoldiers()
# pickUpNearestCoin()
commandSoldiers()
pickUpNearestCoin()