Began merging attacks into actions
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
const linkDependenciesByType = {
|
||||
action: linkResources,
|
||||
attack: linkResources,
|
||||
attribute: linkAttribute,
|
||||
class: linkVariableName,
|
||||
classLevel: linkClassLevel,
|
||||
|
||||
@@ -7,8 +7,8 @@ import container from './computeByType/computeContainer.js';
|
||||
export default Object.freeze({
|
||||
_variable,
|
||||
action,
|
||||
attack: action,
|
||||
attribute,
|
||||
container,
|
||||
slot,
|
||||
spell: action,
|
||||
});
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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 };
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -74,7 +74,9 @@ const transformsByPropType = {
|
||||
],
|
||||
'attack': [
|
||||
...actionTransforms,
|
||||
...getComputedPropertyTransforms('rollBonus'),
|
||||
...getComputedPropertyTransforms('rollBonus', 'attackRoll'),
|
||||
//change type to action
|
||||
{from: 'type', to: 'type', up: () => 'action'},
|
||||
],
|
||||
'attribute': [
|
||||
...getComputedPropertyTransforms('baseValue'),
|
||||
@@ -158,11 +160,12 @@ const transformsByPropType = {
|
||||
],
|
||||
};
|
||||
|
||||
function getComputedPropertyTransforms(key){
|
||||
function getComputedPropertyTransforms(key, toKey){
|
||||
if (!toKey) toKey = key;
|
||||
return [
|
||||
{from: key, to: `${key}.calculation`},
|
||||
{from: `${key}Result`, to: `${key}.value`, up: nanToNull},
|
||||
{from: `${key}Errors`, to: `${key}.errors`, up: trimErrors},
|
||||
{from: `${key}Result`, to: `${toKey}.value`, up: nanToNull},
|
||||
{from: `${key}Errors`, to: `${toKey}.errors`, up: trimErrors},
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
:disabled="model.insufficientResources || !context.editPermission"
|
||||
@click.stop="doAction"
|
||||
>
|
||||
<template v-if="attack && !rollBonusTooLong">
|
||||
<template v-if="rollBonus && !rollBonusTooLong">
|
||||
{{ rollBonus }}
|
||||
</template>
|
||||
<property-icon
|
||||
@@ -122,9 +122,6 @@ export default {
|
||||
type: Object,
|
||||
required: true,
|
||||
},
|
||||
attack: {
|
||||
type: Boolean,
|
||||
},
|
||||
},
|
||||
data(){return {
|
||||
activated: undefined,
|
||||
@@ -133,7 +130,7 @@ export default {
|
||||
}},
|
||||
computed: {
|
||||
rollBonus(){
|
||||
if (!this.attack || !this.model.rollBonus) return;
|
||||
if (!this.model.rollBonus) return;
|
||||
return numberToSignedString(this.model.rollBonus.value);
|
||||
},
|
||||
rollBonusTooLong(){
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<template lang="html">
|
||||
<div :class="attackForm ? 'attack-form' : 'action-form'">
|
||||
<div class="action-form">
|
||||
<div class="layout column align-center">
|
||||
<icon-picker
|
||||
label="Icon"
|
||||
@@ -26,8 +26,8 @@
|
||||
/>
|
||||
|
||||
<computed-field
|
||||
label="Roll bonus"
|
||||
hint="A number (or calculation which returns a number) that is added to a d20 when making the attack roll"
|
||||
label="Attack Roll Bonus"
|
||||
hint="The bonus to attack if this action has an attack roll"
|
||||
:model="model.rollBonus"
|
||||
:error-messages="errors.rollBonus"
|
||||
@change="({path, value, ack}) =>
|
||||
@@ -129,11 +129,6 @@
|
||||
ResourcesForm,
|
||||
},
|
||||
mixins: [propertyFormMixin],
|
||||
props: {
|
||||
attackForm: {
|
||||
type: Boolean,
|
||||
},
|
||||
},
|
||||
data(){
|
||||
let data = {
|
||||
actionTypes: [
|
||||
|
||||
Reference in New Issue
Block a user