Started on DBv1 migration
This commit is contained in:
@@ -10,6 +10,10 @@ import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||
let CreatureProperties = new Mongo.Collection('creatureProperties');
|
||||
|
||||
let CreaturePropertySchema = new SimpleSchema({
|
||||
_migrationError: {
|
||||
type: String,
|
||||
optional: true,
|
||||
},
|
||||
type: {
|
||||
type: String,
|
||||
allowedValues: Object.keys(propertySchemasIndex),
|
||||
|
||||
@@ -1,7 +1,19 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import ErrorSchema from '/imports/api/properties/subSchemas/ErrorSchema.js';
|
||||
import InlineComputationSchema from '/imports/api/properties/subSchemas/InlineComputationSchema.js';
|
||||
import { storedIconsSchema } from '/imports/api/icons/Icons.js';
|
||||
import {
|
||||
InlineCalculationFieldToComputeSchema,
|
||||
ComputedOnlyInlineCalculationFieldSchema,
|
||||
InlineCalculationFieldSchema,
|
||||
} from '/imports/api/properties/subSchemas/InlineCalculationFieldSchema.js';
|
||||
import {
|
||||
FieldToComputeSchema,
|
||||
ComputedOnlyFieldSchema,
|
||||
ComputedFieldSchema,
|
||||
} from '/imports/api/properties/subSchemas/ComputedFieldSchema.js';
|
||||
import {
|
||||
ResourcesSchema,
|
||||
ResourcesComputedOnlySchema,
|
||||
ResourcesComputedSchema,
|
||||
} from '/imports/api/properties/subSchemas/ResourcesSchema.js';
|
||||
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||
|
||||
/*
|
||||
@@ -11,186 +23,75 @@ import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||
* to this action
|
||||
*/
|
||||
let ActionSchema = new SimpleSchema({
|
||||
name: {
|
||||
type: String,
|
||||
optional: true,
|
||||
name: {
|
||||
type: String,
|
||||
optional: true,
|
||||
max: STORAGE_LIMITS.name,
|
||||
},
|
||||
summary: {
|
||||
type: String,
|
||||
optional: true,
|
||||
max: STORAGE_LIMITS.summary,
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
optional: true,
|
||||
max: STORAGE_LIMITS.description,
|
||||
},
|
||||
// What time-resource is used to take the action in combat
|
||||
// long actions take longer than 1 round to cast
|
||||
actionType: {
|
||||
type: String,
|
||||
allowedValues: ['action', 'bonus', 'attack', 'reaction', 'free', 'long'],
|
||||
defaultValue: 'action',
|
||||
},
|
||||
// Who is the action directed at
|
||||
target: {
|
||||
type: String,
|
||||
defaultValue: 'singleTarget',
|
||||
allowedValues: [
|
||||
},
|
||||
summary: {
|
||||
type: InlineCalculationFieldToComputeSchema,
|
||||
optional: true,
|
||||
},
|
||||
description: {
|
||||
type: InlineCalculationFieldToComputeSchema,
|
||||
optional: true,
|
||||
},
|
||||
// What time-resource is used to take the action in combat
|
||||
// long actions take longer than 1 round to cast
|
||||
actionType: {
|
||||
type: String,
|
||||
allowedValues: ['action', 'bonus', 'attack', 'reaction', 'free', 'long'],
|
||||
defaultValue: 'action',
|
||||
},
|
||||
// Who is the action directed at
|
||||
target: {
|
||||
type: String,
|
||||
defaultValue: 'singleTarget',
|
||||
allowedValues: [
|
||||
'self',
|
||||
'singleTarget',
|
||||
'multipleTargets',
|
||||
'multipleTargets',
|
||||
],
|
||||
},
|
||||
// Duplicate the ResourceSchema here so we can extend it elegantly.
|
||||
},
|
||||
// Resources schema changes for between standard, computed, and computedOnly
|
||||
resources: {
|
||||
type: Object,
|
||||
type: ResourcesSchema,
|
||||
defaultValue: {},
|
||||
},
|
||||
'resources.itemsConsumed': {
|
||||
type: Array,
|
||||
defaultValue: [],
|
||||
maxCount: STORAGE_LIMITS.resourcesCount,
|
||||
},
|
||||
'resources.itemsConsumed.$': {
|
||||
type: Object,
|
||||
},
|
||||
'resources.itemsConsumed.$._id': {
|
||||
type: String,
|
||||
regEx: SimpleSchema.RegEx.Id,
|
||||
autoValue(){
|
||||
if (!this.isSet) return Random.id();
|
||||
}
|
||||
},
|
||||
'resources.itemsConsumed.$.tag': {
|
||||
type: String,
|
||||
// Calculation of how many times this action can be used
|
||||
uses: {
|
||||
type: FieldToComputeSchema,
|
||||
optional: true,
|
||||
max: STORAGE_LIMITS.tagLength,
|
||||
},
|
||||
'resources.itemsConsumed.$.quantity': {
|
||||
type: Number,
|
||||
defaultValue: 1,
|
||||
},
|
||||
'resources.itemsConsumed.$.itemId': {
|
||||
type: String,
|
||||
optional: true,
|
||||
max: STORAGE_LIMITS.name,
|
||||
},
|
||||
'resources.attributesConsumed': {
|
||||
type: Array,
|
||||
defaultValue: [],
|
||||
maxCount: STORAGE_LIMITS.resourcesCount,
|
||||
},
|
||||
'resources.attributesConsumed.$': {
|
||||
type: Object,
|
||||
},
|
||||
'resources.attributesConsumed.$._id': {
|
||||
type: String,
|
||||
regEx: SimpleSchema.RegEx.Id,
|
||||
autoValue(){
|
||||
if (!this.isSet) return Random.id();
|
||||
}
|
||||
},
|
||||
'resources.attributesConsumed.$.variableName': {
|
||||
type: String,
|
||||
optional: true,
|
||||
max: STORAGE_LIMITS.variableName,
|
||||
},
|
||||
'resources.attributesConsumed.$.quantity': {
|
||||
type: Number,
|
||||
defaultValue: 1,
|
||||
},
|
||||
// Calculation of how many times this action can be used
|
||||
uses: {
|
||||
type: String,
|
||||
optional: true,
|
||||
max: STORAGE_LIMITS.calculation,
|
||||
},
|
||||
// Integer of how many times it has already been used
|
||||
usesUsed: {
|
||||
type: SimpleSchema.Integer,
|
||||
optional: true,
|
||||
},
|
||||
// How this action's uses are reset automatically
|
||||
reset: {
|
||||
type: String,
|
||||
allowedValues: ['longRest', 'shortRest'],
|
||||
optional: true,
|
||||
},
|
||||
});
|
||||
|
||||
const ComputedOnlyActionSchema = new SimpleSchema({
|
||||
summaryCalculations: {
|
||||
type: Array,
|
||||
defaultValue: [],
|
||||
maxCount: STORAGE_LIMITS.inlineCalculationCount,
|
||||
},
|
||||
'summaryCalculations.$': InlineComputationSchema,
|
||||
|
||||
descriptionCalculations: {
|
||||
type: Array,
|
||||
defaultValue: [],
|
||||
maxCount: STORAGE_LIMITS.inlineCalculationCount,
|
||||
},
|
||||
'descriptionCalculations.$': InlineComputationSchema,
|
||||
|
||||
usesResult: {
|
||||
// Integer of how many times it has already been used
|
||||
usesUsed: {
|
||||
type: SimpleSchema.Integer,
|
||||
optional: true,
|
||||
},
|
||||
usesErrors: {
|
||||
type: Array,
|
||||
optional: true,
|
||||
maxCount: STORAGE_LIMITS.errorCount,
|
||||
},
|
||||
'usesErrors.$':{
|
||||
type: ErrorSchema,
|
||||
},
|
||||
resources: Object,
|
||||
'resources.itemsConsumed': Array,
|
||||
'resources.itemsConsumed.$': Object,
|
||||
'resources.itemsConsumed.$.available': {
|
||||
type: Number,
|
||||
optional: true,
|
||||
},
|
||||
// This appears both in the computed and uncomputed schema because it can be
|
||||
// set by both a computation or a form
|
||||
'resources.itemsConsumed.$.itemId': {
|
||||
// How this action's uses are reset automatically
|
||||
reset: {
|
||||
type: String,
|
||||
regEx: SimpleSchema.RegEx.Id,
|
||||
allowedValues: ['longRest', 'shortRest'],
|
||||
optional: true,
|
||||
},
|
||||
'resources.itemsConsumed.$.itemName': {
|
||||
type: String,
|
||||
max: STORAGE_LIMITS.name,
|
||||
});
|
||||
|
||||
const ComputedOnlyActionSchema = new SimpleSchema({
|
||||
summary: {
|
||||
type: ComputedOnlyInlineCalculationFieldSchema,
|
||||
optional: true,
|
||||
},
|
||||
'resources.itemsConsumed.$.itemIcon': {
|
||||
type: storedIconsSchema,
|
||||
optional: true,
|
||||
max: STORAGE_LIMITS.icon,
|
||||
},
|
||||
'resources.itemsConsumed.$.itemColor': {
|
||||
type: String,
|
||||
optional: true,
|
||||
max: STORAGE_LIMITS.color,
|
||||
},
|
||||
'resources.attributesConsumed': Array,
|
||||
'resources.attributesConsumed.$': Object,
|
||||
'resources.attributesConsumed.$.available': {
|
||||
type: Number,
|
||||
description: {
|
||||
type: ComputedOnlyInlineCalculationFieldSchema,
|
||||
optional: true,
|
||||
},
|
||||
'resources.attributesConsumed.$.statId': {
|
||||
type: String,
|
||||
regEx: SimpleSchema.RegEx.Id,
|
||||
uses: {
|
||||
type: ComputedOnlyFieldSchema,
|
||||
optional: true,
|
||||
},
|
||||
'resources.attributesConsumed.$.statName': {
|
||||
type: String,
|
||||
optional: true,
|
||||
max: STORAGE_LIMITS.name,
|
||||
resources: {
|
||||
type: ResourcesComputedOnlySchema,
|
||||
defaultValue: {},
|
||||
},
|
||||
// True if the uses left is zero, or any item or attribute consumed is
|
||||
// insufficient
|
||||
@@ -202,6 +103,24 @@ const ComputedOnlyActionSchema = new SimpleSchema({
|
||||
|
||||
const ComputedActionSchema = new SimpleSchema()
|
||||
.extend(ActionSchema)
|
||||
.extend(ComputedOnlyActionSchema);
|
||||
.extend(ComputedOnlyActionSchema)
|
||||
.extend({
|
||||
uses: {
|
||||
type: ComputedFieldSchema,
|
||||
optional: true,
|
||||
},
|
||||
summary: {
|
||||
type: InlineCalculationFieldSchema,
|
||||
optional: true,
|
||||
},
|
||||
description: {
|
||||
type: InlineCalculationFieldSchema,
|
||||
optional: true,
|
||||
},
|
||||
resources: {
|
||||
type: ResourcesComputedSchema,
|
||||
defaultValue: {},
|
||||
},
|
||||
});
|
||||
|
||||
export { ActionSchema, ComputedOnlyActionSchema, ComputedActionSchema};
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import { Random } from 'meteor/random';
|
||||
import {
|
||||
FieldToComputeSchema,
|
||||
ComputedOnlyFieldSchema,
|
||||
ComputedFieldSchema,
|
||||
} from '/imports/api/properties/subSchemas/ComputedFieldSchema.js';
|
||||
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||
|
||||
const AttributeConsumedSchema = new SimpleSchema({
|
||||
_id: {
|
||||
@@ -12,11 +18,47 @@ const AttributeConsumedSchema = new SimpleSchema({
|
||||
variableName: {
|
||||
type: String,
|
||||
optional: true,
|
||||
max: STORAGE_LIMITS.variableName,
|
||||
},
|
||||
quantity: {
|
||||
type: Number,
|
||||
defaultValue: 1,
|
||||
type: FieldToComputeSchema,
|
||||
optional: true,
|
||||
},
|
||||
});
|
||||
|
||||
export default AttributeConsumedSchema;
|
||||
const ComputedOnlyAttributeConsumedSchema = new SimpleSchema({
|
||||
available: {
|
||||
type: Number,
|
||||
optional: true,
|
||||
},
|
||||
statId: {
|
||||
type: String,
|
||||
regEx: SimpleSchema.RegEx.Id,
|
||||
optional: true,
|
||||
},
|
||||
statName: {
|
||||
type: String,
|
||||
optional: true,
|
||||
max: STORAGE_LIMITS.name,
|
||||
},
|
||||
quantity: {
|
||||
type: ComputedOnlyFieldSchema,
|
||||
optional: true,
|
||||
},
|
||||
});
|
||||
|
||||
const ComputedAttributeConsumedSchema = new SimpleSchema()
|
||||
.extend(AttributeConsumedSchema)
|
||||
.extend(ComputedOnlyAttributeConsumedSchema)
|
||||
.extend({
|
||||
quantity: {
|
||||
type: ComputedFieldSchema,
|
||||
optional: true,
|
||||
},
|
||||
});
|
||||
|
||||
export {
|
||||
AttributeConsumedSchema,
|
||||
ComputedOnlyAttributeConsumedSchema,
|
||||
ComputedAttributeConsumedSchema
|
||||
};
|
||||
|
||||
35
app/imports/api/properties/subSchemas/ComputedFieldSchema.js
Normal file
35
app/imports/api/properties/subSchemas/ComputedFieldSchema.js
Normal file
@@ -0,0 +1,35 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import ErrorSchema from '/imports/api/properties/subSchemas/ErrorSchema.js';
|
||||
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||
|
||||
const FieldToComputeSchema = new SimpleSchema({
|
||||
// This is required, if we don't have a calculation delete the whole object
|
||||
calculation: {
|
||||
type: String,
|
||||
},
|
||||
});
|
||||
|
||||
const ComputedOnlyFieldSchema = new SimpleSchema({
|
||||
value: {
|
||||
type: SimpleSchema.oneOf(String, Number),
|
||||
optional: true,
|
||||
},
|
||||
errors: {
|
||||
type: Array,
|
||||
optional: true,
|
||||
maxCount: STORAGE_LIMITS.errorCount,
|
||||
},
|
||||
'errors.$':{
|
||||
type: ErrorSchema,
|
||||
},
|
||||
});
|
||||
|
||||
const ComputedFieldSchema = new SimpleSchema()
|
||||
.extend(FieldToComputeSchema)
|
||||
.extend(ComputedOnlyFieldSchema)
|
||||
|
||||
export {
|
||||
FieldToComputeSchema,
|
||||
ComputedOnlyFieldSchema,
|
||||
ComputedFieldSchema
|
||||
};
|
||||
@@ -0,0 +1,37 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import InlineComputationSchema from '/imports/api/properties/subSchemas/InlineComputationSchema.js';
|
||||
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||
|
||||
const InlineCalculationFieldToComputeSchema = new SimpleSchema({
|
||||
text: {
|
||||
type: String,
|
||||
optional: true,
|
||||
max: STORAGE_LIMITS.inlineCalculationField,
|
||||
},
|
||||
});
|
||||
|
||||
const ComputedOnlyInlineCalculationFieldSchema = new SimpleSchema({
|
||||
'inlineCalculations': {
|
||||
type: Array,
|
||||
defaultValue: [],
|
||||
maxCount: STORAGE_LIMITS.inlineCalculationCount,
|
||||
},
|
||||
'inlineCalculations.$': {
|
||||
type: InlineComputationSchema,
|
||||
},
|
||||
value: {
|
||||
type: String,
|
||||
optional: true,
|
||||
max: STORAGE_LIMITS.inlineCalculationField,
|
||||
},
|
||||
});
|
||||
|
||||
const InlineCalculationFieldSchema = new SimpleSchema()
|
||||
.extend(InlineCalculationFieldToComputeSchema)
|
||||
.extend(ComputedOnlyInlineCalculationFieldSchema)
|
||||
|
||||
export {
|
||||
InlineCalculationFieldToComputeSchema,
|
||||
ComputedOnlyInlineCalculationFieldSchema,
|
||||
InlineCalculationFieldSchema,
|
||||
};
|
||||
@@ -8,8 +8,8 @@ const InlineComputationSchema = new SimpleSchema({
|
||||
type: String,
|
||||
max: STORAGE_LIMITS.calculation,
|
||||
},
|
||||
result: {
|
||||
type: String,
|
||||
value: {
|
||||
type: SimpleSchema.oneOf(String, Number),
|
||||
optional: true,
|
||||
max: STORAGE_LIMITS.calculation,
|
||||
},
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import { Random } from 'meteor/random';
|
||||
import {
|
||||
FieldToComputeSchema,
|
||||
ComputedOnlyFieldSchema,
|
||||
ComputedFieldSchema,
|
||||
} from '/imports/api/properties/subSchemas/ComputedFieldSchema.js';
|
||||
import { storedIconsSchema } from '/imports/api/icons/Icons.js';
|
||||
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||
|
||||
const ItemConsumedSchema = new SimpleSchema({
|
||||
_id: {
|
||||
@@ -14,13 +21,61 @@ const ItemConsumedSchema = new SimpleSchema({
|
||||
optional: true,
|
||||
},
|
||||
quantity: {
|
||||
type: Number,
|
||||
defaultValue: 1,
|
||||
type: FieldToComputeSchema,
|
||||
optional: true,
|
||||
},
|
||||
itemId: {
|
||||
type: String,
|
||||
regEx: SimpleSchema.RegEx.Id,
|
||||
optional: true,
|
||||
},
|
||||
});
|
||||
|
||||
export default ItemConsumedSchema;
|
||||
const ComputedOnlyItemConsumedSchema = new SimpleSchema({
|
||||
available: {
|
||||
type: Number,
|
||||
optional: true,
|
||||
},
|
||||
quantity: {
|
||||
type: ComputedOnlyFieldSchema,
|
||||
optional: true,
|
||||
},
|
||||
// This appears both in the computed and uncomputed schema because it can be
|
||||
// set by both a computation or a form
|
||||
itemId: {
|
||||
type: String,
|
||||
regEx: SimpleSchema.RegEx.Id,
|
||||
optional: true,
|
||||
},
|
||||
itemName: {
|
||||
type: String,
|
||||
max: STORAGE_LIMITS.name,
|
||||
optional: true,
|
||||
},
|
||||
itemIcon: {
|
||||
type: storedIconsSchema,
|
||||
optional: true,
|
||||
max: STORAGE_LIMITS.icon,
|
||||
},
|
||||
itemColor: {
|
||||
type: String,
|
||||
optional: true,
|
||||
max: STORAGE_LIMITS.color,
|
||||
},
|
||||
})
|
||||
|
||||
const ComputedItemConsumedSchema = new SimpleSchema()
|
||||
.extend(ItemConsumedSchema)
|
||||
.extend(ComputedOnlyItemConsumedSchema)
|
||||
.extend({
|
||||
quantity: {
|
||||
type: ComputedFieldSchema,
|
||||
optional: true,
|
||||
},
|
||||
});
|
||||
|
||||
export {
|
||||
ItemConsumedSchema,
|
||||
ComputedOnlyItemConsumedSchema,
|
||||
ComputedItemConsumedSchema
|
||||
};
|
||||
|
||||
@@ -1,6 +1,14 @@
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import ItemConsumedSchema from '/imports/api/properties/subSchemas/ItemConsumedSchema.js';
|
||||
import AttributeConsumedSchema from '/imports/api/properties/subSchemas/AttributeConsumedSchema.js';
|
||||
import {
|
||||
ItemConsumedSchema,
|
||||
ComputedOnlyItemConsumedSchema,
|
||||
ComputedItemConsumedSchema
|
||||
} from '/imports/api/properties/subSchemas/ItemConsumedSchema.js';
|
||||
import {
|
||||
AttributeConsumedSchema,
|
||||
ComputedOnlyAttributeConsumedSchema,
|
||||
ComputedAttributeConsumedSchema
|
||||
} from '/imports/api/properties/subSchemas/AttributeConsumedSchema.js';
|
||||
|
||||
const ResourcesSchema = new SimpleSchema({
|
||||
itemsConsumed: {
|
||||
@@ -19,4 +27,42 @@ const ResourcesSchema = new SimpleSchema({
|
||||
},
|
||||
});
|
||||
|
||||
export default ResourcesSchema;
|
||||
const ResourcesComputedOnlySchema = new SimpleSchema({
|
||||
itemsConsumed: {
|
||||
type: Array,
|
||||
defaultValue: [],
|
||||
},
|
||||
'itemsConsumed.$': {
|
||||
type: ComputedOnlyItemConsumedSchema,
|
||||
},
|
||||
attributesConsumed: {
|
||||
type: Array,
|
||||
defaultValue: [],
|
||||
},
|
||||
'attributesConsumed.$': {
|
||||
type: ComputedOnlyAttributeConsumedSchema,
|
||||
},
|
||||
});
|
||||
|
||||
const ResourcesComputedSchema = new SimpleSchema({
|
||||
itemsConsumed: {
|
||||
type: Array,
|
||||
defaultValue: [],
|
||||
},
|
||||
'itemsConsumed.$': {
|
||||
type: ComputedItemConsumedSchema,
|
||||
},
|
||||
attributesConsumed: {
|
||||
type: Array,
|
||||
defaultValue: [],
|
||||
},
|
||||
'attributesConsumed.$': {
|
||||
type: ComputedAttributeConsumedSchema,
|
||||
},
|
||||
});
|
||||
|
||||
export {
|
||||
ResourcesSchema,
|
||||
ResourcesComputedOnlySchema,
|
||||
ResourcesComputedSchema,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user