Lone Wolf Development Forums

Lone Wolf Development Forums (http://forums.wolflair.com/index.php)
-   Realm Works Discussion (http://forums.wolflair.com/forumdisplay.php?f=67)
-   -   Best practices when transforming data? (http://forums.wolflair.com/showthread.php?t=57758)

EightBitz February 19th, 2017 02:37 PM

Best practices when transforming data?
 
With the Pathefinder system, in the structure section, with categories, sections and facets, everything as an ID and a name. I've noticed that with user-added elements in play, the IDs can change. It's not safe to assume that the category_id for the "Spell" category will always be the same for everyone.

With the script I'm working on to import data, the first thing I do is poll all the categories.

Code:

$CategoryList = $structure.GetElementsByTagName("*") | Where-Object {$_.category_id}
That gets me a list of everything in the structure that has a category_id value, whether it's a global category or a user category.

If I want to create a spell topic, I'll search that list for an element with the name of "Spell", and assign the associated category_id to the new topic.

Then for each topic, I grab a list of all the sections in a similar fashion, and just create a loop to create a section for each partition_id it finds for that topic.

Then within the section, I poll for facet_id, and create a snippet for each facet_id.

Then I reference each facet ID by name and process it accordingly.

Up to this point, it all seems like common sense stuff, but from here, things can vary. So my question is, what official standard should I adhere to?

With spells, for example, I'm inclined to assume that:
There will always be an "Overview" section, but it won't necessarily be the first one.
The "Overview" section will always contain the school, subschool, descriptor(s) (etc) snippets.
These snippets for spells will always be present, and always by these names.
There will always be a "Description" section, and it will always have at least one text snippet for the general description of the spell.
There will always be a Mythic section, and it will always have at least one text snippet for a description.

In other words, the basic elements and structure that I see in a default Pathfinder structure, the standard would be to assume that those elements will always be there, by their existing names, and in their existing sections.

There may be MORE snippets and sections, but I don't have to worry about those.

And users may have moved things around and renamed things, but if they have, then it's on their heads, not mine. ;-)

Is that a good general assessment? Or am I making bad assumptions or overlooking anything?

Farling February 19th, 2017 02:51 PM

Since you provide the structure in your import XML file, then you define the layout within those structures.

IF you use the standard game-system structure as the basis for your own XML import file then you can't go far wrong, and RW should map the standard game-system topics/snippets to match any changes that it knows about in the realm into which it's being imported.

The game system structure isn't going to change that often, so it isn't really worth reloading it each time you want to export it.

EightBitz February 19th, 2017 03:08 PM

Quote:

Originally Posted by Farling (Post 244720)
Since you provide the structure in your import XML file, then you define the layout within those structures.

IF you use the standard game-system structure as the basis for your own XML import file then you can't go far wrong, and RW should map the standard game-system topics/snippets to match any changes that it knows about in the realm into which it's being imported.

The game system structure isn't going to change that often, so it isn't really worth reloading it each time you want to export it.

Ah, you're right of course. I guess I have it so ingrained in me not to hard-code things that I overlooked the obvious.

It's still worthwhile to practice good habits, though. :-)


All times are GMT -8. The time now is 02:06 PM.

Powered by vBulletin® - Copyright ©2000 - 2024, vBulletin Solutions, Inc.
wolflair.com copyright ©1998-2016 Lone Wolf Development, Inc. View our Privacy Policy here.