Compare commits
27 Commits
2.0-beta.2
...
2.0-beta.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a9eacfab03 | ||
|
|
1f633621b7 | ||
|
|
9f3c8bef34 | ||
|
|
8a83e7d8a1 | ||
|
|
a28182f3e9 | ||
|
|
3d122e062f | ||
|
|
e9a273244a | ||
|
|
1de3122254 | ||
|
|
298db01e5b | ||
|
|
727101cd63 | ||
|
|
d4d002cf31 | ||
|
|
2150bd6da4 | ||
|
|
e1df145675 | ||
|
|
1eb78756ac | ||
|
|
ce9b9199ec | ||
|
|
cfb1414494 | ||
|
|
4abd689c9f | ||
|
|
f0e443fba2 | ||
|
|
52e7deedc6 | ||
|
|
15d593db79 | ||
|
|
e30754ef26 | ||
|
|
255ac529b3 | ||
|
|
c8b5ada5b9 | ||
|
|
0c24238069 | ||
|
|
66847430ad | ||
|
|
bfb860605f | ||
|
|
d87524418a |
@@ -16,7 +16,7 @@ meteorhacks:subs-manager
|
||||
chuangbo:marked
|
||||
meteor-base@1.4.0
|
||||
mobile-experience@1.1.0
|
||||
mongo@1.10.1
|
||||
mongo@1.11.0
|
||||
session@1.2.0
|
||||
tracker@1.2.0
|
||||
logging@1.2.0
|
||||
@@ -26,7 +26,7 @@ check@1.3.1
|
||||
standard-minifier-js@2.6.0
|
||||
shell-server@0.5.0
|
||||
templates:array
|
||||
ecmascript@0.15.0
|
||||
ecmascript@0.15.1
|
||||
es5-shim@4.8.0
|
||||
reactive-dict@1.3.0
|
||||
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-oauth@1.2.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-router2@0.2.3
|
||||
akryum:vue-sass@0.1.2
|
||||
aldeed:collection2@3.2.1
|
||||
aldeed:collection2@3.3.0
|
||||
aldeed:schema-index@3.0.0
|
||||
allow-deny@1.1.0
|
||||
autoupdate@1.7.0
|
||||
babel-compiler@7.6.0
|
||||
babel-compiler@7.6.1
|
||||
babel-runtime@1.5.0
|
||||
base64@1.0.12
|
||||
binary-heap@1.0.11
|
||||
blaze-tools@1.0.10
|
||||
blaze-tools@1.1.1
|
||||
boilerplate-generator@1.7.1
|
||||
bozhao:link-accounts@2.3.2
|
||||
caching-compiler@1.2.2
|
||||
caching-html-compiler@1.1.3
|
||||
caching-html-compiler@1.2.0
|
||||
callback-hook@1.3.0
|
||||
check@1.3.1
|
||||
chuangbo:marked@0.3.5_1
|
||||
@@ -37,7 +37,7 @@ ddp-server@2.3.2
|
||||
deps@1.0.12
|
||||
diff-sequence@1.1.1
|
||||
dynamic-import@0.6.0
|
||||
ecmascript@0.15.0
|
||||
ecmascript@0.15.1
|
||||
ecmascript-runtime@0.7.0
|
||||
ecmascript-runtime-client@0.11.0
|
||||
ecmascript-runtime-server@0.10.0
|
||||
@@ -48,13 +48,13 @@ fetch@0.1.1
|
||||
geojson-utils@1.0.10
|
||||
google-oauth@1.3.0
|
||||
hot-code-push@1.0.4
|
||||
html-tools@1.0.11
|
||||
htmljs@1.0.11
|
||||
html-tools@1.1.1
|
||||
htmljs@1.1.0
|
||||
http@1.4.3
|
||||
id-map@1.1.0
|
||||
inter-process-messaging@0.1.1
|
||||
lai:collection-extensions@0.2.1_1
|
||||
launch-screen@1.2.0
|
||||
launch-screen@1.2.1
|
||||
livedata@1.0.18
|
||||
localstorage@1.2.0
|
||||
logging@1.2.0
|
||||
@@ -65,19 +65,19 @@ meteorhacks:subs-manager@1.6.4
|
||||
mikowals:batch-insert@1.2.0
|
||||
minifier-css@1.5.3
|
||||
minifier-js@2.6.0
|
||||
minimongo@1.6.1
|
||||
minimongo@1.6.2
|
||||
mobile-experience@1.1.0
|
||||
mobile-status-bar@1.1.0
|
||||
modern-browsers@0.1.5
|
||||
modules@0.16.0
|
||||
modules-runtime@0.12.0
|
||||
momentjs:moment@2.29.1
|
||||
mongo@1.10.1
|
||||
mongo@1.11.0
|
||||
mongo-decimal@0.1.2
|
||||
mongo-dev-server@1.1.0
|
||||
mongo-id@1.0.7
|
||||
npm-bcrypt@0.9.3
|
||||
npm-mongo@3.8.1
|
||||
npm-mongo@3.9.0
|
||||
oauth@1.3.2
|
||||
oauth2@1.3.0
|
||||
ongoworks:speakingurl@9.0.0
|
||||
@@ -113,16 +113,17 @@ simple:json-routes@2.1.0
|
||||
simple:rest@1.1.1
|
||||
simple:rest-method-mixin@1.0.1
|
||||
socket-stream-client@0.3.1
|
||||
spacebars-compiler@1.1.3
|
||||
spacebars-compiler@1.2.1
|
||||
srp@1.1.0
|
||||
standard-minifier-js@2.6.0
|
||||
static-html@1.2.2
|
||||
static-html@1.3.0
|
||||
templates:array@1.0.3
|
||||
templating-tools@1.1.2
|
||||
tmeasday:check-npm-versions@0.3.2
|
||||
templating-tools@1.2.0
|
||||
tmeasday:check-npm-versions@1.0.1
|
||||
tracker@1.2.0
|
||||
typescript@4.2.2
|
||||
underscore@1.0.10
|
||||
url@1.3.1
|
||||
webapp@1.10.0
|
||||
webapp@1.10.1
|
||||
webapp-hashing@1.1.0
|
||||
zer0th:meteor-vuetify-loader@0.1.30
|
||||
|
||||
@@ -7,7 +7,8 @@ import SharingSchema from '/imports/api/sharing/SharingSchema.js';
|
||||
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
|
||||
import {assertEditPermission} from '/imports/api/sharing/sharingPermissions.js';
|
||||
import { assertUserHasPaidBenefits } from '/imports/api/users/patreon/tiers.js';
|
||||
|
||||
import defaultCharacterProperties from '/imports/api/creature/defaultCharacterProperties.js';
|
||||
import insertPropertyFromLibraryNode from '/imports/api/creature/creatureProperties/methods/insertPropertyFromLibraryNode.js';
|
||||
import '/imports/api/creature/removeCreature.js';
|
||||
import '/imports/api/creature/restCreature.js';
|
||||
|
||||
@@ -198,24 +199,29 @@ const insertCreature = new ValidatedMethod({
|
||||
let creatureId = Creatures.insert({
|
||||
owner: this.userId,
|
||||
});
|
||||
CreatureProperties.insert({
|
||||
slotTags: ['base'],
|
||||
quantityExpected: 1,
|
||||
type: 'propertySlot',
|
||||
name: 'Base',
|
||||
description: 'Choose a starting point for your character, this will define the basic setup of your character sheet. Without a base, your sheet will be empty.',
|
||||
hideWhenFull: true,
|
||||
parent: {collection: 'creatures', id: creatureId},
|
||||
ancestors: [{collection: 'creatures', id: creatureId}],
|
||||
order: 0,
|
||||
tags: [],
|
||||
spaceLeft: 1,
|
||||
totalFilled: 0,
|
||||
|
||||
// Insert the default properties
|
||||
// Not batchInsert because we want the properties cleaned by the schema
|
||||
let baseId;
|
||||
defaultCharacterProperties(creatureId).forEach(prop => {
|
||||
let id = CreatureProperties.insert(prop);
|
||||
if (prop.name === 'Ruleset'){
|
||||
baseId = id;
|
||||
}
|
||||
});
|
||||
|
||||
if (Meteor.isServer){
|
||||
// Insert the 5e ruleset as the default base
|
||||
insertPropertyFromLibraryNode.call({
|
||||
nodeId: 'iHbhfcg3AL5isSWbw',
|
||||
parentRef: {id: baseId, collection: 'creatureProperties'},
|
||||
order: 0.5,
|
||||
});
|
||||
}
|
||||
|
||||
this.unblock();
|
||||
return creatureId;
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
const updateCreature = new ValidatedMethod({
|
||||
|
||||
@@ -104,31 +104,10 @@ export default class ComputationMemo {
|
||||
let variableName = prop.variableName;
|
||||
if (!variableName) return;
|
||||
let existingStat = this.statsByVariableName[variableName];
|
||||
prop = this.registerProperty(prop);
|
||||
if (existingStat){
|
||||
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 {
|
||||
prop = this.registerProperty(prop);
|
||||
this.statsById[prop._id] = prop;
|
||||
this.statsByVariableName[variableName] = prop;
|
||||
if (
|
||||
@@ -190,7 +169,9 @@ export default class ComputationMemo {
|
||||
prop = this.registerProperty(prop);
|
||||
let targets = this.getProficiencyTargets(prop);
|
||||
targets.forEach(target => {
|
||||
target.computationDetails.proficiencies.push(prop);
|
||||
if(target.computationDetails.proficiencies){
|
||||
target.computationDetails.proficiencies.push(prop);
|
||||
}
|
||||
});
|
||||
}
|
||||
getProficiencyTargets(prop){
|
||||
@@ -267,6 +248,7 @@ const propDetailsByType = {
|
||||
computed: false,
|
||||
busyComputing: false,
|
||||
effects: [],
|
||||
proficiencies: [],
|
||||
toggleAncestors: [],
|
||||
idsOfSameName: [],
|
||||
};
|
||||
|
||||
@@ -1,31 +1,6 @@
|
||||
import evaluateCalculation from '/imports/api/creature/computation/engine/evaluateCalculation.js';
|
||||
import { union } from 'lodash';
|
||||
|
||||
export default class EffectAggregator{
|
||||
constructor(stat, memo){
|
||||
delete this.baseValueErrors;
|
||||
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;
|
||||
}
|
||||
constructor(){
|
||||
this.base = 0;
|
||||
this.add = 0;
|
||||
this.mul = 1;
|
||||
this.min = Number.NEGATIVE_INFINITY;
|
||||
@@ -46,11 +21,6 @@ export default class EffectAggregator{
|
||||
case 'base':
|
||||
// Take the largest base value
|
||||
this.base = result > this.base ? result : this.base;
|
||||
if (effect.statBase){
|
||||
if (this.statBaseValue === undefined || result > this.statBaseValue){
|
||||
this.statBaseValue = result;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 'add':
|
||||
// Add all adds together
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
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 { union } from 'lodash';
|
||||
|
||||
@@ -14,7 +14,8 @@ export default function combineStat(stat, aggregator, memo){
|
||||
}
|
||||
|
||||
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) {
|
||||
result = aggregator.min;
|
||||
}
|
||||
@@ -32,8 +33,6 @@ function getAggregatorResult(stat, aggregator){
|
||||
|
||||
function combineAttribute(stat, aggregator, memo){
|
||||
stat.value = getAggregatorResult(stat, aggregator);
|
||||
stat.baseValue = aggregator.statBaseValue;
|
||||
stat.baseValueErrors = aggregator.baseValueErrors;
|
||||
if (stat.attributeType === 'spellSlot'){
|
||||
let {
|
||||
result,
|
||||
@@ -78,9 +77,7 @@ function combineSkill(stat, aggregator, memo){
|
||||
// Skills are based on some ability Modifier
|
||||
let ability = stat.ability && memo.statsByVariableName[stat.ability]
|
||||
if (stat.ability && ability){
|
||||
if (!ability.computationDetails.computed){
|
||||
computeStat(ability, memo);
|
||||
}
|
||||
computeStat(ability, memo);
|
||||
stat.abilityMod = ability.modifier;
|
||||
stat.dependencies = union(
|
||||
stat.dependencies,
|
||||
@@ -91,10 +88,10 @@ function combineSkill(stat, aggregator, memo){
|
||||
stat.abilityMod = 0;
|
||||
}
|
||||
// Combine all the child proficiencies
|
||||
stat.proficiency = stat.baseProficiency || 0;
|
||||
stat.proficiency = 0;
|
||||
for (let i in stat.computationDetails.proficiencies){
|
||||
let prof = stat.computationDetails.proficiencies[i];
|
||||
applyToggles(prof, memo);
|
||||
computeProficiency(prof, memo);
|
||||
if (
|
||||
!prof.deactivatedByToggle &&
|
||||
prof.value > stat.proficiency
|
||||
@@ -111,6 +108,14 @@ function combineSkill(stat, aggregator, memo){
|
||||
let profBonusStat = memo.statsByVariableName['proficiencyBonus'];
|
||||
let profBonus = profBonusStat && profBonusStat.value;
|
||||
|
||||
if (profBonusStat){
|
||||
stat.dependencies = union(
|
||||
stat.dependencies,
|
||||
[profBonusStat._id],
|
||||
profBonusStat.dependencies,
|
||||
);
|
||||
}
|
||||
|
||||
if (typeof profBonus !== 'number' && memo.statsByVariableName['level']){
|
||||
let levelProp = memo.statsByVariableName['level'];
|
||||
let level = levelProp.value;
|
||||
@@ -121,18 +126,16 @@ function combineSkill(stat, aggregator, memo){
|
||||
if (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
|
||||
profBonus *= stat.proficiency;
|
||||
// Base value
|
||||
stat.baseValue = aggregator.statBaseValue;
|
||||
stat.baseValueErrors = aggregator.baseValueErrors;
|
||||
if(stat.proficiency === 0.49){
|
||||
// Round down proficiency bonus in the special case
|
||||
profBonus = Math.floor(profBonus * 0.5);
|
||||
} else {
|
||||
profBonus = Math.ceil(profBonus * stat.proficiency);
|
||||
}
|
||||
|
||||
// Combine everything to get the final result
|
||||
let result = (aggregator.base + stat.abilityMod + profBonus + aggregator.add) * aggregator.mul;
|
||||
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 computeEffect from '/imports/api/creature/computation/engine/computeEffect.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 { each, union } from 'lodash';
|
||||
import { each, union, without } from 'lodash';
|
||||
|
||||
export default function computeStat(stat, memo){
|
||||
// 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
|
||||
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 = stat.computationDetails.idsOfSameName.map(
|
||||
id => memo.propsById[id]
|
||||
);
|
||||
|
||||
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: [],
|
||||
computationDetails: {
|
||||
computed: true,
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Compute each active stat's baseValue calculation and apply it
|
||||
if (statInstance.baseValueCalculation) {
|
||||
let {
|
||||
result,
|
||||
context,
|
||||
dependencies
|
||||
} = evaluateCalculation({
|
||||
string: statInstance.baseValueCalculation,
|
||||
prop: statInstance,
|
||||
memo
|
||||
});
|
||||
baseDependencies = union(baseDependencies, dependencies);
|
||||
statInstance.baseValue = +result.value;
|
||||
if (context.errors.length){
|
||||
statInstance.baseValueErrors = context.errors;
|
||||
}
|
||||
// Apply all the base values
|
||||
if (!statInstance.inactive){
|
||||
effects.push({
|
||||
operation: 'base',
|
||||
calculation: statInstance.baseValueCalculation,
|
||||
result: statInstance.baseValue,
|
||||
stats: [statInstance.variableName],
|
||||
dependencies: [],
|
||||
computationDetails: {
|
||||
computed: true,
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Apply all the base baseDependencies
|
||||
allStats.forEach(statInstance => {
|
||||
statInstance.dependencies = union(
|
||||
statInstance.dependencies,
|
||||
without(baseDependencies, statInstance._id)
|
||||
);
|
||||
});
|
||||
|
||||
// Compute and aggregate all the effects
|
||||
let aggregator = new EffectAggregator(stat, memo)
|
||||
each(stat.computationDetails.effects, (effect) => {
|
||||
let aggregator = new EffectAggregator();
|
||||
let effectDeps = [];
|
||||
each(effects, (effect) => {
|
||||
// Compute
|
||||
computeEffect(effect, memo);
|
||||
if (effect.deactivatedByToggle) return;
|
||||
if (effect._id){
|
||||
stat.dependencies = union(
|
||||
stat.dependencies,
|
||||
[effect._id]
|
||||
);
|
||||
}
|
||||
stat.dependencies = union(
|
||||
stat.dependencies,
|
||||
effect.dependencies
|
||||
)
|
||||
|
||||
// dependencies
|
||||
if (effect._id) effectDeps = [effect._id];
|
||||
effectDeps = union(effectDeps, effect.dependencies);
|
||||
|
||||
// Add computed effect to aggregator
|
||||
aggregator.addEffect(effect);
|
||||
});
|
||||
// Conglomerate all the effects to compute the final stat values
|
||||
combineStat(stat, aggregator, memo);
|
||||
// Mark the attribute as computed
|
||||
stat.computationDetails.computed = true;
|
||||
stat.computationDetails.busyComputing = false;
|
||||
|
||||
// Combine the effects into the stats
|
||||
allStats.forEach(statInstance => {
|
||||
// Conglomerate all the effects to compute the final stat values
|
||||
combineStat(statInstance, aggregator, memo);
|
||||
// Mark the stats as computed
|
||||
statInstance.computationDetails.computed = true;
|
||||
statInstance.computationDetails.busyComputing = false;
|
||||
statInstance.dependencies = union(
|
||||
statInstance.dependencies,
|
||||
effectDeps
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -12,29 +12,22 @@ export default function writeAlteredProperties(memo){
|
||||
console.warn('No schema for ' + changed.type);
|
||||
return;
|
||||
}
|
||||
let extraIds = changed.computationDetails.idsOfSameName;
|
||||
let ids;
|
||||
if (extraIds && extraIds.length){
|
||||
ids = [changed._id, ...extraIds];
|
||||
} else {
|
||||
ids = [changed._id];
|
||||
let id = changed._id;
|
||||
let op = undefined;
|
||||
let original = memo.originalPropsById[id];
|
||||
let keys = [
|
||||
'dependencies',
|
||||
'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);
|
||||
}
|
||||
|
||||
@@ -65,7 +65,6 @@ let CreaturePropertySchema = new SimpleSchema({
|
||||
},
|
||||
'dependencies.$': {
|
||||
type: String,
|
||||
regEx: SimpleSchema.RegEx.Id,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -2,9 +2,24 @@ import SimpleSchema from 'simpl-schema';
|
||||
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
||||
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
||||
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
|
||||
import getRootCreatureAncestor from '/imports/api/creature/creatureProperties/getRootCreatureAncestor.js';
|
||||
import { assertEditPermission } from '/imports/api/sharing/sharingPermissions.js';
|
||||
import { insertPropertyWork } from '/imports/api/creature/creatureProperties/methods/insertProperty.js';
|
||||
import getRootCreatureAncestor from '/imports/api/creature/creatureProperties/getRootCreatureAncestor.js';
|
||||
import {
|
||||
setLineageOfDocs,
|
||||
renewDocIds
|
||||
} from '/imports/api/parenting/parenting.js';
|
||||
import recomputeInactiveProperties from '/imports/api/creature/denormalise/recomputeInactiveProperties.js';
|
||||
import { reorderDocs } from '/imports/api/parenting/order.js';
|
||||
import recomputeInventory from '/imports/api/creature/denormalise/recomputeInventory.js';
|
||||
import { recomputeCreatureByDoc } from '/imports/api/creature/computation/methods/recomputeCreature.js';
|
||||
var snackbar;
|
||||
if (Meteor.isClient){
|
||||
snackbar = require(
|
||||
'/imports/ui/components/snackbars/SnackbarQueue.js'
|
||||
).snackbar
|
||||
}
|
||||
|
||||
const DUPLICATE_CHILDREN_LIMIT = 50;
|
||||
|
||||
const duplicateProperty = new ValidatedMethod({
|
||||
name: 'creatureProperties.duplicate',
|
||||
@@ -20,13 +35,70 @@ const duplicateProperty = new ValidatedMethod({
|
||||
timeInterval: 5000,
|
||||
},
|
||||
run({_id}) {
|
||||
let creatureProperty = CreatureProperties.findOne(_id);
|
||||
let rootCreature = getRootCreatureAncestor(creatureProperty);
|
||||
assertEditPermission(rootCreature, this.userId);
|
||||
insertPropertyWork({
|
||||
property: creatureProperty,
|
||||
creature: rootCreature,
|
||||
let property = CreatureProperties.findOne(_id);
|
||||
let creature = getRootCreatureAncestor(property);
|
||||
|
||||
assertEditPermission(creature, this.userId);
|
||||
|
||||
// Renew the doc ID
|
||||
let randomSrc = DDP.randomStream('duplicateProperty');
|
||||
let propertyId = randomSrc.id();
|
||||
property._id = propertyId;
|
||||
|
||||
// Get all the descendants
|
||||
let nodes = CreatureProperties.find({
|
||||
'ancestors.id': _id,
|
||||
removed: {$ne: true},
|
||||
}, {
|
||||
limit: DUPLICATE_CHILDREN_LIMIT + 1,
|
||||
sort: {order: 1},
|
||||
}).fetch();
|
||||
|
||||
// Alert the user if the limit was hit
|
||||
if (nodes.length > DUPLICATE_CHILDREN_LIMIT){
|
||||
nodes.pop();
|
||||
if (Meteor.isClient){
|
||||
snackbar({
|
||||
text: `Only the first ${DUPLICATE_CHILDREN_LIMIT} children were duplicated`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// re-map all the ancestors
|
||||
setLineageOfDocs({
|
||||
docArray: nodes,
|
||||
newAncestry : [
|
||||
...property.ancestors,
|
||||
{id: propertyId, collection: 'creatureProperties'}
|
||||
],
|
||||
oldParent : {id: _id, collection: 'creatureProperties'},
|
||||
});
|
||||
|
||||
// Give the docs new IDs without breaking internal references
|
||||
renewDocIds({docArray: nodes});
|
||||
|
||||
// Order the root node
|
||||
property.order += 0.5;
|
||||
|
||||
// Insert the properties
|
||||
CreatureProperties.batchInsert([property, ...nodes]);
|
||||
|
||||
// Tree structure changed by inserts, reorder the tree
|
||||
reorderDocs({
|
||||
collection: CreatureProperties,
|
||||
ancestorId: property.ancestors[0].id,
|
||||
});
|
||||
|
||||
// Inserting the active status of the property needs to be denormalised
|
||||
recomputeInactiveProperties(creature._id);
|
||||
|
||||
// Recompute the inventory
|
||||
recomputeInventory(creature._id);
|
||||
|
||||
// Inserting a creature property invalidates dependencies: full recompute
|
||||
recomputeCreatureByDoc(creature);
|
||||
|
||||
return propertyId;
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -7,23 +7,8 @@ import getRootCreatureAncestor from '/imports/api/creature/creatureProperties/ge
|
||||
import { recomputeCreatureByDoc } from '/imports/api/creature/computation/methods/recomputeCreature.js';
|
||||
import recomputeInactiveProperties from '/imports/api/creature/denormalise/recomputeInactiveProperties.js';
|
||||
import recomputeInventory from '/imports/api/creature/denormalise/recomputeInventory.js';
|
||||
import INVENTORY_TAGS from '/imports/constants/INVENTORY_TAGS.js';
|
||||
|
||||
export function getParentRefByTag(creatureId, tag){
|
||||
let prop = CreatureProperties.findOne({
|
||||
'ancestors.id': creatureId,
|
||||
removed: {$ne: true},
|
||||
inactive: {$ne: true},
|
||||
tags: tag,
|
||||
}, {
|
||||
sort: {order: 1},
|
||||
});
|
||||
if (prop){
|
||||
return {id: prop._id, collection: 'creatureProperties'};
|
||||
} else {
|
||||
return {id: creatureId, collection: 'creatures'};
|
||||
}
|
||||
}
|
||||
import BUILT_IN_TAGS from '/imports/constants/BUILT_IN_TAGS.js';
|
||||
import getParentRefByTag from '/imports/api/creature/creatureProperties/methods/getParentRefByTag.js';
|
||||
|
||||
// Equipping or unequipping an item will also change its parent
|
||||
const equipItem = new ValidatedMethod({
|
||||
@@ -50,8 +35,9 @@ const equipItem = new ValidatedMethod({
|
||||
}, {
|
||||
selector: {type: 'item'},
|
||||
});
|
||||
let tag = equipped ? INVENTORY_TAGS.equipment : INVENTORY_TAGS.carried;
|
||||
let tag = equipped ? BUILT_IN_TAGS.equipment : BUILT_IN_TAGS.carried;
|
||||
let parentRef = getParentRefByTag(creature._id, tag);
|
||||
if (!parentRef) parentRef = {id: creature._id, collection: 'creatures'};
|
||||
|
||||
organizeDoc.call({
|
||||
docRef: {
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
|
||||
|
||||
export default function getParentRefByTag(creatureId, tag){
|
||||
let prop = CreatureProperties.findOne({
|
||||
'ancestors.id': creatureId,
|
||||
removed: {$ne: true},
|
||||
inactive: {$ne: true},
|
||||
tags: tag,
|
||||
}, {
|
||||
sort: {order: 1},
|
||||
});
|
||||
return prop && {id: prop._id, collection: 'creatureProperties'};
|
||||
}
|
||||
@@ -2,16 +2,26 @@ import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
||||
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
||||
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
|
||||
import getRootCreatureAncestor from '/imports/api/creature/creatureProperties/getRootCreatureAncestor.js';
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import { assertEditPermission } from '/imports/api/sharing/sharingPermissions.js';
|
||||
import { reorderDocs } from '/imports/api/parenting/order.js';
|
||||
import recomputeInactiveProperties from '/imports/api/creature/denormalise/recomputeInactiveProperties.js';
|
||||
import { recomputeCreatureByDoc } from '/imports/api/creature/computation/methods/recomputeCreature.js';
|
||||
import recomputeInventory from '/imports/api/creature/denormalise/recomputeInventory.js';
|
||||
import { getAncestry } from '/imports/api/parenting/parenting.js';
|
||||
import getParentRefByTag from '/imports/api/creature/creatureProperties/methods/getParentRefByTag.js';
|
||||
import { RefSchema } from '/imports/api/parenting/ChildSchema.js';
|
||||
import { getHighestOrder } from '/imports/api/parenting/order.js';
|
||||
|
||||
const insertProperty = new ValidatedMethod({
|
||||
name: 'creatureProperties.insert',
|
||||
validate: null,
|
||||
validate: new SimpleSchema({
|
||||
creatureProperty: {
|
||||
type: Object,
|
||||
blackbox: true,
|
||||
},
|
||||
parentRef: RefSchema,
|
||||
}).validator(),
|
||||
mixins: [RateLimiterMixin],
|
||||
rateLimit: {
|
||||
numRequests: 5,
|
||||
@@ -42,6 +52,86 @@ const insertProperty = new ValidatedMethod({
|
||||
},
|
||||
});
|
||||
|
||||
const insertPropertyAsChildOfTag = new ValidatedMethod({
|
||||
name: 'creatureProperties.insertAsChildOfTag',
|
||||
validate: new SimpleSchema({
|
||||
creatureProperty: {
|
||||
type: Object,
|
||||
blackbox: true,
|
||||
},
|
||||
creatureId: {
|
||||
type: String,
|
||||
regEx: SimpleSchema.RegEx.Id,
|
||||
},
|
||||
tag: {
|
||||
type: String,
|
||||
max: 20,
|
||||
},
|
||||
tagDefaultName: {
|
||||
type: String,
|
||||
max: 20,
|
||||
optional: true,
|
||||
},
|
||||
}).validator(),
|
||||
mixins: [RateLimiterMixin],
|
||||
rateLimit: {
|
||||
numRequests: 5,
|
||||
timeInterval: 5000,
|
||||
},
|
||||
run({creatureProperty, creatureId, tag, tagDefaultName}) {
|
||||
let parentRef = getParentRefByTag(creatureId, tag);
|
||||
|
||||
if (!parentRef){
|
||||
// Use the creature as the parent and mark that we need to insert the folder first later
|
||||
var insertFolderFirst = true;
|
||||
parentRef = {id: creatureId, collection: 'creatures'};
|
||||
}
|
||||
|
||||
// get the new ancestry for the properties
|
||||
let {parentDoc, ancestors} = getAncestry({parentRef});
|
||||
|
||||
// Check permission to edit
|
||||
let rootCreature;
|
||||
if (parentRef.collection === 'creatures'){
|
||||
rootCreature = parentDoc;
|
||||
} else if (parentRef.collection === 'creatureProperties'){
|
||||
rootCreature = getRootCreatureAncestor(parentDoc);
|
||||
} else {
|
||||
throw `${parentRef.collection} is not a valid parent collection`
|
||||
}
|
||||
assertEditPermission(rootCreature, this.userId);
|
||||
|
||||
// Add the folder first if we need to
|
||||
if (insertFolderFirst){
|
||||
let order = getHighestOrder({
|
||||
collection: CreatureProperties,
|
||||
ancestorId: parentRef.id,
|
||||
}) + 1;
|
||||
let id = CreatureProperties.insert({
|
||||
type: 'folder',
|
||||
name: tagDefaultName || (tag.charAt(0).toUpperCase() + tag.slice(1)),
|
||||
tags: [tag],
|
||||
parent: parentRef,
|
||||
ancestors: [parentRef],
|
||||
order,
|
||||
});
|
||||
// Make the folder our new parent
|
||||
let newParentRef = {id, collection: 'creatureProperties'};
|
||||
ancestors = [parentRef, newParentRef];
|
||||
parentRef = newParentRef;
|
||||
creatureProperty.order = order + 1;
|
||||
}
|
||||
|
||||
creatureProperty.parent = parentRef;
|
||||
creatureProperty.ancestors = ancestors;
|
||||
|
||||
return insertPropertyWork({
|
||||
property: creatureProperty,
|
||||
creature: rootCreature,
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
export function insertPropertyWork({property, creature}){
|
||||
delete property._id;
|
||||
let _id = CreatureProperties.insert(property);
|
||||
@@ -63,3 +153,4 @@ export function insertPropertyWork({property, creature}){
|
||||
}
|
||||
|
||||
export default insertProperty;
|
||||
export { insertPropertyAsChildOfTag };
|
||||
|
||||
47
app/imports/api/creature/defaultCharacterProperties.js
Normal file
47
app/imports/api/creature/defaultCharacterProperties.js
Normal file
@@ -0,0 +1,47 @@
|
||||
import BUILT_IN_TAGS from '/imports/constants/BUILT_IN_TAGS.js';
|
||||
|
||||
export default function defaultCharacterProperties(creatureId){
|
||||
if (!creatureId) throw 'creatureId is required';
|
||||
const creatureRef = {collection: 'creatures', id: creatureId};
|
||||
let randomSrc = DDP.randomStream('defaultProperties');
|
||||
const inventoryId = randomSrc.id();
|
||||
const inventoryRef = {collection: 'creatureProperties', id: inventoryId};
|
||||
return [
|
||||
{
|
||||
type: 'propertySlot',
|
||||
name: 'Ruleset',
|
||||
description: 'Choose a starting point for your character, this will define the basic setup of your character sheet. Without a base, your sheet will be empty.',
|
||||
slotTags: ['base'],
|
||||
tags: [],
|
||||
quantityExpected: 1,
|
||||
hideWhenFull: true,
|
||||
spaceLeft: 1,
|
||||
totalFilled: 0,
|
||||
order: 0,
|
||||
parent: creatureRef,
|
||||
ancestors: [creatureRef],
|
||||
}, {
|
||||
_id: inventoryId,
|
||||
type: 'folder',
|
||||
name: 'Inventory',
|
||||
tags: [BUILT_IN_TAGS.inventory],
|
||||
order: 1,
|
||||
parent: creatureRef,
|
||||
ancestors: [creatureRef],
|
||||
}, {
|
||||
type: 'folder',
|
||||
name: 'Equipment',
|
||||
tags: [BUILT_IN_TAGS.equipment],
|
||||
order: 2,
|
||||
parent: inventoryRef,
|
||||
ancestors: [creatureRef, inventoryRef],
|
||||
}, {
|
||||
type: 'folder',
|
||||
name: 'Carried',
|
||||
tags: [BUILT_IN_TAGS.carried],
|
||||
order: 3,
|
||||
parent: inventoryRef,
|
||||
ancestors: [creatureRef, inventoryRef],
|
||||
},
|
||||
];
|
||||
}
|
||||
@@ -34,7 +34,9 @@ const duplicateLibraryNode = new ValidatedMethod({
|
||||
run({_id}) {
|
||||
let libraryNode = LibraryNodes.findOne(_id);
|
||||
assertDocEditPermission(libraryNode, this.userId);
|
||||
let libraryNodeId = Random.id();
|
||||
|
||||
let randomSrc = DDP.randomStream('duplicateLibraryNode');
|
||||
let libraryNodeId = randomSrc.id();
|
||||
libraryNode._id = libraryNodeId;
|
||||
|
||||
let nodes = LibraryNodes.find({
|
||||
|
||||
@@ -33,7 +33,7 @@ const AdjustmentSchema = new SimpleSchema({
|
||||
|
||||
const ComputedOnlyAdjustmentSchema = new SimpleSchema({
|
||||
amountResult: {
|
||||
type: SimpleSchema.Integer,
|
||||
type: SimpleSchema.oneOf(String, Number),
|
||||
optional: true,
|
||||
},
|
||||
amountErrors: {
|
||||
|
||||
@@ -133,6 +133,11 @@ let ComputedOnlyAttributeSchema = new SimpleSchema({
|
||||
type: Boolean,
|
||||
optional: true,
|
||||
},
|
||||
// Denormalised tag if stat is overridden by one with the same variable name
|
||||
overridden: {
|
||||
type: Boolean,
|
||||
optional: true,
|
||||
},
|
||||
});
|
||||
|
||||
const ComputedAttributeSchema = new SimpleSchema()
|
||||
|
||||
@@ -29,7 +29,7 @@ const DamageSchema = new SimpleSchema({
|
||||
|
||||
const ComputedOnlyDamageSchema = new SimpleSchema({
|
||||
amountResult: {
|
||||
type: SimpleSchema.oneOf(String, SimpleSchema.Integer),
|
||||
type: SimpleSchema.oneOf(String, Number),
|
||||
optional: true,
|
||||
},
|
||||
amountErrors: {
|
||||
|
||||
@@ -14,9 +14,10 @@ let ProficiencySchema = new SimpleSchema({
|
||||
type: String,
|
||||
},
|
||||
// A number representing how proficient the character is
|
||||
// where 0.49 is half rounded down and 0.5 is half rounded up
|
||||
value: {
|
||||
type: Number,
|
||||
allowedValues: [0.5, 1, 2],
|
||||
allowedValues: [0.49, 0.5, 1, 2],
|
||||
defaultValue: 1,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -121,6 +121,11 @@ let ComputedOnlySkillSchema = new SimpleSchema({
|
||||
type: Boolean,
|
||||
optional: true,
|
||||
},
|
||||
// Denormalised tag if stat is overridden by one with the same variable name
|
||||
overridden: {
|
||||
type: Boolean,
|
||||
optional: true,
|
||||
},
|
||||
})
|
||||
|
||||
const ComputedSkillSchema = new SimpleSchema()
|
||||
|
||||
@@ -10,7 +10,11 @@ const InlineComputationSchema = new SimpleSchema({
|
||||
type: String,
|
||||
optional: true,
|
||||
},
|
||||
errors: ErrorSchema,
|
||||
errors: {
|
||||
type: Array,
|
||||
optional: true,
|
||||
},
|
||||
'errors.$': ErrorSchema,
|
||||
});
|
||||
|
||||
export default InlineComputationSchema;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
const INVENTORY_TAGS = Object.freeze({
|
||||
const BUILT_IN_TAGS = Object.freeze({
|
||||
inventory: 'inventory',
|
||||
equipment: 'equipment',
|
||||
carried: 'carried',
|
||||
});
|
||||
|
||||
export default INVENTORY_TAGS;
|
||||
export default BUILT_IN_TAGS;
|
||||
@@ -20,7 +20,6 @@ export default class CallNode extends ParseNode {
|
||||
|
||||
// Resolve the arguments
|
||||
let resolvedArgs = this.args.map(node => node[fn](scope, context));
|
||||
|
||||
// Check that the arguments match what is expected
|
||||
let checkFailed = this.checkArugments({
|
||||
fn,
|
||||
@@ -30,7 +29,7 @@ export default class CallNode extends ParseNode {
|
||||
});
|
||||
|
||||
if (checkFailed){
|
||||
if (fn !== 'reduce'){
|
||||
if (fn === 'reduce'){
|
||||
return new ErrorNode({
|
||||
node: this,
|
||||
error: `Invalid arguments to ${this.functionName} function`,
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
:loading="loading"
|
||||
:error-messages="errors"
|
||||
:disabled="isDisabled"
|
||||
filled
|
||||
outlined
|
||||
v-on="on"
|
||||
@focus="focused = true"
|
||||
@blur="focused = false"
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
:menu-props="{auto: true, lazy: true}"
|
||||
:search-input.sync="searchInput"
|
||||
:disabled="isDisabled"
|
||||
filled
|
||||
outlined
|
||||
@change="customChange"
|
||||
@focus="focused = true"
|
||||
@blur="focused = false"
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
:value="safeValue"
|
||||
:menu-props="{auto: true, lazy: true}"
|
||||
:disabled="isDisabled"
|
||||
filled
|
||||
outlined
|
||||
@change="change"
|
||||
@focus="focused = true"
|
||||
@blur="focused = false"
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
:value="safeValue"
|
||||
:disabled="isDisabled"
|
||||
:auto-grow="autoGrow"
|
||||
filled
|
||||
outlined
|
||||
@input="input"
|
||||
@focus="focused = true"
|
||||
@blur="focused = false"
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
:error-messages="errors"
|
||||
:value="safeValue"
|
||||
:disabled="isDisabled"
|
||||
:filled="!regular"
|
||||
:outlined="!regular"
|
||||
@input="input"
|
||||
@focus="focused = true"
|
||||
@blur="focused = false"
|
||||
|
||||
@@ -5,6 +5,13 @@
|
||||
:light="!isDark"
|
||||
:flat="flat"
|
||||
>
|
||||
<v-btn
|
||||
v-if="!embedded"
|
||||
icon
|
||||
@click="back"
|
||||
>
|
||||
<v-icon>arrow_back</v-icon>
|
||||
</v-btn>
|
||||
<property-icon
|
||||
:model="model"
|
||||
class="mr-2"
|
||||
@@ -137,6 +144,7 @@ export default {
|
||||
},
|
||||
flat: Boolean,
|
||||
editing: Boolean,
|
||||
embedded: Boolean,
|
||||
},
|
||||
computed: {
|
||||
isDark(){
|
||||
@@ -163,6 +171,9 @@ export default {
|
||||
colorChanged(value){
|
||||
this.$emit('color-changed', value);
|
||||
},
|
||||
back(){
|
||||
this.$store.dispatch('popDialogStack');
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -6,7 +6,7 @@ let lastSnackbarId = 0;
|
||||
|
||||
function snackbar(data) {
|
||||
globalState.queue.push({
|
||||
data,
|
||||
data, //{text OR content, callback, callbackName} // content is logContent
|
||||
id: ++lastSnackbarId,
|
||||
enqueuedAt: new Date(),
|
||||
shown: false,
|
||||
|
||||
@@ -42,24 +42,12 @@
|
||||
<v-switch
|
||||
label="Show spells tab"
|
||||
:input-value="!model.settings.hideSpellsTab"
|
||||
@change="value => {
|
||||
$emit('change', {path: ['settings','hideSpellsTab'], value: !value});
|
||||
$store.commit(
|
||||
'setTabForCharacterSheet',
|
||||
{id: model._id, tab: 0}
|
||||
);
|
||||
}"
|
||||
@change="changeHideSpellsTab"
|
||||
/>
|
||||
<v-switch
|
||||
label="Show tree tab"
|
||||
:input-value="model.settings.showTreeTab"
|
||||
@change="value => {
|
||||
$emit('change', {path: ['settings','showTreeTab'], value: !!value});
|
||||
$store.commit(
|
||||
'setTabForCharacterSheet',
|
||||
{id: model._id, tab: 0}
|
||||
);
|
||||
}"
|
||||
@change="changeShowTreeTab"
|
||||
/>
|
||||
<text-field
|
||||
label="Hit Dice reset multiplier"
|
||||
@@ -129,6 +117,34 @@ export default {
|
||||
},
|
||||
disabled: Boolean,
|
||||
},
|
||||
methods: {
|
||||
changeShowTreeTab(value){
|
||||
this.$emit('change', {
|
||||
path: ['settings','showTreeTab'],
|
||||
value: !!value
|
||||
});
|
||||
let currentTab = this.$store.getters.tabById(this.model._id);
|
||||
if (!value && currentTab === 5){
|
||||
this.$store.commit(
|
||||
'setTabForCharacterSheet',
|
||||
{id: this.model._id, tab: 4}
|
||||
);
|
||||
}
|
||||
},
|
||||
changeHideSpellsTab(value){
|
||||
this.$emit('change', {
|
||||
path: ['settings','hideSpellsTab'],
|
||||
value: !value
|
||||
});
|
||||
let currentTab = this.$store.getters.tabById(this.model._id);
|
||||
if (!value && currentTab === 3){
|
||||
this.$store.commit(
|
||||
'setTabForCharacterSheet',
|
||||
{id: this.model._id, tab: 4}
|
||||
);
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
import Creatures from '/imports/api/creature/Creatures.js';
|
||||
import DialogBase from '/imports/ui/dialogStack/DialogBase.vue';
|
||||
import removeCreature from '/imports/api/creature/removeCreature.js';
|
||||
import { snackbar } from '/imports/ui/components/snackbars/SnackbarQueue.js';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
@@ -61,12 +62,12 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
remove(){
|
||||
this.$router.push('/characterList');
|
||||
this.$store.dispatch('popDialogStack');
|
||||
removeCreature.call({charId: this.id}, (error) => {
|
||||
if (error) {
|
||||
console.error(error);
|
||||
} else {
|
||||
this.$router.push('/characterList');
|
||||
this.$store.dispatch('popDialogStack');
|
||||
snackbar({text: error.message || error.toString()});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
<script lang="js">
|
||||
import LabeledFab from '/imports/ui/components/LabeledFab.vue';
|
||||
import { getHighestOrder } from '/imports/api/parenting/order.js';
|
||||
import insertProperty from '/imports/api/creature/creatureProperties/methods/insertProperty.js';
|
||||
import insertProperty, { insertPropertyAsChildOfTag } from '/imports/api/creature/creatureProperties/methods/insertProperty.js';
|
||||
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
|
||||
import PROPERTIES from '/imports/constants/PROPERTIES.js';
|
||||
import insertPropertyFromLibraryNode from '/imports/api/creature/creatureProperties/methods/insertPropertyFromLibraryNode.js';
|
||||
@@ -176,9 +176,24 @@
|
||||
collection: CreatureProperties,
|
||||
ancestorId: creatureId
|
||||
}) + 1;
|
||||
let id = insertProperty.call({
|
||||
|
||||
let tagDetails;
|
||||
switch (type){
|
||||
case 'item':
|
||||
tagDetails = {tag: 'carried', name: 'Carried'};
|
||||
break;
|
||||
case 'container':
|
||||
tagDetails = {tag: 'inventory', name: 'Inventory'};
|
||||
break;
|
||||
default:
|
||||
tagDetails = {tag: `${type}s`};
|
||||
break;
|
||||
}
|
||||
let id = insertPropertyAsChildOfTag.call({
|
||||
creatureProperty,
|
||||
parentRef: {collection: 'creatures', id: creatureId},
|
||||
creatureId,
|
||||
tag: tagDetails.tag,
|
||||
tagDefaultName: tagDetails.name,
|
||||
});
|
||||
return id;
|
||||
}
|
||||
@@ -213,7 +228,7 @@
|
||||
component: 'creature-property-from-library-dialog',
|
||||
elementId: 'insert-creature-property-from-library-btn',
|
||||
callback(libraryNode){
|
||||
if (!libraryNode) return;
|
||||
if (!libraryNode) return 'insert-creature-property-fab';
|
||||
revealFab(fab);
|
||||
|
||||
let nodeId = libraryNode._id;
|
||||
|
||||
@@ -156,9 +156,9 @@ export default {
|
||||
},
|
||||
},
|
||||
mounted(){
|
||||
if (this.$store.state.showBuildDialog){
|
||||
this.$store.commit('setShowBuildDialog', false);
|
||||
this.showSlotDialog();
|
||||
if (this.$store.state.showDetailsDialog){
|
||||
this.$store.commit('setShowDetailsDialog', false);
|
||||
this.showCharacterForm();
|
||||
}
|
||||
},
|
||||
meteor: {
|
||||
|
||||
@@ -104,8 +104,8 @@ import ColumnLayout from '/imports/ui/components/ColumnLayout.vue';
|
||||
import ContainerCard from '/imports/ui/properties/components/inventory/ContainerCard.vue';
|
||||
import ToolbarCard from '/imports/ui/components/ToolbarCard.vue';
|
||||
import ItemList from '/imports/ui/properties/components/inventory/ItemList.vue';
|
||||
import { getParentRefByTag } from '/imports/api/creature/creatureProperties/methods/equipItem.js';
|
||||
import INVENTORY_TAGS from '/imports/constants/INVENTORY_TAGS.js';
|
||||
import getParentRefByTag from '/imports/api/creature/creatureProperties/methods/getParentRefByTag.js';
|
||||
import BUILT_IN_TAGS from '/imports/constants/BUILT_IN_TAGS.js';
|
||||
import CoinValue from '/imports/ui/components/CoinValue.vue';
|
||||
|
||||
export default {
|
||||
@@ -183,10 +183,10 @@ export default {
|
||||
});
|
||||
},
|
||||
equipmentParentRef(){
|
||||
return getParentRefByTag(this.creatureId, INVENTORY_TAGS.equipment);
|
||||
return getParentRefByTag(this.creatureId, BUILT_IN_TAGS.equipment);
|
||||
},
|
||||
carriedParentRef(){
|
||||
return getParentRefByTag(this.creatureId, INVENTORY_TAGS.carried);
|
||||
return getParentRefByTag(this.creatureId, BUILT_IN_TAGS.carried);
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
|
||||
@@ -62,7 +62,7 @@ export default {
|
||||
},
|
||||
type: 'spell',
|
||||
removed: {$ne: true},
|
||||
inactive: {$ne: true},
|
||||
deactivatedByAncestor: {$ne: true},
|
||||
}, {
|
||||
sort: {
|
||||
level: 1,
|
||||
|
||||
@@ -345,6 +345,7 @@
|
||||
filter['ancestors.id'] = creature._id;
|
||||
filter.removed = {$ne: true};
|
||||
filter.inactive = {$ne: true};
|
||||
filter.overridden = {$ne: true};
|
||||
return CreatureProperties.find(filter, {
|
||||
sort: {order: 1}
|
||||
});
|
||||
@@ -434,7 +435,8 @@
|
||||
return getProperties(this.creature, {type: 'buff', applied: true});
|
||||
},
|
||||
attacks(){
|
||||
let props = getProperties(this.creature, {type: 'attack'}).map(attack => {
|
||||
let props = getProperties(this.creature, {type: 'attack'})
|
||||
return props && props.map(attack => {
|
||||
attack.children = CreatureProperties.find({
|
||||
'ancestors.id': attack._id,
|
||||
removed: {$ne: true},
|
||||
@@ -444,7 +446,6 @@
|
||||
});
|
||||
return attack;
|
||||
});
|
||||
return props;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
embedded
|
||||
:_id="selected"
|
||||
@removed="selected = undefined"
|
||||
@duplicated="id => selected = id"
|
||||
/>
|
||||
</template>
|
||||
</tree-detail-layout>
|
||||
|
||||
105
app/imports/ui/creature/creatureProperties/Breadcrumbs.vue
Normal file
105
app/imports/ui/creature/creatureProperties/Breadcrumbs.vue
Normal file
@@ -0,0 +1,105 @@
|
||||
<template lang="html">
|
||||
<div
|
||||
class="breadcrumbs layout align-center wrap"
|
||||
:class="{'no-icons': noIcons}"
|
||||
>
|
||||
<template v-for="(prop, index) in props">
|
||||
<v-icon
|
||||
v-if="index !== 0"
|
||||
:key="index"
|
||||
>
|
||||
chevron_right
|
||||
</v-icon>
|
||||
<span
|
||||
v-if="noLinks"
|
||||
:key="prop._id"
|
||||
>
|
||||
<tree-node-view
|
||||
:model="prop"
|
||||
class="breadcrumb-tree-node-view"
|
||||
/>
|
||||
</span>
|
||||
<a
|
||||
v-else
|
||||
:key="prop._id"
|
||||
:data-id="`breadcrumb-${prop._id}`"
|
||||
@click="click(prop._id)"
|
||||
>
|
||||
<tree-node-view
|
||||
:model="prop"
|
||||
class="breadcrumb-tree-node-view"
|
||||
/>
|
||||
</a>
|
||||
</template>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="js">
|
||||
import fetchDocByRef from '/imports/api/parenting/fetchDocByRef.js';
|
||||
import TreeNodeView from '/imports/ui/properties/treeNodeViews/TreeNodeView.vue';
|
||||
|
||||
export default {
|
||||
components: {
|
||||
TreeNodeView,
|
||||
},
|
||||
props: {
|
||||
model: {
|
||||
type: Object,
|
||||
required: true,
|
||||
},
|
||||
noLinks: Boolean,
|
||||
noIcons: Boolean,
|
||||
},
|
||||
computed:{
|
||||
props(){
|
||||
return this.model.ancestors
|
||||
.slice(1)
|
||||
.map(ref => fetchDocByRef(ref))
|
||||
.filter(prop => prop.type !== 'propertySlot');
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
click(id){
|
||||
let store = this.$store;
|
||||
// Check if there is a dialog open for this doc already
|
||||
let dialogFound;
|
||||
let dialogsToPop = 0;
|
||||
store.state.dialogStack.dialogs.forEach(dialog => {
|
||||
if (dialog.data && dialog.data._id === id){
|
||||
dialogFound = true;
|
||||
dialogsToPop = 0;
|
||||
} else {
|
||||
dialogsToPop += 1;
|
||||
}
|
||||
});
|
||||
if (dialogFound){
|
||||
// Pop dialogs until we get to it
|
||||
store.dispatch('popDialogStacks', dialogsToPop);
|
||||
} else {
|
||||
// Otherwise open it as a new dialog
|
||||
store.commit('pushDialogStack', {
|
||||
component: 'creature-property-dialog',
|
||||
elementId: `breadcrumb-${id}`,
|
||||
data: {_id: id},
|
||||
});
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="css" scoped>
|
||||
.breadcrumbs {
|
||||
margin-bottom: 16px;
|
||||
opacity: 0.8;
|
||||
}
|
||||
.no-icons {
|
||||
|
||||
}
|
||||
</style>
|
||||
|
||||
<style lang="css">
|
||||
.no-icons .breadcrumb-tree-node-view .v-icon {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
@@ -5,6 +5,7 @@
|
||||
:model="model"
|
||||
:editing="editing"
|
||||
:flat="flat"
|
||||
:embedded="embedded"
|
||||
style="flex-grow: 0;"
|
||||
@duplicate="duplicate"
|
||||
@remove="remove"
|
||||
@@ -13,6 +14,9 @@
|
||||
/>
|
||||
</template>
|
||||
<template v-if="model">
|
||||
<template v-if="!editing && !embedded">
|
||||
<breadcrumbs :model="model" />
|
||||
</template>
|
||||
<v-fade-transition
|
||||
mode="out-in"
|
||||
>
|
||||
@@ -44,6 +48,14 @@
|
||||
:root="{collection: 'creatureProperties', id: model._id}"
|
||||
@selected="selectSubProperty"
|
||||
/>
|
||||
<v-btn
|
||||
text
|
||||
data-id="insert-creature-property-btn"
|
||||
@click="addProperty"
|
||||
>
|
||||
<v-icon>add</v-icon>
|
||||
Property
|
||||
</v-btn>
|
||||
</template>
|
||||
</template>
|
||||
<div
|
||||
@@ -83,6 +95,9 @@ import { assertEditPermission } from '/imports/api/creature/creaturePermissions.
|
||||
import { get, findLast } from 'lodash';
|
||||
import equipItem from '/imports/api/creature/creatureProperties/methods/equipItem.js';
|
||||
import { snackbar } from '/imports/ui/components/snackbars/SnackbarQueue.js';
|
||||
import { getHighestOrder } from '/imports/api/parenting/order.js';
|
||||
import insertProperty from '/imports/api/creature/creatureProperties/methods/insertProperty.js';
|
||||
import Breadcrumbs from '/imports/ui/creature/creatureProperties/Breadcrumbs.vue';
|
||||
|
||||
let formIndex = {};
|
||||
for (let key in propertyFormIndex){
|
||||
@@ -102,6 +117,7 @@ export default {
|
||||
DialogBase,
|
||||
PropertyToolbar,
|
||||
CreaturePropertiesTree,
|
||||
Breadcrumbs,
|
||||
},
|
||||
props: {
|
||||
_id: String,
|
||||
@@ -158,12 +174,12 @@ export default {
|
||||
methods: {
|
||||
getPropertyName,
|
||||
duplicate(){
|
||||
duplicateProperty.call({_id: this.currentId}, (error) => {
|
||||
duplicateProperty.call({_id: this.currentId}, (error, id) => {
|
||||
if (error) {
|
||||
console.error(error);
|
||||
}
|
||||
if (this.embedded){
|
||||
this.$emit('duplicated');
|
||||
this.$emit('duplicated', id);
|
||||
} else {
|
||||
this.$store.dispatch('popDialogStack');
|
||||
}
|
||||
@@ -224,6 +240,30 @@ export default {
|
||||
elementId: `tree-node-${_id}`,
|
||||
data: {_id},
|
||||
});
|
||||
},
|
||||
addProperty(){
|
||||
let parentPropertyId = this.model._id;
|
||||
// Open the dialog to insert the property
|
||||
this.$store.commit('pushDialogStack', {
|
||||
component: 'creature-property-creation-dialog',
|
||||
elementId: 'insert-creature-property-btn',
|
||||
callback(creatureProperty){
|
||||
if (!creatureProperty) return;
|
||||
// Get order and parent
|
||||
let parentRef = {
|
||||
id: parentPropertyId,
|
||||
collection: 'creatureProperties',
|
||||
};
|
||||
creatureProperty.order = getHighestOrder({
|
||||
collection: CreatureProperties,
|
||||
ancestorId: parentRef.id,
|
||||
}) + 0.5;
|
||||
|
||||
// Insert the property
|
||||
let id = insertProperty.call({creatureProperty, parentRef});
|
||||
return `tree-node-${id}`;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -279,6 +279,7 @@
|
||||
pointer-events: initial;
|
||||
z-index: 1;
|
||||
overflow: hidden;
|
||||
transition: all .3s ease;
|
||||
}
|
||||
.dialog > * {
|
||||
height: 100%;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import Vue from 'vue';
|
||||
|
||||
let dialogStack = {};
|
||||
dialogStack.dialogs = [];
|
||||
|
||||
@@ -25,7 +27,7 @@ const dialogStackStore = {
|
||||
if (!state.dialogs.length){
|
||||
throw new Meteor.Error('can\'t replace dialog if no dialogs are open');
|
||||
}
|
||||
state.dialogs.$set(0, {
|
||||
Vue.set(state.dialogs, state.dialogs.length - 1, {
|
||||
_id,
|
||||
component,
|
||||
data,
|
||||
@@ -57,8 +59,24 @@ const dialogStackStore = {
|
||||
} else {
|
||||
context.commit('popDialogStackMutation', result);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
popDialogStacks(context, quantity){
|
||||
if (quantity <= 0) return;
|
||||
let iterationsLeft = quantity;
|
||||
let intervalId = setInterval(() => {
|
||||
if (history && history.state && history.state.openDialogs){
|
||||
context.commit('setCurrentResult');
|
||||
history.back();
|
||||
} else {
|
||||
context.commit('popDialogStackMutation');
|
||||
}
|
||||
iterationsLeft -= 1;
|
||||
if (iterationsLeft === 0){
|
||||
clearInterval(intervalId);
|
||||
}
|
||||
}, 150);
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default dialogStackStore;
|
||||
|
||||
@@ -92,7 +92,7 @@
|
||||
'setTabForCharacterSheet',
|
||||
{id: result, tab: 4}
|
||||
);
|
||||
this.$store.commit('setShowBuildDialog', true);
|
||||
this.$store.commit('setShowDetailsDialog', true);
|
||||
this.$router.push({ path: `/character/${result}`});
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1,12 +1,19 @@
|
||||
<template>
|
||||
<div>
|
||||
<v-layout
|
||||
align-center
|
||||
justify-center
|
||||
>
|
||||
<h1>
|
||||
No page was found for this address
|
||||
</h1>
|
||||
</v-layout>
|
||||
</div>
|
||||
<v-layout
|
||||
style="height: 100%;"
|
||||
column
|
||||
align-center
|
||||
justify-center
|
||||
>
|
||||
<h1 class="text-h1">
|
||||
404
|
||||
</h1>
|
||||
<h1 class="ma-4 text-h3">
|
||||
No page was found for this address
|
||||
</h1>
|
||||
</v-layout>
|
||||
</template>
|
||||
|
||||
<script lang="js">
|
||||
export default {}
|
||||
</script>
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
type="text"
|
||||
label="Email"
|
||||
:rules="emailRules"
|
||||
class="ma-2"
|
||||
outlined
|
||||
required
|
||||
@keyup.enter="submit"
|
||||
/>
|
||||
@@ -26,6 +28,8 @@
|
||||
type="text"
|
||||
label="Username"
|
||||
:rules="usernameRules"
|
||||
class="ma-2"
|
||||
outlined
|
||||
required
|
||||
@keyup.enter="submit"
|
||||
/>
|
||||
@@ -34,6 +38,8 @@
|
||||
type="password"
|
||||
label="Password"
|
||||
:rules="passwordRules"
|
||||
class="ma-2"
|
||||
outlined
|
||||
required
|
||||
@keyup.enter="submit"
|
||||
/>
|
||||
@@ -42,6 +48,8 @@
|
||||
type="password"
|
||||
label="Password Again"
|
||||
:rules="password2Rules"
|
||||
class="ma-2"
|
||||
outlined
|
||||
required
|
||||
@keyup.enter="submit"
|
||||
/>
|
||||
@@ -78,7 +86,7 @@
|
||||
</template>
|
||||
|
||||
<script lang="js">
|
||||
export default{
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
valid: true,
|
||||
@@ -88,7 +96,7 @@
|
||||
],
|
||||
email: '',
|
||||
emailRules: [
|
||||
v => !!v || 'Name is required',
|
||||
v => !!v || 'E-mail is required',
|
||||
v => /.+@.+/.test(v) || 'E-mail must be valid',
|
||||
],
|
||||
password: '',
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
type="text"
|
||||
label="Username or email"
|
||||
:rules="nameRules"
|
||||
class="ma-2"
|
||||
outlined
|
||||
required
|
||||
@keyup.enter="submit"
|
||||
/>
|
||||
@@ -26,6 +28,8 @@
|
||||
type="password"
|
||||
label="Password"
|
||||
:rules="passwordRules"
|
||||
class="ma-2"
|
||||
outlined
|
||||
required
|
||||
@keyup.enter="submit"
|
||||
/>
|
||||
@@ -39,6 +43,7 @@
|
||||
<v-btn
|
||||
:disabled="!valid"
|
||||
color="accent"
|
||||
class="ma-2"
|
||||
@click="submit"
|
||||
>
|
||||
Sign In
|
||||
@@ -46,6 +51,7 @@
|
||||
<v-btn
|
||||
color="accent"
|
||||
:to="{ name: 'register', query: { redirect: this.$route.query.redirect} }"
|
||||
class="ma-2"
|
||||
>
|
||||
Register
|
||||
</v-btn>
|
||||
@@ -62,6 +68,7 @@
|
||||
</div>
|
||||
<v-btn
|
||||
color="accent"
|
||||
class="ma-2"
|
||||
@click="googleLogin"
|
||||
>
|
||||
Sign in with Google
|
||||
@@ -71,6 +78,7 @@
|
||||
</div>
|
||||
<v-btn
|
||||
color="accent"
|
||||
class="ma-2"
|
||||
@click="patreonLogin"
|
||||
>
|
||||
Sign in with Patreon
|
||||
@@ -80,8 +88,7 @@
|
||||
</template>
|
||||
|
||||
<script lang="js">
|
||||
import { Meteor } from 'meteor/meteor'
|
||||
export default{
|
||||
export default {
|
||||
data: () => ({
|
||||
valid: true,
|
||||
name: '',
|
||||
|
||||
@@ -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',
|
||||
removed: {$ne: true},
|
||||
inactive: {$ne: true},
|
||||
overridden: {$ne: true},
|
||||
};
|
||||
if (creature.settings.hideUnusedStats){
|
||||
filter.hide = {$ne: true};
|
||||
|
||||
@@ -52,7 +52,9 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
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';
|
||||
} else if (this.model.proficiency == 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>
|
||||
@@ -22,7 +22,9 @@
|
||||
<script lang="js">
|
||||
const ICON_SPIN_DURATION = 300;
|
||||
let proficiencyIcon = function(value){
|
||||
if (value == 0.5){
|
||||
if (value == 0.49){
|
||||
return 'brightness_3';
|
||||
} else if (value == 0.5){
|
||||
return 'brightness_2';
|
||||
} else if (value == 1) {
|
||||
return 'brightness_1'
|
||||
@@ -49,7 +51,8 @@
|
||||
iconClass: '',
|
||||
values: [
|
||||
{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'},
|
||||
],
|
||||
}},
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
class="step-1"
|
||||
>
|
||||
<v-toolbar-title slot="toolbar">
|
||||
Add Library Content
|
||||
Property Type
|
||||
</v-toolbar-title>
|
||||
<property-selector
|
||||
slot="unwrapped-content"
|
||||
|
||||
@@ -43,27 +43,30 @@
|
||||
:calculations="model.descriptionCalculations"
|
||||
:inactive="model.inactive"
|
||||
/>
|
||||
|
||||
<effect-viewer
|
||||
v-if="context.creatureId && model.baseValueCalculation"
|
||||
:model="{
|
||||
name: 'Base value',
|
||||
result: model.baseValue,
|
||||
operation: 'base'
|
||||
}"
|
||||
/>
|
||||
<effect-viewer
|
||||
v-for="effect in effects"
|
||||
:key="effect._id"
|
||||
:model="effect"
|
||||
/>
|
||||
<v-list>
|
||||
<attribute-effect
|
||||
v-for="effect in baseEffects"
|
||||
:key="effect._id"
|
||||
:model="effect"
|
||||
:hide-breadcrumbs="effect._id === model._id"
|
||||
:data-id="effect._id"
|
||||
@click="effect._id !== model._id && clickEffect(effect._id)"
|
||||
/>
|
||||
<attribute-effect
|
||||
v-for="effect in effects"
|
||||
:key="effect._id"
|
||||
:model="effect"
|
||||
:data-id="effect._id"
|
||||
@click="clickEffect(effect._id)"
|
||||
/>
|
||||
</v-list>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="js">
|
||||
import propertyViewerMixin from '/imports/ui/properties/viewers/shared/propertyViewerMixin.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';
|
||||
|
||||
export default {
|
||||
@@ -71,7 +74,7 @@
|
||||
context: { default: {} }
|
||||
},
|
||||
components: {
|
||||
EffectViewer,
|
||||
AttributeEffect,
|
||||
},
|
||||
mixins: [propertyViewerMixin],
|
||||
computed: {
|
||||
@@ -87,8 +90,37 @@
|
||||
},
|
||||
methods: {
|
||||
numberToSignedString,
|
||||
clickEffect(id){
|
||||
this.$store.commit('pushDialogStack', {
|
||||
component: 'creature-property-dialog',
|
||||
elementId: `${id}`,
|
||||
data: {_id: id},
|
||||
});
|
||||
},
|
||||
},
|
||||
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(){
|
||||
if (this.context.creatureId){
|
||||
let creatureId = this.context.creatureId;
|
||||
|
||||
@@ -17,19 +17,19 @@
|
||||
import propertyViewerMixin from '/imports/ui/properties/viewers/shared/propertyViewerMixin.js';
|
||||
import ProficiencyIcon from '/imports/ui/properties/shared/ProficiencyIcon.vue';
|
||||
export default {
|
||||
components: {
|
||||
ProficiencyIcon,
|
||||
},
|
||||
mixins: [propertyViewerMixin],
|
||||
computed: {
|
||||
proficiencyText(){
|
||||
switch (this.model.value){
|
||||
case 0.5: return 'Half proficiency bonus';
|
||||
case 1: return 'Proficient';
|
||||
case 2: return 'Double proficiency bonus';
|
||||
components: {
|
||||
ProficiencyIcon,
|
||||
},
|
||||
mixins: [propertyViewerMixin],
|
||||
computed: {
|
||||
proficiencyText(){
|
||||
switch (this.model.value){
|
||||
case 0.5: return 'Half proficiency bonus';
|
||||
case 1: return 'Proficient';
|
||||
case 2: return 'Double proficiency bonus';
|
||||
default: return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -40,18 +40,44 @@
|
||||
:inactive="model.inactive"
|
||||
/>
|
||||
|
||||
<effect-viewer
|
||||
v-if="context.creatureId && model.baseValue"
|
||||
:model="{
|
||||
name: 'Base value',
|
||||
result: model.baseValue,
|
||||
operation: 'base'
|
||||
}"
|
||||
<attribute-effect
|
||||
v-for="effect in baseEffects"
|
||||
:key="effect._id"
|
||||
:model="effect"
|
||||
:hide-breadcrumbs="effect._id === model._id"
|
||||
: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"
|
||||
:key="effect._id"
|
||||
: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>
|
||||
</template>
|
||||
@@ -60,11 +86,14 @@
|
||||
import propertyViewerMixin from '/imports/ui/properties/viewers/shared/propertyViewerMixin.js';
|
||||
import numberToSignedString from '/imports/ui/utility/numberToSignedString.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 {
|
||||
components: {
|
||||
EffectViewer,
|
||||
AttributeEffect,
|
||||
SkillProficiency,
|
||||
},
|
||||
mixins: [propertyViewerMixin],
|
||||
inject: {
|
||||
@@ -80,7 +109,9 @@ export default {
|
||||
}
|
||||
},
|
||||
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';
|
||||
} else if (this.model.proficiency == 1) {
|
||||
return 'brightness_1'
|
||||
@@ -94,8 +125,37 @@ export default {
|
||||
methods: {
|
||||
numberToSignedString,
|
||||
isFinite: Number.isFinite,
|
||||
clickEffect(id){
|
||||
this.$store.commit('pushDialogStack', {
|
||||
component: 'creature-property-dialog',
|
||||
elementId: `${id}`,
|
||||
data: {_id: id},
|
||||
});
|
||||
},
|
||||
},
|
||||
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(){
|
||||
if (this.context.creatureId){
|
||||
let creatureId = this.context.creatureId;
|
||||
@@ -109,6 +169,70 @@ export default {
|
||||
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>
|
||||
|
||||
@@ -13,7 +13,7 @@ const store = new Vuex.Store({
|
||||
rightDrawer: undefined,
|
||||
pageTitle: undefined,
|
||||
characterSheetTabs: {},
|
||||
showBuildDialog: false,
|
||||
showDetailsDialog: false,
|
||||
},
|
||||
getters: {
|
||||
// ...
|
||||
@@ -45,8 +45,8 @@ const store = new Vuex.Store({
|
||||
setTabForCharacterSheet(state, {tab, id}){
|
||||
Vue.set(state.characterSheetTabs, id, tab);
|
||||
},
|
||||
setShowBuildDialog(state, value){
|
||||
state.showBuildDialog = value;
|
||||
setShowDetailsDialog(state, value){
|
||||
state.showDetailsDialog = value;
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user