Compare commits
18 Commits
2.0-beta.2
...
2.0-beta.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4faea42371 | ||
|
|
9825872576 | ||
|
|
85b536bc46 | ||
|
|
9aa8203dcc | ||
|
|
217133137b | ||
|
|
aef7dbcbb3 | ||
|
|
6ff750417f | ||
|
|
a9eacfab03 | ||
|
|
1f633621b7 | ||
|
|
9f3c8bef34 | ||
|
|
8a83e7d8a1 | ||
|
|
a28182f3e9 | ||
|
|
3d122e062f | ||
|
|
e9a273244a | ||
|
|
1de3122254 | ||
|
|
298db01e5b | ||
|
|
727101cd63 | ||
|
|
d4d002cf31 |
@@ -16,7 +16,7 @@ meteorhacks:subs-manager
|
|||||||
chuangbo:marked
|
chuangbo:marked
|
||||||
meteor-base@1.4.0
|
meteor-base@1.4.0
|
||||||
mobile-experience@1.1.0
|
mobile-experience@1.1.0
|
||||||
mongo@1.10.1
|
mongo@1.11.0
|
||||||
session@1.2.0
|
session@1.2.0
|
||||||
tracker@1.2.0
|
tracker@1.2.0
|
||||||
logging@1.2.0
|
logging@1.2.0
|
||||||
@@ -26,7 +26,7 @@ check@1.3.1
|
|||||||
standard-minifier-js@2.6.0
|
standard-minifier-js@2.6.0
|
||||||
shell-server@0.5.0
|
shell-server@0.5.0
|
||||||
templates:array
|
templates:array
|
||||||
ecmascript@0.15.0
|
ecmascript@0.15.1
|
||||||
es5-shim@4.8.0
|
es5-shim@4.8.0
|
||||||
reactive-dict@1.3.0
|
reactive-dict@1.3.0
|
||||||
percolate:synced-cron
|
percolate:synced-cron
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
METEOR@2.1
|
METEOR@2.2
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
accounts-base@1.8.0
|
accounts-base@1.9.0
|
||||||
accounts-google@1.3.3
|
accounts-google@1.3.3
|
||||||
accounts-oauth@1.2.0
|
accounts-oauth@1.2.0
|
||||||
accounts-password@1.7.0
|
accounts-password@1.7.0
|
||||||
@@ -9,19 +9,19 @@ akryum:vue-component-dev-client@0.4.7
|
|||||||
akryum:vue-component-dev-server@0.1.4
|
akryum:vue-component-dev-server@0.1.4
|
||||||
akryum:vue-router2@0.2.3
|
akryum:vue-router2@0.2.3
|
||||||
akryum:vue-sass@0.1.2
|
akryum:vue-sass@0.1.2
|
||||||
aldeed:collection2@3.2.1
|
aldeed:collection2@3.3.0
|
||||||
aldeed:schema-index@3.0.0
|
aldeed:schema-index@3.0.0
|
||||||
allow-deny@1.1.0
|
allow-deny@1.1.0
|
||||||
autoupdate@1.7.0
|
autoupdate@1.7.0
|
||||||
babel-compiler@7.6.0
|
babel-compiler@7.6.1
|
||||||
babel-runtime@1.5.0
|
babel-runtime@1.5.0
|
||||||
base64@1.0.12
|
base64@1.0.12
|
||||||
binary-heap@1.0.11
|
binary-heap@1.0.11
|
||||||
blaze-tools@1.0.10
|
blaze-tools@1.1.1
|
||||||
boilerplate-generator@1.7.1
|
boilerplate-generator@1.7.1
|
||||||
bozhao:link-accounts@2.3.2
|
bozhao:link-accounts@2.3.2
|
||||||
caching-compiler@1.2.2
|
caching-compiler@1.2.2
|
||||||
caching-html-compiler@1.1.3
|
caching-html-compiler@1.2.0
|
||||||
callback-hook@1.3.0
|
callback-hook@1.3.0
|
||||||
check@1.3.1
|
check@1.3.1
|
||||||
chuangbo:marked@0.3.5_1
|
chuangbo:marked@0.3.5_1
|
||||||
@@ -37,7 +37,7 @@ ddp-server@2.3.2
|
|||||||
deps@1.0.12
|
deps@1.0.12
|
||||||
diff-sequence@1.1.1
|
diff-sequence@1.1.1
|
||||||
dynamic-import@0.6.0
|
dynamic-import@0.6.0
|
||||||
ecmascript@0.15.0
|
ecmascript@0.15.1
|
||||||
ecmascript-runtime@0.7.0
|
ecmascript-runtime@0.7.0
|
||||||
ecmascript-runtime-client@0.11.0
|
ecmascript-runtime-client@0.11.0
|
||||||
ecmascript-runtime-server@0.10.0
|
ecmascript-runtime-server@0.10.0
|
||||||
@@ -48,13 +48,13 @@ fetch@0.1.1
|
|||||||
geojson-utils@1.0.10
|
geojson-utils@1.0.10
|
||||||
google-oauth@1.3.0
|
google-oauth@1.3.0
|
||||||
hot-code-push@1.0.4
|
hot-code-push@1.0.4
|
||||||
html-tools@1.0.11
|
html-tools@1.1.1
|
||||||
htmljs@1.0.11
|
htmljs@1.1.0
|
||||||
http@1.4.3
|
http@1.4.3
|
||||||
id-map@1.1.0
|
id-map@1.1.0
|
||||||
inter-process-messaging@0.1.1
|
inter-process-messaging@0.1.1
|
||||||
lai:collection-extensions@0.2.1_1
|
lai:collection-extensions@0.2.1_1
|
||||||
launch-screen@1.2.0
|
launch-screen@1.2.1
|
||||||
livedata@1.0.18
|
livedata@1.0.18
|
||||||
localstorage@1.2.0
|
localstorage@1.2.0
|
||||||
logging@1.2.0
|
logging@1.2.0
|
||||||
@@ -65,19 +65,19 @@ meteorhacks:subs-manager@1.6.4
|
|||||||
mikowals:batch-insert@1.2.0
|
mikowals:batch-insert@1.2.0
|
||||||
minifier-css@1.5.3
|
minifier-css@1.5.3
|
||||||
minifier-js@2.6.0
|
minifier-js@2.6.0
|
||||||
minimongo@1.6.1
|
minimongo@1.6.2
|
||||||
mobile-experience@1.1.0
|
mobile-experience@1.1.0
|
||||||
mobile-status-bar@1.1.0
|
mobile-status-bar@1.1.0
|
||||||
modern-browsers@0.1.5
|
modern-browsers@0.1.5
|
||||||
modules@0.16.0
|
modules@0.16.0
|
||||||
modules-runtime@0.12.0
|
modules-runtime@0.12.0
|
||||||
momentjs:moment@2.29.1
|
momentjs:moment@2.29.1
|
||||||
mongo@1.10.1
|
mongo@1.11.0
|
||||||
mongo-decimal@0.1.2
|
mongo-decimal@0.1.2
|
||||||
mongo-dev-server@1.1.0
|
mongo-dev-server@1.1.0
|
||||||
mongo-id@1.0.7
|
mongo-id@1.0.7
|
||||||
npm-bcrypt@0.9.3
|
npm-bcrypt@0.9.3
|
||||||
npm-mongo@3.8.1
|
npm-mongo@3.9.0
|
||||||
oauth@1.3.2
|
oauth@1.3.2
|
||||||
oauth2@1.3.0
|
oauth2@1.3.0
|
||||||
ongoworks:speakingurl@9.0.0
|
ongoworks:speakingurl@9.0.0
|
||||||
@@ -113,16 +113,17 @@ simple:json-routes@2.1.0
|
|||||||
simple:rest@1.1.1
|
simple:rest@1.1.1
|
||||||
simple:rest-method-mixin@1.0.1
|
simple:rest-method-mixin@1.0.1
|
||||||
socket-stream-client@0.3.1
|
socket-stream-client@0.3.1
|
||||||
spacebars-compiler@1.1.3
|
spacebars-compiler@1.2.1
|
||||||
srp@1.1.0
|
srp@1.1.0
|
||||||
standard-minifier-js@2.6.0
|
standard-minifier-js@2.6.0
|
||||||
static-html@1.2.2
|
static-html@1.3.0
|
||||||
templates:array@1.0.3
|
templates:array@1.0.3
|
||||||
templating-tools@1.1.2
|
templating-tools@1.2.0
|
||||||
tmeasday:check-npm-versions@0.3.2
|
tmeasday:check-npm-versions@1.0.1
|
||||||
tracker@1.2.0
|
tracker@1.2.0
|
||||||
|
typescript@4.2.2
|
||||||
underscore@1.0.10
|
underscore@1.0.10
|
||||||
url@1.3.1
|
url@1.3.1
|
||||||
webapp@1.10.0
|
webapp@1.10.1
|
||||||
webapp-hashing@1.1.0
|
webapp-hashing@1.1.0
|
||||||
zer0th:meteor-vuetify-loader@0.1.30
|
zer0th:meteor-vuetify-loader@0.1.30
|
||||||
|
|||||||
@@ -104,31 +104,10 @@ export default class ComputationMemo {
|
|||||||
let variableName = prop.variableName;
|
let variableName = prop.variableName;
|
||||||
if (!variableName) return;
|
if (!variableName) return;
|
||||||
let existingStat = this.statsByVariableName[variableName];
|
let existingStat = this.statsByVariableName[variableName];
|
||||||
|
prop = this.registerProperty(prop);
|
||||||
if (existingStat){
|
if (existingStat){
|
||||||
existingStat.computationDetails.idsOfSameName.push(prop._id);
|
existingStat.computationDetails.idsOfSameName.push(prop._id);
|
||||||
this.originalPropsById[prop._id] = cloneDeep(prop);
|
|
||||||
if (prop.baseValueCalculation){
|
|
||||||
existingStat.computationDetails.effects.push({
|
|
||||||
operation: 'base',
|
|
||||||
calculation: prop.baseValueCalculation,
|
|
||||||
stats: [variableName],
|
|
||||||
computationDetails: propDetailsByType.effect(),
|
|
||||||
statBase: true,
|
|
||||||
dependencies: [],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (prop.baseProficiency){
|
|
||||||
existingStat.computationDetails.proficiencies.push({
|
|
||||||
value: prop.baseProficiency,
|
|
||||||
stats: [variableName],
|
|
||||||
computationDetails: propDetailsByType.proficiency(),
|
|
||||||
type: 'proficiency',
|
|
||||||
statBase: true,
|
|
||||||
dependencies: [],
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
prop = this.registerProperty(prop);
|
|
||||||
this.statsById[prop._id] = prop;
|
this.statsById[prop._id] = prop;
|
||||||
this.statsByVariableName[variableName] = prop;
|
this.statsByVariableName[variableName] = prop;
|
||||||
if (
|
if (
|
||||||
@@ -190,7 +169,9 @@ export default class ComputationMemo {
|
|||||||
prop = this.registerProperty(prop);
|
prop = this.registerProperty(prop);
|
||||||
let targets = this.getProficiencyTargets(prop);
|
let targets = this.getProficiencyTargets(prop);
|
||||||
targets.forEach(target => {
|
targets.forEach(target => {
|
||||||
target.computationDetails.proficiencies.push(prop);
|
if(target.computationDetails.proficiencies){
|
||||||
|
target.computationDetails.proficiencies.push(prop);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
getProficiencyTargets(prop){
|
getProficiencyTargets(prop){
|
||||||
@@ -267,6 +248,7 @@ const propDetailsByType = {
|
|||||||
computed: false,
|
computed: false,
|
||||||
busyComputing: false,
|
busyComputing: false,
|
||||||
effects: [],
|
effects: [],
|
||||||
|
proficiencies: [],
|
||||||
toggleAncestors: [],
|
toggleAncestors: [],
|
||||||
idsOfSameName: [],
|
idsOfSameName: [],
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,31 +1,6 @@
|
|||||||
import evaluateCalculation from '/imports/api/creature/computation/engine/evaluateCalculation.js';
|
|
||||||
import { union } from 'lodash';
|
|
||||||
|
|
||||||
export default class EffectAggregator{
|
export default class EffectAggregator{
|
||||||
constructor(stat, memo){
|
constructor(){
|
||||||
delete this.baseValueErrors;
|
this.base = 0;
|
||||||
if (stat.baseValueCalculation){
|
|
||||||
let {
|
|
||||||
result,
|
|
||||||
context,
|
|
||||||
dependencies
|
|
||||||
} = evaluateCalculation({
|
|
||||||
string: stat.baseValueCalculation,
|
|
||||||
prop: stat,
|
|
||||||
memo
|
|
||||||
});
|
|
||||||
this.statBaseValue = +result.value;
|
|
||||||
stat.dependencies = union(
|
|
||||||
stat.dependencies,
|
|
||||||
dependencies,
|
|
||||||
);
|
|
||||||
if (context.errors.length){
|
|
||||||
this.baseValueErrors = context.errors;
|
|
||||||
}
|
|
||||||
this.base = this.statBaseValue;
|
|
||||||
} else {
|
|
||||||
this.base = 0;
|
|
||||||
}
|
|
||||||
this.add = 0;
|
this.add = 0;
|
||||||
this.mul = 1;
|
this.mul = 1;
|
||||||
this.min = Number.NEGATIVE_INFINITY;
|
this.min = Number.NEGATIVE_INFINITY;
|
||||||
@@ -46,11 +21,6 @@ export default class EffectAggregator{
|
|||||||
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 (this.statBaseValue === undefined || result > this.statBaseValue){
|
|
||||||
this.statBaseValue = result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 'add':
|
case 'add':
|
||||||
// Add all adds together
|
// Add all adds together
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import computeStat from '/imports/api/creature/computation/engine/computeStat.js';
|
import computeStat from '/imports/api/creature/computation/engine/computeStat.js';
|
||||||
import applyToggles from '/imports/api/creature/computation/engine/applyToggles.js';
|
import computeProficiency from '/imports/api/creature/computation/engine/computeProficiency.js';
|
||||||
import evaluateCalculation from '/imports/api/creature/computation/engine/evaluateCalculation.js';
|
import evaluateCalculation from '/imports/api/creature/computation/engine/evaluateCalculation.js';
|
||||||
import { union } from 'lodash';
|
import { union } from 'lodash';
|
||||||
|
|
||||||
@@ -14,7 +14,8 @@ export default function combineStat(stat, aggregator, memo){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getAggregatorResult(stat, aggregator){
|
function getAggregatorResult(stat, aggregator){
|
||||||
let result = (aggregator.base + aggregator.add) * aggregator.mul;
|
let base = Math.max(aggregator.base, stat.baseValue || 0);
|
||||||
|
let result = (base + aggregator.add) * aggregator.mul;
|
||||||
if (result < aggregator.min) {
|
if (result < aggregator.min) {
|
||||||
result = aggregator.min;
|
result = aggregator.min;
|
||||||
}
|
}
|
||||||
@@ -32,8 +33,6 @@ function getAggregatorResult(stat, aggregator){
|
|||||||
|
|
||||||
function combineAttribute(stat, aggregator, memo){
|
function combineAttribute(stat, aggregator, memo){
|
||||||
stat.value = getAggregatorResult(stat, aggregator);
|
stat.value = getAggregatorResult(stat, aggregator);
|
||||||
stat.baseValue = aggregator.statBaseValue;
|
|
||||||
stat.baseValueErrors = aggregator.baseValueErrors;
|
|
||||||
if (stat.attributeType === 'spellSlot'){
|
if (stat.attributeType === 'spellSlot'){
|
||||||
let {
|
let {
|
||||||
result,
|
result,
|
||||||
@@ -78,9 +77,7 @@ function combineSkill(stat, aggregator, memo){
|
|||||||
// Skills are based on some ability Modifier
|
// Skills are based on some ability Modifier
|
||||||
let ability = stat.ability && memo.statsByVariableName[stat.ability]
|
let ability = stat.ability && memo.statsByVariableName[stat.ability]
|
||||||
if (stat.ability && ability){
|
if (stat.ability && ability){
|
||||||
if (!ability.computationDetails.computed){
|
computeStat(ability, memo);
|
||||||
computeStat(ability, memo);
|
|
||||||
}
|
|
||||||
stat.abilityMod = ability.modifier;
|
stat.abilityMod = ability.modifier;
|
||||||
stat.dependencies = union(
|
stat.dependencies = union(
|
||||||
stat.dependencies,
|
stat.dependencies,
|
||||||
@@ -91,10 +88,10 @@ function combineSkill(stat, aggregator, memo){
|
|||||||
stat.abilityMod = 0;
|
stat.abilityMod = 0;
|
||||||
}
|
}
|
||||||
// Combine all the child proficiencies
|
// Combine all the child proficiencies
|
||||||
stat.proficiency = stat.baseProficiency || 0;
|
stat.proficiency = 0;
|
||||||
for (let i in stat.computationDetails.proficiencies){
|
for (let i in stat.computationDetails.proficiencies){
|
||||||
let prof = stat.computationDetails.proficiencies[i];
|
let prof = stat.computationDetails.proficiencies[i];
|
||||||
applyToggles(prof, memo);
|
computeProficiency(prof, memo);
|
||||||
if (
|
if (
|
||||||
!prof.deactivatedByToggle &&
|
!prof.deactivatedByToggle &&
|
||||||
prof.value > stat.proficiency
|
prof.value > stat.proficiency
|
||||||
@@ -111,6 +108,14 @@ function combineSkill(stat, aggregator, memo){
|
|||||||
let profBonusStat = memo.statsByVariableName['proficiencyBonus'];
|
let profBonusStat = memo.statsByVariableName['proficiencyBonus'];
|
||||||
let profBonus = profBonusStat && profBonusStat.value;
|
let profBonus = profBonusStat && profBonusStat.value;
|
||||||
|
|
||||||
|
if (profBonusStat){
|
||||||
|
stat.dependencies = union(
|
||||||
|
stat.dependencies,
|
||||||
|
[profBonusStat._id],
|
||||||
|
profBonusStat.dependencies,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
if (typeof profBonus !== 'number' && memo.statsByVariableName['level']){
|
if (typeof profBonus !== 'number' && memo.statsByVariableName['level']){
|
||||||
let levelProp = memo.statsByVariableName['level'];
|
let levelProp = memo.statsByVariableName['level'];
|
||||||
let level = levelProp.value;
|
let level = levelProp.value;
|
||||||
@@ -121,18 +126,16 @@ function combineSkill(stat, aggregator, memo){
|
|||||||
if (levelProp.dependencies){
|
if (levelProp.dependencies){
|
||||||
stat.dependencies = union(stat.dependencies, levelProp.dependencies);
|
stat.dependencies = union(stat.dependencies, levelProp.dependencies);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
stat.dependencies = union(
|
|
||||||
stat.dependencies,
|
|
||||||
[profBonusStat._id],
|
|
||||||
profBonusStat.dependencies,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Multiply the proficiency bonus by the actual proficiency
|
// Multiply the proficiency bonus by the actual proficiency
|
||||||
profBonus *= stat.proficiency;
|
if(stat.proficiency === 0.49){
|
||||||
// Base value
|
// Round down proficiency bonus in the special case
|
||||||
stat.baseValue = aggregator.statBaseValue;
|
profBonus = Math.floor(profBonus * 0.5);
|
||||||
stat.baseValueErrors = aggregator.baseValueErrors;
|
} else {
|
||||||
|
profBonus = Math.ceil(profBonus * stat.proficiency);
|
||||||
|
}
|
||||||
|
|
||||||
// Combine everything to get the final result
|
// Combine everything to get the final result
|
||||||
let result = (aggregator.base + stat.abilityMod + profBonus + aggregator.add) * aggregator.mul;
|
let result = (aggregator.base + stat.abilityMod + profBonus + aggregator.add) * aggregator.mul;
|
||||||
if (result < aggregator.min) result = aggregator.min;
|
if (result < aggregator.min) result = aggregator.min;
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
import applyToggles from '/imports/api/creature/computation/engine/applyToggles.js';
|
||||||
|
|
||||||
|
export default function computeEffect(proficiency, memo){
|
||||||
|
if (proficiency.computationDetails.computed) return;
|
||||||
|
if (proficiency.computationDetails.busyComputing){
|
||||||
|
// Trying to compute this proficiency again while it is already computing.
|
||||||
|
// We must be in a dependency loop.
|
||||||
|
proficiency.computationDetails.computed = true;
|
||||||
|
proficiency.result = NaN;
|
||||||
|
proficiency.computationDetails.busyComputing = false;
|
||||||
|
proficiency.computationDetails.error = 'dependencyLoop';
|
||||||
|
if (Meteor.isClient) console.warn('dependencyLoop', proficiency);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Before doing any work, mark this proficiency as busy
|
||||||
|
proficiency.computationDetails.busyComputing = true;
|
||||||
|
|
||||||
|
// Apply any toggles
|
||||||
|
applyToggles(proficiency, memo);
|
||||||
|
|
||||||
|
proficiency.computationDetails.computed = true;
|
||||||
|
proficiency.computationDetails.busyComputing = false;
|
||||||
|
}
|
||||||
@@ -1,8 +1,9 @@
|
|||||||
import combineStat from '/imports/api/creature/computation/engine/combineStat.js';
|
import combineStat from '/imports/api/creature/computation/engine/combineStat.js';
|
||||||
import computeEffect from '/imports/api/creature/computation/engine/computeEffect.js';
|
import computeEffect from '/imports/api/creature/computation/engine/computeEffect.js';
|
||||||
import EffectAggregator from '/imports/api/creature/computation/engine/EffectAggregator.js';
|
import EffectAggregator from '/imports/api/creature/computation/engine/EffectAggregator.js';
|
||||||
|
import evaluateCalculation from '/imports/api/creature/computation/engine/evaluateCalculation.js';
|
||||||
import applyToggles from '/imports/api/creature/computation/engine/applyToggles.js';
|
import applyToggles from '/imports/api/creature/computation/engine/applyToggles.js';
|
||||||
import { each, union } from 'lodash';
|
import { each, union, without } from 'lodash';
|
||||||
|
|
||||||
export default function computeStat(stat, memo){
|
export default function computeStat(stat, memo){
|
||||||
// If the stat is already computed, skip it
|
// If the stat is already computed, skip it
|
||||||
@@ -19,29 +20,135 @@ export default function computeStat(stat, memo){
|
|||||||
}
|
}
|
||||||
// Before doing any work, mark this stat as busy
|
// Before doing any work, mark this stat as busy
|
||||||
stat.computationDetails.busyComputing = true;
|
stat.computationDetails.busyComputing = true;
|
||||||
// Apply any toggles
|
|
||||||
applyToggles(stat, memo);
|
let effects = stat.computationDetails.effects || [];
|
||||||
|
let proficiencies = stat.computationDetails.proficiencies || [];
|
||||||
|
|
||||||
|
// Get references to all the stats that share the variable name
|
||||||
|
let sameNameStats
|
||||||
|
|
||||||
|
if (stat.computationDetails.idsOfSameName){
|
||||||
|
sameNameStats = stat.computationDetails.idsOfSameName.map(
|
||||||
|
id => memo.propsById[id]
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
sameNameStats = [];
|
||||||
|
}
|
||||||
|
|
||||||
|
let allStats = [stat, ...sameNameStats];
|
||||||
|
|
||||||
|
// Decide which stat is the last active stat
|
||||||
|
// The last active stat is considered the cannonical stat
|
||||||
|
let lastActiveStat;
|
||||||
|
allStats.forEach(candidateStat => {
|
||||||
|
applyToggles(candidateStat, memo);
|
||||||
|
if (!candidateStat.inactive) lastActiveStat = candidateStat;
|
||||||
|
candidateStat.overridden = undefined;
|
||||||
|
});
|
||||||
|
if (!lastActiveStat){
|
||||||
|
delete memo.statsByVariableName[stat.variableName];
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Make sure the active stat has all the effects and proficiencies
|
||||||
|
lastActiveStat.computationDetails.effects = effects;
|
||||||
|
lastActiveStat.computationDetails.proficiencies = proficiencies;
|
||||||
|
|
||||||
|
// Update the memo's stat with the chosen stat
|
||||||
|
memo.statsByVariableName[stat.variableName] = lastActiveStat;
|
||||||
|
|
||||||
|
// Recreate list of the non-cannonical stats
|
||||||
|
sameNameStats = without(allStats, lastActiveStat);
|
||||||
|
|
||||||
|
sameNameStats.forEach(statInstance => {
|
||||||
|
// Mark the non-cannonical stats as overridden
|
||||||
|
statInstance.overridden = true;
|
||||||
|
|
||||||
|
// Apply the cannonical damage
|
||||||
|
statInstance.damage = lastActiveStat.damage;
|
||||||
|
});
|
||||||
|
|
||||||
|
let baseDependencies = [];
|
||||||
|
allStats.forEach(statInstance => {
|
||||||
|
// Add this stat and its deps to the dependencies
|
||||||
|
baseDependencies = union(
|
||||||
|
baseDependencies,
|
||||||
|
[statInstance._id],
|
||||||
|
statInstance.dependencies,
|
||||||
|
);
|
||||||
|
|
||||||
|
// Apply all the base proficiencies
|
||||||
|
if (statInstance.baseProficiency && !statInstance.inactive){
|
||||||
|
proficiencies.push({
|
||||||
|
value: statInstance.baseProficiency,
|
||||||
|
stats: [statInstance.variableName],
|
||||||
|
type: 'proficiency',
|
||||||
|
dependencies: statInstance.overridden ?
|
||||||
|
union(statInstance.dependencies, [statInstance._id]) :
|
||||||
|
[],
|
||||||
|
computationDetails: {
|
||||||
|
computed: true,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compute each active stat's baseValue calculation and apply it
|
||||||
|
if (!statInstance.inactive) {
|
||||||
|
let {
|
||||||
|
result,
|
||||||
|
context,
|
||||||
|
dependencies
|
||||||
|
} = evaluateCalculation({
|
||||||
|
string: statInstance.baseValueCalculation,
|
||||||
|
prop: statInstance,
|
||||||
|
memo
|
||||||
|
});
|
||||||
|
statInstance.baseValue = +result.value;
|
||||||
|
statInstance.dependencies = union(statInstance.dependencies, dependencies);
|
||||||
|
if (context.errors.length){
|
||||||
|
statInstance.baseValueErrors = context.errors;
|
||||||
|
}
|
||||||
|
// Apply all the base values
|
||||||
|
effects.push({
|
||||||
|
operation: 'base',
|
||||||
|
calculation: statInstance.baseValueCalculation,
|
||||||
|
result: statInstance.baseValue,
|
||||||
|
stats: [statInstance.variableName],
|
||||||
|
dependencies: statInstance.overridden ?
|
||||||
|
union(statInstance.dependencies, [statInstance._id]) :
|
||||||
|
[],
|
||||||
|
computationDetails: {
|
||||||
|
computed: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
// Compute and aggregate all the effects
|
// Compute and aggregate all the effects
|
||||||
let aggregator = new EffectAggregator(stat, memo)
|
let aggregator = new EffectAggregator();
|
||||||
each(stat.computationDetails.effects, (effect) => {
|
let effectDeps = [];
|
||||||
|
each(effects, (effect) => {
|
||||||
|
// Compute
|
||||||
computeEffect(effect, memo);
|
computeEffect(effect, memo);
|
||||||
if (effect.deactivatedByToggle) return;
|
if (effect.deactivatedByToggle) return;
|
||||||
if (effect._id){
|
|
||||||
stat.dependencies = union(
|
// dependencies
|
||||||
stat.dependencies,
|
if (effect._id) effectDeps = union(effectDeps, [effect._id]);
|
||||||
[effect._id]
|
effectDeps = union(effectDeps, effect.dependencies);
|
||||||
);
|
|
||||||
}
|
// Add computed effect to aggregator
|
||||||
stat.dependencies = union(
|
|
||||||
stat.dependencies,
|
|
||||||
effect.dependencies
|
|
||||||
)
|
|
||||||
aggregator.addEffect(effect);
|
aggregator.addEffect(effect);
|
||||||
});
|
});
|
||||||
// Conglomerate all the effects to compute the final stat values
|
|
||||||
combineStat(stat, aggregator, memo);
|
// Combine the effects into the stats
|
||||||
// Mark the attribute as computed
|
allStats.forEach(statInstance => {
|
||||||
stat.computationDetails.computed = true;
|
// Conglomerate all the effects to compute the final stat values
|
||||||
stat.computationDetails.busyComputing = false;
|
combineStat(statInstance, aggregator, memo);
|
||||||
|
// Mark the stats as computed
|
||||||
|
statInstance.computationDetails.computed = true;
|
||||||
|
statInstance.computationDetails.busyComputing = false;
|
||||||
|
// Only the active stat instance depeneds on the effects
|
||||||
|
if (!statInstance.overridden){
|
||||||
|
statInstance.dependencies = union(statInstance.dependencies, effectDeps);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,29 +12,22 @@ export default function writeAlteredProperties(memo){
|
|||||||
console.warn('No schema for ' + changed.type);
|
console.warn('No schema for ' + changed.type);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let extraIds = changed.computationDetails.idsOfSameName;
|
let id = changed._id;
|
||||||
let ids;
|
let op = undefined;
|
||||||
if (extraIds && extraIds.length){
|
let original = memo.originalPropsById[id];
|
||||||
ids = [changed._id, ...extraIds];
|
let keys = [
|
||||||
} else {
|
'dependencies',
|
||||||
ids = [changed._id];
|
'inactive',
|
||||||
|
'deactivatedBySelf',
|
||||||
|
'deactivatedByAncestor',
|
||||||
|
'deactivatedByToggle',
|
||||||
|
'damage',
|
||||||
|
...schema.objectKeys(),
|
||||||
|
];
|
||||||
|
op = addChangedKeysToOp(op, keys, original, changed);
|
||||||
|
if (op){
|
||||||
|
bulkWriteOperations.push(op);
|
||||||
}
|
}
|
||||||
ids.forEach(id => {
|
|
||||||
let op = undefined;
|
|
||||||
let original = memo.originalPropsById[id];
|
|
||||||
let keys = [
|
|
||||||
'dependencies',
|
|
||||||
'inactive',
|
|
||||||
'deactivatedBySelf',
|
|
||||||
'deactivatedByAncestor',
|
|
||||||
'deactivatedByToggle',
|
|
||||||
...schema.objectKeys(),
|
|
||||||
];
|
|
||||||
op = addChangedKeysToOp(op, keys, original, changed);
|
|
||||||
if (op){
|
|
||||||
bulkWriteOperations.push(op);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
writePropertiesSequentially(bulkWriteOperations);
|
writePropertiesSequentially(bulkWriteOperations);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,7 @@ import {
|
|||||||
import { reorderDocs } from '/imports/api/parenting/order.js';
|
import { reorderDocs } from '/imports/api/parenting/order.js';
|
||||||
import { setDocToLastOrder } from '/imports/api/parenting/order.js';
|
import { setDocToLastOrder } from '/imports/api/parenting/order.js';
|
||||||
import recomputeInventory from '/imports/api/creature/denormalise/recomputeInventory.js';
|
import recomputeInventory from '/imports/api/creature/denormalise/recomputeInventory.js';
|
||||||
|
import fetchDocByRef from '/imports/api/parenting/fetchDocByRef.js';
|
||||||
|
|
||||||
const insertPropertyFromLibraryNode = new ValidatedMethod({
|
const insertPropertyFromLibraryNode = new ValidatedMethod({
|
||||||
name: 'creatureProperties.insertPropertyFromLibraryNode',
|
name: 'creatureProperties.insertPropertyFromLibraryNode',
|
||||||
@@ -54,6 +55,7 @@ const insertPropertyFromLibraryNode = new ValidatedMethod({
|
|||||||
|
|
||||||
// Fetch the library node and its decendents, provided they have not been
|
// Fetch the library node and its decendents, provided they have not been
|
||||||
// removed
|
// removed
|
||||||
|
// TODO: Check permission to read the library this node is in
|
||||||
let node = LibraryNodes.findOne({
|
let node = LibraryNodes.findOne({
|
||||||
_id: nodeId,
|
_id: nodeId,
|
||||||
removed: {$ne: true},
|
removed: {$ne: true},
|
||||||
@@ -65,6 +67,9 @@ const insertPropertyFromLibraryNode = new ValidatedMethod({
|
|||||||
removed: {$ne: true},
|
removed: {$ne: true},
|
||||||
}).fetch();
|
}).fetch();
|
||||||
|
|
||||||
|
// Convert all references into actual nodes
|
||||||
|
nodes = reifyNodeReferences(nodes);
|
||||||
|
|
||||||
// The root node is first in the array of nodes
|
// The root node is first in the array of nodes
|
||||||
// It must get the first generated ID to prevent flickering
|
// It must get the first generated ID to prevent flickering
|
||||||
nodes = [node, ...nodes];
|
nodes = [node, ...nodes];
|
||||||
@@ -115,4 +120,95 @@ const insertPropertyFromLibraryNode = new ValidatedMethod({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Covert node references into actual nodes
|
||||||
|
// TODO: check permissions for each library a reference node references
|
||||||
|
function reifyNodeReferences(nodes, visitedRefs = new Set(), depth = 0){
|
||||||
|
depth += 1;
|
||||||
|
// New nodes added this function
|
||||||
|
let newNodes = [];
|
||||||
|
|
||||||
|
// Filter out the reference nodes we replace
|
||||||
|
let resultingNodes = nodes.filter(node => {
|
||||||
|
|
||||||
|
// We have already visited this ref and replaced it
|
||||||
|
if (visitedRefs.has(node._id)) return false;
|
||||||
|
|
||||||
|
// Already replaced an ancestor node
|
||||||
|
for (let i; i < node.ancestors.length; i++){
|
||||||
|
if (visitedRefs.has(node.ancestors[i].id)) return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This isn't a reference node, continue as normal
|
||||||
|
if (node.type !== 'reference') return true;
|
||||||
|
|
||||||
|
// We have gone too deep, keep the reference node as an error
|
||||||
|
if (depth > 10){
|
||||||
|
if (Meteor.isClient) console.warn('Reference depth limit exceeded');
|
||||||
|
node.cache = {error: 'Reference depth limit exceeded'};
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
let referencedNode
|
||||||
|
try {
|
||||||
|
referencedNode = fetchDocByRef(node.ref);
|
||||||
|
referencedNode.order = node.order;
|
||||||
|
// We are definitely replacing this node, so add it to the list
|
||||||
|
visitedRefs.add(node._id);
|
||||||
|
} catch (e){
|
||||||
|
node.cache = {error: e.reason || e.message || e.toString()};
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get all the descendants of the referenced node
|
||||||
|
let descendents = LibraryNodes.find({
|
||||||
|
'ancestors.id': referencedNode._id,
|
||||||
|
removed: {$ne: true},
|
||||||
|
}, {
|
||||||
|
sort: {order: 1},
|
||||||
|
}).fetch();
|
||||||
|
|
||||||
|
// We are adding the referenced node and its descendants
|
||||||
|
let addedNodes = [referencedNode, ...descendents];
|
||||||
|
|
||||||
|
// re-map all the ancestors to parent the new sub-tree into our existing
|
||||||
|
// node tree
|
||||||
|
setLineageOfDocs({
|
||||||
|
docArray: addedNodes,
|
||||||
|
newAncestry: node.ancestors,
|
||||||
|
oldParent: referencedNode.parent,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Remove all the looped references and descendents from the new nodes
|
||||||
|
// We can't rely on the reify recursion to do this, since the IDs are
|
||||||
|
// getting renewed before it is called
|
||||||
|
addedNodes = addedNodes.filter(node => {
|
||||||
|
// Exclude removed referenced
|
||||||
|
if (visitedRefs.has(node._id)) return false;
|
||||||
|
|
||||||
|
// Exclude descendants of removed references
|
||||||
|
for (let i; i < node.ancestors.length; i++){
|
||||||
|
if (visitedRefs.has(node.ancestors[i].id)) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Give the new referenced sub-tree new ids
|
||||||
|
renewDocIds({
|
||||||
|
docArray: addedNodes,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Reify the subtree as well with recursion
|
||||||
|
addedNodes = reifyNodeReferences(addedNodes, visitedRefs, depth);
|
||||||
|
|
||||||
|
// Store the new nodes from this inner loop without altering the array
|
||||||
|
// we are looping over
|
||||||
|
newNodes.push(...addedNodes);
|
||||||
|
});
|
||||||
|
|
||||||
|
// We are done filtering the array, we can add the new nodes to it
|
||||||
|
resultingNodes.push(...newNodes);
|
||||||
|
|
||||||
|
return resultingNodes;
|
||||||
|
}
|
||||||
|
|
||||||
export default insertPropertyFromLibraryNode;
|
export default insertPropertyFromLibraryNode;
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import { softRemove } from '/imports/api/parenting/softRemove.js';
|
|||||||
import SoftRemovableSchema from '/imports/api/parenting/SoftRemovableSchema.js';
|
import SoftRemovableSchema from '/imports/api/parenting/SoftRemovableSchema.js';
|
||||||
import { storedIconsSchema } from '/imports/api/icons/Icons.js';
|
import { storedIconsSchema } from '/imports/api/icons/Icons.js';
|
||||||
import '/imports/api/library/methods/index.js';
|
import '/imports/api/library/methods/index.js';
|
||||||
|
import { updateReferenceNodeWork } from '/imports/api/library/methods/updateReferenceNode.js';
|
||||||
|
|
||||||
let LibraryNodes = new Mongo.Collection('libraryNodes');
|
let LibraryNodes = new Mongo.Collection('libraryNodes');
|
||||||
|
|
||||||
@@ -76,7 +77,12 @@ const insertNode = new ValidatedMethod({
|
|||||||
run(libraryNode) {
|
run(libraryNode) {
|
||||||
delete libraryNode._id;
|
delete libraryNode._id;
|
||||||
assertNodeEditPermission(libraryNode, this.userId);
|
assertNodeEditPermission(libraryNode, this.userId);
|
||||||
return LibraryNodes.insert(libraryNode);
|
let nodeId = LibraryNodes.insert(libraryNode);
|
||||||
|
if (libraryNode.type == 'reference'){
|
||||||
|
libraryNode._id = nodeId;
|
||||||
|
updateReferenceNodeWork(libraryNode, this.userId);
|
||||||
|
}
|
||||||
|
return nodeId;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -109,9 +115,14 @@ const updateLibraryNode = new ValidatedMethod({
|
|||||||
} else {
|
} else {
|
||||||
modifier = {$set: {[pathString]: value}};
|
modifier = {$set: {[pathString]: value}};
|
||||||
}
|
}
|
||||||
return LibraryNodes.update(_id, modifier, {
|
let numUpdated = LibraryNodes.update(_id, modifier, {
|
||||||
selector: {type: node.type},
|
selector: {type: node.type},
|
||||||
});
|
});
|
||||||
|
if (node.type == 'reference'){
|
||||||
|
node = LibraryNodes.findOne(_id);
|
||||||
|
updateReferenceNodeWork(node, this.userId);
|
||||||
|
}
|
||||||
|
return numUpdated;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
import '/imports/api/library/methods/duplicateLibraryNode.js';
|
import '/imports/api/library/methods/duplicateLibraryNode.js';
|
||||||
|
import '/imports/api/library/methods/updateReferenceNode.js';
|
||||||
|
|||||||
67
app/imports/api/library/methods/updateReferenceNode.js
Normal file
67
app/imports/api/library/methods/updateReferenceNode.js
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
||||||
|
import SimpleSchema from 'simpl-schema';
|
||||||
|
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
||||||
|
import LibraryNodes from '/imports/api/library/LibraryNodes.js';
|
||||||
|
import {
|
||||||
|
assertDocEditPermission,
|
||||||
|
assertViewPermission,
|
||||||
|
} from '/imports/api/sharing/sharingPermissions.js';
|
||||||
|
import fetchDocByRef from '/imports/api/parenting/fetchDocByRef.js';
|
||||||
|
|
||||||
|
const updateReferenceNode = new ValidatedMethod({
|
||||||
|
name: 'libraryNodes.updateReferenceNode',
|
||||||
|
validate: new SimpleSchema({
|
||||||
|
_id: {
|
||||||
|
type: String,
|
||||||
|
regEx: SimpleSchema.RegEx.Id,
|
||||||
|
}
|
||||||
|
}).validator(),
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
|
run({_id}) {
|
||||||
|
let userId = this.userId;
|
||||||
|
let node = LibraryNodes.findOne(_id);
|
||||||
|
assertDocEditPermission(node, userId);
|
||||||
|
updateReferenceNodeWork(node, userId);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
function writeCache(_id, cache){
|
||||||
|
LibraryNodes.update(_id, {$set: {cache}}, {
|
||||||
|
selector: {type: 'reference'},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateReferenceNodeWork(node, userId){
|
||||||
|
let cache = {}
|
||||||
|
if (!node.ref){
|
||||||
|
writeCache(node._id, cache);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let doc, library;
|
||||||
|
try {
|
||||||
|
doc = fetchDocByRef(node.ref);
|
||||||
|
if (doc.removed) throw 'Property has been deleted';
|
||||||
|
if (doc.ancestors[0].id !== node.ancestors[0].id){
|
||||||
|
library = fetchDocByRef(doc.ancestors[0]);
|
||||||
|
assertViewPermission(library, userId)
|
||||||
|
}
|
||||||
|
} catch(e){
|
||||||
|
cache = {error: e.reason || e.message || e.toString()}
|
||||||
|
writeCache(node._id, cache);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cache = {
|
||||||
|
node: {name: doc.name, type: doc.type},
|
||||||
|
};
|
||||||
|
if (library){
|
||||||
|
cache.library = {name: library.name};
|
||||||
|
}
|
||||||
|
writeCache(node._id, cache);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default updateReferenceNode;
|
||||||
|
export { updateReferenceNodeWork }
|
||||||
@@ -4,6 +4,11 @@ const RefSchema = new SimpleSchema({
|
|||||||
id: {
|
id: {
|
||||||
type: String,
|
type: String,
|
||||||
regEx: SimpleSchema.RegEx.Id,
|
regEx: SimpleSchema.RegEx.Id,
|
||||||
|
// TODO: Rather than indexing this field, index `ancestors.0.id` to only
|
||||||
|
// index the root of the ancestor heirarchy to significantly reduce
|
||||||
|
// index size and improve performance
|
||||||
|
// All queries on an ancestor document need to target `ancestors.0.id` first
|
||||||
|
// before targeting a younger ancestor
|
||||||
index: 1
|
index: 1
|
||||||
},
|
},
|
||||||
collection: {
|
collection: {
|
||||||
|
|||||||
@@ -133,6 +133,11 @@ let ComputedOnlyAttributeSchema = new SimpleSchema({
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
|
// Denormalised tag if stat is overridden by one with the same variable name
|
||||||
|
overridden: {
|
||||||
|
type: Boolean,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const ComputedAttributeSchema = new SimpleSchema()
|
const ComputedAttributeSchema = new SimpleSchema()
|
||||||
|
|||||||
@@ -14,9 +14,10 @@ let ProficiencySchema = new SimpleSchema({
|
|||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
// A number representing how proficient the character is
|
// A number representing how proficient the character is
|
||||||
|
// where 0.49 is half rounded down and 0.5 is half rounded up
|
||||||
value: {
|
value: {
|
||||||
type: Number,
|
type: Number,
|
||||||
allowedValues: [0.5, 1, 2],
|
allowedValues: [0.49, 0.5, 1, 2],
|
||||||
defaultValue: 1,
|
defaultValue: 1,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
47
app/imports/api/properties/References.js
Normal file
47
app/imports/api/properties/References.js
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
import SimpleSchema from 'simpl-schema';
|
||||||
|
|
||||||
|
let ReferenceSchema = new SimpleSchema({
|
||||||
|
ref: {
|
||||||
|
type: Object,
|
||||||
|
defaultValue: {},
|
||||||
|
},
|
||||||
|
'ref.id': {
|
||||||
|
type: String,
|
||||||
|
regEx: SimpleSchema.RegEx.Id,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
'ref.collection': {
|
||||||
|
type: String,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
// Denormalised store of referenced property's details
|
||||||
|
cache: {
|
||||||
|
type: Object,
|
||||||
|
defaultValue: {},
|
||||||
|
},
|
||||||
|
'cache.error': {
|
||||||
|
type: String,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
'cache.node': {
|
||||||
|
type: Object,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
'cache.node.name': {
|
||||||
|
type: String,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
'cache.node.type': {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
'cache.library': {
|
||||||
|
type: Object,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
'cache.library.name': {
|
||||||
|
type: String,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export { ReferenceSchema };
|
||||||
@@ -121,6 +121,11 @@ let ComputedOnlySkillSchema = new SimpleSchema({
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
|
// Denormalised tag if stat is overridden by one with the same variable name
|
||||||
|
overridden: {
|
||||||
|
type: Boolean,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const ComputedSkillSchema = new SimpleSchema()
|
const ComputedSkillSchema = new SimpleSchema()
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import { FolderSchema } from '/imports/api/properties/Folders.js';
|
|||||||
import { ComputedOnlyItemSchema } from '/imports/api/properties/Items.js';
|
import { ComputedOnlyItemSchema } from '/imports/api/properties/Items.js';
|
||||||
import { ComputedOnlyNoteSchema } from '/imports/api/properties/Notes.js';
|
import { ComputedOnlyNoteSchema } from '/imports/api/properties/Notes.js';
|
||||||
import { ProficiencySchema } from '/imports/api/properties/Proficiencies.js';
|
import { ProficiencySchema } from '/imports/api/properties/Proficiencies.js';
|
||||||
|
import { ReferenceSchema } from '/imports/api/properties/References.js';
|
||||||
import { ComputedOnlyRollSchema } from '/imports/api/properties/Rolls.js';
|
import { ComputedOnlyRollSchema } from '/imports/api/properties/Rolls.js';
|
||||||
import { ComputedOnlySavingThrowSchema } from '/imports/api/properties/SavingThrows.js';
|
import { ComputedOnlySavingThrowSchema } from '/imports/api/properties/SavingThrows.js';
|
||||||
import { ComputedOnlySkillSchema } from '/imports/api/properties/Skills.js';
|
import { ComputedOnlySkillSchema } from '/imports/api/properties/Skills.js';
|
||||||
@@ -42,6 +43,7 @@ const propertySchemasIndex = {
|
|||||||
note: ComputedOnlyNoteSchema,
|
note: ComputedOnlyNoteSchema,
|
||||||
proficiency: ProficiencySchema,
|
proficiency: ProficiencySchema,
|
||||||
propertySlot: ComputedOnlySlotSchema,
|
propertySlot: ComputedOnlySlotSchema,
|
||||||
|
reference: ReferenceSchema,
|
||||||
roll: ComputedOnlyRollSchema,
|
roll: ComputedOnlyRollSchema,
|
||||||
savingThrow: ComputedOnlySavingThrowSchema,
|
savingThrow: ComputedOnlySavingThrowSchema,
|
||||||
skill: ComputedOnlySkillSchema,
|
skill: ComputedOnlySkillSchema,
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import { FolderSchema } from '/imports/api/properties/Folders.js';
|
|||||||
import { ComputedItemSchema } from '/imports/api/properties/Items.js';
|
import { ComputedItemSchema } from '/imports/api/properties/Items.js';
|
||||||
import { ComputedNoteSchema } from '/imports/api/properties/Notes.js';
|
import { ComputedNoteSchema } from '/imports/api/properties/Notes.js';
|
||||||
import { ProficiencySchema } from '/imports/api/properties/Proficiencies.js';
|
import { ProficiencySchema } from '/imports/api/properties/Proficiencies.js';
|
||||||
|
import { ReferenceSchema } from '/imports/api/properties/References.js';
|
||||||
import { ComputedRollSchema } from '/imports/api/properties/Rolls.js';
|
import { ComputedRollSchema } from '/imports/api/properties/Rolls.js';
|
||||||
import { ComputedSavingThrowSchema } from '/imports/api/properties/SavingThrows.js';
|
import { ComputedSavingThrowSchema } from '/imports/api/properties/SavingThrows.js';
|
||||||
import { ComputedSkillSchema } from '/imports/api/properties/Skills.js';
|
import { ComputedSkillSchema } from '/imports/api/properties/Skills.js';
|
||||||
@@ -40,6 +41,7 @@ const propertySchemasIndex = {
|
|||||||
note: ComputedNoteSchema,
|
note: ComputedNoteSchema,
|
||||||
proficiency: ProficiencySchema,
|
proficiency: ProficiencySchema,
|
||||||
propertySlot: ComputedSlotSchema,
|
propertySlot: ComputedSlotSchema,
|
||||||
|
reference: ReferenceSchema,
|
||||||
roll: ComputedRollSchema,
|
roll: ComputedRollSchema,
|
||||||
savingThrow: ComputedSavingThrowSchema,
|
savingThrow: ComputedSavingThrowSchema,
|
||||||
skill: ComputedSkillSchema,
|
skill: ComputedSkillSchema,
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import { FeatureSchema } from '/imports/api/properties/Features.js';
|
|||||||
import { FolderSchema } from '/imports/api/properties/Folders.js';
|
import { FolderSchema } from '/imports/api/properties/Folders.js';
|
||||||
import { NoteSchema } from '/imports/api/properties/Notes.js';
|
import { NoteSchema } from '/imports/api/properties/Notes.js';
|
||||||
import { ProficiencySchema } from '/imports/api/properties/Proficiencies.js';
|
import { ProficiencySchema } from '/imports/api/properties/Proficiencies.js';
|
||||||
|
import { ReferenceSchema } from '/imports/api/properties/References.js';
|
||||||
import { RollSchema } from '/imports/api/properties/Rolls.js';
|
import { RollSchema } from '/imports/api/properties/Rolls.js';
|
||||||
import { SavingThrowSchema } from '/imports/api/properties/SavingThrows.js';
|
import { SavingThrowSchema } from '/imports/api/properties/SavingThrows.js';
|
||||||
import { SkillSchema } from '/imports/api/properties/Skills.js';
|
import { SkillSchema } from '/imports/api/properties/Skills.js';
|
||||||
@@ -40,6 +41,7 @@ const propertySchemasIndex = {
|
|||||||
note: NoteSchema,
|
note: NoteSchema,
|
||||||
proficiency: ProficiencySchema,
|
proficiency: ProficiencySchema,
|
||||||
propertySlot: SlotSchema,
|
propertySlot: SlotSchema,
|
||||||
|
reference: ReferenceSchema,
|
||||||
roll: RollSchema,
|
roll: RollSchema,
|
||||||
savingThrow: SavingThrowSchema,
|
savingThrow: SavingThrowSchema,
|
||||||
skill: SkillSchema,
|
skill: SkillSchema,
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ function assertIdValid(userId){
|
|||||||
function assertdocExists(doc){
|
function assertdocExists(doc){
|
||||||
if (!doc){
|
if (!doc){
|
||||||
throw new Meteor.Error('Permission denied',
|
throw new Meteor.Error('Permission denied',
|
||||||
'No such document exists');
|
'Permission denied: No such document exists');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -67,6 +67,11 @@ const PROPERTIES = Object.freeze({
|
|||||||
icon: '$vuetify.icons.roll',
|
icon: '$vuetify.icons.roll',
|
||||||
name: 'Roll'
|
name: 'Roll'
|
||||||
},
|
},
|
||||||
|
reference: {
|
||||||
|
icon: 'link',
|
||||||
|
name: 'Reference',
|
||||||
|
libraryOnly: true,
|
||||||
|
},
|
||||||
savingThrow: {
|
savingThrow: {
|
||||||
icon: '$vuetify.icons.saving_throw',
|
icon: '$vuetify.icons.saving_throw',
|
||||||
name: 'Saving throw'
|
name: 'Saving throw'
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ export default class CallNode extends ParseNode {
|
|||||||
|
|
||||||
// Resolve the arguments
|
// Resolve the arguments
|
||||||
let resolvedArgs = this.args.map(node => node[fn](scope, context));
|
let resolvedArgs = this.args.map(node => node[fn](scope, context));
|
||||||
|
|
||||||
// Check that the arguments match what is expected
|
// Check that the arguments match what is expected
|
||||||
let checkFailed = this.checkArugments({
|
let checkFailed = this.checkArugments({
|
||||||
fn,
|
fn,
|
||||||
@@ -30,7 +29,7 @@ export default class CallNode extends ParseNode {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (checkFailed){
|
if (checkFailed){
|
||||||
if (fn !== 'reduce'){
|
if (fn === 'reduce'){
|
||||||
return new ErrorNode({
|
return new ErrorNode({
|
||||||
node: this,
|
node: this,
|
||||||
error: `Invalid arguments to ${this.functionName} function`,
|
error: `Invalid arguments to ${this.functionName} function`,
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
:flat="flat"
|
:flat="flat"
|
||||||
>
|
>
|
||||||
<v-btn
|
<v-btn
|
||||||
|
v-if="!embedded"
|
||||||
icon
|
icon
|
||||||
@click="back"
|
@click="back"
|
||||||
>
|
>
|
||||||
@@ -143,6 +144,7 @@ export default {
|
|||||||
},
|
},
|
||||||
flat: Boolean,
|
flat: Boolean,
|
||||||
editing: Boolean,
|
editing: Boolean,
|
||||||
|
embedded: Boolean,
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
isDark(){
|
isDark(){
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ export default {
|
|||||||
},
|
},
|
||||||
type: 'spell',
|
type: 'spell',
|
||||||
removed: {$ne: true},
|
removed: {$ne: true},
|
||||||
inactive: {$ne: true},
|
deactivatedByAncestor: {$ne: true},
|
||||||
}, {
|
}, {
|
||||||
sort: {
|
sort: {
|
||||||
level: 1,
|
level: 1,
|
||||||
|
|||||||
@@ -345,6 +345,7 @@
|
|||||||
filter['ancestors.id'] = creature._id;
|
filter['ancestors.id'] = creature._id;
|
||||||
filter.removed = {$ne: true};
|
filter.removed = {$ne: true};
|
||||||
filter.inactive = {$ne: true};
|
filter.inactive = {$ne: true};
|
||||||
|
filter.overridden = {$ne: true};
|
||||||
return CreatureProperties.find(filter, {
|
return CreatureProperties.find(filter, {
|
||||||
sort: {order: 1}
|
sort: {order: 1}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
<template lang="html">
|
<template lang="html">
|
||||||
<div class="breadcrumbs layout align-center wrap">
|
<div
|
||||||
|
class="breadcrumbs layout align-center wrap"
|
||||||
|
:class="{'no-icons': noIcons}"
|
||||||
|
>
|
||||||
<template v-for="(prop, index) in props">
|
<template v-for="(prop, index) in props">
|
||||||
<v-icon
|
<v-icon
|
||||||
v-if="index !== 0"
|
v-if="index !== 0"
|
||||||
@@ -7,12 +10,25 @@
|
|||||||
>
|
>
|
||||||
chevron_right
|
chevron_right
|
||||||
</v-icon>
|
</v-icon>
|
||||||
|
<span
|
||||||
|
v-if="noLinks"
|
||||||
|
:key="prop._id"
|
||||||
|
>
|
||||||
|
<tree-node-view
|
||||||
|
:model="prop"
|
||||||
|
class="breadcrumb-tree-node-view"
|
||||||
|
/>
|
||||||
|
</span>
|
||||||
<a
|
<a
|
||||||
|
v-else
|
||||||
:key="prop._id"
|
:key="prop._id"
|
||||||
:data-id="`breadcrumb-${prop._id}`"
|
:data-id="`breadcrumb-${prop._id}`"
|
||||||
@click="click(prop._id)"
|
@click="click(prop._id)"
|
||||||
>
|
>
|
||||||
<tree-node-view :model="prop" />
|
<tree-node-view
|
||||||
|
:model="prop"
|
||||||
|
class="breadcrumb-tree-node-view"
|
||||||
|
/>
|
||||||
</a>
|
</a>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
@@ -31,6 +47,8 @@
|
|||||||
type: Object,
|
type: Object,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
|
noLinks: Boolean,
|
||||||
|
noIcons: Boolean,
|
||||||
},
|
},
|
||||||
computed:{
|
computed:{
|
||||||
props(){
|
props(){
|
||||||
@@ -74,5 +92,14 @@
|
|||||||
.breadcrumbs {
|
.breadcrumbs {
|
||||||
margin-bottom: 16px;
|
margin-bottom: 16px;
|
||||||
opacity: 0.8;
|
opacity: 0.8;
|
||||||
|
}
|
||||||
|
.no-icons {
|
||||||
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style lang="css">
|
||||||
|
.no-icons .breadcrumb-tree-node-view .v-icon {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<template lang="html">
|
<template lang="html">
|
||||||
<selectable-property-dialog
|
<selectable-property-dialog
|
||||||
:value="forcedType || type"
|
:value="forcedType || type"
|
||||||
|
no-library-only-props
|
||||||
@input="e => type = e"
|
@input="e => type = e"
|
||||||
>
|
>
|
||||||
<creature-property-insert-form
|
<creature-property-insert-form
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
:model="model"
|
:model="model"
|
||||||
:editing="editing"
|
:editing="editing"
|
||||||
:flat="flat"
|
:flat="flat"
|
||||||
|
:embedded="embedded"
|
||||||
style="flex-grow: 0;"
|
style="flex-grow: 0;"
|
||||||
@duplicate="duplicate"
|
@duplicate="duplicate"
|
||||||
@remove="remove"
|
@remove="remove"
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import LibraryNodeCreationDialog from '/imports/ui/library/LibraryNodeCreationDi
|
|||||||
import LibraryNodeDialog from '/imports/ui/library/LibraryNodeDialog.vue';
|
import LibraryNodeDialog from '/imports/ui/library/LibraryNodeDialog.vue';
|
||||||
import MoveLibraryNodeDialog from '/imports/ui/library/MoveLibraryNodeDialog.vue'
|
import MoveLibraryNodeDialog from '/imports/ui/library/MoveLibraryNodeDialog.vue'
|
||||||
import SelectCreaturesDialog from '/imports/ui/tabletop/SelectCreaturesDialog.vue';
|
import SelectCreaturesDialog from '/imports/ui/tabletop/SelectCreaturesDialog.vue';
|
||||||
|
import SelectLibraryNodeDialog from '/imports/ui/library/SelectLibraryNodeDialog.vue';
|
||||||
import ShareDialog from '/imports/ui/sharing/ShareDialog.vue';
|
import ShareDialog from '/imports/ui/sharing/ShareDialog.vue';
|
||||||
import SlotDetailsDialog from '/imports/ui/creature/slots/SlotDetailsDialog.vue';
|
import SlotDetailsDialog from '/imports/ui/creature/slots/SlotDetailsDialog.vue';
|
||||||
import SlotFillDialog from '/imports/ui/creature/slots/SlotFillDialog.vue';
|
import SlotFillDialog from '/imports/ui/creature/slots/SlotFillDialog.vue';
|
||||||
@@ -37,7 +38,8 @@ export default {
|
|||||||
LibraryNodeDialog,
|
LibraryNodeDialog,
|
||||||
MoveLibraryNodeDialog,
|
MoveLibraryNodeDialog,
|
||||||
SelectCreaturesDialog,
|
SelectCreaturesDialog,
|
||||||
ShareDialog,
|
SelectLibraryNodeDialog,
|
||||||
|
ShareDialog,
|
||||||
SlotDetailsDialog,
|
SlotDetailsDialog,
|
||||||
SlotFillDialog,
|
SlotFillDialog,
|
||||||
TierTooLowDialog,
|
TierTooLowDialog,
|
||||||
|
|||||||
47
app/imports/ui/library/SelectLibraryNodeDialog.vue
Normal file
47
app/imports/ui/library/SelectLibraryNodeDialog.vue
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<template lang="html">
|
||||||
|
<dialog-base>
|
||||||
|
<v-toolbar-title slot="toolbar">
|
||||||
|
Select Library Property
|
||||||
|
</v-toolbar-title>
|
||||||
|
<library-and-node
|
||||||
|
slot="unwrapped-content"
|
||||||
|
style="height: 100%;"
|
||||||
|
selection
|
||||||
|
@selected="val => node = val"
|
||||||
|
/>
|
||||||
|
<template slot="actions">
|
||||||
|
<v-btn
|
||||||
|
text
|
||||||
|
color="primary"
|
||||||
|
@click="$store.dispatch('popDialogStack')"
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</v-btn>
|
||||||
|
<v-spacer />
|
||||||
|
<v-btn
|
||||||
|
text
|
||||||
|
color="primary"
|
||||||
|
@click="$store.dispatch('popDialogStack', node)"
|
||||||
|
>
|
||||||
|
Select
|
||||||
|
</v-btn>
|
||||||
|
</template>
|
||||||
|
</dialog-base>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="js">
|
||||||
|
import DialogBase from '/imports/ui/dialogStack/DialogBase.vue';
|
||||||
|
import LibraryAndNode from '/imports/ui/library/LibraryAndNode.vue';
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
DialogBase,
|
||||||
|
LibraryAndNode,
|
||||||
|
},
|
||||||
|
data(){return {
|
||||||
|
node: undefined,
|
||||||
|
};},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="css" scoped>
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,138 @@
|
|||||||
|
<template lang="html">
|
||||||
|
<v-list-item
|
||||||
|
class="effect-viewer layout align-center"
|
||||||
|
v-on="!hideBreadcrumbs ? {click} : {}"
|
||||||
|
>
|
||||||
|
<div class="effect-icon">
|
||||||
|
<v-tooltip bottom>
|
||||||
|
<template #activator="{ on }">
|
||||||
|
<v-icon
|
||||||
|
class="mx-2"
|
||||||
|
style="cursor: default;"
|
||||||
|
large
|
||||||
|
v-on="on"
|
||||||
|
>
|
||||||
|
{{ effectIcon }}
|
||||||
|
</v-icon>
|
||||||
|
</template>
|
||||||
|
<span>{{ operation }}</span>
|
||||||
|
</v-tooltip>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="text-h4 effect-value mr-2"
|
||||||
|
>
|
||||||
|
{{ displayedValue }}
|
||||||
|
</div>
|
||||||
|
<div class="layout column my-2">
|
||||||
|
<div class="text-body-1 mb-1">
|
||||||
|
{{ model.name || operation }}
|
||||||
|
</div>
|
||||||
|
<div v-if="!hideBreadcrumbs">
|
||||||
|
<breadcrumbs
|
||||||
|
:model="model"
|
||||||
|
class="text-caption"
|
||||||
|
no-links
|
||||||
|
no-icons
|
||||||
|
style="margin-bottom: 0"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</v-list-item>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="js">
|
||||||
|
import propertyViewerMixin from '/imports/ui/properties/viewers/shared/propertyViewerMixin.js';
|
||||||
|
import getEffectIcon from '/imports/ui/utility/getEffectIcon.js';
|
||||||
|
import Breadcrumbs from '/imports/ui/creature/creatureProperties/Breadcrumbs.vue';
|
||||||
|
import { isFinite } from 'lodash';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
Breadcrumbs,
|
||||||
|
},
|
||||||
|
mixins: [propertyViewerMixin],
|
||||||
|
props: {
|
||||||
|
hideBreadcrumbs: Boolean
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
hasClickListener(){
|
||||||
|
return this.$listeners && this.$listeners.click
|
||||||
|
},
|
||||||
|
resolvedValue(){
|
||||||
|
return this.model.result !== undefined ? this.model.result : this.model.calculation;
|
||||||
|
},
|
||||||
|
effectIcon(){
|
||||||
|
let value = this.resolvedValue;
|
||||||
|
return getEffectIcon(this.model.operation, value);
|
||||||
|
},
|
||||||
|
operation(){
|
||||||
|
switch(this.model.operation) {
|
||||||
|
case 'base': return 'Base value';
|
||||||
|
case 'add': return 'Add';
|
||||||
|
case 'mul': return 'Multiply';
|
||||||
|
case 'min': return 'Minimum';
|
||||||
|
case 'max': return 'Maximum';
|
||||||
|
case 'advantage': return 'Advantage';
|
||||||
|
case 'disadvantage': return 'Disadvantage';
|
||||||
|
case 'passiveAdd': return 'Passive bonus';
|
||||||
|
case 'fail': return 'Always fail';
|
||||||
|
case 'conditional': return 'Conditional benefit' ;
|
||||||
|
default: return '';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
showValue(){
|
||||||
|
switch(this.model.operation) {
|
||||||
|
case 'base': return true;
|
||||||
|
case 'add': return true;
|
||||||
|
case 'mul': return true;
|
||||||
|
case 'min': return true;
|
||||||
|
case 'max': return true;
|
||||||
|
case 'advantage': return false;
|
||||||
|
case 'disadvantage': return false;
|
||||||
|
case 'passiveAdd': return true;
|
||||||
|
case 'fail': return false;
|
||||||
|
case 'conditional': return false;
|
||||||
|
default: return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
displayedValue(){
|
||||||
|
let value = this.resolvedValue;
|
||||||
|
switch(this.model.operation) {
|
||||||
|
case 'base': return value;
|
||||||
|
case 'add': return isFinite(value) ? Math.abs(value) : value;
|
||||||
|
case 'mul': return value;
|
||||||
|
case 'min': return value;
|
||||||
|
case 'max': return value;
|
||||||
|
case 'advantage': return;
|
||||||
|
case 'disadvantage': return;
|
||||||
|
case 'passiveAdd': return isFinite(value) ? Math.abs(value) : value;
|
||||||
|
case 'fail': return;
|
||||||
|
case 'conditional': return;
|
||||||
|
default: return undefined;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
click(e){
|
||||||
|
this.$emit('click', e);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="css" scoped>
|
||||||
|
.icon, .effect-icon {
|
||||||
|
min-width: 30px;
|
||||||
|
}
|
||||||
|
.icon {
|
||||||
|
color: inherit !important;
|
||||||
|
}
|
||||||
|
.net-effect {
|
||||||
|
flex-grow: 0;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
.effect-value {
|
||||||
|
min-width: 60px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -41,6 +41,7 @@
|
|||||||
attributeType: 'healthBar',
|
attributeType: 'healthBar',
|
||||||
removed: {$ne: true},
|
removed: {$ne: true},
|
||||||
inactive: {$ne: true},
|
inactive: {$ne: true},
|
||||||
|
overridden: {$ne: true},
|
||||||
};
|
};
|
||||||
if (creature.settings.hideUnusedStats){
|
if (creature.settings.hideUnusedStats){
|
||||||
filter.hide = {$ne: true};
|
filter.hide = {$ne: true};
|
||||||
|
|||||||
@@ -52,7 +52,9 @@ export default {
|
|||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
icon(){
|
icon(){
|
||||||
if (this.model.proficiency == 0.5){
|
if (this.model.proficiency == 0.49){
|
||||||
|
return 'brightness_3';
|
||||||
|
} else if (this.model.proficiency == 0.5){
|
||||||
return 'brightness_2';
|
return 'brightness_2';
|
||||||
} else if (this.model.proficiency == 1) {
|
} else if (this.model.proficiency == 1) {
|
||||||
return 'brightness_1'
|
return 'brightness_1'
|
||||||
|
|||||||
114
app/imports/ui/properties/components/skills/SkillProficiency.vue
Normal file
114
app/imports/ui/properties/components/skills/SkillProficiency.vue
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
<template lang="html">
|
||||||
|
<v-list-item
|
||||||
|
class="proficiency-viewer layout align-center"
|
||||||
|
v-on="!hideBreadcrumbs ? {click} : {}"
|
||||||
|
>
|
||||||
|
<div class="effect-icon">
|
||||||
|
<v-tooltip bottom>
|
||||||
|
<template #activator="{ on }">
|
||||||
|
<v-icon
|
||||||
|
class="mx-2"
|
||||||
|
style="cursor: default;"
|
||||||
|
large
|
||||||
|
v-on="on"
|
||||||
|
>
|
||||||
|
{{ icon }}
|
||||||
|
</v-icon>
|
||||||
|
</template>
|
||||||
|
<span>{{ proficiencyText }}</span>
|
||||||
|
</v-tooltip>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="text-h4 effect-value mr-2"
|
||||||
|
>
|
||||||
|
{{ proficiencyValue }}
|
||||||
|
</div>
|
||||||
|
<div class="layout column my-2">
|
||||||
|
<div class="text-body-1 mb-1">
|
||||||
|
{{ model.name || proficiencyText }}
|
||||||
|
</div>
|
||||||
|
<div v-if="!hideBreadcrumbs">
|
||||||
|
<breadcrumbs
|
||||||
|
:model="model"
|
||||||
|
class="text-caption"
|
||||||
|
no-links
|
||||||
|
no-icons
|
||||||
|
style="margin-bottom: 0"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</v-list-item>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="js">
|
||||||
|
import propertyViewerMixin from '/imports/ui/properties/viewers/shared/propertyViewerMixin.js';
|
||||||
|
import Breadcrumbs from '/imports/ui/creature/creatureProperties/Breadcrumbs.vue';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
Breadcrumbs,
|
||||||
|
},
|
||||||
|
mixins: [propertyViewerMixin],
|
||||||
|
props: {
|
||||||
|
hideBreadcrumbs: Boolean,
|
||||||
|
proficiencyBonus: {
|
||||||
|
type: Number,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
icon(){
|
||||||
|
if (this.model.value == 0.49){
|
||||||
|
return 'brightness_3';
|
||||||
|
} else if (this.model.value == 0.5) {
|
||||||
|
return 'brightness_2'
|
||||||
|
} else if (this.model.value == 1) {
|
||||||
|
return 'brightness_1'
|
||||||
|
} else if (this.model.value == 2){
|
||||||
|
return 'album'
|
||||||
|
} else {
|
||||||
|
return 'radio_button_unchecked';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
proficiencyText(){
|
||||||
|
switch (this.model.value){
|
||||||
|
case 0.49: return 'Half proficiency bonus rounded down';
|
||||||
|
case 0.5: return 'Half proficiency bonus rounded up';
|
||||||
|
case 1: return 'Proficient';
|
||||||
|
case 2: return 'Double proficiency bonus';
|
||||||
|
default: return '';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
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: 30px;
|
||||||
|
}
|
||||||
|
.icon {
|
||||||
|
color: inherit !important;
|
||||||
|
}
|
||||||
|
.net-effect {
|
||||||
|
flex-grow: 0;
|
||||||
|
flex-shrink: 0;
|
||||||
|
}
|
||||||
|
.effect-value {
|
||||||
|
min-width: 60px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
69
app/imports/ui/properties/forms/ReferenceForm.vue
Normal file
69
app/imports/ui/properties/forms/ReferenceForm.vue
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
<template lang="html">
|
||||||
|
<div class="folder-form layout justify-start wrap">
|
||||||
|
<v-text-field
|
||||||
|
label="Linked Property"
|
||||||
|
style="flex-basis: 300px;"
|
||||||
|
readonly
|
||||||
|
outlined
|
||||||
|
persistent-hint
|
||||||
|
:loading="linkLoading"
|
||||||
|
:value="
|
||||||
|
model.cache.node && model.cache.node.name ||
|
||||||
|
model.ref && model.ref.id
|
||||||
|
"
|
||||||
|
:hint="model.cache.library && model.cache.library.name"
|
||||||
|
:error-messages="model.cache.error || errors.ref"
|
||||||
|
prepend-inner-icon="link"
|
||||||
|
append-icon="refresh"
|
||||||
|
data-id="change-ref"
|
||||||
|
@click="changeReference"
|
||||||
|
@click:prepend-inner="changeReference"
|
||||||
|
@click:append="updateReferenceNode"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="js">
|
||||||
|
import propertyFormMixin from '/imports/ui/properties/forms/shared/propertyFormMixin.js';
|
||||||
|
import updateReferenceNode from '/imports/api/library/methods/updateReferenceNode.js';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
mixins: [propertyFormMixin],
|
||||||
|
data(){return {
|
||||||
|
linkLoading: false,
|
||||||
|
}},
|
||||||
|
methods: {
|
||||||
|
changeReference(){
|
||||||
|
let that = this;
|
||||||
|
this.$store.commit('pushDialogStack', {
|
||||||
|
component: 'select-library-node-dialog',
|
||||||
|
elementId: 'change-ref',
|
||||||
|
callback(node){
|
||||||
|
if (!node) return;
|
||||||
|
that.linkLoading = true;
|
||||||
|
that.$emit('change', {
|
||||||
|
path: ['ref'],
|
||||||
|
value: {
|
||||||
|
id: node._id,
|
||||||
|
collection: 'libraryNodes',
|
||||||
|
},
|
||||||
|
ack(){
|
||||||
|
that.linkLoading = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
updateReferenceNode(){
|
||||||
|
if (!this.model._id) return;
|
||||||
|
this.linkLoading = true;
|
||||||
|
updateReferenceNode.call({_id: this.model._id}, () => {
|
||||||
|
this.linkLoading = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="css" scoped>
|
||||||
|
</style>
|
||||||
@@ -22,7 +22,9 @@
|
|||||||
<script lang="js">
|
<script lang="js">
|
||||||
const ICON_SPIN_DURATION = 300;
|
const ICON_SPIN_DURATION = 300;
|
||||||
let proficiencyIcon = function(value){
|
let proficiencyIcon = function(value){
|
||||||
if (value == 0.5){
|
if (value == 0.49){
|
||||||
|
return 'brightness_3';
|
||||||
|
} else if (value == 0.5){
|
||||||
return 'brightness_2';
|
return 'brightness_2';
|
||||||
} else if (value == 1) {
|
} else if (value == 1) {
|
||||||
return 'brightness_1'
|
return 'brightness_1'
|
||||||
@@ -49,7 +51,8 @@
|
|||||||
iconClass: '',
|
iconClass: '',
|
||||||
values: [
|
values: [
|
||||||
{value: 1, text: 'Proficient'},
|
{value: 1, text: 'Proficient'},
|
||||||
{value: 0.5, text: 'Half proficiency bonus'},
|
{value: 0.49, text: 'Half proficiency bonus rounded down'},
|
||||||
|
{value: 0.5, text: 'Half proficiency bonus rounded up'},
|
||||||
{value: 2, text: 'Double proficiency bonus'},
|
{value: 2, text: 'Double proficiency bonus'},
|
||||||
],
|
],
|
||||||
}},
|
}},
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import FolderForm from '/imports/ui/properties/forms/FolderForm.vue';
|
|||||||
import ItemForm from '/imports/ui/properties/forms/ItemForm.vue';
|
import ItemForm from '/imports/ui/properties/forms/ItemForm.vue';
|
||||||
import NoteForm from '/imports/ui/properties/forms/NoteForm.vue';
|
import NoteForm from '/imports/ui/properties/forms/NoteForm.vue';
|
||||||
import ProficiencyForm from '/imports/ui/properties/forms/ProficiencyForm.vue';
|
import ProficiencyForm from '/imports/ui/properties/forms/ProficiencyForm.vue';
|
||||||
|
import ReferenceForm from '/imports/ui/properties/forms/ReferenceForm.vue';
|
||||||
import RollForm from '/imports/ui/properties/forms/RollForm.vue';
|
import RollForm from '/imports/ui/properties/forms/RollForm.vue';
|
||||||
import SavingThrowForm from '/imports/ui/properties/forms/SavingThrowForm.vue';
|
import SavingThrowForm from '/imports/ui/properties/forms/SavingThrowForm.vue';
|
||||||
import SkillForm from '/imports/ui/properties/forms/SkillForm.vue';
|
import SkillForm from '/imports/ui/properties/forms/SkillForm.vue';
|
||||||
@@ -41,6 +42,7 @@ export default {
|
|||||||
note: NoteForm,
|
note: NoteForm,
|
||||||
proficiency: ProficiencyForm,
|
proficiency: ProficiencyForm,
|
||||||
propertySlot: SlotForm,
|
propertySlot: SlotForm,
|
||||||
|
reference: ReferenceForm,
|
||||||
roll: RollForm,
|
roll: RollForm,
|
||||||
savingThrow: SavingThrowForm,
|
savingThrow: SavingThrowForm,
|
||||||
skill: SkillForm,
|
skill: SkillForm,
|
||||||
|
|||||||
@@ -9,33 +9,35 @@
|
|||||||
wrap
|
wrap
|
||||||
fill-height
|
fill-height
|
||||||
>
|
>
|
||||||
<v-flex
|
<template v-for="(property, type) in PROPERTIES">
|
||||||
v-for="(property, type) in PROPERTIES"
|
<v-flex
|
||||||
:key="type"
|
v-if="!noLibraryOnlyProps || !property.libraryOnly"
|
||||||
sm4
|
:key="type"
|
||||||
xs6
|
sm4
|
||||||
>
|
xs6
|
||||||
<v-card
|
|
||||||
hover
|
|
||||||
style="height: 100%; overflow: hidden;"
|
|
||||||
@click="$emit('select', type)"
|
|
||||||
>
|
>
|
||||||
<div
|
<v-card
|
||||||
class="layout align-center justify-center"
|
hover
|
||||||
style="min-height: 70px;"
|
style="height: 100%; overflow: hidden;"
|
||||||
|
@click="$emit('select', type)"
|
||||||
>
|
>
|
||||||
<v-icon x-large>
|
<div
|
||||||
{{ property.icon }}
|
class="layout align-center justify-center"
|
||||||
</v-icon>
|
style="min-height: 70px;"
|
||||||
</div>
|
>
|
||||||
<h3
|
<v-icon x-large>
|
||||||
class="subtitle pb-3"
|
{{ property.icon }}
|
||||||
style="text-align: center;"
|
</v-icon>
|
||||||
>
|
</div>
|
||||||
{{ property.name }}
|
<h3
|
||||||
</h3>
|
class="subtitle pb-3"
|
||||||
</v-card>
|
style="text-align: center;"
|
||||||
</v-flex>
|
>
|
||||||
|
{{ property.name }}
|
||||||
|
</h3>
|
||||||
|
</v-card>
|
||||||
|
</v-flex>
|
||||||
|
</template>
|
||||||
</v-layout>
|
</v-layout>
|
||||||
</v-container>
|
</v-container>
|
||||||
</div>
|
</div>
|
||||||
@@ -43,8 +45,12 @@
|
|||||||
|
|
||||||
<script lang="js">
|
<script lang="js">
|
||||||
import PROPERTIES from '/imports/constants/PROPERTIES.js';
|
import PROPERTIES from '/imports/constants/PROPERTIES.js';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data(){return {
|
props: {
|
||||||
|
noLibraryOnlyProps: Boolean,
|
||||||
|
},
|
||||||
|
data(){ return {
|
||||||
PROPERTIES,
|
PROPERTIES,
|
||||||
};},
|
};},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
</v-toolbar-title>
|
</v-toolbar-title>
|
||||||
<property-selector
|
<property-selector
|
||||||
slot="unwrapped-content"
|
slot="unwrapped-content"
|
||||||
|
:no-library-only-props="noLibraryOnlyProps"
|
||||||
@select="type => $emit('input', type)"
|
@select="type => $emit('input', type)"
|
||||||
/>
|
/>
|
||||||
</dialog-base>
|
</dialog-base>
|
||||||
@@ -34,6 +35,7 @@ export default {
|
|||||||
PropertySelector,
|
PropertySelector,
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
|
noLibraryOnlyProps: Boolean,
|
||||||
value: {
|
value: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -0,0 +1,22 @@
|
|||||||
|
<template lang="html">
|
||||||
|
<div class="layout align-center justify-start">
|
||||||
|
<property-icon
|
||||||
|
v-if="!hideIcon"
|
||||||
|
class="mr-2"
|
||||||
|
:model="model"
|
||||||
|
:color="model.color"
|
||||||
|
:class="selected && 'primary--text'"
|
||||||
|
/>
|
||||||
|
<div class="text-no-wrap text-truncate">
|
||||||
|
{{ model.cache.node && model.cache.node.name || title }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="js">
|
||||||
|
import treeNodeViewMixin from '/imports/ui/properties/treeNodeViews/treeNodeViewMixin.js';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
mixins: [treeNodeViewMixin],
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -4,6 +4,7 @@ import ItemTreeNode from '/imports/ui/properties/treeNodeViews/ItemTreeNode.vue'
|
|||||||
import DamageTreeNode from '/imports/ui/properties/treeNodeViews/DamageTreeNode.vue';
|
import DamageTreeNode from '/imports/ui/properties/treeNodeViews/DamageTreeNode.vue';
|
||||||
import EffectTreeNode from '/imports/ui/properties/treeNodeViews/EffectTreeNode.vue';
|
import EffectTreeNode from '/imports/ui/properties/treeNodeViews/EffectTreeNode.vue';
|
||||||
import ClassLevelTreeNode from '/imports/ui/properties/treeNodeViews/ClassLevelTreeNode.vue';
|
import ClassLevelTreeNode from '/imports/ui/properties/treeNodeViews/ClassLevelTreeNode.vue';
|
||||||
|
import ReferenceTreeNode from '/imports/ui/properties/treeNodeViews/ReferenceTreeNode.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
default: DefaultTreeNode,
|
default: DefaultTreeNode,
|
||||||
@@ -12,4 +13,5 @@ export default {
|
|||||||
damage: DamageTreeNode,
|
damage: DamageTreeNode,
|
||||||
effect: EffectTreeNode,
|
effect: EffectTreeNode,
|
||||||
item: ItemTreeNode,
|
item: ItemTreeNode,
|
||||||
|
reference: ReferenceTreeNode,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,27 +43,30 @@
|
|||||||
:calculations="model.descriptionCalculations"
|
:calculations="model.descriptionCalculations"
|
||||||
:inactive="model.inactive"
|
:inactive="model.inactive"
|
||||||
/>
|
/>
|
||||||
|
<v-list>
|
||||||
<effect-viewer
|
<attribute-effect
|
||||||
v-if="context.creatureId && model.baseValueCalculation"
|
v-for="effect in baseEffects"
|
||||||
:model="{
|
:key="effect._id"
|
||||||
name: 'Base value',
|
:model="effect"
|
||||||
result: model.baseValue,
|
:hide-breadcrumbs="effect._id === model._id"
|
||||||
operation: 'base'
|
:data-id="effect._id"
|
||||||
}"
|
@click="effect._id !== model._id && clickEffect(effect._id)"
|
||||||
/>
|
/>
|
||||||
<effect-viewer
|
<attribute-effect
|
||||||
v-for="effect in effects"
|
v-for="effect in effects"
|
||||||
:key="effect._id"
|
:key="effect._id"
|
||||||
:model="effect"
|
:model="effect"
|
||||||
/>
|
:data-id="effect._id"
|
||||||
|
@click="clickEffect(effect._id)"
|
||||||
|
/>
|
||||||
|
</v-list>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="js">
|
<script lang="js">
|
||||||
import propertyViewerMixin from '/imports/ui/properties/viewers/shared/propertyViewerMixin.js'
|
import propertyViewerMixin from '/imports/ui/properties/viewers/shared/propertyViewerMixin.js'
|
||||||
import numberToSignedString from '/imports/ui/utility/numberToSignedString.js';
|
import numberToSignedString from '/imports/ui/utility/numberToSignedString.js';
|
||||||
import EffectViewer from '/imports/ui/properties/viewers/EffectViewer.vue';
|
import AttributeEffect from '/imports/ui/properties/components/attributes/AttributeEffect.vue';
|
||||||
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
|
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
@@ -71,7 +74,7 @@
|
|||||||
context: { default: {} }
|
context: { default: {} }
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
EffectViewer,
|
AttributeEffect,
|
||||||
},
|
},
|
||||||
mixins: [propertyViewerMixin],
|
mixins: [propertyViewerMixin],
|
||||||
computed: {
|
computed: {
|
||||||
@@ -87,8 +90,37 @@
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
numberToSignedString,
|
numberToSignedString,
|
||||||
|
clickEffect(id){
|
||||||
|
this.$store.commit('pushDialogStack', {
|
||||||
|
component: 'creature-property-dialog',
|
||||||
|
elementId: `${id}`,
|
||||||
|
data: {_id: id},
|
||||||
|
});
|
||||||
|
},
|
||||||
},
|
},
|
||||||
meteor: {
|
meteor: {
|
||||||
|
baseEffects(){
|
||||||
|
if (this.context.creatureId){
|
||||||
|
let creatureId = this.context.creatureId;
|
||||||
|
return CreatureProperties.find({
|
||||||
|
'ancestors.id': creatureId,
|
||||||
|
type: 'attribute',
|
||||||
|
variableName: this.model.variableName,
|
||||||
|
removed: {$ne: true},
|
||||||
|
inactive: {$ne: true},
|
||||||
|
}).map( prop => ({
|
||||||
|
_id: prop._id,
|
||||||
|
name: 'Attribute base value',
|
||||||
|
operation: 'base',
|
||||||
|
calculation: prop.baseValueCalculation,
|
||||||
|
result: prop.baseValue,
|
||||||
|
stats: [prop.variableName],
|
||||||
|
ancestors: prop.ancestors,
|
||||||
|
}) ).filter(effect => effect.result);
|
||||||
|
} else {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
},
|
||||||
effects(){
|
effects(){
|
||||||
if (this.context.creatureId){
|
if (this.context.creatureId){
|
||||||
let creatureId = this.context.creatureId;
|
let creatureId = this.context.creatureId;
|
||||||
|
|||||||
@@ -17,19 +17,19 @@
|
|||||||
import propertyViewerMixin from '/imports/ui/properties/viewers/shared/propertyViewerMixin.js';
|
import propertyViewerMixin from '/imports/ui/properties/viewers/shared/propertyViewerMixin.js';
|
||||||
import ProficiencyIcon from '/imports/ui/properties/shared/ProficiencyIcon.vue';
|
import ProficiencyIcon from '/imports/ui/properties/shared/ProficiencyIcon.vue';
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
ProficiencyIcon,
|
ProficiencyIcon,
|
||||||
},
|
},
|
||||||
mixins: [propertyViewerMixin],
|
mixins: [propertyViewerMixin],
|
||||||
computed: {
|
computed: {
|
||||||
proficiencyText(){
|
proficiencyText(){
|
||||||
switch (this.model.value){
|
switch (this.model.value){
|
||||||
case 0.5: return 'Half proficiency bonus';
|
case 0.5: return 'Half proficiency bonus';
|
||||||
case 1: return 'Proficient';
|
case 1: return 'Proficient';
|
||||||
case 2: return 'Double proficiency bonus';
|
case 2: return 'Double proficiency bonus';
|
||||||
default: return '';
|
default: return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
30
app/imports/ui/properties/viewers/ReferenceViewer.vue
Normal file
30
app/imports/ui/properties/viewers/ReferenceViewer.vue
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<template lang="html">
|
||||||
|
<div class="reference-viewer">
|
||||||
|
<property-field
|
||||||
|
v-if="model.cache.error"
|
||||||
|
name="Error"
|
||||||
|
:value="model.cache.error"
|
||||||
|
/>
|
||||||
|
<property-field
|
||||||
|
v-else-if="model.ref && model.ref.id"
|
||||||
|
name="Linked Property"
|
||||||
|
:value="model.cache.node && model.cache.node.name || model.ref.id"
|
||||||
|
/>
|
||||||
|
<property-field
|
||||||
|
v-if="model.cache.library && model.cache.library.name"
|
||||||
|
name="Library"
|
||||||
|
:value="model.cache.library.name"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script lang="js">
|
||||||
|
import propertyViewerMixin from '/imports/ui/properties/viewers/shared/propertyViewerMixin.js'
|
||||||
|
|
||||||
|
export default {
|
||||||
|
mixins: [propertyViewerMixin],
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="css" scoped>
|
||||||
|
</style>
|
||||||
@@ -40,18 +40,44 @@
|
|||||||
:inactive="model.inactive"
|
:inactive="model.inactive"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<effect-viewer
|
<attribute-effect
|
||||||
v-if="context.creatureId && model.baseValue"
|
v-for="effect in baseEffects"
|
||||||
:model="{
|
:key="effect._id"
|
||||||
name: 'Base value',
|
:model="effect"
|
||||||
result: model.baseValue,
|
:hide-breadcrumbs="effect._id === model._id"
|
||||||
operation: 'base'
|
:data-id="effect._id"
|
||||||
}"
|
@click="effect._id !== model._id && clickEffect(effect._id)"
|
||||||
/>
|
/>
|
||||||
<effect-viewer
|
<attribute-effect
|
||||||
|
v-if="ability"
|
||||||
|
:key="ability._id"
|
||||||
|
:model="ability"
|
||||||
|
:data-id="ability._id"
|
||||||
|
@click="clickEffect(ability._id)"
|
||||||
|
/>
|
||||||
|
<attribute-effect
|
||||||
v-for="effect in effects"
|
v-for="effect in effects"
|
||||||
:key="effect._id"
|
:key="effect._id"
|
||||||
:model="effect"
|
:model="effect"
|
||||||
|
:data-id="effect._id"
|
||||||
|
@click="clickEffect(effect._id)"
|
||||||
|
/>
|
||||||
|
<skill-proficiency
|
||||||
|
v-for="proficiency in baseProficiencies"
|
||||||
|
:key="proficiency._id"
|
||||||
|
:model="proficiency"
|
||||||
|
:proficiency-bonus="proficiencyBonus"
|
||||||
|
:hide-breadcrumbs="proficiency._id === model._id"
|
||||||
|
:data-id="proficiency._id"
|
||||||
|
@click="clickEffect(proficiency._id)"
|
||||||
|
/>
|
||||||
|
<skill-proficiency
|
||||||
|
v-for="proficiency in proficiencies"
|
||||||
|
:key="proficiency._id"
|
||||||
|
:model="proficiency"
|
||||||
|
:proficiency-bonus="proficiencyBonus"
|
||||||
|
:data-id="proficiency._id"
|
||||||
|
@click="clickEffect(proficiency._id)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -60,11 +86,14 @@
|
|||||||
import propertyViewerMixin from '/imports/ui/properties/viewers/shared/propertyViewerMixin.js';
|
import propertyViewerMixin from '/imports/ui/properties/viewers/shared/propertyViewerMixin.js';
|
||||||
import numberToSignedString from '/imports/ui/utility/numberToSignedString.js';
|
import numberToSignedString from '/imports/ui/utility/numberToSignedString.js';
|
||||||
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
|
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
|
||||||
import EffectViewer from '/imports/ui/properties/viewers/EffectViewer.vue';
|
import AttributeEffect from '/imports/ui/properties/components/attributes/AttributeEffect.vue';
|
||||||
|
import SkillProficiency from '/imports/ui/properties/components/skills/SkillProficiency.vue';
|
||||||
|
import Creatures from '/imports/api/creature/Creatures.js';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
EffectViewer,
|
AttributeEffect,
|
||||||
|
SkillProficiency,
|
||||||
},
|
},
|
||||||
mixins: [propertyViewerMixin],
|
mixins: [propertyViewerMixin],
|
||||||
inject: {
|
inject: {
|
||||||
@@ -80,7 +109,9 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
icon(){
|
icon(){
|
||||||
if (this.model.proficiency == 0.5){
|
if (this.model.proficiency == 0.49){
|
||||||
|
return 'brightness_3';
|
||||||
|
} else if (this.model.proficiency == 0.5){
|
||||||
return 'brightness_2';
|
return 'brightness_2';
|
||||||
} else if (this.model.proficiency == 1) {
|
} else if (this.model.proficiency == 1) {
|
||||||
return 'brightness_1'
|
return 'brightness_1'
|
||||||
@@ -94,8 +125,37 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
numberToSignedString,
|
numberToSignedString,
|
||||||
isFinite: Number.isFinite,
|
isFinite: Number.isFinite,
|
||||||
|
clickEffect(id){
|
||||||
|
this.$store.commit('pushDialogStack', {
|
||||||
|
component: 'creature-property-dialog',
|
||||||
|
elementId: `${id}`,
|
||||||
|
data: {_id: id},
|
||||||
|
});
|
||||||
|
},
|
||||||
},
|
},
|
||||||
meteor: {
|
meteor: {
|
||||||
|
baseEffects(){
|
||||||
|
if (this.context.creatureId){
|
||||||
|
let creatureId = this.context.creatureId;
|
||||||
|
return CreatureProperties.find({
|
||||||
|
'ancestors.id': creatureId,
|
||||||
|
type: 'attribute',
|
||||||
|
variableName: this.model.variableName,
|
||||||
|
removed: {$ne: true},
|
||||||
|
inactive: {$ne: true},
|
||||||
|
}).map( prop => ({
|
||||||
|
_id: prop._id,
|
||||||
|
name: 'Skill base value',
|
||||||
|
operation: 'base',
|
||||||
|
calculation: prop.baseValueCalculation,
|
||||||
|
result: prop.baseValue,
|
||||||
|
stats: [prop.variableName],
|
||||||
|
ancestors: prop.ancestors,
|
||||||
|
}) ).filter(effect => effect.result);
|
||||||
|
} else {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
},
|
||||||
effects(){
|
effects(){
|
||||||
if (this.context.creatureId){
|
if (this.context.creatureId){
|
||||||
let creatureId = this.context.creatureId;
|
let creatureId = this.context.creatureId;
|
||||||
@@ -109,6 +169,70 @@ export default {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
baseProficiencies(){
|
||||||
|
if (this.context.creatureId){
|
||||||
|
let creatureId = this.context.creatureId;
|
||||||
|
return CreatureProperties.find({
|
||||||
|
'ancestors.id': creatureId,
|
||||||
|
type: 'skill',
|
||||||
|
variableName: this.model.variableName,
|
||||||
|
removed: {$ne: true},
|
||||||
|
inactive: {$ne: true},
|
||||||
|
}).map( prop => ({
|
||||||
|
_id: prop._id,
|
||||||
|
name: 'Skill base proficiency',
|
||||||
|
value: prop.baseProficiency,
|
||||||
|
stats: [prop.variableName],
|
||||||
|
ancestors: prop.ancestors,
|
||||||
|
}) ).filter(prof => prof.value);
|
||||||
|
} else {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
proficiencies(){
|
||||||
|
let creatureId = this.context.creatureId;
|
||||||
|
if (creatureId){
|
||||||
|
return CreatureProperties.find({
|
||||||
|
'ancestors.id': creatureId,
|
||||||
|
stats: this.model.variableName,
|
||||||
|
type: 'proficiency',
|
||||||
|
removed: {$ne: true},
|
||||||
|
inactive: {$ne: true},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
},
|
||||||
|
ability(){
|
||||||
|
let creatureId = this.context.creatureId;
|
||||||
|
let ability = this.model.ability;
|
||||||
|
if (!creatureId || !ability) return;
|
||||||
|
let abilityProp = CreatureProperties.findOne({
|
||||||
|
'ancestors.id': creatureId,
|
||||||
|
variableName: ability,
|
||||||
|
type: 'attribute',
|
||||||
|
removed: {$ne: true},
|
||||||
|
inactive: {$ne: true},
|
||||||
|
overridden: {$ne: true},
|
||||||
|
});
|
||||||
|
if (!abilityProp) return;
|
||||||
|
return {
|
||||||
|
_id: abilityProp._id,
|
||||||
|
name: abilityProp.name,
|
||||||
|
operation: 'base',
|
||||||
|
result: abilityProp.modifier,
|
||||||
|
stats: [this.model.variableName],
|
||||||
|
ancestors: abilityProp.ancestors,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
proficiencyBonus(){
|
||||||
|
let creatureId = this.context.creatureId;
|
||||||
|
if (!creatureId) return;
|
||||||
|
let creature = Creatures.findOne(creatureId)
|
||||||
|
return creature &&
|
||||||
|
creature.variables.proficiencyBonus &&
|
||||||
|
creature.variables.proficiencyBonus.currentValue;
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import FolderViewer from '/imports/ui/properties/viewers/FolderViewer.vue';
|
|||||||
import ItemViewer from '/imports/ui/properties/viewers/ItemViewer.vue';
|
import ItemViewer from '/imports/ui/properties/viewers/ItemViewer.vue';
|
||||||
import NoteViewer from '/imports/ui/properties/viewers/NoteViewer.vue';
|
import NoteViewer from '/imports/ui/properties/viewers/NoteViewer.vue';
|
||||||
import ProficiencyViewer from '/imports/ui/properties/viewers/ProficiencyViewer.vue';
|
import ProficiencyViewer from '/imports/ui/properties/viewers/ProficiencyViewer.vue';
|
||||||
|
import ReferenceViewer from '/imports/ui/properties/viewers/ReferenceViewer.vue';
|
||||||
import RollViewer from '/imports/ui/properties/viewers/RollViewer.vue';
|
import RollViewer from '/imports/ui/properties/viewers/RollViewer.vue';
|
||||||
import SkillViewer from '/imports/ui/properties/viewers/SkillViewer.vue';
|
import SkillViewer from '/imports/ui/properties/viewers/SkillViewer.vue';
|
||||||
import SavingThrowViewer from '/imports/ui/properties/viewers/SavingThrowViewer.vue';
|
import SavingThrowViewer from '/imports/ui/properties/viewers/SavingThrowViewer.vue';
|
||||||
@@ -42,6 +43,7 @@ export default {
|
|||||||
proficiency: ProficiencyViewer,
|
proficiency: ProficiencyViewer,
|
||||||
propertySlot: SlotViewer,
|
propertySlot: SlotViewer,
|
||||||
roll: RollViewer,
|
roll: RollViewer,
|
||||||
|
reference: ReferenceViewer,
|
||||||
savingThrow: SavingThrowViewer,
|
savingThrow: SavingThrowViewer,
|
||||||
slotFiller: SlotFillerViewer,
|
slotFiller: SlotFillerViewer,
|
||||||
skill: SkillViewer,
|
skill: SkillViewer,
|
||||||
|
|||||||
Reference in New Issue
Block a user