[Adventurer] Wise Moves

rly whyy doesnt it work here is my code

while True:
    coin = hero.findNearestItem()
    if hero.gold >= 50:
        hero.moveXY(30, 50)
    if hero.gold >= 75:
        hero.moveXY(30, 38)
    if hero.gold >= 100:
        hero.moveXY(30, 26)
    elif coin:
        hero.moveXY(coin.pos.x, coin.pos.y)

Since your first if statement is the lowest number, you will always run that code and not the other two. You need to think of a way to prevent the first if statement from running and save the gold for the other ones. Something like, if the ogre passes a certain mark, send a decoy, otherwise nail him with the lightning bolt or archers. Need enchanted lenses or twilight glasses to see the ogre from a good distance.

Also, I suggest switching your last moveXY() to a move() for the coin which will ensure you are chasing down the closest gold coin every step. Speed helps on this level too

i know but the level doesnt work when i stand on the button it doesnt work

You’re probably using the wrong coordinates.

what are the coordinates then?

Read the hints (20 chars)

i did and i put in the coordinates but it doesnt work

while True:
    coin = hero.findNearestItem()
    if hero.gold >= 100:
        hero.moveXY(30, 26)
    elif coin:
        hero.moveXY(coin.pos.x, coin.pos.y)

here is my code

Please explain a little more. What isn’t working? What are you expecting to happen? Are saying you can’t pass the level, or the code doesn’t work. Does an archer appear when you move to the 30,26? From what I can see, your code works as written. Your hero gets 100 coins, moves to the correct coordinate and an archer appears.

Also, for collecting the coins switch the moveXY() to move() to grab the closest coin faster.
Wise Moves

when i stand on the coordinates given in the comments when i stand on the coordinates it doesnt work

@Chaboi_3000 the coordinates for the archer button don’t work.

Try for yourself.

Edit: Never mind, the buttons didn’t work because I was using boss star

Hi SuperSmacker! Welcome back :tada:

I’m probably not playing CodeCombat anymore lol I just wanted to come and check on things

Neither, but I like to help on the forum.
btw Happy Cakeday! It’s all happening at once.

Bumping because I tweaked a little of this level to make archers more useful.
Decoy-No change
Lightning-Nerf. Now deals 100 damage from 500. Stun remains the same.
Archer-Buff. Doubled damage output and increased range.

Please let me know how the new changes feel.

3 Likes

when I did

hero.summon("Lightning-bolt")

It didn’t work

2 Likes

It didn’t say what to call the Lightning Bolt

2 Likes

Please read the hints a little more carefully. It’ll show you the coordinates for the moves :slight_smile:

1 Like

this is my code

# You need to prevent the big brawler from reaching your base! Use the gold you collect to use 3 different moves. 
# There are three moves
'''
Lightning Bolt: 50 coins
Summon Decoy: 75 coins
Summon Archer: 100 coins 
'''
# If you need further info about the moves, read the hints. 
while True:
    item = hero.findNearestItem()
    if item:
        hero.moveXY(item.pos.x, item.pos.y)
    if hero.gold > 50:
        hero.moveXY(30, 50)
        hero.summon("Lightning-Bolt")
2 Likes

You don’t need the hero.summon().

1 Like