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

@ -1458,8 +1458,8 @@ export default class Actor5e extends Actor {
} }
// Sort classes which can recover HD, assuming players prefer recovering larger HD first. // Sort classes which can recover HD, assuming players prefer recovering larger HD first.
const sortedClasses = this.items.filter(item => item.data.type === "class").sort((a, b) => { const sortedClasses = Object.values(this.classes).sort((a, b) => {
return (parseInt(a.data.data.hitDice.slice(1)) || 0) - (parseInt(a.data.data.hitDice.slice(1)) || 0); return (parseInt(b.data.data.hitDice.slice(1)) || 0) - (parseInt(a.data.data.hitDice.slice(1)) || 0);
}); });
let updates = []; let updates = [];

View file

@ -393,10 +393,7 @@ export default class ActorSheet5e extends ActorSheet {
/* Event Listeners and Handlers /* Event Listeners and Handlers
/* -------------------------------------------- */ /* -------------------------------------------- */
/** /** @inheritdoc */
* Activate event listeners using the prepared sheet HTML
* @param html {HTML} The prepared HTML object ready to be rendered into the DOM
*/
activateListeners(html) { activateListeners(html) {
// Activate Item Filters // Activate Item Filters
@ -407,6 +404,9 @@ export default class ActorSheet5e extends ActorSheet {
// Item summaries // Item summaries
html.find('.item .item-name.rollable h4').click(event => this._onItemSummary(event)); html.find('.item .item-name.rollable h4').click(event => this._onItemSummary(event));
// View Item Sheets
html.find('.item-edit').click(this._onItemEdit.bind(this));
// Editable Only Listeners // Editable Only Listeners
if ( this.isEditable ) { if ( this.isEditable ) {
@ -429,7 +429,6 @@ export default class ActorSheet5e extends ActorSheet {
// Owned Item management // Owned Item management
html.find('.item-create').click(this._onItemCreate.bind(this)); html.find('.item-create').click(this._onItemCreate.bind(this));
html.find('.item-edit').click(this._onItemEdit.bind(this));
html.find('.item-delete').click(this._onItemDelete.bind(this)); html.find('.item-delete').click(this._onItemDelete.bind(this));
html.find('.item-collapse').click(this._onItemCollapse.bind(this)); html.find('.item-collapse').click(this._onItemCollapse.bind(this));
html.find('.item-uses input').click(ev => ev.target.select()).change(this._onUsesChange.bind(this)); html.find('.item-uses input').click(ev => ev.target.select()).change(this._onUsesChange.bind(this));

View file

@ -221,11 +221,11 @@ export default class ActorSheet5eCharacterNew extends ActorSheet5e {
/** /**
* Activate event listeners using the prepared sheet HTML * Activate event listeners using the prepared sheet HTML
* @param html {HTML} The prepared HTML object ready to be rendered into the DOM * @param html {jQuery} The prepared HTML object ready to be rendered into the DOM
*/ */
activateListeners(html) { activateListeners(html) {
super.activateListeners(html); super.activateListeners(html);
if ( !this.options.editable ) return; if ( !this.isEditable ) return;
// Inventory Functions // Inventory Functions
// html.find(".currency-convert").click(this._onConvertCurrency.bind(this)); // html.find(".currency-convert").click(this._onConvertCurrency.bind(this));

View file

@ -257,7 +257,7 @@ export default class ActorSheet5eVehicle extends ActorSheet5e {
/** @override */ /** @override */
activateListeners(html) { activateListeners(html) {
super.activateListeners(html); super.activateListeners(html);
if (!this.options.editable) return; if (!this.isEditable) return;
html.find('.item-toggle').click(this._onToggleItem.bind(this)); html.find('.item-toggle').click(this._onToggleItem.bind(this));
html.find('.item-hp input') html.find('.item-hp input')

View file

@ -403,10 +403,7 @@ export default class ActorSheet5e extends ActorSheet {
/* Event Listeners and Handlers /* Event Listeners and Handlers
/* -------------------------------------------- */ /* -------------------------------------------- */
/** /** @inheritdoc */
* Activate event listeners using the prepared sheet HTML
* @param html {HTML} The prepared HTML object ready to be rendered into the DOM
*/
activateListeners(html) { activateListeners(html) {
// Activate Item Filters // Activate Item Filters
@ -417,6 +414,9 @@ export default class ActorSheet5e extends ActorSheet {
// Item summaries // Item summaries
html.find('.item .item-name.rollable h4').click(event => this._onItemSummary(event)); html.find('.item .item-name.rollable h4').click(event => this._onItemSummary(event));
// View Item Sheets
html.find('.item-edit').click(this._onItemEdit.bind(this));
// Editable Only Listeners // Editable Only Listeners
if ( this.isEditable ) { if ( this.isEditable ) {
@ -439,7 +439,6 @@ export default class ActorSheet5e extends ActorSheet {
// Owned Item management // Owned Item management
html.find('.item-create').click(this._onItemCreate.bind(this)); html.find('.item-create').click(this._onItemCreate.bind(this));
html.find('.item-edit').click(this._onItemEdit.bind(this));
html.find('.item-delete').click(this._onItemDelete.bind(this)); html.find('.item-delete').click(this._onItemDelete.bind(this));
html.find('.item-uses input').click(ev => ev.target.select()).change(this._onUsesChange.bind(this)); html.find('.item-uses input').click(ev => ev.target.select()).change(this._onUsesChange.bind(this));
html.find('.slot-max-override').click(this._onPowerSlotOverride.bind(this)); html.find('.slot-max-override').click(this._onPowerSlotOverride.bind(this));

View file

@ -201,11 +201,11 @@ export default class ActorSheet5eCharacter extends ActorSheet5e {
/** /**
* Activate event listeners using the prepared sheet HTML * Activate event listeners using the prepared sheet HTML
* @param html {HTML} The prepared HTML object ready to be rendered into the DOM * @param html {jQuery} The prepared HTML object ready to be rendered into the DOM
*/ */
activateListeners(html) { activateListeners(html) {
super.activateListeners(html); super.activateListeners(html);
if ( !this.options.editable ) return; if ( !this.isEditable ) return;
// Item State Toggling // Item State Toggling
html.find('.item-toggle').click(this._onToggleItem.bind(this)); html.find('.item-toggle').click(this._onToggleItem.bind(this));

View file

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