Data changes to make attacks top level objects

This commit is contained in:
Stefan Zermatten
2019-09-19 16:03:46 +02:00
parent 63a20b2bef
commit 66d11d58f3
19 changed files with 368 additions and 201 deletions

View File

@@ -1,6 +1,5 @@
import SimpleSchema from 'simpl-schema';
import { Random } from 'meteor/random';
import DAMAGE_TYPES from '/imports/constants/DAMAGE_TYPES.js';
const AdjustmentSchema = new SimpleSchema({
_id: {
@@ -10,8 +9,8 @@ const AdjustmentSchema = new SimpleSchema({
if (!this.isSet) return Random.id();
}
},
// The roll that determines how much to damage the attribute
damage: {
// The roll that determines how much to change the attribute
adjustment: {
type: String,
optional: true,
defaultValue: '1',
@@ -31,12 +30,6 @@ const AdjustmentSchema = new SimpleSchema({
type: String,
optional: true,
},
// If set, the type of damage this adjustment causes
damageType: {
type: String,
allowedValues: DAMAGE_TYPES,
optional: true,
},
});
export default AdjustmentSchema;

View File

@@ -0,0 +1,36 @@
import SimpleSchema from 'simpl-schema';
import { Random } from 'meteor/random';
import DAMAGE_TYPES from '/imports/constants/DAMAGE_TYPES.js';
const DamageSchema = new SimpleSchema({
_id: {
type: String,
regEx: SimpleSchema.RegEx.Id,
autoValue(){
if (!this.isSet) return Random.id();
}
},
// The roll that determines how much to damage the attribute
damage: {
type: String,
optional: true,
defaultValue: '1d8 + strength.modifier',
},
// Who this adjustment applies to
target: {
type: String,
defaultValue: 'every',
allowedValues: [
'self', // the character who took the action
'each', // rolled once for `each` target
'every', // rolled once and applied to `every` target
],
},
damageType: {
type: String,
allowedValues: DAMAGE_TYPES,
defaultValue: 'slashing',
},
});
export default DamageSchema;

View File

@@ -0,0 +1,37 @@
import SimpleSchema from 'simpl-schema';
import AdjustmentSchema from '/imports/api/properties/subSchemas/AdjustmentSchema.js';
import DamageSchema from '/imports/api/properties/subSchemas/AdjustmentSchema.js';
import { StoredBuffWithIdSchema } from '/imports/api/properties/Buffs.js';
let RollResultsSchema = new SimpleSchema ({
// Expression of whether or not to apply the roll
// Evaluates to an expression which gets compared to the roll
// or a number which the roll must equal
comparison: {
type: String,
optional: true,
},
damages: {
type: Array,
defaultValue: [],
},
'damages.$': {
type: DamageSchema,
},
adjustments: {
type: Array,
defaultValue: [],
},
'adjustments.$': {
type: AdjustmentSchema,
},
buffs: {
type: Array,
defaultValue: [],
},
'buffs.$': {
type: StoredBuffWithIdSchema,
},
});
export { RollResultsSchema };