From 67633fb83806b3485157788fe5bc66d3939162fa Mon Sep 17 00:00:00 2001 From: jesuisfrog Date: Tue, 6 Aug 2024 01:36:58 -0700 Subject: [PATCH 1/5] Automate increase and decrease to item repair --- packs/equipment/crafters-eyepiece.json | 19 +++++++++++++++++++ src/module/actor/character/data.ts | 3 ++- src/module/actor/character/document.ts | 2 +- .../migrations/722-crafting-system-data.ts | 6 +++++- .../system/action-macros/crafting/repair.ts | 7 ++++--- 5 files changed, 31 insertions(+), 6 deletions(-) diff --git a/packs/equipment/crafters-eyepiece.json b/packs/equipment/crafters-eyepiece.json index 0cd61060a39..963add362fe 100644 --- a/packs/equipment/crafters-eyepiece.json +++ b/packs/equipment/crafters-eyepiece.json @@ -40,6 +40,25 @@ "selector": "crafting", "type": "item", "value": 1 + }, + { + "key": "ActiveEffectLike", + "mode": "add", + "path": "system.crafting.repairValue", + "value": 5 + }, + { + "key": "Note", + "text": "When you Repair an item, increase the Hit Points restored to 10 + 10 per proficiency rank on a success or 15 + 15 per proficiency rank on a critical success.", + "title": "Crafter's Eyepiece:", + "selector": "crafting-check", + "outcome": [ + "success", + "criticalSuccess" + ], + "predicate": [ + "action:repair" + ] } ], "size": "med", diff --git a/src/module/actor/character/data.ts b/src/module/actor/character/data.ts index c8709dccba0..19832c063b6 100644 --- a/src/module/actor/character/data.ts +++ b/src/module/actor/character/data.ts @@ -404,7 +404,8 @@ interface VersatileWeaponOption { interface CharacterCraftingData { formulas: CraftingFormulaData[]; entries: Record>; -} + repairValue: 5; +} interface CharacterResources extends CreatureResources { /** The current and maximum number of hero points */ diff --git a/src/module/actor/character/document.ts b/src/module/actor/character/document.ts index 019f5bdfac0..94c3f15b2ba 100644 --- a/src/module/actor/character/document.ts +++ b/src/module/actor/character/document.ts @@ -456,7 +456,7 @@ class CharacterPF2e { callback: async (result) => { // react to check result by posting a chat message with appropriate follow-up options const { actor } = result; - if (item && result.message instanceof ChatMessagePF2e && actor.isOfType("creature")) { + if (item && result.message instanceof ChatMessagePF2e && actor.isOfType("character")) { const messageSource = result.message.toObject(); const flavor = await (async () => { const proficiencyRank = actor.skills.crafting.rank ?? 0; + const repairValue = actor.system.crafting.repairValue if ("criticalSuccess" === result.outcome) { const label = "PF2E.Actions.Repair.Labels.RestoreItemHitPoints"; - const restored = String(10 + proficiencyRank * 10); + const restored = String((repairValue + 5) + proficiencyRank * (repairValue + 5)); return renderRepairResult(item, "restore", label, restored); } else if ("success" === result.outcome) { const label = "PF2E.Actions.Repair.Labels.RestoreItemHitPoints"; - const restored = String(5 + proficiencyRank * 5); + const restored = String(repairValue + proficiencyRank * repairValue); return renderRepairResult(item, "restore", label, restored); } else if ("criticalFailure" === result.outcome) { const label = "PF2E.Actions.Repair.Labels.RollItemDamage"; From 6ca238402d53988ec33fa4d31c88af3ecb30da3b Mon Sep 17 00:00:00 2001 From: jesuisfrog Date: Tue, 6 Aug 2024 12:50:53 -0700 Subject: [PATCH 2/5] Update flavor text handling for Crafter's Eyepiece. Fix Lint. Remove repairValue mention in an old migration file. --- .../equipment/crafters-eyepiece-greater.json | 19 +++++++++++++++++++ packs/equipment/crafters-eyepiece.json | 4 ++-- src/module/actor/character/data.ts | 2 +- .../migrations/722-crafting-system-data.ts | 6 +----- .../system/action-macros/crafting/repair.ts | 4 ++-- static/lang/re-en.json | 3 +++ 6 files changed, 28 insertions(+), 10 deletions(-) diff --git a/packs/equipment/crafters-eyepiece-greater.json b/packs/equipment/crafters-eyepiece-greater.json index e7fab92adf3..e5f4556694b 100644 --- a/packs/equipment/crafters-eyepiece-greater.json +++ b/packs/equipment/crafters-eyepiece-greater.json @@ -40,6 +40,25 @@ "selector": "crafting", "type": "item", "value": 2 + }, + { + "key": "ActiveEffectLike", + "mode": "add", + "path": "system.crafting.repairValue", + "value": 5 + }, + { + "key": "Note", + "text": "PF2E.SpecificRule.CraftersEyepiece.Note", + "title": "{item|name}", + "selector": "crafting-check", + "outcome": [ + "success", + "criticalSuccess" + ], + "predicate": [ + "action:repair" + ] } ], "size": "med", diff --git a/packs/equipment/crafters-eyepiece.json b/packs/equipment/crafters-eyepiece.json index 963add362fe..227e16c4c5d 100644 --- a/packs/equipment/crafters-eyepiece.json +++ b/packs/equipment/crafters-eyepiece.json @@ -49,8 +49,8 @@ }, { "key": "Note", - "text": "When you Repair an item, increase the Hit Points restored to 10 + 10 per proficiency rank on a success or 15 + 15 per proficiency rank on a critical success.", - "title": "Crafter's Eyepiece:", + "text": "PF2E.SpecificRule.CraftersEyepiece.Note", + "title": "{item|name}", "selector": "crafting-check", "outcome": [ "success", diff --git a/src/module/actor/character/data.ts b/src/module/actor/character/data.ts index 19832c063b6..4f5550d7ac6 100644 --- a/src/module/actor/character/data.ts +++ b/src/module/actor/character/data.ts @@ -405,7 +405,7 @@ interface CharacterCraftingData { formulas: CraftingFormulaData[]; entries: Record>; repairValue: 5; -} +} interface CharacterResources extends CreatureResources { /** The current and maximum number of hero points */ diff --git a/src/module/migration/migrations/722-crafting-system-data.ts b/src/module/migration/migrations/722-crafting-system-data.ts index d95ee085fd9..f6d147e8dd4 100644 --- a/src/module/migration/migrations/722-crafting-system-data.ts +++ b/src/module/migration/migrations/722-crafting-system-data.ts @@ -10,7 +10,7 @@ export class Migration722CraftingSystemData extends MigrationBase { if (source.type !== "character") return; if (!R.isPlainObject(source.system.crafting)) { - const filledCrafting = { entries: {}, formulas: [] , repairValue: 5}; + const filledCrafting = { entries: {}, formulas: [], repairValue: 5 }; source.system.crafting = filledCrafting; } @@ -22,9 +22,5 @@ export class Migration722CraftingSystemData extends MigrationBase { if (!Array.isArray(crafting.formulas)) { crafting.formulas = []; } - - if(!R.isNumber(crafting.repairValue)){ - crafting.repairValue = 5; - } } } diff --git a/src/module/system/action-macros/crafting/repair.ts b/src/module/system/action-macros/crafting/repair.ts index 21b9a43fc8a..786fa23450f 100644 --- a/src/module/system/action-macros/crafting/repair.ts +++ b/src/module/system/action-macros/crafting/repair.ts @@ -72,10 +72,10 @@ async function repair(options: RepairActionOptions): Promise { const messageSource = result.message.toObject(); const flavor = await (async () => { const proficiencyRank = actor.skills.crafting.rank ?? 0; - const repairValue = actor.system.crafting.repairValue + const repairValue = actor.system.crafting.repairValue; if ("criticalSuccess" === result.outcome) { const label = "PF2E.Actions.Repair.Labels.RestoreItemHitPoints"; - const restored = String((repairValue + 5) + proficiencyRank * (repairValue + 5)); + const restored = String(repairValue + 5 + proficiencyRank * (repairValue + 5)); return renderRepairResult(item, "restore", label, restored); } else if ("success" === result.outcome) { const label = "PF2E.Actions.Repair.Labels.RestoreItemHitPoints"; diff --git a/static/lang/re-en.json b/static/lang/re-en.json index cda0cacfa7d..e5c510387ae 100644 --- a/static/lang/re-en.json +++ b/static/lang/re-en.json @@ -2320,6 +2320,9 @@ "Prone": "Prone", "Standard": "Standard" }, + "CraftersEyepiece":{ + "Note":"When you Repair an item, increase the Hit Points restored to 10 + 10 per proficiency rank on a success or 15 + 15 per proficiency rank on a critical success." + }, "CriticalDeck": { "Effect": { "Label": "Critical Effect" From 3b77dda6999f96e1066c7e73ce5b8c92375da5cd Mon Sep 17 00:00:00 2001 From: jesuisfrog Date: Tue, 6 Aug 2024 01:36:58 -0700 Subject: [PATCH 3/5] Automate increase and decrease to item repair --- packs/equipment/crafters-eyepiece.json | 19 +++++++++++++++++++ src/module/actor/character/data.ts | 3 ++- src/module/actor/character/document.ts | 2 +- .../migrations/722-crafting-system-data.ts | 6 +++++- .../system/action-macros/crafting/repair.ts | 7 ++++--- 5 files changed, 31 insertions(+), 6 deletions(-) diff --git a/packs/equipment/crafters-eyepiece.json b/packs/equipment/crafters-eyepiece.json index 0cd61060a39..963add362fe 100644 --- a/packs/equipment/crafters-eyepiece.json +++ b/packs/equipment/crafters-eyepiece.json @@ -40,6 +40,25 @@ "selector": "crafting", "type": "item", "value": 1 + }, + { + "key": "ActiveEffectLike", + "mode": "add", + "path": "system.crafting.repairValue", + "value": 5 + }, + { + "key": "Note", + "text": "When you Repair an item, increase the Hit Points restored to 10 + 10 per proficiency rank on a success or 15 + 15 per proficiency rank on a critical success.", + "title": "Crafter's Eyepiece:", + "selector": "crafting-check", + "outcome": [ + "success", + "criticalSuccess" + ], + "predicate": [ + "action:repair" + ] } ], "size": "med", diff --git a/src/module/actor/character/data.ts b/src/module/actor/character/data.ts index c8709dccba0..19832c063b6 100644 --- a/src/module/actor/character/data.ts +++ b/src/module/actor/character/data.ts @@ -404,7 +404,8 @@ interface VersatileWeaponOption { interface CharacterCraftingData { formulas: CraftingFormulaData[]; entries: Record>; -} + repairValue: 5; +} interface CharacterResources extends CreatureResources { /** The current and maximum number of hero points */ diff --git a/src/module/actor/character/document.ts b/src/module/actor/character/document.ts index 019f5bdfac0..94c3f15b2ba 100644 --- a/src/module/actor/character/document.ts +++ b/src/module/actor/character/document.ts @@ -456,7 +456,7 @@ class CharacterPF2e { callback: async (result) => { // react to check result by posting a chat message with appropriate follow-up options const { actor } = result; - if (item && result.message instanceof ChatMessagePF2e && actor.isOfType("creature")) { + if (item && result.message instanceof ChatMessagePF2e && actor.isOfType("character")) { const messageSource = result.message.toObject(); const flavor = await (async () => { const proficiencyRank = actor.skills.crafting.rank ?? 0; + const repairValue = actor.system.crafting.repairValue if ("criticalSuccess" === result.outcome) { const label = "PF2E.Actions.Repair.Labels.RestoreItemHitPoints"; - const restored = String(10 + proficiencyRank * 10); + const restored = String((repairValue + 5) + proficiencyRank * (repairValue + 5)); return renderRepairResult(item, "restore", label, restored); } else if ("success" === result.outcome) { const label = "PF2E.Actions.Repair.Labels.RestoreItemHitPoints"; - const restored = String(5 + proficiencyRank * 5); + const restored = String(repairValue + proficiencyRank * repairValue); return renderRepairResult(item, "restore", label, restored); } else if ("criticalFailure" === result.outcome) { const label = "PF2E.Actions.Repair.Labels.RollItemDamage"; From bb1299b04840698d8fd56ec0d65967d25f415346 Mon Sep 17 00:00:00 2001 From: jesuisfrog Date: Tue, 6 Aug 2024 12:50:53 -0700 Subject: [PATCH 4/5] Update flavor text handling for Crafter's Eyepiece. Fix Lint. Remove repairValue mention in an old migration file. --- .../equipment/crafters-eyepiece-greater.json | 19 +++++++++++++++++++ packs/equipment/crafters-eyepiece.json | 4 ++-- src/module/actor/character/data.ts | 2 +- .../migrations/722-crafting-system-data.ts | 6 +----- .../system/action-macros/crafting/repair.ts | 4 ++-- static/lang/re-en.json | 3 +++ 6 files changed, 28 insertions(+), 10 deletions(-) diff --git a/packs/equipment/crafters-eyepiece-greater.json b/packs/equipment/crafters-eyepiece-greater.json index e7fab92adf3..e5f4556694b 100644 --- a/packs/equipment/crafters-eyepiece-greater.json +++ b/packs/equipment/crafters-eyepiece-greater.json @@ -40,6 +40,25 @@ "selector": "crafting", "type": "item", "value": 2 + }, + { + "key": "ActiveEffectLike", + "mode": "add", + "path": "system.crafting.repairValue", + "value": 5 + }, + { + "key": "Note", + "text": "PF2E.SpecificRule.CraftersEyepiece.Note", + "title": "{item|name}", + "selector": "crafting-check", + "outcome": [ + "success", + "criticalSuccess" + ], + "predicate": [ + "action:repair" + ] } ], "size": "med", diff --git a/packs/equipment/crafters-eyepiece.json b/packs/equipment/crafters-eyepiece.json index 963add362fe..227e16c4c5d 100644 --- a/packs/equipment/crafters-eyepiece.json +++ b/packs/equipment/crafters-eyepiece.json @@ -49,8 +49,8 @@ }, { "key": "Note", - "text": "When you Repair an item, increase the Hit Points restored to 10 + 10 per proficiency rank on a success or 15 + 15 per proficiency rank on a critical success.", - "title": "Crafter's Eyepiece:", + "text": "PF2E.SpecificRule.CraftersEyepiece.Note", + "title": "{item|name}", "selector": "crafting-check", "outcome": [ "success", diff --git a/src/module/actor/character/data.ts b/src/module/actor/character/data.ts index 19832c063b6..4f5550d7ac6 100644 --- a/src/module/actor/character/data.ts +++ b/src/module/actor/character/data.ts @@ -405,7 +405,7 @@ interface CharacterCraftingData { formulas: CraftingFormulaData[]; entries: Record>; repairValue: 5; -} +} interface CharacterResources extends CreatureResources { /** The current and maximum number of hero points */ diff --git a/src/module/migration/migrations/722-crafting-system-data.ts b/src/module/migration/migrations/722-crafting-system-data.ts index d95ee085fd9..f6d147e8dd4 100644 --- a/src/module/migration/migrations/722-crafting-system-data.ts +++ b/src/module/migration/migrations/722-crafting-system-data.ts @@ -10,7 +10,7 @@ export class Migration722CraftingSystemData extends MigrationBase { if (source.type !== "character") return; if (!R.isPlainObject(source.system.crafting)) { - const filledCrafting = { entries: {}, formulas: [] , repairValue: 5}; + const filledCrafting = { entries: {}, formulas: [], repairValue: 5 }; source.system.crafting = filledCrafting; } @@ -22,9 +22,5 @@ export class Migration722CraftingSystemData extends MigrationBase { if (!Array.isArray(crafting.formulas)) { crafting.formulas = []; } - - if(!R.isNumber(crafting.repairValue)){ - crafting.repairValue = 5; - } } } diff --git a/src/module/system/action-macros/crafting/repair.ts b/src/module/system/action-macros/crafting/repair.ts index 21b9a43fc8a..786fa23450f 100644 --- a/src/module/system/action-macros/crafting/repair.ts +++ b/src/module/system/action-macros/crafting/repair.ts @@ -72,10 +72,10 @@ async function repair(options: RepairActionOptions): Promise { const messageSource = result.message.toObject(); const flavor = await (async () => { const proficiencyRank = actor.skills.crafting.rank ?? 0; - const repairValue = actor.system.crafting.repairValue + const repairValue = actor.system.crafting.repairValue; if ("criticalSuccess" === result.outcome) { const label = "PF2E.Actions.Repair.Labels.RestoreItemHitPoints"; - const restored = String((repairValue + 5) + proficiencyRank * (repairValue + 5)); + const restored = String(repairValue + 5 + proficiencyRank * (repairValue + 5)); return renderRepairResult(item, "restore", label, restored); } else if ("success" === result.outcome) { const label = "PF2E.Actions.Repair.Labels.RestoreItemHitPoints"; diff --git a/static/lang/re-en.json b/static/lang/re-en.json index c5599ef8d09..a8ff2704949 100644 --- a/static/lang/re-en.json +++ b/static/lang/re-en.json @@ -2320,6 +2320,9 @@ "Prone": "Prone", "Standard": "Standard" }, + "CraftersEyepiece":{ + "Note":"When you Repair an item, increase the Hit Points restored to 10 + 10 per proficiency rank on a success or 15 + 15 per proficiency rank on a critical success." + }, "CriticalDeck": { "Effect": { "Label": "Critical Effect" From 5700ee63798eaaadb283675f070e9af3b3b959a5 Mon Sep 17 00:00:00 2001 From: jesuisfrog Date: Wed, 7 Aug 2024 13:56:24 -0700 Subject: [PATCH 5/5] Remove change that was not needed --- src/module/migration/migrations/722-crafting-system-data.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/module/migration/migrations/722-crafting-system-data.ts b/src/module/migration/migrations/722-crafting-system-data.ts index f6d147e8dd4..c8990d17dd1 100644 --- a/src/module/migration/migrations/722-crafting-system-data.ts +++ b/src/module/migration/migrations/722-crafting-system-data.ts @@ -10,7 +10,7 @@ export class Migration722CraftingSystemData extends MigrationBase { if (source.type !== "character") return; if (!R.isPlainObject(source.system.crafting)) { - const filledCrafting = { entries: {}, formulas: [], repairValue: 5 }; + const filledCrafting = { entries: {}, formulas: [] }; source.system.crafting = filledCrafting; }