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