Zadziałało ale nie jestem pewien czy to dobre rozwiązanie - raczej powinien dookoła przejść

Widziałem podobne rozwiązanie w necie ale poszedł dołem

 

// Move to the wizard and get their secret values.
hero.moveXY(20, 24);
var secretA = hero.findNearestFriend().getSecretA();
var secretB = hero.findNearestFriend().getSecretB();
var secretC = hero.findNearestFriend().getSecretC();

// If ALL three values are true, take the high path.
// Otherwise, take the low path. Save the 4th value.
var secretD = secretA && secretB && secretC;
if (secretD)

// Sneak through the forest and ambush the shaman.
// Listen to 'Commander Craig' for warning of approaching enemy.

// Place flags after pressing Submit.
while(true) {
    var flag = hero.findFlag();
    var enemy = hero.findNearestEnemy();
    if (flag){
        // Pick the flag up.

CLEAVE okazało się niepotrzebne - trzeba zmienić bohatera na ŁUCZNIKA

 

// Nadchodzi armia ogrów. Użyj flag by wygrać bitwę !
while(true) {
    var flag = hero.findFlag();
    var enemy = hero.findNearestEnemy();
    if (flag){
                hero.pickUpFlag(flag);
    } else if (enemy){
        hero.attack(enemy);

<!-- The 'toggleClass' jQuery function turns on/off... -->
<!-- ... classes whether or not the class is off/on. -->

<script>
    var image = $("img");
    var header = $("h1");
    function toggleExpand() {
        image.toggleClass("expand");
        // Toggle class "expand" on the 'h1' tag by using the header variable we just created
        header.toggleClass("expand");
    }

<!-- It is possible to find which element was selected. -->
<!-- Using $(this) in an event function does just that. -->
<!-- var elm = $(this) sets elm to the clicked element. -->

<script>
    li = $("li");
    function toggleStriked() {
        $(this).toggleClass("striked");
    }
    li.on("click", toggleStriked);
    
    h2 = $("h2"); // This sets h2 to all h2 elements.
    function toggleBold() {
        // $() also accepts 'this' as an argument.
        // 'this', when inside of an event function is...
        // ... the specific target for the event!
        // Look at "toggleStriked" for an example.
        // Toggle the class "bold" on the clicked h2:
            $(h2).toggleClass("bold");
    }
    // When any h2 is clicked, perform "toggleBold".
    h2.on("click", toggleBold);
</script>
<style>
    .bold {
        font-weight:bold;
        font-size:xx-large;
    }
    .striked {
        text-decoration:line-through;
    }

<!-- To select neighboring elements, use "siblings()" -->
<!-- Use this to unfocus elements next to a target. -->
<!-- Elements are neighbors when at similar identation. -->

<script>
    var selectable = $(".selectable");
    function focusSelected() {
        var targetElement = $(this);
        var siblings = targetElement.siblings();
        siblings.addClass("mute");
        // Use removeClass() to remove "sel" from siblings.
        siblings.removeClass("sel");
        targetElement.removeClass("mute");
        // Use addClass() to add "sel" to targetElement.
        targetElement.addClass("sel");
    }
    selectable.on("click", focusSelected);
</script>
<style>
    .selectable {
        /* This makes the element transparent. */
        cursor: pointer;
        background-color:gray;
    }
    .sel {
        background-color:green;
    }
    .mute {
        /* This makes the element transparent. */
        opacity:0.1;
    }
    body {
        text-align:center;
    }
</style>