2024-05-17 12:46:44 +02:00
|
|
|
let skill = `Trade (${this.item.parenthesesText})`
|
|
|
|
let currentCareer = this.actor.system.currentCareer;
|
|
|
|
let existingSkill = this.actor.itemTypes.skill.find(i => i.name == skill);
|
|
|
|
|
|
|
|
if (!currentCareer) return
|
|
|
|
|
|
|
|
|
|
|
|
let inCurrentCareer = currentCareer.system.skills.includes(skill);
|
2024-06-06 21:09:27 +02:00
|
|
|
let craftsmanAdded = this.actor.getFlag("wfrp4e", "craftsmanAdded") || {};
|
|
|
|
if (existingSkill && inCurrentCareer && !craftsmanAdded[existingSkill.name])
|
2024-05-17 12:46:44 +02:00
|
|
|
{
|
|
|
|
existingSkill.system.advances.costModifier = -5;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-06-06 21:09:27 +02:00
|
|
|
craftsmanAdded[skill] = true;
|
2024-05-17 12:46:44 +02:00
|
|
|
currentCareer.system.skills.push(skill);
|
2024-06-06 21:09:27 +02:00
|
|
|
setProperty(this.actor, "flags.wfrp4e.craftsmanAdded", craftsmanAdded)
|
|
|
|
}
|