Hello:
I am coding in Python, but my problem with this level is that my while True loop doesn’t repeat itself.
Can anybody tell me, what am I doing wrong?
Here is my code:
hero.moveXY(18,40)
while True:
friendFoeObject()
movement()
def friendFoeObject():
while True:
friend = hero.findNearestFriend()
enemy = hero.findNearestEnemy()
item = hero.findNearestItem()
if friend:
if friend.type == "soldier":
hero.cast("heal", friend)
if friend.type == "goliath":
hero.cast("grow", friend)
if friend.type == "paladin":
hero.cast("regen", friend)
elif enemy:
if enemy.type == "scout":
hero.cast("force-bolt", enemy)
if enemy.type == "brawler":
hero.cast("shrink", enemy)
if enemy.type == "ogre":
hero.cast("poison-cloud", enemy)
elif item:
if item.type != "poison":
hero.moveXY(item.pos.x, item.pos.y)
else:
continue
else:
continue
def movement():
x = hero.pos.x
y = hero.pos.y
if y == 40:
hero.moveXY(x,y-16)
elif y == 24:
hero.moveXY(x+16,y+16)