function init(hero) {
    hero.setName("Iron-Spider/\u00A7c\u00A7lCARDBOARD CONSUMER\u00A7r");
    hero.setVersion("Comics");
    hero.setTier(8);
    
    hero.setHelmet("item.superhero_armor.piece.mask");
    hero.setChestplate("item.superhero_armor.piece.chestpiece");
    hero.setLeggings("item.superhero_armor.piece.pants");
    hero.setBoots("item.superhero_armor.piece.boots");
    
    hero.addPowers("cchp:spider_physiology", "cchp:web_shooters_iron_spider", "cchp:waldoes");
    hero.addAttribute("FALL_RESISTANCE", 12, 0);
    hero.addAttribute("JUMP_HEIGHT", 2, 0);
    hero.addAttribute("PUNCH_DAMAGE", 8.5, 0);
    hero.addAttribute("SPRINT_SPEED", 0.6, 1);
    hero.addAttribute("STEP_HEIGHT", 0.5, 0);
    hero.addAttribute("IMPACT_DAMAGE", 0.5, 1);
    
    hero.addKeyBind("UTILITY_BELT", "key.webShooters", 1);
    hero.addKeyBind("WEB_ZIP", "key.webZip", 2);
	hero.addKeyBindFunc("func_WEB_SWINGING", webSwingingKey, "key.webSwinging", 3);
    hero.addKeyBind("SLOW_MOTION", "key.slowMotion", 4);
    hero.addKeyBind("TENTACLES", "Toggle Waldoes", 5);
    hero.addKeyBind("TENTACLE_JAB", "Waldoe Jab", 1);
    hero.addKeyBind("TENTACLE_GRAB", "Waldoe Grab", 2);
    
    hero.setModifierEnabled(isModifierEnabled);
    hero.setKeyBindEnabled(isKeyBindEnabled);
	hero.setHasProperty(hasProperty);

}

function webSwingingKey(player, manager) {
    var flag = player.getData("fiskheroes:web_swinging");
    
    if (!flag) {
        manager.setDataWithNotify(player, "fiskheroes:prev_utility_belt_type", player.getData("fiskheroes:utility_belt_type"));
        manager.setDataWithNotify(player, "fiskheroes:utility_belt_type", -1);
    }
    
    manager.setDataWithNotify(player, "fiskheroes:web_swinging", !flag);
    return true;
}

function isModifierEnabled(entity, modifier) {
    switch (modifier.name()) {
    case "fiskheroes:web_swinging":
        return entity.getHeldItem().isEmpty() && entity.getData("fiskheroes:utility_belt_type") == -1;
    case "fiskheroes:leaping":
        return modifier.id() == "springboard" == (entity.getData("fiskheroes:ticks_since_swinging") < 5);
    default:
        return true;
    }
}

function isKeyBindEnabled(entity, keyBind) {
    switch (keyBind) {
    case "func_WEB_SWINGING":
        return entity.getHeldItem().isEmpty() && entity.getData("fiskheroes:tentacles") == null;
    case "UTILITY_BELT":
        return entity.getData("fiskheroes:tentacles") == null;
    case "WEB_ZIP":
        return entity.getData("fiskheroes:tentacles") == null;
    default:
        return true;
    }
}
function isModifierEnabled(entity, modifier) {
    return modifier.name() != "fiskheroes:water_breathing" || !entity.getData("fiskheroes:mask_open");
}

function hasProperty(entity, property) {
    return property == "MASK_TOGGLE" || property == "BREATHE_SPACE" && !entity.getData("fiskheroes:mask_open");
}

function isKeyBindEnabled(entity, keyBind) {
    switch (keyBind) {
    case "func_WEB_SWINGING":
        return entity.getHeldItem().isEmpty() && entity.getData("fiskheroes:tentacles") == null;
    case "UTILITY_BELT":
        return entity.getData("fiskheroes:tentacles") == null;
    case "WEB_ZIP":
        return entity.getData("fiskheroes:tentacles") == null;
    case "TENTACLE_JAB":
        return entity.getData('fiskheroes:tentacles') != null;
    case "TENTACLE_STRIKE":
        return entity.getData('fiskheroes:tentacles') != null;
    default:
        return true;
    }
}