function init(hero) {
    hero.setName("Doctor Fate");
    hero.setTier(10);
    
    hero.setHelmet("Helmet");

    hero.addPowers("jmctheroes:order_magic");
    hero.addAttribute("FALL_RESISTANCE", 1.0, 1);
    hero.addAttribute("JUMP_HEIGHT", 2.0, 0);
    hero.addAttribute("PUNCH_DAMAGE", 7.0, 0);
    hero.addAttribute("SPRINT_SPEED", 0.55, 1);

    hero.addKeyBind("BLADE", "Toggle Magical Sword", 1);
    hero.addKeyBind("SHIELD", "Toggle Magical Shield", 1);
    hero.addKeyBind("SPELL_MENU", "Order Spells", 2);
    hero.addKeyBind("CHARGED_BEAM", "Beam of Order", 3);
    hero.addKeyBind("TELEPORT", "key.teleport", 4);
    hero.addKeyBind("HOVER", "Levitate", 4);
    hero.addKeyBind("FATE", "Summon the Power of Order", 5);

    hero.setAttributeProfile(getProfile);
    hero.setTierOverride(getTierOverride);
    hero.setKeyBindEnabled(isKeyBindEnabled);
    hero.setModifierEnabled(isModifierEnabled);
    hero.addAttributeProfile("BLADE", bladeProfile);
    hero.addAttributeProfile("SHIELD", shieldProfile);
    hero.addAttributeProfile("INACTIVE", inactiveProfile);
}

function bladeProfile(profile) {
    profile.inheritDefaults();
    profile.addAttribute("PUNCH_DAMAGE", 11.3, 0);
    profile.addAttribute("IMPACT_DAMAGE", 0.8, 1);
}

function shieldProfile(profile) {
    profile.inheritDefaults();
    profile.addAttribute("PUNCH_DAMAGE", 9.7, 0);
    profile.addAttribute("IMPACT_DAMAGE", 0.95, 1);
}

function inactiveProfile(profile) {
    profile.revokeAugments();
}

function getProfile(entity) {
    if (!entity.getData("jmctheroes:dyn/fate")) {
        return "INACTIVE";
    }
    else if (entity.getData("fiskheroes:blade")) {
        return "BLADE";
    }
    else if (entity.getData("fiskheroes:shield")) {
        return "SHIELD";
    }
}

function isModifierEnabled(entity, modifier) {
    if (modifier.name() != "fiskheroes:transformation" && modifier.name() != "fiskheroes:cooldown" && (!entity.getData("jmctheroes:dyn/fate"))) {
        return false;
    }
  
    switch (modifier.name()) {
    case "fiskheroes:blade":
        return !(entity.getData("fiskheroes:shield") && entity.getData("fiskheroes:blade"));
    case "fiskheroes:shield":
        return !(entity.getData("fiskheroes:shield") && entity.getData("fiskheroes:blade"));
    case "fiskheroes:lightning_cast":
        return (entity.getData("jmctheroes:dyn/fate"));
    case "fiskheroes:hover":
        return (entity.getData("jmctheroes:dyn/fate"));
    default:
        return true;
    }
}

function isKeyBindEnabled(entity, keyBind) {
    if (keyBind == "FATE") {
        return entity.getData("fiskheroes:mask_open_timer") == 0;
    }
    else if (!entity.getData("jmctheroes:dyn/fate")) {
        return false;
    }
    
    switch (keyBind) {
    case "SHIELD":
        return entity.getData("fiskheroes:blade_timer") == 0 || entity.isBookPlayer();
    case "BLADE":
        return entity.getData("fiskheroes:shield_timer") > 0 || entity.getData("fiskheroes:blade_timer") > 0 || entity.isBookPlayer();
    case "SPELL_MENU":
        return entity.getData("jmctheroes:dyn/fate");
    case "CHARGED_BEAM":
        return entity.getData("jmctheroes:dyn/fate");
    case "TELEPORT":
        return !entity.isSneaking() && entity.getData("jmctheroes:dyn/fate");
    case "HOVER":
        return entity.isSneaking() && entity.getData("jmctheroes:dyn/fate");
    default:
        return true;
    }
}

function getTierOverride(entity) {
    return entity.getData("jmctheroes:dyn/fate") ? 10 : 0;
}