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

Foundry 10 #1079

Merged
merged 19 commits into from
Sep 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions modules/actors/actor-ffg.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,20 +125,20 @@ export class ActorFFG extends Actor {
const item = {
name: element.name,
itemId: element.id,
description: element.data?.data?.description,
activation: element.data?.data?.activation?.value,
activationLabel: element.data?.data?.activation?.label,
isRanked: element.data?.data?.ranks?.ranked,
description: element.system?.description,
activation: element.system.activation?.value,
activationLabel: element.system.activation?.label,
isRanked: element.system.ranks?.ranked,
source: [{ type: "talent", typeLabel: "SWFFG.Talent", name: element.name, id: element.id }],
};
if (item.isRanked) {
item.rank = element.data?.data?.ranks?.current;
item.rank = element.system.ranks?.current;
} else {
item.rank = "N/A";
}

if (CONFIG.FFG.theme !== "starwars") {
item.tier = parseInt(element.data?.data?.tier, 10);
item.tier = parseInt(element.system.tier, 10);
}

let index = globalTalentList.findIndex((obj) => {
Expand All @@ -149,9 +149,9 @@ export class ActorFFG extends Actor {
globalTalentList.push(item);
} else {
globalTalentList[index].source.push({ type: "talent", typeLabel: "SWFFG.Talent", name: element.name, id: element.id });
globalTalentList[index].rank += element.data?.data?.ranks?.current;
globalTalentList[index].rank += element.system.ranks?.current;
if (CONFIG.FFG.theme !== "starwars") {
globalTalentList[index].tier = Math.abs(globalTalentList[index].rank + (parseInt(element.data?.data?.tier, 10) - 1));
globalTalentList[index].tier = Math.abs(globalTalentList[index].rank + (parseInt(element.system.tier, 10) - 1));
}
}
});
Expand Down Expand Up @@ -445,7 +445,7 @@ export class ActorFFG extends Actor {
value = [data[name][k].fore, data[name][k].port, data[name][k].starboard, data[name][k].aft];
} else if (key === "Soak") {
try {
if ((typeof actorData.data.flags?.config?.enableAutoSoakCalculation === undefined && game.settings.get("starwarsffg", "enableSoakCalc")) || actorData.data.flags?.config?.enableAutoSoakCalculation) {
if ((typeof actorData.flags?.config?.enableAutoSoakCalculation === undefined && game.settings.get("starwarsffg", "enableSoakCalc")) || actorData.flags?.config?.enableAutoSoakCalculation) {
value = 0;
}
} catch (err) {
Expand Down
4 changes: 2 additions & 2 deletions modules/actors/adversary-sheet-ffg.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class AdversarySheetFFG extends ActorSheetFFG {
default:
}

data.items = this.actor.items.map((item) => item.data);
data.items = this.actor.items.map((item) => item);

return data;
}
Expand All @@ -54,7 +54,7 @@ export class AdversarySheetFFG extends ActorSheetFFG {

if (!this.options.editable) return;

if (this.actor.data.type === "character") {
if (this.actor.type === "character") {
this.sheetoptions.clear();
this.sheetoptions.register("enableAutoSoakCalculation", {
name: game.i18n.localize("SWFFG.EnableSoakCalc"),
Expand Down
2 changes: 1 addition & 1 deletion modules/dice/roll.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ export class RollFFG extends Roll {
if (rMode) msg.applyRollMode(rollMode);

// Either create or return the data
return create ? cls.create(msg.data) : msg.data;
return create ? cls.create(msg) : msg;
}

/** @override */
Expand Down
2 changes: 1 addition & 1 deletion modules/helpers/actor-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export default class ActorHelpers {
}
});
// Handle skill rank updates
Object.keys(this.object.data.data.skills).forEach((key) => {
Object.keys(this.object.system.skills).forEach((key) => {
let total = ModifierHelpers.getCalculateValueForAttribute(key, this.actor.system.attributes, ownedItems, "Skill Rank");
let x = parseInt(formData.data.skills[key]?.rank, 10) - total;
let y = parseInt(formData.data.attributes[key]?.value, 10) + x;
Expand Down
12 changes: 6 additions & 6 deletions modules/helpers/dice-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export default class DiceHelpers {
item = obj.actor.token.actor.items.get(itemID);
}
}
const itemData = item?.data || {};
const itemData = item || {};
const status = this.getWeaponStatus(itemData);

// TODO: Get weapon specific modifiers from itemmodifiers and itemattachments
Expand Down Expand Up @@ -233,16 +233,16 @@ export default class DiceHelpers {
if (item.type === "weapon") {
dicePool = await ModifierHelpers.getDicePoolModifiers(dicePool, item, []);

if (item?.data?.itemattachment) {
await ImportHelpers.asyncForEach(item.data.itemattachment, async (attachment) => {
if (item?.system?.itemattachment) {
await ImportHelpers.asyncForEach(item.system.itemattachment, async (attachment) => {
//get base mods and additional mods totals
const activeModifiers = attachment.data.itemmodifier.filter((i) => i.data?.active);
const activeModifiers = attachment.system.itemmodifier.filter((i) => i.system?.active);

dicePool = await ModifierHelpers.getDicePoolModifiers(dicePool, attachment, activeModifiers);
});
}
if (item?.data?.itemmodifier) {
await ImportHelpers.asyncForEach(item.data.itemmodifier, async (modifier) => {
if (item?.system?.itemmodifier) {
await ImportHelpers.asyncForEach(item.system.itemmodifier, async (modifier) => {
dicePool = await ModifierHelpers.getDicePoolModifiers(dicePool, modifier, []);
});
}
Expand Down
14 changes: 7 additions & 7 deletions modules/helpers/embeddeditem-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,15 +127,15 @@ export default class EmbeddedItemHelpers {

let modifierIndex;
let item;
if (ownedItem?.data?.data?.[modifierType]) {
modifierIndex = ownedItem.data.data[modifierType].findIndex((i) => i._id === modifierId || i.id === modifierId);
item = ownedItem.data.data[modifierType][modifierIndex];
if (ownedItem?.system[modifierType]) {
modifierIndex = ownedItem.system[modifierType].findIndex((i) => i._id === modifierId || i.id === modifierId);
item = ownedItem.system[modifierType][modifierIndex];
}

if (!item) {
// this is a modifier on an attachment
ownedItem.data.data.itemattachment.forEach((a) => {
modifierIndex = a.data[modifierType].findIndex((m) => m.id === modifierId);
ownedItem.system.itemattachment.forEach((a) => {
modifierIndex = a.system[modifierType].findIndex((m) => m.id === modifierId);
if (modifierIndex > -1) {
item = a.data[modifierType][modifierIndex];
}
Expand All @@ -144,9 +144,9 @@ export default class EmbeddedItemHelpers {

const readonlyItem = {
name: item.name,
content: item.data.description,
content: item.system.description,
permission: {
default: CONST.ENTITY_PERMISSIONS.OBSERVER,
default: CONST.DOCUMENT_OWNERSHIP_LEVELS.OBSERVER,
},
};

Expand Down
8 changes: 4 additions & 4 deletions modules/helpers/modifiers.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default class ModifierHelpers {
}
if ((key === "Defence-Melee" || key === "Defence-Ranged") && item.system?.defence) {
// get the highest defense item
const shouldUse = items.filter((i) => item.system.defence >= i.data.defence).length >= 0;
const shouldUse = items.filter((i) => item.system.defence >= i.system.defence).length >= 0;
if (shouldUse) {
sources.push({ modtype, key, name: item.name, value: item.system.defence.adjusted, type: item.type });
total += parseInt(item.system.defence.adjusted, 10);
Expand Down Expand Up @@ -188,12 +188,12 @@ export default class ModifierHelpers {
let checked = false;
let sources = [];

let rank = item?.data?.rank;
let rank = item?.system?.rank;
if(rank === null || rank === undefined) {
rank = 1;
}
if (item?.data) {
const filteredAttributes = Object.values(item.data.attributes).filter((a) => a.modtype === modtype && a.mod === key);
if (item?.system) {
const filteredAttributes = Object.values(item.system.attributes).filter((a) => a.modtype === modtype && a.mod === key);

filteredAttributes.forEach((attr) => {
sources.push({ modtype, key, name: item.name, value: attr.value * rank, type: item.type });
Expand Down
6 changes: 3 additions & 3 deletions modules/importer/import-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ export default class ImportHelpers {

const content = await pack.getDocuments();
for (var i = 0; i < content.length; i++) {
CONFIG.temporary[packid][content[i].data?.flags?.starwarsffg?.ffgimportid] = duplicate(content[i]);
CONFIG.temporary[packid][content[i].flags?.starwarsffg?.ffgimportid] = duplicate(content[i]);
}
}
} else {
Expand Down Expand Up @@ -2376,7 +2376,7 @@ export default class ImportHelpers {
} else if (dieMod.SkillChar) {
// this is a skill modifier based on characteristic (ex all Brawn skills);
const skillTheme = await game.settings.get("starwarsffg", "skilltheme");
const allSkillsLists = JSON.parse(await game.settings.get("starwarsffg", "arraySkillList"));
const allSkillsLists = await game.settings.get("starwarsffg", "arraySkillList");
const skills = allSkillsLists.find((i) => i.id === skillTheme).skills;
const characteristicSkills = Object.keys(skills).filter((s) => skills[s].characteristic === ImportHelpers.convertOGCharacteristic(dieMod.SkillChar));

Expand All @@ -2391,7 +2391,7 @@ export default class ImportHelpers {
});
} else if (dieMod.SkillType) {
const skillTheme = await game.settings.get("starwarsffg", "skilltheme");
const allSkillsLists = JSON.parse(await game.settings.get("starwarsffg", "arraySkillList"));
const allSkillsLists = await game.settings.get("starwarsffg", "arraySkillList");
const skills = allSkillsLists.find((i) => i.id === skillTheme).skills;
const characteristicSkills = Object.keys(skills).filter((s) => skills[s].type.toLowerCase() === dieMod.SkillType.toLowerCase());

Expand Down
24 changes: 12 additions & 12 deletions modules/importer/oggdude/importers/specializations.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ export default class Specializations {
const item = specializationData.Specialization;

let data = ImportHelpers.prepareBaseObject(item, "specialization");
data.data = {
data.system = {
attributes: {},
description: item.Description,
talents: {},
careerskills: {},
isReadOnly: true,
};

data.data.description += ImportHelpers.getSources(item?.Sources ?? item?.Source);
data.data.attributes = mergeObject(data.data.attributes, ImportHelpers.processStatMod(item?.Attributes));
data.data.attributes = mergeObject(data.data.attributes, ImportHelpers.processCareerSkills(item?.CareerSkills, true));
data.system.description += ImportHelpers.getSources(item?.Sources ?? item?.Source);
data.system.attributes = mergeObject(data.system.attributes, ImportHelpers.processStatMod(item?.Attributes));
data.system.attributes = mergeObject(data.system.attributes, ImportHelpers.processCareerSkills(item?.CareerSkills, true));

for (let i = 0; i < item.TalentRows.TalentRow.length; i += 1) {
const row = item.TalentRows.TalentRow[i];
Expand All @@ -47,17 +47,17 @@ export default class Specializations {

if (talentItem) {
rowTalent.name = talentItem.name;
rowTalent.description = talentItem.data.description;
rowTalent.activation = talentItem.data.activation.value;
rowTalent.activationLabel = talentItem.data.activation.label;
rowTalent.isForceTalent = talentItem?.data?.isForceTalent ? true : false;
rowTalent.isConflictTalent = talentItem?.data?.isConflictTalent ? true : false;
rowTalent.isRanked = talentItem?.data?.ranks?.ranked ? true : false;
rowTalent.description = talentItem.system.description;
rowTalent.activation = talentItem.system.activation.value;
rowTalent.activationLabel = talentItem.system.activation.label;
rowTalent.isForceTalent = talentItem?.system?.isForceTalent ? true : false;
rowTalent.isConflictTalent = talentItem?.system?.isConflictTalent ? true : false;
rowTalent.isRanked = talentItem?.system?.ranks?.ranked ? true : false;
rowTalent.size = "single";
rowTalent.canLinkTop = true;
rowTalent.canLinkRight = true;
rowTalent.itemId = talentItem._id;
rowTalent.attributes = talentItem.data.attributes;
rowTalent.attributes = talentItem.system.attributes;

if (row.Directions.Direction[index].Up && row.Directions.Direction[index].Up === "true") {
rowTalent["links-top-1"] = true;
Expand All @@ -72,7 +72,7 @@ export default class Specializations {
}

const talentKey = `talent${i * 4 + index}`;
data.data.talents[talentKey] = rowTalent;
data.system.talents[talentKey] = rowTalent;
} else {
CONFIG.logger.warn(`Unable to find ${keyName}`);
}
Expand Down
14 changes: 7 additions & 7 deletions modules/importer/oggdude/importers/vehicles.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default class Vehicles {

let data = ImportHelpers.prepareBaseObject(item, "vehicle");
data.items = [];
data.data = {
data.system = {
biography: item.Description,
stats: {
silhouette: {
Expand Down Expand Up @@ -84,7 +84,7 @@ export default class Vehicles {
itemattachment: [],
};

data.data.biography += ImportHelpers.getSources(item?.Sources ?? item?.Source);
data.system.biography += ImportHelpers.getSources(item?.Sources ?? item?.Source);

if (item.VehicleWeapons?.VehicleWeapon) {
if (!Array.isArray(item.VehicleWeapons.VehicleWeapon)) {
Expand All @@ -96,19 +96,19 @@ export default class Vehicles {
const weaponData = JSON.parse(JSON.stringify(weaponEntity));
delete weaponData._id;

if (!Array.isArray(weaponData.data.itemmodifier)) {
weaponData.data.itemmodifier = [];
if (!Array.isArray(weaponData.system.itemmodifier)) {
weaponData.system.itemmodifier = [];
}
const count = weapon.Count ? parseInt(weapon.Count, 10) : 1;
if (!weaponData.data?.firingarc) weaponData.data.firingarc = {};
if (!weaponData.system?.firingarc) weaponData.system.firingarc = {};
["Fore", "Aft", "Port", "Starboard", "Dorsal", "Ventral"].forEach((location) => {
weaponData.data.firingarc[location.toLowerCase()] = weapon?.FiringArcs?.[location] === "true" ? true : false;
weaponData.system.firingarc[location.toLowerCase()] = weapon?.FiringArcs?.[location] === "true" ? true : false;
});

if (weapon?.Qualities) {
const mods = await ImportHelpers.processMods(weapon);
if (mods.qualities) {
weaponData.data.itemmodifier = weaponData.data.itemmodifier.concat(mods.qualities.itemmodifier);
weaponData.system.itemmodifier = weaponData.system.itemmodifier.concat(mods.qualities.itemmodifier);
}
}

Expand Down
Loading