Skills can now apply to calcs by tag

This commit is contained in:
Stefan Zermatten
2023-06-14 13:56:44 +02:00
parent 442aea2bbe
commit 04de76d20e
9 changed files with 131 additions and 40 deletions

View File

@@ -7,7 +7,7 @@
>
<div class="effect-icon">
<proficiency-icon
:value="model.value"
:value="model.proficiency"
class="prof-icon"
/>
</div>
@@ -16,7 +16,7 @@
<span
class="effect-value mr-2"
>
{{ proficiencyValue }}
{{ displayedValue }}
</span>
{{ displayedText }}
</v-list-item-title>
@@ -26,34 +26,25 @@
<script lang="js">
import ProficiencyIcon from '/imports/client/ui/properties/shared/ProficiencyIcon.vue';
import numberToSignedString from '/imports/api/utility/numberToSignedString.js';
export default {
components: {
ProficiencyIcon,
},
props: {
hideBreadcrumbs: Boolean,
model: {
type: Object,
required: true,
},
proficiencyBonus: {
type: Number,
default: 0,
},
},
computed: {
displayedText(){
return this.model.name || 'Proficiency'
return this.model.name || (this.model.type == 'proficiency' ? 'Proficiency' : 'Skill')
},
displayedValue() {
return numberToSignedString(this.model.value);
},
proficiencyValue(){
if (!this.proficiencyBonus) return;
if (this.model.value === 0.49){
return Math.floor(0.5 * this.proficiencyBonus);
} else {
return Math.ceil(this.model.value * this.proficiencyBonus);
}
},
},
methods: {
click(e){

View File

@@ -15,9 +15,8 @@
/>
<computed-field
v-else
label="To Hit"
prefix="1d20 + "
hint="The bonus to attack if this action has an attack roll"
label="Base attack roll bonus"
hint="Must be set for the action to have an attack roll"
:model="model.attackRoll"
:error-messages="errors.attackRoll"
@change="({path, value, ack}) =>

View File

@@ -81,6 +81,24 @@
</v-col>
</v-row>
</form-section>
<form-section name="Apply skill">
<smart-switch
label="Apply skill to targeted tags"
:value="model.targetByTags"
:error-messages="errors.targetByTags"
@change="change('targetByTags', ...arguments)"
/>
<v-expand-transition>
<tag-targeting
v-if="model.targetByTags"
:model="model"
:errors="errors"
@change="e => $emit('change', e)"
@push="e => $emit('push', e)"
@pull="e => $emit('pull', e)"
/>
</v-expand-transition>
</form-section>
<slot />
</form-sections>
</div>
@@ -91,11 +109,13 @@ import ProficiencySelect from '/imports/client/ui/properties/forms/shared/Profic
import FormSection from '/imports/client/ui/properties/forms/shared/FormSection.vue';
import createListOfProperties from '/imports/client/ui/properties/forms/shared/lists/createListOfProperties.js';
import propertyFormMixin from '/imports/client/ui/properties/forms/shared/propertyFormMixin.js';
import TagTargeting from '/imports/client/ui/properties/forms/shared/TagTargeting.vue';
export default {
components: {
ProficiencySelect,
FormSection,
TagTargeting,
},
mixins: [propertyFormMixin],
data() {

View File

@@ -9,7 +9,7 @@
v-if="showValue"
#value
>
{{ model.value }}
{{ displayedValue }}
</template>
<template #prepend>
<slot name="prepend" />
@@ -37,7 +37,7 @@ export default {
},
computed: {
showValue() {
const value = this.model.value;
let value = this.displayedValue;
if (
this.hideValue ||
(value === undefined || value === null) ||
@@ -45,6 +45,14 @@ export default {
) return false;
return true;
},
displayedValue() {
let value = this.model.value;
// Use the base value instead if the calculation has it, because effects can modify the value
if (this.model.baseValue !== undefined) {
value = this.model.baseValue;
}
return value;
},
errorList(){
if (this.model.parseError){
return [this.model.parseError, ...this.model.errors];

View File

@@ -54,7 +54,7 @@
style="max-width: 100%;"
>
<inline-effect
v-if="typeof calculation.value === 'number'"
v-if="typeof calculation.value === 'number' && calculation.baseValue !== 0"
hide-breadcrumbs
:model="{
name: 'Base value',