Skip to content

Commit

Permalink
Fix for removeCondition errors when a condition does not exist in sta…
Browse files Browse the repository at this point in the history
…tusEffects #656
  • Loading branch information
bithir committed Jun 21, 2024
1 parent 0a38270 commit a356d8d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
4 changes: 4 additions & 0 deletions Release_Notes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
Version 5.1

* Fix for #656 removeCondition errors when a condition does not exist in statusEffects

Version 5.0
* Updated for Foundry vtt version 12

Expand Down
7 changes: 4 additions & 3 deletions script/common/actor.js
Original file line number Diff line number Diff line change
Expand Up @@ -773,14 +773,15 @@ export class SymbaroumActor extends Actor {

async addCondition(effect, flagData) {
if (typeof effect === "string") {
effect = foundry.utils.duplicate(CONFIG.statusEffects.find((e) => e.id == effect));
effect = CONFIG.statusEffects.find((e) => e.id == effect);
}
if (!effect) return "No Effect Found";
if (!effect.id) return "Conditions require an id field";

let existing = this.hasCondition(effect.id);

if (!existing) {
if (!existing) {
effect = foundry.utils.duplicate(effect);
effect.label = game.i18n.localize(effect.label)?.replace(/(^\w{1})|(\s+\w{1})/g, (letter) => letter.toUpperCase());
effect.name = game.i18n.localize(effect.name)?.replace(/(^\w{1})|(\s+\w{1})/g, (letter) => letter.toUpperCase());
if (foundry.utils.isNewerVersion('11', game.version) ) {
Expand All @@ -796,7 +797,7 @@ export class SymbaroumActor extends Actor {
}

async removeCondition(effect) {
if (typeof effect === "string") effect = foundry.utils.duplicate(CONFIG.statusEffects.find((e) => e.id == effect));
if (typeof effect === "string") effect = CONFIG.statusEffects.find((e) => e.id == effect);
if (!effect) return "No Effect Found";
if (!effect.id) return "Conditions require an id field";
let existing = this.hasCondition(effect.id);
Expand Down
2 changes: 1 addition & 1 deletion system.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "symbaroum",
"title": "Symbaroum",
"description": "Twilight falls. Davokar darkens.",
"version": "5.0.0",
"version": "5.1.0",
"compatibility": {
"minimum": 12,
"verified": 12,
Expand Down

0 comments on commit a356d8d

Please sign in to comment.