Desert Combat (SOLVED)


#1

Hi, i’ve been stuck on Desert Combat for a while and was wondering if you could help me. I’m not sure if i just don’t have the methods our something is wrong with my code can you help me.

Heres my code:

# while-loops repeat until the condition is false.

ordersGiven = 0
while ordersGiven < 5:
    # Move down 10 meters.
    pet.moveXY(10, 50)
    # Order your ally to "Attack!" with hero.say
    # They can only hear you if you are on the X.
    hero.say("Attack!")

    # Be sure to increment ordersGiven!
    ordersGiven:

while True:
    enemy = hero.findNearestEnemy()
    # When you're done giving orders, join the attack.
    else:
        hero.attack(enemy)


#2

Hey there!

Alright so I think because you are telling your pet to move not hero. Your XY has a hard factor and you are not telling it to subtract (move down) from the y axis while maintaining your x axis. It is in a true loop so it will keep repeating the move down until the conditions are met ending the while loop.

Also you are not adding to the orders given, it is just left blank. You need to tell the console to add 1 for every loop complete. (check hint section for further details on how to do this in your language)

So by telling your hero to move down 10m and say attack, then adding 1 to your loop, the condition “ordersGiven < 5” will automatically break out of the loop when you hit 5 and continue into your next while true loop.

The first loop “orderGiven < 5” is what it will continue to loop until conditions are met, and then continue onto the next section of your code.

Sorry if I explained this oddly at all. So without giving the answer here is what I do in JavaScript to move down x amount of meters. “hero.moveXY(hero.pos.x, hero.pos,y -10);” so my hero is staying on the same x axis (left to right) and moving down the y axis (up and down).

(I edited this comment a few times so that I gave info without full on giving the answer, I hope this helps!)

Also happy birthday=)


#3

Hi, thank you for the wishes. I was about to fix my code then I went on and now all my progress is gone and i’m all the way in the beginning. I’m wondering if you are able to fix this bug if now I can summon someone else.


#4

Sorry, who are you trying to summon? I think that would be something you need to contact the dev’s about. As far as I know if you are a registered user all your old solutions save. (like if I go back in levels, all my old code is there)


#5

Yes, except when I logged in it says i’m on Kithgard Dungeun, but i’m actually on Sarven Desert, and if I try to go to where i’m at it won’t let me because it’s locked.:confused:


#6

Are you automatically logging onto another account? Is your username, gems, achievements, etc… all the same? I know if I log on a different Facebook/google or am using a different computer and go to automatically log on Codecombat I have to make sure it is specifically selecting my account (sometimes even manually type in my credentials depending the pc)


#7

I think this is something @maka can help with.


#8

Hi.
Either DM me with your username or email team@codecombat.com for assistance (include your username). Also, make sure you’re logged in as the right user – go to https://codecombat.com/account/settings to check.

Maka


#9

Hi, i’m SO sorry! I had made an account earlier and then made a second one later. I logged in my old account and thought it was my main account. Again I’m so sorry, I feel horrible!:disappointed_relieved::slightly_frowning_face:


#10

Hey, we’re all human, we all make mistakes =) I wouldn’t stress lol


#11

I think a computer made a mistake which made somebody get fired before.


#12

Hi, Areau I forgot to tell you thank you! I passed the level! Thank you again!:blush:


#13

Any time Naimaa1! I’m just happy I’ve learned enough that I can pass on the knowledge haha =)


#14

No worries! These things happen (pretty often – which is why I was able to guess it might be the wrong account). Glad it’s resolved. :slight_smile:


#15

Hi there your hero must be move down 10 meters not your pet .