import { world, system} from "@minecraft/server";
import { ModalFormData } from "@minecraft/server-ui";
import { getAbilities } from "./../../abilities/import.js";

const weapon = {
    name: 'abilityScroll',
    display_name: "Ability Scroll",
    dual_wield: "none",
    type: "scroll",
    block_damage: 45,
    cd: 8,
    cmbname: "dch_cmb",
    setCore(player, item, inventory, level) {
        let choices = getAbilities(level)
        
        let jk = []
        for(let i = 0; i < (choices.length - 1); i++){
            jk.push(choices[i][0])
        }
        const modalForm = new ModalFormData()
        .title('Ability Picker');

        modalForm.dropdown('Choose an Ability', jk);
        modalForm
            .show(player)
            .then((response) => {
                const [speller] = response.formValues;
                let spell = choices[speller][1]
                item.setLore([`§0¡${spell}`])
                inventory.setItem(player.selectedSlot, item)
            })
    },
    book_select(player, item) {
        item.setLore(newLore)
        item.setDynamicProperty("abilities", JSON.stringify(Abilities))
        item.setDynamicProperty("fightStyle", 1)
        player.getComponent('equippable')?.setEquipment(EquipmentSlot.Mainhand, item)
    }
}

export default weapon


