diff --git a/packs/data-import/fvtt-Item-new-bond.json b/packs/data-import/fvtt-Item-new-bond.json new file mode 100644 index 0000000..d5000dd --- /dev/null +++ b/packs/data-import/fvtt-Item-new-bond.json @@ -0,0 +1,23 @@ +[ + { + "name": "New Bond", + "type": "bond", + "img": "icons/svg/mystery-man.svg", + "data": { + "name": "", + "description": "", + "score": 10, + "relationship": "" + }, + "effects": [], + "sort": 0, + "flags": { + "exportSource": { + "world": "dgtest", + "system": "deltagreen", + "coreVersion": "0.8.6", + "systemVersion": "1.0.0" + } + } + } +] diff --git a/packs/data-import/fvtt-Item-unarmed-attack.json b/packs/data-import/fvtt-Item-unarmed-attack.json new file mode 100644 index 0000000..02482b0 --- /dev/null +++ b/packs/data-import/fvtt-Item-unarmed-attack.json @@ -0,0 +1,34 @@ +[ + { + "name": "Unarmed Attack", + "type": "weapon", + "img": "systems/deltagreen/assets/icons/punch.svg", + "data": { + "name": "", + "description": "", + "skill": "melee_weapons", + "range": "0M", + "damage": "1D4-1", + "armorPiercing": 0, + "lethality": 0, + "isLethal": false, + "killRadius": "N/A", + "ammo": "", + "expense": "Standard", + "equipped": true + }, + "effects": [], + "sort": 0, + "flags": { + "core": { + "sourceId": "Compendium.deltagreen.hand-to-hand-weapons.JQEMyFfCHx38gupS" + }, + "exportSource": { + "world": "dgtest", + "system": "deltagreen", + "coreVersion": "0.8.6", + "systemVersion": "1.0.0" + } + } + } +] \ No newline at end of file diff --git a/packs/data-import/import_macro.js b/packs/data-import/import_macro.js new file mode 100644 index 0000000..232ff22 --- /dev/null +++ b/packs/data-import/import_macro.js @@ -0,0 +1,67 @@ +async function FillCompendium() { + + console.log('Loading compendium...'); + + const targetCompName = "pregens"; + const agentsDataPath = 'http://localhost:30000/systems/deltagreen/packs/data-import/pregen-actor-data.json'; + const bondDataPath = 'http://localhost:30000/systems/deltagreen/packs/data-import/fvtt-Item-new-bond.json'; + const unarmedAttackDataPath = 'http://localhost:30000/systems/deltagreen/packs/data-import/fvtt-Item-unarmed-attack.json'; + + // check if pack already exists, and if it does, delete it to avoid duplicates + let pack = game.packs.get("world." + targetCompName); + + if(typeof pack !== 'undefined'){ + await pack.deleteCompendium(); + } + + // create or recreate the pack so we can add everything + let data = { + 'label': "DG Pregens", + 'entity': "Actor", + 'name': targetCompName + }; + + await CompendiumCollection.createCompendium(data); + + let targetPack = game.packs.get("world." + targetCompName); + + let bondItemTemplate = ''; + + // get the item data for a placeholder bond + await fetch(bondDataPath).then(response => response.json()).then(function(response){ + bondItemTemplate = response; + }); + + let unarmedAttackItemTemplate = ''; + + // get the item data for a placeholder bond + await fetch(unarmedAttackDataPath).then(response => response.json()).then(function(response){ + unarmedAttackItemTemplate = response; + }); + + let agentArr = []; + + // load JSON file filled with agent stats + await fetch(agentsDataPath).then(response => response.json()).then(function(response){ + agentArr = Object.entries(response.agents); + }); + + //agentArr.forEach(function(item){ + for(var item of agentArr){ + + agentData = item[1]; + + let worldActor = await Actor.create(agentData); + + await worldActor.createEmbeddedDocuments("Item", bondItemTemplate); + + await worldActor.createEmbeddedDocuments("Item", unarmedAttackItemTemplate); + + await targetPack.importDocument(worldActor); + + await worldActor.delete(); + + } +} + +FillCompendium(); \ No newline at end of file diff --git a/packs/data-import/pregen-actor-data.json b/packs/data-import/pregen-actor-data.json new file mode 100644 index 0000000..ccb2070 --- /dev/null +++ b/packs/data-import/pregen-actor-data.json @@ -0,0 +1,87 @@ +{ + "agents": [ + { + "name": "pregen-actor1", + "type": "agent", + "img": "icons/svg/mystery-man.svg", + "data": { + "statistics": { + "str": { + "value": 10, + "distinguishing_feature": "test" + }, + "con": { + "value": 11, + "distinguishing_feature": "hello" + }, + "dex": { + "value": 12, + "distinguishing_feature": "" + }, + "int": { + "value": 13, + "distinguishing_feature": "" + }, + "pow": { + "value": 14, + "distinguishing_feature": "" + }, + "cha": { + "value": 15, + "distinguishing_feature": "" + } + }, + + "biography": { + "profession": "", + "employer": "Federal Goverment", + "nationality": "", + "sex": "M", + "age": "44", + "education": "" + } + } + }, + { + "name": "pregen-actor2", + "type": "agent", + "img": "icons/svg/mystery-man.svg", + "data": { + "statistics": { + "str": { + "value": 15, + "distinguishing_feature": "strong" + }, + "con": { + "value": 14, + "distinguishing_feature": "hearty" + }, + "dex": { + "value": 13, + "distinguishing_feature": "" + }, + "int": { + "value": 12, + "distinguishing_feature": "" + }, + "pow": { + "value": 11, + "distinguishing_feature": "" + }, + "cha": { + "value": 10, + "distinguishing_feature": "" + } + }, + + "biography": { + "profession": "Astronomer", + "employer": "", + "nationality": "", + "sex": "F", + "age": "23", + "education": "" + } + } + } +]}