Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

[SOLVED] Most basic Dueling Grounds confusion

So I can’t really tell what “level” this is - it’s the first instance of dueling grounds, and I’ve been searching for a clue or hint for more than 2 hours and getting nowhere.

It says it’s “Level 20” in the bottom left, and shows 23/122 in “Backwoods Forest”.

It looks there are two players spawned: Myself and “Simple Red CPU” who is outfitted in the same exact gear as me. 4/5 year old “solutions” to this seem to replace “hero.” with self.

Either way, the best I ever do by following the comments is a draw:

// Defeat the enemy hero in a duel!

while(true) {
    // Find and attack the enemy inside a loop.
    // When you're done, submit to the multiplayer ladder!
    var enemy = hero.findNearestEnemy();
    hero.attack(enemy);
    hero.attack(enemy);    
}

Both dead, every time. First simple solution: remove one attack line.

So I attempted to integrate an if/else condition (based on numerous threads about this issue) - but no matter how I position my face, I always get an error adding the “else” statement “Expected an Identifier and instead saw Else”* I’m leaving this here, because after reloading the level about a dozen times, it’s not doing this any more. Problem is, even with an if/else condition the results are the same:

// Defeat the enemy hero in a duel!

while(true) {
    // Find and attack the enemy inside a loop.
    // When you're done, submit to the multiplayer ladder!
    var enemy = hero.findNearestEnemy();
if (enemy) {
    hero.attack(enemy);   
    }
    else {
    hero.shield();
    }
}

Mutual death.

I have no idea what’s expected to survive since my enemy is a clone with the exact same plan and damage capabilities. I attempted to integrate an “if ready cleave” condition, but that fails also - I can add the “if ready” statement, but “cleave” isn’t a method I’m allowed.

I’m totally stumped as to how to survive the duel since the CPU gets my same sword and armor.

Hi, welcome to the CodeCombat discourse.


I'm not sure I understand why you're losing. Your most simple code should win because the CPU says something which slows down it's attack. Could you show me a screenshot of you screen and of you inventory with your equipment on so I can see what's going on. Thanks

-Danny

Inventory Screenshot

image

Could you also show a screenshot of the screen while you’re playing, that’s more important.

Apologies. I’m having to wait 24 hours between every post while they are vetted by moderators I guess. I attempted to upload that screenshot, but it was filtered. It will be a few hours until I can upload it as long this post isn’t referred for moderation. Thanks for your patience and continual engagement, I know waiting on output is annoying, so I really appreciate this.

1 Like

Post execution screenshot

My pleasure. I think the reason is because you’re a new user so you can’t post more than one image per post, sorry about that.
I think I’ve worked out the problem though: I think it’s because your sword does a lot of damage (particularly because you’re using Hattori, the hero who does the most damage) so you and the CPU are doing the same thing, and he doesn’t attack enough to say: “Take that!” and give you time to kill him first. Maybe try warcry, it might give you enough of an advantage over him.
Most people wouldn’t have such a good sword though, so don’t worry too much about drawing with the CPU, you’ll probably be able to beat a lot of other people. (Although you do need to beat the CPU at the start, if warcry doesn’t work, try buying some of the rings (“earthskin”, “regeneration”, “thornprick”) or getting the emperor’s gloves. They’re expensive, but they’re really worth it.
I hope this helps,
-Danny

The sword was it. I backed down to the basic sword (kept armor and other equipment the same) and worked 1st try. Thanks very much for your input.

1 Like