[SOLVED]Underground Business

Is your indentation right

Just to make sure, you guys are doing python right?

1 Like

Yes of course

I’ll translate this first your saying if their is a enemy attack it but if their is not a enemy move to 21, 34 and if you have over three hundred gold break the loop

i sugest you read this comment really carefully

2 Likes

Please format it correctly.
Lydia

2 Likes

I think I got the answer.I less than 300 not more. thank you sooooooooooooooooooo much

That is not what I meant please can you post your most recent FORMATTED code

this is my 1st time doing the forum.

:grimacing: :grimacing: :grimacing:

Hello and welcome to codecombat discourse! This is a cozy forum where you can share ideas, share fan art, get assistance for code, etc! Before you proceed, we hope that you review this topic, which shows all essentials of this board! Thanks!

Then review this page please

I think it is your second isint it?

yeah but the thing on top of the screen says @Pameleen didnt post for 2 years

ummmmmmmmmmmmmm no. dont think so.

I know just nevermind.

Can you please post your code?


# Accumulate 300 gold and escape from the dungeon.

def onSpawn(event):
    # Send the pet to walk around the dungeon:
    pet.moveXY(69, 57)
    pet.moveXY(71, 57)
    pet.moveXY(71, 11)
    pet.moveXY(20, 11)
    pet.moveXY(21, 36)
    pet.moveXY(15, 36)
    pet.moveXY(hero.pos.x, hero.pos.y)
    # Don't forget to return it to the hero:
    
    pass

pet.on("spawn", onSpawn)

while True:
    # Guard peasants:
    enemy = hero.findNearestEnemy()
    # When you have 300+ gold move to the red mark:
    if enemy:
        hero.attack(enemy)
        hero.attack(enemy)
        hero.attack(enemy)    
        hero.attack(enemy)
    else:
        hero.moveXY(21, 34)
    if hero.gold>=300:
        break
hero.moveXY(50, 34)

did it work right!!!

1 Like

do you notice anything wrong?

you dont need four attacks because itt is in the loop

delete this

Your code should work

does not work.Still the same thing is wrong.