Hello,
I am at stuck at this level and i don’t understand where the problem comes from.
The level is “Wishing well”.
less = "Nimis"
more = "Non satis"
requiredGold = 104
# This function calculates the sum of coin values.
def sumCoinValues(coins):
i = 0
total = 0
while i < len(coins):
total += coins[i].value
i += 1
return total
while True:
items = hero.findItems()
goldAmount = sumCoinValues(items)
if len(items) != 0:
# If there is not enough gold, then say "Non satis".
if goldAmount < 104:
hero.say("non satis")
if goldAmount >104:
hero.say("Nimis")
if goldAmount == 140:
coins = hero.findItems()
coinIndex = 0
nearest = coin
nearestDistance = 9999
while coinIndex < len(coins):
coin = coins[coinIndex]
coinIndex += 1
distance = hero.distanceTo(coin)
if distance < nearestDistance:
nearest = coin
nearestDistance = distance
if nearest:
hero.moveXY(nearest.pos.x, nearest.pos.y)
if anyone is able to help me, it would be amazing !
Thank you,
Eliot