function init(hero) {
    hero.setName("Green Lantern");
    hero.setVersion("Comics");
    hero.setTier(8);
    
    hero.setChestplate("Ring");
    
    hero.addPowers("cwheropack:green_lantern_ring");
    hero.addAttribute("PUNCH_DAMAGE", 7.5, 0);
    hero.addAttribute("FALL_RESISTANCE", 8.0, 0);
    hero.addAttribute("SPRINT_SPEED", 0.4, 1);

    hero.addKeyBind("BLADE", "key.blade", 1);
    hero.addKeyBind("SHIELD", "Shield", 2);
    hero.addKeyBind("CHARGED_BEAM", "Charged Beam", 3);
    hero.addKeyBind("TELEPORT", "Space/Earth", 3)
    hero.addKeyBind("SPELL_MENU", "Menu", 4);
    hero.addKeyBind("SUIT", "Active Armor", 5);

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

    hero.addAttributeProfile("INACTIVE", inactiveProfile);
}

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


function shieldProfile(profile) {
    profile.inheritDefaults();
    profile.addAttribute("BASE_SPEED", 2.75, 1);
    profile.addAttribute("JUMP_HEIGHT", -2.0, 1);
}

function getAttributeProfile(entity) {
    return entity.getData("fiskheroes:shield_blocking") ? "SHIELD" : null;
}

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


function getTierOverride(entity) {
    return entity.getData("fiskheroes:dyn/nanites") ? 9 : 0;
}

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

function isModifierEnabled(entity, modifier) {
    if (modifier.name() != "fiskheroes:transformation" && modifier.name() != "fiskheroes:cooldown" && (!entity.getData("fiskheroes:dyn/nanites") || modifier.name() == "fiskheroes:propelled_flight" && entity.getData("fiskheroes:dyn/nanite_timer") < 1)) {
        return false;
    }
  
    switch (modifier.name()) {
    case "fiskheroes::gliding":
        return !entity.getData("fiskheroes:dyn/steel_timer");
    case "fiskheroes:teleportation":
        return entity.posY() > 1000;
    case "fiskheroes:charged_beam":
        return entity.posY() <= 1000;
    default:
        return true;
    }
}


function isKeyBindEnabled(entity, keyBind) {
    if (keyBind == "SUIT") {
        return entity.getData("fiskheroes:mask_open_timer") == 0;
    }
    else if (!entity.getData("fiskheroes:dyn/nanites")) {
        return false;
    }
    
    switch (keyBind) {
    case "ENERGY_PROJECTION":
        return !entity.isSneaking();
    case "BLADE":
        return entity.getData("fiskheroes:dyn/nanites");
    case "CHARGED_BEAM":
        return entity.posY() <= 1000;
    case "TELEPORT":
        return entity.posY() > 1000;
    case "SPELL_MENU":
        return entity.getData("fiskheroes:dyn/nanites");
    default:
        return true;
    }
}

function hasProperty(entity, property) {
    switch (property) {
    case "MASK_TOGGLE":
        return entity.getData("fiskheroes:dyn/nanite_timer") == 1;
    case "BREATHE_SPACE":
        return !entity.getData("fiskheroes:mask_open") && entity.getData("fiskheroes:dyn/nanites");
    default:
        return false;
    }
}

