diff --git a/backend/models/DatagenEntry.js b/backend/models/DatagenEntry.js index be6c7822..de0d23ec 100644 --- a/backend/models/DatagenEntry.js +++ b/backend/models/DatagenEntry.js @@ -4,7 +4,7 @@ const Schema = mongoose.Schema; const DatagenEntrySchema = new Schema({ id: {type: String, required: true}, schema: { type: String, required: true}, - data: { type: Object }, + data: { type: Object, default: {} }, datagen_collection: {type: mongoose.Types.ObjectId, ref: "DatagenCollection"}, }); diff --git a/backend/services/datagen.js b/backend/services/datagen.js index f693cbc8..510d4c53 100644 --- a/backend/services/datagen.js +++ b/backend/services/datagen.js @@ -69,7 +69,7 @@ async function appendDatagen(file, modelName, info, datagenCollection){ let fileData = JSON.parse(fs.readFileSync(file)); return await DatagenEntry.create({ id: fileData.id, - data: fileData.value, + data: fileData.value !== undefined ? fileData.value : {}, schema: modelName, datagen_collection: datagenCollection }); diff --git a/plugins/dnd-5e/client/main.js b/plugins/dnd-5e/client/main.js index 7ba4ae6c..3b2a0b10 100644 --- a/plugins/dnd-5e/client/main.js +++ b/plugins/dnd-5e/client/main.js @@ -1,4 +1,4 @@ -import { FetchConcepts, InitData } from "./data"; +import { FetchConcepts, GetConcepts, InitData } from "./data"; import { Global } from '@/services/PluginGlobals'; var dndModule; @@ -44,6 +44,8 @@ function Main(Api){ Api.createWindow(databaseWindow, { title: "Campaign items", id: 'campaign-items-window', + fetchConcepts: FetchConcepts, // Requests reactive ref update + getConcepts: GetConcepts, // Needs to return reactive ref value close: () => Api.clearWindow("campaign-items-window") }); } diff --git a/plugins/dnd-5e/client/views/Books.vue b/plugins/dnd-5e/client/views/Books.vue index 1c63f7bd..0a56fc57 100644 --- a/plugins/dnd-5e/client/views/Books.vue +++ b/plugins/dnd-5e/client/views/Books.vue @@ -37,19 +37,18 @@ function FetchBookList(){ } function OpenBook(element){ - console.log(element); - console.log("!!!!!"); dndModule.getDatagenData(element.id).then(response => { - console.log(response.data); Api.createWindow(PluginData.windows.database, { title: element.name, id: 'campaign-items-window', elements: response.data.elements, + transformer: (element) => element.data, topper: { icon: "/plugins/" + element.package + "/" + element.icon, title: element.name, description: element.desc }, + getConcepts: () => response.data.elements, close: () => Api.clearWindow("campaign-items-window") }); }); diff --git a/plugins/dnd-5e/client/views/Database.vue b/plugins/dnd-5e/client/views/Database.vue index 0e79c105..6347cc65 100644 --- a/plugins/dnd-5e/client/views/Database.vue +++ b/plugins/dnd-5e/client/views/Database.vue @@ -38,22 +38,33 @@ onMounted(() => { SetResizable(id, true); SetMinSize(id, {width: 800, height: 300}); - watch(GetConcepts, () => { - let elements = GetConcepts(); - weapons.value = elements.filter((e) => e.type == "Weapon"); - equipment.value = elements.filter((e) => e.type == "Equipment"); - consumables.value = elements.filter((e) => e.type == "Consumable"); - containers.value = elements.filter((e) => e.type == "Container"); - tools.value = elements.filter((e) => e.type == "Tool"); - spells.value = elements.filter((e) => e.type == "Spell"); - features.value = elements.filter((e) => e.type == "Feature"); + // console.log(data); - console.log(elements); - console.log(elements); + watch(data.getConcepts, () => { + updateView(); }); - FetchConcepts(); + if(data.fetchConcepts) data.fetchConcepts(); + updateView(); }); + +function updateView(){ + let elements = data.getConcepts(); + if(data.transformer) elements = elements.map(element => data.transformer(element)); + + console.log(elements); + + weapons.value = elements.filter((e) => e.type == "Weapon"); + equipment.value = elements.filter((e) => e.type == "Equipment"); + consumables.value = elements.filter((e) => e.type == "Consumable"); + containers.value = elements.filter((e) => e.type == "Container"); + tools.value = elements.filter((e) => e.type == "Tool"); + spells.value = elements.filter((e) => e.type == "Spell"); + features.value = elements.filter((e) => e.type == "Feature"); + + console.log(elements); +} + function OpenCreateItemPrompt(){ Api.createWindow(PluginData.windows.create_item_prompt, {id: 'create_item_prompt', title: 'Create Item', close: () => Api.clearWindow('create_item_prompt')}) } diff --git a/plugins/dnd-5e/datagen/dnd-5e-dm-manual/data/effect/test_effect.json b/plugins/dnd-5e/datagen/dnd-5e-dm-manual/data/effect/test_effect.json deleted file mode 100644 index a0fc6c4a..00000000 --- a/plugins/dnd-5e/datagen/dnd-5e-dm-manual/data/effect/test_effect.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "id": "effects/test_effect", - "value": {} -} \ No newline at end of file diff --git a/plugins/dnd-5e/datagen/dnd-5e-dm-manual/data/item/consumables/test_consumable.json b/plugins/dnd-5e/datagen/dnd-5e-dm-manual/data/item/consumables/test_consumable.json deleted file mode 100644 index a6ed6885..00000000 --- a/plugins/dnd-5e/datagen/dnd-5e-dm-manual/data/item/consumables/test_consumable.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "id": "consumables/test_consumable", - "value": {} -} \ No newline at end of file diff --git a/plugins/dnd-5e/datagen/dnd-5e-dm-manual/data/item/containers/test_container.json b/plugins/dnd-5e/datagen/dnd-5e-dm-manual/data/item/containers/test_container.json deleted file mode 100644 index 11ddc8d8..00000000 --- a/plugins/dnd-5e/datagen/dnd-5e-dm-manual/data/item/containers/test_container.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "id": "container/test_container", - "value": {} -} \ No newline at end of file diff --git a/plugins/dnd-5e/datagen/dnd-5e-dm-manual/data/item/equipment/test_equipment.json b/plugins/dnd-5e/datagen/dnd-5e-dm-manual/data/item/equipment/test_equipment.json deleted file mode 100644 index 361a07c6..00000000 --- a/plugins/dnd-5e/datagen/dnd-5e-dm-manual/data/item/equipment/test_equipment.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "id": "equipment/test_equipment", - "value": {} -} \ No newline at end of file diff --git a/plugins/dnd-5e/datagen/dnd-5e-dm-manual/data/item/features/test_feature.json b/plugins/dnd-5e/datagen/dnd-5e-dm-manual/data/item/features/test_feature.json deleted file mode 100644 index aafc4739..00000000 --- a/plugins/dnd-5e/datagen/dnd-5e-dm-manual/data/item/features/test_feature.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "id": "feature/test_feature", - "value": {} -} \ No newline at end of file diff --git a/plugins/dnd-5e/datagen/dnd-5e-dm-manual/data/item/spells/test_spell.json b/plugins/dnd-5e/datagen/dnd-5e-dm-manual/data/item/spells/test_spell.json deleted file mode 100644 index 4f091bc4..00000000 --- a/plugins/dnd-5e/datagen/dnd-5e-dm-manual/data/item/spells/test_spell.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "id": "spells/test_spell", - "value": {} -} \ No newline at end of file diff --git a/plugins/dnd-5e/datagen/dnd-5e-dm-manual/data/item/tools/test_tool.json b/plugins/dnd-5e/datagen/dnd-5e-dm-manual/data/item/tools/test_tool.json deleted file mode 100644 index e48370fc..00000000 --- a/plugins/dnd-5e/datagen/dnd-5e-dm-manual/data/item/tools/test_tool.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "id": "tools/test_tool", - "value": {} -} \ No newline at end of file diff --git a/plugins/dnd-5e/datagen/dnd-5e-dm-manual/data/item/weapons/test_weapon.json b/plugins/dnd-5e/datagen/dnd-5e-dm-manual/data/item/weapons/test_weapon.json index c9844fec..865d2a33 100644 --- a/plugins/dnd-5e/datagen/dnd-5e-dm-manual/data/item/weapons/test_weapon.json +++ b/plugins/dnd-5e/datagen/dnd-5e-dm-manual/data/item/weapons/test_weapon.json @@ -1,5 +1,5 @@ { - "id": "weapon/test_weapon", + "id": "weapons/test_weapon", "value": { "name": "Test datagen weapon", "description": "Test test test", @@ -10,7 +10,7 @@ "weight": "10", "price": "10", "data": { - "weapon_type": "Natural", + "weapon_type": "Natural", "properties": [ "Finesse" ] diff --git a/plugins/dnd-5e/datagen/dnd-5e-dm-manual/data/monster/test_monster.json b/plugins/dnd-5e/datagen/dnd-5e-dm-manual/data/monster/test_monster.json deleted file mode 100644 index 818a5698..00000000 --- a/plugins/dnd-5e/datagen/dnd-5e-dm-manual/data/monster/test_monster.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "id": "monsters/test_monster", - "value": {} -} \ No newline at end of file diff --git a/plugins/dnd-5e/datagen/dnd-5e-dm-manual/data/progressable/classes/test_class.json b/plugins/dnd-5e/datagen/dnd-5e-dm-manual/data/progressable/classes/test_class.json deleted file mode 100644 index f6b44d86..00000000 --- a/plugins/dnd-5e/datagen/dnd-5e-dm-manual/data/progressable/classes/test_class.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "id": "classes/test_class", - "value": {} -} \ No newline at end of file diff --git a/plugins/dnd-5e/datagen/dnd-5e-dm-manual/data/progressable/races/test_race.json b/plugins/dnd-5e/datagen/dnd-5e-dm-manual/data/progressable/races/test_race.json deleted file mode 100644 index e486d974..00000000 --- a/plugins/dnd-5e/datagen/dnd-5e-dm-manual/data/progressable/races/test_race.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "id": "races/test_race", - "value": {} -} \ No newline at end of file diff --git a/plugins/dnd-5e/datagen/dnd-5e-dm-manual/data/table/test_table.json b/plugins/dnd-5e/datagen/dnd-5e-dm-manual/data/table/test_table.json deleted file mode 100644 index c03fadce..00000000 --- a/plugins/dnd-5e/datagen/dnd-5e-dm-manual/data/table/test_table.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "id": "table/test_table", - "value": {} -} \ No newline at end of file diff --git a/plugins/dnd-5e/datagen/dnd-5e-monster-manual/data/effect/test_effect.json b/plugins/dnd-5e/datagen/dnd-5e-monster-manual/data/effect/test_effect.json deleted file mode 100644 index a0fc6c4a..00000000 --- a/plugins/dnd-5e/datagen/dnd-5e-monster-manual/data/effect/test_effect.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "id": "effects/test_effect", - "value": {} -} \ No newline at end of file diff --git a/plugins/dnd-5e/datagen/dnd-5e-monster-manual/data/item/consumables/test_consumable.json b/plugins/dnd-5e/datagen/dnd-5e-monster-manual/data/item/consumables/test_consumable.json deleted file mode 100644 index a6ed6885..00000000 --- a/plugins/dnd-5e/datagen/dnd-5e-monster-manual/data/item/consumables/test_consumable.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "id": "consumables/test_consumable", - "value": {} -} \ No newline at end of file diff --git a/plugins/dnd-5e/datagen/dnd-5e-monster-manual/data/item/containers/test_container.json b/plugins/dnd-5e/datagen/dnd-5e-monster-manual/data/item/containers/test_container.json deleted file mode 100644 index 11ddc8d8..00000000 --- a/plugins/dnd-5e/datagen/dnd-5e-monster-manual/data/item/containers/test_container.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "id": "container/test_container", - "value": {} -} \ No newline at end of file diff --git a/plugins/dnd-5e/datagen/dnd-5e-monster-manual/data/item/equipment/test_equipment.json b/plugins/dnd-5e/datagen/dnd-5e-monster-manual/data/item/equipment/test_equipment.json deleted file mode 100644 index 361a07c6..00000000 --- a/plugins/dnd-5e/datagen/dnd-5e-monster-manual/data/item/equipment/test_equipment.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "id": "equipment/test_equipment", - "value": {} -} \ No newline at end of file diff --git a/plugins/dnd-5e/datagen/dnd-5e-monster-manual/data/item/features/test_feature.json b/plugins/dnd-5e/datagen/dnd-5e-monster-manual/data/item/features/test_feature.json deleted file mode 100644 index aafc4739..00000000 --- a/plugins/dnd-5e/datagen/dnd-5e-monster-manual/data/item/features/test_feature.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "id": "feature/test_feature", - "value": {} -} \ No newline at end of file diff --git a/plugins/dnd-5e/datagen/dnd-5e-monster-manual/data/item/spells/test_spell.json b/plugins/dnd-5e/datagen/dnd-5e-monster-manual/data/item/spells/test_spell.json deleted file mode 100644 index 4f091bc4..00000000 --- a/plugins/dnd-5e/datagen/dnd-5e-monster-manual/data/item/spells/test_spell.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "id": "spells/test_spell", - "value": {} -} \ No newline at end of file diff --git a/plugins/dnd-5e/datagen/dnd-5e-monster-manual/data/item/tools/test_tool.json b/plugins/dnd-5e/datagen/dnd-5e-monster-manual/data/item/tools/test_tool.json deleted file mode 100644 index e48370fc..00000000 --- a/plugins/dnd-5e/datagen/dnd-5e-monster-manual/data/item/tools/test_tool.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "id": "tools/test_tool", - "value": {} -} \ No newline at end of file diff --git a/plugins/dnd-5e/datagen/dnd-5e-monster-manual/data/item/weapons/test_weapon.json b/plugins/dnd-5e/datagen/dnd-5e-monster-manual/data/item/weapons/test_weapon.json deleted file mode 100644 index c9844fec..00000000 --- a/plugins/dnd-5e/datagen/dnd-5e-monster-manual/data/item/weapons/test_weapon.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "id": "weapon/test_weapon", - "value": { - "name": "Test datagen weapon", - "description": "Test test test", - "icon": "icons/weapons/ammunition/shot-round-blue.webp", - "type": "Weapon", - "rarity": "Rare", - "quantity": "1", - "weight": "10", - "price": "10", - "data": { - "weapon_type": "Natural", - "properties": [ - "Finesse" - ] - } - } -} \ No newline at end of file diff --git a/plugins/dnd-5e/datagen/dnd-5e-monster-manual/data/monster/test_monster.json b/plugins/dnd-5e/datagen/dnd-5e-monster-manual/data/monster/test_monster.json index 818a5698..18bf1790 100644 --- a/plugins/dnd-5e/datagen/dnd-5e-monster-manual/data/monster/test_monster.json +++ b/plugins/dnd-5e/datagen/dnd-5e-monster-manual/data/monster/test_monster.json @@ -1,4 +1,6 @@ { "id": "monsters/test_monster", - "value": {} + "value": { + + } } \ No newline at end of file diff --git a/plugins/dnd-5e/datagen/dnd-5e-monster-manual/data/progressable/classes/test_class.json b/plugins/dnd-5e/datagen/dnd-5e-monster-manual/data/progressable/classes/test_class.json deleted file mode 100644 index f6b44d86..00000000 --- a/plugins/dnd-5e/datagen/dnd-5e-monster-manual/data/progressable/classes/test_class.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "id": "classes/test_class", - "value": {} -} \ No newline at end of file diff --git a/plugins/dnd-5e/datagen/dnd-5e-monster-manual/data/progressable/races/test_race.json b/plugins/dnd-5e/datagen/dnd-5e-monster-manual/data/progressable/races/test_race.json deleted file mode 100644 index e486d974..00000000 --- a/plugins/dnd-5e/datagen/dnd-5e-monster-manual/data/progressable/races/test_race.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "id": "races/test_race", - "value": {} -} \ No newline at end of file diff --git a/plugins/dnd-5e/datagen/dnd-5e-monster-manual/data/table/test_table.json b/plugins/dnd-5e/datagen/dnd-5e-monster-manual/data/table/test_table.json deleted file mode 100644 index c03fadce..00000000 --- a/plugins/dnd-5e/datagen/dnd-5e-monster-manual/data/table/test_table.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "id": "table/test_table", - "value": {} -} \ No newline at end of file diff --git a/plugins/dnd-5e/datagen/dnd-5e-player-manual/data/effect/test_effect.json b/plugins/dnd-5e/datagen/dnd-5e-player-manual/data/effect/test_effect.json deleted file mode 100644 index a0fc6c4a..00000000 --- a/plugins/dnd-5e/datagen/dnd-5e-player-manual/data/effect/test_effect.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "id": "effects/test_effect", - "value": {} -} \ No newline at end of file diff --git a/plugins/dnd-5e/datagen/dnd-5e-player-manual/data/item/consumables/test_consumable.json b/plugins/dnd-5e/datagen/dnd-5e-player-manual/data/item/consumables/test_consumable.json deleted file mode 100644 index a6ed6885..00000000 --- a/plugins/dnd-5e/datagen/dnd-5e-player-manual/data/item/consumables/test_consumable.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "id": "consumables/test_consumable", - "value": {} -} \ No newline at end of file diff --git a/plugins/dnd-5e/datagen/dnd-5e-player-manual/data/item/containers/test_container.json b/plugins/dnd-5e/datagen/dnd-5e-player-manual/data/item/containers/test_container.json deleted file mode 100644 index 11ddc8d8..00000000 --- a/plugins/dnd-5e/datagen/dnd-5e-player-manual/data/item/containers/test_container.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "id": "container/test_container", - "value": {} -} \ No newline at end of file diff --git a/plugins/dnd-5e/datagen/dnd-5e-player-manual/data/item/equipment/test_equipment.json b/plugins/dnd-5e/datagen/dnd-5e-player-manual/data/item/equipment/test_equipment.json deleted file mode 100644 index 361a07c6..00000000 --- a/plugins/dnd-5e/datagen/dnd-5e-player-manual/data/item/equipment/test_equipment.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "id": "equipment/test_equipment", - "value": {} -} \ No newline at end of file diff --git a/plugins/dnd-5e/datagen/dnd-5e-player-manual/data/item/features/test_feature.json b/plugins/dnd-5e/datagen/dnd-5e-player-manual/data/item/features/test_feature.json deleted file mode 100644 index aafc4739..00000000 --- a/plugins/dnd-5e/datagen/dnd-5e-player-manual/data/item/features/test_feature.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "id": "feature/test_feature", - "value": {} -} \ No newline at end of file diff --git a/plugins/dnd-5e/datagen/dnd-5e-player-manual/data/item/spells/test_spell.json b/plugins/dnd-5e/datagen/dnd-5e-player-manual/data/item/spells/test_spell.json deleted file mode 100644 index 4f091bc4..00000000 --- a/plugins/dnd-5e/datagen/dnd-5e-player-manual/data/item/spells/test_spell.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "id": "spells/test_spell", - "value": {} -} \ No newline at end of file diff --git a/plugins/dnd-5e/datagen/dnd-5e-player-manual/data/item/tools/test_tool.json b/plugins/dnd-5e/datagen/dnd-5e-player-manual/data/item/tools/test_tool.json deleted file mode 100644 index e48370fc..00000000 --- a/plugins/dnd-5e/datagen/dnd-5e-player-manual/data/item/tools/test_tool.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "id": "tools/test_tool", - "value": {} -} \ No newline at end of file diff --git a/plugins/dnd-5e/datagen/dnd-5e-player-manual/data/item/weapons/test_weapon.json b/plugins/dnd-5e/datagen/dnd-5e-player-manual/data/item/weapons/test_weapon.json deleted file mode 100644 index c9844fec..00000000 --- a/plugins/dnd-5e/datagen/dnd-5e-player-manual/data/item/weapons/test_weapon.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "id": "weapon/test_weapon", - "value": { - "name": "Test datagen weapon", - "description": "Test test test", - "icon": "icons/weapons/ammunition/shot-round-blue.webp", - "type": "Weapon", - "rarity": "Rare", - "quantity": "1", - "weight": "10", - "price": "10", - "data": { - "weapon_type": "Natural", - "properties": [ - "Finesse" - ] - } - } -} \ No newline at end of file diff --git a/plugins/dnd-5e/datagen/dnd-5e-player-manual/data/monster/test_monster.json b/plugins/dnd-5e/datagen/dnd-5e-player-manual/data/monster/test_monster.json deleted file mode 100644 index 818a5698..00000000 --- a/plugins/dnd-5e/datagen/dnd-5e-player-manual/data/monster/test_monster.json +++ /dev/null @@ -1,4 +0,0 @@ -{ - "id": "monsters/test_monster", - "value": {} -} \ No newline at end of file