Merge branch 'version-2' of https://github.com/ThaumRystra/DiceCloud into version-2
This commit is contained in:
@@ -1 +0,0 @@
|
||||
{"directory":"public/components/"}
|
||||
@@ -2,8 +2,7 @@ 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/creature/properties/Buffs.js';
|
||||
import PropertySchema from '/imports/api/creature/subSchemas/PropertySchema.js';
|
||||
import ChildSchema from '/imports/api/parenting/ChildSchema.js';
|
||||
import { PropertySchema } from '/imports/api/creature/properties/Properties.js'
|
||||
import ColorSchema from '/imports/api/creature/subSchemas/ColorSchema.js';
|
||||
|
||||
// Mixins
|
||||
@@ -11,26 +10,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 +50,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 +59,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 +68,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,
|
||||
@@ -82,7 +91,6 @@ ActionSchema.extend(ColorSchema);
|
||||
|
||||
Actions.attachSchema(ActionSchema);
|
||||
Actions.attachSchema(PropertySchema);
|
||||
Actions.attachSchema(ChildSchema);
|
||||
|
||||
const insertAction = new ValidatedMethod({
|
||||
name: 'Actions.methods.insert',
|
||||
@@ -104,18 +112,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;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import PropertySchema from '/imports/api/creature/subSchemas/PropertySchema.js';
|
||||
import ChildSchema from '/imports/api/parenting/ChildSchema.js';
|
||||
import { PropertySchema } from '/imports/api/creature/properties/Properties.js'
|
||||
import ColorSchema from '/imports/api/creature/subSchemas/ColorSchema.js';
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import schema from '/imports/api/schema.js';
|
||||
@@ -79,7 +78,6 @@ let AttributeSchema = schema({
|
||||
});
|
||||
|
||||
AttributeSchema.extend(ColorSchema);
|
||||
AttributeSchema.extend(PropertySchema);
|
||||
|
||||
const ComputedAttributeSchema = schema({
|
||||
// The computed value of the attribute
|
||||
@@ -95,7 +93,7 @@ const ComputedAttributeSchema = schema({
|
||||
}).extend(AttributeSchema);
|
||||
|
||||
Attributes.attachSchema(ComputedAttributeSchema);
|
||||
Attributes.attachSchema(ChildSchema);
|
||||
Attributes.attachSchema(PropertySchema);
|
||||
|
||||
const insertAttribute = new ValidatedMethod({
|
||||
name: 'Attributes.methods.insert',
|
||||
@@ -125,7 +123,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 +132,6 @@ const updateAttribute = new ValidatedMethod({
|
||||
'baseValue',
|
||||
]);
|
||||
},
|
||||
run({_id, update}) {
|
||||
return Attributes.update(_id, update);
|
||||
},
|
||||
});
|
||||
|
||||
const adjustAttribute = new ValidatedMethod({
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import schema from '/imports/api/schema.js';
|
||||
import PropertySchema from '/imports/api/creature/subSchemas/PropertySchema.js';
|
||||
import ChildSchema from '/imports/api/parenting/ChildSchema.js';
|
||||
import { PropertySchema } from '/imports/api/creature/properties/Properties.js'
|
||||
import { EffectSchema } from '/imports/api/creature/properties/Effects.js';
|
||||
|
||||
// Mixins
|
||||
@@ -9,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 Buffs = new Mongo.Collection('buffs');
|
||||
|
||||
@@ -77,7 +78,6 @@ let AppliedBuffSchema = schema({
|
||||
|
||||
Buffs.attachSchema(AppliedBuffSchema);
|
||||
Buffs.attachSchema(PropertySchema);
|
||||
Buffs.attachSchema(ChildSchema);
|
||||
|
||||
const insertBuff = new ValidatedMethod({
|
||||
name: 'Buffs.methods.insert',
|
||||
@@ -99,18 +99,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;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import schema from '/imports/api/schema.js';
|
||||
import PropertySchema from '/imports/api/creature/subSchemas/PropertySchema.js';
|
||||
import ChildSchema from '/imports/api/parenting/ChildSchema.js';
|
||||
import { PropertySchema } from '/imports/api/creature/properties/Properties.js'
|
||||
import VARIABLE_NAME_REGEX from '/imports/constants/VARIABLE_NAME_REGEX.js';
|
||||
|
||||
// Mixins
|
||||
@@ -9,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 ClassLevels = new Mongo.Collection("classLevels");
|
||||
|
||||
@@ -17,6 +18,10 @@ let ClassLevelSchema = schema({
|
||||
type: String,
|
||||
optional: true,
|
||||
},
|
||||
enabled: {
|
||||
type: Boolean,
|
||||
defaultValue: true,
|
||||
},
|
||||
// The name of this class level's variable
|
||||
variableName: {
|
||||
type: String,
|
||||
@@ -42,7 +47,6 @@ let ClassLevelSchema = schema({
|
||||
|
||||
ClassLevels.attachSchema(ClassLevelSchema);
|
||||
ClassLevels.attachSchema(PropertySchema);
|
||||
ClassLevels.attachSchema(ChildSchema);
|
||||
|
||||
// Todo ensure the class level is being parented to a compatible class, and that
|
||||
// previous level requirements are met
|
||||
@@ -66,18 +70,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;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import schema from '/imports/api/schema.js';
|
||||
import PropertySchema from '/imports/api/creature/subSchemas/PropertySchema.js';
|
||||
import ChildSchema from '/imports/api/parenting/ChildSchema.js';
|
||||
import { PropertySchema } from '/imports/api/creature/properties/Properties.js'
|
||||
import ColorSchema from "/imports/api/creature/subSchemas/ColorSchema.js";
|
||||
import VARIABLE_NAME_REGEX from '/imports/constants/VARIABLE_NAME_REGEX.js';
|
||||
|
||||
@@ -10,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 Classes = new Mongo.Collection("classes");
|
||||
|
||||
@@ -29,7 +30,6 @@ ClassSchema.extend(ColorSchema);
|
||||
|
||||
Classes.attachSchema(ClassSchema);
|
||||
Classes.attachSchema(PropertySchema);
|
||||
Classes.attachSchema(ChildSchema);
|
||||
|
||||
const insertClass = new ValidatedMethod({
|
||||
name: 'Classes.methods.insert',
|
||||
@@ -51,18 +51,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;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import schema from '/imports/api/schema.js';
|
||||
import PropertySchema from '/imports/api/creature/subSchemas/PropertySchema.js';
|
||||
import ChildSchema from '/imports/api/parenting/ChildSchema.js';
|
||||
import { PropertySchema } from '/imports/api/creature/properties/Properties.js'
|
||||
import DAMAGE_TYPES from '/imports/constants/DAMAGE_TYPES.js';
|
||||
|
||||
// Mixins
|
||||
@@ -10,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 DamageMultipliers = new Mongo.Collection("damageMultipliers");
|
||||
|
||||
@@ -37,17 +38,16 @@ let DamageMultiplierSchema = schema({
|
||||
|
||||
DamageMultipliers.attachSchema(DamageMultiplierSchema);
|
||||
DamageMultipliers.attachSchema(PropertySchema);
|
||||
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 +60,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;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import schema from '/imports/api/schema.js';
|
||||
import PropertySchema from '/imports/api/creature/subSchemas/PropertySchema.js';
|
||||
import ChildSchema from '/imports/api/parenting/ChildSchema.js';
|
||||
import { PropertySchema } from '/imports/api/creature/properties/Properties.js'
|
||||
|
||||
// Mixins
|
||||
import recomputeCreatureMixin from '/imports/api/mixins/recomputeCreatureMixin.js';
|
||||
@@ -9,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 Effects = new Mongo.Collection('effects');
|
||||
|
||||
@@ -56,9 +57,8 @@ const EffectComputedSchema = new SimpleSchema({
|
||||
},
|
||||
}).extend(EffectSchema);
|
||||
|
||||
Effects.attachSchema(PropertySchema);
|
||||
Effects.attachSchema(ChildSchema);
|
||||
Effects.attachSchema(EffectComputedSchema);
|
||||
Effects.attachSchema(PropertySchema);
|
||||
|
||||
const insertEffect = new ValidatedMethod({
|
||||
name: 'Effects.methods.insert',
|
||||
@@ -81,18 +81,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',
|
||||
]);
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import schema from '/imports/api/schema.js';
|
||||
import PropertySchema from '/imports/api/creature/subSchemas/PropertySchema.js';
|
||||
import { PropertySchema } from '/imports/api/creature/properties/Properties.js'
|
||||
import recomputeCreatureXP from '/imports/api/creature/creatureComputation.js';
|
||||
|
||||
// Mixins
|
||||
@@ -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");
|
||||
|
||||
@@ -46,8 +48,8 @@ let ExperienceSchema = schema({
|
||||
},
|
||||
});
|
||||
|
||||
Experiences.attachSchema(PropertySchema);
|
||||
Experiences.attachSchema(ExperienceSchema);
|
||||
Experiences.attachSchema(PropertySchema);
|
||||
|
||||
const insertExperience = new ValidatedMethod({
|
||||
name: 'Experiences.methods.insert',
|
||||
@@ -77,16 +79,14 @@ const insertExperience = new ValidatedMethod({
|
||||
const updateExperience = new ValidatedMethod({
|
||||
name: 'Experiences.methods.update',
|
||||
mixins: [
|
||||
creaturePermissionMixin,
|
||||
recomputeCreatureMixin,
|
||||
simpleSchemaMixin,
|
||||
propagateInheritanceUpdateMixin,
|
||||
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);
|
||||
},
|
||||
|
||||
@@ -1,26 +1,27 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import schema from '/imports/api/schema.js';
|
||||
import { assertEditPermission } from '/imports/api/creature/creaturePermissions.js';
|
||||
import { recomputeCreatureById } from '/imports/api/creature/creatureComputation.js'
|
||||
import { getHighestOrder } from '/imports/api/order/order.js';
|
||||
import PropertySchema from '/imports/api/creature/subSchemas/PropertySchema.js';
|
||||
import ChildSchema from '/imports/api/parenting/ChildSchema.js';
|
||||
import { PropertySchema } from '/imports/api/creature/properties/Properties.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');
|
||||
|
||||
let FeatureSchema = schema({
|
||||
let FeatureSchema = new SimpleSchema({
|
||||
name: {
|
||||
type: String,
|
||||
optional: true,
|
||||
},
|
||||
enabled: {
|
||||
type: Boolean,
|
||||
defaultValue: true,
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
optional: true,
|
||||
@@ -35,16 +36,15 @@ FeatureSchema.extend(ColorSchema);
|
||||
|
||||
Features.attachSchema(FeatureSchema);
|
||||
Features.attachSchema(PropertySchema);
|
||||
Features.attachSchema(ChildSchema);
|
||||
|
||||
const insertFeature = new ValidatedMethod({
|
||||
name: 'Features.methods.insert',
|
||||
mixins: [
|
||||
creaturePermissionMixin,
|
||||
setDocAncestryMixin,
|
||||
ensureAncestryContainsCharIdMixin,
|
||||
setDocToLastMixin,
|
||||
simpleSchemaMixin,
|
||||
simpleSchemaMixin,
|
||||
ensureAncestryContainsCharIdMixin,
|
||||
setDocAncestryMixin,
|
||||
creaturePermissionMixin,
|
||||
],
|
||||
collection: Features,
|
||||
permission: 'edit',
|
||||
@@ -57,18 +57,13 @@ const insertFeature = new ValidatedMethod({
|
||||
const updateFeature = new ValidatedMethod({
|
||||
name: 'Features.methods.update',
|
||||
mixins: [
|
||||
updateSchemaMixin,
|
||||
propagateInheritanceUpdateMixin,
|
||||
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;
|
||||
|
||||
@@ -1,26 +1,32 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import schema from '/imports/api/schema.js';
|
||||
import PropertySchema from '/imports/api/creature/subSchemas/PropertySchema.js';
|
||||
import ChildSchema from '/imports/api/parenting/ChildSchema.js';
|
||||
import { PropertySchema } from '/imports/api/creature/properties/Properties.js'
|
||||
|
||||
// Mixins
|
||||
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 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,
|
||||
},
|
||||
});
|
||||
|
||||
Folders.attachSchema(FolderSchema);
|
||||
Folders.attachSchema(PropertySchema);
|
||||
Folders.attachSchema(ChildSchema);
|
||||
|
||||
const insertFolder = new ValidatedMethod({
|
||||
name: 'Folders.methods.insert',
|
||||
@@ -42,18 +48,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;
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
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/creature/subSchemas/PropertySchema.js';
|
||||
import { PropertySchema } from '/imports/api/creature/properties/Properties.js'
|
||||
|
||||
// Mixins
|
||||
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 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;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import schema from '/imports/api/schema.js';
|
||||
import PropertySchema from '/imports/api/creature/subSchemas/PropertySchema.js';
|
||||
import ChildSchema from '/imports/api/parenting/ChildSchema.js';
|
||||
import { PropertySchema } from '/imports/api/creature/properties/Properties.js'
|
||||
|
||||
// Mixins
|
||||
import recomputeCreatureMixin from '/imports/api/mixins/recomputeCreatureMixin.js';
|
||||
@@ -9,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 Proficiencies = new Mongo.Collection("proficiencies");
|
||||
|
||||
@@ -32,7 +33,6 @@ let ProficiencySchema = schema({
|
||||
|
||||
Proficiencies.attachSchema(ProficiencySchema);
|
||||
Proficiencies.attachSchema(PropertySchema);
|
||||
Proficiencies.attachSchema(ChildSchema);
|
||||
|
||||
const insertProficiency = new ValidatedMethod({
|
||||
name: 'Proficiencies.methods.insert',
|
||||
@@ -55,18 +55,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',
|
||||
]);
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
64
app/imports/api/creature/properties/Properties.js
Normal file
64
app/imports/api/creature/properties/Properties.js
Normal file
@@ -0,0 +1,64 @@
|
||||
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/mixins/recomputeCreatureMixin.js';
|
||||
import creaturePermissionMixin from '/imports/api/mixins/creaturePermissionMixin.js';
|
||||
import simpleSchemaMixin from '/imports/api/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,6 +1,5 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import PropertySchema from '/imports/api/creature/subSchemas/PropertySchema.js';
|
||||
import ChildSchema from '/imports/api/parenting/ChildSchema.js';
|
||||
import { PropertySchema } from '/imports/api/creature/properties/Properties.js'
|
||||
import AdjustmentSchema from '/imports/api/creature/subSchemas/AdjustmentSchema.js';
|
||||
import StoredBuffSchema from '/imports/api/creature/properties/Buffs.js';
|
||||
|
||||
@@ -9,14 +8,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,17 +88,12 @@ 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);
|
||||
Rolls.attachSchema(PropertySchema);
|
||||
Rolls.attachSchema(ChildSchema);
|
||||
|
||||
const insertRoll = new ValidatedMethod({
|
||||
name: 'Rolls.methods.insert',
|
||||
@@ -123,18 +115,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;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import schema from '/imports/api/schema.js';
|
||||
import PropertySchema from '/imports/api/creature/subSchemas/PropertySchema.js';
|
||||
import ChildSchema from '/imports/api/parenting/ChildSchema.js';
|
||||
import { PropertySchema } from '/imports/api/creature/properties/Properties.js'
|
||||
import ColorSchema from '/imports/api/creature/subSchemas/ColorSchema.js';
|
||||
|
||||
// Mixins
|
||||
@@ -10,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 Skills = new Mongo.Collection("skills");
|
||||
|
||||
@@ -101,7 +102,6 @@ let ComputedSkillSchema = schema({
|
||||
|
||||
Skills.attachSchema(ComputedSkillSchema);
|
||||
Skills.attachSchema(PropertySchema);
|
||||
Skills.attachSchema(ChildSchema);
|
||||
|
||||
const insertSkill = new ValidatedMethod({
|
||||
name: 'Skills.methods.insert',
|
||||
@@ -124,18 +124,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',
|
||||
]);
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
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/creature/subSchemas/PropertySchema.js';
|
||||
import ChildSchema from '/imports/api/parenting/ChildSchema.js';
|
||||
import { PropertySchema } from '/imports/api/creature/properties/Properties.js'
|
||||
|
||||
// Mixins
|
||||
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 SpellLists = new Mongo.Collection("spellLists");
|
||||
|
||||
@@ -42,7 +43,6 @@ SpellListSchema.extend(ColorSchema);
|
||||
|
||||
SpellLists.attachSchema(SpellListSchema);
|
||||
SpellLists.attachSchema(PropertySchema);
|
||||
SpellLists.attachSchema(ChildSchema);
|
||||
|
||||
const insertSpellList = new ValidatedMethod({
|
||||
name: 'SpellLists.methods.insert',
|
||||
@@ -64,18 +64,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;
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
import ColorSchema from '/imports/api/creature/subSchemas/ColorSchema.js';
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import schema from '/imports/api/schema.js';
|
||||
import PropertySchema from '/imports/api/creature/subSchemas/PropertySchema.js';
|
||||
import ChildSchema from '/imports/api/parenting/ChildSchema.js';
|
||||
import { PropertySchema } from '/imports/api/creature/properties/Properties.js'
|
||||
|
||||
// Mixins
|
||||
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';
|
||||
|
||||
const magicSchools = [
|
||||
'Abjuration',
|
||||
@@ -28,11 +29,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,
|
||||
@@ -86,7 +94,6 @@ SpellSchema.extend(ColorSchema);
|
||||
|
||||
Spells.attachSchema(SpellSchema);
|
||||
Spells.attachSchema(PropertySchema);
|
||||
Spells.attachSchema(ChildSchema);
|
||||
|
||||
const insertSpell = new ValidatedMethod({
|
||||
name: 'Spells.methods.insert',
|
||||
@@ -108,18 +115,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;
|
||||
|
||||
@@ -1,22 +1,12 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
|
||||
const getColorSchema = function({optional = true} = {}){
|
||||
let schema = {
|
||||
const ColorSchema = new SimpleSchema({
|
||||
color: {
|
||||
type: String,
|
||||
// match hex colors of the form #A23 or #A23f56
|
||||
regEx: /^#([a-f0-9]{3}){1,2}\b$/i,
|
||||
};
|
||||
if (optional) {
|
||||
schema.optional = true;
|
||||
} else {
|
||||
schema.defaultValue = "#9E9E9E";
|
||||
}
|
||||
return schema
|
||||
};
|
||||
|
||||
const ColorSchema = new SimpleSchema({
|
||||
color: getColorSchema(),
|
||||
optional: true,
|
||||
},
|
||||
});
|
||||
|
||||
export default ColorSchema;
|
||||
export { getColorSchema };
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import SoftRemovableSchema from '/imports/api/parenting/SoftRemovableSchema.js';
|
||||
|
||||
const PropertySchema = new SimpleSchema({
|
||||
charId: {
|
||||
type: String,
|
||||
regEx: SimpleSchema.RegEx.Id,
|
||||
index: 1,
|
||||
optional: true,
|
||||
},
|
||||
enabled: {
|
||||
type: Boolean,
|
||||
defaultValue: true,
|
||||
},
|
||||
name: {
|
||||
type: String,
|
||||
optional: true,
|
||||
},
|
||||
order: {
|
||||
type: SimpleSchema.Integer,
|
||||
index: true,
|
||||
},
|
||||
});
|
||||
|
||||
PropertySchema.extend(SoftRemovableSchema);
|
||||
|
||||
export default PropertySchema;
|
||||
@@ -1,7 +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/creature/subSchemas/PropertySchema.js';
|
||||
import { PropertySchema } from '/imports/api/creature/properties/Properties.js'
|
||||
import ChildSchema from '/imports/api/parenting/ChildSchema.js';
|
||||
|
||||
//set up the collection for containers
|
||||
|
||||
@@ -1,7 +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/creature/subSchemas/PropertySchema.js';
|
||||
import { PropertySchema } from '/imports/api/creature/properties/Properties.js'
|
||||
import ChildSchema from '/imports/api/parenting/ChildSchema.js';
|
||||
|
||||
Items = new Mongo.Collection("items");
|
||||
|
||||
@@ -8,12 +8,12 @@ export function setDocToLastMixin(methodOptions){
|
||||
if (methodOptions.validate){
|
||||
throw new Meteor.Error(`setDocToLastMixin should come before simpleSchemaMixin`);
|
||||
}
|
||||
methodOptions.schema.extend({
|
||||
methodOptions.schema = new SimpleSchema({
|
||||
charId: {
|
||||
type: String,
|
||||
regEx: SimpleSchema.RegEx.Id,
|
||||
},
|
||||
});
|
||||
}).extend(methodOptions.schema);
|
||||
let collection = methodOptions.collection;
|
||||
if (!collection){
|
||||
throw new Meteor.Error("`collection` required in method options for setDocToLastMixin");
|
||||
|
||||
@@ -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,16 +42,26 @@ 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
|
||||
methodOptions.validate = function(args){
|
||||
argumentSchema.validate(args);
|
||||
updateSchema.validate(args.update, methodOptions.schemaValidatorOptions);
|
||||
updateSchema.validate(
|
||||
{$set: 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;
|
||||
}
|
||||
|
||||
@@ -1,15 +1,7 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import schema from '/imports/api/schema.js';
|
||||
|
||||
const RefSchema = new SimpleSchema({
|
||||
id: {
|
||||
type: String,
|
||||
regEx: SimpleSchema.RegEx.Id,
|
||||
index: 1
|
||||
},
|
||||
collection: {
|
||||
type: String
|
||||
},
|
||||
const inhertitedFieldsSchema = new SimpleSchema({
|
||||
name: {
|
||||
type: String,
|
||||
optional: true,
|
||||
@@ -21,6 +13,19 @@ const RefSchema = new SimpleSchema({
|
||||
},
|
||||
});
|
||||
|
||||
const RefSchema = new SimpleSchema({
|
||||
id: {
|
||||
type: String,
|
||||
regEx: SimpleSchema.RegEx.Id,
|
||||
index: 1
|
||||
},
|
||||
collection: {
|
||||
type: String
|
||||
},
|
||||
});
|
||||
|
||||
RefSchema.extend(inhertitedFieldsSchema);
|
||||
|
||||
let ChildSchema = schema({
|
||||
parent: {
|
||||
type: RefSchema,
|
||||
@@ -35,9 +40,7 @@ let ChildSchema = schema({
|
||||
},
|
||||
});
|
||||
|
||||
const inheritedFields = new Set(RefSchema.objectKeys());
|
||||
inheritedFields.delete('id');
|
||||
inheritedFields.delete('collection');
|
||||
const inheritedFields = new Set(inhertitedFieldsSchema.objectKeys());
|
||||
|
||||
export default ChildSchema;
|
||||
export { inheritedFields };
|
||||
|
||||
@@ -9,4 +9,4 @@ const docNotFoundError = function({id, collection}){
|
||||
export default function fetchDocByRef({id, collection}, options){
|
||||
return getCollectionByName(collection).findOne(id, options) ||
|
||||
docNotFoundError({id, collection});
|
||||
};
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ export function getAncestry({id, collection}){
|
||||
};
|
||||
|
||||
// Ancestors is [...parent's ancestors, parent ref]
|
||||
let ancestors = parentDoc.ancestors;
|
||||
let ancestors = parentDoc.ancestors || [];
|
||||
ancestors.push(parent);
|
||||
|
||||
return {parent, ancestors};
|
||||
@@ -90,9 +90,10 @@ export function getAncestry({id, collection}){
|
||||
export function setDocAncestryMixin(methodOptions){
|
||||
// Extend the method's schema to require the needed properties
|
||||
// This mixin should come before simpleschema mixin
|
||||
methodOptions.schema.extend({
|
||||
methodOptions.schema = new SimpleSchema({
|
||||
parent: {
|
||||
type: Object,
|
||||
optional: true,
|
||||
},
|
||||
'parent.id': {
|
||||
type: String,
|
||||
@@ -101,10 +102,14 @@ export function setDocAncestryMixin(methodOptions){
|
||||
'parent.collection': {
|
||||
type: String,
|
||||
},
|
||||
});
|
||||
}).extend(methodOptions.schema);
|
||||
// Change the doc's ancestry before running
|
||||
let runFunc = methodOptions.run;
|
||||
methodOptions.run = function(doc, ...rest){
|
||||
// If the doc's parent doesn't exist, set it to the character
|
||||
if (!doc.parent && doc.charId) {
|
||||
doc.parent = {id: doc.charId, collection: 'creatures'};
|
||||
}
|
||||
let {parent, ancestors} = getAncestry(doc.parent);
|
||||
doc.parent = parent;
|
||||
doc.ancestors = ancestors;
|
||||
@@ -137,12 +142,12 @@ function ensureAncestryContainsId(ancestors, id){
|
||||
export function ensureAncestryContainsCharIdMixin(methodOptions){
|
||||
// Extend the method's schema to require the needed properties
|
||||
// This mixin should come before simpleSchemaMixin
|
||||
methodOptions.schema.extend({
|
||||
methodOptions.schema = new SimpleSchema({
|
||||
charId: {
|
||||
type: String,
|
||||
regEx: SimpleSchema.RegEx.Id,
|
||||
},
|
||||
});
|
||||
}).extend(methodOptions.schema);
|
||||
let runFunc = methodOptions.run;
|
||||
methodOptions.run = function({charId, ancestors}){
|
||||
ensureAncestryContainsId(ancestors, charId);
|
||||
|
||||
@@ -2,11 +2,11 @@ import getCollectionByName from '/imports/api/parenting/getCollectionByName.js';
|
||||
import updateDecendents from '/imports/api/parenting/parenting.js';
|
||||
|
||||
// 1 + n database hits
|
||||
export function softRemove({id, collection}){
|
||||
export function softRemove({_id, collection}){
|
||||
let removalDate = new Date();
|
||||
// Remove this document
|
||||
collection = getCollectionByName(collection);
|
||||
collection.update(id, {$set: {
|
||||
collection.update(_id, {$set: {
|
||||
removed: true,
|
||||
removedAt: removalDate,
|
||||
}, $unset: {
|
||||
@@ -15,15 +15,15 @@ export function softRemove({id, collection}){
|
||||
// Remove all the decendents that have not yet been removed, and set them to be
|
||||
// removed with this document
|
||||
updateDecendents({
|
||||
ancestorId: id,
|
||||
ancestorId: _id,
|
||||
filter: {removed: {$ne: true}},
|
||||
modifier: {$set: {
|
||||
removed: true,
|
||||
removedAt: removalDate,
|
||||
removedWith: id,
|
||||
removedWith: _id,
|
||||
}},
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
const restoreError = function(){
|
||||
throw new Meteor.Error('restore-failed',
|
||||
@@ -31,10 +31,10 @@ const restoreError = function(){
|
||||
);
|
||||
};
|
||||
|
||||
export function restore({id, collection}){
|
||||
export function restore({_id, collection}){
|
||||
collection = getCollectionByName(collection);
|
||||
let numUpdated = collection.update({
|
||||
_id: id,
|
||||
_id,
|
||||
removedWith: {$exists: false}
|
||||
}, { $unset: {
|
||||
removed: 1,
|
||||
@@ -42,9 +42,9 @@ export function restore({id, collection}){
|
||||
}});
|
||||
if (numUpdated === 0) restoreError();
|
||||
updateDecendents({
|
||||
ancestorId: id,
|
||||
ancestorId: _id,
|
||||
filter: {
|
||||
removedWith: id,
|
||||
removedWith: _id,
|
||||
},
|
||||
modifier: { $unset: {
|
||||
removed: 1,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
|
||||
function getDefaultSchema(){
|
||||
return new SimpleSchema({}, {
|
||||
export default function schema(options){
|
||||
return new SimpleSchema(options, {
|
||||
clean: {
|
||||
filter: true,
|
||||
autoConvert: true,
|
||||
@@ -11,8 +11,4 @@ function getDefaultSchema(){
|
||||
removeNullsFromArrays: true,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
export default function schema(options){
|
||||
return getDefaultSchema().extend(options);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3,8 +3,10 @@
|
||||
<column-layout>
|
||||
<div v-for="feature in features" :key="feature._id">
|
||||
<feature-card
|
||||
v-bind="feature"
|
||||
:data-id="feature._id"
|
||||
v-bind="feature"
|
||||
:data-id="feature._id"
|
||||
@update="updateFeature"
|
||||
@click="featureClicked(feature)"
|
||||
/>
|
||||
</div>
|
||||
</column-layout>
|
||||
@@ -21,11 +23,11 @@
|
||||
|
||||
<script>
|
||||
import Creatures from '/imports/api/creature/Creatures.js';
|
||||
import Features from '/imports/api/creature/properties/Features.js';
|
||||
import Features, { updateFeature } from '/imports/api/creature/properties/Features.js';
|
||||
import { insertFeature } from '/imports/api/creature/properties/Features.js';
|
||||
import ColumnLayout from '/imports/ui/components/ColumnLayout.vue';
|
||||
import FeatureCard from '/imports/ui/components/features/FeatureCard.vue';
|
||||
import { evaluateComputation, evaluateString } from '/imports/ui/utility/evaluate.js';
|
||||
import { evaluateComputation, evaluateStringWithVariables } from '/imports/ui/utility/evaluate.js';
|
||||
|
||||
export default {
|
||||
props: {
|
||||
@@ -45,8 +47,7 @@
|
||||
}, {
|
||||
sort: {order: 1},
|
||||
}).map(f => {
|
||||
f.uses = evaluateComputation(f.uses, vars);
|
||||
f.description = evaluateString(f.description, vars);
|
||||
f.description = evaluateStringWithVariables(f.description, vars);
|
||||
return f;
|
||||
});
|
||||
},
|
||||
@@ -60,12 +61,28 @@
|
||||
callback(feature){
|
||||
if (!feature) return;
|
||||
feature.charId = charId;
|
||||
let featureId = insertFeature.call({feature});
|
||||
let featureId = insertFeature.call(feature);
|
||||
return featureId
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
updateFeature({_id, update}, ack){
|
||||
updateFeature.call({_id, update}, error => {
|
||||
if (ack){
|
||||
ack(error);
|
||||
} else if(error) {
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
},
|
||||
featureClicked(feature){
|
||||
this.$store.commit('pushDialogStack', {
|
||||
component: 'feature-dialog-container',
|
||||
elementId: feature._id,
|
||||
data: {_id: feature._id},
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
20
app/imports/ui/components/MarkdownText.vue
Normal file
20
app/imports/ui/components/MarkdownText.vue
Normal file
@@ -0,0 +1,20 @@
|
||||
<template lang="html">
|
||||
<div v-html="compiledMarkdown">
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import marked from 'marked';
|
||||
|
||||
export default {
|
||||
props: {
|
||||
markdown: String,
|
||||
},
|
||||
computed: {
|
||||
compiledMarkdown() {
|
||||
if (!this.markdown) return;
|
||||
return marked(this.markdown, { sanitize: true });
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
@@ -1,15 +1,15 @@
|
||||
<template lang="html">
|
||||
<v-card>
|
||||
<v-card :hover="hasClickListener" @click="$emit('click')">
|
||||
<v-toolbar
|
||||
flat
|
||||
style="transform: none;"
|
||||
@click="$emit('click')"
|
||||
:color="color"
|
||||
:dark="isDark"
|
||||
>
|
||||
<slot name="toolbar"/>
|
||||
</v-toolbar>
|
||||
<div>
|
||||
<div
|
||||
>
|
||||
<slot/>
|
||||
</div>
|
||||
</v-card>
|
||||
@@ -29,7 +29,10 @@
|
||||
computed: {
|
||||
isDark(){
|
||||
return isDarkColor(this.color);
|
||||
}
|
||||
},
|
||||
hasClickListener(){
|
||||
return this.$listeners && !!this.$listeners.click
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -1,56 +1,40 @@
|
||||
<template lang="html">
|
||||
<toolbar-card :color="color" @click="$emit('click')">
|
||||
<span slot="toolbar">
|
||||
{{name}}
|
||||
</span>
|
||||
<v-spacer slot="toolbar"/>
|
||||
<v-checkbox
|
||||
hide-details
|
||||
class="shrink"
|
||||
v-if="!alwaysEnabled"
|
||||
:value="enabled"
|
||||
@change="enabled => $emit('change', {enabled})"
|
||||
slot="toolbar"
|
||||
/>
|
||||
<v-card-text>
|
||||
{{description}}
|
||||
</v-card-text>
|
||||
<v-card-actions v-if="uses">
|
||||
<toolbar-card :color="color" @click="$emit('click')" :id="_id">
|
||||
<template slot="toolbar">
|
||||
<span>
|
||||
{{name}}
|
||||
</span>
|
||||
<v-spacer/>
|
||||
<v-btn
|
||||
flat
|
||||
:disabled="uses - used <= 0"
|
||||
@click="$emit('used')"
|
||||
>
|
||||
Use
|
||||
</v-btn>
|
||||
<v-btn
|
||||
flat
|
||||
:disabled="!used"
|
||||
@click="$emit('reset')"
|
||||
>
|
||||
Reset
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
<v-checkbox
|
||||
hide-details
|
||||
class="shrink"
|
||||
v-if="!alwaysEnabled"
|
||||
:value="enabled"
|
||||
@click.stop="$emit('update', {_id, update: {enabled: !enabled}})"
|
||||
/>
|
||||
</template>
|
||||
<v-card-text v-if="description">
|
||||
<markdown-text :markdown="description"/>
|
||||
</v-card-text>
|
||||
</toolbar-card>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import MarkdownText from '/imports/ui/components/MarkdownText.vue';
|
||||
import ToolbarCard from '/imports/ui/components/ToolbarCard.vue';
|
||||
|
||||
export default {
|
||||
props: {
|
||||
_id: String,
|
||||
charId: String,
|
||||
name: String,
|
||||
description: String,
|
||||
uses: Number,
|
||||
used: Number,
|
||||
reset: String,
|
||||
color: String,
|
||||
enabled: Boolean,
|
||||
alwaysEnabled: Boolean,
|
||||
},
|
||||
components: {
|
||||
MarkdownText,
|
||||
ToolbarCard,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,74 +1,46 @@
|
||||
<template lang="html">
|
||||
<dialog-base>
|
||||
<div slot="toolbar">
|
||||
New Feature
|
||||
</div>
|
||||
<feature-edit
|
||||
<property-insert-dialog
|
||||
documentType="Feature"
|
||||
:doc="feature"
|
||||
:schema="schema"
|
||||
:errors.sync="errors"
|
||||
>
|
||||
<feature-form
|
||||
:feature="feature"
|
||||
:errors="errors"
|
||||
@change="change"
|
||||
@update="update"
|
||||
:debounce-time="0"
|
||||
:errors="errors"
|
||||
/>
|
||||
<v-spacer slot="actions"/>
|
||||
<v-btn
|
||||
flat
|
||||
slot="actions"
|
||||
:disabled="!valid"
|
||||
@click="$store.dispatch('popDialogStack', feature)"
|
||||
>
|
||||
Insert Feature
|
||||
</v-btn>
|
||||
</dialog-base>
|
||||
</property-insert-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import FeatureEdit from '/imports/ui/components/features/FeatureEdit.vue';
|
||||
import Features from '/imports/api/creature/properties/Features.js';
|
||||
import DialogBase from '/imports/ui/dialogStack/DialogBase.vue';
|
||||
import FeatureForm from '/imports/ui/components/features/FeatureForm.vue';
|
||||
import Features, { FeatureSchema } from '/imports/api/creature/properties/Features.js';
|
||||
import PropertyInsertDialog from '/imports/ui/components/properties/PropertyInsertDialog.vue';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
FeatureEdit,
|
||||
DialogBase,
|
||||
FeatureForm,
|
||||
PropertyInsertDialog,
|
||||
},
|
||||
data(){ return {
|
||||
feature: {
|
||||
name: 'New Feature',
|
||||
description: null,
|
||||
uses: null,
|
||||
used: 0,
|
||||
reset: null,
|
||||
enabled: true,
|
||||
alwaysEnabled: true,
|
||||
color: '#9E9E9E',
|
||||
},
|
||||
valid: true,
|
||||
schema: FeatureSchema,
|
||||
errors: {},
|
||||
}},
|
||||
methods: {
|
||||
change(update, ack){
|
||||
update(update, ack){
|
||||
for (key in update){
|
||||
this.feature[key] = update[key];
|
||||
}
|
||||
if (ack) ack();
|
||||
},
|
||||
},
|
||||
created(){
|
||||
this.validationContext = Features.simpleSchema().newContext();
|
||||
},
|
||||
computed: {
|
||||
errors(){
|
||||
this.valid = true;
|
||||
let cleanAtt = this.validationContext.clean(this.feature)
|
||||
this.validationContext.validate(cleanAtt, {keys: [
|
||||
'name', 'description', 'uses', 'used', 'reset', 'enabled',
|
||||
'alwaysEnabled', 'color',
|
||||
]});
|
||||
let errors = {};
|
||||
this.validationContext.validationErrors().forEach(error => {
|
||||
if (this.valid) this.valid = false;
|
||||
errors[error.name] = Features.simpleSchema().messageForError(error);
|
||||
});
|
||||
return errors;
|
||||
ack();
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,45 +1,32 @@
|
||||
<template lang="html">
|
||||
<dialog-base>
|
||||
<div slot="toolbar" :color="color">
|
||||
{{name}}
|
||||
</div>
|
||||
<property-dialog :doc="feature" collection="features" @remove="$emit('remove')">
|
||||
<div>
|
||||
{{description}}
|
||||
<markdown-text :markdown="feature.computedDescription || feature.description"/>
|
||||
<!--
|
||||
<child-lists
|
||||
:effects="effects"
|
||||
:proficiencies="proficiencies"
|
||||
:actions="actions"
|
||||
:attacks="attacks"
|
||||
:parent="feature"
|
||||
/>
|
||||
-->
|
||||
</div>
|
||||
<div slot="edit">
|
||||
<feature-edit
|
||||
:feature="$props"
|
||||
@change="(update, ack) => $emit('change', update, ack)"
|
||||
/>
|
||||
</div>
|
||||
</dialog-base>
|
||||
<feature-form slot="form" :feature="feature" @update="(update, ack) => $emit('update', update, ack)"/>
|
||||
</property-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
props: {
|
||||
charId: String,
|
||||
name: String,
|
||||
description: String,
|
||||
uses: String,
|
||||
used: Number,
|
||||
reset: String,
|
||||
enabled: Boolean,
|
||||
alwaysEnabled: Boolean,
|
||||
order: Number,
|
||||
color: String,
|
||||
effects: Array,
|
||||
proficiencies: Array,
|
||||
actions: Array,
|
||||
attacks: Array,
|
||||
import PropertyDialog from '/imports/ui/components/properties/PropertyDialog.vue';
|
||||
import FeatureForm from '/imports/ui/components/features/FeatureForm.vue';
|
||||
import MarkdownText from '/imports/ui/components/MarkdownText.vue';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
PropertyDialog,
|
||||
FeatureForm,
|
||||
MarkdownText,
|
||||
},
|
||||
props: {
|
||||
feature: Object,
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="css" scoped>
|
||||
|
||||
@@ -1,47 +1,42 @@
|
||||
<template lang="html">
|
||||
<feature-dialog
|
||||
v-bind="feature"
|
||||
:effects="effects"
|
||||
v-on="{clickedEffect, change}"
|
||||
:feature="feature"
|
||||
@update="update"
|
||||
@remove="remove"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Features, {updateFeature} from '/imports/api/creature/properties/Features.js';
|
||||
import FeatureDialog from '/imports/ui/components/features/FeatureDialog.vue';
|
||||
import Features from '/imports/api/creature/properties/Features.js';
|
||||
import { updateFeature } from '/imports/api/creature/properties/Features.js';
|
||||
import Effects from '/imports/api/creature/properties/Effects.js';
|
||||
import {evaluateStringForCharId} from '/imports/ui/utility/evaluate.js';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
AttributeDialog,
|
||||
FeatureDialog,
|
||||
},
|
||||
props: {
|
||||
_id: String,
|
||||
},
|
||||
meteor: {
|
||||
feature(){
|
||||
return Features.findOne(this._id);
|
||||
},
|
||||
effects(){
|
||||
if (!this.feature) return;
|
||||
return Effects.find({
|
||||
'parent.id': this.feature._id,
|
||||
}, {
|
||||
sort: {order: 1},
|
||||
}).fetch();
|
||||
let feature = Features.findOne(this._id);
|
||||
feature.computedDescription = evaluateStringForCharId(
|
||||
feature.description, feature.charId
|
||||
);
|
||||
return feature;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
clickedEffect(e){
|
||||
console.log({TODO: e});
|
||||
},
|
||||
change(update, ack){
|
||||
updateFeature.call({_id: this._id, update}, error => ack(error));
|
||||
update(update, ack){
|
||||
updateFeature.call({
|
||||
_id: this._id,
|
||||
update,
|
||||
}, error => ack(error));
|
||||
},
|
||||
remove(){
|
||||
softRemoveProperty({_id: this._id, collection: 'features'});
|
||||
}
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="css" scoped>
|
||||
</style>
|
||||
|
||||
@@ -3,35 +3,10 @@
|
||||
<text-field
|
||||
label="Name"
|
||||
:value="feature.name"
|
||||
@change="(name, ack) => $emit('change', {name}, ack)"
|
||||
@change="(name, ack) => $emit('update', {name}, ack)"
|
||||
:error-messages="errors.name"
|
||||
:debounce-time="debounceTime"
|
||||
/>
|
||||
<text-field
|
||||
label="Used"
|
||||
type="number"
|
||||
:value="feature.used"
|
||||
@change="(used, ack) => $emit('change', {used}, ack)"
|
||||
:error-messages="errors.used"
|
||||
:debounce-time="debounceTime"
|
||||
/>
|
||||
<text-field
|
||||
label="Uses"
|
||||
:value="feature.uses"
|
||||
@change="(uses, ack) => $emit('change', {uses}, ack)"
|
||||
:error-messages="errors.uses"
|
||||
:debounce-time="debounceTime"
|
||||
/>
|
||||
<smart-select
|
||||
label="Reset"
|
||||
clearable
|
||||
:items="resetOptions"
|
||||
:value="feature.reset"
|
||||
:error-messages="errors.reset"
|
||||
:menu-props="{auto: true, lazy: true}"
|
||||
@change="(reset, ack) => $emit('change', {reset}, ack)"
|
||||
:debounce-time="debounceTime"
|
||||
/>
|
||||
<smart-select
|
||||
label="Enabled"
|
||||
:items="enabledOptions"
|
||||
@@ -45,7 +20,7 @@
|
||||
label="Description"
|
||||
:value="feature.description"
|
||||
:error-messages="errors.description"
|
||||
@change="(description, ack) => $emit('change', {description}, ack)"
|
||||
@change="(description, ack) => $emit('update', {description}, ack)"
|
||||
:debounce-time="debounceTime"
|
||||
/>
|
||||
</div>
|
||||
@@ -65,15 +40,6 @@
|
||||
debounceTime: Number,
|
||||
},
|
||||
data(){ return{
|
||||
resetOptions: [
|
||||
{
|
||||
text: 'Short rest',
|
||||
value: 'shortRest',
|
||||
}, {
|
||||
text: 'Long rest',
|
||||
value: 'longRest',
|
||||
}
|
||||
],
|
||||
enabledOptions: [
|
||||
{
|
||||
text: 'Always enabled',
|
||||
@@ -98,11 +64,11 @@
|
||||
methods: {
|
||||
changeEnabled(value, ack){
|
||||
if (value === 'always'){
|
||||
this.$emit('change', {enabled: true, alwaysEnabled: true}, ack);
|
||||
this.$emit('update', {enabled: true, alwaysEnabled: true}, ack);
|
||||
} else if (value === 'enabled'){
|
||||
this.$emit('change', {enabled: true, alwaysEnabled: false}, ack);
|
||||
this.$emit('update', {enabled: true, alwaysEnabled: false}, ack);
|
||||
} else if (value === 'disabled'){
|
||||
this.$emit('change', {enabled: false, alwaysEnabled: false}, ack);
|
||||
this.$emit('update', {enabled: false, alwaysEnabled: false}, ack);
|
||||
}
|
||||
}
|
||||
}
|
||||
27
app/imports/ui/components/properties/PropertyDialog.vue
Normal file
27
app/imports/ui/components/properties/PropertyDialog.vue
Normal file
@@ -0,0 +1,27 @@
|
||||
<template lang="html">
|
||||
<dialog-base @delete="$emit('delete')">
|
||||
<slot name="toolbar" slot="toolbar" :color="doc.color">
|
||||
<div>
|
||||
{{doc.name}}
|
||||
</div>
|
||||
</slot>
|
||||
<!-- Breadcrumbs go here -->
|
||||
<slot/>
|
||||
<slot name="form" slot="edit"/>
|
||||
</dialog-base>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import DialogBase from '/imports/ui/dialogStack/DialogBase.vue';
|
||||
export default {
|
||||
components: {
|
||||
DialogBase,
|
||||
},
|
||||
props: {
|
||||
doc: Object,
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="css" scoped>
|
||||
</style>
|
||||
@@ -0,0 +1,67 @@
|
||||
<template lang="html">
|
||||
<dialog-base>
|
||||
<template slot="toolbar">
|
||||
<div>
|
||||
New {{documentType}}
|
||||
</div>
|
||||
</template>
|
||||
<template #default>
|
||||
<slot @update="update"/>
|
||||
</template>
|
||||
<template slot="actions">
|
||||
<v-spacer/>
|
||||
<v-btn
|
||||
flat
|
||||
:disabled="!valid"
|
||||
@click="$store.dispatch('popDialogStack', doc)"
|
||||
>
|
||||
Insert {{documentType}}
|
||||
</v-btn>
|
||||
</template>
|
||||
</dialog-base>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Vue from 'vue';
|
||||
import DialogBase from '/imports/ui/dialogStack/DialogBase.vue';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
DialogBase,
|
||||
},
|
||||
props: {
|
||||
documentType: String,
|
||||
schema: Object,
|
||||
doc: Object,
|
||||
},
|
||||
data(){ return {
|
||||
valid: true,
|
||||
}},
|
||||
watch: {
|
||||
doc: {
|
||||
handler(newDoc){
|
||||
let validationContext = this.schema.newContext();
|
||||
this.valid = true;
|
||||
let cleanAtt = validationContext.clean(newDoc)
|
||||
validationContext.validate(cleanAtt, {keys: [
|
||||
'name', 'description', 'uses', 'used', 'reset', 'enabled',
|
||||
'alwaysEnabled', 'color',
|
||||
]});
|
||||
let errors = {};
|
||||
validationContext.validationErrors().forEach(error => {
|
||||
if (this.valid) this.valid = false;
|
||||
errors[error.name] = this.schema.messageForError(error);
|
||||
});
|
||||
this.$emit('update:errors', errors);
|
||||
},
|
||||
deep: true,
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
log: console.log
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="css" scoped>
|
||||
</style>
|
||||
@@ -7,7 +7,7 @@
|
||||
<slot name="toolbar"></slot>
|
||||
<template v-if="$slots.edit">
|
||||
<v-spacer/>
|
||||
<v-btn icon flat @click="() => $emit('delete')" v-if="isEditing">
|
||||
<v-btn icon flat @click="$emit('remove')" v-if="isEditing">
|
||||
<v-icon>delete</v-icon>
|
||||
</v-btn>
|
||||
<v-btn icon flat @click="isEditing = !isEditing">
|
||||
@@ -15,6 +15,11 @@
|
||||
</v-btn>
|
||||
</template>
|
||||
</v-toolbar>
|
||||
<template v-if="breadcrumbs">
|
||||
<v-card-text>
|
||||
example > bread > crumb
|
||||
</v-card-text>
|
||||
</template>
|
||||
<v-card-text id="base-dialog-body" v-scroll:#base-dialog-body="onScroll">
|
||||
<v-tabs-items :value="isEditing ? 1 : 0" touchless>
|
||||
<v-tab-item>
|
||||
@@ -37,6 +42,7 @@
|
||||
export default {
|
||||
props: {
|
||||
color: String,
|
||||
breadcrumbs: Object,
|
||||
},
|
||||
data(){ return {
|
||||
offsetTop: 0,
|
||||
|
||||
@@ -2,6 +2,7 @@ import AttributeDialog from '/imports/ui/components/attributes/AttributeDialog.v
|
||||
import AttributeDialogContainer from '/imports/ui/components/attributes/AttributeDialogContainer.vue';
|
||||
import AttributeCreationDialog from '/imports/ui/components/attributes/AttributeCreationDialog.vue';
|
||||
import FeatureCreationDialog from '/imports/ui/components/features/FeatureCreationDialog.vue';
|
||||
import FeatureDialogContainer from '/imports/ui/components/features/FeatureDialogContainer.vue';
|
||||
import SkillDialogContainer from '/imports/ui/components/skills/SkillDialogContainer.vue';
|
||||
|
||||
export default {
|
||||
@@ -9,5 +10,6 @@ export default {
|
||||
AttributeDialogContainer,
|
||||
AttributeCreationDialog,
|
||||
FeatureCreationDialog,
|
||||
FeatureDialogContainer,
|
||||
SkillDialogContainer,
|
||||
};
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
@enter="enter"
|
||||
@leave="leave"
|
||||
>
|
||||
<div class="sibling" key="sibling"/>
|
||||
<v-card
|
||||
v-for="(dialog, index) in dialogs"
|
||||
:key="dialog._id"
|
||||
@@ -25,7 +24,9 @@
|
||||
:style="getDialogStyle(index)"
|
||||
:elevation="6"
|
||||
>
|
||||
<component :is="dialog.component" v-bind="dialog.data" @pop="popDialogStack($event)" class="dialog-component"></component>
|
||||
<transition name="slide">
|
||||
<component :is="dialog.component" v-bind="dialog.data" @pop="popDialogStack($event)" class="dialog-component"></component>
|
||||
</transition>
|
||||
</v-card>
|
||||
</transition-group>
|
||||
</v-layout>
|
||||
@@ -168,7 +169,7 @@
|
||||
e.preventDefault();
|
||||
}
|
||||
},
|
||||
watch:{
|
||||
watch: {
|
||||
dialogs(newDialogs) {
|
||||
let el = document.documentElement;
|
||||
if (newDialogs.length) {
|
||||
|
||||
@@ -20,6 +20,19 @@ const dialogStackStore = {
|
||||
});
|
||||
updateHistory();
|
||||
},
|
||||
replaceDialog(stat, {component, data, elementId, callback}){
|
||||
const _id = Random.id();
|
||||
if (!state.dialogs.length){
|
||||
throw new Meteor.Error("can't replace dialog if no dialogs are open");
|
||||
}
|
||||
state.dialogs.$set(0, {
|
||||
_id,
|
||||
component,
|
||||
data,
|
||||
elementId,
|
||||
callback,
|
||||
});
|
||||
},
|
||||
popDialogStackMutation (state, result){
|
||||
const dialog = state.dialogs.pop();
|
||||
state.currentResult = null;
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
import Creatures from '/imports/api/creature/Creatures.js';
|
||||
|
||||
// Computations resolve to numbers
|
||||
// vars is a dict of variables to substitute
|
||||
function evaluateComputation(string, vars){
|
||||
export function evaluateComputation(string, vars){
|
||||
if (!string) return string;
|
||||
// Replace all the string variables with numbers if possible
|
||||
let substitutedString = string.replace(
|
||||
@@ -14,11 +16,11 @@ function evaluateComputation(string, vars){
|
||||
} catch (e){
|
||||
return substitutedString;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
// Strings can have computations in bracers like so: {computation}
|
||||
// vars is a dict of variables to substitute
|
||||
function evaluateString(string, vars){
|
||||
export function evaluateStringWithVariables(string, vars){
|
||||
if (!string) return string;
|
||||
// Compute everything inside bracers
|
||||
return string.replace(/\{([^\{\}]*)\}/g, function(match, p1){
|
||||
@@ -26,4 +28,8 @@ function evaluateString(string, vars){
|
||||
});
|
||||
}
|
||||
|
||||
export { evaluateComputation, evaluateString };
|
||||
export function evaluateStringForCharId(string, charId){
|
||||
let char = Creatures.findOne(charId, {fields: {variables: 1}});
|
||||
let vars = char ? char.variables : {};
|
||||
return evaluateStringWithVariables(string, vars);
|
||||
}
|
||||
|
||||
7
app/package-lock.json
generated
7
app/package-lock.json
generated
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "rpg-docs",
|
||||
"name": "dicecloud",
|
||||
"version": "0.10.0",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
@@ -830,6 +830,11 @@
|
||||
"p-defer": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"marked": {
|
||||
"version": "0.6.1",
|
||||
"resolved": "https://registry.npmjs.org/marked/-/marked-0.6.1.tgz",
|
||||
"integrity": "sha512-+H0L3ibcWhAZE02SKMqmvYsErLo4EAVJxu5h3bHBBDvvjeWXtl92rGUSBYHL2++5Y+RSNgl8dYOAXcYe7lp1fA=="
|
||||
},
|
||||
"mathjs": {
|
||||
"version": "5.5.0",
|
||||
"resolved": "https://registry.npmjs.org/mathjs/-/mathjs-5.5.0.tgz",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "rpg-docs",
|
||||
"name": "dicecloud",
|
||||
"version": "0.10.0",
|
||||
"description": "Unofficial Online Realtime D&D 5e App",
|
||||
"license": "GPL-3.0",
|
||||
@@ -20,6 +20,7 @@
|
||||
"css-box-shadow": "^1.0.0-3",
|
||||
"fibers": "^2.0.2",
|
||||
"lodash": "^4.17.11",
|
||||
"marked": "^0.6.1",
|
||||
"mathjs": "^5.5.0",
|
||||
"meteor-node-stubs": "^0.3.3",
|
||||
"moo": "^0.5.0",
|
||||
|
||||
Reference in New Issue
Block a user