var utils = implement("fiskheroes:external/utils");

function init(hero) {
    hero.setName("Silver Surfer/Norrin Radd");
    hero.setTier(9);
    

    hero.setHelmet("Heaf");
    hero.setChestplate("Torso");
    hero.setLeggings("Legs");
    hero.setBoots("Feet");
    
    hero.addPowers("tgheroes:surf");
    hero.addAttribute("PUNCH_DAMAGE", 8.0, 0);
    hero.addAttribute("SPRINT_SPEED", 0.3, 1);
    hero.addAttribute("JUMP_HEIGHT", 2.0, 0);
    hero.addAttribute("FALL_RESISTANCE", 1.0, 1);


	hero.addKeyBind("CHARGED_BEAM", "Energy Beam", 1);
    hero.addKeyBind("SURF", "Surfboard", 3);	
	hero.addKeyBind("TELEPORT", "Teleport", 4);
    hero.addKeyBind("TELEKINESIS", "Telekinesis", 5);

    hero.setModifierEnabled(isModifierEnabled);
    hero.setHasProperty(hasProperty);

	hero.setDamageProfile(entity => entity.getHeldItem().isEmpty() ? "PUNCH" : null);
	hero.addDamageProfile("PUNCH", {
	"types": {
	"BLUNT": 2.0
        },
	});
	
    hero.setTickHandler((entity, manager) => {
        if (entity.getData("tgheroes:dyn/surf_board")) {
        manager.setData(entity, "fiskheroes:flying", true);
    }
    });
}

function isModifierEnabled(entity, modifier) {
  switch (modifier.name()) {
    case "fiskheroes:controlled_flight":
        return entity.getData("tgheroes:dyn/surf_board"); 
    default:
        return true;
    }
}

function hasProperty(entity, property) {
    return property == "BREATHE_SPACE";
}
