TheLastScrub / delta-green-foundry-vtt-system-unofficial

A Foundry VTT game system for Delta Green: The RPG! This is a fan made work that is unaffiliated with Shane Ivey or Arc Dream Publishing, published under the Delta Green Community license. http://www.delta-green.com https://foundryvtt.com/
MIT License
25 stars 23 forks source link

Fix: Importing/Duplicating actors no longer resets default Typed Skill back to Art (Painting) #102

Closed jalensailin closed 5 months ago

jalensailin commented 5 months ago

Issue:

When importing actors from the compendium or duplicating them, the default Typed Skill was erroneously being reverted back to Art (Painting), regardless of how the actor was configured. In the code, this was because we were using the createActor hook to translate this default skill. Unfortunately, this hook gets called for imported actors and duplicated actors alike, which called this translation code, which reverted this Typed Skill back to Art (Painting). So, we needed a solution that could identify when an actor was being imported/duped vs. being created brand new. The preCreateActor hook has an extra argument which provides the creationData for the actor. In a brand new actor, the only creationData are the properties name and type. In a duped/imported actor, the creationData has all of the info from the original actor, including the property system. So, we check for the presence of the property system in creationData, and if it is there, we don't fire the hook.

To Test:

  1. Check out this branch.
  2. Switch language to Portuguese.
  3. Create a brand new Agent Actor and a brand new NPC Actor.
  4. Ensure that the default Typed Skill is appropriately translated to Artes (Pintura).
  5. Change the label/group of the default Typed Skill from Art (Painting) to anything else on both actors.
  6. Duplicate both actors.
  7. Ensure that the default Typed Skill has not reverted to Art (Painting).
  8. Drag both actors to a compendium.
  9. Ensure that in the compendium, the Typed Skill has not reverted.
  10. Import these actors back from the compendium.
  11. Ensure that the Typed Skill has not reverted on the imported actors.