forked from GitHub-Mirrors/foundry-sw5e
New properties item list
New properties item list
This commit is contained in:
parent
bf30d8faa8
commit
7b51a5c178
8 changed files with 348 additions and 7 deletions
|
@ -47,6 +47,7 @@ export class ItemSheet5e extends ItemSheet {
|
|||
data.hasAttackRoll = this.item.hasAttack;
|
||||
data.isHealing = data.item.data.actionType === "heal";
|
||||
data.isFlatDC = getProperty(data.item.data, "save.scaling") === "flat";
|
||||
data.isWeapon = data.item.type === "weapon";
|
||||
return data;
|
||||
}
|
||||
|
||||
|
@ -145,6 +146,25 @@ export class ItemSheet5e extends ItemSheet {
|
|||
return arr;
|
||||
}, []);
|
||||
|
||||
// Handle armorproperties Array
|
||||
let armorproperties = Object.entries(formData).filter(e => e[0].startsWith("data.armorproperties.parts"));
|
||||
formData["data.armorproperties.parts"] = armorproperties.reduce((arr, entry) => {
|
||||
let [i, j] = entry[0].split(".").slice(3);
|
||||
if ( !arr[i] ) arr[i] = [];
|
||||
arr[i][j] = entry[1];
|
||||
return arr;
|
||||
}, []);
|
||||
|
||||
// Handle weaponproperties Array
|
||||
let weaponproperties = Object.entries(formData).filter(e => e[0].startsWith("data.weaponproperties.parts"));
|
||||
formData["data.weaponproperties.parts"] = weaponproperties.reduce((arr, entry) => {
|
||||
let [i, j] = entry[0].split(".").slice(3);
|
||||
if ( !arr[i] ) arr[i] = [];
|
||||
arr[i][j] = entry[1];
|
||||
return arr;
|
||||
}, []);
|
||||
|
||||
|
||||
// Update the Item
|
||||
super._updateObject(event, formData);
|
||||
}
|
||||
|
@ -158,6 +178,13 @@ export class ItemSheet5e extends ItemSheet {
|
|||
|
||||
// Activate any Trait Selectors
|
||||
html.find('.trait-selector.class-skills').click(this._onConfigureClassSkills.bind(this));
|
||||
|
||||
// Armor properties
|
||||
html.find(".armorproperties-control").click(this._onarmorpropertiesControl.bind(this));
|
||||
|
||||
// Weapon properties
|
||||
html.find(".weaponproperties-control").click(this._onweaponpropertiesControl.bind(this));
|
||||
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
@ -191,6 +218,64 @@ export class ItemSheet5e extends ItemSheet {
|
|||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Add or remove a armorproperties part from the armorproperties formula
|
||||
* @param {Event} event The original click event
|
||||
* @return {Promise}
|
||||
* @private
|
||||
*/
|
||||
async _onarmorpropertiesControl(event) {
|
||||
event.preventDefault();
|
||||
const a = event.currentTarget;
|
||||
|
||||
// Add new armorproperties component
|
||||
if ( a.classList.contains("add-armorproperties") ) {
|
||||
await this._onSubmit(event); // Submit any unsaved changes
|
||||
const armorproperties = this.item.data.data.armorproperties;
|
||||
return this.item.update({"data.armorproperties.parts": armorproperties.parts.concat([["", ""]])});
|
||||
}
|
||||
|
||||
// Remove a armorproperties component
|
||||
if ( a.classList.contains("delete-armorproperties") ) {
|
||||
await this._onSubmit(event); // Submit any unsaved changes
|
||||
const li = a.closest(".armorproperties-part");
|
||||
const armorproperties = duplicate(this.item.data.data.armorproperties);
|
||||
armorproperties.parts.splice(Number(li.dataset.armorpropertiesPart), 1);
|
||||
return this.item.update({"data.armorproperties.parts": armorproperties.parts});
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Add or remove a weaponproperties part from the weaponproperties formula
|
||||
* @param {Event} event The original click event
|
||||
* @return {Promise}
|
||||
* @private
|
||||
*/
|
||||
async _onweaponpropertiesControl(event) {
|
||||
event.preventDefault();
|
||||
const a = event.currentTarget;
|
||||
|
||||
// Add new weaponproperties component
|
||||
if ( a.classList.contains("add-weaponproperties") ) {
|
||||
await this._onSubmit(event); // Submit any unsaved changes
|
||||
const weaponproperties = this.item.data.data.weaponproperties;
|
||||
return this.item.update({"data.weaponproperties.parts": weaponproperties.parts.concat([["", ""]])});
|
||||
}
|
||||
|
||||
// Remove a weaponproperties component
|
||||
if ( a.classList.contains("delete-weaponproperties") ) {
|
||||
await this._onSubmit(event); // Submit any unsaved changes
|
||||
const li = a.closest(".weaponproperties-part");
|
||||
const weaponproperties = duplicate(this.item.data.data.weaponproperties);
|
||||
weaponproperties.parts.splice(Number(li.dataset.weaponpropertiesPart), 1);
|
||||
return this.item.update({"data.weaponproperties.parts": weaponproperties.parts});
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Handle spawning the TraitSelector application which allows a checkbox of multiple trait options
|
||||
* @param {Event} event The click event which originated the selection
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue