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

Mountain:square-shield

Doesnt make a square if they both move to bottom left corner of square i think.

// Incoming yeti attack! Use your paladins to form a square!
// Remember squares have equal-length sides!

function findByName(name, thangs) {
    for(var i = 0; i < thangs.length; i++) {
        var thang = thangs[i];
        if(thang.id == name) {
            return thang;
        }
    }
    return null;
}
var friends = hero.findFriends();
// Celadia is in the top left corner.
var celadia = findByName("Celadia", friends);
// Dedalia is in the top right corner.
var dedalia = findByName("Dedalia", friends);
var sideLength = celadia.distanceTo(dedalia);

// Illumina and Vaelia should finish forming a square!
var vaelia = findByName("Vaelia", friends);
var illumina = findByName("Illumina", friends);

// Command Vaelia to move to the bottom left corner of the square.
var target = {"x":celadia.pos.x,"y":celadia.pos.y-sideLength};
hero.command(vaelia, "move", target);
// Command Illumina to move to the bottom left corner of the square.
target = {"x":dedalia.pos.x,"y":celadia.pos.y-sideLength};
hero.command(illumina, "move", target);


I may be wrong, but you did not define the x y coordinates.

My codes good it runs fine
I just think that the comments are missleading
because we would end up with a triangle if both of them went to one corner

In that case it may be a glitch or a bug. Ask nick or Bryukh

@Luke10 please mention only@stephanie for support. Thanks.

1 Like