Added "save for half" to damage form
This commit is contained in:
@@ -33,10 +33,23 @@ const DamageSchema = createPropertySchema({
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
|
// remove the entire object if there is no saving throw
|
||||||
save: {
|
save: {
|
||||||
type: SavingThrowSchema,
|
type: Object,
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
|
// The computed DC
|
||||||
|
'save.dc': {
|
||||||
|
type: 'fieldToCompute',
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
// The variable name of save to roll
|
||||||
|
'save.stat': {
|
||||||
|
type: String,
|
||||||
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.variableName,
|
||||||
|
},
|
||||||
|
// The damage to deal on a successful save
|
||||||
'save.damageFunction': {
|
'save.damageFunction': {
|
||||||
type: 'fieldToCompute',
|
type: 'fieldToCompute',
|
||||||
optional: true,
|
optional: true,
|
||||||
@@ -51,13 +64,18 @@ const ComputedOnlyDamageSchema = createPropertySchema({
|
|||||||
parseLevel: 'compile',
|
parseLevel: 'compile',
|
||||||
},
|
},
|
||||||
save: {
|
save: {
|
||||||
type: ComputedOnlySavingThrowSchema,
|
type: Object,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
'save.dc': {
|
||||||
|
type: 'computedOnlyField',
|
||||||
|
parseLevel: 'compile',
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
'save.damageFunction': {
|
'save.damageFunction': {
|
||||||
type: 'computedOnlyField',
|
type: 'computedOnlyField',
|
||||||
optional: true,
|
|
||||||
parseLevel: 'compile',
|
parseLevel: 'compile',
|
||||||
|
optional: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -31,25 +31,92 @@
|
|||||||
@change="change('damageType', ...arguments)"
|
@change="change('damageType', ...arguments)"
|
||||||
/>
|
/>
|
||||||
</v-col>
|
</v-col>
|
||||||
</v-row>
|
<v-col cols="12">
|
||||||
<smart-toggle
|
|
||||||
label="Target creature"
|
|
||||||
:value="model.target"
|
|
||||||
:options="[
|
|
||||||
{name: 'Action Target', value: 'target'},
|
|
||||||
{name: 'Self', value: 'self'},
|
|
||||||
]"
|
|
||||||
:error-messages="errors.target"
|
|
||||||
@change="change('target', ...arguments)"
|
|
||||||
/>
|
|
||||||
<form-sections type="damage">
|
|
||||||
<form-section name="Log">
|
|
||||||
<smart-switch
|
<smart-switch
|
||||||
label="Don't show in log"
|
label="Save for half damage"
|
||||||
:value="model.silent"
|
:value="!!model.save"
|
||||||
:error-messages="errors.silent"
|
:error-messages="errors.save"
|
||||||
@change="change('silent', ...arguments)"
|
@change="(val, ack) => $emit('change', {
|
||||||
|
path: ['save'],
|
||||||
|
value: val ? {} : undefined,
|
||||||
|
ack
|
||||||
|
})"
|
||||||
/>
|
/>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
<v-expand-transition>
|
||||||
|
<v-row
|
||||||
|
v-if="model.save"
|
||||||
|
dense
|
||||||
|
>
|
||||||
|
<v-col
|
||||||
|
cols="12"
|
||||||
|
md="6"
|
||||||
|
>
|
||||||
|
<computed-field
|
||||||
|
label="DC"
|
||||||
|
hint="Saving throw DC"
|
||||||
|
:model="model.save.dc"
|
||||||
|
:error-messages="errors['save.dc']"
|
||||||
|
@change="({path, value, ack}) =>
|
||||||
|
$emit('change', {path: ['save', 'dc', ...path], value, ack})"
|
||||||
|
/>
|
||||||
|
</v-col>
|
||||||
|
<v-col
|
||||||
|
cols="12"
|
||||||
|
md="6"
|
||||||
|
>
|
||||||
|
<smart-combobox
|
||||||
|
label="Save"
|
||||||
|
hint="Which stat the saving throw targets"
|
||||||
|
:value="model.save.stat"
|
||||||
|
:items="saveList"
|
||||||
|
:error-messages="errors['save.stat']"
|
||||||
|
@change="(value, ack) =>
|
||||||
|
$emit('change', {path: ['save', 'stat'], value, ack})"
|
||||||
|
/>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
</v-expand-transition>
|
||||||
|
<v-row>
|
||||||
|
<v-col cols="12">
|
||||||
|
<smart-toggle
|
||||||
|
label="Target creature"
|
||||||
|
:value="model.target"
|
||||||
|
:options="[
|
||||||
|
{name: 'Action Target', value: 'target'},
|
||||||
|
{name: 'Self', value: 'self'},
|
||||||
|
]"
|
||||||
|
:error-messages="errors.target"
|
||||||
|
@change="change('target', ...arguments)"
|
||||||
|
/>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
|
<form-sections type="damage">
|
||||||
|
<form-section name="Behavior">
|
||||||
|
<v-row>
|
||||||
|
<v-col cols="12">
|
||||||
|
<smart-switch
|
||||||
|
label="Don't show in log"
|
||||||
|
:value="model.silent"
|
||||||
|
:error-messages="errors.silent"
|
||||||
|
@change="change('silent', ...arguments)"
|
||||||
|
/>
|
||||||
|
</v-col>
|
||||||
|
<v-col cols="12">
|
||||||
|
<computed-field
|
||||||
|
v-if="!!model.save"
|
||||||
|
label="Damage function"
|
||||||
|
hint="Instead of half, you can use a function to determine the new damage to deal; use "~damage" to reference the standard damage"
|
||||||
|
placeholder="~damage / 2"
|
||||||
|
persistent-placeholder
|
||||||
|
:model="model.save.damageFunction"
|
||||||
|
:error-messages="errors['save.damageFunction']"
|
||||||
|
@change="({path, value, ack}) =>
|
||||||
|
$emit('change', {path: ['save', 'damageFunction', ...path], value, ack})"
|
||||||
|
/>
|
||||||
|
</v-col>
|
||||||
|
</v-row>
|
||||||
</form-section>
|
</form-section>
|
||||||
<slot />
|
<slot />
|
||||||
</form-sections>
|
</form-sections>
|
||||||
@@ -60,9 +127,10 @@
|
|||||||
import DAMAGE_TYPES from '/imports/constants/DAMAGE_TYPES.js';
|
import DAMAGE_TYPES from '/imports/constants/DAMAGE_TYPES.js';
|
||||||
import propertyFormMixin from '/imports/client/ui/properties/forms/shared/propertyFormMixin.js';
|
import propertyFormMixin from '/imports/client/ui/properties/forms/shared/propertyFormMixin.js';
|
||||||
import VARIABLE_NAME_REGEX from '/imports/constants/VARIABLE_NAME_REGEX.js';
|
import VARIABLE_NAME_REGEX from '/imports/constants/VARIABLE_NAME_REGEX.js';
|
||||||
|
import saveListMixin from '/imports/client/ui/properties/forms/shared/lists/saveListMixin.js';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
mixins: [propertyFormMixin],
|
mixins: [propertyFormMixin, saveListMixin],
|
||||||
props: {
|
props: {
|
||||||
parentTarget: {
|
parentTarget: {
|
||||||
type: String,
|
type: String,
|
||||||
@@ -102,6 +170,13 @@ export default {
|
|||||||
return hints[this.model.target];
|
return hints[this.model.target];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
methods: {
|
||||||
|
saveChange({ path, value, ack }) {
|
||||||
|
console.log({ path, value, ack });
|
||||||
|
this.$emit('change', {path: [ 'save', ...path ], value, ack})
|
||||||
|
this.$emit('change', {path: [ 'silent' ], value: true, ack})
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,6 @@
|
|||||||
</v-col>
|
</v-col>
|
||||||
<v-col
|
<v-col
|
||||||
cols="12"
|
cols="12"
|
||||||
md="6"
|
|
||||||
>
|
>
|
||||||
<smart-toggle
|
<smart-toggle
|
||||||
label="Target creature"
|
label="Target creature"
|
||||||
|
|||||||
Reference in New Issue
Block a user