Fixed inserting new characters. No wizard though

This commit is contained in:
Thaum Rystra
2020-02-29 17:31:21 +02:00
parent acb9369100
commit 692a7983f8
10 changed files with 123 additions and 78 deletions

View File

@@ -3,10 +3,6 @@ import deathSaveSchema from "/imports/api/properties/subSchemas/DeathSavesSchema
import ColorSchema from "/imports/api/properties/subSchemas/ColorSchema.js";
import SharingSchema from '/imports/api/sharing/SharingSchema.js';
//Methods
import '/imports/api/creature/insertCreature.js';
import '/imports/api/creature/removeCreature.js';
//set up the collection for creatures
Creatures = new Mongo.Collection("creatures");
@@ -95,5 +91,27 @@ CreatureSchema.extend(SharingSchema);
Creatures.attachSchema(CreatureSchema);
const insertCreature = new ValidatedMethod({
name: "Creatures.methods.insertCreature",
validate: null,
run() {
if (!this.userId) {
throw new Meteor.Error("Creatures.methods.insert.denied",
"You need to be logged in to insert a creature");
}
// Create the creature document
let charId = Creatures.insert({
owner: this.userId,
});
this.unblock();
return charId;
},
});
export default Creatures;
export { CreatureSchema };
export { CreatureSchema, insertCreature };

View File

@@ -1,40 +0,0 @@
import getDefaultCharacterDocs from '/imports/api/creature/getDefaultCharacterDocs.js';
import Attributes from '/imports/api/properties/Attributes.js';
import Skills from '/imports/api/properties/Skills.js';
import DamageMultipliers from '/imports/api/properties/DamageMultipliers.js';
import Effects from '/imports/api/properties/Effects.js';
import Containers from '/imports/api/properties/Containers.js';
import Items from '/imports/api/properties/Items.js';
const addDefaultDocs = function(docs){
Attributes.rawCollection().insert(docs.attributes, {ordered: false});
Skills.rawCollection().insert(docs.skills, {ordered: false});
DamageMultipliers.rawCollection().insert(docs.damageMultipliers, {ordered: false});
Effects.rawCollection().insert(docs.effects, {ordered: false});
Containers.rawCollection().insert(docs.containers, {ordered: false});
Items.rawCollection().insert(docs.items, {ordered: false});
};
const insertCreature = new ValidatedMethod({
name: "Creatures.methods.insertCreature",
validate: null,
run() {
if (!this.userId) {
throw new Meteor.Error("Creatures.methods.insert.denied",
"You need to be logged in to insert a creature");
}
// Create the creature document
let charId = Creatures.insert({
owner: this.userId,
});
this.unblock();
return charId;
},
});
export default insertCreature;