Is there anything wrong with the following code? I got very strange outcomes:
- if I comment out the two hero.say statements then I got stuck very early, the system reporting “the code never finished, either it is really slow or infinite loop”
- if I leave the first “say” but comment out the second then I got further but eventually the system still reporting “the code never finished…”
- if I have all the three say then I get to the end where I “ran out of time” because I spent so much time saying things!
def commandHeal(paladins, target): for paladin in paladins: if target.health < target.maxHealth: if paladin.canCast("heal"): hero.say(paladin.id + " is healing " + target.id) hero.command(paladin, "cast", "heal", target) else: hero.command(paladin, "shield") hero.say(paladin.id + " is shielding") else: #hero.say("fully healed") break # previous paladin has fully healed the target