tools for building a compendium of pregens

This commit is contained in:
TheLastScrub
2021-06-13 14:03:53 -07:00
parent 4703df4996
commit 4a8b7922d3
4 changed files with 211 additions and 0 deletions
+23
View File
@@ -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"
}
}
}
]
@@ -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"
}
}
}
]
+67
View File
@@ -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();
+87
View File
@@ -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": ""
}
}
}
]}