Bank Raid Level Not Working (Solved)

This is my code

# Wait for ogres, defeat them and collect gold.

while True:
    enemies = hero.findEnemies()
    # That variable is used to iterate "enemies" array.
    enemyIndex = 0
    # While it less than the array length:
    while enemyIndex < len(enemies):
        # Get an enemy from the array.
        enemy = enemies[enemyIndex]
        hero.attack(enemy)
        # Increase "enemyIndex" by one.
        enemyIndex += 1
    coins = hero.findItems()
    # That variable is used to iterate "coins" array.
    coinIndex = 0
    while coinIndex < len(coins):
        # Get a coin from the "coins" array at coinIndex.
        coin = coins[coinIndex]
        # Collect that coin.
        hero.moveXY(coin.pos.x, coin.pos.y)
        # Increase "coinIndex" by one.
        coinIndex = coinIndex + 1
        pass

But for some reason my hero just sits there and doesn’t collet the coins.

2 Likes

Your Code is OK and it works for me.

2 Likes

what glasses are you using?

1 Like

I have the enchanted lens on

1 Like

Try resubmitting the code and if that doesn’t work perhaps insert a hero.say() after the coins detection.

coins = hero.findItems()
hero.say("Coins length= " + coins.length)
1 Like

The code gets stuck on the second loop after it finishes killing the ogres.

1 Like

It’s solved. apply the level doesn’t work with wizards so I changed my hero into a melee hero and it worked

1 Like

WHY is it that we need to not use wizards on this level? Codewise I mean. Did I miss something along the way?

1 Like

It works with wizards, but for them you need another solution than for a warrior.

1 Like

well right now i had see this same bug.

my solution (in spanish, i translate all text i can to my native language, including comments and variables) was using the warrior :

# Espera por los ogros, derrotales y recoge oro.

while True:
    Enemigos = hero.findEnemies()
    # IndiceDeEnemigos es usado para iterar el arreglo Enemigos
    IndiceDeEnemigos = 0
    # Mientas IndiceDeEnemigos es menor que len(Enemigos)
    while IndiceDeEnemigos < len(Enemigos):
	# Atacar a los enemigos en IndiceDeEnemigos
        Enemigo = Enemigos[IndiceDeEnemigos]
        hero.isReady("cleave") and hero.cleave(Enemigo)
	# Incrementar IndiceDeEnemigos en uno.
        IndiceDeEnemigos += 1
    Monedas = hero.findItems()
    #DILO#hero.say("Monedas= " + Monedas.length)
    # Monedero es usado para iterar el arreglo Monedas
    Monedero = 0
    while Monedero < len(Monedas):
        # Recoge una moneda de las monedas usando el arreglo Monedero
	Moneda = Monedas[Monedero]
	# Recoge esa moneda
        hero.moveXY(Moneda.pos.x, Moneda.pos.y)
	# Incrementa el Monedero en 1
        Monedero += 1

For some strange reason, if i try to use hero.attack instead hero.isReady(“cleave”) and hero.attack(“cleave”)

When the hero defeat the enemies and the coins appears, the warrior, don’t move to pick up coins.

but when i change attack method for cleave, the hero yes pick up the cleave, but i don’t understand why.

1 Like

same i dont know why tho

Hi @yAin_jAne. Welcome to the CodeCombat Discourse.
If you have a problem with your code please post it here, formatted as it says here.
Thanks,
:lion: :lion: :lion: