Hello everyone,
This is my code. My hero doesn’t summon any soldiers.
function findSouthernUnits(units) {
var southernUnits = [];
for(var i=0; i < southernUnits.length; i++) {
var unit = units[i];
if(unit.pos.y < hero.pos.y) {
// Add the unit to the array with: push()
southernUnits.push(unit);
}
}
return southernUnits;
}
while(true) {
var friends = hero.findFriends();
var enemies = hero.findEnemies();
// Use findSouthernUnits to get enemies to the south.
var enemy = findSouthernUnits(enemies);
// If there are more ogres south of you than friends.
if (enemy.length > friends.length){
// Then summon another "soldier".
hero.summon("soldier");
}
}