forked from GitHub-Mirrors/foundry-sw5e
Merge branch 'Develop' into 1.3.5-dev
This commit is contained in:
commit
95b2b1e39c
33 changed files with 221 additions and 154 deletions
|
@ -696,10 +696,10 @@ export default class Actor5e extends Actor {
|
|||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
/* Event Handlers
|
||||
/* Event Handlers */
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/** @inheritDoc */
|
||||
/** @inheritdoc */
|
||||
async _preCreate(data, options, user) {
|
||||
await super._preCreate(data, options, user);
|
||||
|
||||
|
|
|
@ -75,10 +75,10 @@ export default class ActorSheet5e extends ActorSheet {
|
|||
options: this.options,
|
||||
editable: this.isEditable,
|
||||
cssClass: isOwner ? "editable" : "locked",
|
||||
isCharacter: this.actor.data.type === "character",
|
||||
isNPC: this.actor.data.type === "npc",
|
||||
isStarship: this.actor.data.type === "starship",
|
||||
isVehicle: this.actor.data.type === 'vehicle',
|
||||
isCharacter: this.actor.type === "character",
|
||||
isNPC: this.actor.type === "npc",
|
||||
isStarship: this.actor.type === "starship",
|
||||
isVehicle: this.actor.type === 'vehicle',
|
||||
config: CONFIG.SW5E,
|
||||
rollData: this.actor.getRollData.bind(this.actor)
|
||||
};
|
||||
|
@ -109,7 +109,7 @@ export default class ActorSheet5e extends ActorSheet {
|
|||
|
||||
// Skills
|
||||
if (actorData.data.skills) {
|
||||
for ( let [s, skl] of Object.entries(actorData.data.skills)) {
|
||||
for (let [s, skl] of Object.entries(actorData.data.skills)) {
|
||||
skl.ability = CONFIG.SW5E.abilityAbbreviations[skl.ability];
|
||||
skl.icon = this._getProficiencyIcon(skl.value);
|
||||
skl.hover = CONFIG.SW5E.proficiencyLevels[skl.value];
|
||||
|
|
|
@ -112,7 +112,7 @@ export default class ActorSheet5eCharacterNew extends ActorSheet5e {
|
|||
this._prepareItemToggleState(item);
|
||||
|
||||
// Primary Class
|
||||
if ( item.type === "class" ) item.isOriginalClass = ( item.data._id === this.actor.data.data.details.originalClass );
|
||||
if ( item.type === "class" ) item.isOriginalClass = ( item._id === this.actor.data.data.details.originalClass );
|
||||
|
||||
// Classify items into types
|
||||
if ( item.type === "power" && ["lgt", "drk", "uni"].includes(item.data.school) ) arr[1].push(item);
|
||||
|
@ -143,7 +143,7 @@ export default class ActorSheet5eCharacterNew extends ActorSheet5e {
|
|||
for ( let i of items ) {
|
||||
i.data.quantity = i.data.quantity || 0;
|
||||
i.data.weight = i.data.weight || 0;
|
||||
i.totalWeight = Math.round(i.data.quantity * i.data.weight * 10) / 10;
|
||||
i.totalWeight = (i.data.quantity * i.data.weight).toNearest(0.1);
|
||||
inventory[i.type].items.push(i);
|
||||
}
|
||||
|
||||
|
@ -156,9 +156,9 @@ export default class ActorSheet5eCharacterNew extends ActorSheet5e {
|
|||
classes: { label: "SW5E.ItemTypeClassPl", items: [], hasActions: false, dataset: {type: "class"}, isClass: true },
|
||||
classfeatures: { label: "SW5E.ItemTypeClassFeats", items: [], hasActions: true, dataset: {type: "classfeature"}, isClassfeature: true },
|
||||
archetype: { label: "SW5E.ItemTypeArchetype", items: [], hasActions: false, dataset: {type: "archetype"}, isArchetype: true },
|
||||
deployments: { label: "SW5E.ItemTypeDeploymentPl", items: [], hasActions: false, dataset: {type: "deployment"}, isDeployment: true },
|
||||
deploymentfeatures: { label: "SW5E.ItemTypeDeploymentFeaturePl", items: [], hasActions: true, dataset: {type: "deploymentfeature"}, isDeploymentfeature: true },
|
||||
ventures: { label: "SW5E.ItemTypeVenturePl", items: [], hasActions: false, dataset: {type: "venture"}, isVenture: true },
|
||||
deployments: { label: "SW5E.ItemTypeDeploymentPl", items: [], hasActions: false, dataset: {type: "deployment"}, isDeployment: true },
|
||||
deploymentfeatures: { label: "SW5E.ItemTypeDeploymentFeaturePl", items: [], hasActions: true, dataset: {type: "deploymentfeature"}, isDeploymentfeature: true },
|
||||
ventures: { label: "SW5E.ItemTypeVenturePl", items: [], hasActions: false, dataset: {type: "venture"}, isVenture: true },
|
||||
species: { label: "SW5E.ItemTypeSpecies", items: [], hasActions: false, dataset: {type: "species"}, isSpecies: true },
|
||||
background: { label: "SW5E.ItemTypeBackground", items: [], hasActions: false, dataset: {type: "background"}, isBackground: true },
|
||||
fightingstyles: { label: "SW5E.ItemTypeFightingStylePl", items: [], hasActions: false, dataset: {type: "fightingstyle"}, isFightingstyle: true },
|
||||
|
@ -175,9 +175,9 @@ export default class ActorSheet5eCharacterNew extends ActorSheet5e {
|
|||
features.classes.items = classes;
|
||||
features.classfeatures.items = classfeatures;
|
||||
features.archetype.items = archetypes;
|
||||
features.deployments.items = deployments;
|
||||
features.deploymentfeatures.items = deploymentfeatures;
|
||||
features.ventures.items = ventures;
|
||||
features.deployments.items = deployments;
|
||||
features.deploymentfeatures.items = deploymentfeatures;
|
||||
features.ventures.items = ventures;
|
||||
features.species.items = species;
|
||||
features.background.items = backgrounds;
|
||||
features.fightingstyles.items = fightingstyles;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import Actor5e from "../../entity.js";
|
||||
import Actor5e from "../entity.js";
|
||||
import ActorSheet5e from "./base.js";
|
||||
|
||||
/**
|
||||
|
@ -88,7 +88,7 @@ export default class ActorSheet5eNPCNew extends ActorSheet5e {
|
|||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/** @override */
|
||||
/** @inheritdoc */
|
||||
getData(options) {
|
||||
const data = super.getData(options);
|
||||
|
||||
|
|
|
@ -222,7 +222,7 @@ export default class ActorSheet5eVehicle extends ActorSheet5e {
|
|||
if ( isCargo ) {
|
||||
totalWeight += (item.data.weight || 0) * item.data.quantity;
|
||||
cargo.cargo.items.push(item);
|
||||
continue
|
||||
continue;
|
||||
}
|
||||
|
||||
// Handle non-cargo item types
|
||||
|
@ -371,6 +371,8 @@ export default class ActorSheet5eVehicle extends ActorSheet5e {
|
|||
return super._onItemDelete(event);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/** @override */
|
||||
async _onDropItemCreate(itemData) {
|
||||
const cargoTypes = ["weapon", "equipment", "consumable", "tool", "loot", "backpack"];
|
||||
|
|
|
@ -789,7 +789,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)
|
||||
};
|
||||
|
@ -820,6 +820,7 @@ export default class ActorSheet5e extends ActorSheet {
|
|||
*/
|
||||
_onItemDelete(event) {
|
||||
event.preventDefault();
|
||||
const li = event.currentTarget.closest(".item");
|
||||
const item = this.actor.items.get(li.dataset.itemId);
|
||||
if ( item ) return item.delete();
|
||||
}
|
||||
|
|
|
@ -101,7 +101,7 @@ export default class ActorSheet5eCharacter extends ActorSheet5e {
|
|||
this._prepareItemToggleState(item);
|
||||
|
||||
// Primary Class
|
||||
if ( item.type === "class" ) item.isOriginalClass = ( item.data._id === this.actor.data.data.details.originalClass );
|
||||
if ( item.type === "class" ) item.isOriginalClass = ( item._id === this.actor.data.data.details.originalClass );
|
||||
|
||||
// Classify items into types
|
||||
if ( item.type === "power" ) arr[1].push(item);
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import Actor5e from "../entity.js";
|
||||
import ActorSheet5e from "./base.js";
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/**
|
||||
* An application class which provides advanced configuration for special character flags which modify an Actor
|
||||
* @extends {DocumentSheet}
|
||||
* @implements {DocumentSheet}
|
||||
*/
|
||||
export default class ActorSheetFlags extends DocumentSheet {
|
||||
static get defaultOptions() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/**
|
||||
* A simple form to set actor movement speeds
|
||||
* A simple form to set Actor movement speeds.
|
||||
* @extends {DocumentSheet}
|
||||
*/
|
||||
export default class ActorSensesConfig extends DocumentSheet {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
*/
|
||||
export default class TraitSelector extends DocumentSheet {
|
||||
|
||||
/** @inheritDoc */
|
||||
/** @inheritdoc */
|
||||
static get defaultOptions() {
|
||||
return foundry.utils.mergeObject(super.defaultOptions, {
|
||||
id: "trait-selector",
|
||||
|
|
|
@ -110,19 +110,13 @@ SW5E.weaponProficiencies = {
|
|||
*/
|
||||
SW5E.weaponProficienciesMap = {
|
||||
"natural": true,
|
||||
"simpleB": "sim",
|
||||
"simpleVW": "sim",
|
||||
"simpleB": "sim",
|
||||
"simpleLW": "sim",
|
||||
"martialB": "mar",
|
||||
"martialVW": "mar",
|
||||
"martialLW": "mar",
|
||||
|
||||
// "simpleM": "sim",
|
||||
// "simpleR": "sim",
|
||||
// "martialM": "mar",
|
||||
// "martialR": "mar"
|
||||
}
|
||||
|
||||
"martialB": "mar",
|
||||
"martialLW": "mar"
|
||||
};
|
||||
|
||||
// TODO: Check to see if this can be used
|
||||
// It's not actually been used anywhere in DND5e 1.3.2
|
||||
|
@ -439,7 +433,7 @@ SW5E.armorProficiencies = {
|
|||
* Used when a new player owned item is created
|
||||
* @type {Object}
|
||||
*/
|
||||
SW5E.armorProficienciesMap = {
|
||||
SW5E.armorProficienciesMap = {
|
||||
"natural": true,
|
||||
"clothing": true,
|
||||
"light": "lgt",
|
||||
|
@ -780,7 +774,7 @@ SW5E.starshipRolesgrg = {
|
|||
|
||||
/**
|
||||
* The set of possible sensory perception types which an Actor may have
|
||||
* @type {object}
|
||||
* @enum {string}
|
||||
*/
|
||||
SW5E.senses = {
|
||||
"blindsight": "SW5E.SenseBlindsight",
|
||||
|
|
|
@ -42,7 +42,14 @@ export function simplifyRollFormula(formula, data, {constantFirst = false} = {})
|
|||
const rollableFormula = Roll.getFormula(rollableTerms); // Cleans up the non-constant terms and produces a new formula string
|
||||
|
||||
// Mathematically evaluate the constant formula to produce a single constant term
|
||||
const constantPart = constantFormula ? Roll.safeEval(constantFormula) : undefined;
|
||||
let constantPart = undefined;
|
||||
if ( constantFormula ) {
|
||||
try {
|
||||
constantPart = Roll.safeEval(constantFormula)
|
||||
} catch (err) {
|
||||
console.warn(`Unable to evaluate constant term ${constantFormula} in simplifyRollFormula`);
|
||||
}
|
||||
}
|
||||
|
||||
// Order the rollable and constant terms, either constant first or second depending on the optional argument
|
||||
const parts = constantFirst ? [constantPart, rollableFormula] : [rollableFormula, constantPart];
|
||||
|
|
|
@ -255,7 +255,7 @@ export default class Item5e extends Item {
|
|||
|
||||
// Range Label
|
||||
let rng = data.range || {};
|
||||
if (["none", "touch", "self"].includes(rng.units) || (rng.value === 0)) {
|
||||
if ( ["none", "touch", "self"].includes(rng.units) ) {
|
||||
rng.value = null;
|
||||
rng.long = null;
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ export default class ItemSheet5e extends ItemSheet {
|
|||
// Potential consumption targets
|
||||
data.abilityConsumptionTargets = this._getItemConsumptionTargets(itemData);
|
||||
|
||||
// Action Detail
|
||||
// Action Details
|
||||
data.hasAttackRoll = this.item.hasAttack;
|
||||
data.isHealing = itemData.data.actionType === "heal";
|
||||
data.isFlatDC = getProperty(itemData, "data.save.scaling") === "flat";
|
||||
|
|
|
@ -142,7 +142,7 @@ export const migrateActorData = async function(actor) {
|
|||
const results = await memo;
|
||||
|
||||
// Migrate the Owned Item
|
||||
const itemData = i instanceof CONFIG.Item.documentClass ? i.toObject() : i
|
||||
const itemData = i instanceof CONFIG.Item.documentClass ? i.toObject() : i;
|
||||
let itemUpdate = await migrateActorItemData(itemData, actor);
|
||||
|
||||
// Prepared, Equipped, and Proficient for NPC actors
|
||||
|
@ -154,7 +154,7 @@ export const migrateActorData = async function(actor) {
|
|||
|
||||
// Update the Owned Item
|
||||
if ( !isObjectEmpty(itemUpdate) ) {
|
||||
itemUpdate._id = itemData.id;
|
||||
itemUpdate._id = itemData._id;
|
||||
console.log(`Migrating Actor ${actor.name}'s ${i.name}`);
|
||||
results.push(expandObject(itemUpdate));
|
||||
}
|
||||
|
@ -208,12 +208,15 @@ function cleanActorData(actorData) {
|
|||
|
||||
/**
|
||||
* Migrate a single Item entity to incorporate latest data model changes
|
||||
* @param item
|
||||
*
|
||||
* @param {object} item Item data to migrate
|
||||
* @return {object} The updateData to apply
|
||||
*/
|
||||
export const migrateItemData = function(item) {
|
||||
const updateData = {};
|
||||
_migrateItemClassPowerCasting(item, updateData);
|
||||
_migrateItemAttunement(item, updateData);
|
||||
_migrateItemPowercasting(item, updateData);
|
||||
return updateData;
|
||||
};
|
||||
|
||||
|
@ -228,6 +231,7 @@ export const migrateActorItemData = async function(item, actor) {
|
|||
const updateData = {};
|
||||
_migrateItemClassPowerCasting(item, updateData);
|
||||
_migrateItemAttunement(item, updateData);
|
||||
_migrateItemPowercasting(item, updateData);
|
||||
await _migrateItemPower(item, actor, updateData);
|
||||
return updateData;
|
||||
};
|
||||
|
@ -464,6 +468,8 @@ function _migrateActorSenses(actor, updateData) {
|
|||
return updateData;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Migrate the actor details.type string to object
|
||||
* @private
|
||||
|
@ -643,12 +649,32 @@ async function _migrateItemPower(item, actor, updateData) {
|
|||
* @private
|
||||
*/
|
||||
function _migrateItemAttunement(item, updateData) {
|
||||
if ( item.data.data.attuned === undefined ) return updateData;
|
||||
if ( item.data?.attuned === undefined ) return updateData;
|
||||
updateData["data.attunement"] = CONFIG.SW5E.attunementTypes.NONE;
|
||||
updateData["data.-=attuned"] = null;
|
||||
return updateData;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/**
|
||||
* Replace class powercasting string to object.
|
||||
*
|
||||
* @param {object} item Item data to migrate
|
||||
* @param {object} updateData Existing update to expand upon
|
||||
* @return {object} The updateData to apply
|
||||
* @private
|
||||
*/
|
||||
function _migrateItemPowercasting(item, updateData) {
|
||||
if ( item.type !== "class" || (foundry.utils.getType(item.data.powercasting) === "Object") ) return updateData;
|
||||
updateData["data.powercasting"] = {
|
||||
progression: item.data.powercasting,
|
||||
ability: ""
|
||||
};
|
||||
return updateData;
|
||||
}
|
||||
|
||||
|
||||
/* -------------------------------------------- */
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue