# Restless Dead (Javascript, Anya)

**URL:** <https://discourse.codecombat.com/t/restless-dead-javascript-anya/35887>\
**Category:** Level Help\
**Created:** [August 4, 2023, 3:24pm UTC](https://discourse.codecombat.com/t/restless-dead-javascript-anya/35887 "2023-08-04T15:24:30Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![gnarlyMarley](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/gnarlymarley/32/34823_2.png) [@gnarlyMarley](https://discourse.codecombat.com/u/gnarlyMarley)\
**Post date:** [August 4, 2023, 3:24pm UTC](https://discourse.codecombat.com/t/restless-dead-javascript-anya/35887/1 "2023-08-04T15:24:30Z")

</div>

My soldiers and I are losing the battle. Not sure what else to do, other that try a different character.  
Is there a spell, weapon, or armor I should add for Anya to work?

```python
hero.setFlowerColor("blue");
let redX = {
    x: 19,
    y: 40
};
hero.moveXY(56, 15);
while (hero.pos.x != redX.x) {
    let yeti = hero.findNearestEnemy();
    if (yeti) {
        hero.attack(yeti);
    }
    let item = hero.findNearestItem();
    if (item) {
        hero.moveXY(item.pos.x, item.pos.y);
    }
    hero.move(redX);
}
while (true) {
    if (hero.gold >= hero.costOf("soldier")) {
        hero.summon("soldier");
    }
    let enemy = hero.findNearestEnemy();
    if (enemy) {
        let soldiers = hero.findFriends();
        for (let soldier of soldiers) {
            hero.command(soldier, "attack", enemy);
        }
        if (hero.canCast("drain-life", enemy)) {
            hero.cast("drain-life", enemy);
        } else {
            if (hero.canCast("chain-lightning", enemy)) {
                hero.cast("chain-lightning", enemy);
            } else {
                hero.attack(enemy);
            }
        }
    }
}

```

---

<div class="post-metadata">

**Author:** ![JustALuke](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/justaluke/32/43608_2.png) [@JustALuke](https://discourse.codecombat.com/u/JustALuke)\
**Post date:** [August 4, 2023, 9:39pm UTC](https://discourse.codecombat.com/t/restless-dead-javascript-anya/35887/2 "2023-08-04T21:39:15Z")

</div>

Can you post a picture of your gear?

---

<div class="post-metadata">

**Author:** ![gnarlyMarley](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/gnarlymarley/32/34823_2.png) [@gnarlyMarley](https://discourse.codecombat.com/u/gnarlyMarley)\
**Post date:** [August 5, 2023, 4:38pm UTC](https://discourse.codecombat.com/t/restless-dead-javascript-anya/35887/3 "2023-08-05T16:38:35Z")

</div>

![image](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/3X/e/b/ebaf256ff5364d87e2f95a3327a37ebc7732011b.jpeg)

---

<div class="post-metadata">

**Author:** ![gnarlyMarley](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/gnarlymarley/32/34823_2.png) [@gnarlyMarley](https://discourse.codecombat.com/u/gnarlyMarley)\
**Post date:** [August 5, 2023, 7:13pm UTC](https://discourse.codecombat.com/t/restless-dead-javascript-anya/35887/4 "2023-08-05T19:13:50Z")

</div>

I bought a new shield and sword, then ran the same code and it worked!! 😀 👍

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/codecombat/original/2X/a/a9445509d1a758c41b5ddcddc8c8e20a5dedb67f.png) [@system](https://discourse.codecombat.com/u/system)\
**Post date:** [August 6, 2023, 7:14am UTC](https://discourse.codecombat.com/t/restless-dead-javascript-anya/35887/5 "2023-08-06T07:14:15Z")

</div>

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.
