forked from GitHub-Mirrors/foundry-sw5e

Things unfinished: - Migration - The update adds new sections to the class sheet to allow some light customisation, this hasn't been included, but could be extended for the sake of dynamic classes with automatic class features and more - The French - The packs have not yet been updated, meaning due to the addition of a progression field to the class item, classes now don't set force or tech points - I updated the function calls in starships, but I didn't update it very thoroughly, it'll need checking - I only did a little testing - There has since been updates to DND5e that hasn't made it to release that patch bugs, those should be implemented Things changed from base 5e: - Short rests and long rests were merged into one function, this needed some rewrites to account for force and tech points, and for printing the correct message Extra Comments: - Unfinished code exists for automatic spell scrolls, this could be extended for single use force or tech powers - Weapon proficiencies probably need revising - Elven accuracy, halfling lucky, and reliable talent are present in the roll logic, this probably needs revising for sw5e - SW5e has a variant rule that permits force powers of any alignment to use either charisma or wisdom, that could be implemented - SW5e's version of gritty realism, [Longer Rests](https://sw5e.com/rules/variantRules/Longer%20Rests) differs from base dnd, this could be implemented - Extra ideas I've had while looking through the code can be found in Todos next to the ideas relevant context
68 lines
2.5 KiB
JavaScript
68 lines
2.5 KiB
JavaScript
/**
|
|
* A Dialog to prompt the user to select from a list of items.
|
|
* @type {Dialog}
|
|
*/
|
|
export default class SelectItemsPrompt extends Dialog {
|
|
constructor(items, dialogData={}, options={}) {
|
|
super(dialogData, options);
|
|
this.options.classes = ["sw5e", "dialog", "select-items-prompt", "sheet"];
|
|
|
|
/**
|
|
* Store a reference to the Item entities being used
|
|
* @type {Array<Item5e>}
|
|
*/
|
|
this.items = items;
|
|
}
|
|
|
|
activateListeners(html) {
|
|
super.activateListeners(html);
|
|
|
|
// render the item's sheet if its image is clicked
|
|
html.on('click', '.item-image', (event) => {
|
|
const item = this.items.find((feature) => feature.id === event.currentTarget.dataset?.itemId);
|
|
|
|
item?.sheet.render(true);
|
|
})
|
|
}
|
|
|
|
/**
|
|
* A constructor function which displays the AddItemPrompt app for a given Actor and Item set.
|
|
* Returns a Promise which resolves to the dialog FormData once the workflow has been completed.
|
|
* @param {Array<Item5e>} items
|
|
* @param {Object} options
|
|
* @param {string} options.hint - Localized hint to display at the top of the prompt
|
|
* @return {Promise<string[]>} - list of item ids which the user has selected
|
|
*/
|
|
static async create(items, {
|
|
hint
|
|
}) {
|
|
// Render the ability usage template
|
|
const html = await renderTemplate("systems/sw5e/templates/apps/select-items-prompt.html", {items, hint});
|
|
|
|
return new Promise((resolve) => {
|
|
const dlg = new this(items, {
|
|
title: game.i18n.localize('SW5E.SelectItemsPromptTitle'),
|
|
content: html,
|
|
buttons: {
|
|
apply: {
|
|
icon: `<i class="fas fa-user-plus"></i>`,
|
|
label: game.i18n.localize('SW5E.Apply'),
|
|
callback: html => {
|
|
const fd = new FormDataExtended(html[0].querySelector("form")).toObject();
|
|
const selectedIds = Object.keys(fd).filter(itemId => fd[itemId]);
|
|
resolve(selectedIds);
|
|
}
|
|
},
|
|
cancel: {
|
|
icon: '<i class="fas fa-forward"></i>',
|
|
label: game.i18n.localize('SW5E.Skip'),
|
|
callback: () => resolve([])
|
|
}
|
|
},
|
|
default: "apply",
|
|
close: () => resolve([])
|
|
});
|
|
dlg.render(true);
|
|
});
|
|
}
|
|
}
|