Data changes to make attacks top level objects
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 };
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 };
|
||||
@@ -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 };
|
||||
@@ -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 };
|
||||
|
||||
@@ -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;
|
||||
|
||||
36
app/imports/api/properties/subSchemas/DamageSchema.js
Normal file
36
app/imports/api/properties/subSchemas/DamageSchema.js
Normal 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;
|
||||
37
app/imports/api/properties/subSchemas/RollResultsSchema.js
Normal file
37
app/imports/api/properties/subSchemas/RollResultsSchema.js
Normal 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 };
|
||||
Reference in New Issue
Block a user