# Nalfar cryptor spells

**URL:** https://discourse.codecombat.com/t/nalfar-cryptor-spells/22706
**Category:** Scribe
**Created:** [July 2, 2020, 7:53am UTC](https://discourse.codecombat.com/t/nalfar-cryptor-spells/22706 "2020-07-02T07:53:50Z")
**Posts on this page:** 15
**Page:** 1

<div class="post-metadata">

### Author: ![iLuvCookies](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/iluvcookies/32/15251_2.png) [@iLuvCookies](https://discourse.codecombat.com/u/iLuvCookies)
#### Post date: [July 2, 2020, 7:53am UTC](https://discourse.codecombat.com/t/nalfar-cryptor-spells/22706/1 "2020-07-02T07:53:50Z")

</div>

Hello can someone explain to me what this code means, I’m new to Nalfar Cryptor and I need some guides on some of his spells.

```python

pet.moveXY(25,70)
def shouldIUsePoison():
    enemies = hero.findEnemies()
    for enemy in enemies:
        if enemy and hero.distanceTo(enemy)>10 and hero.distanceTo(enemy)<=30:
            return enemy
def DIE(enemy):
    if hero.distanceTo(enemy)<=15:
        hero.cast("drain-life", enemy)
    elif hero.distanceTo(enemy)<=45:
        hero.attack(enemy)
while True:
    hero.moveXY(87, 71)
    if hero.canCast("raise-dead"):
        corpses = hero.findCorpses()
        if corpses.length>5:
            hero.cast("raise-dead")
    if hero.canCast("summon-burl"):
        hero.cast("summon-burl")
    if hero.canCast("summon-undead"):
        hero.cast("summon-undead")
    foes=hero.findEnemies()
    warlocks=hero.findByType("warlock",foes)
    witchs=hero.findByType("witch",foes)
    enemies=warlocks+witchs
    enemy=hero.findNearest(enemies)
    if enemy:
        DIE(enemy)
    else:
        fangriders=hero.findByType("fangrider",foes)
        throwers=hero.findByType("thrower",foes)
        shamans=hero.findByType("shaman",foes)
        enemies=fangriders+throwers+shamans
        enemy=hero.findNearest(enemies)
        if enemy:
            DIE(enemy)
        else:
            enemy = hero.findNearestEnemy()
            if enemy:
                DIE(enemy)
    should=shouldIUsePoison()
    if hero.canCast("poison-cloud") and should:
        hero.cast("poison-cloud", should)
    friends=hero.findFriends()
    if friends:
        BFF=friends[0]
        for friend in friends:
            if friend.health>BFF.health:
                BFF=friend
        if BFF and hero.canCast("sacrifice"):
            hero.cast("sacrifice",BFF)

```

---

<div class="post-metadata">

### Author: ![Deadpool198](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/deadpool198/32/16753_2.png) [@Deadpool198](https://discourse.codecombat.com/u/Deadpool198)
#### Post date: [July 2, 2020, 7:59am UTC](https://discourse.codecombat.com/t/nalfar-cryptor-spells/22706/2 "2020-07-02T07:59:54Z")

</div>

Hi @iLuvCookies, Welcome to the CodeCombat Discourse! 🎉  
You could check out this topic:

> [@Nalfar Cryptor Spells Help](https://discourse.codecombat.com/t/nalfar-cryptor-spells-help/22675):
>
> Hi, when im doing the Stranded in the Dunes level I have to code the whole level, I chose to use Nalfar Cryptor I just started using him and dont know how to use the spells, can someone help me this is my current code right now. // Go to the far right edge of the level to find new areas. // Check the guide for more details. while True: hero.moveXY(hero.pos.x + 1, hero.pos.y ) enemy = hero.findNearestEnemy() if enemy: if hero.canCast("summon-burl", enemy): he…

If you have any more questions about specific spells please ask.  
Danny

---

<div class="post-metadata">

### Author: ![iLuvCookies](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/iluvcookies/32/15251_2.png) [@iLuvCookies](https://discourse.codecombat.com/u/iLuvCookies)
#### Post date: [July 2, 2020, 8:06am UTC](https://discourse.codecombat.com/t/nalfar-cryptor-spells/22706/3 "2020-07-02T08:06:01Z")

</div>

What does `for enemy in enemies:` and `if corpses.length > 5:` means thanks

---

<div class="post-metadata">

### Author: ![AnSeDra](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ansedra/32/13123_2.png) [@AnSeDra](https://discourse.codecombat.com/u/AnSeDra)
#### Post date: [July 2, 2020, 8:15am UTC](https://discourse.codecombat.com/t/nalfar-cryptor-spells/22706/4 "2020-07-02T08:15:36Z")

</div>

The first one (`for enemy in enemies`) loops over all of the enemies and call each one of them enemy (the for loops are explained in the mountain) and the second one (`if corpses.length > 5`) checks if the array corpses has 7 or more elements (if you use Phyton you can write len(corpses) instead of corpses.length). Do you understand?

Andrei

---

<div class="post-metadata">

### Author: ![iLuvCookies](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/iluvcookies/32/15251_2.png) [@iLuvCookies](https://discourse.codecombat.com/u/iLuvCookies)
#### Post date: [July 2, 2020, 9:28am UTC](https://discourse.codecombat.com/t/nalfar-cryptor-spells/22706/5 "2020-07-02T09:28:39Z")

</div>

So these 2 codes are explained in the mountain, correct?

---

<div class="post-metadata">

### Author: ![AnSeDra](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ansedra/32/13123_2.png) [@AnSeDra](https://discourse.codecombat.com/u/AnSeDra)
#### Post date: [July 2, 2020, 9:35am UTC](https://discourse.codecombat.com/t/nalfar-cryptor-spells/22706/6 "2020-07-02T09:35:17Z")

</div>

The for loops are for sure explained there. And the if statements are explained in the forest. And the arrays are explained in the desert.

Andrei

---

<div class="post-metadata">

### Author: ![iLuvCookies](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/iluvcookies/32/15251_2.png) [@iLuvCookies](https://discourse.codecombat.com/u/iLuvCookies)
#### Post date: [July 2, 2020, 12:15pm UTC](https://discourse.codecombat.com/t/nalfar-cryptor-spells/22706/7 "2020-07-02T12:15:20Z")

</div>

I’m in dessert currenly but I dont think ive learned it yet, I’ve just started Cubic Minefield, but I’m still confused what array is?

---

<div class="post-metadata">

### Author: ![AnSeDra](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ansedra/32/13123_2.png) [@AnSeDra](https://discourse.codecombat.com/u/AnSeDra)
#### Post date: [July 2, 2020, 1:22pm UTC](https://discourse.codecombat.com/t/nalfar-cryptor-spells/22706/8 "2020-07-02T13:22:09Z")

</div>

An array is a list, but you will also learn that in the next levels. 😉

Andrei

---

<div class="post-metadata">

### Author: ![iLuvCookies](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/iluvcookies/32/15251_2.png) [@iLuvCookies](https://discourse.codecombat.com/u/iLuvCookies)
#### Post date: [July 2, 2020, 2:11pm UTC](https://discourse.codecombat.com/t/nalfar-cryptor-spells/22706/9 "2020-07-02T14:11:38Z")

</div>

im still a little bit confused corpses.length, length is from one end to another, so it doesnt quite make sense

---

<div class="post-metadata">

### Author: ![dedreous](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/dedreous/32/13849_2.png) [@dedreous](https://discourse.codecombat.com/u/dedreous)
#### Post date: [July 2, 2020, 2:22pm UTC](https://discourse.codecombat.com/t/nalfar-cryptor-spells/22706/10 "2020-07-02T14:22:18Z")

</div>

Think of it this way…hero.findCorpses() results in this:

corpes[0] = deadGuy1  
corpes[1] = deadGuy2  
corpes[2] = deadGuy3  
corpes[3] = deadGuy4  
…etc

In this case, the length of the array is 4. The line ‘if corpses.length \> 5’ is testing to see if at least 6 or more corpses are available. This allows for maximum efficiency when casting “raise-dead”.

---

<div class="post-metadata">

### Author: ![iLuvCookies](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/iluvcookies/32/15251_2.png) [@iLuvCookies](https://discourse.codecombat.com/u/iLuvCookies)
#### Post date: [July 2, 2020, 2:25pm UTC](https://discourse.codecombat.com/t/nalfar-cryptor-spells/22706/11 "2020-07-02T14:25:15Z")

</div>

Thanks got it

---

<div class="post-metadata">

### Author: ![iLuvCookies](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/iluvcookies/32/15251_2.png) [@iLuvCookies](https://discourse.codecombat.com/u/iLuvCookies)
#### Post date: [July 2, 2020, 2:50pm UTC](https://discourse.codecombat.com/t/nalfar-cryptor-spells/22706/12 "2020-07-02T14:50:06Z")

</div>

If its a different code like `if len(neutrals):` does it mean the same thing?

---

<div class="post-metadata">

### Author: ![dedreous](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/dedreous/32/13849_2.png) [@dedreous](https://discourse.codecombat.com/u/dedreous)
#### Post date: [July 2, 2020, 3:02pm UTC](https://discourse.codecombat.com/t/nalfar-cryptor-spells/22706/13 "2020-07-02T15:02:22Z")

</div>

Not sure I understand your question, but the default usage in PY is len(something). However, the other method, ‘something.length’ (which is default for JS) is also supported in PY.

---

<div class="post-metadata">

### Author: ![iLuvCookies](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/iluvcookies/32/15251_2.png) [@iLuvCookies](https://discourse.codecombat.com/u/iLuvCookies)
#### Post date: [July 3, 2020, 1:55am UTC](https://discourse.codecombat.com/t/nalfar-cryptor-spells/22706/14 "2020-07-03T01:55:52Z")

</div>

What does `while itemIndex < len[items]` means

---

<div class="post-metadata">

### Author: ![Deadpool198](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/deadpool198/32/16753_2.png) [@Deadpool198](https://discourse.codecombat.com/u/Deadpool198)
#### Post date: [July 3, 2020, 7:18am UTC](https://discourse.codecombat.com/t/nalfar-cryptor-spells/22706/15 "2020-07-03T07:18:09Z")

</div>

It means pretty much what the statement says (python is sometimes very like english):  
while-itemIndex-is-less-than-the-amount-of-items: ----Then do something:  
itemIndex is a variable probably with an integer value (whole number 1,2,3) And items is an array of items.  
Normally at the end of the code inside one of those loops you would increment (increase by one) itemIndex, so that the code loops through the exact same amount of times as the number of coins you have.  
Danny
