Skip to content

Commit

Permalink
use Settings.NAMESPACE instead of hardcoded string.
Browse files Browse the repository at this point in the history
  • Loading branch information
AngryBeaver committed Sep 15, 2023
1 parent 4111a7c commit c0ca2a5
Show file tree
Hide file tree
Showing 10 changed files with 19 additions and 15 deletions.
2 changes: 2 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Changelog
## 3.2.x simple or
## 3.2.3
- some reported module incompatibility fixes
## 3.2.2
- automatically fix broken tools (dnd5e)
- add flag to created or updated items
Expand Down
2 changes: 1 addition & 1 deletion module.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"title": "Beaver's Crafting Module",
"description": "A Module for not only Crafting. But also Tracking any activities, Skill challenges, Quest and Progress, Faction reputation and more",
"id": "beavers-crafting",
"version": "3.2.2",
"version": "3.2.3",
"authors": [
{
"name": "angryBeaver",
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
{
"name": "beavers-crafting",
"title": "Beaver's Crafting",
"version": "3.2.2",
"version": "3.2.3",
"description": "Crafting",
"devDir": "C:\\Users\\Riess\\AppData\\Local\\FoundryVTT\\Data\\modules",
"#devDir": "C:\\Users\\Riess\\AppData\\Local\\FoundryVTT\\Data\\modules",
"#devDir": "C:\\data\\Data\\modules",
"devDir": "D:\\Vtts\\v10\\Data\\modules",
"#devDir": "D:\\Vtts\\v11\\Data\\modules",
"main": "src/main.js",
"scripts": {
"build": "npx gulp",
Expand Down
4 changes: 2 additions & 2 deletions src/AnyOf.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ export class AnyOf {
return (
item?.type === beaversSystemInterface.configLootItemType && (
item?.system?.source === Settings.ANYOF_SUBTYPE ||
getProperty(item,`flags.beavers-crafting.subtype`) === Settings.ANYOF_SUBTYPE
getProperty(item,`flags.${Settings.NAMESPACE}.subtype`) === Settings.ANYOF_SUBTYPE
)
);
}

constructor(item) {
const flags = getProperty(item,`flags.${Settings.NAMESPACE}.anyOf`) || {};
const data = mergeObject(this.defaultData(), flags || {}, {inplace: false});
const data = mergeObject(this.defaultData(), flags, {inplace: false});
this.macro = data.macro;
this.img = item.img;
this.name = item.name;
Expand Down
2 changes: 1 addition & 1 deletion src/Crafting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ export class Crafting implements CraftingData {
}
}
};
setProperty(update, `flags.beavers-crafting.crafting.${uuid}`, this.serialize());
setProperty(update, `flags.${Settings.NAMESPACE}.crafting.${uuid}`, this.serialize());
await this.actor.update(update);
}

Expand Down
4 changes: 2 additions & 2 deletions src/Recipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ export class Recipe implements RecipeData {
// @ts-ignore
return (item?.type === beaversSystemInterface.configLootItemType && (
item?.system?.source === Settings.RECIPE_SUBTYPE ||
getProperty(item, `flags.beavers-crafting.subtype`) === Settings.RECIPE_SUBTYPE
getProperty(item, `flags.${Settings.NAMESPACE}.subtype`) === Settings.RECIPE_SUBTYPE
)
)
}

static fromItem(item): Recipe {
const flags = getProperty(item,`flags.${Settings.NAMESPACE}.recipe`) || {};
const data = mergeObject({input: {}, output: {}, required: {}}, flags || {}, {inplace: false});
const data = mergeObject({input: {}, output: {}, required: {}}, flags, {inplace: false});
return new Recipe(item.uuid, item.id, item.name, item.img, data);
}

Expand Down
2 changes: 1 addition & 1 deletion src/apps/ActorSheetTab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class ActorSheetTab {

async init() {
const label = game["i18n"].localize("beaversCrafting.actorSheet.tab");
const flag = getProperty(this.app.actor,`flags.beavers-crafting.crafting`) || {};
const flag = getProperty(this.app.actor,`flags.${Settings.NAMESPACE}.crafting`) || {};
const unsortedFolders = {};
for(const [x,y] of Object.entries(flag)){
const craftingData = (y as CraftingData);
Expand Down
4 changes: 2 additions & 2 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,10 @@ Hooks.once("beavers-system-interface.ready", async function(){

//add Subtype to create Item
Hooks.on("preCreateItem", (doc, createData, options, user) => {
if (getProperty(createData, `flags.beavers-crafting.subtype`) === 'recipe' ) {
if (getProperty(createData, `flags.${Settings.NAMESPACE}.subtype`) === 'recipe' ) {
doc.updateSource({"flags.beavers-crafting.subtype": Settings.RECIPE_SUBTYPE,"img":"icons/sundries/scrolls/scroll-worn-tan.webp"});
}
if (getProperty(createData,`flags.beavers-crafting.subtype`) === 'anyOf' ) {
if (getProperty(createData,`flags.${Settings.NAMESPACE}.subtype`) === 'anyOf' ) {
doc.updateSource({"flags.beavers-crafting.subtype": Settings.ANYOF_SUBTYPE,"img":"modules/beavers-crafting/icons/anyOf.png"});
}
});
Expand Down
4 changes: 2 additions & 2 deletions src/migration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export async function migrateRecipeSkillToTests() {
ui.notifications?.warn("Beavers Crafting |" + e);
}
}
const flag = getProperty(actor, `flags.beavers-crafting.crafting`) || {};
const flag = getProperty(actor, `flags.${Settings.NAMESPACE}.crafting`) || {};
for (const [x, y] of Object.entries(flag)) {
try {
const craftingData = (y as CraftingData);
Expand Down Expand Up @@ -120,7 +120,7 @@ export async function migrateDeprecateTools() {
ui.notifications?.warn("Beavers Crafting |" + e);
}
}
const flag = getProperty(actor, `flags.beavers-crafting.crafting`) || {};
const flag = getProperty(actor, `flags.${Settings.NAMESPACE}.crafting`) || {};
for (const [x, y] of Object.entries(flag)) {
try {
const craftingData = (y as CraftingData);
Expand Down

0 comments on commit c0ca2a5

Please sign in to comment.