Files
DiceCloud/app/imports/api/properties/Adjustments.ts
2025-05-02 15:38:18 +02:00

54 lines
1.4 KiB
TypeScript

import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS';
import createPropertySchema from '/imports/api/properties/subSchemas/createPropertySchema';
import { TypedSimpleSchema } from '/imports/api/utility/TypedSimpleSchema';
const AdjustmentSchema = createPropertySchema({
// The roll that determines how much to change the attribute
// This can be simplified, but should only compute when activated
amount: {
type: 'fieldToCompute' as const,
parseLevel: 'compile',
optional: true,
defaultValue: 1,
},
// Who this adjustment applies to
target: {
type: String,
defaultValue: 'target',
allowedValues: [
'self',
'target',
] as const,
},
// The stat this rolls applies to
stat: {
type: String,
optional: true,
max: STORAGE_LIMITS.variableName,
},
operation: {
type: String,
allowedValues: ['set', 'increment'] as const,
defaultValue: 'increment',
},
// Prevent the property from showing up in the log
silent: {
type: Boolean,
optional: true,
},
});
const ComputedOnlyAdjustmentSchema = createPropertySchema({
amount: {
type: 'computedOnlyField' as const,
parseLevel: 'compile',
optional: true,
},
});
const ComputedAdjustmentSchema = TypedSimpleSchema.from({})
.extend(AdjustmentSchema)
.extend(ComputedOnlyAdjustmentSchema);
export { AdjustmentSchema, ComputedAdjustmentSchema, ComputedOnlyAdjustmentSchema };