Removed all separate property collections to be replaced with a single "creature property" collection
This commit is contained in:
79
app/imports/api/creature/CreatureProperties.js
Normal file
79
app/imports/api/creature/CreatureProperties.js
Normal file
@@ -0,0 +1,79 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import schema from '/imports/api/schema.js';
|
||||
import ChildSchema from '/imports/api/parenting/ChildSchema.js';
|
||||
import propertySchemas from '/imports/api/properties/propertySchemas.js';
|
||||
import Libraries from '/imports/api/library/Libraries.js';
|
||||
import { assertEditPermission } from '/imports/api/sharing/sharingPermissions.js';
|
||||
import getModifierFields from '/imports/api/getModifierFields.js';
|
||||
|
||||
let CreatureProperties = new Mongo.Collection('creatureProperties');
|
||||
|
||||
let CreaturePropertySchema = schema({
|
||||
creaturePropertyType: {
|
||||
type: String,
|
||||
allowedValues: Object.keys(propertySchemas),
|
||||
},
|
||||
charId: {
|
||||
type: String,
|
||||
regEx: SimpleSchema.RegEx.Id,
|
||||
index: 1,
|
||||
optional: true,
|
||||
},
|
||||
});
|
||||
|
||||
for (let key in propertySchemas){
|
||||
let schema = new SimpleSchema({});
|
||||
schema.extend(propertySchemas[key]);
|
||||
schema.extend(CreaturePropertySchema);
|
||||
schema.extend(ChildSchema);
|
||||
CreatureProperties.attachSchema(schema, {
|
||||
selector: {creaturePropertyType: key}
|
||||
});
|
||||
}
|
||||
|
||||
const adjustAttribute = new ValidatedMethod({
|
||||
name: 'Attributes.methods.adjust',
|
||||
mixins: [
|
||||
simpleSchemaMixin,
|
||||
creaturePermissionMixin,
|
||||
],
|
||||
collection: Attributes,
|
||||
permission: 'edit',
|
||||
schema: new SimpleSchema({
|
||||
_id: SimpleSchema.RegEx.Id,
|
||||
type: {
|
||||
type: String,
|
||||
allowedValues: ['set', 'increment']
|
||||
},
|
||||
value: Number,
|
||||
}),
|
||||
run({_id, type, value}) {
|
||||
if (type === 'set'){
|
||||
let currentValue = currentAttribute.value;
|
||||
// Set represents what we want the value to be after adjustment
|
||||
// So we need the actual adjustment to get to that value
|
||||
let adjustment = value - currentValue;
|
||||
// Ajustment can't exceed total value
|
||||
if (-adjustment > currentValue) adjustment = -currentValue;
|
||||
// Adjustment must be negative
|
||||
if (adjustment > 0) adjustment = 0;
|
||||
return Attributes.update(_id, {$set: {adjustment}});
|
||||
} else if (type === 'increment'){
|
||||
let remaining = currentAttribute.value + (currentAttribute.adjustment || 0);
|
||||
let adj = currentAttribute.adjustment;
|
||||
// Can't decrease adjustment below remaining value
|
||||
let increment = value;
|
||||
if (-increment > remaining) increment = -remaining;
|
||||
// Can't increase adjustment above zero
|
||||
if (increment > -adj) increment = -adj;
|
||||
if (typeof currentAttribute.adjustment === 'number'){
|
||||
return Attributes.update(_id, {$inc: {adjustment: increment}});
|
||||
} else {
|
||||
return Attributes.update(_id, {$set: {adjustment: increment}});
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
export default CreatureProperties;
|
||||
export { CreaturePropertySchema};
|
||||
@@ -2,18 +2,6 @@ import SimpleSchema from 'simpl-schema';
|
||||
import schema from '/imports/api/schema.js';
|
||||
import AdjustmentSchema from '/imports/api/creature/subSchemas/AdjustmentSchema.js';
|
||||
import StoredBuffSchema from '/imports/api/properties/Buffs.js';
|
||||
import { PropertySchema } from '/imports/api/properties/Properties.js'
|
||||
import ColorSchema from '/imports/api/creature/subSchemas/ColorSchema.js';
|
||||
|
||||
// Mixins
|
||||
import creaturePermissionMixin from '/imports/api/creature/mixins/creaturePermissionMixin.js';
|
||||
import { setDocToLastMixin } from '/imports/api/creature/mixins/setDocToLastMixin.js';
|
||||
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
||||
import simpleSchemaMixin from '/imports/api/creature/mixins/simpleSchemaMixin.js';
|
||||
import propagateInheritanceUpdateMixin from '/imports/api/creature/mixins/propagateInheritanceUpdateMixin.js';
|
||||
import updateSchemaMixin from '/imports/api/creature/mixins/updateSchemaMixin.js';
|
||||
|
||||
let Actions = new Mongo.Collection('actions');
|
||||
|
||||
/*
|
||||
* Actions are things a character can do
|
||||
@@ -21,7 +9,7 @@ let Actions = new Mongo.Collection('actions');
|
||||
* Any actions that are children of this action will be considered alternatives
|
||||
* to this action
|
||||
*/
|
||||
let ActionSchema = schema({
|
||||
let ActionSchema = new SimpleSchema({
|
||||
name: {
|
||||
type: String,
|
||||
optional: true,
|
||||
@@ -93,39 +81,4 @@ let ActionSchema = schema({
|
||||
},
|
||||
});
|
||||
|
||||
ActionSchema.extend(ColorSchema);
|
||||
|
||||
Actions.attachSchema(ActionSchema);
|
||||
Actions.attachSchema(PropertySchema);
|
||||
|
||||
const insertAction = new ValidatedMethod({
|
||||
name: 'Actions.methods.insert',
|
||||
mixins: [
|
||||
creaturePermissionMixin,
|
||||
setDocAncestryMixin,
|
||||
ensureAncestryContainsCharIdMixin,
|
||||
setDocToLastMixin,
|
||||
simpleSchemaMixin,
|
||||
],
|
||||
collection: Actions,
|
||||
permission: 'edit',
|
||||
schema: ActionSchema,
|
||||
run(action) {
|
||||
return Actions.insert(action);
|
||||
},
|
||||
});
|
||||
|
||||
const updateAction = new ValidatedMethod({
|
||||
name: 'Actions.methods.update',
|
||||
mixins: [
|
||||
propagateInheritanceUpdateMixin,
|
||||
updateSchemaMixin,
|
||||
creaturePermissionMixin,
|
||||
],
|
||||
collection: Actions,
|
||||
permission: 'edit',
|
||||
schema: ActionSchema,
|
||||
});
|
||||
|
||||
export default Actions;
|
||||
export { ActionSchema, insertAction, updateAction };
|
||||
export default { ActionSchema };
|
||||
|
||||
@@ -1,31 +1,12 @@
|
||||
import { PropertySchema } from '/imports/api/properties/Properties.js'
|
||||
import ColorSchema from '/imports/api/creature/subSchemas/ColorSchema.js';
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import schema from '/imports/api/schema.js';
|
||||
import VARIABLE_NAME_REGEX from '/imports/constants/VARIABLE_NAME_REGEX.js';
|
||||
import getModifierFields from '/imports/api/getModifierFields.js';
|
||||
|
||||
// Mixins
|
||||
import recomputeCreatureMixin from '/imports/api/creature/mixins/recomputeCreatureMixin.js';
|
||||
import creaturePermissionMixin from '/imports/api/creature/mixins/creaturePermissionMixin.js';
|
||||
import { setDocToLastMixin } from '/imports/api/creature/mixins/setDocToLastMixin.js';
|
||||
import {
|
||||
setDocAncestryMixin,
|
||||
ensureAncestryContainsCharIdMixin
|
||||
} from '/imports/api/parenting/parenting.js';
|
||||
import simpleSchemaMixin from '/imports/api/creature/mixins/simpleSchemaMixin.js';
|
||||
import updateSchemaMixin from '/imports/api/creature/mixins/updateSchemaMixin.js';
|
||||
import propagateInheritanceUpdateMixin from '/imports/api/creature/mixins/propagateInheritanceUpdateMixin.js';
|
||||
|
||||
let Attributes = new Mongo.Collection('attributes');
|
||||
|
||||
/*
|
||||
* Attributes are numbered stats of a character
|
||||
*/
|
||||
let AttributeSchema = schema({
|
||||
let AttributeSchema = new SimpleSchema({
|
||||
name: {
|
||||
type: String,
|
||||
optional: true,
|
||||
defaultValue: 'New Attribute',
|
||||
},
|
||||
// The technical, lowercase, single-word name used in formulae
|
||||
@@ -81,9 +62,7 @@ let AttributeSchema = schema({
|
||||
},
|
||||
});
|
||||
|
||||
AttributeSchema.extend(ColorSchema);
|
||||
|
||||
const ComputedAttributeSchema = schema({
|
||||
let ComputedAttributeSchema = schema({
|
||||
// The computed value of the attribute
|
||||
value: {
|
||||
type: Number,
|
||||
@@ -96,91 +75,4 @@ const ComputedAttributeSchema = schema({
|
||||
},
|
||||
}).extend(AttributeSchema);
|
||||
|
||||
Attributes.attachSchema(ComputedAttributeSchema);
|
||||
Attributes.attachSchema(PropertySchema);
|
||||
|
||||
const insertAttribute = new ValidatedMethod({
|
||||
name: 'Attributes.methods.insert',
|
||||
mixins: [
|
||||
setDocAncestryMixin,
|
||||
ensureAncestryContainsCharIdMixin,
|
||||
recomputeCreatureMixin,
|
||||
creaturePermissionMixin,
|
||||
setDocToLastMixin,
|
||||
simpleSchemaMixin,
|
||||
],
|
||||
collection: Attributes,
|
||||
permission: 'edit',
|
||||
schema: AttributeSchema,
|
||||
run(attribute) {
|
||||
return Attributes.insert(attribute);
|
||||
},
|
||||
});
|
||||
|
||||
const updateAttribute = new ValidatedMethod({
|
||||
name: 'Attributes.methods.update',
|
||||
mixins: [
|
||||
recomputeCreatureMixin,
|
||||
propagateInheritanceUpdateMixin,
|
||||
updateSchemaMixin,
|
||||
creaturePermissionMixin,
|
||||
],
|
||||
collection: Attributes,
|
||||
permission: 'edit',
|
||||
schema: AttributeSchema.omit(['adjutment']),
|
||||
skipRecompute({update}){
|
||||
let fields = getModifierFields(update);
|
||||
return !fields.hasAny([
|
||||
'variableName',
|
||||
'type',
|
||||
'baseValue',
|
||||
]);
|
||||
},
|
||||
});
|
||||
|
||||
const adjustAttribute = new ValidatedMethod({
|
||||
name: 'Attributes.methods.adjust',
|
||||
mixins: [
|
||||
simpleSchemaMixin,
|
||||
creaturePermissionMixin,
|
||||
],
|
||||
collection: Attributes,
|
||||
permission: 'edit',
|
||||
schema: new SimpleSchema({
|
||||
_id: SimpleSchema.RegEx.Id,
|
||||
type: {
|
||||
type: String,
|
||||
allowedValues: ['set', 'increment']
|
||||
},
|
||||
value: Number,
|
||||
}),
|
||||
run({_id, type, value}) {
|
||||
if (type === 'set'){
|
||||
let currentValue = currentAttribute.value;
|
||||
// Set represents what we want the value to be after adjustment
|
||||
// So we need the actual adjustment to get to that value
|
||||
let adjustment = value - currentValue;
|
||||
// Ajustment can't exceed total value
|
||||
if (-adjustment > currentValue) adjustment = -currentValue;
|
||||
// Adjustment must be negative
|
||||
if (adjustment > 0) adjustment = 0;
|
||||
return Attributes.update(_id, {$set: {adjustment}});
|
||||
} else if (type === 'increment'){
|
||||
let remaining = currentAttribute.value + (currentAttribute.adjustment || 0);
|
||||
let adj = currentAttribute.adjustment;
|
||||
// Can't decrease adjustment below remaining value
|
||||
let increment = value;
|
||||
if (-increment > remaining) increment = -remaining;
|
||||
// Can't increase adjustment above zero
|
||||
if (increment > -adj) increment = -adj;
|
||||
if (typeof currentAttribute.adjustment === 'number'){
|
||||
return Attributes.update(_id, {$inc: {adjustment: increment}});
|
||||
} else {
|
||||
return Attributes.update(_id, {$set: {adjustment: increment}});
|
||||
}
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
export default Attributes;
|
||||
export { AttributeSchema, insertAttribute, updateAttribute, adjustAttribute };
|
||||
export { AttributeSchema, ComputedAttributeSchema };
|
||||
|
||||
@@ -1,18 +1,6 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import schema from '/imports/api/schema.js';
|
||||
import { PropertySchema } from '/imports/api/properties/Properties.js'
|
||||
import { EffectSchema } from '/imports/api/properties/Effects.js';
|
||||
|
||||
// Mixins
|
||||
import creaturePermissionMixin from '/imports/api/creature/mixins/creaturePermissionMixin.js';
|
||||
import { setDocToLastMixin } from '/imports/api/creature/mixins/setDocToLastMixin.js';
|
||||
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
||||
import simpleSchemaMixin from '/imports/api/creature/mixins/simpleSchemaMixin.js';
|
||||
import propagateInheritanceUpdateMixin from '/imports/api/creature/mixins/propagateInheritanceUpdateMixin.js';
|
||||
import updateSchemaMixin from '/imports/api/creature/mixins/updateSchemaMixin.js';
|
||||
|
||||
let Buffs = new Mongo.Collection('buffs');
|
||||
|
||||
let BuffSchema = new SimpleSchema({
|
||||
_id: {
|
||||
type: String,
|
||||
@@ -57,7 +45,7 @@ let StoredBuffSchema = new SimpleSchema({
|
||||
},
|
||||
}).extend(BuffSchema);
|
||||
|
||||
let AppliedBuffSchema = schema({
|
||||
let AppliedBuffSchema = new SimpleSchema({
|
||||
durationSpent: {
|
||||
type: Number,
|
||||
optional: true,
|
||||
@@ -78,37 +66,4 @@ let AppliedBuffSchema = schema({
|
||||
},
|
||||
}).extend(BuffSchema);
|
||||
|
||||
Buffs.attachSchema(AppliedBuffSchema);
|
||||
Buffs.attachSchema(PropertySchema);
|
||||
|
||||
const insertBuff = new ValidatedMethod({
|
||||
name: 'Buffs.methods.insert',
|
||||
mixins: [
|
||||
creaturePermissionMixin,
|
||||
setDocAncestryMixin,
|
||||
ensureAncestryContainsCharIdMixin,
|
||||
setDocToLastMixin,
|
||||
simpleSchemaMixin,
|
||||
],
|
||||
collection: Buffs,
|
||||
permission: 'edit',
|
||||
schema: BuffSchema,
|
||||
run(buff) {
|
||||
return Buffs.insert(buff);
|
||||
},
|
||||
});
|
||||
|
||||
const updateBuff = new ValidatedMethod({
|
||||
name: 'Buffs.methods.update',
|
||||
mixins: [
|
||||
propagateInheritanceUpdateMixin,
|
||||
updateSchemaMixin,
|
||||
creaturePermissionMixin,
|
||||
],
|
||||
collection: Buffs,
|
||||
permission: 'edit',
|
||||
schema: BuffSchema,
|
||||
});
|
||||
|
||||
export default Buffs;
|
||||
export { AppliedBuffSchema, StoredBuffSchema, insertBuff, updateBuff };
|
||||
export { AppliedBuffSchema, StoredBuffSchema };
|
||||
|
||||
@@ -1,19 +1,8 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import schema from '/imports/api/schema.js';
|
||||
import { PropertySchema } from '/imports/api/properties/Properties.js'
|
||||
import VARIABLE_NAME_REGEX from '/imports/constants/VARIABLE_NAME_REGEX.js';
|
||||
|
||||
// Mixins
|
||||
import creaturePermissionMixin from '/imports/api/creature/mixins/creaturePermissionMixin.js';
|
||||
import { setDocToLastMixin } from '/imports/api/creature/mixins/setDocToLastMixin.js';
|
||||
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
||||
import simpleSchemaMixin from '/imports/api/creature/mixins/simpleSchemaMixin.js';
|
||||
import propagateInheritanceUpdateMixin from '/imports/api/creature/mixins/propagateInheritanceUpdateMixin.js';
|
||||
import updateSchemaMixin from '/imports/api/creature/mixins/updateSchemaMixin.js';
|
||||
|
||||
let ClassLevels = new Mongo.Collection("classLevels");
|
||||
|
||||
let ClassLevelSchema = schema({
|
||||
let ClassLevelSchema = new SimpleSchema({
|
||||
name: {
|
||||
type: String,
|
||||
optional: true,
|
||||
@@ -35,39 +24,4 @@ let ClassLevelSchema = schema({
|
||||
},
|
||||
});
|
||||
|
||||
ClassLevels.attachSchema(ClassLevelSchema);
|
||||
ClassLevels.attachSchema(PropertySchema);
|
||||
|
||||
// Todo ensure the class level is being parented to a compatible class, and that
|
||||
// previous level requirements are met
|
||||
const insertClassLevel = new ValidatedMethod({
|
||||
name: 'ClassLevels.methods.insert',
|
||||
mixins: [
|
||||
creaturePermissionMixin,
|
||||
setDocAncestryMixin,
|
||||
ensureAncestryContainsCharIdMixin,
|
||||
setDocToLastMixin,
|
||||
simpleSchemaMixin,
|
||||
],
|
||||
collection: ClassLevels,
|
||||
permission: 'edit',
|
||||
schema: ClassLevelSchema,
|
||||
run(classLevel) {
|
||||
return ClassLevels.insert(classLevel);
|
||||
},
|
||||
});
|
||||
|
||||
const updateClassLevel = new ValidatedMethod({
|
||||
name: 'ClassLevels.methods.update',
|
||||
mixins: [
|
||||
propagateInheritanceUpdateMixin,
|
||||
updateSchemaMixin,
|
||||
creaturePermissionMixin,
|
||||
],
|
||||
collection: ClassLevels,
|
||||
permission: 'edit',
|
||||
schema: ClassLevelSchema,
|
||||
});
|
||||
|
||||
export default ClassLevels;
|
||||
export { ClassLevelSchema, insertClassLevel, updateClassLevel };
|
||||
export { ClassLevelSchema };
|
||||
|
||||
@@ -1,21 +1,8 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import schema from '/imports/api/schema.js';
|
||||
import { PropertySchema } from '/imports/api/properties/Properties.js'
|
||||
import ColorSchema from "/imports/api/creature/subSchemas/ColorSchema.js";
|
||||
import VARIABLE_NAME_REGEX from '/imports/constants/VARIABLE_NAME_REGEX.js';
|
||||
|
||||
// Mixins
|
||||
import creaturePermissionMixin from '/imports/api/creature/mixins/creaturePermissionMixin.js';
|
||||
import { setDocToLastMixin } from '/imports/api/creature/mixins/setDocToLastMixin.js';
|
||||
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
||||
import simpleSchemaMixin from '/imports/api/creature/mixins/simpleSchemaMixin.js';
|
||||
import propagateInheritanceUpdateMixin from '/imports/api/creature/mixins/propagateInheritanceUpdateMixin.js';
|
||||
import updateSchemaMixin from '/imports/api/creature/mixins/updateSchemaMixin.js';
|
||||
|
||||
let Classes = new Mongo.Collection("classes");
|
||||
|
||||
// TODO use variable name in computation engine, rather than a generated one
|
||||
let ClassSchema = schema({
|
||||
let ClassSchema = new SimpleSchema({
|
||||
name: {
|
||||
type: String,
|
||||
optional: true,
|
||||
@@ -26,39 +13,4 @@ let ClassSchema = schema({
|
||||
},
|
||||
});
|
||||
|
||||
ClassSchema.extend(ColorSchema);
|
||||
|
||||
Classes.attachSchema(ClassSchema);
|
||||
Classes.attachSchema(PropertySchema);
|
||||
|
||||
const insertClass = new ValidatedMethod({
|
||||
name: 'Classes.methods.insert',
|
||||
mixins: [
|
||||
creaturePermissionMixin,
|
||||
setDocAncestryMixin,
|
||||
ensureAncestryContainsCharIdMixin,
|
||||
setDocToLastMixin,
|
||||
simpleSchemaMixin,
|
||||
],
|
||||
collection: Classes,
|
||||
permission: 'edit',
|
||||
schema: ClassSchema,
|
||||
run(cls) {
|
||||
return Classes.insert(cls);
|
||||
},
|
||||
});
|
||||
|
||||
const updateClass = new ValidatedMethod({
|
||||
name: 'Classes.methods.update',
|
||||
mixins: [
|
||||
propagateInheritanceUpdateMixin,
|
||||
updateSchemaMixin,
|
||||
creaturePermissionMixin,
|
||||
],
|
||||
collection: Classes,
|
||||
permission: 'edit',
|
||||
schema: ClassSchema,
|
||||
});
|
||||
|
||||
export default Classes;
|
||||
export { ClassSchema, insertClass, updateClass };
|
||||
export { ClassSchema };
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import schema from '/imports/api/schema.js';
|
||||
import ColorSchema from "/imports/api/creature/subSchemas/ColorSchema.js";
|
||||
import { PropertySchema } from '/imports/api/properties/Properties.js'
|
||||
import ChildSchema from '/imports/api/parenting/ChildSchema.js';
|
||||
|
||||
//set up the collection for containers
|
||||
let Containers = new Mongo.Collection("containers");
|
||||
|
||||
let ContainerSchema = schema({
|
||||
let ContainerSchema = new SimpleSchema({
|
||||
name: {
|
||||
type: String,
|
||||
optional: true,
|
||||
@@ -39,11 +35,4 @@ let ContainerSchema = schema({
|
||||
},
|
||||
});
|
||||
|
||||
ContainerSchema.extend(ColorSchema);
|
||||
|
||||
Containers.attachSchema(ContainerSchema);
|
||||
Containers.attachSchema(PropertySchema);
|
||||
Containers.attachSchema(ChildSchema);
|
||||
|
||||
export default Containers;
|
||||
export { ContainerSchema };
|
||||
|
||||
@@ -1,24 +1,11 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import schema from '/imports/api/schema.js';
|
||||
import { PropertySchema } from '/imports/api/properties/Properties.js'
|
||||
import DAMAGE_TYPES from '/imports/constants/DAMAGE_TYPES.js';
|
||||
|
||||
// Mixins
|
||||
import recomputeCreatureMixin from '/imports/api/creature/mixins/recomputeCreatureMixin.js';
|
||||
import creaturePermissionMixin from '/imports/api/creature/mixins/creaturePermissionMixin.js';
|
||||
import { setDocToLastMixin } from '/imports/api/creature/mixins/setDocToLastMixin.js';
|
||||
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
||||
import simpleSchemaMixin from '/imports/api/creature/mixins/simpleSchemaMixin.js';
|
||||
import propagateInheritanceUpdateMixin from '/imports/api/creature/mixins/propagateInheritanceUpdateMixin.js';
|
||||
import updateSchemaMixin from '/imports/api/creature/mixins/updateSchemaMixin.js';
|
||||
|
||||
let DamageMultipliers = new Mongo.Collection("damageMultipliers");
|
||||
|
||||
/*
|
||||
* DamageMultipliers are multipliers that affect how much damage is taken from
|
||||
* a given damage type
|
||||
*/
|
||||
let DamageMultiplierSchema = schema({
|
||||
let DamageMultiplierSchema = new SimpleSchema({
|
||||
name: {
|
||||
type: String,
|
||||
optional: true,
|
||||
@@ -37,39 +24,4 @@ let DamageMultiplierSchema = schema({
|
||||
},
|
||||
});
|
||||
|
||||
DamageMultipliers.attachSchema(DamageMultiplierSchema);
|
||||
DamageMultipliers.attachSchema(PropertySchema);
|
||||
|
||||
const insertDamageMultiplier = new ValidatedMethod({
|
||||
name: 'DamageMultipliers.methods.insert',
|
||||
mixins: [
|
||||
setDocAncestryMixin,
|
||||
ensureAncestryContainsCharIdMixin,
|
||||
recomputeCreatureMixin,
|
||||
setDocToLastMixin,
|
||||
simpleSchemaMixin,
|
||||
creaturePermissionMixin,
|
||||
],
|
||||
collection: DamageMultipliers,
|
||||
permission: 'edit',
|
||||
schema: DamageMultiplierSchema,
|
||||
run(dm) {
|
||||
return DamageMultipliers.insert(dm);
|
||||
},
|
||||
});
|
||||
|
||||
const updateDamageMultiplier = new ValidatedMethod({
|
||||
name: 'DamageMultipliers.methods.update',
|
||||
mixins: [
|
||||
recomputeCreatureMixin,
|
||||
propagateInheritanceUpdateMixin,
|
||||
updateSchemaMixin,
|
||||
creaturePermissionMixin,
|
||||
],
|
||||
collection: DamageMultipliers,
|
||||
permission: 'edit',
|
||||
schema: DamageMultiplierSchema,
|
||||
});
|
||||
|
||||
export default DamageMultipliers;
|
||||
export { DamageMultiplierSchema, insertDamageMultiplier, updateDamageMultiplier };
|
||||
export { DamageMultiplierSchema };
|
||||
|
||||
@@ -1,23 +1,13 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import schema from '/imports/api/schema.js';
|
||||
import { PropertySchema } from '/imports/api/properties/Properties.js'
|
||||
|
||||
// Mixins
|
||||
import recomputeCreatureMixin from '/imports/api/creature/mixins/recomputeCreatureMixin.js';
|
||||
import creaturePermissionMixin from '/imports/api/creature/mixins/creaturePermissionMixin.js';
|
||||
import { setDocToLastMixin } from '/imports/api/creature/mixins/setDocToLastMixin.js';
|
||||
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
||||
import simpleSchemaMixin from '/imports/api/creature/mixins/simpleSchemaMixin.js';
|
||||
import propagateInheritanceUpdateMixin from '/imports/api/creature/mixins/propagateInheritanceUpdateMixin.js';
|
||||
import updateSchemaMixin from '/imports/api/creature/mixins/updateSchemaMixin.js';
|
||||
|
||||
let Effects = new Mongo.Collection('effects');
|
||||
|
||||
/*
|
||||
* Effects are reason-value attached to skills and abilities
|
||||
* that modify their final value or presentation in some way
|
||||
*/
|
||||
let EffectSchema = schema({
|
||||
let EffectSchema = new SimpleSchema({
|
||||
_id: {
|
||||
type: String,
|
||||
regEx: SimpleSchema.RegEx.Id,
|
||||
@@ -56,7 +46,7 @@ let EffectSchema = schema({
|
||||
},
|
||||
});
|
||||
|
||||
const EffectComputedSchema = new SimpleSchema({
|
||||
const ComputedEffectSchema = new SimpleSchema({
|
||||
// The computed result of the effect
|
||||
result: {
|
||||
type: SimpleSchema.oneOf(Number, String),
|
||||
@@ -64,47 +54,4 @@ const EffectComputedSchema = new SimpleSchema({
|
||||
},
|
||||
}).extend(EffectSchema);
|
||||
|
||||
Effects.attachSchema(EffectComputedSchema);
|
||||
Effects.attachSchema(PropertySchema);
|
||||
|
||||
const insertEffect = new ValidatedMethod({
|
||||
name: 'Effects.methods.insert',
|
||||
mixins: [
|
||||
creaturePermissionMixin,
|
||||
setDocAncestryMixin,
|
||||
ensureAncestryContainsCharIdMixin,
|
||||
recomputeCreatureMixin,
|
||||
setDocToLastMixin,
|
||||
simpleSchemaMixin,
|
||||
],
|
||||
collection: Effects,
|
||||
permission: 'edit',
|
||||
schema: EffectSchema,
|
||||
run(effect) {
|
||||
return Effects.insert(effect);
|
||||
},
|
||||
});
|
||||
|
||||
const updateEffect = new ValidatedMethod({
|
||||
name: 'Effects.methods.update',
|
||||
mixins: [
|
||||
recomputeCreatureMixin,
|
||||
propagateInheritanceUpdateMixin,
|
||||
updateSchemaMixin,
|
||||
creaturePermissionMixin,
|
||||
],
|
||||
collection: Effects,
|
||||
permission: 'edit',
|
||||
schema: EffectSchema,
|
||||
skipRecompute({update}){
|
||||
let fields = getModifierFields(update);
|
||||
return !fields.hasAny([
|
||||
'operation',
|
||||
'calculation',
|
||||
'stat',
|
||||
]);
|
||||
},
|
||||
});
|
||||
|
||||
export default Effects;
|
||||
export { EffectSchema };
|
||||
export { EffectSchema, ComputedEffectSchema };
|
||||
|
||||
@@ -1,20 +1,6 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import schema from '/imports/api/schema.js';
|
||||
import { PropertySchema } from '/imports/api/properties/Properties.js'
|
||||
import recomputeCreatureXP from '/imports/api/creature/creatureComputation.js';
|
||||
|
||||
// Mixins
|
||||
import recomputeCreatureMixin from '/imports/api/creature/mixins/recomputeCreatureMixin.js';
|
||||
import creaturePermissionMixin from '/imports/api/creature/mixins/creaturePermissionMixin.js';
|
||||
import { setDocToLastMixin } from '/imports/api/creature/mixins/setDocToLastMixin.js';
|
||||
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
||||
import simpleSchemaMixin from '/imports/api/creature/mixins/simpleSchemaMixin.js';
|
||||
import propagateInheritanceUpdateMixin from '/imports/api/creature/mixins/propagateInheritanceUpdateMixin.js';
|
||||
import updateSchemaMixin from '/imports/api/creature/mixins/updateSchemaMixin.js';
|
||||
|
||||
let Experiences = new Mongo.Collection("experience");
|
||||
|
||||
let ExperienceSchema = schema({
|
||||
let ExperienceSchema = new SimpleSchema({
|
||||
title: {
|
||||
type: String,
|
||||
optional: true,
|
||||
@@ -46,56 +32,4 @@ let ExperienceSchema = schema({
|
||||
},
|
||||
});
|
||||
|
||||
Experiences.attachSchema(ExperienceSchema);
|
||||
Experiences.attachSchema(PropertySchema);
|
||||
|
||||
const insertExperience = new ValidatedMethod({
|
||||
name: 'Experiences.methods.insert',
|
||||
mixins: [
|
||||
creaturePermissionMixin,
|
||||
setDocAncestryMixin,
|
||||
ensureAncestryContainsCharIdMixin,
|
||||
recomputeCreatureMixin,
|
||||
setDocToLastMixin,
|
||||
simpleSchemaMixin,
|
||||
],
|
||||
collection: Experiences,
|
||||
permission: 'edit',
|
||||
schema: ExperienceSchema,
|
||||
skipRecompute(experience){
|
||||
return !experience.value;
|
||||
},
|
||||
run(experience) {
|
||||
let result = Experiences.insert(experience);
|
||||
if (experience.value){
|
||||
recomputeCreatureXP(charId);
|
||||
}
|
||||
return result;
|
||||
},
|
||||
});
|
||||
|
||||
const updateExperience = new ValidatedMethod({
|
||||
name: 'Experiences.methods.update',
|
||||
mixins: [
|
||||
recomputeCreatureMixin,
|
||||
propagateInheritanceUpdateMixin,
|
||||
updateSchemaMixin,
|
||||
creaturePermissionMixin,
|
||||
],
|
||||
collection: Experiences,
|
||||
permission: 'edit',
|
||||
schema: ExperienceSchema,
|
||||
skipRecompute({update}){
|
||||
return !('value' in update);
|
||||
},
|
||||
run({_id, update, charId}) {
|
||||
let result = Experiences.update(_id, {$set: update});
|
||||
if ('value' in update){
|
||||
recomputeCreatureXP(charId);
|
||||
}
|
||||
return result;
|
||||
},
|
||||
});
|
||||
|
||||
export default Experiences;
|
||||
export { ExperienceSchema, insertExperience, updateExperience };
|
||||
export { ExperienceSchema };
|
||||
|
||||
@@ -1,22 +1,8 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import schema from '/imports/api/schema.js';
|
||||
import { PropertySchema } from '/imports/api/properties/Properties.js'
|
||||
import ColorSchema from '/imports/api/creature/subSchemas/ColorSchema.js';
|
||||
|
||||
// Mixins
|
||||
import creaturePermissionMixin from '/imports/api/creature/mixins/creaturePermissionMixin.js';
|
||||
import { setDocToLastMixin } from '/imports/api/creature/mixins/setDocToLastMixin.js';
|
||||
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
||||
import simpleSchemaMixin from '/imports/api/creature/mixins/simpleSchemaMixin.js';
|
||||
import propagateInheritanceUpdateMixin from '/imports/api/creature/mixins/propagateInheritanceUpdateMixin.js';
|
||||
import updateSchemaMixin from '/imports/api/creature/mixins/updateSchemaMixin.js';
|
||||
|
||||
let Features = new Mongo.Collection('features');
|
||||
|
||||
let FeatureSchema = new SimpleSchema({
|
||||
name: {
|
||||
type: String,
|
||||
optional: true,
|
||||
},
|
||||
enabled: {
|
||||
type: Boolean,
|
||||
@@ -32,39 +18,4 @@ let FeatureSchema = new SimpleSchema({
|
||||
},
|
||||
});
|
||||
|
||||
FeatureSchema.extend(ColorSchema);
|
||||
|
||||
Features.attachSchema(FeatureSchema);
|
||||
Features.attachSchema(PropertySchema);
|
||||
|
||||
const insertFeature = new ValidatedMethod({
|
||||
name: 'Features.methods.insert',
|
||||
mixins: [
|
||||
setDocToLastMixin,
|
||||
simpleSchemaMixin,
|
||||
ensureAncestryContainsCharIdMixin,
|
||||
setDocAncestryMixin,
|
||||
creaturePermissionMixin,
|
||||
],
|
||||
collection: Features,
|
||||
permission: 'edit',
|
||||
schema: FeatureSchema,
|
||||
run(feature) {
|
||||
return Features.insert(feature);
|
||||
},
|
||||
});
|
||||
|
||||
const updateFeature = new ValidatedMethod({
|
||||
name: 'Features.methods.update',
|
||||
mixins: [
|
||||
updateSchemaMixin,
|
||||
propagateInheritanceUpdateMixin,
|
||||
creaturePermissionMixin,
|
||||
],
|
||||
collection: Features,
|
||||
permission: 'edit',
|
||||
schema: FeatureSchema,
|
||||
});
|
||||
|
||||
export default Features;
|
||||
export { FeatureSchema, insertFeature, updateFeature }
|
||||
export { FeatureSchema }
|
||||
|
||||
@@ -1,56 +1,11 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import schema from '/imports/api/schema.js';
|
||||
import { PropertySchema } from '/imports/api/properties/Properties.js'
|
||||
|
||||
// Mixins
|
||||
import creaturePermissionMixin from '/imports/api/creature/mixins/creaturePermissionMixin.js';
|
||||
import { setDocToLastMixin } from '/imports/api/creature/mixins/setDocToLastMixin.js';
|
||||
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
||||
import simpleSchemaMixin from '/imports/api/creature/mixins/simpleSchemaMixin.js';
|
||||
import propagateInheritanceUpdateMixin from '/imports/api/creature/mixins/propagateInheritanceUpdateMixin.js';
|
||||
import updateSchemaMixin from '/imports/api/creature/mixins/updateSchemaMixin.js';
|
||||
|
||||
let Folders = new Mongo.Collection('folders');
|
||||
|
||||
// Folders organize a character sheet into a tree, particularly to group things
|
||||
// like 'race' and 'background'
|
||||
let FolderSchema = schema({
|
||||
let FolderSchema = new SimpleSchema({
|
||||
name: {
|
||||
type: String,
|
||||
},
|
||||
});
|
||||
|
||||
Folders.attachSchema(FolderSchema);
|
||||
Folders.attachSchema(PropertySchema);
|
||||
|
||||
const insertFolder = new ValidatedMethod({
|
||||
name: 'Folders.methods.insert',
|
||||
mixins: [
|
||||
creaturePermissionMixin,
|
||||
setDocAncestryMixin,
|
||||
ensureAncestryContainsCharIdMixin,
|
||||
setDocToLastMixin,
|
||||
simpleSchemaMixin,
|
||||
],
|
||||
collection: Folders,
|
||||
permission: 'edit',
|
||||
schema: FolderSchema,
|
||||
run(folder) {
|
||||
return Folders.insert(folder);
|
||||
},
|
||||
});
|
||||
|
||||
const updateFolder = new ValidatedMethod({
|
||||
name: 'Folders.methods.update',
|
||||
mixins: [
|
||||
propagateInheritanceUpdateMixin,
|
||||
updateSchemaMixin,
|
||||
creaturePermissionMixin,
|
||||
],
|
||||
collection: Folders,
|
||||
permission: 'edit',
|
||||
schema: FolderSchema,
|
||||
});
|
||||
|
||||
export default Folders;
|
||||
export { FolderSchema, insertFolder, updateFolder };
|
||||
export { FolderSchema };
|
||||
|
||||
@@ -1,12 +1,6 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import schema from '/imports/api/schema.js';
|
||||
import ColorSchema from "/imports/api/creature/subSchemas/ColorSchema.js";
|
||||
import { PropertySchema } from '/imports/api/properties/Properties.js'
|
||||
import ChildSchema from '/imports/api/parenting/ChildSchema.js';
|
||||
|
||||
Items = new Mongo.Collection("items");
|
||||
|
||||
ItemSchema = schema({
|
||||
ItemSchema = new SimpleSchema({
|
||||
name: {
|
||||
type: String,
|
||||
optional: true,
|
||||
@@ -52,11 +46,4 @@ ItemSchema = schema({
|
||||
},
|
||||
});
|
||||
|
||||
ItemSchema.extend(ColorSchema);
|
||||
|
||||
Items.attachSchema(ItemSchema);
|
||||
Items.attachSchema(PropertySchema);
|
||||
Items.attachSchema(ChildSchema);
|
||||
|
||||
export default Items;
|
||||
export { ItemSchema };
|
||||
|
||||
@@ -1,19 +1,6 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import schema from '/imports/api/schema.js';
|
||||
import ColorSchema from "/imports/api/creature/subSchemas/ColorSchema.js";
|
||||
import { PropertySchema } from '/imports/api/properties/Properties.js'
|
||||
|
||||
// Mixins
|
||||
import creaturePermissionMixin from '/imports/api/creature/mixins/creaturePermissionMixin.js';
|
||||
import { setDocToLastMixin } from '/imports/api/creature/mixins/setDocToLastMixin.js';
|
||||
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
||||
import simpleSchemaMixin from '/imports/api/creature/mixins/simpleSchemaMixin.js';
|
||||
import propagateInheritanceUpdateMixin from '/imports/api/creature/mixins/propagateInheritanceUpdateMixin.js';
|
||||
import updateSchemaMixin from '/imports/api/creature/mixins/updateSchemaMixin.js';
|
||||
|
||||
let Notes = new Mongo.Collection("notes");
|
||||
|
||||
let NoteSchema = schema({
|
||||
let NoteSchema = new SimpleSchema({
|
||||
name: {
|
||||
type: String,
|
||||
optional: true,
|
||||
@@ -24,39 +11,4 @@ let NoteSchema = schema({
|
||||
},
|
||||
});
|
||||
|
||||
NoteSchema.extend(ColorSchema);
|
||||
|
||||
Notes.attachSchema(NoteSchema);
|
||||
Notes.attachSchema(PropertySchema);
|
||||
|
||||
const insertNote = new ValidatedMethod({
|
||||
name: 'Notes.methods.insert',
|
||||
mixins: [
|
||||
creaturePermissionMixin,
|
||||
setDocAncestryMixin,
|
||||
ensureAncestryContainsCharIdMixin,
|
||||
setDocToLastMixin,
|
||||
simpleSchemaMixin,
|
||||
],
|
||||
collection: Notes,
|
||||
permission: 'edit',
|
||||
schema: NoteSchema,
|
||||
run(note) {
|
||||
return Notes.insert(note);
|
||||
},
|
||||
});
|
||||
|
||||
const updateNote = new ValidatedMethod({
|
||||
name: 'Notes.methods.update',
|
||||
mixins: [
|
||||
propagateInheritanceUpdateMixin,
|
||||
updateSchemaMixin,
|
||||
creaturePermissionMixin,
|
||||
],
|
||||
collection: Notes,
|
||||
permission: 'edit',
|
||||
schema: NoteSchema,
|
||||
});
|
||||
|
||||
export default Notes;
|
||||
export { NoteSchema, insertNote, updateNote };
|
||||
export { NoteSchema };
|
||||
|
||||
@@ -1,19 +1,6 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import schema from '/imports/api/schema.js';
|
||||
import { PropertySchema } from '/imports/api/properties/Properties.js'
|
||||
|
||||
// Mixins
|
||||
import recomputeCreatureMixin from '/imports/api/creature/mixins/recomputeCreatureMixin.js';
|
||||
import creaturePermissionMixin from '/imports/api/creature/mixins/creaturePermissionMixin.js';
|
||||
import { setDocToLastMixin } from '/imports/api/creature/mixins/setDocToLastMixin.js';
|
||||
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
||||
import simpleSchemaMixin from '/imports/api/creature/mixins/simpleSchemaMixin.js';
|
||||
import propagateInheritanceUpdateMixin from '/imports/api/creature/mixins/propagateInheritanceUpdateMixin.js';
|
||||
import updateSchemaMixin from '/imports/api/creature/mixins/updateSchemaMixin.js';
|
||||
|
||||
let Proficiencies = new Mongo.Collection("proficiencies");
|
||||
|
||||
let ProficiencySchema = schema({
|
||||
let ProficiencySchema = new SimpleSchema({
|
||||
// The variableName of the skill to apply this to
|
||||
skill: {
|
||||
type: String,
|
||||
@@ -27,46 +14,4 @@ let ProficiencySchema = schema({
|
||||
},
|
||||
});
|
||||
|
||||
Proficiencies.attachSchema(ProficiencySchema);
|
||||
Proficiencies.attachSchema(PropertySchema);
|
||||
|
||||
const insertProficiency = new ValidatedMethod({
|
||||
name: 'Proficiencies.methods.insert',
|
||||
mixins: [
|
||||
creaturePermissionMixin,
|
||||
setDocToLastMixin,
|
||||
setDocAncestryMixin,
|
||||
ensureAncestryContainsCharIdMixin,
|
||||
recomputeCreatureMixin,
|
||||
simpleSchemaMixin,
|
||||
],
|
||||
collection: Proficiencies,
|
||||
permission: 'edit',
|
||||
schema: ProficiencySchema,
|
||||
run(prof) {
|
||||
return Proficiencies.insert(prof);
|
||||
},
|
||||
});
|
||||
|
||||
const updateProficiency = new ValidatedMethod({
|
||||
name: 'Proficiencies.methods.update',
|
||||
mixins: [
|
||||
recomputeCreatureMixin,
|
||||
propagateInheritanceUpdateMixin,
|
||||
updateSchemaMixin,
|
||||
creaturePermissionMixin,
|
||||
],
|
||||
collection: Proficiencies,
|
||||
permission: 'edit',
|
||||
schema: ProficiencySchema,
|
||||
skipRecompute({update}){
|
||||
let fields = getModifierFields(update);
|
||||
return !fields.hasAny([
|
||||
'value',
|
||||
'skill',
|
||||
]);
|
||||
},
|
||||
});
|
||||
|
||||
export default Proficiencies;
|
||||
export { ProficiencySchema, insertProficiency, updateProficiency };
|
||||
export { ProficiencySchema };
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import SoftRemovableSchema from '/imports/api/parenting/SoftRemovableSchema.js';
|
||||
import ChildSchema from '/imports/api/parenting/ChildSchema.js';
|
||||
import softRemove from '/imports/api/parenting/softRemove.js';
|
||||
import getCollectionByName from '/imports/api/parenting/getCollectionByName.js';
|
||||
|
||||
// Mixins
|
||||
import recomputeCreatureMixin from '/imports/api/creature/mixins/recomputeCreatureMixin.js';
|
||||
import creaturePermissionMixin from '/imports/api/creature/mixins/creaturePermissionMixin.js';
|
||||
import simpleSchemaMixin from '/imports/api/creature/mixins/simpleSchemaMixin.js';
|
||||
|
||||
const PropertySchema = new SimpleSchema({
|
||||
charId: {
|
||||
type: String,
|
||||
regEx: SimpleSchema.RegEx.Id,
|
||||
index: 1,
|
||||
optional: true,
|
||||
},
|
||||
name: {
|
||||
type: String,
|
||||
optional: true,
|
||||
},
|
||||
enabled: {
|
||||
type: Boolean,
|
||||
defaultValue: true,
|
||||
},
|
||||
order: {
|
||||
type: SimpleSchema.Integer,
|
||||
index: true,
|
||||
},
|
||||
});
|
||||
|
||||
PropertySchema.extend(SoftRemovableSchema);
|
||||
PropertySchema.extend(ChildSchema);
|
||||
|
||||
// Always recomputes the character, because we don't know the extent of the tree
|
||||
// that was removed with this document
|
||||
const softRemoveProperty = new ValidatedMethod({
|
||||
name: 'softRemoveProperty',
|
||||
mixins: [
|
||||
simpleSchemaMixin,
|
||||
recomputeCreatureMixin,
|
||||
creaturePermissionMixin,
|
||||
],
|
||||
getCharId({_id, collection}){
|
||||
let col = getCollectionByName(collection);
|
||||
let doc = col.findOne(_id, {fields: {charId: 1}});
|
||||
if (!doc || !doc.charId){
|
||||
throw new Meteor.Error(`Could not find charId of ${_id} in ${collection}`);
|
||||
} else {
|
||||
return doc.charId;
|
||||
}
|
||||
},
|
||||
permission: 'edit',
|
||||
schema: new SimpleSchema({
|
||||
_id: SimpleSchema.RegEx.Id,
|
||||
collection: String,
|
||||
}),
|
||||
run({_id, collection}){
|
||||
softRemove({_id, collection});
|
||||
},
|
||||
});
|
||||
|
||||
export { PropertySchema, softRemoveProperty };
|
||||
@@ -1,18 +1,7 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import { PropertySchema } from '/imports/api/properties/Properties.js'
|
||||
import AdjustmentSchema from '/imports/api/creature/subSchemas/AdjustmentSchema.js';
|
||||
import StoredBuffSchema from '/imports/api/properties/Buffs.js';
|
||||
|
||||
// Mixins
|
||||
import creaturePermissionMixin from '/imports/api/creature/mixins/creaturePermissionMixin.js';
|
||||
import { setDocToLastMixin } from '/imports/api/creature/mixins/setDocToLastMixin.js';
|
||||
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
||||
import simpleSchemaMixin from '/imports/api/creature/mixins/simpleSchemaMixin.js';
|
||||
import propagateInheritanceUpdateMixin from '/imports/api/creature/mixins/propagateInheritanceUpdateMixin.js';
|
||||
import updateSchemaMixin from '/imports/api/creature/mixins/updateSchemaMixin.js';
|
||||
|
||||
let Rolls = new Mongo.Collection('rolls');
|
||||
|
||||
let RollChildrenSchema = new SimpleSchema({
|
||||
// The adjustments to be applied
|
||||
adjustments: {
|
||||
@@ -99,37 +88,4 @@ let RollSchema = new SimpleSchema({
|
||||
},
|
||||
});
|
||||
|
||||
Rolls.attachSchema(RollSchema);
|
||||
Rolls.attachSchema(PropertySchema);
|
||||
|
||||
const insertRoll = new ValidatedMethod({
|
||||
name: 'Rolls.methods.insert',
|
||||
mixins: [
|
||||
creaturePermissionMixin,
|
||||
setDocToLastMixin,
|
||||
setDocAncestryMixin,
|
||||
ensureAncestryContainsCharIdMixin,
|
||||
simpleSchemaMixin,
|
||||
],
|
||||
collection: Rolls,
|
||||
permission: 'edit',
|
||||
schema: RollSchema,
|
||||
run(roll) {
|
||||
return Rolls.insert(roll);
|
||||
},
|
||||
});
|
||||
|
||||
const updateRoll = new ValidatedMethod({
|
||||
name: 'Rolls.methods.update',
|
||||
mixins: [
|
||||
propagateInheritanceUpdateMixin,
|
||||
updateSchemaMixin,
|
||||
creaturePermissionMixin,
|
||||
],
|
||||
collection: Rolls,
|
||||
permission: 'edit',
|
||||
schema: RollSchema,
|
||||
});
|
||||
|
||||
export default Rolls;
|
||||
export { RollSchema, insertRoll, updateRoll };
|
||||
export { RollSchema };
|
||||
|
||||
@@ -12,8 +12,6 @@ import simpleSchemaMixin from '/imports/api/creature/mixins/simpleSchemaMixin.js
|
||||
import propagateInheritanceUpdateMixin from '/imports/api/creature/mixins/propagateInheritanceUpdateMixin.js';
|
||||
import updateSchemaMixin from '/imports/api/creature/mixins/updateSchemaMixin.js';
|
||||
|
||||
let Skills = new Mongo.Collection("skills");
|
||||
|
||||
/*
|
||||
* Skills are anything that results in a modifier to be added to a D20
|
||||
* Skills have an ability score modifier that they use as their basis
|
||||
@@ -59,9 +57,8 @@ let SkillSchema = schema({
|
||||
},
|
||||
});
|
||||
|
||||
SkillSchema.extend(ColorSchema);
|
||||
|
||||
let ComputedSkillSchema = schema({
|
||||
let ComputedSkillSchema = new SimpleSchema({
|
||||
// Computed value of skill to be added to skill rolls
|
||||
value: {
|
||||
type: Number,
|
||||
@@ -101,49 +98,4 @@ let ComputedSkillSchema = schema({
|
||||
},
|
||||
}).extend(SkillSchema);
|
||||
|
||||
Skills.attachSchema(ComputedSkillSchema);
|
||||
Skills.attachSchema(PropertySchema);
|
||||
|
||||
const insertSkill = new ValidatedMethod({
|
||||
name: 'Skills.methods.insert',
|
||||
mixins: [
|
||||
creaturePermissionMixin,
|
||||
setDocToLastMixin,
|
||||
setDocAncestryMixin,
|
||||
ensureAncestryContainsCharIdMixin,
|
||||
recomputeCreatureMixin,
|
||||
simpleSchemaMixin,
|
||||
],
|
||||
collection: Skills,
|
||||
permission: 'edit',
|
||||
schema: SkillSchema,
|
||||
run(skill) {
|
||||
return Skills.insert(skill);
|
||||
},
|
||||
});
|
||||
|
||||
const updateSkill = new ValidatedMethod({
|
||||
name: 'Skills.methods.update',
|
||||
mixins: [
|
||||
recomputeCreatureMixin,
|
||||
propagateInheritanceUpdateMixin,
|
||||
updateSchemaMixin,
|
||||
creaturePermissionMixin,
|
||||
],
|
||||
collection: Skills,
|
||||
permission: 'edit',
|
||||
schema: SkillSchema,
|
||||
skipRecompute({update}){
|
||||
let fields = getModifierFields(update);
|
||||
return !fields.hasAny([
|
||||
'variableName',
|
||||
'ability',
|
||||
'type',
|
||||
'baseValue',
|
||||
'baseProficiency',
|
||||
]);
|
||||
},
|
||||
});
|
||||
|
||||
export default Skills;
|
||||
export { SkillSchema };
|
||||
export { SkillSchema, ComputedSkillSchema };
|
||||
|
||||
@@ -1,20 +1,7 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import schema from '/imports/api/schema.js';
|
||||
import ColorSchema from "/imports/api/creature/subSchemas/ColorSchema.js";
|
||||
import { PropertySchema } from '/imports/api/properties/Properties.js'
|
||||
|
||||
// Mixins
|
||||
import creaturePermissionMixin from '/imports/api/creature/mixins/creaturePermissionMixin.js';
|
||||
import { setDocToLastMixin } from '/imports/api/creature/mixins/setDocToLastMixin.js';
|
||||
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
||||
import simpleSchemaMixin from '/imports/api/creature/mixins/simpleSchemaMixin.js';
|
||||
import propagateInheritanceUpdateMixin from '/imports/api/creature/mixins/propagateInheritanceUpdateMixin.js';
|
||||
import updateSchemaMixin from '/imports/api/creature/mixins/updateSchemaMixin.js';
|
||||
import VARIABLE_NAME_REGEX from '/imports/constants/VARIABLE_NAME_REGEX.js';
|
||||
|
||||
let SpellLists = new Mongo.Collection("spellLists");
|
||||
|
||||
let SpellListSchema = schema({
|
||||
let SpellListSchema = new SimpleSchema({
|
||||
name: {
|
||||
type: String,
|
||||
optional: true,
|
||||
@@ -36,39 +23,4 @@ let SpellListSchema = schema({
|
||||
},
|
||||
});
|
||||
|
||||
SpellListSchema.extend(ColorSchema);
|
||||
|
||||
SpellLists.attachSchema(SpellListSchema);
|
||||
SpellLists.attachSchema(PropertySchema);
|
||||
|
||||
const insertSpellList = new ValidatedMethod({
|
||||
name: 'SpellLists.methods.insert',
|
||||
mixins: [
|
||||
creaturePermissionMixin,
|
||||
setDocToLastMixin,
|
||||
setDocAncestryMixin,
|
||||
ensureAncestryContainsCharIdMixin,
|
||||
simpleSchemaMixin,
|
||||
],
|
||||
collection: SpellLists,
|
||||
permission: 'edit',
|
||||
schema: SpellListSchema,
|
||||
run(spellList) {
|
||||
return SpellLists.insert(spellList);
|
||||
},
|
||||
});
|
||||
|
||||
const updateSpellList = new ValidatedMethod({
|
||||
name: 'SpellLists.methods.update',
|
||||
mixins: [
|
||||
propagateInheritanceUpdateMixin,
|
||||
updateSchemaMixin,
|
||||
creaturePermissionMixin,
|
||||
],
|
||||
collection: SpellLists,
|
||||
permission: 'edit',
|
||||
schema: SpellListSchema,
|
||||
});
|
||||
|
||||
export default SpellLists;
|
||||
export { SpellListSchema }
|
||||
|
||||
@@ -22,8 +22,6 @@ const magicSchools = [
|
||||
'transmutation',
|
||||
];
|
||||
|
||||
let Spells = new Mongo.Collection('spells');
|
||||
|
||||
let SpellSchema = schema({
|
||||
name: {
|
||||
type: String,
|
||||
@@ -94,39 +92,4 @@ let SpellSchema = schema({
|
||||
},
|
||||
});
|
||||
|
||||
SpellSchema.extend(ColorSchema);
|
||||
|
||||
Spells.attachSchema(SpellSchema);
|
||||
Spells.attachSchema(PropertySchema);
|
||||
|
||||
const insertSpell = new ValidatedMethod({
|
||||
name: 'Spells.methods.insert',
|
||||
mixins: [
|
||||
creaturePermissionMixin,
|
||||
setDocToLastMixin,
|
||||
setDocAncestryMixin,
|
||||
ensureAncestryContainsCharIdMixin,
|
||||
simpleSchemaMixin,
|
||||
],
|
||||
collection: Spells,
|
||||
permission: 'edit',
|
||||
schema: SpellSchema,
|
||||
run(spell) {
|
||||
return Spells.insert(spell);
|
||||
},
|
||||
});
|
||||
|
||||
const updateSpell = new ValidatedMethod({
|
||||
name: 'Spells.methods.update',
|
||||
mixins: [
|
||||
propagateInheritanceUpdateMixin,
|
||||
updateSchemaMixin,
|
||||
creaturePermissionMixin,
|
||||
],
|
||||
collection: Spells,
|
||||
permission: 'edit',
|
||||
schema: SpellSchema,
|
||||
});
|
||||
|
||||
export default Spells;
|
||||
export { SpellSchema, insertSpell, updateSpell };
|
||||
export { SpellSchema };
|
||||
|
||||
44
app/imports/api/properties/propertySchemas.js
Normal file
44
app/imports/api/properties/propertySchemas.js
Normal file
@@ -0,0 +1,44 @@
|
||||
import { CreatureSchema } from '/imports/api/creature/Creatures.js';
|
||||
import { ActionSchema } from '/imports/api/properties/Actions.js';
|
||||
import { AttributeSchema } from '/imports/api/properties/Attributes.js';
|
||||
import { StoredBuffSchema } from '/imports/api/properties/Buffs.js';
|
||||
import { ClassSchema } from '/imports/api/properties/Classes.js';
|
||||
import { ClassLevelSchema } from '/imports/api/properties/ClassLevels.js';
|
||||
import { DamageMultiplierSchema } from '/imports/api/properties/DamageMultipliers.js';
|
||||
import { EffectSchema } from '/imports/api/properties/Effects.js';
|
||||
import { ExperienceSchema } from '/imports/api/properties/Experiences.js';
|
||||
import { FeatureSchema } from '/imports/api/properties/Features.js';
|
||||
import { FolderSchema } from '/imports/api/properties/Folders.js';
|
||||
import { NoteSchema } from '/imports/api/properties/Notes.js';
|
||||
import { ProficiencySchema } from '/imports/api/properties/Proficiencies.js';
|
||||
import { RollSchema } from '/imports/api/properties/Rolls.js';
|
||||
import { SkillSchema } from '/imports/api/properties/Skills.js';
|
||||
import { SpellListSchema } from '/imports/api/properties/SpellLists.js';
|
||||
import { SpellSchema } from '/imports/api/properties/Spells.js';
|
||||
import { ContainerSchema } from '/imports/api/properties/Containers.js';
|
||||
import { ItemSchema } from '/imports/api/properties/Items.js';
|
||||
|
||||
|
||||
const propertySchemas = {
|
||||
creature: CreatureSchema,
|
||||
action: ActionSchema,
|
||||
attribute: AttributeSchema,
|
||||
buff: StoredBuffSchema,
|
||||
class: ClassSchema,
|
||||
classLevel: ClassLevelSchema,
|
||||
damageMultiplier: DamageMultiplierSchema,
|
||||
effect: EffectSchema,
|
||||
experience: ExperienceSchema,
|
||||
feature: FeatureSchema,
|
||||
folder: FolderSchema,
|
||||
note: NoteSchema,
|
||||
proficiency: ProficiencySchema,
|
||||
roll: RollSchema,
|
||||
skill: SkillSchema,
|
||||
spellList: SpellListSchema,
|
||||
spell: SpellSchema,
|
||||
container: ContainerSchema,
|
||||
item: ItemSchema,
|
||||
};
|
||||
|
||||
export default propertySchemas;
|
||||
@@ -1,14 +0,0 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
|
||||
export default function schema(options){
|
||||
return new SimpleSchema(options, {
|
||||
clean: {
|
||||
filter: true,
|
||||
autoConvert: true,
|
||||
removeEmptyStrings: true,
|
||||
trimStrings: false,
|
||||
getAutoValues: true,
|
||||
removeNullsFromArrays: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
14
app/imports/constants/SCHEMA_OPTIONS.js
Normal file
14
app/imports/constants/SCHEMA_OPTIONS.js
Normal file
@@ -0,0 +1,14 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
|
||||
const SCHEMA_OPTIONS = {
|
||||
clean: {
|
||||
filter: true,
|
||||
autoConvert: true,
|
||||
removeEmptyStrings: true,
|
||||
trimStrings: false,
|
||||
getAutoValues: true,
|
||||
removeNullsFromArrays: true,
|
||||
},
|
||||
};
|
||||
|
||||
export default SCHEMA_OPTIONS;
|
||||
Reference in New Issue
Block a user