Added "save for half" to damage form
This commit is contained in:
@@ -33,10 +33,23 @@ const DamageSchema = createPropertySchema({
|
||||
type: Boolean,
|
||||
optional: true,
|
||||
},
|
||||
// remove the entire object if there is no saving throw
|
||||
save: {
|
||||
type: SavingThrowSchema,
|
||||
type: Object,
|
||||
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': {
|
||||
type: 'fieldToCompute',
|
||||
optional: true,
|
||||
@@ -51,13 +64,18 @@ const ComputedOnlyDamageSchema = createPropertySchema({
|
||||
parseLevel: 'compile',
|
||||
},
|
||||
save: {
|
||||
type: ComputedOnlySavingThrowSchema,
|
||||
type: Object,
|
||||
optional: true,
|
||||
},
|
||||
'save.dc': {
|
||||
type: 'computedOnlyField',
|
||||
parseLevel: 'compile',
|
||||
optional: true,
|
||||
},
|
||||
'save.damageFunction': {
|
||||
type: 'computedOnlyField',
|
||||
optional: true,
|
||||
parseLevel: 'compile',
|
||||
optional: true,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -31,25 +31,92 @@
|
||||
@change="change('damageType', ...arguments)"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<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">
|
||||
<v-col cols="12">
|
||||
<smart-switch
|
||||
label="Don't show in log"
|
||||
:value="model.silent"
|
||||
:error-messages="errors.silent"
|
||||
@change="change('silent', ...arguments)"
|
||||
label="Save for half damage"
|
||||
:value="!!model.save"
|
||||
:error-messages="errors.save"
|
||||
@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>
|
||||
<slot />
|
||||
</form-sections>
|
||||
@@ -60,9 +127,10 @@
|
||||
import DAMAGE_TYPES from '/imports/constants/DAMAGE_TYPES.js';
|
||||
import propertyFormMixin from '/imports/client/ui/properties/forms/shared/propertyFormMixin.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 {
|
||||
mixins: [propertyFormMixin],
|
||||
mixins: [propertyFormMixin, saveListMixin],
|
||||
props: {
|
||||
parentTarget: {
|
||||
type: String,
|
||||
@@ -102,6 +170,13 @@ export default {
|
||||
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>
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
</v-col>
|
||||
<v-col
|
||||
cols="12"
|
||||
md="6"
|
||||
>
|
||||
<smart-toggle
|
||||
label="Target creature"
|
||||
|
||||
Reference in New Issue
Block a user