Code seems to basically work; I think my problem is a nesting issue. Hero moves to the first point, casts spell VENI (Latin command for ‘come here’ which I actually use with my children!), and then he kills the skeleton.
And then that’s it. He just sits there. It doesn’t continue to loop through and move on. Thanks for the help.
// Loop through the powerMap to find positive numbers.
// First, loop through indexes of rows.
for (var i = 0; i < powerMap.length; i++) {
// Each row is an array. Iterate through it.
for (var j = 0; j < powerMap[i].length; j++) {
// Get the value of the i row and j column.
var pointValue = powerMap[i][j];
// If it's a positive number:
if (pointValue > 0) {
// Use convert to get XY coordinates.
var pos = convert(i, j);
// Move there, say "VENI" and be prepared!
hero.moveXY(pos.x, pos.y);
hero.say(spell);
while (true) {
var enemy = hero.findNearestEnemy();
if (enemy && enemy.health > 0) {
hero.attack(enemy);
}
}
}
}
}