hero.choose
can be used to make sure choices. you can choose not only type but specific item.
hero.chooseItem = function(){
if(hero.energy <= 8) return "energy";
return "mana";
};
def choose():
if hero.energy <= 8: return "energy"
return "mana"
hero.chooseItem = choose
hero.chooseItem = function(){
let items = hero.findItems().filter(
(item) => item.x < 60 && item.y > hero.y);
if(items.length > 0) return items[0];
return hero.findItems()[0];
};
def choose():
items = [item for item in hero.findItems() if item.x < 60 and item.y > hero.y]
if len(items) > 0: return items[0]
return hero.findItems()[0]
hero.chooseItem = choose