adds with splitStack a new equipment interaction

pull/61/head
macniel 2025-10-27 10:55:31 +01:00
parent 92540c58cb
commit ff09875ad3
1 changed files with 31 additions and 0 deletions

View File

@ -248,6 +248,37 @@ export default {
return !thisObject.document.isWorn(itemId) && item.system.category.indexOf("Fernkampfwaffe") != -1 return !thisObject.document.isWorn(itemId) && item.system.category.indexOf("Fernkampfwaffe") != -1
} }
}, },
{
name: "Aufteilen",
icon: '<i class="fa-solid fa-split"></i>',
callback: async (target) => {
const {itemId} = target.dataset
const item = thisObject.document.items.get(itemId)
const previousStackSize = item.system.quantity
const newStackSize = await foundry.applications.api.DialogV2.prompt({
window: {title: "Größe des neuen Stapels"},
content: `<input name="size" type="number" min="1" max="${previousStackSize}" value="1" step="1" autofocus>`,
ok: {
label: "Aufteilen",
callback: (event, button, dialog) => button.form.elements.size.valueAsNumber
}
});
if (newStackSize) {
const clone = item.clone({
system: {
quantity: newStackSize
}
})
thisObject.document.createEmbeddedDocuments('Item', [clone])
item.update({"system.quantity": previousStackSize - newStackSize})
}
},
condition: (target) => {
const {itemId} = target.dataset
const item = thisObject.document.items.get(itemId)
return item.system.quantity > 1
}
},
{ {
name: "Aus dem Inventar entfernen", name: "Aus dem Inventar entfernen",
icon: '<i class="fa-solid fa-trash"></i>', icon: '<i class="fa-solid fa-trash"></i>',