diff --git a/app/imports/api/library/librarySchemas.js b/app/imports/api/library/librarySchemas.js index a98f566f..83352ed7 100644 --- a/app/imports/api/library/librarySchemas.js +++ b/app/imports/api/library/librarySchemas.js @@ -1,5 +1,6 @@ import SimpleSchema from 'simpl-schema'; import { ActionSchema } from '/imports/api/properties/Actions.js'; +import { AttackSchema } from '/imports/api/properties/Attacks.js'; import { AttributeSchema } from '/imports/api/properties/Attributes.js'; import { StoredBuffSchema } from '/imports/api/properties/Buffs.js'; import { ClassLevelSchema } from '/imports/api/properties/ClassLevels.js'; @@ -19,6 +20,7 @@ import { ItemSchema } from '/imports/api/properties/Items.js'; const librarySchemas = { action: ActionSchema, + attack: AttackSchema, attribute: AttributeSchema, buff: StoredBuffSchema, classLevel: ClassLevelSchema, diff --git a/app/imports/api/properties/Actions.js b/app/imports/api/properties/Actions.js index 16a02879..04024a8b 100644 --- a/app/imports/api/properties/Actions.js +++ b/app/imports/api/properties/Actions.js @@ -1,5 +1,6 @@ import SimpleSchema from 'simpl-schema'; import AdjustmentSchema from '/imports/api/properties/subSchemas/AdjustmentSchema.js'; +import DamageSchema from '/imports/api/properties/subSchemas/DamageSchema.js'; import { StoredBuffWithIdSchema } from '/imports/api/properties/Buffs.js'; /* @@ -19,7 +20,7 @@ let ActionSchema = new SimpleSchema({ }, // What time-resource is used to take the action in combat // long actions take longer than 1 round to cast - type: { + actionType: { type: String, allowedValues: ['action', 'bonus', 'attack', 'reaction', 'free', 'long'], defaultValue: 'action', @@ -52,6 +53,13 @@ let ActionSchema = new SimpleSchema({ 'adjustments.$': { type: AdjustmentSchema, }, + damages: { + type: Array, + defaultValue: [], + }, + 'damages.$': { + type: DamageSchema, + }, // Buffs applied when taking this action buffs: { type: Array, diff --git a/app/imports/api/properties/Attacks.js b/app/imports/api/properties/Attacks.js index b6460266..1d484ba6 100644 --- a/app/imports/api/properties/Attacks.js +++ b/app/imports/api/properties/Attacks.js @@ -1,5 +1,4 @@ import SimpleSchema from 'simpl-schema'; -import AdjustmentSchema from '/imports/api/properties/subSchemas/AdjustmentSchema.js'; import { ActionSchema } from '/imports/api/properties/Actions.js'; // Attacks are special instances of actions @@ -9,16 +8,9 @@ let AttackSchema = new SimpleSchema() // What gets added to the d20 roll rollBonus: { type: String, + defaultValue: 'strength.modifier + proficiencyBonus', optional: true, }, - // What damage does it do to the targets - adjustments: { - type: Array, - defaultValue: [], - }, - 'adjustments.$': { - type: AdjustmentSchema, - }, // If set reference an item whose quantity is reduced by 1 every time this // attack is rolled ammunition: { @@ -27,12 +19,16 @@ let AttackSchema = new SimpleSchema() optional: true, }, // Set better defaults for the action - type: { + actionType: { defaultValue: 'attack', }, tags: { + type: Array, defaultValue: ['attack'], }, + 'tags.$': { + type: String, + }, }); export { AttackSchema }; diff --git a/app/imports/api/properties/Effects.js b/app/imports/api/properties/Effects.js index 39ee063c..fee9cd3c 100644 --- a/app/imports/api/properties/Effects.js +++ b/app/imports/api/properties/Effects.js @@ -29,6 +29,16 @@ let EffectSchema = new SimpleSchema({ type: String, optional: true, }, + statType: { + type: String, + allowedValues: [ + 'attribute', + 'skill', + 'roll', + 'attack', + 'damage', + ], + }, //which stats the effect is applied to stats: { type: Array, diff --git a/app/imports/api/properties/Items.js b/app/imports/api/properties/Items.js index 49363008..c2758e0d 100644 --- a/app/imports/api/properties/Items.js +++ b/app/imports/api/properties/Items.js @@ -1,4 +1,5 @@ import SimpleSchema from 'simpl-schema'; +import VARIABLE_NAME_REGEX from '/imports/constants/VARIABLE_NAME_REGEX.js'; ItemSchema = new SimpleSchema({ name: { @@ -6,6 +7,13 @@ ItemSchema = new SimpleSchema({ optional: true, defaultValue: "New Item", }, + // Variable name to reference this item as ammunition or in formulae + variableName: { + type: String, + regEx: VARIABLE_NAME_REGEX, + min: 3, + defaultValue: 'newAttribute', + }, // Plural name of the item, if there is more than one plural: { type: String, diff --git a/app/imports/api/properties/RollModifier.js b/app/imports/api/properties/RollModifier.js deleted file mode 100644 index a97eedc9..00000000 --- a/app/imports/api/properties/RollModifier.js +++ /dev/null @@ -1,53 +0,0 @@ -import SimpleSchema from 'simpl-schema'; - -/* - * RollModifiers are reason-value attached to rolls - * that modify their final value in some way - * These are separate from effects because they never cause a recomputation - * themselves - */ -let RollModifierSchema = new SimpleSchema({ - name: { - type: String, - optional: true, - }, - operation: { - type: String, - defaultValue: 'rollBonus', - allowedValues: [ - 'rollBonus', - 'damageBonus', - 'advantage', - ], - }, - calculation: { - type: String, - optional: true, - }, - // which tags the modifier is applied to - // all tags must match - 'tags.$': { - type: String, - optional: true, - }, -}); - -const StoredRollModifierSchema = new SimpleSchema({ - _id: { - type: String, - regEx: SimpleSchema.RegEx.Id, - autoValue(){ - if (!this.isSet) return Random.id(); - } - }, -}).extend(RollModifierSchema); - -const ComputedRollModifierSchema = new SimpleSchema({ - // The computed result of the effect - result: { - type: SimpleSchema.oneOf(Number, String), - optional: true, - }, -}).extend(RollModifierSchema); - -export { RollModifierSchema, StoredRollModifierSchema, ComputedRollModifierSchema }; diff --git a/app/imports/api/properties/RollResults.js b/app/imports/api/properties/RollResults.js deleted file mode 100644 index 39b67708..00000000 --- a/app/imports/api/properties/RollResults.js +++ /dev/null @@ -1,27 +0,0 @@ -import SimpleSchema from 'simpl-schema'; -import AdjustmentSchema from '/imports/api/creature/subSchemas/AdjustmentSchema.js'; -import { StoredBuffWithIdSchema } from '/imports/api/properties/Buffs.js'; - -let RollResultSchema = new SimpleSchema ({ - // Expression of whether or not to apply - comparison: { - type: String, - optional: true, - }, - adjustments: { - type: Array, - defaultValue: [], - }, - 'adjustments.$': { - type: AdjustmentSchema, - }, - buffs: { - type: Array, - defaultValue: [], - }, - 'buffs.$': { - type: StoredBuffWithIdSchema, - }, -}); - -export { RollResultSchema }; diff --git a/app/imports/api/properties/Rolls.js b/app/imports/api/properties/Rolls.js index dc97f201..57756add 100644 --- a/app/imports/api/properties/Rolls.js +++ b/app/imports/api/properties/Rolls.js @@ -1,4 +1,5 @@ import SimpleSchema from 'simpl-schema'; +import { RollResultsSchema } from '/imports/api/properties/subSchemas/RollResultsSchema.js' /** * Rolls are children to actions or other rolls, they are triggered with 0 or @@ -33,6 +34,13 @@ let RollSchema = new SimpleSchema({ 'tags.$': { type: String, }, + results: { + type: Array, + defaultValue: [], + }, + 'results.$': { + type: RollResultsSchema, + }, }); export { RollSchema }; diff --git a/app/imports/api/properties/subSchemas/AdjustmentSchema.js b/app/imports/api/properties/subSchemas/AdjustmentSchema.js index c23393d1..04031e2a 100644 --- a/app/imports/api/properties/subSchemas/AdjustmentSchema.js +++ b/app/imports/api/properties/subSchemas/AdjustmentSchema.js @@ -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; diff --git a/app/imports/api/properties/subSchemas/DamageSchema.js b/app/imports/api/properties/subSchemas/DamageSchema.js new file mode 100644 index 00000000..ab9400ab --- /dev/null +++ b/app/imports/api/properties/subSchemas/DamageSchema.js @@ -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; diff --git a/app/imports/api/properties/subSchemas/RollResultsSchema.js b/app/imports/api/properties/subSchemas/RollResultsSchema.js new file mode 100644 index 00000000..cd8ddadd --- /dev/null +++ b/app/imports/api/properties/subSchemas/RollResultsSchema.js @@ -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 }; diff --git a/app/imports/constants/PROPERTIES.js b/app/imports/constants/PROPERTIES.js index 60723516..8e762d67 100644 --- a/app/imports/constants/PROPERTIES.js +++ b/app/imports/constants/PROPERTIES.js @@ -3,6 +3,10 @@ const PROPERTIES = Object.freeze({ icon: 'offline_bolt', name: 'Action' }, + attack: { + icon: 'bolt', + name: 'Attack' + }, attribute: { icon: 'donut_small', name: 'Attribute' diff --git a/app/imports/ui/properties/forms/ActionForm.vue b/app/imports/ui/properties/forms/ActionForm.vue index f291597e..8c0a344b 100644 --- a/app/imports/ui/properties/forms/ActionForm.vue +++ b/app/imports/ui/properties/forms/ActionForm.vue @@ -1,5 +1,5 @@