# Defeat munchkins, collect coins. Everything as usual.
# Use AND to check existence and type in one statement.

while True:
    enemy = hero.findNearestEnemy()
    # With AND, the type is only checked if enemy exists.
    if enemy and enemy.type == "munchkin":
        hero.attack(enemy)

# Nie martw sie o małe i średnie ogry.
# Twoimi celami są typy "brawler".
# Kiedy awanturnik (brawler) jest bliżej niż 50metrów , odpal artylerię.

while True:
    # Znajdź najbliższego wroga i zmież dystans do niego.
    enemy = hero.findNearestEnemy()
    distance = hero.distanceTo(enemy)

# Cudownapolana się zmieniła od naszej ostatniej wizyty.
# Ogry  rzuciły na to klątwę i musimy je pokonać.
# Burl nadal zbiera  klejnoty, nie dotykaj go.
# Ponadto nie atakuj Burla.

while True:
    # Znajdź najbliższy przedmiot.
    # Zbierz je(jeśli są) tylko wtedy gdy to nie jest klejnot.
    item = hero.findNearestItem()

// This function allows to fight until the certain time
// and report about defeated enemies.
function fightAndReport(untilTime) {
    var defeated = 0;
    while (true) {
        var enemy = hero.findNearestEnemy();
        if (enemy) {
            hero.attack(enemy);
            if (enemy.health <= 0) {
                defeated += 1;

// Ogry atakują pobliski posterunek!
// Command the hero to defend the tiny settlement.
// Kontroluj czas swojej warty na zegarku, żeby żadne ogry się nie przedostały.

while(true) {
    var polarPos = hero.time / 4;
    // Liczba od 20 do 60.

// Learn the difference between destroy and defeat.

// Spawn the enemies.
var ogre1 = game.spawnXY("ogre", 12, 18);
ogre1.behavior = "AttacksNearest";
var ogre2 = game.spawnXY("ogre", 68, 50);
ogre2.behavior = "AttacksNearest";