# Grim Determination has a bug about paladins

**URL:** <https://discourse.codecombat.com/t/grim-determination-has-a-bug-about-paladins/28797>\
**Category:** Level Help\
**Created:** [May 11, 2021, 6:28am UTC](https://discourse.codecombat.com/t/grim-determination-has-a-bug-about-paladins/28797 "2021-05-11T06:28:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Cheung\_Wilbur](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/cheung_wilbur/32/22448_2.png) [@Cheung\_Wilbur](https://discourse.codecombat.com/u/Cheung_Wilbur)\
**Post date:** [May 11, 2021, 6:28am UTC](https://discourse.codecombat.com/t/grim-determination-has-a-bug-about-paladins/28797/1 "2021-05-11T06:28:29Z")

</div>

It doesn’t work.  
bug: labeled  
bug type: argument error: you need something to cast upon.

```python
#sample
#paladin = hero.findNearest(hero.findByType("paladin"))
#if paladin.canCast("heal", hero):
# hero.command(paladin, "cast", "heal", hero)

#starts here

# Your goal is to protect Reynaldo

# Find the paladin with the lowest health.
def lowestHealthPaladin():
    lowestHealth = 99999
    lowestFriend = None
    friends = hero.findFriends()
    for friend in friends:
        if friend.type != "paladin":
            continue
        if friend.health < lowestHealth and friend.health < friend.maxHealth:
            lowestHealth = friend.health
            lowestFriend = friend
    return lowestFriend

def commandPaladin(p):
    # Heal the paladin with the lowest health using lowestHealthPaladin()
    # You can use paladin.canCast("heal") and command(paladin, "cast", "heal", target)
    # Paladins can also shield: command(paladin, "shield")
    # And don't forget, they can attack, too
    weak = lowestHealthPaladin()
    if p.canCast("heal", weak):
#bug
        hero.command(p, "cast", "heal", weak)
    else:
        hero.command(p, "shield")
    pass

#peasent commanded, not shown

#griffin command, not shown

def commandFriends():
    # Command your friends.
    friends = hero.findFriends()
    for friend in friends:
        if friend.type == "peasant":
            commandPeasant(friend)
        elif friend.type == "griffin-rider":
            commandGriffin(friend)
        elif friend.type == "paladin":
            commandPaladin(friend)
    #All commandable
    #boss star 3

while True:
    commandFriends()
    if hero.gold >= 50:
        hero.summon("griffin-rider")

```

What’s wrong? misspelled? Several times already!

---

<div class="post-metadata">

**Author:** ![Hydrobolic](https://avatars.discourse-cdn.com/v4/letter/h/e47c2d/32.png) [@Hydrobolic](https://discourse.codecombat.com/u/Hydrobolic)\
**Post date:** [May 11, 2021, 6:34am UTC](https://discourse.codecombat.com/t/grim-determination-has-a-bug-about-paladins/28797/2 "2021-05-11T06:34:50Z")

</div>

Say `lowestHealthPaladin` returns `None`, which can happen if all paladins are at full health. Does `p.canCast("heal", weak)` make sense? You may need to check for the existence of `weak` first.

---

<div class="post-metadata">

**Author:** ![Cheung\_Wilbur](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/cheung_wilbur/32/22448_2.png) [@Cheung\_Wilbur](https://discourse.codecombat.com/u/Cheung_Wilbur)\
**Post date:** [May 11, 2021, 7:44am UTC](https://discourse.codecombat.com/t/grim-determination-has-a-bug-about-paladins/28797/3 "2021-05-11T07:44:37Z")

</div>

How do I find paladin health? Please tell me.  
I tried using p.health, but it doesn’t work.

---

<div class="post-metadata">

**Author:** ![Hydrobolic](https://avatars.discourse-cdn.com/v4/letter/h/e47c2d/32.png) [@Hydrobolic](https://discourse.codecombat.com/u/Hydrobolic)\
**Post date:** [May 11, 2021, 7:56am UTC](https://discourse.codecombat.com/t/grim-determination-has-a-bug-about-paladins/28797/4 "2021-05-11T07:56:20Z")

</div>

`p.health` will tell you the health of a paladin, _provided it exists_. Otherwise you’re trying to fetch the health of a non-existent paladin, which doesn’t make sense. You can see it used in the definition of `lowestHealthPaladin`.

To solve your original problem of not knowing whether the return value of `lowestHealthPaladin` exists or not, you should use an if, as so:

`if p and p.canCast("heal", weak):`

---

<div class="post-metadata">

**Author:** ![Ryan\_Wong](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.codecombat.com/ryan_wong/32/25710_2.png) [@Ryan\_Wong](https://discourse.codecombat.com/u/Ryan_Wong)\
**Post date:** [May 11, 2021, 3:56pm UTC](https://discourse.codecombat.com/t/grim-determination-has-a-bug-about-paladins/28797/5 "2021-05-11T15:56:24Z")

</div>

Hello and welcome to codecombat discourse! This is a cozy forum where you can share ideas, share fan art, get assistance for code, etc! Before you proceed, we hope that you review [this topic](https://discourse.codecombat.com/t/welcome-to-codecombat-discourse-forums/15601), which shows all essentials of this board! Thanks!  
@Cheung_Wilbur can you send me a link to the level?
