Finished migrating creatures to simpl-schema
This commit is contained in:
@@ -90,12 +90,13 @@ const insertCharacter = new ValidatedMethod({
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Create the creature document
|
// Create the creature document
|
||||||
Creatures.insert({name, owner: this.userId});
|
let charId = Creatures.insert({name, owner: this.userId});
|
||||||
this.unblock();
|
this.unblock();
|
||||||
//Add all the required attributes to it
|
//Add all the required attributes to it
|
||||||
if (Meteor.isServer){
|
if (Meteor.isServer){
|
||||||
addDefaultStats(charId);
|
addDefaultStats(charId);
|
||||||
}
|
}
|
||||||
|
return charId;
|
||||||
},
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
@@ -141,6 +142,67 @@ if (Meteor.isServer){
|
|||||||
doc.settings.newUserExperience = true;
|
doc.settings.newUserExperience = true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//give characters default items
|
||||||
|
Characters.after.insert(function(userId, char) {
|
||||||
|
if (Meteor.isServer){
|
||||||
|
var containerId = Containers.insert({
|
||||||
|
name: "Coin Pouch",
|
||||||
|
charId: char._id,
|
||||||
|
isCarried: true,
|
||||||
|
description: "A sturdy pouch for coins",
|
||||||
|
color: "d",
|
||||||
|
});
|
||||||
|
Items.insert({
|
||||||
|
name: "Gold piece",
|
||||||
|
plural: "Gold pieces",
|
||||||
|
charId: char._id,
|
||||||
|
quantity: 0,
|
||||||
|
weight: 0.02,
|
||||||
|
value: 1,
|
||||||
|
color: "n",
|
||||||
|
parent: {
|
||||||
|
id: containerId,
|
||||||
|
collection: "Containers",
|
||||||
|
},
|
||||||
|
settings: {
|
||||||
|
showIncrement: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
Items.insert({
|
||||||
|
name: "Silver piece",
|
||||||
|
plural: "Silver pieces",
|
||||||
|
charId: char._id,
|
||||||
|
quantity: 0,
|
||||||
|
weight: 0.02,
|
||||||
|
value: 0.1,
|
||||||
|
color: "q",
|
||||||
|
parent: {
|
||||||
|
id: containerId,
|
||||||
|
collection: "Containers",
|
||||||
|
},
|
||||||
|
settings: {
|
||||||
|
showIncrement: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
Items.insert({
|
||||||
|
name: "Copper piece",
|
||||||
|
plural: "Copper pieces",
|
||||||
|
charId: char._id,
|
||||||
|
quantity: 0,
|
||||||
|
weight: 0.02,
|
||||||
|
value: 0.01,
|
||||||
|
color: "s",
|
||||||
|
parent: {
|
||||||
|
id: containerId,
|
||||||
|
collection: "Containers",
|
||||||
|
},
|
||||||
|
settings: {
|
||||||
|
showIncrement: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
Creatures.allow({
|
Creatures.allow({
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import ColorSchema from "/imports/api/creature/subSchemas/ColorSchema.js";
|
|||||||
|
|
||||||
Items = new Mongo.Collection("items");
|
Items = new Mongo.Collection("items");
|
||||||
|
|
||||||
Schemas.Item = new SimpleSchema({
|
itemSchema = new SimpleSchema({
|
||||||
name: {type: String, optional: true, trim: false, defaultValue: "New Item"},
|
name: {type: String, optional: true, trim: false, defaultValue: "New Item"},
|
||||||
plural: {type: String, optional: true, trim: false},
|
plural: {type: String, optional: true, trim: false},
|
||||||
description:{type: String, optional: true, trim: false},
|
description:{type: String, optional: true, trim: false},
|
||||||
@@ -14,10 +14,11 @@ Schemas.Item = new SimpleSchema({
|
|||||||
value: {type: Number, min: 0, defaultValue: 0},
|
value: {type: Number, min: 0, defaultValue: 0},
|
||||||
enabled: {type: Boolean, defaultValue: false},
|
enabled: {type: Boolean, defaultValue: false},
|
||||||
requiresAttunement: {type: Boolean, defaultValue: false},
|
requiresAttunement: {type: Boolean, defaultValue: false},
|
||||||
|
settings: {type: Object},
|
||||||
"settings.showIncrement": {type: Boolean, defaultValue: false},
|
"settings.showIncrement": {type: Boolean, defaultValue: false},
|
||||||
});
|
});
|
||||||
|
|
||||||
Items.attachSchema(Schemas.Item);
|
Items.attachSchema(itemSchema);
|
||||||
Items.attachSchema(ColorSchema);
|
Items.attachSchema(ColorSchema);
|
||||||
|
|
||||||
var checkMovePermission = function(itemId, parent) {
|
var checkMovePermission = function(itemId, parent) {
|
||||||
@@ -205,64 +206,3 @@ makeChild(Items); //children of containers
|
|||||||
makeParent(Items, ["name", "enabled"]); //parents of effects and attacks
|
makeParent(Items, ["name", "enabled"]); //parents of effects and attacks
|
||||||
|
|
||||||
//Items.allow(CHARACTER_SUBSCHEMA_ALLOW);
|
//Items.allow(CHARACTER_SUBSCHEMA_ALLOW);
|
||||||
|
|
||||||
//give characters default items
|
|
||||||
Characters.after.insert(function(userId, char) {
|
|
||||||
if (Meteor.isServer){
|
|
||||||
var containerId = Containers.insert({
|
|
||||||
name: "Coin Pouch",
|
|
||||||
charId: char._id,
|
|
||||||
isCarried: true,
|
|
||||||
description: "A sturdy pouch for coins",
|
|
||||||
color: "d",
|
|
||||||
});
|
|
||||||
Items.insert({
|
|
||||||
name: "Gold piece",
|
|
||||||
plural: "Gold pieces",
|
|
||||||
charId: char._id,
|
|
||||||
quantity: 0,
|
|
||||||
weight: 0.02,
|
|
||||||
value: 1,
|
|
||||||
color: "n",
|
|
||||||
parent: {
|
|
||||||
id: containerId,
|
|
||||||
collection: "Containers",
|
|
||||||
},
|
|
||||||
settings: {
|
|
||||||
showIncrement: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
Items.insert({
|
|
||||||
name: "Silver piece",
|
|
||||||
plural: "Silver pieces",
|
|
||||||
charId: char._id,
|
|
||||||
quantity: 0,
|
|
||||||
weight: 0.02,
|
|
||||||
value: 0.1,
|
|
||||||
color: "q",
|
|
||||||
parent: {
|
|
||||||
id: containerId,
|
|
||||||
collection: "Containers",
|
|
||||||
},
|
|
||||||
settings: {
|
|
||||||
showIncrement: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
Items.insert({
|
|
||||||
name: "Copper piece",
|
|
||||||
plural: "Copper pieces",
|
|
||||||
charId: char._id,
|
|
||||||
quantity: 0,
|
|
||||||
weight: 0.02,
|
|
||||||
value: 0.01,
|
|
||||||
color: "s",
|
|
||||||
parent: {
|
|
||||||
id: containerId,
|
|
||||||
collection: "Containers",
|
|
||||||
},
|
|
||||||
settings: {
|
|
||||||
showIncrement: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|||||||
Reference in New Issue
Block a user