I am playing binary deployment, but I am having a few problems. I made a function that deploys the soldiers/archers in the correct order, but they don’t do it fast enough. I run out of time. if I run it too fast, they don’t receive my commands, but if I run it too slow, they don’t get done in time. My other problem is that I can’t find the paladin’s deployment attribute for the number.
When I hit submit, the paladin’s number changes, and I have to change the number that is plugged into my function. How do I save the number stated as a variable that can be used for my function? Here’s my code:
this.deployLine = function(number,paladinX,paladinY){
var binary = [“soldier”,“archer”];
if (number>=128){
this.summon(binary[1]);
var friend = this.findNearest(this.findFriends());
this.command(friend, “move”, {x:paladinX+5,y:paladinY});
number = number-128;
}else{
this.summon(binary[0]);
friend = this.findNearest(this.findFriends());
this.command(friend, “move”, {x:paladinX+5,y:paladinY});
}
if (number>=64){
this.summon(binary[1]);
friend = this.findNearest(this.findFriends());
this.command(friend, “move”, {x:paladinX+10,y:paladinY});
number = number-64;
}else{
this.summon(binary[0]);
friend = this.findNearest(this.findFriends());
this.command(friend, “move”, {x:paladinX+10,y:paladinY});
}
if (number>=32){
this.summon(binary[1]);
friend = this.findNearest(this.findFriends());
this.command(friend, “move”, {x:paladinX+15,y:paladinY});
number = number-32;
}else{
this.summon(binary[0]);
friend = this.findNearest(this.findFriends());
this.command(friend, “move”, {x:paladinX+15,y:paladinY});
}
if (number>=16){
this.summon(binary[1]);
friend = this.findNearest(this.findFriends());
this.command(friend, “move”, {x:paladinX+20,y:paladinY});
number=number-16;
}else{
this.summon(binary[0]);
friend = this.findNearest(this.findFriends());
this.command(friend, “move”, {x:paladinX+20,y:paladinY});
}
if (number>=8){
this.summon(binary[1]);
friend = this.findNearest(this.findFriends());
this.command(friend, “move”, {x:paladinX+25,y:paladinY});
}else{
this.summon(binary[0]);
friend = this.findNearest(this.findFriends());
this.command(friend, “move”, {x:paladinX+25,y:paladinY});
}
if (number>=4){
this.summon(binary[1]);
friend = this.findNearest(this.findFriends());
this.command(friend, “move”, {x:paladinX+30,y:paladinY});
number=number-4;
}else{
this.summon(binary[0]);
friend = this.findNearest(this.findFriends());
}
if (number>=2){
this.summon(binary[1]);
friend = this.findNearest(this.findFriends());
this.command(friend, “move”, {x:paladinX+35,y:paladinY});
number=number-2;
}else{
this.summon(binary[0]);
friend = this.findNearest(this.findFriends());
this.command(friend, “move”, {x:paladinX+35,y:paladinY});
}
if (number>=1){
this.summon(binary[1]);
friend = this.findNearest(this.findFriends());
this.command(friend, “move”, {x:paladinX+40,y:paladinY});
number=number-1;
}else{
this.summon(binary[0]);
friend = this.findNearest(this.findFriends());
this.command(friend, “move”, {x:paladinX+40,y:paladinY});
}
};
this.deployLine(???);