gurps
gurps copied to clipboard
Feature Request: Import GCA/GCS Player Data as Foundry Items
Updated on 09-07-24
Oh boy, this seems big.
Indeed, this is a significant change.
Currently, GGA does not use the Foundry Item Framework, except for dragged items. To handle player data, we use the Actor Component classes to store data received from GCA/GCS imports. For example, inventory is handled by the Equipment
class, which is saved inside GurpsActor
in actor.system.equipment
, split between carried and other items. It uses fairly complex code that handles recursive logic to manage "parent" and "child" items—think of a sword inside a bag of holding inside a backpack.
The proposal is to add a new settings option: GURPS.settingUseFoundryItems
, allowing the system to create Foundry items for not only equipment but also Advantages, Disadvantages, Skills, and Spells. The default value is disabled.
When enabled, on the next import, GGA will:
- Look for an existing
GurpsItem
for imported GCA/GCS traits, equipment, skills, or spells. If it exists, it will preserve the Item data, like name, image, counts, uses, and notes. - Recursively create the
GurpsItems
. This can be a very long operation for GCS sheets on the first install. On subsequent imports, only the modified items will be imported. - For equipment, create the
actor.system.equipment
as-is, linking the correspondingitemId
. - For other traits, create the correct
actor.system.<key>
object as-is, linking the correspondingitemId
. - If the
GurpsItem
is modified, the system will reflect the change in the correspondingactor.system.<key>
object.
When disabled, on the next import, GGA will:
- Remove all
GurpsItems
previously created via import for that actor. Only imported items will be affected, not items from Compendium (dragged items) or those created by the user (saved items). - Create the
actor.system.<key>
objects as-is, preserving data from removed GurpsItems (name, count, uses, notes) in theActorComponent.itemInfo
property.
The Settings:
The operation (using a GCA-generated character with a fairly small inventory):
The New Item Experience
To make this work, the Item sheet was reworked to handle Items, Spells, Skills, and Traits. For example, here is the Skill Item Sheet:
If you do not set the import
field (the 'Roll' field), the system will use the otf
field (the 'Skill Level' field) to define the skill target. If you set the import
field, the system will use the number you defined.
More signs in the Actor Sheet.
The Actor sheet now shows an icon when the trait/skill/spell is from another Item or if the item was dragged from the compendium:
The blue icon is for dragged items (has globalid
). The dark orange is for items generated from other items (has fromItem
). The tooltip indicates the origin Item or the Global item which generated them.
Ok, but why this?
First, to make use of the Foundry Items Framework. Second, to offer an alternative to current GURPS Worlds in GGA, allowing export to another game system, like GCSGA, using an exported Compendium. I'm not sure if GCSGA developers will opt for this approach, but at least we can work with items like this (using Ripper93's Paper Doll):
By the way, this works for items even if the setting is disabled.
Ok, but I have some doubts
Q. What happens to my already created items?
A. The expected behavior is not to change any non-imported items from GCA/GCS. In other words, if you manually created an item on the sheet, it will remain unchanged by this code.
Q. What happens to item data that does not exist in Equipment, like the Image, if I disable this option?
A. All item-exclusive data will be backed up inside the Equipment object (system.itemInfo
). If you enable it again, on the next import, a new item will be created with the same data as the previous one.
Q. Can I drag and drop items between actors created from different generators? One in GCA and another in GCS, for example?
A. Yes, on the next import, the system will ignore items from the other generator, preserving that item on the sheet.
Q. Can I work with both options - Items and Equipment - at the same time, in different Actors/Sheets?
A. For the imported items, no, to avoid some nasty bugs. If you enable or disable the option, you'll need to reimport all your actors to recreate items or equipment. A dialog will remind you to reimport the sheet. User-created or Compendium items work as intended, whether this option is enabled or not.
Q. Why does the import take so long?
A. Because the items are truly saved in the database. This is an expensive operation for JavaScript, and the current code is not optimized for that. This is an even bigger refactoring.
Nice, how can I test this?
- First, please, please, back up your game world.
- Make sure your GCS or GCA character is up-to-date with their Actor counterpart.
- Enable the settings and reimport all your actors.
- If you want to revert to the classic equipment, just disable the option and import all Actors again.
I've tested this code extensively, but there are many scenarios to cover. Any help is appreciated.