import { EquipmentSlot} from "@minecraft/server";
import { ActionFormData } from "@minecraft/server-ui";

const weapon = {
    name: 'learning_book',
    display_name: "Learning Book",
    dual_wield: "none",
    type: "book",
    setCore(player, item) {
        const fades = new ActionFormData()
            .title('clash')
            .body('')
            .button(`Art of Slashing`)
            .button(`Moving around`)
            .button(`Cutting Rocks And Minerals`)
            .show(player)
            .then(result => {
            if (result.selection === 0) {
                item.setLore(`Art of Slashing`)
                item.setDynamicProperty("skill","slashing")
                player.getComponent('equippable')?.setEquipment(EquipmentSlot.Mainhand, item)
            }
            if (result.selection === 1) {
                item.setLore(`Moving around`)
                item.setDynamicProperty("skill","movement")
                player.getComponent('equippable')?.setEquipment(EquipmentSlot.Mainhand, item)
            }
            if (result.selection === 2) {
                item.setLore(`Cutting Rocks And Minerals`)
                item.setDynamicProperty("skill","cutting")
                player.getComponent('equippable')?.setEquipment(EquipmentSlot.Mainhand, item)
            }
        })
    },
    book_select(player, item) {
        const fades = new ActionFormData()
            .title('clash')
            .body('')
            .button(`Art of Slashing`)
            .button(`Moving around`)
            .button(`Cutting Rocks And Minerals`)
            .show(player)
            .then(result => {
            if (result.selection === 0) {
                item.setLore([`Art of Slashing`])
                item.setDynamicProperty("skill","slashing")
                player.getComponent('equippable')?.setEquipment(EquipmentSlot.Mainhand, item)
            }
            if (result.selection === 1) {
                item.setLore([`Moving around`])
                item.setDynamicProperty("skill","movement")
                player.getComponent('equippable')?.setEquipment(EquipmentSlot.Mainhand, item)
            }
            if (result.selection === 2) {
                item.setLore([`Cutting Rocks And Minerals`])
                item.setDynamicProperty("skill","cutting")
                player.getComponent('equippable')?.setEquipment(EquipmentSlot.Mainhand, item)
            }
        })
    }
}

export default weapon


