Files
DiceCloud/app/imports/api/properties/Adjustments.js

49 lines
1.3 KiB
JavaScript

import SimpleSchema from 'simpl-schema';
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
import {
fieldToCompute,
computedOnlyField,
} from '/imports/api/properties/subSchemas/ComputedFieldSchema.js';
const AdjustmentSchema = new SimpleSchema({
// The roll that determines how much to change the attribute
// This can be simplified, but should only compute when activated
amount: {
type: Object,
optional: true,
},
'amount.calculation': {
type: String,
defaultValue: 1,
},
// Who this adjustment applies to
target: {
type: String,
defaultValue: 'every',
allowedValues: [
'self', // the character who took the Adjustment
'each', // rolled once for `each` target
'every', // rolled once and applied to `every` target
],
},
// The stat this rolls applies to
stat: {
type: String,
optional: true,
max: STORAGE_LIMITS.variableName,
},
operation: {
type: String,
allowedValues: ['set', 'increment'],
defaultValue: 'increment',
},
}).extend(fieldToCompute('amount'));
const ComputedOnlyAdjustmentSchema = computedOnlyField('amount');
const ComputedAdjustmentSchema = new SimpleSchema()
.extend(AdjustmentSchema)
.extend(ComputedOnlyAdjustmentSchema);
export { AdjustmentSchema, ComputedAdjustmentSchema, ComputedOnlyAdjustmentSchema };