// Remember that enemies may not yet exist.
while (true) {
    var enemy = hero.findNearestEnemy();
    // If there is an enemy, attack it!
    if (enemy) {
        hero.attack(enemy);
    }
    else {
        hero.moveXY(26, 35);
    }
}

// Pozostań na środku i broń!

while(true) {
    var enemy = hero.findNearestEnemy();
    if (enemy) {
        // Zaatakuj przeciwnika...
        hero.attack(enemy);
    }
    else {
        // ... lub powróć do pozycji defensywnej.
        hero.moveXY(40, 34);
    }
}

// komendy poniżej instrukcji "if " wykonają się tylko jeżeli jej warunek okaże sięprawdziwym.
// == oznacza "równa się"
if (2 + 2 == 4) {
    hero.say("Hey!");
}
if (2 + 2 == 5) {
    hero.say("Yes, you!");
}

// If-statement code only runs when the if’s condition is true.
// Fix all the if-statements to beat the level.

// == means "is equal to".
if (1 + 1 + 1 == 2) {  // ∆ Make this false.
    hero.moveXY(5, 15);  // Move to the first mines.
}
if (2 + 2 == 4) {  // ∆ Make this true.
    hero.moveXY(15, 40);  // Move to the first gem.
}
// != means "is not equal to".
if (2 + 2 == 4) {  // ∆ Make this true.
    hero.moveXY(25, 15);  // Move to the second gem.
}

// Boolean to wartość będąca True albo False
// Symbol == oznacza "być jednakowym z?
// Pisząc A == B zadajesz pytania: "Czy A jest równe B?
// Odpowiedzią jest wartość boolean!
// Kliknij  przycisk "Podpowiedź' jeśli masz jakieś niejasności!

// Pytanie: 2 == 3
// Użyj Say by podać poprawną odpowiedź:
hero.say(false);

// Patrol the village entrances.
// Build a "fire-trap" when you see an ogre.
// Don't blow up any peasants!

while(true) {
    hero.moveXY(43, 50);
    var top = hero.findNearestEnemy();
    if (top) {
        hero.buildXY("fire-trap", 43, 50);
    }