forked from GitHub-Mirrors/foundry-sw5e
Added changes from DND5e 1.3.3
This commit is contained in:
parent
3cfee9dd81
commit
f839166082
7 changed files with 29 additions and 26 deletions
|
@ -1458,8 +1458,8 @@ export default class Actor5e extends Actor {
|
|||
}
|
||||
|
||||
// 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) => {
|
||||
return (parseInt(a.data.data.hitDice.slice(1)) || 0) - (parseInt(a.data.data.hitDice.slice(1)) || 0);
|
||||
const sortedClasses = Object.values(this.classes).sort((a, b) => {
|
||||
return (parseInt(b.data.data.hitDice.slice(1)) || 0) - (parseInt(a.data.data.hitDice.slice(1)) || 0);
|
||||
});
|
||||
|
||||
let updates = [];
|
||||
|
|
|
@ -393,10 +393,7 @@ export default class ActorSheet5e extends ActorSheet {
|
|||
/* Event Listeners and Handlers
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Activate event listeners using the prepared sheet HTML
|
||||
* @param html {HTML} The prepared HTML object ready to be rendered into the DOM
|
||||
*/
|
||||
/** @inheritdoc */
|
||||
activateListeners(html) {
|
||||
|
||||
// Activate Item Filters
|
||||
|
@ -407,6 +404,9 @@ export default class ActorSheet5e extends ActorSheet {
|
|||
// Item summaries
|
||||
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
|
||||
if ( this.isEditable ) {
|
||||
|
||||
|
@ -429,7 +429,6 @@ export default class ActorSheet5e extends ActorSheet {
|
|||
|
||||
// Owned Item management
|
||||
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-collapse').click(this._onItemCollapse.bind(this));
|
||||
html.find('.item-uses input').click(ev => ev.target.select()).change(this._onUsesChange.bind(this));
|
||||
|
|
|
@ -221,11 +221,11 @@ export default class ActorSheet5eCharacterNew extends ActorSheet5e {
|
|||
|
||||
/**
|
||||
* 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) {
|
||||
super.activateListeners(html);
|
||||
if ( !this.options.editable ) return;
|
||||
if ( !this.isEditable ) return;
|
||||
|
||||
// Inventory Functions
|
||||
// html.find(".currency-convert").click(this._onConvertCurrency.bind(this));
|
||||
|
|
|
@ -257,7 +257,7 @@ export default class ActorSheet5eVehicle extends ActorSheet5e {
|
|||
/** @override */
|
||||
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-hp input')
|
||||
|
|
|
@ -403,10 +403,7 @@ export default class ActorSheet5e extends ActorSheet {
|
|||
/* Event Listeners and Handlers
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Activate event listeners using the prepared sheet HTML
|
||||
* @param html {HTML} The prepared HTML object ready to be rendered into the DOM
|
||||
*/
|
||||
/** @inheritdoc */
|
||||
activateListeners(html) {
|
||||
|
||||
// Activate Item Filters
|
||||
|
@ -417,6 +414,9 @@ export default class ActorSheet5e extends ActorSheet {
|
|||
// Item summaries
|
||||
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
|
||||
if ( this.isEditable ) {
|
||||
|
||||
|
@ -439,7 +439,6 @@ export default class ActorSheet5e extends ActorSheet {
|
|||
|
||||
// Owned Item management
|
||||
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-uses input').click(ev => ev.target.select()).change(this._onUsesChange.bind(this));
|
||||
html.find('.slot-max-override').click(this._onPowerSlotOverride.bind(this));
|
||||
|
|
|
@ -201,11 +201,11 @@ export default class ActorSheet5eCharacter extends ActorSheet5e {
|
|||
|
||||
/**
|
||||
* 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) {
|
||||
super.activateListeners(html);
|
||||
if ( !this.options.editable ) return;
|
||||
if ( !this.isEditable ) return;
|
||||
|
||||
// Item State Toggling
|
||||
html.find('.item-toggle').click(this._onToggleItem.bind(this));
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue