Updated simpl-schema and collection2, started untangling the mess that made
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
|
||||
let Actions = new Mongo.Collection("actions");
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import {makeChild} from "/imports/api/parenting.js";
|
||||
|
||||
let Attacks = new Mongo.Collection("attacks");
|
||||
|
||||
/*
|
||||
@@ -51,15 +54,6 @@ attackSchema = new SimpleSchema({
|
||||
],
|
||||
defaultValue: "slashing",
|
||||
},
|
||||
//the id of the feature, buff or item that created this effect
|
||||
parent: {
|
||||
type: Schemas.Parent
|
||||
},
|
||||
color: {
|
||||
type: String,
|
||||
allowedValues: _.pluck(colorOptions, "key"),
|
||||
defaultValue: "q",
|
||||
},
|
||||
enabled: {
|
||||
type: Boolean,
|
||||
defaultValue: true,
|
||||
@@ -68,7 +62,7 @@ attackSchema = new SimpleSchema({
|
||||
|
||||
Attacks.attachSchema(attackSchema);
|
||||
|
||||
Attacks.attachBehaviour("softRemovable");
|
||||
//Attacks.attachBehaviour("softRemovable");
|
||||
makeChild(Attacks, ["name", "enabled"]); //children of lots of things
|
||||
|
||||
Attacks.after.insert(function (userId, attack) {
|
||||
@@ -83,7 +77,4 @@ Attacks.after.insert(function (userId, attack) {
|
||||
}
|
||||
});
|
||||
|
||||
Attacks.allow(CHARACTER_SUBSCHEMA_ALLOW);
|
||||
Attacks.deny(CHARACTER_SUBSCHEMA_DENY);
|
||||
|
||||
export default Attacks;
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import {makeChild} from "/imports/api/parenting.js";
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import ColorSchema from "/imports/api/creature/subSchemas/ColorSchema.js";
|
||||
|
||||
let Attributes = new Mongo.Collection("attributes");
|
||||
|
||||
@@ -78,6 +80,7 @@ attributeSchema = new SimpleSchema({
|
||||
});
|
||||
|
||||
Attributes.attachSchema(attributeSchema);
|
||||
Attributes.attachSchema(ColorSchema);
|
||||
|
||||
Attributes.attachBehaviour("softRemovable");
|
||||
makeChild(Attributes, ["enabled"]); //children of lots of things
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
Buffs = new Mongo.Collection("buffs");
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import {makeParent} from "/imports/api/parenting.js";
|
||||
import ColorSchema from "/imports/api/creature/subSchemas/ColorSchema.js";
|
||||
|
||||
Schemas.Buff = new SimpleSchema({
|
||||
let Buffs = new Mongo.Collection("buffs");
|
||||
|
||||
let buffSchema = new SimpleSchema({
|
||||
charId: {
|
||||
type: String,
|
||||
regEx: SimpleSchema.RegEx.Id,
|
||||
@@ -27,6 +31,9 @@ Schemas.Buff = new SimpleSchema({
|
||||
"custom",
|
||||
],
|
||||
},
|
||||
lifeTime: {
|
||||
type: Object,
|
||||
},
|
||||
"lifeTime.total": {
|
||||
type: Number,
|
||||
defaultValue: 0, //0 is infinite
|
||||
@@ -37,11 +44,6 @@ Schemas.Buff = new SimpleSchema({
|
||||
defaultValue: 0,
|
||||
min: 0,
|
||||
},
|
||||
color: {
|
||||
type: String,
|
||||
allowedValues: _.pluck(colorOptions, "key"),
|
||||
defaultValue: "q",
|
||||
},
|
||||
appliedBy: { //the charId of whoever applied the buff
|
||||
type: String,
|
||||
regEx: SimpleSchema.RegEx.Id,
|
||||
@@ -58,10 +60,10 @@ Schemas.Buff = new SimpleSchema({
|
||||
},
|
||||
});
|
||||
|
||||
Buffs.attachSchema(Schemas.Buff);
|
||||
Buffs.attachSchema(buffSchema);
|
||||
Buffs.attachSchema(ColorSchema);
|
||||
|
||||
Buffs.attachBehaviour("softRemovable");
|
||||
//Buffs.attachBehaviour("softRemovable");
|
||||
makeParent(Buffs, ["name", "enabled"]); //parents of effects, attacks, proficiencies
|
||||
|
||||
Buffs.allow(CHARACTER_SUBSCHEMA_ALLOW);
|
||||
Buffs.deny(CHARACTER_SUBSCHEMA_DENY);
|
||||
export default Buffs;
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
Classes = new Mongo.Collection("classes");
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import {makeParent} from "/imports/api/parenting.js";
|
||||
import ColorSchema from "/imports/api/creature/subSchemas/ColorSchema.js";
|
||||
|
||||
Schemas.Class = new SimpleSchema({
|
||||
let Classes = new Mongo.Collection("classes");
|
||||
|
||||
classSchema= new SimpleSchema({
|
||||
charId: {type: String, regEx: SimpleSchema.RegEx.Id, index: 1},
|
||||
name: {type: String, optional: true, trim: false},
|
||||
level: {type: Number},
|
||||
@@ -16,17 +20,12 @@ Schemas.Class = new SimpleSchema({
|
||||
}
|
||||
},
|
||||
},
|
||||
color: {
|
||||
type: String,
|
||||
allowedValues: _.pluck(colorOptions, "key"),
|
||||
defaultValue: "q",
|
||||
},
|
||||
});
|
||||
|
||||
Classes.attachSchema(Schemas.Class);
|
||||
Classes.attachSchema(classSchema);
|
||||
Classes.attachSchema(ColorSchema);
|
||||
|
||||
Classes.attachBehaviour("softRemovable");
|
||||
//Classes.attachBehaviour("softRemovable");
|
||||
makeParent(Classes, "name"); //parents of effects and attacks
|
||||
|
||||
Classes.allow(CHARACTER_SUBSCHEMA_ALLOW);
|
||||
Classes.deny(CHARACTER_SUBSCHEMA_DENY);
|
||||
export default Classes;
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
Conditions = new Mongo.Collection("conditions");
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import {makeParent} from "/imports/api/parenting.js";
|
||||
import ColorSchema from "/imports/api/creature/subSchemas/ColorSchema.js";
|
||||
|
||||
Schemas.Conditions = new SimpleSchema({
|
||||
let Conditions = new Mongo.Collection("conditions");
|
||||
|
||||
conditionSchema = new SimpleSchema({
|
||||
charId: {
|
||||
type: String,
|
||||
regEx: SimpleSchema.RegEx.Id,
|
||||
@@ -26,17 +30,12 @@ Schemas.Conditions = new SimpleSchema({
|
||||
defaultValue: 0,
|
||||
min: 0,
|
||||
},
|
||||
color: {
|
||||
type: String,
|
||||
allowedValues: _.pluck(colorOptions, "key"),
|
||||
defaultValue: "q",
|
||||
},
|
||||
});
|
||||
|
||||
Conditions.attachSchema(Schemas.Conditions);
|
||||
Conditions.attachSchema(conditionSchema);
|
||||
Conditions.attachSchema(ColorSchema);
|
||||
|
||||
Conditions.attachBehaviour("softRemovable");
|
||||
//Conditions.attachBehaviour("softRemovable");
|
||||
makeParent(Conditions, ["name"]); //parents of effects, attacks, proficiencies
|
||||
|
||||
Conditions.allow(CHARACTER_SUBSCHEMA_ALLOW);
|
||||
Conditions.deny(CHARACTER_SUBSCHEMA_DENY);
|
||||
export default Conditions;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
||||
import Effects from "/imports/api/creature/Effects.js"
|
||||
import deathSaveSchema from "/imports/api/creature/subSchemas/DeathSaves.js"
|
||||
import ColorSchema from "/imports/api/creature/subSchemas/ColorSchema.js";
|
||||
|
||||
//set up the collection for creatures
|
||||
Creatures = new Mongo.Collection("creatures");
|
||||
@@ -32,12 +33,6 @@ let creatureSchema = new SimpleSchema({
|
||||
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},
|
||||
color: {
|
||||
type: String,
|
||||
defaultValue: "#9E9E9E",
|
||||
// match hex colors of the form #A23 or #A23f56
|
||||
regEx: /^#([a-f0-9]{3}){1,2}\b$/i,
|
||||
},
|
||||
//TODO add per-creature settings
|
||||
//how many experiences to load at a time in XP table
|
||||
"settings.experiencesInc": {type: Number, defaultValue: 20},
|
||||
@@ -61,6 +56,7 @@ let creatureSchema = new SimpleSchema({
|
||||
});
|
||||
|
||||
Creatures.attachSchema(creatureSchema);
|
||||
Creatures.attachSchema(ColorSchema);
|
||||
|
||||
Creatures.calculate = {
|
||||
xpLevel: function(charId){
|
||||
|
||||
@@ -37,15 +37,11 @@ Schemas.CustomBuff = new SimpleSchema({
|
||||
defaultValue: 0, //0 is infinite
|
||||
min: 0,
|
||||
},
|
||||
//the id of the feature, buff or item that creates this buff
|
||||
parent: {
|
||||
type: Schemas.Parent,
|
||||
},
|
||||
});
|
||||
|
||||
CustomBuffs.attachSchema(Schemas.CustomBuff);
|
||||
|
||||
CustomBuffs.attachBehaviour("softRemovable");
|
||||
//CustomBuffs.attachBehaviour("softRemovable");
|
||||
makeParent(CustomBuffs, ["name", "enabled"]); //parents of effects, attacks, proficiencies. Since this represents a template, "enabled" is always false.
|
||||
makeChild(CustomBuffs); //children of lots of things
|
||||
|
||||
|
||||
@@ -22,9 +22,6 @@ Schemas.DamageMultiplier = new SimpleSchema({
|
||||
decimal: true,
|
||||
defaultValue: 1,
|
||||
},
|
||||
parent: {
|
||||
type: Schemas.Parent
|
||||
},
|
||||
enabled: {
|
||||
type: Boolean,
|
||||
defaultValue: true,
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
Features = new Mongo.Collection("features");
|
||||
import ColorSchema from "/imports/api/creature/subSchemas/ColorSchema.js";
|
||||
|
||||
Schemas.Feature = new SimpleSchema({
|
||||
charId: {type: String, regEx: SimpleSchema.RegEx.Id, index: 1},
|
||||
@@ -13,13 +14,10 @@ Schemas.Feature = new SimpleSchema({
|
||||
},
|
||||
enabled: {type: Boolean, defaultValue: true},
|
||||
alwaysEnabled:{type: Boolean, defaultValue: true},
|
||||
color: {type: String,
|
||||
allowedValues: _.pluck(colorOptions, "key"),
|
||||
defaultValue: "q",
|
||||
},
|
||||
});
|
||||
|
||||
Features.attachSchema(Schemas.Feature);
|
||||
Features.attachSchema(ColorSchema);
|
||||
|
||||
Features.helpers({
|
||||
usesLeft: function(){
|
||||
@@ -30,12 +28,9 @@ Features.helpers({
|
||||
},
|
||||
});
|
||||
|
||||
Features.attachBehaviour("softRemovable");
|
||||
//Features.attachBehaviour("softRemovable");
|
||||
makeParent(Features, ["name", "enabled"]); //parents of effects and attacks
|
||||
|
||||
Features.allow(CHARACTER_SUBSCHEMA_ALLOW);
|
||||
Features.deny(CHARACTER_SUBSCHEMA_DENY);
|
||||
|
||||
//give characters default feature of base ability scores of 10
|
||||
Characters.after.insert(function(userId, char) {
|
||||
if (Meteor.isServer){
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
Notes = new Mongo.Collection("notes");
|
||||
import ColorSchema from "/imports/api/creature/subSchemas/ColorSchema.js";
|
||||
|
||||
Schemas.Note = new SimpleSchema({
|
||||
charId: {type: String, regEx: SimpleSchema.RegEx.Id, index: 1},
|
||||
name: {type: String, optional: true, trim: false},
|
||||
description: {type: String, optional: true, trim: false},
|
||||
color: {
|
||||
type: String,
|
||||
allowedValues:_.pluck(colorOptions, "key"),
|
||||
defaultValue: "q",
|
||||
},
|
||||
});
|
||||
|
||||
Notes.attachSchema(Schemas.Note);
|
||||
Attributes.attachSchema(ColorSchema);
|
||||
|
||||
Notes.attachBehaviour("softRemovable");
|
||||
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
SpellLists = new Mongo.Collection("spellLists");
|
||||
import ColorSchema from "/imports/api/creature/subSchemas/ColorSchema.js";
|
||||
|
||||
Schemas.SpellLists = new SimpleSchema({
|
||||
charId: {type: String, regEx: SimpleSchema.RegEx.Id, index: 1},
|
||||
@@ -7,15 +8,11 @@ Schemas.SpellLists = new SimpleSchema({
|
||||
saveDC: {type: String, optional: true, trim: false},
|
||||
attackBonus: {type: String, optional: true, trim: false},
|
||||
maxPrepared: {type: String, optional: true, trim: false},
|
||||
color: {
|
||||
type: String,
|
||||
allowedValues: _.pluck(colorOptions, "key"),
|
||||
defaultValue: "q",
|
||||
},
|
||||
"settings.showUnprepared": {type: Boolean, defaultValue: true},
|
||||
});
|
||||
|
||||
SpellLists.attachSchema(Schemas.SpellLists);
|
||||
Attributes.attachSchema(ColorSchema);
|
||||
|
||||
SpellLists.helpers({
|
||||
numPrepared: function(){
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
Spells = new Mongo.Collection("spells");
|
||||
import ColorSchema from "/imports/api/creature/subSchemas/ColorSchema.js";
|
||||
|
||||
Schemas.Spell = new SimpleSchema({
|
||||
charId: {type: String, regEx: SimpleSchema.RegEx.Id, index: 1},
|
||||
@@ -52,14 +53,10 @@ Schemas.Spell = new SimpleSchema({
|
||||
defaultValue: "Abjuration",
|
||||
allowedValues: magicSchools,
|
||||
},
|
||||
color: {
|
||||
type: String,
|
||||
allowedValues: _.pluck(colorOptions, "key"),
|
||||
defaultValue: "q",
|
||||
},
|
||||
});
|
||||
|
||||
Spells.attachSchema(Schemas.Spell);
|
||||
Attributes.attachSchema(ColorSchema);
|
||||
|
||||
Spells.attachBehaviour("softRemovable");
|
||||
makeChild(Spells); //children of spell lists
|
||||
@@ -249,4 +246,4 @@ Meteor.methods({
|
||||
check(charId, String);
|
||||
copySpell(spellId, "Characters", charId);
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,41 +0,0 @@
|
||||
TemporaryHitPoints = new Mongo.Collection("temporaryHitPoints");
|
||||
|
||||
Schemas.TemporaryHitPoints = new SimpleSchema({
|
||||
charId: {type: String, regEx: SimpleSchema.RegEx.Id, index: 1},
|
||||
name: {type: String, optional: true},
|
||||
maximum: {type: Number, defaultValue: 0, min: 0, max: 500},
|
||||
used: {type: Number, defaultValue: 0, min: 0, max: 500},
|
||||
deleteOnZero:{type: Boolean, defaultValue: false},
|
||||
dateAdded: {
|
||||
type: Date,
|
||||
autoValue: function() {
|
||||
if (this.isInsert) {
|
||||
return new Date();
|
||||
} else if (this.isUpsert) {
|
||||
return {$setOnInsert: new Date()};
|
||||
} else {
|
||||
this.unset();
|
||||
}
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
TemporaryHitPoints.attachSchema(Schemas.TemporaryHitPoints);
|
||||
|
||||
TemporaryHitPoints.helpers({
|
||||
left: function(){
|
||||
return this.maximum - this.used;
|
||||
}
|
||||
});
|
||||
|
||||
//remove the temporary hit points when they hit zero
|
||||
TemporaryHitPoints.after.update(
|
||||
function(userId, thp, fieldNames, modifier, options){
|
||||
if (thp.used >= thp.maximum && thp.deleteOnZero){
|
||||
TemporaryHitPoints.remove(thp._id);
|
||||
}
|
||||
}, {fetchPrevious: false}
|
||||
);
|
||||
|
||||
TemporaryHitPoints.allow(CHARACTER_SUBSCHEMA_ALLOW);
|
||||
TemporaryHitPoints.deny(CHARACTER_SUBSCHEMA_DENY);
|
||||
11
app/imports/api/creature/subSchemas/ColorSchema.js
Normal file
11
app/imports/api/creature/subSchemas/ColorSchema.js
Normal file
@@ -0,0 +1,11 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
const ColorSchema = new SimpleSchema({
|
||||
color: {
|
||||
type: String,
|
||||
defaultValue: "#9E9E9E",
|
||||
// match hex colors of the form #A23 or #A23f56
|
||||
regEx: /^#([a-f0-9]{3}){1,2}\b$/i,
|
||||
},
|
||||
});
|
||||
|
||||
export default ColorSchema;
|
||||
@@ -1,4 +1,5 @@
|
||||
const deathSaveSchema = new SimpleSchema({
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
const DeathSavesSchema = new SimpleSchema({
|
||||
pass: {
|
||||
type: Number,
|
||||
min: 0,
|
||||
@@ -21,4 +22,4 @@ const deathSaveSchema = new SimpleSchema({
|
||||
},
|
||||
});
|
||||
|
||||
export default deathSaveSchema;
|
||||
export default DeathSavesSchema;
|
||||
@@ -1,3 +1,4 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
||||
|
||||
let childSchema = new SimpleSchema({
|
||||
|
||||
Reference in New Issue
Block a user