-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfvtt-export-foundry-data.js
180 lines (153 loc) · 3.85 KB
/
fvtt-export-foundry-data.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
let item_types = {
'adventuringgear': [
'Medical',
'Clothing',
'Utility',
'DataRecordingAndStorage',
'Storage',
'Communications',
'LifeSupport',
'WeaponOrArmorAccessory',
],
'consumables': [
'AlcoholicBeverage',
'Spice',
],
'blasters': [
'SimpleBlaster',
'MartialBlaster',
'ExoticBlaster',
],
'lightweapons': [
'SimpleLightweapon',
'MartialLightweapon',
'ExoticLightweapon',
],
'vibroweapons': [
'SimpleVibroweapon',
'MartialVibroweapon',
'Natural',
'ExoticVibroweapon',
],
'enhanceditems': [
'EnhancedAdventuringGear',
'EnhancedArmor',
'EnhancedConsumable',
'EnhancedFocus',
'EnhancedShield',
// 'EnhancedShipArmor',
// 'EnhancedShipShield',
// 'EnhancedShipWeapon',
'EnhancedWeapon',
],
'modifications': [
'EnhancedItemModification',
'EnhancedCyberneticAugmentation',
'EnhancedDroidCustomization',
],
'armor': ['Armor'],
'ammo': ['Ammunition'],
'explosives': ['Explosive'],
'implements': ['Tool'],
'kits': ['Kit'],
'gamingsets': ['GamingSet'],
'musicalinstruments': ['MusicalInstrument'],
'forcepowers': ['ForcePower'],
'techpowers': ['TechPower'],
'maneuvers': ['Maneuver'],
'archetypes': ['Archetype'],
'archetypefeatures': ['ArchetypeFeature'],
'classes': ['Class'],
'classfeatures': ['ClassFeature'],
'invocations': ['ClassInvocation'],
'species': ['Species'],
'speciesfeatures': ['SpeciesFeature'],
'backgrounds': ['Background'],
'feats': [
'Feat',
'ClassImprovement',
'MulticlassImprovement',
'SplashclassImprovement',
'WeaponFocus',
'WeaponSupremacy',
],
'fightingstyles': ['FightingStyle'],
'fightingmasteries': ['FightingMastery'],
'lightsaberforms': ['LightsaberForm'],
}
let journal_entry_types = {
'weaponproperties': ['WeaponProperty'],
'armorproperties': ['ArmorProperty'],
'conditions': ['Conditions']
}
let actor_types = {
'monsters_temp': ['Monster']
}
// item_types = {};
// journal_entry_types = {};
const foundry_data = {};
for (const type of Object.keys(item_types)) {
console.log(`Extracting from ${type} compendium`);
const pack = await game.packs.get(`sw5e.${type}`);
if (!pack) {
console.log(`Compendium pack sw5e.${type} not found`);
continue;
}
const pack_docs = await pack.getDocuments();
for(const pack_doc of pack_docs) {
const pack_item = pack_doc;
const uid = pack_item.flags["sw5e-importer"]?.uid ?? pack_item.flags.uid;
if (uid) {
foundry_data[uid] = {
id: pack_item._id,
effects: pack_item.effects
}
}
}
}
for (const type of Object.keys(journal_entry_types)) {
console.log(`Extracting from ${type} compendium`);
const pack = await game.packs.get(`sw5e.${type}`);
if (!pack) {
console.log(`Compendium pack sw5e.${type} not found`);
continue;
}
const pack_docs = await pack.getDocuments();
for(const pack_doc of pack_docs) {
const pack_entry = pack_doc;
const uid = pack_entry.flags["sw5e-importer"]?.uid ?? pack_entry.flags.uid;
if (uid) {
foundry_data[uid] = { id: pack_entry._id };
}
}
}
for (const type of Object.keys(actor_types)) {
console.log(`Extracting from ${type} compendium`);
const pack = await game.packs.get(`sw5e.${type}`);
if (!pack) {
console.log(`Compendium pack sw5e.${type} not found`);
continue;
}
const pack_docs = await pack.getDocuments();
for(const pack_doc of pack_docs) {
const pack_actor = pack_doc;
const actor_uid = pack_actor.flags["sw5e-importer"]?.uid ?? pack_actor.flags.uid;
if (actor_uid) {
const foundry_data_items = {};
for (const pack_item of pack_actor.items) {
const item_uid = pack_item.flags["sw5e-importer"]?.uid ?? pack_item.flags.uid;
foundry_data_items[item_uid] = {
id: pack_item._id,
effects: pack_item.effects
};
}
foundry_data[actor_uid] = {
id: pack_actor._id,
effects: pack_actor.effects,
sub_entities: foundry_data_items
}
}
}
}
console.log('Foundry Data:');
console.log(foundry_data);