diff --git a/app/imports/api/campaign/Party.js b/app/imports/api/campaign/Party.js index 92461adf..41ce048c 100644 --- a/app/imports/api/campaign/Party.js +++ b/app/imports/api/campaign/Party.js @@ -10,10 +10,13 @@ let partySchema = new SimpleSchema({ optional: true, }, characters: { - type: [String], + type: Array, + defaultValue: [], + }, + characters: { + type: String, regEx: SimpleSchema.RegEx.Id, index: 1, - defaultValue: [], }, owner: { type: String, diff --git a/app/imports/api/creature/CreatureDefaults.js b/app/imports/api/creature/CreatureDefaults.js index 9e00e12d..4d88a87d 100644 --- a/app/imports/api/creature/CreatureDefaults.js +++ b/app/imports/api/creature/CreatureDefaults.js @@ -72,3 +72,5 @@ getDefaultCreatureDocs = function(charId, creatureType = "pc"){ } return docs; } + +export default getDefaultCreatureDocs; diff --git a/app/imports/api/creature/Creatures.js b/app/imports/api/creature/Creatures.js index 42bbbb0b..a20bb0a0 100644 --- a/app/imports/api/creature/Creatures.js +++ b/app/imports/api/creature/Creatures.js @@ -1,8 +1,9 @@ import { ValidatedMethod } from 'meteor/mdg:validated-method'; import SimpleSchema from 'simpl-schema'; import Effects from "/imports/api/creature/Effects.js" -import deathSaveSchema from "/imports/api/creature/subSchemas/DeathSaves.js" +import deathSaveSchema from "/imports/api/creature/subSchemas/DeathSavesSchema.js" import ColorSchema from "/imports/api/creature/subSchemas/ColorSchema.js"; +import getDefaultCreatureDocs from "/imports/api/creature/CreatureDefaults.js"; //set up the collection for creatures Creatures = new Mongo.Collection("creatures"); @@ -32,9 +33,11 @@ let creatureSchema = new SimpleSchema({ //permissions party: {type: String, regEx: SimpleSchema.RegEx.Id, optional: true}, owner: {type: String, regEx: SimpleSchema.RegEx.Id, index: 1}, - readers: {type: [String], regEx: SimpleSchema.RegEx.Id, defaultValue: [], index: 1}, - writers: {type: [String], regEx: SimpleSchema.RegEx.Id, defaultValue: [], index: 1}, - //TODO add per-creature settings + readers: {type: Array, defaultValue: []}, + "readers.$": {type: String, regEx: SimpleSchema.RegEx.Id, index: 1}, + writers: {type: Array, defaultValue: []}, + "writers.$": {type: String, regEx: SimpleSchema.RegEx.Id, index: 1}, + settings: {type: Object}, //how many experiences to load at a time in XP table "settings.experiencesInc": {type: SimpleSchema.Integer, defaultValue: 20}, //slowed down by carrying too much? @@ -144,7 +147,7 @@ if (Meteor.isServer){ }); //give characters default items - Characters.after.insert(function(userId, char) { + Creatures.after.insert(function(userId, char) { if (Meteor.isServer){ var containerId = Containers.insert({ name: "Coin Pouch", diff --git a/app/imports/api/library/Library.js b/app/imports/api/library/Library.js index 6688d0e5..74ecbe95 100644 --- a/app/imports/api/library/Library.js +++ b/app/imports/api/library/Library.js @@ -1,6 +1,8 @@ +import SimpleSchema from 'simpl-schema'; + Libraries = new Mongo.Collection("library"); -Schemas.Library = new SimpleSchema({ +librarySchema = new SimpleSchema({ name: {type: String}, owner: {type: String, regEx: SimpleSchema.RegEx.Id}, readers: {type: [String], regEx: SimpleSchema.RegEx.Id, defaultValue: []}, @@ -8,7 +10,7 @@ Schemas.Library = new SimpleSchema({ public: {type: Boolean, defaultValue: false}, }); -Libraries.attachSchema(Schemas.Library); +Libraries.attachSchema(librarySchema); Libraries.allow({ insert(userId, doc) { @@ -45,3 +47,5 @@ Libraries.canEdit = function(userId, libraryId){ const library = Libraries.findOne(libraryId); return canEdit(userId, library); }; + +export default Libraries; diff --git a/app/imports/api/library/LibraryItems.js b/app/imports/api/library/LibraryItems.js index 20a02a94..9d4f937f 100644 --- a/app/imports/api/library/LibraryItems.js +++ b/app/imports/api/library/LibraryItems.js @@ -1,6 +1,9 @@ +import SimpleSchema from 'simpl-schema'; +import libraryAttacksSchema from "/imports/api/library/"; + LibraryItems = new Mongo.Collection("libraryItems"); -Schemas.LibraryItems = new SimpleSchema({ +libraryItemsSchema = new SimpleSchema({ libraryName:{type: String, optional: true, trim: false}, name: {type: String, defaultValue: "New Item", trim: false}, plural: {type: String, optional: true, trim: false}, @@ -12,6 +15,7 @@ Schemas.LibraryItems = new SimpleSchema({ library: {type: String, regEx: SimpleSchema.RegEx.Id, index: 1}, + settings: {type: Object}, "settings.category": { type: String, optional: true, @@ -24,11 +28,11 @@ Schemas.LibraryItems = new SimpleSchema({ defaultValue: false, }, - effects: {type: [Schemas.LibraryEffects], defaultValue: []}, - attacks: {type: [Schemas.LibraryAttacks], defaultValue: []}, + effects: [Schemas.LibraryEffects], + attacks: [Schemas.LibraryAttacks], }); -LibraryItems.attachSchema(Schemas.LibraryItems); +LibraryItems.attachSchema(libraryItemsSchema); LibraryItems.allow({ insert(userId, doc) { diff --git a/app/imports/server/publications/index.js b/app/imports/server/publications/index.js index 3c957ef0..e0e0d145 100644 --- a/app/imports/server/publications/index.js +++ b/app/imports/server/publications/index.js @@ -1,5 +1,5 @@ -import "characterList.js"; -import "library.js"; -import "singleCharacter.js"; -import "user.js"; -import "users.js"; +import "./characterList.js"; +import "./library.js"; +import "./singleCharacter.js"; +import "./user.js"; +import "./users.js"; diff --git a/app/imports/server/publications/library.js b/app/imports/server/publications/library.js index 8bb65a00..97ea2b3f 100644 --- a/app/imports/server/publications/library.js +++ b/app/imports/server/publications/library.js @@ -1,4 +1,4 @@ -import Libraries from "/imports/api/library/library.js" +import Libraries from "/imports/api/library/Library.js" const standardLibraryIds = [ "SRDLibraryGA3XWsd",