foundryvtt / foundryvtt-premium-content

Public issue tracking for feature requests and bug reports related to first-party premium content for Foundry Virtual Tabletop.
https://foundryvtt.com/packages/premium
17 stars 1 forks source link

[Bug]: Inconsistent handling of actor's `system.details.source` data #483

Closed MaxPat931 closed 4 months ago

MaxPat931 commented 8 months ago

What happened?

Source data is not consistent across actors, and missing for several as well

image image image

What package are you reporting this for?

Phandelver and Below: The Shattered Obelisk

Version

1.0.0

Relevant log output

No response

MaxPat931 commented 8 months ago

It looks like the latest update did standardize all the SRD references into Custom, but there are still inconsistencies for the PBSO entries (Book or Custom, and or &, with or without The Shattered Obelisk) image

I adapted this from something else in #macro-polo, but seemed to work well and give all the PBSO actors consistent Source data, based on whether or not an actor of a matching name exists in the SRD compendium, and changes the SRD matches to have the same data as the SRD compendium, and will log out the changes, just in case.
(Of course, this is just for the compendium actors, the in world actors, and tokens would need to be updated as well)

const srdMonsPack = game.packs.get("dnd5e.monsters");
const pbsoMonsPack = game.packs.get("dnd-phandelver-below.pbso-bestiary")

const matches = new Set(pbsoMonsPack.index.map(e => e.name)).intersection(new Set(srdMonsPack.index.map(e => e.name)));
for (let match of matches) {
    const targetSource = await pbsoMonsPack.getDocument(pbsoMonsPack.index.getName(match)._id);
    if (targetSource.system.details.source.book === "SRD 5.1") {
        console.log(targetSource.name, "Correct!")
        continue};
    console.log("SRD-TARGETSOURCE-OLD", targetSource.name, targetSource.system.details.source)
    await targetSource.update({ 'system.details.source.book': "SRD 5.1", 'system.details.source.custom': "", 'system.details.source.license': "CC-BY-4.0" })
    console.log("SRD-TARGETSOURCE-NEW", targetSource.name, targetSource.system.details.source)
}

const uniques = new Set(pbsoMonsPack.index.map(e => e.name)).difference(new Set(srdMonsPack.index.map(e => e.name)));
for (let unique of uniques) {
    const targetSource = await pbsoMonsPack.getDocument(pbsoMonsPack.index.getName(unique)._id);
    if (targetSource.system.details.source.book === "Phandelver and Below: The Shattered Obelisk")  {
        console.log(targetSource.name, "Correct!")
        continue};
    console.log("PBSO-TARGETSOURCE-OLD", targetSource.name, targetSource.system.details.source)
    await targetSource.update({ 'system.details.source.book': "Phandelver and Below: The Shattered Obelisk", 'system.details.source.custom': "" })
    console.log("PBSO-TARGETSOURCE-NEW", targetSource.name, targetSource.system.details.source)
}
mattexdee commented 4 months ago

Fixed as part of our 1.2.0 release.