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
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:
Check out this branch.
Switch language to Portuguese.
Create a brand new Agent Actor and a brand new NPC Actor.
Ensure that the default Typed Skill is appropriately translated to Artes (Pintura).
Change the label/group of the default Typed Skill from Art (Painting) to anything else on both actors.
Duplicate both actors.
Ensure that the default Typed Skill has not reverted to Art (Painting).
Drag both actors to a compendium.
Ensure that in the compendium, the Typed Skill has not reverted.
Import these actors back from the compendium.
Ensure that the Typed Skill has not reverted on the imported actors.
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. ThepreCreateActor
hook has an extra argument which provides thecreationData
for the actor. In a brand new actor, the onlycreationData
are the propertiesname
andtype
. In a duped/imported actor, thecreationData
has all of the info from the original actor, including the propertysystem
. So, we check for the presence of the propertysystem
increationData
, and if it is there, we don't fire the hook.To Test: