Skip to content

Commit

Permalink
5e bugfixes and migration improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
aaclayton committed Nov 26, 2019
1 parent c8f386d commit e96e57a
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 36 deletions.
7 changes: 2 additions & 5 deletions dnd5e.css
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@
margin-bottom: 5px;
}
.dnd5e.sheet.actor .counters .counter {
padding: 0 6px;
padding: 0 3px;
line-height: 32px;
}
.dnd5e.sheet.actor .counters .counter h4 {
Expand All @@ -586,17 +586,14 @@
height: 20px;
max-width: 20px;
margin: 0;
padding: 0;
text-align: center;
}
.dnd5e.sheet.actor .counters .counter input[type="checkbox"] {
position: relative;
margin: 0;
top: 6px;
}
.dnd5e.sheet.actor .counters .counter.lair input[type="text"] {
width: 32px;
max-width: 32px;
}
.dnd5e.sheet.actor .counters .counter span.sep {
margin: 0 -2px;
font-size: 12px;
Expand Down
8 changes: 2 additions & 6 deletions less/actors.less
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@
margin-bottom: 5px;

.counter {
padding: 0 6px;
padding: 0 3px;
line-height: 32px;

h4 {
Expand All @@ -280,6 +280,7 @@
height: 20px;
max-width: 20px;
margin: 0;
padding: 0;
text-align: center;
}

Expand All @@ -289,11 +290,6 @@
top: 6px;
}

&.lair input[type="text"] {
width: 32px;
max-width: 32px;
}

span.sep {
margin: 0 -2px;
font-size: 12px;
Expand Down
10 changes: 5 additions & 5 deletions module/apps/actor-flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,16 @@ export class ActorSheetFlags extends BaseEntitySheet {
*/
_updateObject(event, formData) {
const actor = this.object;
const flags = duplicate(actor.data.flags.dnd5e || {});

// Iterate over the flags which may be configured
const updateData = {};
for ( let [k, v] of Object.entries(CONFIG.DND5E.characterFlags) ) {
if ( [undefined, null, "", false].includes(formData[k]) ) delete flags[k];
else if ( (v.type === Number) && (formData[k] === 0) ) delete flags[k];
else flags[k] = formData[k];
if ( [undefined, null, "", false].includes(formData[k]) ) updateData[`-=${k}`] = null;
else if ( (v.type === Number) && (formData[k] === 0) ) updateData[`-=${k}`] = null;
else updateData[k] = formData[k];
}

// Set the new flags in bulk
actor.update({'flags.dnd5e': flags});
actor.update({'flags.dnd5e': updateData});
}
}
18 changes: 0 additions & 18 deletions module/apps/trait-selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export class ActorTraitSelector extends FormApplication {

// Get current values
let attr = getProperty(this.object.data, this.attribute);
if ( typeof attr.value === "string" ) attr.value = this.constructor._backCompat(attr.value, this.options.choices);

// Populate choices
const choices = duplicate(this.options.choices);
Expand All @@ -54,23 +53,6 @@ export class ActorTraitSelector extends FormApplication {

/* -------------------------------------------- */

/**
* Support backwards compatibility for old-style string separated traits
* @private
*/
static _backCompat(current, choices) {
if ( !current || current.length === 0 ) return [];
current = current.split(/[\s,]/).filter(t => !!t);
return current.map(val => {
for ( let [k, v] of Object.entries(choices) ) {
if ( val === v ) return k;
}
return null;
}).filter(val => !!val);
}

/* -------------------------------------------- */

/**
* Update the Actor object with new trait data processed from the form
* @private
Expand Down
2 changes: 1 addition & 1 deletion module/item/entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export class Item5e extends Item {
rng.value = null;
rng.long = null;
}
labels.range = [rng.value, C.distanceUnits[rng.units]].filterJoin(" ");
labels.range = [rng.value, rng.long ? `/ ${rng.long}` : null, C.distanceUnits[rng.units]].filterJoin(" ");

// Duration Label
let dur = item.data.duration || {};
Expand Down
2 changes: 1 addition & 1 deletion module/migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ const _migrateRemoveDeprecated = function(ent, updateData, toFlatten) {
const flat = flattenObject(ent.data);

// Deprecate entire objects
const toDeprecate = Object.entries.flat().filter(e => e[0].endsWith("_deprecated") && (e[1] === true)).map(e => {
const toDeprecate = Object.entries(flat).filter(e => e[0].endsWith("_deprecated") && (e[1] === true)).map(e => {
let parent = e[0].split(".");
parent.pop();
return parent.join(".");
Expand Down

0 comments on commit e96e57a

Please sign in to comment.