Added changes from DND5e 1.3.3

This commit is contained in:
Jacob Lucas 2021-06-03 04:10:22 +01:00
parent 3cfee9dd81
commit f839166082
7 changed files with 29 additions and 26 deletions

View file

@ -317,7 +317,7 @@ export default class Item5e extends Item {
*/
getDerivedDamageLabel() {
const itemData = this.data.data;
if ( !this.hasAttack || !itemData || !this.isOwned ) return [];
if ( !this.hasDamage || !itemData || !this.isOwned ) return [];
const rollData = this.getRollData();
@ -538,7 +538,7 @@ export default class Item5e extends Item {
// Commit pending data updates
if ( !foundry.utils.isObjectEmpty(itemUpdates) ) await item.update(itemUpdates);
if ( consumeQuantity && (id.quantity === 0) ) await item.delete();
if ( consumeQuantity && (item.data.data.quantity === 0) ) await item.delete();
if ( !foundry.utils.isObjectEmpty(actorUpdates) ) await actor.update(actorUpdates);
if ( !foundry.utils.isObjectEmpty(resourceUpdates) ) {
const resource = actor.items.get(id.consume?.target);
@ -1342,7 +1342,7 @@ export default class Item5e extends Item {
// Get the Item from stored flag data or by the item ID on the Actor
const storedData = message.getFlag("sw5e", "itemData");
const item = storedData ? new this.constructor(storedData, {parent: actor}) : actor.items.get(card.dataset.itemId);
const item = storedData ? new this(storedData, {parent: actor}) : actor.items.get(card.dataset.itemId);
if ( !item ) {
return ui.notifications.error(game.i18n.format("SW5E.ActionWarningNoItem", {item: card.dataset.itemId, name: actor.name}))
}
@ -1444,14 +1444,19 @@ export default class Item5e extends Item {
if ( !this.isEmbedded || (this.parent.type === "vehicle") ) return;
const actorData = this.parent.data;
const isNPC = this.parent.type === "npc";
let updates;
switch (data.type) {
case "equipment":
return this._onCreateOwnedEquipment(data, actorData, isNPC);
updates = this._onCreateOwnedEquipment(data, actorData, isNPC);
break;
case "weapon":
return this._onCreateOwnedWeapon(data, actorData, isNPC);
updates = this._onCreateOwnedWeapon(data, actorData, isNPC);
break;
case "power":
return this._onCreateOwnedPower(data, actorData, isNPC);
updates = this._onCreateOwnedPower(data, actorData, isNPC);
break;
}
if (updates) return this.data.update(updates);
}
/* -------------------------------------------- */
@ -1543,7 +1548,7 @@ export default class Item5e extends Item {
updates["data.proficient"] = (armorProf === true) || actorArmorProfs.includes(armorProf);
}
}
foundry.utils.mergeObject(data, updates);
return updates;
}
/* -------------------------------------------- */
@ -1555,7 +1560,7 @@ export default class Item5e extends Item {
_onCreateOwnedPower(data, actorData, isNPC) {
const updates = {};
updates["data.prepared"] = true; // Automatically prepare powers for everyone
foundry.utils.mergeObject(data, updates);
return updates;
}
/* -------------------------------------------- */
@ -1587,7 +1592,7 @@ export default class Item5e extends Item {
updates["data.proficient"] = (weaponProf === true) || actorWeaponProfs.includes(weaponProf);
}
}
foundry.utils.mergeObject(data, updates);
return updates;
}
/* -------------------------------------------- */