more small progress on migration

This commit is contained in:
Stefan Zermatten
2021-09-07 15:48:51 +02:00
parent b0980d26ac
commit 43f056ae95
5 changed files with 34 additions and 51 deletions

View File

@@ -86,6 +86,10 @@ const ComputedOnlyActionSchema = createPropertySchema({
type: Boolean,
optional: true,
},
uses: {
type: 'computedOnlyField',
optional: true,
},
});
const ComputedActionSchema = new SimpleSchema()

View File

@@ -1,18 +1,15 @@
import SimpleSchema from 'simpl-schema';
import { ActionSchema, ComputedOnlyActionSchema } from '/imports/api/properties/Actions.js';
import {
fieldToCompute,
computedOnlyField,
} from '/imports/api/properties/subSchemas/ComputedFieldSchema.js';
import createPropertySchema from '/imports/api/properties/subSchemas/createPropertySchema.js';
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
// Attacks are special instances of actions
let AttackSchema = new SimpleSchema()
.extend(ActionSchema)
.extend({
.extend(createPropertySchema({
// What gets added to the d20 roll
rollBonus: {
type: Object,
type: 'fieldToCompute',
optional: true,
},
'rollBonus.calculation': {
@@ -34,11 +31,16 @@ let AttackSchema = new SimpleSchema()
type: String,
max: STORAGE_LIMITS.tagLength,
},
}).extend(fieldToCompute('rollBonus'));
}));
const ComputedOnlyAttackSchema = new SimpleSchema()
.extend(ComputedOnlyActionSchema)
.extend(computedOnlyField('rollBonus'));
.extend(createPropertySchema({
rollBonus: {
type: 'computedOnlyField',
optional: true,
},
}));
const ComputedAttackSchema = new SimpleSchema()
.extend(AttackSchema)

View File

@@ -1,13 +1,12 @@
import SimpleSchema from 'simpl-schema';
import ErrorSchema from '/imports/api/properties/subSchemas/ErrorSchema.js';
import VARIABLE_NAME_REGEX from '/imports/constants/VARIABLE_NAME_REGEX.js';
import InlineComputationSchema from '/imports/api/properties/subSchemas/InlineComputationSchema.js';
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
import createPropertySchema from '/imports/api/properties/subSchemas/createPropertySchema.js';
/*
* Attributes are numbered stats of a character
*/
let AttributeSchema = new SimpleSchema({
let AttributeSchema = createPropertySchema({
name: {
type: String,
defaultValue: 'New Attribute',
@@ -41,24 +40,22 @@ let AttributeSchema = new SimpleSchema({
// For type hitDice, the size needs to be stored separately
hitDiceSize: {
type: String,
allowedValues: ['d4', 'd6', 'd8', 'd10', 'd12', 'd20'],
allowedValues: ['d1', 'd2', 'd4', 'd6', 'd8', 'd10', 'd12', 'd20', 'd100'],
optional: true,
},
// For type spellSlot, the level needs to be stored separately
spellSlotLevelCalculation: {
type: String,
spellSlotLevel: {
type: 'fieldToCompute',
optional: true,
max: STORAGE_LIMITS.calculation,
},
// The starting value, before effects
baseValueCalculation: {
type: String,
baseValue: {
type: 'fieldToCompute',
optional: true,
max: STORAGE_LIMITS.calculation,
},
// Description of what the attribute is used for
description: {
type: String,
type: 'inlineCalculationFieldToCompute',
optional: true,
max: STORAGE_LIMITS.description,
},
@@ -81,47 +78,27 @@ let AttributeSchema = new SimpleSchema({
},
});
let ComputedOnlyAttributeSchema = new SimpleSchema({
descriptionCalculations: {
type: Array,
defaultValue: [],
maxCount: STORAGE_LIMITS.inlineCalculationCount,
let ComputedOnlyAttributeSchema = createPropertySchema({
description: {
type: 'computedOnlyInlineCalculationField',
optional: true,
},
'descriptionCalculations.$': InlineComputationSchema,
// The result of baseValueCalculation
baseValue: {
type: SimpleSchema.oneOf(Number, String, Boolean),
type: 'computedOnlyField',
optional: true,
},
baseValueErrors: {
type: Array,
optional: true,
},
'baseValueErrors.$': {
type: ErrorSchema,
maxCount: STORAGE_LIMITS.errorCount,
},
// The result of spellSlotLevelCalculation
spellSlotLevelValue: {
type: SimpleSchema.oneOf(Number, String, Boolean),
optional: true,
},
spellSlotLevelErrors: {
type: Array,
optional: true,
maxCount: STORAGE_LIMITS.errorCount,
},
'spellSlotLevelErrors.$': {
type: ErrorSchema,
spellSlotLevel: {
type: 'computedOnlyField',
optional: true,
},
// The computed value of the attribute
value: {
total: {
type: SimpleSchema.oneOf(Number, String, Boolean),
defaultValue: 0,
optional: true,
},
// The computed value of the attribute minus the damage
currentValue: {
value: {
type: SimpleSchema.oneOf(Number, String, Boolean),
defaultValue: 0,
optional: true,

View File

@@ -11,7 +11,7 @@ const exampleAction = {
'itemsConsumed':[],
'attributesConsumed':[{
'_id':'FaK6jXEj3pSe7mNuu',
'quantity':1,
'quantity': '1',
'variableName':'HunterTech',
'statId':'qccf9j5tfNJjZ3GGn',
'statName':'Hunter\'s Technique',

View File

@@ -94,7 +94,7 @@
>
<v-btn
color="accent"
round
rounded
large
to="/sign-in"
>