In the case where your hero is not at full health and at least one paladin is unable to heal, your while
loop has no action in it, and thus will spin forever in an infinite loop. When you include the hero.say
statement, instead CodeCombat blocks for a few frames every iteration as your hero says something, preventing an infinite loop. Nick comments on the exact behavior here.
How you want to solve this issue is up to you. The hero.wait
command may come in handy as a replacement for an awkward hero.say
.
(A side note- I’d suggest generalizing fullHeal()
with a for
loop over paladins so it’s able to utilize more or less than exactly two paladins. for-of loops are worth learning about)