Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- #137: Fix error when no config data.
  • Loading branch information
Larkinabout committed Nov 15, 2024
1 parent e0ad253 commit c72a95c
Show file tree
Hide file tree
Showing 20 changed files with 142 additions and 140 deletions.
14 changes: 7 additions & 7 deletions scripts/activation-costs.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,13 @@ function registerSettings () {
* @param {object} data
*/
export function setConfig (data = null) {
if (checkEmpty(data)) {
if (checkEmpty(CONFIG.DND5E[property])) {
resetDnd5eConfig(property)
}
return
}

const buildConfig = (keys, data) => Object.fromEntries(
keys.filter((key) => data[key].visible || data[key].visible === undefined)
.map((key) => [
Expand All @@ -66,13 +73,6 @@ export function setConfig (data = null) {
])
)

if (checkEmpty(data)) {
if (checkEmpty(CONFIG.DND5E[property])) {
resetDnd5eConfig(property)
}
return
}

const defaultConfig = foundry.utils.deepClone(CONFIG.CUSTOM_DND5E[property])
const config = buildConfig(Object.keys(data), foundry.utils.mergeObject(defaultConfig, data))
config && (CONFIG.DND5E[property] = config)
Expand Down
14 changes: 7 additions & 7 deletions scripts/actor-sizes.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ function registerSettings () {
* @param {object} data
*/
export function setConfig (data = null) {
if (checkEmpty(data)) {
if (checkEmpty(CONFIG.DND5E[property])) {
resetDnd5eConfig(property)
}
return
}

const buildConfig = (keys, data) => Object.fromEntries(
keys.filter((key) => data[key].visible || data[key].visible === undefined)
.map((key) => [
Expand All @@ -67,13 +74,6 @@ export function setConfig (data = null) {
])
)

if (checkEmpty(data)) {
if (checkEmpty(CONFIG.DND5E[property])) {
resetDnd5eConfig(property)
}
return
}

const defaultConfig = foundry.utils.deepClone(CONFIG.CUSTOM_DND5E[property])
const config = buildConfig(Object.keys(data), foundry.utils.mergeObject(defaultConfig, data))
config && (CONFIG.DND5E[property] = config)
Expand Down
14 changes: 7 additions & 7 deletions scripts/armor-calculations.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ function registerSettings () {
* @param {object} data
*/
export function setConfig (data = null) {
if (checkEmpty(data)) {
if (checkEmpty(CONFIG.DND5E[property])) {
resetDnd5eConfig(property)
}
return
}

const buildConfig = (keys, data) => Object.fromEntries(
keys.filter((key) => data[key].visible || data[key].visible === undefined)
.map((key) => [
Expand All @@ -64,13 +71,6 @@ export function setConfig (data = null) {
])
)

if (checkEmpty(data)) {
if (checkEmpty(CONFIG.DND5E[property])) {
resetDnd5eConfig(property)
}
return
}

const defaultConfig = foundry.utils.deepClone(CONFIG.CUSTOM_DND5E[property])
const config = buildConfig(Object.keys(data), foundry.utils.mergeObject(defaultConfig, data))
config && (CONFIG.DND5E[property] = config)
Expand Down
14 changes: 7 additions & 7 deletions scripts/armor-ids.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ function registerSettings () {
* @param {object} data
*/
export function setConfig (data = null) {
if (checkEmpty(data)) {
if (checkEmpty(CONFIG.DND5E[property])) {
resetDnd5eConfig(property)
}
return
}

const buildConfig = (keys, data) => Object.fromEntries(
keys.filter((key) => data[key].visible || data[key].visible === undefined)
.map((key) => [
Expand All @@ -53,13 +60,6 @@ export function setConfig (data = null) {
])
)

if (checkEmpty(data)) {
if (checkEmpty(CONFIG.DND5E[property])) {
resetDnd5eConfig(property)
}
return
}

const defaultConfig = foundry.utils.deepClone(CONFIG.CUSTOM_DND5E[property])
const config = buildConfig(Object.keys(data), foundry.utils.mergeObject(defaultConfig, data))
config && (CONFIG.DND5E[property] = config)
Expand Down
14 changes: 7 additions & 7 deletions scripts/armor-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ function registerSettings () {
* @param {object} data
*/
export function setConfig (data = null) {
if (checkEmpty(data)) {
if (checkEmpty(CONFIG.DND5E[property])) {
resetDnd5eConfig(property)
}
return
}

const buildConfig = (keys, data) => Object.fromEntries(
keys.filter((key) => data[key].visible || data[key].visible === undefined)
.map((key) => [
Expand All @@ -53,13 +60,6 @@ export function setConfig (data = null) {
])
)

if (checkEmpty(data)) {
if (checkEmpty(CONFIG.DND5E[property])) {
resetDnd5eConfig(property)
}
return
}

const defaultConfig = foundry.utils.deepClone(CONFIG.CUSTOM_DND5E[property])
const config = buildConfig(Object.keys(data), foundry.utils.mergeObject(defaultConfig, data))
config && (CONFIG.DND5E[property] = config)
Expand Down
14 changes: 7 additions & 7 deletions scripts/consumable-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ function registerSettings () {
* @param {object} data
*/
export function setConfig (data = null) {
if (checkEmpty(data)) {
if (checkEmpty(CONFIG.DND5E[property])) {
resetDnd5eConfig(property)
}
return
}

const buildConfig = (keys, data) => Object.fromEntries(
keys.filter((key) => data[key].visible || data[key].visible === undefined)
.map((key) => [
Expand All @@ -55,13 +62,6 @@ export function setConfig (data = null) {
])
)

if (checkEmpty(data)) {
if (checkEmpty(CONFIG.DND5E[property])) {
resetDnd5eConfig(property)
}
return
}

const defaultConfig = foundry.utils.deepClone(CONFIG.CUSTOM_DND5E[property])
const config = buildConfig(Object.keys(data), foundry.utils.mergeObject(defaultConfig, data))
config && (CONFIG.DND5E[property] = config)
Expand Down
14 changes: 7 additions & 7 deletions scripts/currency.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,13 @@ function registerHooks () {
* @param {object} data
*/
export function setConfig (data = null) {
if (checkEmpty(data)) {
if (checkEmpty(CONFIG.DND5E[property])) {
resetDnd5eConfig(property)
}
return
}

const buildConfig = (keys, data) => Object.fromEntries(
keys.filter((key) => data[key].visible || data[key].visible === undefined)
.map((key) => [
Expand All @@ -97,13 +104,6 @@ export function setConfig (data = null) {
])
)

if (checkEmpty(data)) {
if (checkEmpty(CONFIG.DND5E[property])) {
resetDnd5eConfig(property)
}
return
}

const defaultConfig = foundry.utils.deepClone(CONFIG.CUSTOM_DND5E[property])
const config = buildConfig(Object.keys(data), foundry.utils.mergeObject(defaultConfig, data))
config && (CONFIG.DND5E[property] = config)
Expand Down
14 changes: 7 additions & 7 deletions scripts/damage-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ function registerSettings () {
* @param {object} data
*/
export function setConfig (data = null) {
if (checkEmpty(data)) {
if (checkEmpty(CONFIG.DND5E[property])) {
resetDnd5eConfig(property)
}
return
}

const buildConfig = (keys, data) => Object.fromEntries(
keys.filter((key) => data[key].visible || data[key].visible === undefined)
.map((key) => [
Expand All @@ -66,13 +73,6 @@ export function setConfig (data = null) {
])
)

if (checkEmpty(data)) {
if (checkEmpty(CONFIG.DND5E[property])) {
resetDnd5eConfig(property)
}
return
}

const defaultConfig = foundry.utils.deepClone(CONFIG.CUSTOM_DND5E[property])
const config = buildConfig(Object.keys(data), foundry.utils.mergeObject(defaultConfig, data))
config && (CONFIG.DND5E[property] = config)
Expand Down
14 changes: 7 additions & 7 deletions scripts/feature-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@ function registerSettings () {
* @param {object} data
*/
export function setConfig (data = null) {
if (checkEmpty(data)) {
if (checkEmpty(CONFIG.DND5E[property])) {
resetDnd5eConfig(property)
}
return
}

const buildConfig = (keys, data) => Object.fromEntries(
keys.filter((key) => data[key].visible || data[key].visible === undefined)
.map((key) => [
Expand All @@ -55,13 +62,6 @@ export function setConfig (data = null) {
])
)

if (checkEmpty(data)) {
if (checkEmpty(CONFIG.DND5E[property])) {
resetDnd5eConfig(property)
}
return
}

const defaultConfig = foundry.utils.deepClone(CONFIG.CUSTOM_DND5E[property])
const config = buildConfig(Object.keys(data), foundry.utils.mergeObject(defaultConfig, data))
config && (CONFIG.DND5E[property] = config)
Expand Down
14 changes: 7 additions & 7 deletions scripts/item-action-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ function registerSettings () {
* @param {object} data
*/
export function setConfig (data = null) {
if (checkEmpty(data)) {
if (checkEmpty(CONFIG.DND5E[property])) {
resetDnd5eConfig(property)
}
return
}

const buildConfig = (keys, data) => Object.fromEntries(
keys.filter((key) => data[key].visible || data[key].visible === undefined)
.map((key) => [
Expand All @@ -54,13 +61,6 @@ export function setConfig (data = null) {
])
)

if (checkEmpty(data)) {
if (checkEmpty(CONFIG.DND5E[property])) {
resetDnd5eConfig(property)
}
return
}

const defaultConfig = foundry.utils.deepClone(CONFIG.CUSTOM_DND5E[property])
const config = buildConfig(Object.keys(data), foundry.utils.mergeObject(defaultConfig, data))
config && (CONFIG.DND5E[property] = config)
Expand Down
14 changes: 7 additions & 7 deletions scripts/item-activation-cost-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ function registerSettings () {
* @param {object} data
*/
export function setConfig (data = null) {
if (checkEmpty(data)) {
if (checkEmpty(CONFIG.DND5E[property])) {
resetDnd5eConfig(property)
}
return
}

const buildConfig = (keys, data) => Object.fromEntries(
keys.filter((key) => data[key].visible || data[key].visible === undefined)
.map((key) => [
Expand All @@ -54,13 +61,6 @@ export function setConfig (data = null) {
])
)

if (checkEmpty(data)) {
if (checkEmpty(CONFIG.DND5E[property])) {
resetDnd5eConfig(property)
}
return
}

const defaultConfig = foundry.utils.deepClone(CONFIG.CUSTOM_DND5E[property])
const config = buildConfig(Object.keys(data), foundry.utils.mergeObject(defaultConfig, data))
config && (CONFIG.DND5E[property] = config)
Expand Down
14 changes: 7 additions & 7 deletions scripts/item-properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ function getSettingDefault () {
* @param {object} data
*/
export function setConfig (data = null) {
if (checkEmpty(data)) {
if (checkEmpty(CONFIG.DND5E.itemProperties)) {
resetDnd5eConfig('itemProperties')
}
return
}

const buildConfig = (data) => Object.fromEntries(
Object.entries(data)
.filter(([_, value]) => value.visible || value.visible === undefined)
Expand Down Expand Up @@ -125,13 +132,6 @@ export function setConfig (data = null) {
? foundry.utils.deepClone(CONFIG.CUSTOM_DND5E.validProperties)
: validProperties

if (checkEmpty(data)) {
if (checkEmpty(CONFIG.DND5E.itemProperties)) {
resetDnd5eConfig('itemProperties')
}
return
}

const config = buildConfig(data)
config && (CONFIG.DND5E.itemProperties = config)
}
14 changes: 7 additions & 7 deletions scripts/item-rarity.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ function registerHooks () {
* @param {object} data
*/
export function setConfig (data = null) {
if (checkEmpty(data)) {
if (checkEmpty(CONFIG.DND5E[property])) {
resetDnd5eConfig(property)
}
return
}

const buildConfig = (keys, data) => Object.fromEntries(
keys.filter((key) => data[key].visible || data[key].visible === undefined)
.map((key) => [
Expand All @@ -59,13 +66,6 @@ export function setConfig (data = null) {
])
)

if (checkEmpty(data)) {
if (checkEmpty(CONFIG.DND5E[property])) {
resetDnd5eConfig(property)
}
return
}

const defaultConfig = foundry.utils.deepClone(CONFIG.CUSTOM_DND5E[property])
const config = buildConfig(Object.keys(data), foundry.utils.mergeObject(defaultConfig, data))
config && (CONFIG.DND5E[property] = config)
Expand Down
14 changes: 7 additions & 7 deletions scripts/languages.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,13 @@ function registerSettings () {
* @param {object} data
*/
export function setConfig (data = null) {
if (checkEmpty(data)) {
if (checkEmpty(CONFIG.DND5E[property])) {
resetDnd5eConfig(property)
}
return
}

const buildConfig = (keys, data) => Object.fromEntries(
keys.filter((key) => data[key].visible || data[key].visible === undefined)
.map((key) => [
Expand All @@ -54,13 +61,6 @@ export function setConfig (data = null) {
])
)

if (checkEmpty(data)) {
if (checkEmpty(CONFIG.DND5E[property])) {
resetDnd5eConfig(property)
}
return
}

const defaultConfig = foundry.utils.deepClone(CONFIG.CUSTOM_DND5E[property])
const config = buildConfig(Object.keys(data), foundry.utils.mergeObject(defaultConfig, data))
config && (CONFIG.DND5E[property] = config)
Expand Down
Loading

0 comments on commit c72a95c

Please sign in to comment.