Hi, I need some help with my javascript code, the problem is that my hero bashes all the enemies but then does not collect the gems, what is wrong? I do not understand…
I have checked the code more than 10 times and I still do not understand what is wrong, could someone help me? please…
Javascript code:
// Be careful with these ogres.
// They are special trained fat-free uber ogres and very strong.
// The keyword is fat-free.
var enemies = hero.findEnemies();
var enemyIndex = 0;
while(enemyIndex < enemies.length) {
var enemy = enemies[enemyIndex];
if (enemy) {
hero.bash(enemy);
hero.moveXY(40, 33);
if (enemyIndex >= 4) {
break;
}
}
enemyIndex += 1;
}
var items = hero.findItems();
var itemIndex = 0;
while(itemIndex > items.length) {
var item = items[itemIndex];
if (item) {
hero.moveXY(item.pos.x, item.pos.y);
}
itemIndex += 1;
}