Added hide when total/value zero to attributes

This commit is contained in:
Stefan Zermatten
2022-11-03 20:39:02 +02:00
parent 8f56a60fb1
commit d63ad9ea8f
4 changed files with 84 additions and 20 deletions

View File

@@ -107,6 +107,14 @@ let AttributeSchema = createPropertySchema({
type: Boolean,
optional: true,
},
hideWhenTotalZero: {
type: Boolean,
optional: true,
},
hideWhenValueZero: {
type: Boolean,
optional: true,
},
// Automatically zero the adjustment on these conditions
reset: {
type: String,

View File

@@ -365,6 +365,10 @@ const getProperties = function (creature, filter, options = {
filter.removed = { $ne: true };
filter.inactive = { $ne: true };
filter.overridden = { $ne: true };
filter.$nor = [
{ hideWhenTotalZero: true, total: 0 },
{ hideWhenValueZero: true, value: 0 },
];
return CreatureProperties.find(filter, options);
};

View File

@@ -42,6 +42,10 @@ export default {
removed: { $ne: true },
inactive: { $ne: true },
overridden: { $ne: true },
$nor: [
{ hideWhenTotalZero: true, total: 0 },
{ hideWhenValueZero: true, value: 0 },
],
};
if (creature.settings.hideUnusedStats) {
filter.hide = { $ne: true };

View File

@@ -151,26 +151,74 @@
@change="change('tags', ...arguments)"
/>
<div class="layout column align-center">
<smart-switch
v-if="model.attributeType !== 'hitDice'"
label="Allow decimal values"
class="no-flex"
:value="model.decimal"
:error-messages="errors.decimal"
@change="change('decimal', ...arguments)"
/>
<smart-switch
label="Can be damaged into negative values"
:value="model.ignoreLowerLimit"
:error-messages="errors.ignoreLowerLimit"
@change="change('ignoreLowerLimit', ...arguments)"
/>
<smart-switch
label="Can be incremented above total"
:value="model.ignoreUpperLimit"
:error-messages="errors.ignoreUpperLimit"
@change="change('ignoreUpperLimit', ...arguments)"
/>
<v-row dense>
<v-col
cols="12"
sm="6"
md="4"
>
<smart-switch
v-if="model.attributeType !== 'hitDice'"
label="Allow decimal values"
class="mx-4"
:value="model.decimal"
:error-messages="errors.decimal"
@change="change('decimal', ...arguments)"
/>
</v-col>
<v-col
cols="12"
sm="6"
md="4"
>
<smart-switch
label="Can be damaged into negative values"
class="mx-4"
:value="model.ignoreLowerLimit"
:error-messages="errors.ignoreLowerLimit"
@change="change('ignoreLowerLimit', ...arguments)"
/>
</v-col>
<v-col
cols="12"
sm="6"
md="4"
>
<smart-switch
label="Can be incremented above total"
class="mx-4"
:value="model.ignoreUpperLimit"
:error-messages="errors.ignoreUpperLimit"
@change="change('ignoreUpperLimit', ...arguments)"
/>
</v-col>
<v-col
cols="12"
sm="6"
md="4"
>
<smart-switch
label="Hide when total is zero"
class="mx-4"
:value="model.hideWhenTotalZero"
:error-messages="errors.hideWhenTotalZero"
@change="change('hideWhenTotalZero', ...arguments)"
/>
</v-col>
<v-col
cols="12"
sm="6"
md="4"
>
<smart-switch
label="Hide when value is zero"
class="mx-4"
:value="model.hideWhenValueZero"
:error-messages="errors.hideWhenValueZero"
@change="change('hideWhenValueZero', ...arguments)"
/>
</v-col>
</v-row>
<div
class="layout justify-center"
style="align-self: stretch;"