methods now use correct mixins
This commit is contained in:
@@ -11,26 +11,35 @@ import creaturePermissionMixin from '/imports/api/mixins/creaturePermissionMixin
|
||||
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
||||
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
||||
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
||||
|
||||
import propagateInheritanceUpdateMixin from '/imports/api/mixins/propagateInheritanceUpdateMixin.js';
|
||||
import updateSchemaMixin from '/imports/api/mixins/updateSchemaMixin.js';
|
||||
|
||||
let Actions = new Mongo.Collection('actions');
|
||||
|
||||
/*
|
||||
* Actions are things a character can do
|
||||
* Any rolls that are children of actions will be rolled when taking the action
|
||||
* Any actions that are children of this action will be considered alternatives
|
||||
* to this action
|
||||
*/
|
||||
let ActionSchema = schema({
|
||||
name: {
|
||||
type: String,
|
||||
optional: true,
|
||||
},
|
||||
enabled: {
|
||||
type: Boolean,
|
||||
defaultValue: true,
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
optional: true,
|
||||
},
|
||||
// What time-resource is used to take the action in combat
|
||||
// long actions take longer than 1 round to cast
|
||||
type: {
|
||||
type: String,
|
||||
allowedValues: ['attack', 'action', 'bonus', 'reaction', 'free'],
|
||||
allowedValues: ['action', 'bonus', 'attack', 'reaction', 'free', 'long'],
|
||||
defaultValue: 'action',
|
||||
},
|
||||
// Who is the action directed at
|
||||
@@ -42,8 +51,8 @@ let ActionSchema = schema({
|
||||
'multipleTargets',
|
||||
],
|
||||
},
|
||||
// Adjustments applied when taking this action, regardless of roll outcomes
|
||||
// If these adjustments can't be made, the action should be unusable
|
||||
// Adjustments applied when taking this action
|
||||
// Ideally, if these adjustments can't be made, the action should be unusable
|
||||
adjustments: {
|
||||
type: Array,
|
||||
defaultValue: [],
|
||||
@@ -51,7 +60,7 @@ let ActionSchema = schema({
|
||||
'adjustments.$': {
|
||||
type: AdjustmentSchema,
|
||||
},
|
||||
// Buffs applied when taking this action, regardless of roll outcomes
|
||||
// Buffs applied when taking this action
|
||||
buffs: {
|
||||
type: Array,
|
||||
defaultValue: [],
|
||||
@@ -60,7 +69,8 @@ let ActionSchema = schema({
|
||||
type: StoredBuffSchema,
|
||||
},
|
||||
// Calculation of how many times this action can be used
|
||||
// Only set if this action tracks its own uses
|
||||
// Only set if this action tracks its own uses, rather than adjusting
|
||||
// resources
|
||||
uses: {
|
||||
type: String,
|
||||
optional: true,
|
||||
@@ -104,18 +114,13 @@ const insertAction = new ValidatedMethod({
|
||||
const updateAction = new ValidatedMethod({
|
||||
name: 'Actions.methods.update',
|
||||
mixins: [
|
||||
propagateInheritanceUpdateMixin,
|
||||
updateSchemaMixin,
|
||||
creaturePermissionMixin,
|
||||
simpleSchemaMixin,
|
||||
],
|
||||
collection: Actions,
|
||||
permission: 'edit',
|
||||
schema: new SimpleSchema({
|
||||
_id: SimpleSchema.RegEx.Id,
|
||||
update: ActionSchema.omit('name'),
|
||||
}),
|
||||
run({_id, update}) {
|
||||
return Actions.update(_id, {$set: update});
|
||||
},
|
||||
schema: ActionSchema,
|
||||
});
|
||||
|
||||
export default Actions;
|
||||
|
||||
@@ -79,7 +79,6 @@ let AttributeSchema = schema({
|
||||
});
|
||||
|
||||
AttributeSchema.extend(ColorSchema);
|
||||
AttributeSchema.extend(PropertySchema);
|
||||
|
||||
const ComputedAttributeSchema = schema({
|
||||
// The computed value of the attribute
|
||||
@@ -94,6 +93,7 @@ const ComputedAttributeSchema = schema({
|
||||
},
|
||||
}).extend(AttributeSchema);
|
||||
|
||||
Attributes.attachSchema(PropertySchema);
|
||||
Attributes.attachSchema(ComputedAttributeSchema);
|
||||
Attributes.attachSchema(ChildSchema);
|
||||
|
||||
@@ -125,7 +125,7 @@ const updateAttribute = new ValidatedMethod({
|
||||
],
|
||||
collection: Attributes,
|
||||
permission: 'edit',
|
||||
updateSchema: AttributeSchema,
|
||||
schema: AttributeSchema.omit(['adjutment']),
|
||||
skipRecompute({update}){
|
||||
let fields = getModifierFields(update);
|
||||
return !fields.hasAny([
|
||||
@@ -134,9 +134,6 @@ const updateAttribute = new ValidatedMethod({
|
||||
'baseValue',
|
||||
]);
|
||||
},
|
||||
run({_id, update}) {
|
||||
return Attributes.update(_id, update);
|
||||
},
|
||||
});
|
||||
|
||||
const adjustAttribute = new ValidatedMethod({
|
||||
|
||||
@@ -9,6 +9,8 @@ import creaturePermissionMixin from '/imports/api/mixins/creaturePermissionMixin
|
||||
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
||||
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
||||
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
||||
import propagateInheritanceUpdateMixin from '/imports/api/mixins/propagateInheritanceUpdateMixin.js';
|
||||
import updateSchemaMixin from '/imports/api/mixins/updateSchemaMixin.js';
|
||||
|
||||
let Buffs = new Mongo.Collection('buffs');
|
||||
|
||||
@@ -99,18 +101,13 @@ const insertBuff = new ValidatedMethod({
|
||||
const updateBuff = new ValidatedMethod({
|
||||
name: 'Buffs.methods.update',
|
||||
mixins: [
|
||||
propagateInheritanceUpdateMixin,
|
||||
updateSchemaMixin,
|
||||
creaturePermissionMixin,
|
||||
simpleSchemaMixin,
|
||||
],
|
||||
collection: Buffs,
|
||||
permission: 'edit',
|
||||
schema: new SimpleSchema({
|
||||
_id: SimpleSchema.RegEx.Id,
|
||||
update: BuffSchema.omit('name'),
|
||||
}),
|
||||
run({_id, update}) {
|
||||
return Buffs.update(_id, {$set: update});
|
||||
},
|
||||
schema: BuffSchema,
|
||||
});
|
||||
|
||||
export default Buffs;
|
||||
|
||||
@@ -9,6 +9,8 @@ import creaturePermissionMixin from '/imports/api/mixins/creaturePermissionMixin
|
||||
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
||||
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
||||
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
||||
import propagateInheritanceUpdateMixin from '/imports/api/mixins/propagateInheritanceUpdateMixin.js';
|
||||
import updateSchemaMixin from '/imports/api/mixins/updateSchemaMixin.js';
|
||||
|
||||
let ClassLevels = new Mongo.Collection("classLevels");
|
||||
|
||||
@@ -17,6 +19,10 @@ let ClassLevelSchema = schema({
|
||||
type: String,
|
||||
optional: true,
|
||||
},
|
||||
enabled: {
|
||||
type: Boolean,
|
||||
defaultValue: true,
|
||||
},
|
||||
// The name of this class level's variable
|
||||
variableName: {
|
||||
type: String,
|
||||
@@ -66,18 +72,13 @@ const insertClassLevel = new ValidatedMethod({
|
||||
const updateClassLevel = new ValidatedMethod({
|
||||
name: 'ClassLevels.methods.update',
|
||||
mixins: [
|
||||
propagateInheritanceUpdateMixin,
|
||||
updateSchemaMixin,
|
||||
creaturePermissionMixin,
|
||||
simpleSchemaMixin,
|
||||
],
|
||||
collection: ClassLevels,
|
||||
permission: 'edit',
|
||||
schema: new SimpleSchema({
|
||||
_id: SimpleSchema.RegEx.Id,
|
||||
update: ClassLevelSchema.omit('name'),
|
||||
}),
|
||||
run({_id, update}) {
|
||||
return ClassLevels.update(_id, {$set: update});
|
||||
},
|
||||
schema: ClassLevelSchema,
|
||||
});
|
||||
|
||||
export default ClassLevels;
|
||||
|
||||
@@ -10,6 +10,8 @@ import creaturePermissionMixin from '/imports/api/mixins/creaturePermissionMixin
|
||||
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
||||
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
||||
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
||||
import propagateInheritanceUpdateMixin from '/imports/api/mixins/propagateInheritanceUpdateMixin.js';
|
||||
import updateSchemaMixin from '/imports/api/mixins/updateSchemaMixin.js';
|
||||
|
||||
let Classes = new Mongo.Collection("classes");
|
||||
|
||||
@@ -51,18 +53,13 @@ const insertClass = new ValidatedMethod({
|
||||
const updateClass = new ValidatedMethod({
|
||||
name: 'Classes.methods.update',
|
||||
mixins: [
|
||||
propagateInheritanceUpdateMixin,
|
||||
updateSchemaMixin,
|
||||
creaturePermissionMixin,
|
||||
simpleSchemaMixin,
|
||||
],
|
||||
collection: Classes,
|
||||
permission: 'edit',
|
||||
schema: new SimpleSchema({
|
||||
_id: SimpleSchema.RegEx.Id,
|
||||
update: ClassSchema.omit('name'),
|
||||
}),
|
||||
run({_id, update}) {
|
||||
return Classes.update(_id, {$set: update});
|
||||
},
|
||||
schema: ClassSchema,
|
||||
});
|
||||
|
||||
export default Classes;
|
||||
|
||||
@@ -10,6 +10,8 @@ import creaturePermissionMixin from '/imports/api/mixins/creaturePermissionMixin
|
||||
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
||||
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
||||
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
||||
import propagateInheritanceUpdateMixin from '/imports/api/mixins/propagateInheritanceUpdateMixin.js';
|
||||
import updateSchemaMixin from '/imports/api/mixins/updateSchemaMixin.js';
|
||||
|
||||
let DamageMultipliers = new Mongo.Collection("damageMultipliers");
|
||||
|
||||
@@ -42,12 +44,12 @@ DamageMultipliers.attachSchema(ChildSchema);
|
||||
const insertDamageMultiplier = new ValidatedMethod({
|
||||
name: 'DamageMultipliers.methods.insert',
|
||||
mixins: [
|
||||
creaturePermissionMixin,
|
||||
setDocAncestryMixin,
|
||||
ensureAncestryContainsCharIdMixin,
|
||||
recomputeCreatureMixin,
|
||||
setDocToLastMixin,
|
||||
simpleSchemaMixin,
|
||||
creaturePermissionMixin,
|
||||
],
|
||||
collection: DamageMultipliers,
|
||||
permission: 'edit',
|
||||
@@ -60,19 +62,14 @@ const insertDamageMultiplier = new ValidatedMethod({
|
||||
const updateDamageMultiplier = new ValidatedMethod({
|
||||
name: 'DamageMultipliers.methods.update',
|
||||
mixins: [
|
||||
creaturePermissionMixin,
|
||||
recomputeCreatureMixin,
|
||||
simpleSchemaMixin,
|
||||
propagateInheritanceUpdateMixin,
|
||||
updateSchemaMixin,
|
||||
creaturePermissionMixin,
|
||||
],
|
||||
collection: DamageMultipliers,
|
||||
permission: 'edit',
|
||||
schema: new SimpleSchema({
|
||||
_id: SimpleSchema.RegEx.Id,
|
||||
update: DamageMultiplierSchema.omit('name'),
|
||||
}),
|
||||
run({_id, update}) {
|
||||
return DamageMultipliers.update(_id, {$set: update});
|
||||
},
|
||||
schema: DamageMultiplierSchema,
|
||||
});
|
||||
|
||||
export default DamageMultipliers;
|
||||
|
||||
@@ -9,6 +9,8 @@ import creaturePermissionMixin from '/imports/api/mixins/creaturePermissionMixin
|
||||
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
||||
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
||||
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
||||
import propagateInheritanceUpdateMixin from '/imports/api/mixins/propagateInheritanceUpdateMixin.js';
|
||||
import updateSchemaMixin from '/imports/api/mixins/updateSchemaMixin.js';
|
||||
|
||||
let Effects = new Mongo.Collection('effects');
|
||||
|
||||
@@ -81,18 +83,21 @@ const insertEffect = new ValidatedMethod({
|
||||
const updateEffect = new ValidatedMethod({
|
||||
name: 'Effects.methods.update',
|
||||
mixins: [
|
||||
creaturePermissionMixin,
|
||||
recomputeCreatureMixin,
|
||||
simpleSchemaMixin,
|
||||
propagateInheritanceUpdateMixin,
|
||||
updateSchemaMixin,
|
||||
creaturePermissionMixin,
|
||||
],
|
||||
collection: Effects,
|
||||
permission: 'edit',
|
||||
schema: new SimpleSchema({
|
||||
_id: SimpleSchema.RegEx.Id,
|
||||
update: EffectSchema.omit('name'),
|
||||
}),
|
||||
run({_id, update}) {
|
||||
return Effects.update(_id, {$set: update});
|
||||
schema: EffectSchema,
|
||||
skipRecompute({update}){
|
||||
let fields = getModifierFields(update);
|
||||
return !fields.hasAny([
|
||||
'operation',
|
||||
'calculation',
|
||||
'stat',
|
||||
]);
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@ import creaturePermissionMixin from '/imports/api/mixins/creaturePermissionMixin
|
||||
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
||||
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
||||
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
||||
import propagateInheritanceUpdateMixin from '/imports/api/mixins/propagateInheritanceUpdateMixin.js';
|
||||
import updateSchemaMixin from '/imports/api/mixins/updateSchemaMixin.js';
|
||||
|
||||
let Experiences = new Mongo.Collection("experience");
|
||||
|
||||
@@ -77,16 +79,14 @@ const insertExperience = new ValidatedMethod({
|
||||
const updateExperience = new ValidatedMethod({
|
||||
name: 'Experiences.methods.update',
|
||||
mixins: [
|
||||
creaturePermissionMixin,
|
||||
recomputeCreatureMixin,
|
||||
simpleSchemaMixin,
|
||||
ropagateInheritanceUpdateMixin,
|
||||
updateSchemaMixin,
|
||||
creaturePermissionMixin,
|
||||
],
|
||||
collection: Experiences,
|
||||
permission: 'edit',
|
||||
schema: new SimpleSchema({
|
||||
_id: SimpleSchema.RegEx.Id,
|
||||
update: ExperienceSchema.omit('name'),
|
||||
}),
|
||||
schema: ExperienceSchema,
|
||||
skipRecompute({update}){
|
||||
return !('value' in update);
|
||||
},
|
||||
|
||||
@@ -8,11 +8,12 @@ import ChildSchema from '/imports/api/parenting/ChildSchema.js';
|
||||
import ColorSchema from '/imports/api/creature/subSchemas/ColorSchema.js';
|
||||
|
||||
// Mixins
|
||||
import recomputeCreatureMixin from '/imports/api/mixins/recomputeCreatureMixin.js';
|
||||
import creaturePermissionMixin from '/imports/api/mixins/creaturePermissionMixin.js';
|
||||
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
||||
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
||||
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
||||
import propagateInheritanceUpdateMixin from '/imports/api/mixins/propagateInheritanceUpdateMixin.js';
|
||||
import updateSchemaMixin from '/imports/api/mixins/updateSchemaMixin.js';
|
||||
|
||||
let Features = new Mongo.Collection('features');
|
||||
|
||||
@@ -21,6 +22,10 @@ let FeatureSchema = schema({
|
||||
type: String,
|
||||
optional: true,
|
||||
},
|
||||
enabled: {
|
||||
type: Boolean,
|
||||
defaultValue: true,
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
optional: true,
|
||||
@@ -57,18 +62,13 @@ const insertFeature = new ValidatedMethod({
|
||||
const updateFeature = new ValidatedMethod({
|
||||
name: 'Features.methods.update',
|
||||
mixins: [
|
||||
propagateInheritanceUpdateMixin,
|
||||
updateSchemaMixin,
|
||||
creaturePermissionMixin,
|
||||
simpleSchemaMixin,
|
||||
],
|
||||
collection: Features,
|
||||
permission: 'edit',
|
||||
schema: new SimpleSchema({
|
||||
_id: SimpleSchema.RegEx.Id,
|
||||
update: FeatureSchema.omit('name'),
|
||||
}),
|
||||
run({_id, update}) {
|
||||
return Features.update(_id, {$set: update});
|
||||
},
|
||||
schema: FeatureSchema,
|
||||
});
|
||||
|
||||
export default Features;
|
||||
|
||||
@@ -8,18 +8,25 @@ import creaturePermissionMixin from '/imports/api/mixins/creaturePermissionMixin
|
||||
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
||||
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
||||
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
||||
import propagateInheritanceUpdateMixin from '/imports/api/mixins/propagateInheritanceUpdateMixin.js';
|
||||
import updateSchemaMixin from '/imports/api/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({
|
||||
name: {
|
||||
type: String,
|
||||
optional: true,
|
||||
},
|
||||
});
|
||||
enabled: {
|
||||
type: Boolean,
|
||||
defaultValue: true,
|
||||
},
|
||||
}).extend(PropertySchema);
|
||||
|
||||
Folders.attachSchema(FolderSchema);
|
||||
Folders.attachSchema(PropertySchema);
|
||||
Folders.attachSchema(ChildSchema);
|
||||
|
||||
const insertFolder = new ValidatedMethod({
|
||||
@@ -42,18 +49,13 @@ const insertFolder = new ValidatedMethod({
|
||||
const updateFolder = new ValidatedMethod({
|
||||
name: 'Folders.methods.update',
|
||||
mixins: [
|
||||
propagateInheritanceUpdateMixin,
|
||||
updateSchemaMixin,
|
||||
creaturePermissionMixin,
|
||||
simpleSchemaMixin,
|
||||
],
|
||||
collection: Folders,
|
||||
permission: 'edit',
|
||||
schema: new SimpleSchema({
|
||||
_id: SimpleSchema.RegEx.Id,
|
||||
update: FolderSchema.omit('name'),
|
||||
}),
|
||||
run({_id, update}) {
|
||||
return Folders.update(_id, {$set: update});
|
||||
},
|
||||
schema: FolderSchema,
|
||||
});
|
||||
|
||||
export default Folders;
|
||||
|
||||
@@ -8,6 +8,8 @@ import creaturePermissionMixin from '/imports/api/mixins/creaturePermissionMixin
|
||||
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
||||
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
||||
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
||||
import propagateInheritanceUpdateMixin from '/imports/api/mixins/propagateInheritanceUpdateMixin.js';
|
||||
import updateSchemaMixin from '/imports/api/mixins/updateSchemaMixin.js';
|
||||
|
||||
let Notes = new Mongo.Collection("notes");
|
||||
|
||||
@@ -47,18 +49,13 @@ const insertNote = new ValidatedMethod({
|
||||
const updateNote = new ValidatedMethod({
|
||||
name: 'Notes.methods.update',
|
||||
mixins: [
|
||||
propagateInheritanceUpdateMixin,
|
||||
updateSchemaMixin,
|
||||
creaturePermissionMixin,
|
||||
simpleSchemaMixin,
|
||||
],
|
||||
collection: Notes,
|
||||
permission: 'edit',
|
||||
schema: new SimpleSchema({
|
||||
_id: SimpleSchema.RegEx.Id,
|
||||
update: NoteSchema.omit('name'),
|
||||
}),
|
||||
run({_id, update}) {
|
||||
return Notes.update(_id, {$set: update});
|
||||
},
|
||||
schema: NoteSchema,
|
||||
});
|
||||
|
||||
export default Notes;
|
||||
|
||||
@@ -9,6 +9,8 @@ import creaturePermissionMixin from '/imports/api/mixins/creaturePermissionMixin
|
||||
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
||||
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
||||
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
||||
import propagateInheritanceUpdateMixin from '/imports/api/mixins/propagateInheritanceUpdateMixin.js';
|
||||
import updateSchemaMixin from '/imports/api/mixins/updateSchemaMixin.js';
|
||||
|
||||
let Proficiencies = new Mongo.Collection("proficiencies");
|
||||
|
||||
@@ -55,18 +57,20 @@ const insertProficiency = new ValidatedMethod({
|
||||
const updateProficiency = new ValidatedMethod({
|
||||
name: 'Proficiencies.methods.update',
|
||||
mixins: [
|
||||
creaturePermissionMixin,
|
||||
recomputeCreatureMixin,
|
||||
simpleSchemaMixin,
|
||||
propagateInheritanceUpdateMixin,
|
||||
updateSchemaMixin,
|
||||
creaturePermissionMixin,
|
||||
],
|
||||
collection: Proficiencies,
|
||||
permission: 'edit',
|
||||
schema: new SimpleSchema({
|
||||
_id: SimpleSchema.RegEx.Id,
|
||||
update: ProficiencySchema.omit('name'),
|
||||
}),
|
||||
run({_id, update}) {
|
||||
return Proficiencies.update(_id, {$set: update});
|
||||
schema: ProficiencySchema,
|
||||
skipRecompute({update}){
|
||||
let fields = getModifierFields(update);
|
||||
return !fields.hasAny([
|
||||
'value',
|
||||
'skill',
|
||||
]);
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -9,14 +9,12 @@ import creaturePermissionMixin from '/imports/api/mixins/creaturePermissionMixin
|
||||
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
||||
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
||||
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
||||
import propagateInheritanceUpdateMixin from '/imports/api/mixins/propagateInheritanceUpdateMixin.js';
|
||||
import updateSchemaMixin from '/imports/api/mixins/updateSchemaMixin.js';
|
||||
|
||||
let Rolls = new Mongo.Collection('rolls');
|
||||
|
||||
let RollChildrenSchema = new SimpleSchema({
|
||||
name: {
|
||||
type: String,
|
||||
optional: true,
|
||||
},
|
||||
// The adjustments to be applied
|
||||
adjustments: {
|
||||
type: Array,
|
||||
@@ -91,12 +89,8 @@ let RollSchema = new SimpleSchema({
|
||||
optional: true,
|
||||
},
|
||||
// The buffs and adjustments to apply based on the outcome of the roll
|
||||
hit: {
|
||||
type: RollChildrenSchema,
|
||||
},
|
||||
miss: {
|
||||
type: RollChildrenSchema,
|
||||
},
|
||||
hit: RollChildrenSchema,
|
||||
miss: RollChildrenSchema,
|
||||
});
|
||||
|
||||
Rolls.attachSchema(RollSchema);
|
||||
@@ -123,18 +117,13 @@ const insertRoll = new ValidatedMethod({
|
||||
const updateRoll = new ValidatedMethod({
|
||||
name: 'Rolls.methods.update',
|
||||
mixins: [
|
||||
propagateInheritanceUpdateMixin,
|
||||
updateSchemaMixin,
|
||||
creaturePermissionMixin,
|
||||
simpleSchemaMixin,
|
||||
],
|
||||
collection: Rolls,
|
||||
permission: 'edit',
|
||||
schema: new SimpleSchema({
|
||||
_id: SimpleSchema.RegEx.Id,
|
||||
update: RollSchema.omit('name'),
|
||||
}),
|
||||
run({_id, update}) {
|
||||
return Rolls.update(_id, {$set: update});
|
||||
},
|
||||
schema: RollSchema,
|
||||
});
|
||||
|
||||
export default Rolls;
|
||||
|
||||
@@ -10,6 +10,8 @@ import creaturePermissionMixin from '/imports/api/mixins/creaturePermissionMixin
|
||||
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
||||
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
||||
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
||||
import propagateInheritanceUpdateMixin from '/imports/api/mixins/propagateInheritanceUpdateMixin.js';
|
||||
import updateSchemaMixin from '/imports/api/mixins/updateSchemaMixin.js';
|
||||
|
||||
let Skills = new Mongo.Collection("skills");
|
||||
|
||||
@@ -124,18 +126,23 @@ const insertSkill = new ValidatedMethod({
|
||||
const updateSkill = new ValidatedMethod({
|
||||
name: 'Skills.methods.update',
|
||||
mixins: [
|
||||
creaturePermissionMixin,
|
||||
recomputeCreatureMixin,
|
||||
simpleSchemaMixin,
|
||||
propagateInheritanceUpdateMixin,
|
||||
updateSchemaMixin,
|
||||
creaturePermissionMixin,
|
||||
],
|
||||
collection: Skills,
|
||||
permission: 'edit',
|
||||
schema: new SimpleSchema({
|
||||
_id: SimpleSchema.RegEx.Id,
|
||||
update: SkillSchema.omit('name'),
|
||||
}),
|
||||
run({_id, update}) {
|
||||
return Skills.update(_id, {$set: update});
|
||||
schema: SkillSchema,
|
||||
skipRecompute({update}){
|
||||
let fields = getModifierFields(update);
|
||||
return !fields.hasAny([
|
||||
'variableName',
|
||||
'ability',
|
||||
'type',
|
||||
'baseValue',
|
||||
'baseProficiency',
|
||||
]);
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -9,6 +9,8 @@ import creaturePermissionMixin from '/imports/api/mixins/creaturePermissionMixin
|
||||
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
||||
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
||||
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
||||
import propagateInheritanceUpdateMixin from '/imports/api/mixins/propagateInheritanceUpdateMixin.js';
|
||||
import updateSchemaMixin from '/imports/api/mixins/updateSchemaMixin.js';
|
||||
|
||||
let SpellLists = new Mongo.Collection("spellLists");
|
||||
|
||||
@@ -64,18 +66,13 @@ const insertSpellList = new ValidatedMethod({
|
||||
const updateSpellList = new ValidatedMethod({
|
||||
name: 'SpellLists.methods.update',
|
||||
mixins: [
|
||||
propagateInheritanceUpdateMixin,
|
||||
updateSchemaMixin,
|
||||
creaturePermissionMixin,
|
||||
simpleSchemaMixin,
|
||||
],
|
||||
collection: SpellLists,
|
||||
permission: 'edit',
|
||||
schema: new SimpleSchema({
|
||||
_id: SimpleSchema.RegEx.Id,
|
||||
update: SpellListSchema.omit('name'),
|
||||
}),
|
||||
run({_id, update}) {
|
||||
return SpellLists.update(_id, {$set: update});
|
||||
},
|
||||
schema: SpellListSchema,
|
||||
});
|
||||
|
||||
export default SpellLists;
|
||||
|
||||
@@ -9,6 +9,8 @@ import creaturePermissionMixin from '/imports/api/mixins/creaturePermissionMixin
|
||||
import { setDocToLastMixin } from '/imports/api/mixins/setDocToLastMixin.js';
|
||||
import { setDocAncestryMixin, ensureAncestryContainsCharIdMixin } from '/imports/api/parenting/parenting.js';
|
||||
import simpleSchemaMixin from '/imports/api/mixins/simpleSchemaMixin.js';
|
||||
import propagateInheritanceUpdateMixin from '/imports/api/mixins/propagateInheritanceUpdateMixin.js';
|
||||
import updateSchemaMixin from '/imports/api/mixins/updateSchemaMixin.js';
|
||||
|
||||
const magicSchools = [
|
||||
'Abjuration',
|
||||
@@ -28,11 +30,18 @@ let SpellSchema = schema({
|
||||
type: String,
|
||||
optional: true,
|
||||
},
|
||||
prepared: {
|
||||
type: String,
|
||||
defaultValue: 'prepared',
|
||||
allowedValues: ['prepared', 'unprepared', 'always'],
|
||||
// If it's always prepared, it doesn't count against the number of spells
|
||||
// prepared in a spell list, and enabled should be true
|
||||
alwaysPrepared: {
|
||||
type: Boolean,
|
||||
defaultValue: false,
|
||||
},
|
||||
// Spells are enabled when they are prepared, so that unprepared spells don't
|
||||
// show their actions
|
||||
enabled: {
|
||||
type: Boolean,
|
||||
defaultValue: true,
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
optional: true,
|
||||
@@ -108,18 +117,13 @@ const insertSpell = new ValidatedMethod({
|
||||
const updateSpell = new ValidatedMethod({
|
||||
name: 'Spells.methods.update',
|
||||
mixins: [
|
||||
propagateInheritanceUpdateMixin,
|
||||
updateSchemaMixin,
|
||||
creaturePermissionMixin,
|
||||
simpleSchemaMixin,
|
||||
],
|
||||
collection: Spells,
|
||||
permission: 'edit',
|
||||
schema: new SimpleSchema({
|
||||
_id: SimpleSchema.RegEx.Id,
|
||||
update: SpellSchema.omit('name'),
|
||||
}),
|
||||
run({_id, update}) {
|
||||
return Spells.update(_id, {$set: update});
|
||||
},
|
||||
schema: SpellSchema,
|
||||
});
|
||||
|
||||
export default Spells;
|
||||
|
||||
@@ -12,16 +12,12 @@ import SimpleSchema from 'simpl-schema';
|
||||
export default function updateSchemaMixin(methodOptions) {
|
||||
// If the user didn't give us a schema and they did give us a validate, assume
|
||||
// that they are choosing to use the validate way of doing things in this call.
|
||||
// If they've built a wrapper around ValidateMethod that includes this mixin
|
||||
// all the time, this could happen semi-"intentionally". There may be times they
|
||||
// just don't want to use a schema and have specified a "validate" option. So
|
||||
// returning the unchanged options instead of an error seems proper.
|
||||
if ((
|
||||
typeof methodOptions.updateSchema === 'undefined' &&
|
||||
typeof methodOptions.schema === 'undefined' &&
|
||||
typeof methodOptions.validate !== 'undefined'
|
||||
) || (
|
||||
typeof methodOptions.updateSchema !== 'undefined' &&
|
||||
methodOptions.updateSchema === null &&
|
||||
typeof methodOptions.schema !== 'undefined' &&
|
||||
methodOptions.schema === null &&
|
||||
typeof methodOptions.validate !== 'undefined' &&
|
||||
methodOptions.validate !== null
|
||||
)) {
|
||||
@@ -46,10 +42,10 @@ export default function updateSchemaMixin(methodOptions) {
|
||||
|
||||
// Make the update schema a SimpleSchema, if it isn't already
|
||||
let updateSchema;
|
||||
if (methodOptions.updateSchema instanceof SimpleSchema) {
|
||||
updateSchema = methodOptions.updateSchema;
|
||||
if (methodOptions.schema instanceof SimpleSchema) {
|
||||
updateSchema = methodOptions.schema;
|
||||
} else {
|
||||
updateSchema = new SimpleSchema(methodOptions.updateSchema);
|
||||
updateSchema = new SimpleSchema(methodOptions.schema);
|
||||
}
|
||||
|
||||
// Set up the new validation
|
||||
@@ -57,5 +53,12 @@ export default function updateSchemaMixin(methodOptions) {
|
||||
argumentSchema.validate(args);
|
||||
updateSchema.validate(args.update, methodOptions.schemaValidatorOptions);
|
||||
};
|
||||
|
||||
// Give a default run function if one isn't supplied
|
||||
if (!methodOptions.run){
|
||||
methodOptions.run = function({_id, update}){
|
||||
return MethodOptions.collection.update(_id, {$set: update});
|
||||
};
|
||||
}
|
||||
return methodOptions;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user