Hi all - First time through Code Combat and I’m stuck at the “Wishing Well” level on the desert map. I’m pretty confident my code is good, and I’ve even tried code from other users for this level, but the level keeps saying “Goals: Ran out of time”. One thing I noticed is that the amount of gold shown at the top of the screen keeps increasing until it gets to ~190 gold, then never goes down again. Is this a bug, or am I doing something wrong? Please help because I can’t progress in this game…
less = "Nimis"
more = "Non satis"
requiredGold = 104
# This function calculates the sum of coin values.
def sumCoinValues(coins):
total = 0
for coin in coins:
total += coin.value
return total
def collectCoins(coins):
for coin in coins:
hero.moveXY(coin.pos.x, coin.pos.y)
while True:
items = hero.findItems()
goldAmount = sumCoinValues(items)
if len(items) != 0:
# If there is not enough gold, then say "Non satis".
if goldAmount < requiredGold:
hero.say(less)
elif goldAmount > requiredGold:
hero.say(more)
elif goldAmount == requiredGold:
collectCoins(items)