Made hiding stats that aren't targeted by effects or proficiencies an option
This commit is contained in:
@@ -27,6 +27,11 @@ let CreatureSettingsSchema = new SimpleSchema({
|
||||
type: Boolean,
|
||||
optional: true,
|
||||
},
|
||||
// Hide all the unused stats
|
||||
hideUnusedStats: {
|
||||
type: Boolean,
|
||||
optional: true,
|
||||
}
|
||||
});
|
||||
|
||||
let CreatureSchema = new SimpleSchema({
|
||||
|
||||
@@ -24,15 +24,19 @@ export default class EffectAggregator{
|
||||
this.set = undefined;
|
||||
this.conditional = [];
|
||||
this.rollBonus = [];
|
||||
this.hasNoEffects = true;
|
||||
}
|
||||
addEffect(effect){
|
||||
let result = effect.result;
|
||||
if (this.hasNoEffects) this.hasNoEffects = false;
|
||||
switch(effect.operation){
|
||||
case 'base':
|
||||
// Take the largest base value
|
||||
this.base = result > this.base ? result : this.base;
|
||||
if (effect.statBase){
|
||||
this.statBaseValue = result > this.statBaseValue ? result : this.statBaseValue;
|
||||
if (this.statBaseValue === undefined || result > this.statBaseValue){
|
||||
this.statBaseValue = result;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'add':
|
||||
|
||||
@@ -36,6 +36,9 @@ function combineAttribute(stat, aggregator){
|
||||
stat.modifier = Math.floor((stat.value - 10) / 2);
|
||||
}
|
||||
stat.currentValue = stat.value - (stat.damage || 0);
|
||||
stat.hide = aggregator.hasNoEffects &&
|
||||
stat.baseValue === undefined ||
|
||||
undefined
|
||||
}
|
||||
|
||||
function combineSkill(stat, aggregator, memo){
|
||||
@@ -73,7 +76,12 @@ function combineSkill(stat, aggregator, memo){
|
||||
let result = (stat.abilityMod + profBonus + aggregator.add) * aggregator.mul;
|
||||
if (result < aggregator.min) result = aggregator.min;
|
||||
if (result > aggregator.max) result = aggregator.max;
|
||||
result = Math.floor(result);
|
||||
if (aggregator.set !== undefined) {
|
||||
result = aggregator.set;
|
||||
}
|
||||
if (Number.isFinite(result)){
|
||||
result = Math.floor(result);
|
||||
}
|
||||
stat.value = result;
|
||||
// Advantage/disadvantage
|
||||
if (aggregator.advantage && !aggregator.disadvantage){
|
||||
@@ -93,6 +101,10 @@ function combineSkill(stat, aggregator, memo){
|
||||
stat.fail = aggregator.fail;
|
||||
// Rollbonus
|
||||
stat.rollBonuses = aggregator.rollBonus;
|
||||
// Hide
|
||||
stat.hide = aggregator.hasNoEffects &&
|
||||
stat.proficiency == 0 ||
|
||||
undefined;
|
||||
}
|
||||
|
||||
function combineDamageMultiplier(stat){
|
||||
|
||||
@@ -93,6 +93,11 @@ let ComputedOnlyAttributeSchema = new SimpleSchema({
|
||||
type: SimpleSchema.Integer,
|
||||
optional: true,
|
||||
},
|
||||
// Should this attribute hide
|
||||
hide: {
|
||||
type: Boolean,
|
||||
optional: true,
|
||||
},
|
||||
});
|
||||
|
||||
const ComputedAttributeSchema = new SimpleSchema()
|
||||
|
||||
@@ -101,6 +101,11 @@ let ComputedOnlySkillSchema = new SimpleSchema({
|
||||
type: SimpleSchema.Integer,
|
||||
optional: true,
|
||||
},
|
||||
// Should this attribute hide
|
||||
hide: {
|
||||
type: Boolean,
|
||||
optional: true,
|
||||
},
|
||||
})
|
||||
|
||||
const ComputedSkillSchema = new SimpleSchema()
|
||||
|
||||
@@ -42,9 +42,16 @@
|
||||
:disabled="disabled"
|
||||
@change="(value, ack) => $emit('change', {path: ['avatarPicture'], value, ack})"
|
||||
/>
|
||||
<!--
|
||||
<form-sections>
|
||||
<form-section name="settings">
|
||||
<form-sections>
|
||||
<form-section name="settings">
|
||||
<v-switch
|
||||
label="Hide redundant stats"
|
||||
:input-value="model.settings.hideUnusedStats"
|
||||
:error-messages="errors.hideUnusedStats"
|
||||
:disabled="disabled"
|
||||
@change="value => $emit('change', {path: ['settings','hideUnusedStats'], value: !!value || null})"
|
||||
/>
|
||||
<!--
|
||||
<v-switch
|
||||
label="Use variant encumbrance"
|
||||
:input-value="model.settings.useVariantEncumbrance"
|
||||
@@ -66,9 +73,9 @@
|
||||
:disabled="disabled"
|
||||
@change="value => $emit('change', {path: ['settings','swapStatAndModifier'], value})"
|
||||
/>
|
||||
</form-section>
|
||||
</form-sections>
|
||||
-->
|
||||
-->
|
||||
</form-section>
|
||||
</form-sections>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
<template lang="html">
|
||||
<div class="stats-tab ma-2">
|
||||
<div
|
||||
v-if="creature"
|
||||
class="stats-tab ma-2"
|
||||
>
|
||||
<div class="px-2 pt-2">
|
||||
<health-bar-card-container :creature-id="creatureId" />
|
||||
</div>
|
||||
@@ -290,23 +293,27 @@
|
||||
import AttackListTile from '/imports/ui/properties/components/actions/AttackListTile.vue';
|
||||
import getActiveProperties from '/imports/api/creature/getActiveProperties.js';
|
||||
|
||||
const getProperties = function(creatureId, filter){
|
||||
const getProperties = function(creature, filter,){
|
||||
if (!creature) return;
|
||||
if (creature.settings.hideUnusedStats){
|
||||
filter.hide = {$ne: true};
|
||||
}
|
||||
return getActiveProperties({
|
||||
ancestorId: creatureId,
|
||||
ancestorId: creature._id,
|
||||
filter,
|
||||
options: {sort: {order: 1}},
|
||||
});
|
||||
};
|
||||
|
||||
const getAttributeOfType = function(creatureId, type){
|
||||
return getProperties(creatureId, {
|
||||
const getAttributeOfType = function(creature, type){
|
||||
return getProperties(creature, {
|
||||
type: 'attribute',
|
||||
attributeType: type,
|
||||
});
|
||||
};
|
||||
|
||||
const getSkillOfType = function(creatureId, type){
|
||||
return getProperties(creatureId, {
|
||||
const getSkillOfType = function(creature, type){
|
||||
return getProperties(creature, {
|
||||
type: 'skill',
|
||||
skillType: type,
|
||||
});
|
||||
@@ -337,49 +344,49 @@
|
||||
return Creatures.findOne(this.creatureId);
|
||||
},
|
||||
abilities(){
|
||||
return getAttributeOfType(this.creatureId, 'ability');
|
||||
return getAttributeOfType(this.creature, 'ability');
|
||||
},
|
||||
stats(){
|
||||
return getAttributeOfType(this.creatureId, 'stat');
|
||||
return getAttributeOfType(this.creature, 'stat');
|
||||
},
|
||||
modifiers(){
|
||||
return getAttributeOfType(this.creatureId, 'modifier');
|
||||
return getAttributeOfType(this.creature, 'modifier');
|
||||
},
|
||||
resources(){
|
||||
return getAttributeOfType(this.creatureId, 'resource');
|
||||
return getAttributeOfType(this.creature, 'resource');
|
||||
},
|
||||
spellSlots(){
|
||||
return getAttributeOfType(this.creatureId, 'spellSlot');
|
||||
return getAttributeOfType(this.creature, 'spellSlot');
|
||||
},
|
||||
hitDice(){
|
||||
return getAttributeOfType(this.creatureId, 'hitDice');
|
||||
return getAttributeOfType(this.creature, 'hitDice');
|
||||
},
|
||||
checks(){
|
||||
return getSkillOfType(this.creatureId, 'check');
|
||||
return getSkillOfType(this.creature, 'check');
|
||||
},
|
||||
savingThrows(){
|
||||
return getSkillOfType(this.creatureId, 'save');
|
||||
return getSkillOfType(this.creature, 'save');
|
||||
},
|
||||
skills(){
|
||||
return getSkillOfType(this.creatureId, 'skill');
|
||||
return getSkillOfType(this.creature, 'skill');
|
||||
},
|
||||
tools(){
|
||||
return getSkillOfType(this.creatureId, 'tool');
|
||||
return getSkillOfType(this.creature, 'tool');
|
||||
},
|
||||
weapons(){
|
||||
return getSkillOfType(this.creatureId, 'weapon');
|
||||
return getSkillOfType(this.creature, 'weapon');
|
||||
},
|
||||
armors(){
|
||||
return getSkillOfType(this.creatureId, 'armor');
|
||||
return getSkillOfType(this.creature, 'armor');
|
||||
},
|
||||
languages(){
|
||||
return getSkillOfType(this.creatureId, 'language');
|
||||
return getSkillOfType(this.creature, 'language');
|
||||
},
|
||||
actions(){
|
||||
return getProperties(this.creatureId, {type: 'action'});
|
||||
return getProperties(this.creature, {type: 'action'});
|
||||
},
|
||||
attacks(){
|
||||
return getProperties(this.creatureId, {type: 'attack'});
|
||||
return getProperties(this.creature, {type: 'attack'});
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
|
||||
Reference in New Issue
Block a user