Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Active effects take two #1777

Merged
merged 16 commits into from
Jan 23, 2025
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
`?`
* Features:
* Attachments now actually work! ([#1215](/~https://github.com/StarWarsFoundryVTT/StarWarsFFG/issues/1215))

`1.905`
* Fixes
* Hotfix for inability to roll dice with modifiers (e.g. critical injuries)
Expand Down
17 changes: 16 additions & 1 deletion lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"SWFFG.TabSpecializations": "Specializations",
"SWFFG.TabCareer": "Career Data",
"SWFFG.TabXpLog": "XP log",
"SWFFG.LongDescription": "Long Description:",
"SWFFG.LongDescription": "Long Description",
"SWFFG.Sources": "Source(s):",
"SWFFG.CharacteristicBrawn": "Brawn",
"SWFFG.CharacteristicBrawnAbbreviation": "Br",
Expand Down Expand Up @@ -97,6 +97,7 @@
"SWFFG.ItemsSoak": "Soak",
"SWFFG.ItemsHP": "HP",
"SWFFG.ItemsPrice": "Price",
"SWFFG.ItemsPricePlaceholder": "Value of Item",
"SWFFG.ItemsRarity": "Rarity",
"SWFFG.ItemsQuantity": "Quantity",
"SWFFG.ItemsQty": "Qty",
Expand Down Expand Up @@ -754,6 +755,20 @@
"SWFFG.Actors.Sheets.Purchase.Tooltip.ForcePower": "Purchase a new Force Power",
"SWFFG.Actors.Sheets.Purchase.Tooltip.SignatureAbility": "Purchase a new Signature Ability",
"SWFFG.Actors.Sheets.Purchase.Tooltip.SkilLRank": "Purchase a Skill Rank",
"SWFFG.Items.Popout.Title": "Editing {currentItem} on {parentItem}",
"SWFFG.Items.Popout.Tabs.Basics": "Basics",
"SWFFG.Items.Popout.Tabs.BaseMods": "Base Mods",
"SWFFG.Items.Popout.Tabs.Modifications": "Modifications",
"SWFFG.Items.Popout.Label.Modification": "Modification",
"SWFFG.Items.Popout.Label.Installed": "Installed?",
"SWFFG.Items.Popout.Label.Ranks": "Ranks",
"SWFFG.Items.Popout.Label.NotRanked": "Not Ranked",
"SWFFG.Items.Popout.Info.DragDrop": "(drag-and-drop mods or qualities to add them)",
"SWFFG.Items.Popout.Buttons.Modification.Add": "Add Modification",
"SWFFG.Items.Popout.Type.Warning": "Changing this will immediately CHANGE all base and modification mods",
"SWFFG.Items.Sheets.Qualities.FromAttachment": "(from attachment)",
"SWFFG.Items.Sheets.Qualities.Ranks": "ranks from",
"SWFFG.Items.Attachments.Label.Hardpoints": "Using {hardpoints} hardpoints",
"SWFFG.Settings.Purchase.Specialization.Name": "Specialization Compendiums",
"SWFFG.Settings.Purchase.Specialization.Hint": "Comma seperated compendiums to search for buying Specializations (no spaces)",
"SWFFG.Settings.Purchase.ForcePower.Name": "Force Power Compendiums",
Expand Down
40 changes: 0 additions & 40 deletions modules/actors/actor-sheet-ffg.js
Original file line number Diff line number Diff line change
Expand Up @@ -1732,29 +1732,6 @@ export class ActorSheetFFG extends ActorSheet {

for await (const spec of specializations) {
CONFIG.logger.debug(`_updateSpecialization(): starting work on ${spec.name}`);
const specializationTalents = spec.system.talents;
for (const talent in specializationTalents) {
let gameItem;
if (specializationTalents[talent].pack && specializationTalents[talent].pack.length > 0) {
const pack = await game.packs.get(specializationTalents[talent]?.pack);
if (pack) {
await pack.getIndex();
let entry = await pack.index.find((e) => e._id === specializationTalents[talent].itemId);
if (!entry) {
entry = await pack.index.find((e) => e.name === specializationTalents[talent].name);
}
if (entry) {
gameItem = await pack.getDocument(entry._id);
}
}
} else {
gameItem = await game.items.get(specializationTalents[talent].itemId);
}

if (gameItem) {
this._updateSpecializationTalentReference(specializationTalents[talent], gameItem);
}
}

if (spec?.talentList && spec.talentList.length > 0) {
spec.talentList.forEach((talent) => {
Expand Down Expand Up @@ -1788,23 +1765,6 @@ export class ActorSheetFFG extends ActorSheet {
CONFIG.logger.debug(data.talentList.slice());
}

/**
* Update a specialization talent based on talent reference
* @param {Object} specializationTalentItem
* @param {Object} talentItem
*/
_updateSpecializationTalentReference(specializationTalentItem, talentItem) {
CONFIG.logger.debug(`Starwars FFG - Updating Specializations Talent`);
specializationTalentItem.name = talentItem.name;
specializationTalentItem.description = talentItem.system.description;
specializationTalentItem.activation = talentItem.system.activation.value;
specializationTalentItem.activationLabel = talentItem.system.activation.label;
specializationTalentItem.isRanked = talentItem.system.ranks.ranked;
specializationTalentItem.isForceTalent = talentItem.system.isForceTalent;
specializationTalentItem.isConflictTalent = talentItem.system.isConflictTalent;
specializationTalentItem.attributes = talentItem.system.attributes;
}

/**
* Open dialog for popout editor
* @param {Object} event
Expand Down
77 changes: 76 additions & 1 deletion modules/config/ffg-modifiers.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import {weapon_stats} from "./ffg-weapons.js";
import {armor_stats} from "./ffg-armor.js";
import {vehicle_stats} from "./ffg-vehicles.js";
import {character_characteristics, character_stats} from "./ffg-characters.js";
import {skills} from "./ffg-skills.js";

export const general_modifiers = {
"Characteristic": {
"value": "Characteristic",
Expand Down Expand Up @@ -63,6 +69,18 @@ export const general_modifiers = {
"value": "Skill Setback",
"label": "SWFFG.ModTypeSkillSetback",
},
"Weapon Stat": {
"value": "Weapon Stat",
"label": "SWFFG.ModTypeStatWeapon",
},
"Armor Stat": {
"value": "Armor Stat",
"label": "SWFFG.ModTypeStatArmor",
},
"Vehicle Stat": {
"value": "Vehicle Stat",
"label": "SWFFG.ModTypeStatVehicle",
},
"Stat": {
"value": "Stat",
"label": "SWFFG.ModTypeStat",
Expand All @@ -88,13 +106,36 @@ export const weapon_modifiers = {
},
};

export const vehicle_modifiers = {
export const armor_modifiers = {
"Result Modifiers": {
"value": "Result Modifiers",
"label": "SWFFG.ModTypeResultModifiers",
},
"Dice Modifiers": {
"value": "Dice Modifiers",
"label": "SWFFG.ModTypeDiceModifiers",
},
"Roll Modifiers": {
"value": "Roll Modifiers",
"label": "SWFFG.ModTypeRollModifiers",
},
"Armor Stat": {
"value": "Armor Stat",
"label": "SWFFG.ModTypeStatArmor",
},
"Stat": {
"value": "Stat",
"label": "SWFFG.ModTypeStat",
},
};

export const vehicle_modifiers = {
"Vehicle Stat": {
"value": "Vehicle Stat",
"label": "SWFFG.ModTypeStatVehicle",
},
};

export const modifier_types = {
"All": {
"value": "all",
Expand Down Expand Up @@ -217,3 +258,37 @@ export const itemmodifier_resultmodifiers = {
"label": "SWFFG.ModTypeAddDespair",
},
};

export const modTypeToModMap = {
"Weapon Stat": weapon_stats,
"Armor Stat": armor_stats,
"Vehicle Stat": vehicle_stats,
"Stat": character_stats,
"Result Modifiers": itemmodifier_resultmodifiers,
"Dice Modifiers": itemmodifier_dicemodifiers,
"Roll Modifiers": itemmodifier_rollmodifiers,
"Characteristic": character_characteristics,
"Career Skill": skills,
"Force Boost": skills,
"Skill Add Advantage": skills,
"Skill Add Dark": skills,
"Skill Add Despair": skills,
"Skill Add Failure": skills,
"Skill Add Light": skills,
"Skill Add Success": skills,
"Skill Add Threat": skills,
"Skill Add Triumph": skills,
"Skill Add Upgrade": skills,
"Skill Boost": skills,
"Skill Rank": skills,
"Skill Remove Setback": skills,
"Skill Setback": skills,
};

export const itemTypeToModTypeMap = {
"weapon": weapon_modifiers,
"armor": armor_modifiers,
"armour": armor_modifiers,
"vehicle": vehicle_modifiers,
"all": general_modifiers,
}
24 changes: 23 additions & 1 deletion modules/helpers/item-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,32 @@ export default class ItemHelpers {
delete updatedData.data;
}
// Initialize updatedData.system if the key is present with no value
if (Object.keys(updatedData).includes('system') && typeof updatedData.system === "undefined")
if (Object.keys(updatedData).includes('system') && typeof updatedData.system === "undefined")
{
updatedData.system = {};
}
return updatedData;
}

/**
* Takes formData and converts certain fields into an array, rather than the odd name they have by default
* For example, submitting a form with a modifier on it results in a field value of "itemmodifier[0]", rather than
* a field named "itemmodifier" with a single entry in an array
* @param formData
*/
static explodeFormData(formData) {
// convert the formdata into a dict
formData = foundry.utils.expandObject(formData);
// collapse the resulting entries with an index into an array
const relevantEntries = Object.keys(formData?.system).filter(i => i.includes("[") && i.includes("]"));
for (const cur_entry in relevantEntries) {
const updatedKeyName = relevantEntries[cur_entry].replace(/\[.*\]/, "");
if (!Object.keys(formData.system).includes(updatedKeyName)) {
formData.system[updatedKeyName] = [];
}
formData.system[updatedKeyName].push(formData.system[relevantEntries[cur_entry]]);
delete formData.system[relevantEntries[cur_entry]];
}
return formData;
}
}
24 changes: 0 additions & 24 deletions modules/helpers/modifiers.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,30 +311,6 @@ export default class ModifierHelpers {
}).render(true);
}

static async popoutModiferWindowSpecTalents(event) {
event.preventDefault();
const a = $(event.currentTarget).parents(".talent-block")?.[0];
const keyname = $(a).attr("id");

const title = `${game.i18n.localize("SWFFG.TabModifiers")}: ${this.object.system.talents[keyname].name}`;

const data = {
parent: this.object,
keyname,
data: {
data: {
...this.object.system.talents[keyname],
},
},
isUpgrade: false,
isTalent: true,
};

new PopoutModifiers(data, {
title,
}).render(true);
}

static async getDicePoolModifiers(pool, item, items) {
let dicePool = new DicePoolFFG(pool);

Expand Down
4 changes: 4 additions & 0 deletions modules/helpers/partial-templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ export default class TemplateHelpers {
"systems/starwarsffg/templates/parts/actor/ffg-skills.html",
"systems/starwarsffg/templates/parts/actor/ffg-weapon-armor-gear.html",
"systems/starwarsffg/templates/parts/actor/ffg-vehicle-weapon-attachments.html",
"systems/starwarsffg/templates/parts/ffg-qualities-attachments-mods.html",
"systems/starwarsffg/templates/parts/ffg-mods.html",
"systems/starwarsffg/templates/items/dialogs/ffg-mod.html",
"systems/starwarsffg/templates/items/dialogs/ffg-modification.html",
"systems/starwarsffg/templates/parts/actor/ffg-vehicle-cargo.html",
"systems/starwarsffg/templates/parts/actor/ffg-vehicle-crew.html",
"systems/starwarsffg/templates/parts/actor/ffg-homestead-upgrades.html",
Expand Down
Loading