Hey there I’m super new to coding and was working as a human on a beginner level for the Gold Rush game. Can anyone please tell me what I am doing wrong and what needs to be fixed?
var me = this;
var items = this.getItems();
var enemy = this.getNearestEnemy();
function what(item) {
if (item.bountyGold() == 5) {
return "gem";
} else if (item.bountyGold() == 4) {
return "gold";
} else if (item.bountyGold() == 3) {
return "silver";
} else if (item.bountyGold() == 2) {
return "bronze";
}
}
var i = 0;
if (what(items[i]) === "gem" || what(items[i]) === "gold") {
me.move(items[i].pos);
} else {
++i;
me.moveXY(18, 40);
}
But this is for gold rush, not based on hero boots. Should be able to use both move and moveXY there.
As for what you did wrong. It looks like you forgot to put the last chunk inside of a loop. Basically you will attempt to go to the first item in your list if it is a gem or gold, otherwise, you will go to 18,40 and stand there because each time you are looking only at item 0.