Make Items with mods equippable (#11)

Changes:
 + Items that can influence you stats are equippable
 + only equipped items influence your stats
 + Armor now influences your stats
 + move mods into a partial for easier changes
This commit is contained in:
2023-11-30 15:50:59 +01:00
committed by GitHub
parent 8095785fc2
commit 28595e7dd0
13 changed files with 143 additions and 125 deletions
+4 -1
View File
@@ -138,7 +138,7 @@ export class M5Character extends Actor {
const aggregate = new M5ModAggregate(data, ret);
context.items
?.filter((item) => item.type === "item" || item.type === "effect")
?.filter((item) => (item.type === "item" || item.type === "effect" || item.type === "armor") && item.system.equipped)
.forEach((item) => {
const mods = item.system.mods;
//console.log("Actor item mods", mods)
@@ -166,6 +166,7 @@ export class M5Character extends Actor {
label: label,
magic: item.system.magic,
calc: item.system.calc,
equipped: item.system?.equipped,
};
});
}
@@ -185,6 +186,7 @@ export class M5Character extends Actor {
label: label,
magic: item.system.magic,
calc: item.system.calc,
equipped: item.system?.equipped,
};
});
}
@@ -267,6 +269,7 @@ export class M5Character extends Actor {
label: label,
magic: item.system.magic,
calc: item.system.calc,
equipped: item.system?.equipped,
};
});
}
+9 -1
View File
@@ -105,6 +105,11 @@ export class M5Item extends Item {
calc.fw += skillData.fw;
}
}
} else if (itemType === "armor") {
itemData.mods[0] = { type: "stat", id: "defenseBonus", operation: "add", value: itemData.stats.defenseBonus };
itemData.mods[1] = { type: "stat", id: "attackBonus", operation: "add", value: itemData.stats.attackBonus };
itemData.mods[2] = { type: "stat", id: "movement", operation: "add", value: itemData.stats.movementBonus };
itemData.mods[3] = { type: "attribute", id: "gw", operation: "add100", value: itemData.attributeMod.gw };
} else if (itemType === "spell") {
calc.fw = 0;
if (actor) {
@@ -134,8 +139,10 @@ export class M5Item extends Item {
itemData.rolls.formulas[0].label = skill.name;
}
}
} else if (itemType === "item" || itemType === "effect") {
}
if (itemData?.mods) {
calc.mods = {};
Object.keys(itemData?.mods).forEach((key) => {
const mod = itemData.mods[key];
const modCalc = {};
@@ -243,6 +250,7 @@ export class M5Item extends Item {
}
const roll = new M5Roll(rollData, this.actor, item.name);
console.log(roll);
return roll.toMessage();
} else {
ChatMessage.create({