Added tag-targeted profs to calculation viewers
This commit is contained in:
@@ -3,6 +3,9 @@ import evaluateCalculation from '../../utility/evaluateCalculation.js';
|
||||
export default function computeCalculation(computation, node) {
|
||||
const calcObj = node.data;
|
||||
evaluateCalculation(calcObj, computation.scope);
|
||||
if (calcObj.effects || calcObj.proficiencies) {
|
||||
calcObj.baseValue = calcObj.value;
|
||||
}
|
||||
aggregateCalculationEffects(node, computation);
|
||||
aggregateCalculationProficiencies(node, computation);
|
||||
}
|
||||
@@ -36,7 +39,6 @@ function aggregateCalculationEffects(node, computation) {
|
||||
true // enumerate only outbound links
|
||||
);
|
||||
if (calcObj.effects && typeof calcObj.value === 'number') {
|
||||
calcObj.baseValue = calcObj.value;
|
||||
calcObj.effects.forEach(effect => {
|
||||
if (
|
||||
effect.operation === 'add' &&
|
||||
@@ -71,23 +73,28 @@ function aggregateCalculationProficiencies(node, computation) {
|
||||
},
|
||||
true // enumerate only outbound links
|
||||
);
|
||||
if (calcObj.proficiencies) {
|
||||
if (calcObj.proficiencies && typeof calcObj.value === 'number') {
|
||||
calcObj.proficiency = 0;
|
||||
let currentProf;
|
||||
calcObj.proficiencies.forEach(prof => {
|
||||
if (prof.value > calcObj.proficiency) {
|
||||
if (currentProf) currentProf.overridden = true;
|
||||
calcObj.proficiency = prof.value;
|
||||
} else {
|
||||
prof.overridden = true;
|
||||
}
|
||||
});
|
||||
// Get the character's proficiency bonus to apply
|
||||
let profBonus = computation.scope['proficiencyBonus']?.value || 0;
|
||||
|
||||
calcObj.proficiencyBonus = profBonus;
|
||||
let totalBonus;
|
||||
// Multiply the proficiency bonus by the actual proficiency
|
||||
if (calcObj.proficiency === 0.49) {
|
||||
// Round down proficiency bonus in the special case
|
||||
calcObj.proficiencyBonus = Math.floor(profBonus * 0.5);
|
||||
totalBonus = Math.floor(profBonus * 0.5);
|
||||
} else {
|
||||
calcObj.proficiencyBonus = Math.ceil(profBonus * calcObj.proficiency);
|
||||
totalBonus = Math.ceil(profBonus * calcObj.proficiency);
|
||||
}
|
||||
calcObj.value += calcObj.proficiencyBonus;
|
||||
calcObj.value += totalBonus;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -211,7 +211,6 @@ export default {
|
||||
},
|
||||
change(arg) {
|
||||
const { path, value, ack } = arg;
|
||||
console.log('creaturePropDialogChangeHandler', arg);
|
||||
if (path && path[0] === 'equipped'){
|
||||
equipItem.call({_id: this.currentId, equipped: value}, ack);
|
||||
return;
|
||||
|
||||
@@ -0,0 +1,85 @@
|
||||
<template lang="html">
|
||||
<v-list-item
|
||||
class="inline-proficiency layout align-center"
|
||||
:class="{'text--disabled': model.overridden}"
|
||||
dense
|
||||
@click="click"
|
||||
>
|
||||
<div class="effect-icon">
|
||||
<proficiency-icon
|
||||
:value="model.value"
|
||||
class="prof-icon"
|
||||
/>
|
||||
</div>
|
||||
<v-list-item-content>
|
||||
<v-list-item-title>
|
||||
<span
|
||||
class="effect-value mr-2"
|
||||
>
|
||||
{{ proficiencyValue }}
|
||||
</span>
|
||||
{{ displayedText }}
|
||||
</v-list-item-title>
|
||||
</v-list-item-content>
|
||||
</v-list-item>
|
||||
</template>
|
||||
|
||||
<script lang="js">
|
||||
import ProficiencyIcon from '/imports/client/ui/properties/shared/ProficiencyIcon.vue';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
ProficiencyIcon,
|
||||
},
|
||||
props: {
|
||||
hideBreadcrumbs: Boolean,
|
||||
model: {
|
||||
type: Object,
|
||||
required: true,
|
||||
},
|
||||
proficiencyBonus: {
|
||||
type: Number,
|
||||
default: 0,
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
displayedText(){
|
||||
return this.model.name || 'Proficiency'
|
||||
},
|
||||
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){
|
||||
this.$emit('click', e);
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="css" scoped>
|
||||
.icon, .effect-icon {
|
||||
min-width: 20px;
|
||||
}
|
||||
.icon {
|
||||
color: inherit !important;
|
||||
}
|
||||
.net-effect {
|
||||
flex-grow: 0;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.effect-value {
|
||||
min-width: 30px;
|
||||
text-align: center;
|
||||
}
|
||||
.prof-icon {
|
||||
width: 24px;
|
||||
margin: 0 8px;
|
||||
}
|
||||
</style>
|
||||
@@ -49,7 +49,7 @@
|
||||
</slot>
|
||||
</div>
|
||||
<div
|
||||
v-if="calculation && calculation.effects"
|
||||
v-if="calculation && (calculation.effects || calculation.proficiencies)"
|
||||
class="flex-grow-1"
|
||||
style="max-width: 100%;"
|
||||
>
|
||||
@@ -70,6 +70,14 @@
|
||||
:model="effect"
|
||||
@click="clickEffect(effect._id)"
|
||||
/>
|
||||
<inline-proficiency
|
||||
v-for="proficiency in calculation.proficiencies"
|
||||
:key="proficiency._id"
|
||||
:data-id="proficiency._id"
|
||||
:model="proficiency"
|
||||
:proficiency-bonus="calculation.proficiencyBonus"
|
||||
@click="clickEffect(proficiency._id)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
@@ -77,12 +85,14 @@
|
||||
</template>
|
||||
|
||||
<script lang="js">
|
||||
import numberToSignedString from '../../../../../api/utility/numberToSignedString.js';
|
||||
import numberToSignedString from '/imports/api/utility/numberToSignedString.js';
|
||||
import InlineEffect from '/imports/client/ui/properties/components/effects/InlineEffect.vue';
|
||||
import InlineProficiency from '/imports/client/ui/properties/components/proficiencies/InlineProficiency.vue';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
InlineEffect,
|
||||
InlineProficiency,
|
||||
},
|
||||
inject: {
|
||||
theme: {
|
||||
|
||||
Reference in New Issue
Block a user