Bonjour,
Pouvez-vous m’aider à corriger ce code, j’ai une boucle infinie mais je ne comprends pas pourquoi.
J’utilise comme héro Okar.
def defEnemyAttack():
enemies = hero.findEnemies()
faible = None
moinsSante >= 70
enemyIndex = 0
while enemyIndex < len (enemies):
enemy = enemies [enemyIndex]
if enemy.health < moinsSante:
faible = enemy
moinsSante = enemy.health
hero.attack(enemy)
elif enemy.health > moinsSante:
fort = enemy
if hero.canCast("chain-lightning", fort):
hero.cast("chain-lightning", fort)
elif hero.isReady("bash"):
hero.bash(fort)
elif hero.isReady("throw") and hero.distanceTo(fort.pos) < hero.throwRange:
hero.throw(fort)
elif hero.isReady("stomp"):
hero.stomp(fort)
elif hero.isReady("hurl"):
hero.hurl(fort)
else:
hero.attack(enemy)
enemyIndex += 1
def gold():
presGold = None
minGoldDist = 9001
coinIndex =0
coins = hero.findItems()
for coin in coins:
dist = hero.distanceTo(coin)/coin.value
if minGoldDist > dist:
presGold =coin
minGoldDist = dist
hero.move(presGold.pos)
def point2():
points=[{"x":5, "y":49},{"x":5, "y":20},{"x":76, "y":51},{"x":76, "y":19}]
pointspres = None
minpointdis = 9001
for point in points:
distance2 = hero.distanceTo(point)
if minpointdis > distance2:
pointspres= point
minpointdis= distance2
hero.move(pointspres)
while True:
item = hero.findNearestItem()
enemy = hero.findNearestEnemy()
if item :
gold()
if enemy:
distance = hero.distanceTo(enemy)
if distance<20:
defEnemyAttack()
if hero.health/3:
point2()
gold()



