How is this not working for the commandSoldier() function?
def summonSoldier():
hero.summon("soldier")
def commandSoldier():
friend = hero.findFriends()
enemy = friend.findNearestEnemy()
if enemy:
hero.command(archer, "attack", enemy)
while True:
enemy = hero.findNearestEnemy()
summonSoldier()
commandSoldier()
if hero.isReady("cleave"):
hero.cleave(enemy)
elif hero.isReady("bash"):
hero.bash(enemy)
else:
hero.attack(enemy)
I do have boss star one.
abc
September 9, 2021, 8:03pm
2
Your hero is not always ready to summon a soldier. Each one costs 25 gold, so if your hero’s gold is less than that amount, it will stop and wait until its gold reaches twenty five.
def summonSoldier():
if hero.gold >= 25:
hero.summon("soldier")
def commandSoldier():
friend = hero.findFriends()
enemy = friend.findNearestEnemy()
if enemy:
hero.command(archer, "attack", enemy)
while True:
enemy = hero.findNearestEnemy()
summonSoldier()
commandSoldier()
if hero.isReady("cleave"):
hero.cleave(enemy)
elif hero.isReady("bash"):
hero.bash(enemy)
else:
hero.attack(enemy)
The main problem is in here.
“friend has no method of findNearestEnemy”
ok so friend is a variable containing ALL of your friends. maybe do friend = hero.findNearestFriend()
?
and this goes in the level help category
I did that, now it says “type error”
abc
September 9, 2021, 8:35pm
10
You can do:
friends = hero.findFriends()
for friend in friends:
#code
or
friend = hero.findNearest(hero.findFriends())
1 Like
Thanks, abc, that worked!
1 Like
system
Closed
September 10, 2021, 8:40am
12
This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.