Began merging attacks into actions

This commit is contained in:
Stefan Zermatten
2021-10-06 14:57:13 +02:00
parent 1a14393031
commit 0097696cc8
10 changed files with 23 additions and 71 deletions

View File

@@ -1,6 +1,5 @@
const linkDependenciesByType = {
action: linkResources,
attack: linkResources,
attribute: linkAttribute,
class: linkVariableName,
classLevel: linkClassLevel,

View File

@@ -7,8 +7,8 @@ import container from './computeByType/computeContainer.js';
export default Object.freeze({
_variable,
action,
attack: action,
attribute,
container,
slot,
spell: action,
});

View File

@@ -40,6 +40,12 @@ let ActionSchema = createPropertySchema({
'multipleTargets',
],
},
// Some actions have an attack roll
attackRoll: {
type: 'fieldToCompute',
optional: true,
defaultValue: 'strength.modifier + proficiencyBonus',
},
// Calculation of how many times this action can be used
uses: {
type: 'fieldToCompute',
@@ -129,6 +135,10 @@ const ComputedOnlyActionSchema = createPropertySchema({
optional: true,
removeBeforeCompute: true,
},
attackRoll: {
type: 'computedOnlyField',
optional: true,
},
uses: {
type: 'computedOnlyField',
optional: true,

View File

@@ -1,46 +0,0 @@
import SimpleSchema from 'simpl-schema';
import { ActionSchema, ComputedOnlyActionSchema } from '/imports/api/properties/Actions.js';
import createPropertySchema from '/imports/api/properties/subSchemas/createPropertySchema.js';
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
// Attacks are special instances of actions
let AttackSchema = new SimpleSchema()
.extend(ActionSchema)
.extend(createPropertySchema({
// What gets added to the d20 roll
rollBonus: {
type: 'fieldToCompute',
optional: true,
defaultValue: 'strength.modifier + proficiencyBonus',
},
// Set better defaults for the action
actionType: {
type: String,
defaultValue: 'attack',
max: STORAGE_LIMITS.name,
},
tags: {
type: Array,
defaultValue: ['attack'],
maxCount: STORAGE_LIMITS.tagCount,
},
'tags.$': {
type: String,
max: STORAGE_LIMITS.tagLength,
},
}));
const ComputedOnlyAttackSchema = new SimpleSchema()
.extend(ComputedOnlyActionSchema)
.extend(createPropertySchema({
rollBonus: {
type: 'computedOnlyField',
optional: true,
},
}));
const ComputedAttackSchema = new SimpleSchema()
.extend(AttackSchema)
.extend(ComputedOnlyAttackSchema);
export { AttackSchema, ComputedOnlyAttackSchema, ComputedAttackSchema };

View File

@@ -1,7 +1,6 @@
import SimpleSchema from 'simpl-schema';
import { ComputedOnlyActionSchema } from '/imports/api/properties/Actions.js';
import { ComputedOnlyAdjustmentSchema } from '/imports/api/properties/Adjustments.js';
import { ComputedOnlyAttackSchema } from '/imports/api/properties/Attacks.js';
import { ComputedOnlyAttributeSchema } from '/imports/api/properties/Attributes.js';
import { ComputedOnlyBuffSchema } from '/imports/api/properties/Buffs.js';
import { ComputedOnlyClassSchema } from '/imports/api/properties/Classes.js';
@@ -29,7 +28,6 @@ import { ComputedOnlyToggleSchema } from '/imports/api/properties/Toggles.js';
const propertySchemasIndex = {
action: ComputedOnlyActionSchema,
adjustment: ComputedOnlyAdjustmentSchema,
attack: ComputedOnlyAttackSchema,
attribute: ComputedOnlyAttributeSchema,
buff: ComputedOnlyBuffSchema,
class: ComputedOnlyClassSchema,

View File

@@ -1,7 +1,6 @@
import SimpleSchema from 'simpl-schema';
import { ComputedActionSchema } from '/imports/api/properties/Actions.js';
import { ComputedAdjustmentSchema } from '/imports/api/properties/Adjustments.js';
import { ComputedAttackSchema } from '/imports/api/properties/Attacks.js';
import { ComputedAttributeSchema } from '/imports/api/properties/Attributes.js';
import { ComputedBuffSchema } from '/imports/api/properties/Buffs.js';
import { ComputedClassSchema } from '/imports/api/properties/Classes.js';
@@ -29,7 +28,6 @@ import { ComputedToggleSchema } from '/imports/api/properties/Toggles.js';
const propertySchemasIndex = {
action: ComputedActionSchema,
adjustment: ComputedAdjustmentSchema,
attack: ComputedAttackSchema,
attribute: ComputedAttributeSchema,
buff: ComputedBuffSchema,
class: ComputedClassSchema,

View File

@@ -1,7 +1,6 @@
import SimpleSchema from 'simpl-schema';
import { ActionSchema } from '/imports/api/properties/Actions.js';
import { AdjustmentSchema } from '/imports/api/properties/Adjustments.js';
import { AttackSchema } from '/imports/api/properties/Attacks.js';
import { AttributeSchema } from '/imports/api/properties/Attributes.js';
import { BuffSchema } from '/imports/api/properties/Buffs.js';
import { ClassSchema } from '/imports/api/properties/Classes.js';
@@ -29,7 +28,6 @@ import { ItemSchema } from '/imports/api/properties/Items.js';
const propertySchemasIndex = {
action: ActionSchema,
adjustment: AdjustmentSchema,
attack: AttackSchema,
attribute: AttributeSchema,
buff: BuffSchema,
class: ClassSchema,