Skip to content

Commit

Permalink
fix: 🐛 Critical Injuries dragged on to sheet
Browse files Browse the repository at this point in the history
  • Loading branch information
aMediocreDad committed Aug 15, 2024
1 parent 861e660 commit b315c2a
Show file tree
Hide file tree
Showing 22 changed files with 32 additions and 32 deletions.
5 changes: 5 additions & 0 deletions .changeset/cyan-pots-drive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"forbidden-lands": patch
---

Fixed an issue where critical injuries dragged onto character sheets would not be created
17 changes: 6 additions & 11 deletions src/actor/actor-document.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,12 @@ export class ForbiddenLandsActor extends Actor {
for await (const entity of newData) {
if (!entity.system) continue;

entity.system = await Object.entries(entity.system).reduce(
async (obj, [key, value]) => {
if (typeof value === "string" && value.match(inlineRoll)) {
const result = await createRoll(inlineRoll.exec(value));
value = value.replace(inlineRoll, result);
}
const resolved = await obj;
return { ...resolved, [key]: value };
},
{},
);
for await (const [key, value] of Object.entries(entity.system)) {
if (typeof value === "string" && value.match(inlineRoll)) {
const result = await createRoll(inlineRoll.exec(value));
entity.system[key] = value.replace(inlineRoll, result);
}
}

// We only want to touch flags of items that are considered "gear"
if (!CONFIG.fbl.carriedItemTypes.includes(entity.type)) continue;
Expand Down
2 changes: 1 addition & 1 deletion src/actor/character/character-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class ForbiddenLandsCharacterSheet extends ForbiddenLandsActorSheet {
"forbidden-lands",
"useHealthAndResolve",
);
return mergeObject(super.defaultOptions, {
return foundry.utils.mergeObject(super.defaultOptions, {
classes: ["forbidden-lands", "sheet", "actor"],
width: 660,
height: useHealthAndResolve ? 790 : 740,
Expand Down
2 changes: 1 addition & 1 deletion src/actor/monster/monster-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import localizeString from "@utils/localize-string.js";
//import { ActorSheetConfig } from "@utils/sheet-config.js";
export class ForbiddenLandsMonsterSheet extends ForbiddenLandsActorSheet {
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
return foundry.utils.mergeObject(super.defaultOptions, {
...super.defaultOptions,
classes: ["forbidden-lands", "sheet", "actor"],
template:
Expand Down
2 changes: 1 addition & 1 deletion src/actor/party/party-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class ForbiddenLandsPartySheet extends ActorSheet {
dragSelector: ".party-member",
dropSelector: ".party-member-list",
});
return mergeObject(super.defaultOptions, {
return foundry.utils.mergeObject(super.defaultOptions, {
classes: ["forbidden-lands", "sheet", "actor", "party"],
template: "systems/forbidden-lands/templates/actor/party/party-sheet.hbs",
width: window.innerWidth * 0.05 + 650,
Expand Down
2 changes: 1 addition & 1 deletion src/actor/stronghold/stronghold-sheet.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ForbiddenLandsActorSheet } from "../actor-sheet.js";
export class ForbiddenLandsStrongholdSheet extends ForbiddenLandsActorSheet {
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
return foundry.utils.mergeObject(super.defaultOptions, {
...super.defaultOptions,
classes: ["forbidden-lands", "sheet", "actor"],
template:
Expand Down
2 changes: 1 addition & 1 deletion src/components/character-generator/character-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export class ForbiddenLandsCharacterGenerator extends Application {
}

static get defaultOptions() {
return mergeObject(super.defaultOptions, {
return foundry.utils.mergeObject(super.defaultOptions, {
classes: ["forbidden-lands", "sheet", "actor"],
template:
"systems/forbidden-lands/templates/components/character-generator/generator-sheet.hbs",
Expand Down
2 changes: 1 addition & 1 deletion src/components/roll-engine/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export class FBLRollHandler extends FormApplication {
* Foundry override intended to customize the window render.
*/
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
return foundry.utils.mergeObject(super.defaultOptions, {
classes: ["forbidden-lands"],
width: "500",
height: "auto",
Expand Down
2 changes: 1 addition & 1 deletion src/item/armor/armor-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ForbiddenLandsItemSheet } from "@item/item-sheet";

export class ForbiddenLandsArmorSheet extends ForbiddenLandsItemSheet {
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
return foundry.utils.mergeObject(super.defaultOptions, {
...super.defaultOptions,
template: "systems/forbidden-lands/templates/item/armor/armor-sheet.hbs",
tabs: [
Expand Down
2 changes: 1 addition & 1 deletion src/item/building/building-sheet.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ForbiddenLandsItemSheet } from "@item/item-sheet";
export class ForbiddenLandsBuildingSheet extends ForbiddenLandsItemSheet {
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
return foundry.utils.mergeObject(super.defaultOptions, {
...super.defaultOptions,
template:
"systems/forbidden-lands/templates/item/building/building-sheet.hbs",
Expand Down
2 changes: 1 addition & 1 deletion src/item/critical-injury/critical-injury-sheet.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ForbiddenLandsItemSheet } from "@item/item-sheet";
export class ForbiddenLandsCriticalInjurySheet extends ForbiddenLandsItemSheet {
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
return foundry.utils.mergeObject(super.defaultOptions, {
...super.defaultOptions,
template:
"systems/forbidden-lands/templates/item/critical-injury/critical-injury-sheet.hbs",
Expand Down
2 changes: 1 addition & 1 deletion src/item/gear/gear-sheet.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ForbiddenLandsItemSheet } from "@item/item-sheet";
export class ForbiddenLandsGearSheet extends ForbiddenLandsItemSheet {
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
return foundry.utils.mergeObject(super.defaultOptions, {
...super.defaultOptions,
template: "systems/forbidden-lands/templates/item/gear/gear-sheet.hbs",
tabs: [
Expand Down
2 changes: 1 addition & 1 deletion src/item/hireling/hireling-sheet.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ForbiddenLandsItemSheet } from "@item/item-sheet";
export class ForbiddenLandsHirelingSheet extends ForbiddenLandsItemSheet {
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
return foundry.utils.mergeObject(super.defaultOptions, {
...super.defaultOptions,
template:
"systems/forbidden-lands/templates/item/hireling/hireling-sheet.hbs",
Expand Down
2 changes: 1 addition & 1 deletion src/item/item-document.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export class ForbiddenLandsItem extends Item {
}
const message = await ChatMessage.create(chatData);
if (itemData.isCriticalInjury) {
const content = $(message.data.content);
const content = $(message.content);
const limit = content.find("[data-type='limit']").text().trim();
const healingTime = content.find("[data-type='healtime']").text().trim();
itemData.system.limit = limit;
Expand Down
2 changes: 1 addition & 1 deletion src/item/item-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class ForbiddenLandsItemSheet extends ItemSheet {
}

static get defaultOptions() {
return mergeObject(super.defaultOptions, {
return foundry.utils.mergeObject(super.defaultOptions, {
...super.defaultOptions,
classes: ["forbidden-lands", "sheet", "item"],
width: window.innerWidth * 0.08 + 350,
Expand Down
2 changes: 1 addition & 1 deletion src/item/monster-attack/monster-attack-sheet.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ForbiddenLandsItemSheet } from "@item/item-sheet";
export class ForbiddenLandsMonsterAttackSheet extends ForbiddenLandsItemSheet {
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
return foundry.utils.mergeObject(super.defaultOptions, {
...super.defaultOptions,
template:
"systems/forbidden-lands/templates/item/monster-attack/monster-attack-sheet.hbs",
Expand Down
2 changes: 1 addition & 1 deletion src/item/raw-material/raw-material-sheet.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ForbiddenLandsItemSheet } from "@item/item-sheet";
export class ForbiddenLandsRawMaterialSheet extends ForbiddenLandsItemSheet {
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
return foundry.utils.mergeObject(super.defaultOptions, {
...super.defaultOptions,
template:
"systems/forbidden-lands/templates/item/raw-material/raw-material-sheet.hbs",
Expand Down
2 changes: 1 addition & 1 deletion src/item/spell/spell-sheet.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ForbiddenLandsItemSheet } from "@item/item-sheet";
export class ForbiddenLandsSpellSheet extends ForbiddenLandsItemSheet {
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
return foundry.utils.mergeObject(super.defaultOptions, {
...super.defaultOptions,
template: "systems/forbidden-lands/templates/item/spell/spell-sheet.hbs",
});
Expand Down
2 changes: 1 addition & 1 deletion src/item/talent/talent-sheet.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ForbiddenLandsItemSheet } from "@item/item-sheet";
export class ForbiddenLandsTalentSheet extends ForbiddenLandsItemSheet {
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
return foundry.utils.mergeObject(super.defaultOptions, {
...super.defaultOptions,
template:
"systems/forbidden-lands/templates/item/talent/talent-sheet.hbs",
Expand Down
2 changes: 1 addition & 1 deletion src/item/weapon/weapon-sheet.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ForbiddenLandsItemSheet } from "@item/item-sheet";
export class ForbiddenLandsWeaponSheet extends ForbiddenLandsItemSheet {
static get defaultOptions() {
return mergeObject(super.defaultOptions, {
return foundry.utils.mergeObject(super.defaultOptions, {
...super.defaultOptions,
template:
"systems/forbidden-lands/templates/item/weapon/weapon-sheet.hbs",
Expand Down
2 changes: 1 addition & 1 deletion src/system/core/migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ const migrateSceneData = (scene) => {
const updates = new Map(update[embeddedName].map((u) => [u._id, u]));
for (const embedded of actorData[embeddedName]) {
const toUpdate = updates.get(embedded._id);
if (toUpdate) mergeObject(embedded, toUpdate);
if (toUpdate) foundry.utils.mergeObject(embedded, toUpdate);
}
delete update[embeddedName];
}
Expand Down
4 changes: 2 additions & 2 deletions src/system/core/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class TableConfigMenu extends FormApplication {
});

static get defaultOptions() {
return mergeObject(super.defaultOptions, {
return foundry.utils.mergeObject(super.defaultOptions, {
template:
"systems/forbidden-lands/templates/components/tables-config.hbs",
classes: ["tables-config"],
Expand Down Expand Up @@ -127,7 +127,7 @@ export class SheetConfigMenu extends FormApplication {
});

static get defaultOptions() {
return mergeObject(super.defaultOptions, {
return foundry.utils.mergeObject(super.defaultOptions, {
template: "systems/forbidden-lands/templates/components/sheet-config.hbs",
classes: ["sheet-config"],
title: "CONFIG.SHEET_CONFIG.TITLE",
Expand Down

0 comments on commit b315c2a

Please sign in to comment.