New properties item list

New properties item list
This commit is contained in:
VINI1520 2020-07-13 19:51:27 -03:00
parent bf30d8faa8
commit 7b51a5c178
8 changed files with 348 additions and 7 deletions

View file

@ -238,7 +238,40 @@ SW5E.damageTypes = {
"necrotic": "SW5E.DamageNecrotic",
"poison": "SW5E.DamagePoison",
"psychic": "SW5E.DamagePsychic",
"Sonic": "SW5E.DamageSonic",
"Sonic": "SW5E.DamageSonic"
};
/* -------------------------------------------- */
// armor Types
SW5E.armorpropertiesTypes = {
"Absorptive": "SW5E.ArmorProperAbsorptive",
"Agile": "SW5E.ArmorProperAgile",
"Anchor": "SW5E.ArmorProperAnchor",
"Avoidant": "SW5E.ArmorProperAvoidant",
"Barbed": "SW5E.ArmorProperBarbed",
"Charging": "SW5E.ArmorProperCharging",
"Concealing": "SW5E.ArmorProperConcealing",
"Cumbersome": "SW5E.ArmorProperCumbersome",
"Gauntleted": "SW5E.ArmorProperGauntleted",
"Imbalanced": "SW5E.ArmorProperImbalanced",
"Impermeable": "SW5E.ArmorProperImpermeable",
"Insulated": "SW5E.ArmorProperInsulated",
"Interlocking": "SW5E.ArmorProperInterlocking",
"Lambent": "SW5E.ArmorProperLambent",
"Lightweight": "SW5E.ArmorProperLightweight",
"Magnetic": "SW5E.ArmorProperMagnetic",
"Obscured": "SW5E.ArmorProperObscured",
"Powered": "SW5E.ArmorProperPowered",
"Reactive": "SW5E.ArmorProperReactive",
"Regulated": "SW5E.ArmorProperRegulated",
"Reinforced": "SW5E.ArmorProperReinforced",
"Responsive": "SW5E.ArmorProperResponsive",
"Rigid": "SW5E.ArmorProperRigid",
"Silent": "SW5E.ArmorProperSilent",
"Spiked": "SW5E.ArmorProperSpiked",
"Steadfast": "SW5E.ArmorProperSteadfast",
"Versatile": "SW5E.ArmorProperVersatile"
};
/* -------------------------------------------- */
@ -597,7 +630,7 @@ SW5E.languages = {
"sith": "SW5E.LanguagesSith",
"togruti": "SW5E.LanguagesTogruti",
"dosh": "SW5E.LanguagesDosh",
"twi'leki": "SW5E.LanguagesTwi'leki",
"twi'leki": "SW5E.LanguagesTwileki",
"tusken": "SW5E.LanguagesTusken",
"shyriiwook": "SW5E.LanguagesShyriiwook",
"zabraki": "SW5E.LanguagesZabraki",

View file

@ -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