// Soldiers will slowly arrive, but the ogres will overwhelm them.
// A basic attack loop isn't going to be enough to keep you alive.
while(true) {
    var flag = hero.findFlag();
    var enemy = hero.findNearestEnemy();
    if(flag) {
        hero.say("Maybe I should do something with that flag?");
        hero.moveXY(flag.pos.x, flag.pos.y);
        hero.pickUpFlag(flag);

// Move to 'Eszter' and get the secret number from her.
hero.moveXY(16, 32);
var esz = hero.findNearestFriend().getSecret();

// Multiply by 3 and subtract 2 to get 'Tamas's number.
// Remember to use parentheses to do calculations in the right order.
// Move to 'Tamas' and say his magic number.
var tam = esz * 3 - 2;
hero.moveXY(24, 28);
hero.say(tam);

To nie jest całkiem dobre rozwiązanie - "hero" gubi "item" i nie może go znaleźć - był zbyt wolny

dodaliśmy więc "else" ale to powinno być coś ogólnego bo tu pasuje tylko do pozycji gdzie "hero" stracił kontakt z "item" - w innej pozycji by nie zadziałało. 

 

// Follow the lightstone to navigate the traps.

while (true) {
    var item = hero.findNearestItem();
    if (item) {
        // Store the item's position in a new variable using item.pos:
        var position = item.pos;
        // Store the X and Y coordinates using pos.x and pos.y:
        var itemX = item.pos.x;
        var itemY = item.pos.y;

// Atakuj tylko wrogów typu "munchkin" i "thrower".
// Nie atakuj typu "burl". Uciekaj od typu "ogre"!
while(true) {
    var enemy = hero.findNearestEnemy();
    
    // Pamiętaj: nie atakuj typu "burl"!
    if (enemy.type == "burl") {
        hero.say("Nie zatakuję tego Burla!");
    }