Changes for 1.3.5

This commit is contained in:
TJ 2021-06-21 18:27:34 -05:00
parent e2f002292b
commit c0e71fe0f3
22 changed files with 102 additions and 68 deletions

View file

@ -1688,11 +1688,13 @@ export default class Actor5e extends Actor {
// Get the Tokens which represent this actor
if ( canvas.ready ) {
const tokens = this.getActiveTokens(true);
const tokenData = await original.getTokenData();
const tokenUpdates = tokens.map(t => {
const tokenData = original.data.token.toJSON();
tokenData._id = t.id;
tokenData.actorId = original.id;
return tokenData;
const update = duplicate(tokenData);
update._id = t.id;
delete update.x;
delete update.y;
return update;
});
canvas.scene.updateEmbeddedDocuments("Token", tokenUpdates);
}

View file

@ -781,7 +781,7 @@ export default class ActorSheet5e extends ActorSheet {
const header = event.currentTarget;
const type = header.dataset.type;
const itemData = {
name: game.i18n.format("SW5E.ItemNew", {type: type.capitalize()}),
name: game.i18n.format("SW5E.ItemNew", {type: game.i18n.localize(`SW5E.ItemType${type.capitalize()}`)}),
type: type,
data: foundry.utils.deepClone(header.dataset)
};

View file

@ -39,7 +39,7 @@ export default class AbilityUseDialog extends Dialog {
// Prepare dialog form data
const data = {
item: item.data,
title: game.i18n.format("SW5E.AbilityUseHint", item.data),
title: game.i18n.format("SW5E.AbilityUseHint", {type: game.i18n.localize(`SW5E.ItemType${item.type.capitalize()}`), name: item.name}),
note: this._getAbilityUseNote(item.data, uses, recharge),
consumePowerSlot: false,
consumeRecharge: recharges,
@ -59,7 +59,7 @@ export default class AbilityUseDialog extends Dialog {
const label = game.i18n.localize("SW5E.AbilityUse" + (data.isPower ? "Cast" : "Use"));
return new Promise((resolve) => {
const dlg = new this(item, {
title: `${item.name}: Usage Configuration`,
title: `${item.name}: ${game.i18n.localize("SW5E.AbilityUseConfig")}`,
content: html,
buttons: {
use: {
@ -187,7 +187,7 @@ export default class AbilityUseDialog extends Dialog {
// Abilities which use Recharge
if ( !!recharge.value ) {
return game.i18n.format(recharge.charged ? "SW5E.AbilityUseChargedHint" : "SW5E.AbilityUseRechargeHint", {
type: item.type,
type: game.i18n.localize(`SW5E.ItemType${item.type.capitalize()}`),
})
}
@ -201,7 +201,7 @@ export default class AbilityUseDialog extends Dialog {
else if ( item.data.quantity === 1 && uses.autoDestroy ) str = "SW5E.AbilityUseConsumableDestroyHint";
else if ( item.data.quantity > 1 ) str = "SW5E.AbilityUseConsumableQuantityHint";
return game.i18n.format(str, {
type: item.data.consumableType,
type: game.i18n.localize(`SW5E.Consumable${item.data.consumableType.capitalize()}`),
value: uses.value,
quantity: item.data.quantity,
max: uses.max,
@ -212,7 +212,7 @@ export default class AbilityUseDialog extends Dialog {
// Other Items
else {
return game.i18n.format("SW5E.AbilityUseNormalHint", {
type: item.type,
type: game.i18n.localize(`SW5E.ItemType${item.type.capitalize()}`),
value: uses.value,
max: uses.max,
per: CONFIG.SW5E.limitedUsePeriods[uses.per]

View file

@ -40,11 +40,11 @@ export default class LongRestDialog extends Dialog {
static async longRestDialog({ actor } = {}) {
return new Promise((resolve, reject) => {
const dlg = new this(actor, {
title: "Long Rest",
title: game.i18n.localize("SW5E.LongRest"),
buttons: {
rest: {
icon: '<i class="fas fa-bed"></i>',
label: "Rest",
label: game.i18n.localize("SW5E.Rest"),
callback: html => {
let newDay = true;
if (game.settings.get("sw5e", "restVariant") !== "gritty")
@ -54,7 +54,7 @@ export default class LongRestDialog extends Dialog {
},
cancel: {
icon: '<i class="fas fa-times"></i>',
label: "Cancel",
label: game.i18n.localize("Cancel"),
callback: reject
}
},

View file

@ -93,11 +93,11 @@ export default class ShortRestDialog extends Dialog {
static async shortRestDialog({actor}={}) {
return new Promise((resolve, reject) => {
const dlg = new this(actor, {
title: "Short Rest",
title: game.i18n.localize("SW5E.ShortRest"),
buttons: {
rest: {
icon: '<i class="fas fa-bed"></i>',
label: "Rest",
label: game.i18n.localize("SW5E.Rest"),
callback: html => {
let newDay = false;
if (game.settings.get("sw5e", "restVariant") === "gritty")
@ -107,7 +107,7 @@ export default class ShortRestDialog extends Dialog {
},
cancel: {
icon: '<i class="fas fa-times"></i>',
label: "Cancel",
label: game.i18n.localize("Cancel"),
callback: reject
}
},

View file

@ -103,6 +103,27 @@ SW5E.weaponProficiencies = {
"vbw": "SW5E.WeaponVibrowhipProficiency"
};
/**
* A map of weapon item proficiency to actor item proficiency
* Used when a new player owned item is created
* @type {Object}
*/
SW5E.weaponProficienciesMap = {
"natural": true,
"simpleB": "sim",
"simpleVW": "sim",
"simpleLW": "sim",
"martialB": "mar",
"martialVW": "mar",
"martialLW": "mar",
// "simpleM": "sim",
// "simpleR": "sim",
// "martialM": "mar",
// "martialR": "mar"
}
// TODO: Check to see if this can be used
// It's not actually been used anywhere in DND5e 1.3.2
// Note name mapped to ID in compendium
@ -270,8 +291,8 @@ SW5E.abilityActivationTypes = {
"hour": SW5E.timePeriods.hour,
"day": SW5E.timePeriods.day,
"special": SW5E.timePeriods.spec,
"legendary": "SW5E.LegAct",
"lair": "SW5E.LairAct",
"legendary": "SW5E.LegendaryActionLabel",
"lair": "SW5E.LairActionLabel",
"crew": "SW5E.VehicleCrewAction"
};
@ -413,6 +434,19 @@ SW5E.armorProficiencies = {
"shl": "SW5E.EquipmentShieldProficiency"
};
/**
* A map of armor item proficiency to actor item proficiency
* Used when a new player owned item is created
* @type {Object}
*/
SW5E.armorProficienciesMap = {
"natural": true,
"clothing": true,
"light": "lgt",
"medium": "med",
"heavy": "hvy",
"shield": "shl"
}
/* -------------------------------------------- */

8
module/effects.js vendored
View file

@ -11,7 +11,7 @@ export function onManageActiveEffect(event, owner) {
switch ( a.dataset.action ) {
case "create":
return owner.createEmbeddedDocuments("ActiveEffect", [{
label: "New Effect",
label: game.i18n.localize("SW5E.EffectNew"),
icon: "icons/svg/aura.svg",
origin: owner.uuid,
"duration.rounds": li.dataset.effectType === "temporary" ? 1 : undefined,
@ -37,17 +37,17 @@ export function prepareActiveEffectCategories(effects) {
const categories = {
temporary: {
type: "temporary",
label: "SW5E.EffectsCategoryTemporary",
label: game.i18n.localize("SW5E.EffectTemporary"),
effects: []
},
passive: {
type: "passive",
label: "SW5E.EffectsCategoryPassive",
label: game.i18n.localize("SW5E.EffectPassive"),
effects: []
},
inactive: {
type: "inactive",
label: "SW5E.EffectsCategoryInactive",
label: game.i18n.localize("SW5E.EffectInactive"),
effects: []
}
};

View file

@ -1295,7 +1295,10 @@ export default class Item5e extends Item {
const abl = this.abilityMod;
if ( abl ) {
const ability = rollData.abilities[abl];
rollData["mod"] = ability.mod || 0;
if ( !ability ) {
console.warn(`Item ${this.name} in Actor ${this.actor.name} has an invalid item ability modifier of ${abl} defined`);
}
rollData["mod"] = ability?.mod || 0;
}
// Include a proficiency score
@ -1536,14 +1539,7 @@ export default class Item5e extends Item {
if ( isNPC ) {
updates["data.proficient"] = true; // NPCs automatically have equipment proficiency
} else {
const armorProf = {
"natural": true,
"clothing": true,
"light": "lgt",
"medium": "med",
"heavy": "hvy",
"shield": "shl"
}[data.data?.armor?.type]; // Player characters check proficiency
const armorProf = CONFIG.DND5E.armorProficienciesMap[data.data?.armor?.type]; // Player characters check proficiency
const actorArmorProfs = actorData.data.traits?.armorProf?.value || [];
updates["data.proficient"] = (armorProf === true) || actorArmorProfs.includes(armorProf);
}
@ -1579,15 +1575,7 @@ export default class Item5e extends Item {
updates["data.proficient"] = true; // NPCs automatically have equipment proficiency
} else {
// TODO: With the changes to make weapon proficiencies more verbose, this may need revising
const weaponProf = {
"natural": true,
"simpleVW": "sim",
"simpleB": "sim",
"simpleLW": "sim",
"martialVW": "mar",
"martialB": "mar",
"martialLW": "mar"
}[data.data?.weaponType]; // Player characters check proficiency
const weaponProf = CONFIG.DND5E.weaponProficienciesMap[data.data?.weaponType]; // Player characters check proficiency
const actorWeaponProfs = actorData.data.traits?.weaponProf?.value || [];
updates["data.proficient"] = (weaponProf === true) || actorWeaponProfs.includes(weaponProf);
}

View file

@ -90,8 +90,7 @@ export default class AbilityTemplate extends MeasuredTemplate {
if ( now - moveTime <= 20 ) return;
const center = event.data.getLocalPosition(this.layer);
const snapped = canvas.grid.getSnappedPosition(center.x, center.y, 2);
this.data.x = snapped.x;
this.data.y = snapped.y;
this.data.update({x: snapped.x, y: snapped.y});
this.refresh();
moveTime = now;
};