Skip to content

Commit

Permalink
feat(active_effects): improve active effect implementation
Browse files Browse the repository at this point in the history
* correct bug where modifiers could not be directly created on items anymore
* remove unused code
* fix encumbrance AE when multiple items are on an actor

#1215
  • Loading branch information
wrycu committed Jun 6, 2023
1 parent 9faa8ac commit b282533
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 360 deletions.
9 changes: 3 additions & 6 deletions modules/actors/actor-ffg.js
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,6 @@ export class ActorFFG extends Actor {
Object.keys(CONFIG.FFG.characteristics).forEach((key) => {
let total = 0;
total += data.attributes[key].value;
total += ModifierHelpers.getCalculatedValueFromItems(items, key, "Characteristic");
data.characteristics[key].value = total > 7 ? 7 : total;
});

Expand Down Expand Up @@ -519,7 +518,6 @@ export class ActorFFG extends Actor {
}

total += data.attributes[key].value;
total += ModifierHelpers.getCalculatedValueFromItems(items, key, "Stat");

if (key === "Soak") {
data.stats[k].value = total;
Expand All @@ -538,13 +536,13 @@ export class ActorFFG extends Actor {
let total = 0;
total += data.attributes[key].value;

const skillValues = ModifierHelpers.getCalculatedValueFromItems(items, key, "Skill Rank", true);
const skillValues = {sources: [], total: 0};
total += skillValues.total;
skillValues.sources.push({ modtype: "purchased", key: "purchased", name: "purchased", value: data.attributes[key].value });

/* Career Skills */
if (!data.skills[key].careerskill) {
const careerSkillValues = ModifierHelpers.getCalculatedValueFromItems(items, key, "Career Skill", true);
const careerSkillValues = {total: 0, sources: [], checked: false};
data.skills[key].careerskill = careerSkillValues.checked;
data.skills[key].careerskillsource = careerSkillValues.sources;
}
Expand All @@ -561,7 +559,7 @@ export class ActorFFG extends Actor {
data.skills[key].upgradessource = upgradesValues.sources;

const setValueAndSources = (modifiername, propertyname) => {
const obj = ModifierHelpers.getCalculatedValueFromItems(items, key, modifiername, true);
const obj = {sources: [], total: 0};
if (obj.total > 0) {
data.skills[key][propertyname] = obj.total;
data.skills[key][`${propertyname}source`] = obj.sources;
Expand Down Expand Up @@ -623,7 +621,6 @@ export class ActorFFG extends Actor {
} else {
total += data.attributes[key].value;
}
total += ModifierHelpers.getCalculatedValueFromItems(items, key, "Stat");

if (k === "shields") {
data.stats[k].fore = data.attributes[key].value[0] + total > 0 ? data.attributes[key].value[0] + total : 0;
Expand Down
4 changes: 2 additions & 2 deletions modules/actors/actor-sheet-ffg.js
Original file line number Diff line number Diff line change
Expand Up @@ -517,8 +517,8 @@ export class ActorSheetFFG extends ActorSheet {
const li = $(ev.currentTarget);
const item = this.actor.items.get(li.data("itemId"));
if (item) {
item.update({ ["system.equippable.equipped"]: !item.system.equippable.equipped });
await ModifierHelpers.updateAEsForEquip(this.actor, item, !item.system.equippable.equipped);
await item.update({ ["system.equippable.equipped"]: !item.system.equippable.equipped });
await ModifierHelpers.updateAEsForEquip(this.actor, item, item.system.equippable.equipped);
}
});

Expand Down
1 change: 1 addition & 0 deletions modules/helpers/dice-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ export default class DiceHelpers {
}

static async getModifiers(dicePool, item) {
// TODO: refactor this to not import attachments every time a roll is made (!)
if (item.type === "weapon") {
dicePool = await ModifierHelpers.getDicePoolModifiers(dicePool, item, []);

Expand Down
Loading

0 comments on commit b282533

Please sign in to comment.