Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team

Difficulty Beating Grim Determination (SOLVED Victory: BUG?)


Original Text:
I am having difficulty beating this level. Everything works but they keep killing all of my paladins and Reynaldo. Would you, please give me suggestions for improvement?
/End Original Text

While watching the code run I kept noticing that the paladins would heal once and then stop healing. So I added a hero.say command to tell me if can cast was true or false. Once the code was run it was a victory.
There were a few other changes to the program done, but the paladins did not work correctly until I added the hero.say.

// Your goal is to protect Reynaldo
function commandPeasant(friend) {
    var coin = friend.findNearest(friend.findItems());
        hero.command(friend, "move", coin.pos);

function commandGriffin(friend) {
    //var enemies = hero.findByType('warlock', friend.findEnemies());
    var enemy = friend.findNearestEnemy();
        hero.command(friend, "attack", enemy);
// Find the paladin with the lowest health.
function lowestHealthPaladin() {
    var lowestHealth = 99999;
    var lowestFriend = null;
    var friends = hero.findFriends();
    for(var f=0; f < friends.length; f++) {
        var friend = friends[f];
        if(friend.type != "paladin") { continue; }
        if( < lowestHealth && < friend.maxHealth) {
            lowestHealth =;
            lowestFriend = friend;
    return lowestFriend;

function commandPaladin(friend) {
    // Heal the paladin with the lowest health using lowestHealthPaladin()
    var hurtPaladin = lowestHealthPaladin();
    // You can use paladin.canCast("heal") and command(paladin, "cast", "heal", target)
    if(hurtPaladin && friend.canCast("heal")){
        hero.command(friend, "cast", "heal", hurtPaladin);
    // Paladins can also shield: command(paladin, "shield")
    hero.command(friend, "shield");
    // And don't forget, they can attack, too!

    var enemy = friend.findNearest(hero.findEnemies());
    if (enemy) {
        hero.command(friend, "attack", enemy);
function commandFriends() {
    // Command your friends.
    var friends = hero.findFriends();
    for(var i=0; i < friends.length; i++) {
        var friend = friends[i];
        if(friend.type == "peasant") {
        } else if(friend.type == "griffin-rider") {
        } else if(friend.type == "paladin") {

while(true) {
    // Summon griffin riders!
    if( >= hero.costOf("griffin-rider")){