var soldiers = this.getCombatants();
// Just killing the first soldier doesn't seem like a winning strategy...
// Click the "Guide" button if you need a hint on telling who is on what team.
for(var i = 0; i < soldiers.length; i++)
var spy = soldiers[i];
if(spy && spy.team == "ogres")
if(this.distanceTo(spy) > this.attackRange)
else if(this.distanceTo(spy) < this.attackRange)
I had a difficult time understanding the order of how the loops are nested, and I got some good information from my dad who worked on this with me. Why would the loop use an
else if condition to attack if the move condition is being satisfied? Is that programming convention, or applicable only in this case?