Added edit tab to base dialogs, added edit screen to attribute dialog
This commit is contained in:
@@ -18,12 +18,12 @@ const getRacialBonusEffect = function(charId, attribute, bonus){
|
||||
name: "Race Bonus",
|
||||
stat: attribute,
|
||||
operation: "add",
|
||||
calculation: bonus,
|
||||
calculation: bonus.toString(),
|
||||
enabled: true,
|
||||
parent: {
|
||||
collection: "Creatures",
|
||||
id: charId,
|
||||
group: "racial",
|
||||
group: "race",
|
||||
},
|
||||
charId: charId,
|
||||
};
|
||||
|
||||
@@ -91,6 +91,7 @@ let updateAttributeSchema = pickKeysAsOptional(attributeSchema, [
|
||||
'type',
|
||||
'baseValue',
|
||||
'decimal',
|
||||
'adjustment',
|
||||
'reset',
|
||||
'resetMultiplier',
|
||||
'color',
|
||||
@@ -109,13 +110,18 @@ const updateAttribute = new ValidatedMethod({
|
||||
}).validator(),
|
||||
|
||||
run({_id, update}) {
|
||||
let currentAttribute = Attributes.findOne(_id);
|
||||
let currentAttribute = Attributes.findOne(_id, {fields: {value: 1, charId: 1}});
|
||||
if (!currentAttribute){
|
||||
throw new Meteor.Error("Attributes.methods.update.denied",
|
||||
`No attributes exist with the id: ${_id}`);
|
||||
}
|
||||
let charId = currentAttribute.charId;
|
||||
if (canEditCreature(charId, this.userId)){
|
||||
if (typeof update.adjustment === 'number'){
|
||||
let val = currentAttribute.value;
|
||||
if (update.adjustment < -val) update.adjustment = -val;
|
||||
if (update.adjustment > 0) update.adjustment = 0;
|
||||
}
|
||||
Attributes.update(_id, {$set: update});
|
||||
recomputeCreatureById(charId);
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
},
|
||||
data(){return {
|
||||
theme,
|
||||
tab: 1,
|
||||
tab: 0,
|
||||
}},
|
||||
methods: {
|
||||
...mapMutations([
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div v-for="modifier in modifiers" class="modifier">
|
||||
<div v-for="modifier in modifiers" class="modifier" :key="modifier._id">
|
||||
<attribute-card modifier
|
||||
v-bind="modifier"
|
||||
:id="`${_uid}-${modifier._id}`"
|
||||
@@ -44,11 +44,11 @@
|
||||
<v-list>
|
||||
<v-subheader>Hit Dice</v-subheader>
|
||||
<template v-for="(hitDie, index) in hitDice">
|
||||
<v-divider v-if="index !== 0"/>
|
||||
<v-divider v-if="index !== 0" :key="hitDice._id + 'divider'"/>
|
||||
<hit-dice-list-tile
|
||||
v-bind="hitDie"
|
||||
:key="hitDie._id"
|
||||
:id="`${_uid}-${hitDie._id}`"
|
||||
:key="hitDice._id"
|
||||
@click="clickAttribute({elementId: `${_uid}-${hitDie._id}`, _id: hitDie._id})"
|
||||
@change="e => hitDiceChange(hitDie._id, e)"
|
||||
/>
|
||||
|
||||
@@ -3,27 +3,32 @@
|
||||
<div slot="toolbar">
|
||||
{{name}}
|
||||
</div>
|
||||
<v-layout align-center column v-if="type === 'ability'">
|
||||
<div class="display-3 mod">
|
||||
{{numberToSignedString(mod)}}
|
||||
<div>
|
||||
<v-layout align-center column v-if="type === 'ability'">
|
||||
<div class="display-3 mod">
|
||||
{{numberToSignedString(mod)}}
|
||||
</div>
|
||||
<div class="display-1 ability-value">
|
||||
{{value}}
|
||||
</div>
|
||||
</v-layout>
|
||||
<div class="display-3 attribute-value" v-else-if="type === 'healthBar'">
|
||||
{{value+adjustment}} / {{value}}
|
||||
</div>
|
||||
<div class="display-1 ability-value">
|
||||
<div class="display-3 attribute-value" v-else-if="type === 'modifier'">
|
||||
{{numberToSignedString(value)}}
|
||||
</div>
|
||||
<div class="display-3 attribute-value" v-else>
|
||||
{{value}}
|
||||
</div>
|
||||
</v-layout>
|
||||
<div class="display-3 attribute-value" v-else-if="type === 'healthBar'">
|
||||
{{value+adjustment}} / {{value}}
|
||||
<attribute-effect-list v-if="attribueBaseEffect" :effects="[attribueBaseEffect]"/>
|
||||
<div v-if="effects && effects.length">
|
||||
<h6 class="title">Effects</h6>
|
||||
<attribute-effect-list :effects="effects" @click="clickedEffect"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="display-3 attribute-value" v-else-if="type === 'modifier'">
|
||||
{{numberToSignedString(value)}}
|
||||
</div>
|
||||
<div class="display-3 attribute-value" v-else>
|
||||
{{value}}
|
||||
</div>
|
||||
<attribute-effect-list v-if="attribueBaseEffect" :effects="[attribueBaseEffect]"/>
|
||||
<div v-if="effects && effects.length">
|
||||
<h6 class="title">Effects</h6>
|
||||
<attribute-effect-list :effects="effects" @click="clickedEffect"/>
|
||||
<div slot="edit">
|
||||
<attribute-edit :attribute="$props" @change="(update, ack) => $emit('change', update, ack)"/>
|
||||
</div>
|
||||
</dialog-base>
|
||||
</template>
|
||||
@@ -32,15 +37,24 @@
|
||||
import store from "/imports/ui/vuexStore.js";
|
||||
import DialogBase from "/imports/ui/dialogStack/DialogBase.vue";
|
||||
import AttributeEffectList from '/imports/ui/components/AttributeEffectList.vue';
|
||||
import AttributeEdit from '/imports/ui/components/AttributeEdit.vue';
|
||||
import numberToSignedString from '/imports/ui/utility/numberToSignedString.js';
|
||||
|
||||
export default {
|
||||
props: {
|
||||
charId: String,
|
||||
name: String,
|
||||
variableName: String,
|
||||
order: Number,
|
||||
type: String,
|
||||
baseValue: Number,
|
||||
value: Number,
|
||||
mod: Number,
|
||||
baseValue: Number,
|
||||
adjustment: Number,
|
||||
decimal: Boolean,
|
||||
reset: String,
|
||||
resetMultiplier: Number,
|
||||
color: String,
|
||||
adjustment: {type: Number, default: 0},
|
||||
effects: {type: Array, default: () => []},
|
||||
},
|
||||
@@ -66,6 +80,7 @@
|
||||
components: {
|
||||
DialogBase,
|
||||
AttributeEffectList,
|
||||
AttributeEdit,
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -2,13 +2,14 @@
|
||||
<attribute-dialog
|
||||
v-bind="attribute"
|
||||
:effects="effects"
|
||||
v-on="{clickedEffect}"
|
||||
v-on="{clickedEffect, change}"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import AttributeDialog from '/imports/ui/components/AttributeDialog.vue';
|
||||
import Attributes from '/imports/api/creature/properties/Attributes.js';
|
||||
import { updateAttribute, adjustAttribute } from '/imports/api/creature/properties/Attributes.js';
|
||||
export default {
|
||||
components: {
|
||||
AttributeDialog,
|
||||
@@ -36,7 +37,12 @@
|
||||
methods: {
|
||||
clickedEffect(e){
|
||||
console.log(e);
|
||||
}
|
||||
},
|
||||
change(update, ack){
|
||||
updateAttribute.call({_id: this._id, update}, error => {
|
||||
ack(error);
|
||||
});
|
||||
},
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
label="Base Value"
|
||||
type="number"
|
||||
:value="attribute.baseValue"
|
||||
@change="(baseValue, ack) => $emit('change', {baseValue}, ack)"
|
||||
@change="(baseValue, ack) => $emit('change', {baseValue: +baseValue}, ack)"
|
||||
hint="This is the value of the attribute before effects are applied"
|
||||
/>
|
||||
<text-field
|
||||
@@ -34,7 +34,7 @@
|
||||
<v-switch
|
||||
label="Allow decimal values"
|
||||
:value="attribute.decimal"
|
||||
@change="e => $emit('change', {decimal: e})"
|
||||
@change="e => $emit('change', {decimal: !!e})"
|
||||
/>
|
||||
<smart-select
|
||||
label="Reset"
|
||||
@@ -49,7 +49,7 @@
|
||||
label="Reset Multiplier"
|
||||
type="number"
|
||||
:value="attribute.resetMultiplier"
|
||||
@change="(resetMultiplier, ack) => $emit('change', {resetMultiplier}, ack)"
|
||||
@change="(resetMultiplier, ack) => $emit('change', {resetMultiplier: +resetMultiplier}, ack)"
|
||||
hint="Some attributes, like hit dice, only reset by half their total on a long rest"
|
||||
/>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user