Compare commits
22 Commits
2.0-beta.7
...
2.0-beta.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9b01f5fb45 | ||
|
|
389785f5db | ||
|
|
e1bfb173ab | ||
|
|
ecba587253 | ||
|
|
3f540d0f14 | ||
|
|
dc18734d1f | ||
|
|
1535e00093 | ||
|
|
5198c655e9 | ||
|
|
8d41643136 | ||
|
|
ea8d036c72 | ||
|
|
93d566e263 | ||
|
|
b4da32f9ab | ||
|
|
986fe8fd93 | ||
|
|
dd4596851e | ||
|
|
bc3fc9574a | ||
|
|
db1ae5db3d | ||
|
|
d1e7eb2fa0 | ||
|
|
efb8b87a2d | ||
|
|
b04b915c7b | ||
|
|
21b823f85c | ||
|
|
4631579181 | ||
|
|
edf3920e84 |
@@ -50,3 +50,5 @@ akryum:vue-component
|
|||||||
accounts-patreon
|
accounts-patreon
|
||||||
bozhao:link-accounts
|
bozhao:link-accounts
|
||||||
peerlibrary:reactive-publish
|
peerlibrary:reactive-publish
|
||||||
|
simple:rest
|
||||||
|
simple:rest-method-mixin
|
||||||
|
|||||||
@@ -115,6 +115,9 @@ service-configuration@1.0.11
|
|||||||
session@1.2.0
|
session@1.2.0
|
||||||
sha@1.0.9
|
sha@1.0.9
|
||||||
shell-server@0.5.0
|
shell-server@0.5.0
|
||||||
|
simple:json-routes@2.1.0
|
||||||
|
simple:rest@1.1.1
|
||||||
|
simple:rest-method-mixin@1.0.1
|
||||||
socket-stream-client@0.3.0
|
socket-stream-client@0.3.0
|
||||||
spacebars@1.0.15
|
spacebars@1.0.15
|
||||||
spacebars-compiler@1.1.3
|
spacebars-compiler@1.1.3
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { Meteor } from 'meteor/meteor';
|
import { Meteor } from 'meteor/meteor';
|
||||||
import { Mongo } from 'meteor/mongo';
|
import { Mongo } from 'meteor/mongo';
|
||||||
|
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
||||||
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
import ColorSchema from '/imports/api/properties/subSchemas/ColorSchema.js';
|
import ColorSchema from '/imports/api/properties/subSchemas/ColorSchema.js';
|
||||||
@@ -19,6 +20,8 @@ import {
|
|||||||
import {setDocToLastOrder} from '/imports/api/parenting/order.js';
|
import {setDocToLastOrder} from '/imports/api/parenting/order.js';
|
||||||
import { storedIconsSchema } from '/imports/api/icons/Icons.js';
|
import { storedIconsSchema } from '/imports/api/icons/Icons.js';
|
||||||
|
|
||||||
|
import '/imports/api/creature/actions/doAction.js';
|
||||||
|
|
||||||
let CreatureProperties = new Mongo.Collection('creatureProperties');
|
let CreatureProperties = new Mongo.Collection('creatureProperties');
|
||||||
|
|
||||||
let CreaturePropertySchema = new SimpleSchema({
|
let CreaturePropertySchema = new SimpleSchema({
|
||||||
@@ -55,7 +58,7 @@ for (let key in propertySchemasIndex){
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCreature(property){
|
export function getCreature(property){
|
||||||
if (!property) throw new Meteor.Error('No property provided');
|
if (!property) throw new Meteor.Error('No property provided');
|
||||||
let creature = Creatures.findOne(property.ancestors[0].id);
|
let creature = Creatures.findOne(property.ancestors[0].id);
|
||||||
if (!creature) throw new Meteor.Error('Creature does not exist');
|
if (!creature) throw new Meteor.Error('Creature does not exist');
|
||||||
@@ -76,8 +79,13 @@ function recomputeCreatures(property){
|
|||||||
}
|
}
|
||||||
|
|
||||||
const insertProperty = new ValidatedMethod({
|
const insertProperty = new ValidatedMethod({
|
||||||
name: 'CreatureProperties.methods.insert',
|
name: 'creatureProperties.insert',
|
||||||
validate: null,
|
validate: null,
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
run({creatureProperty}) {
|
run({creatureProperty}) {
|
||||||
delete creatureProperty._id;
|
delete creatureProperty._id;
|
||||||
assertPropertyEditPermission(creatureProperty, this.userId);
|
assertPropertyEditPermission(creatureProperty, this.userId);
|
||||||
@@ -88,13 +96,18 @@ const insertProperty = new ValidatedMethod({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const duplicateProperty = new ValidatedMethod({
|
const duplicateProperty = new ValidatedMethod({
|
||||||
name: 'CreatureProperties.methods.duplicate',
|
name: 'creatureProperties.duplicate',
|
||||||
validate: new SimpleSchema({
|
validate: new SimpleSchema({
|
||||||
_id: {
|
_id: {
|
||||||
type: String,
|
type: String,
|
||||||
regEx: SimpleSchema.RegEx.Id,
|
regEx: SimpleSchema.RegEx.Id,
|
||||||
}
|
}
|
||||||
}).validator(),
|
}).validator(),
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
run({_id}) {
|
run({_id}) {
|
||||||
let creatureProperty = CreatureProperties.findOne(_id);
|
let creatureProperty = CreatureProperties.findOne(_id);
|
||||||
assertPropertyEditPermission(creatureProperty, this.userId);
|
assertPropertyEditPermission(creatureProperty, this.userId);
|
||||||
@@ -105,7 +118,7 @@ const duplicateProperty = new ValidatedMethod({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const insertPropertyFromLibraryNode = new ValidatedMethod({
|
const insertPropertyFromLibraryNode = new ValidatedMethod({
|
||||||
name: 'CreatureProperties.methods.insertPropertyFromLibraryNode',
|
name: 'creatureProperties.insertPropertyFromLibraryNode',
|
||||||
validate: new SimpleSchema({
|
validate: new SimpleSchema({
|
||||||
nodeId: {
|
nodeId: {
|
||||||
type: String,
|
type: String,
|
||||||
@@ -115,6 +128,11 @@ const insertPropertyFromLibraryNode = new ValidatedMethod({
|
|||||||
type: RefSchema,
|
type: RefSchema,
|
||||||
},
|
},
|
||||||
}).validator(),
|
}).validator(),
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
run({nodeId, parentRef}) {
|
run({nodeId, parentRef}) {
|
||||||
// get the new ancestry for the properties
|
// get the new ancestry for the properties
|
||||||
let {parentDoc, ancestors} = getAncestry({parentRef});
|
let {parentDoc, ancestors} = getAncestry({parentRef});
|
||||||
@@ -178,7 +196,7 @@ const insertPropertyFromLibraryNode = new ValidatedMethod({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const updateProperty = new ValidatedMethod({
|
const updateProperty = new ValidatedMethod({
|
||||||
name: 'CreatureProperties.methods.update',
|
name: 'creatureProperties.update',
|
||||||
validate({_id, path}){
|
validate({_id, path}){
|
||||||
if (!_id) return false;
|
if (!_id) return false;
|
||||||
// We cannot change these fields with a simple update
|
// We cannot change these fields with a simple update
|
||||||
@@ -192,6 +210,11 @@ const updateProperty = new ValidatedMethod({
|
|||||||
'This property can\'t be updated directly');
|
'This property can\'t be updated directly');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
run({_id, path, value}) {
|
run({_id, path, value}) {
|
||||||
let property = CreatureProperties.findOne(_id);
|
let property = CreatureProperties.findOne(_id);
|
||||||
assertPropertyEditPermission(property, this.userId);
|
assertPropertyEditPermission(property, this.userId);
|
||||||
@@ -210,8 +233,39 @@ const updateProperty = new ValidatedMethod({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export function damagePropertyWork({property, operation, value}){
|
||||||
|
if (operation === 'set'){
|
||||||
|
let currentValue = property.value;
|
||||||
|
// Set represents what we want the value to be after damage
|
||||||
|
// So we need the actual damage to get to that value
|
||||||
|
let damage = currentValue - value;
|
||||||
|
// Damage can't exceed total value
|
||||||
|
if (damage > currentValue) damage = currentValue;
|
||||||
|
// Damage must be positive
|
||||||
|
if (damage < 0) damage = 0;
|
||||||
|
CreatureProperties.update(property._id, {
|
||||||
|
$set: {damage}
|
||||||
|
}, {
|
||||||
|
selector: property
|
||||||
|
});
|
||||||
|
} else if (operation === 'increment'){
|
||||||
|
let currentValue = property.value - (property.damage || 0);
|
||||||
|
let currentDamage = property.damage;
|
||||||
|
let increment = value;
|
||||||
|
// Can't increase damage above the remaining value
|
||||||
|
if (increment > currentValue) increment = currentValue;
|
||||||
|
// Can't decrease damage below zero
|
||||||
|
if (-increment > currentDamage) increment = -currentDamage;
|
||||||
|
CreatureProperties.update(property._id, {
|
||||||
|
$inc: {damage: increment}
|
||||||
|
}, {
|
||||||
|
selector: property
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const damageProperty = new ValidatedMethod({
|
const damageProperty = new ValidatedMethod({
|
||||||
name: 'CreatureProperties.methods.adjust',
|
name: 'creatureProperties.damage',
|
||||||
validate: new SimpleSchema({
|
validate: new SimpleSchema({
|
||||||
_id: SimpleSchema.RegEx.Id,
|
_id: SimpleSchema.RegEx.Id,
|
||||||
operation: {
|
operation: {
|
||||||
@@ -220,6 +274,11 @@ const damageProperty = new ValidatedMethod({
|
|||||||
},
|
},
|
||||||
value: Number,
|
value: Number,
|
||||||
}).validator(),
|
}).validator(),
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 20,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
run({_id, operation, value}) {
|
run({_id, operation, value}) {
|
||||||
let currentProperty = CreatureProperties.findOne(_id);
|
let currentProperty = CreatureProperties.findOne(_id);
|
||||||
// Check permissions
|
// Check permissions
|
||||||
@@ -232,40 +291,41 @@ const damageProperty = new ValidatedMethod({
|
|||||||
`Property of type "${currentProperty.type}" can't be damaged`
|
`Property of type "${currentProperty.type}" can't be damaged`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (operation === 'set'){
|
damagePropertyWork({property: currentProperty, operation, value})
|
||||||
let currentValue = currentProperty.value;
|
|
||||||
// Set represents what we want the value to be after damage
|
|
||||||
// So we need the actual damage to get to that value
|
|
||||||
let damage = currentValue - value;
|
|
||||||
// Damage can't exceed total value
|
|
||||||
if (damage > currentValue) damage = currentValue;
|
|
||||||
// Damage must be positive
|
|
||||||
if (damage < 0) damage = 0;
|
|
||||||
CreatureProperties.update(_id, {
|
|
||||||
$set: {damage}
|
|
||||||
}, {
|
|
||||||
selector: currentProperty
|
|
||||||
});
|
|
||||||
} else if (operation === 'increment'){
|
|
||||||
let currentValue = currentProperty.value - (currentProperty.damage || 0);
|
|
||||||
let currentDamage = currentProperty.damage;
|
|
||||||
let increment = value;
|
|
||||||
// Can't increase damage above the remaining value
|
|
||||||
if (increment > currentValue) increment = currentValue;
|
|
||||||
// Can't decrease damage below zero
|
|
||||||
if (-increment > currentDamage) increment = -currentDamage;
|
|
||||||
CreatureProperties.update(_id, {
|
|
||||||
$inc: {damage: increment}
|
|
||||||
}, {
|
|
||||||
selector: currentProperty
|
|
||||||
});
|
|
||||||
}
|
|
||||||
recomputeCreatures(currentProperty);
|
recomputeCreatures(currentProperty);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export function adjustQuantityWork({property, operation, value}){
|
||||||
|
// Check if property has quantity
|
||||||
|
let schema = CreatureProperties.simpleSchema(property);
|
||||||
|
if (!schema.allowsKey('quantity')){
|
||||||
|
throw new Meteor.Error(
|
||||||
|
'Adjust quantity failed',
|
||||||
|
`Property of type "${property.type}" doesn't have a quantity`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (operation === 'set'){
|
||||||
|
CreatureProperties.update(property._id, {
|
||||||
|
$set: {quantity: value}
|
||||||
|
}, {
|
||||||
|
selector: property
|
||||||
|
});
|
||||||
|
} else if (operation === 'increment'){
|
||||||
|
// value here is 'damage'
|
||||||
|
value = -value;
|
||||||
|
let currentQuantity = property.quantity;
|
||||||
|
if (currentQuantity + value < 0) value = -currentQuantity;
|
||||||
|
CreatureProperties.update(property._id, {
|
||||||
|
$inc: {quantity: value}
|
||||||
|
}, {
|
||||||
|
selector: property
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const adjustQuantity = new ValidatedMethod({
|
const adjustQuantity = new ValidatedMethod({
|
||||||
name: 'CreatureProperties.methods.adjustQuantity',
|
name: 'creatureProperties.adjustQuantity',
|
||||||
validate: new SimpleSchema({
|
validate: new SimpleSchema({
|
||||||
_id: SimpleSchema.RegEx.Id,
|
_id: SimpleSchema.RegEx.Id,
|
||||||
operation: {
|
operation: {
|
||||||
@@ -274,41 +334,65 @@ const adjustQuantity = new ValidatedMethod({
|
|||||||
},
|
},
|
||||||
value: Number,
|
value: Number,
|
||||||
}).validator(),
|
}).validator(),
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
run({_id, operation, value}) {
|
run({_id, operation, value}) {
|
||||||
let currentProperty = CreatureProperties.findOne(_id);
|
let currentProperty = CreatureProperties.findOne(_id);
|
||||||
// Check permissions
|
// Check permissions
|
||||||
assertPropertyEditPermission(currentProperty, this.userId);
|
assertPropertyEditPermission(currentProperty, this.userId);
|
||||||
// Check if property can take damage
|
adjustQuantityWork({property: currentProperty, operation, value});
|
||||||
let schema = CreatureProperties.simpleSchema(currentProperty);
|
recomputeCreatures(currentProperty);
|
||||||
if (!schema.allowsKey('quantity')){
|
},
|
||||||
throw new Meteor.Error(
|
});
|
||||||
'Adjust quantity failed',
|
|
||||||
`Property of type "${currentProperty.type}" doesn't have a quantity`
|
const selectAmmoItem = new ValidatedMethod({
|
||||||
);
|
name: 'creatureProperties.selectAmmoItem',
|
||||||
}
|
validate: new SimpleSchema({
|
||||||
if (operation === 'set'){
|
actionId: SimpleSchema.RegEx.Id,
|
||||||
CreatureProperties.update(_id, {
|
itemId: SimpleSchema.RegEx.Id,
|
||||||
$set: {quantity: value}
|
itemConsumedIndex: Number,
|
||||||
}, {
|
}).validator(),
|
||||||
selector: currentProperty
|
mixins: [RateLimiterMixin],
|
||||||
});
|
rateLimit: {
|
||||||
} else if (operation === 'increment'){
|
numRequests: 5,
|
||||||
// value here is 'damage'
|
timeInterval: 5000,
|
||||||
value = -value;
|
},
|
||||||
let currentQuantity = currentProperty.quantity;
|
run({actionId, itemId, itemConsumedIndex}) {
|
||||||
if (currentQuantity + value < 0) value = -currentQuantity;
|
let action = CreatureProperties.findOne(actionId);
|
||||||
CreatureProperties.update(_id, {
|
// Check permissions
|
||||||
$inc: {quantity: value}
|
assertPropertyEditPermission(action, this.userId);
|
||||||
}, {
|
// Check that this index has a document to edit
|
||||||
selector: currentProperty
|
let itemConsumed = action.resources.itemsConsumed[itemConsumedIndex];
|
||||||
});
|
if (!itemConsumed){
|
||||||
}
|
throw new Meteor.Error('Resouce not found',
|
||||||
|
'Could not set ammo, because the ammo document was not found');
|
||||||
|
}
|
||||||
|
let itemToLink = CreatureProperties.findOne(itemId);
|
||||||
|
if (!itemToLink){
|
||||||
|
throw new Meteor.Error('Item not found',
|
||||||
|
'Could not set ammo: the item was not found');
|
||||||
|
}
|
||||||
|
let path = `resources.itemsConsumed.${itemConsumedIndex}.itemId`;
|
||||||
|
CreatureProperties.update(actionId, {
|
||||||
|
$set: {[path]: itemId}
|
||||||
|
}, {
|
||||||
|
selector: action,
|
||||||
|
});
|
||||||
|
recomputeCreatures(action);
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const pushToProperty = new ValidatedMethod({
|
const pushToProperty = new ValidatedMethod({
|
||||||
name: 'CreatureProperties.methods.push',
|
name: 'creatureProperties.push',
|
||||||
validate: null,
|
validate: null,
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
run({_id, path, value}){
|
run({_id, path, value}){
|
||||||
let property = CreatureProperties.findOne(_id);
|
let property = CreatureProperties.findOne(_id);
|
||||||
assertPropertyEditPermission(property, this.userId);
|
assertPropertyEditPermission(property, this.userId);
|
||||||
@@ -322,8 +406,13 @@ const pushToProperty = new ValidatedMethod({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const pullFromProperty = new ValidatedMethod({
|
const pullFromProperty = new ValidatedMethod({
|
||||||
name: 'CreatureProperties.methods.pull',
|
name: 'creatureProperties.pull',
|
||||||
validate: null,
|
validate: null,
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
run({_id, path, itemId}){
|
run({_id, path, itemId}){
|
||||||
let property = CreatureProperties.findOne(_id);
|
let property = CreatureProperties.findOne(_id);
|
||||||
assertPropertyEditPermission(property, this.userId);
|
assertPropertyEditPermission(property, this.userId);
|
||||||
@@ -338,10 +427,15 @@ const pullFromProperty = new ValidatedMethod({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const softRemoveProperty = new ValidatedMethod({
|
const softRemoveProperty = new ValidatedMethod({
|
||||||
name: 'CreatureProperties.methods.softRemove',
|
name: 'creatureProperties.softRemove',
|
||||||
validate: new SimpleSchema({
|
validate: new SimpleSchema({
|
||||||
_id: SimpleSchema.RegEx.Id
|
_id: SimpleSchema.RegEx.Id
|
||||||
}).validator(),
|
}).validator(),
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
run({_id}){
|
run({_id}){
|
||||||
let property = CreatureProperties.findOne(_id);
|
let property = CreatureProperties.findOne(_id);
|
||||||
assertPropertyEditPermission(property, this.userId);
|
assertPropertyEditPermission(property, this.userId);
|
||||||
@@ -360,6 +454,7 @@ export {
|
|||||||
updateProperty,
|
updateProperty,
|
||||||
damageProperty,
|
damageProperty,
|
||||||
adjustQuantity,
|
adjustQuantity,
|
||||||
|
selectAmmoItem,
|
||||||
pushToProperty,
|
pushToProperty,
|
||||||
pullFromProperty,
|
pullFromProperty,
|
||||||
softRemoveProperty,
|
softRemoveProperty,
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
||||||
|
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
import deathSaveSchema from '/imports/api/properties/subSchemas/DeathSavesSchema.js'
|
import deathSaveSchema from '/imports/api/properties/subSchemas/DeathSavesSchema.js'
|
||||||
import ColorSchema from '/imports/api/properties/subSchemas/ColorSchema.js';
|
import ColorSchema from '/imports/api/properties/subSchemas/ColorSchema.js';
|
||||||
@@ -65,24 +66,31 @@ let CreatureSchema = new SimpleSchema({
|
|||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
// Mechanics
|
// Mechanics
|
||||||
deathSave: {
|
deathSave: {
|
||||||
type: deathSaveSchema,
|
type: deathSaveSchema,
|
||||||
defaultValue: {},
|
defaultValue: {},
|
||||||
},
|
},
|
||||||
xp: {
|
// Stats that are computed and denormalised outside of recomputation
|
||||||
|
denormalizedStats: {
|
||||||
|
type: Object,
|
||||||
|
defaultValue: {},
|
||||||
|
},
|
||||||
|
// Sum of all XP gained by this character
|
||||||
|
'denormalizedStats.xp': {
|
||||||
type: SimpleSchema.Integer,
|
type: SimpleSchema.Integer,
|
||||||
defaultValue: 0,
|
defaultValue: 0,
|
||||||
},
|
},
|
||||||
weightCarried: {
|
// Sum of all levels granted by milestone XP
|
||||||
|
'denormalizedStats.milestoneLevels': {
|
||||||
|
type: SimpleSchema.Integer,
|
||||||
|
defaultValue: 0,
|
||||||
|
},
|
||||||
|
// Sum of all weights of items and containers that are carried
|
||||||
|
'denormalizedStats.weightCarried': {
|
||||||
type: Number,
|
type: Number,
|
||||||
defaultValue: 0,
|
defaultValue: 0,
|
||||||
},
|
},
|
||||||
level: {
|
|
||||||
type: SimpleSchema.Integer,
|
|
||||||
defaultValue: 0,
|
|
||||||
},
|
|
||||||
type: {
|
type: {
|
||||||
type: String,
|
type: String,
|
||||||
defaultValue: 'pc',
|
defaultValue: 'pc',
|
||||||
@@ -113,10 +121,16 @@ Creatures.attachSchema(CreatureSchema);
|
|||||||
|
|
||||||
const insertCreature = new ValidatedMethod({
|
const insertCreature = new ValidatedMethod({
|
||||||
|
|
||||||
name: 'Creatures.methods.insertCreature',
|
name: 'creatures.insertCreature',
|
||||||
|
|
||||||
validate: null,
|
validate: null,
|
||||||
|
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
|
|
||||||
run() {
|
run() {
|
||||||
if (!this.userId) {
|
if (!this.userId) {
|
||||||
throw new Meteor.Error('Creatures.methods.insert.denied',
|
throw new Meteor.Error('Creatures.methods.insert.denied',
|
||||||
@@ -139,22 +153,41 @@ const insertCreature = new ValidatedMethod({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const updateCreature = new ValidatedMethod({
|
const updateCreature = new ValidatedMethod({
|
||||||
name: 'Creatures.methods.update',
|
name: 'creatures.update',
|
||||||
validate({_id, path}){
|
validate({_id, path}){
|
||||||
if (!_id) return false;
|
if (!_id) return false;
|
||||||
// Allowed fields
|
// Allowed fields
|
||||||
let allowedFields = ['name', 'alignment', 'gender', 'picture', 'avatarPicture', 'settings'];
|
let allowedFields = [
|
||||||
|
'name',
|
||||||
|
'alignment',
|
||||||
|
'gender',
|
||||||
|
'picture',
|
||||||
|
'avatarPicture',
|
||||||
|
'color',
|
||||||
|
'settings',
|
||||||
|
];
|
||||||
if (!allowedFields.includes(path[0])){
|
if (!allowedFields.includes(path[0])){
|
||||||
throw new Meteor.Error('Creatures.methods.update.denied',
|
throw new Meteor.Error('Creatures.methods.update.denied',
|
||||||
'This field can\'t be updated using this method');
|
'This field can\'t be updated using this method');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
run({_id, path, value}) {
|
run({_id, path, value}) {
|
||||||
let creature = Creatures.findOne(_id);
|
let creature = Creatures.findOne(_id);
|
||||||
assertEditPermission(creature, this.userId);
|
assertEditPermission(creature, this.userId);
|
||||||
Creatures.update(_id, {
|
if (value === undefined || value === null){
|
||||||
$set: {[path.join('.')]: value},
|
Creatures.update(_id, {
|
||||||
});
|
$unset: {[path.join('.')]: 1},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Creatures.update(_id, {
|
||||||
|
$set: {[path.join('.')]: value},
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
89
app/imports/api/creature/actions/doAction.js
Normal file
89
app/imports/api/creature/actions/doAction.js
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
import SimpleSchema from 'simpl-schema';
|
||||||
|
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
||||||
|
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
||||||
|
import CreatureProperties, { getCreature, damagePropertyWork, adjustQuantityWork } from '/imports/api/creature/CreatureProperties.js';
|
||||||
|
import { assertEditPermission } from '/imports/api/creature/creaturePermissions.js';
|
||||||
|
import { recomputeCreatureByDoc } from '/imports/api/creature/computation/recomputeCreature.js';
|
||||||
|
|
||||||
|
const doAction = new ValidatedMethod({
|
||||||
|
name: 'creatureProperties.doAction',
|
||||||
|
validate: new SimpleSchema({
|
||||||
|
actionId: SimpleSchema.RegEx.Id,
|
||||||
|
}).validator(),
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 10,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
|
run({actionId}) {
|
||||||
|
let action = CreatureProperties.findOne(actionId);
|
||||||
|
// Check permissions
|
||||||
|
let creature = getCreature(action);
|
||||||
|
assertEditPermission(creature, this.userId);
|
||||||
|
doActionWork(action);
|
||||||
|
// Note this only recomputes the top-level creature, not the nearest one
|
||||||
|
recomputeCreatureByDoc(creature);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
function doActionWork(action){
|
||||||
|
spendResources(action);
|
||||||
|
}
|
||||||
|
|
||||||
|
function spendResources(action){
|
||||||
|
// Check Uses
|
||||||
|
if (action.usesUsed >= action.usesResult){
|
||||||
|
throw new Meteor.Error('Insufficient Uses',
|
||||||
|
'This action has no uses left');
|
||||||
|
}
|
||||||
|
// Resources
|
||||||
|
if (action.insufficientResources){
|
||||||
|
throw new Meteor.Error('Insufficient Resources',
|
||||||
|
'This creature doesn\'t have sufficient resources to perform this action');
|
||||||
|
}
|
||||||
|
// Items
|
||||||
|
let itemQuantityAdjustments = [];
|
||||||
|
action.resources.itemsConsumed.forEach(itemConsumed => {
|
||||||
|
if (!itemConsumed.itemId){
|
||||||
|
throw new Meteor.Error('Ammo not selected',
|
||||||
|
'No ammo was selected for this action');
|
||||||
|
}
|
||||||
|
let item = CreatureProperties.findOne(itemConsumed.itemId);
|
||||||
|
if (!item || item.ancestors[0].id !== action.ancestors[0].id){
|
||||||
|
throw new Meteor.Error('Ammo not found',
|
||||||
|
'The action\'s ammo was not found on the creature');
|
||||||
|
}
|
||||||
|
if (!item.equipped){
|
||||||
|
throw new Meteor.Error('Ammo not equipped',
|
||||||
|
'The selected ammo is not equipped');
|
||||||
|
}
|
||||||
|
if (!itemConsumed.quantity) return;
|
||||||
|
itemQuantityAdjustments.push({
|
||||||
|
property: item,
|
||||||
|
operation: 'increment',
|
||||||
|
value: itemConsumed.quantity,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
// No more errors should be thrown after this line
|
||||||
|
// Now that we have confirmed that there are no errors, do actual work
|
||||||
|
//Items
|
||||||
|
itemQuantityAdjustments.forEach(adjustQuantityWork);
|
||||||
|
// Use uses
|
||||||
|
CreatureProperties.update(action._id, {
|
||||||
|
$inc: {usesUsed: 1}
|
||||||
|
}, {
|
||||||
|
selector: action
|
||||||
|
});
|
||||||
|
// Damage stats
|
||||||
|
action.resources.attributesConsumed.forEach(attConsumed => {
|
||||||
|
if (!attConsumed.quantity) return;
|
||||||
|
let stat = CreatureProperties.findOne(attConsumed.statId);
|
||||||
|
damagePropertyWork({
|
||||||
|
property: stat,
|
||||||
|
operation: 'increment',
|
||||||
|
value: attConsumed.quantity,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export default doAction;
|
||||||
@@ -3,7 +3,7 @@ import { includes, cloneDeep } from 'lodash';
|
|||||||
// The computation memo is an in-memory data structure used only during the
|
// The computation memo is an in-memory data structure used only during the
|
||||||
// computation process
|
// computation process
|
||||||
export default class ComputationMemo {
|
export default class ComputationMemo {
|
||||||
constructor(props){
|
constructor(props, creature){
|
||||||
this.statsByVariableName = {};
|
this.statsByVariableName = {};
|
||||||
this.extraStatsByVariableName = {};
|
this.extraStatsByVariableName = {};
|
||||||
this.statsById = {};
|
this.statsById = {};
|
||||||
@@ -15,6 +15,10 @@ export default class ComputationMemo {
|
|||||||
this.classes = {};
|
this.classes = {};
|
||||||
this.togglesById = {};
|
this.togglesById = {};
|
||||||
this.toggleIds = new Set();
|
this.toggleIds = new Set();
|
||||||
|
// Equipped items that might be used as ammo
|
||||||
|
this.equipmentById = {};
|
||||||
|
// Properties that have calculations, but don't impact other properties
|
||||||
|
this.endStepPropsById = {};
|
||||||
// First note all the ids of all the toggles
|
// First note all the ids of all the toggles
|
||||||
props.forEach((prop) => {
|
props.forEach((prop) => {
|
||||||
if (
|
if (
|
||||||
@@ -38,6 +42,10 @@ export default class ComputationMemo {
|
|||||||
) {
|
) {
|
||||||
// Add all the stats
|
// Add all the stats
|
||||||
this.addStat(prop);
|
this.addStat(prop);
|
||||||
|
} else if (
|
||||||
|
prop.type === 'item'
|
||||||
|
) {
|
||||||
|
this.addEquipment(prop);
|
||||||
} else {
|
} else {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -49,8 +57,19 @@ export default class ComputationMemo {
|
|||||||
this.addProficiency(prop);
|
this.addProficiency(prop);
|
||||||
} else if (prop.type === 'classLevel'){
|
} else if (prop.type === 'classLevel'){
|
||||||
this.addClassLevel(prop);
|
this.addClassLevel(prop);
|
||||||
|
} else {
|
||||||
|
this.addEndStepProp(prop);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
for (let name in creature.denormalizedStats){
|
||||||
|
if (!this.statsByVariableName[name]){
|
||||||
|
this.statsByVariableName[name] = {
|
||||||
|
variableName: name,
|
||||||
|
value: creature.denormalizedStats[name],
|
||||||
|
computationDetails: propDetailsByType.denormalizedStat(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
registerProperty(prop){
|
registerProperty(prop){
|
||||||
this.originalPropsById[prop._id] = cloneDeep(prop);
|
this.originalPropsById[prop._id] = cloneDeep(prop);
|
||||||
@@ -172,6 +191,14 @@ export default class ComputationMemo {
|
|||||||
});
|
});
|
||||||
return targets;
|
return targets;
|
||||||
}
|
}
|
||||||
|
addEquipment(prop){
|
||||||
|
prop = this.registerProperty(prop);
|
||||||
|
this.equipmentById[prop._id] = prop;
|
||||||
|
}
|
||||||
|
addEndStepProp(prop){
|
||||||
|
prop = this.registerProperty(prop);
|
||||||
|
this.endStepPropsById[prop._id] = prop;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function isAbility(prop){
|
function isAbility(prop){
|
||||||
@@ -197,7 +224,7 @@ function isSkillOperation(prop){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function propDetails(prop){
|
function propDetails(prop){
|
||||||
return propDetailsByType[prop.type]() || {};
|
return propDetailsByType[prop.type] && propDetailsByType[prop.type]() || {};
|
||||||
}
|
}
|
||||||
|
|
||||||
const propDetailsByType = {
|
const propDetailsByType = {
|
||||||
@@ -251,4 +278,10 @@ const propDetailsByType = {
|
|||||||
disabledByToggle: false,
|
disabledByToggle: false,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
denormalizedStat(){
|
||||||
|
return {
|
||||||
|
toggleAncestors: [],
|
||||||
|
disabledByToggle: false,
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,96 @@
|
|||||||
|
import evaluateCalculation from '/imports/api/creature/computation/evaluateCalculation.js';
|
||||||
|
|
||||||
|
export default function computeEndStepProperty(prop, memo){
|
||||||
|
switch (prop.type){
|
||||||
|
case 'action':
|
||||||
|
case 'spell':
|
||||||
|
computeAction(prop, memo);
|
||||||
|
break;
|
||||||
|
case 'attack':
|
||||||
|
computeAction(prop, memo);
|
||||||
|
computeAttack(prop, memo);
|
||||||
|
break;
|
||||||
|
case 'savingThrow':
|
||||||
|
computeSavingThrow(prop, memo);
|
||||||
|
break;
|
||||||
|
case 'spellList':
|
||||||
|
computeSpellList(prop, memo);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function computeAction(prop, memo){
|
||||||
|
// Uses
|
||||||
|
let {value, errors} = evaluateCalculation(prop.uses, memo);
|
||||||
|
prop.usesResult = value;
|
||||||
|
if (errors.length){
|
||||||
|
prop.usesErrors = errors;
|
||||||
|
} else {
|
||||||
|
delete prop.usesErrors;
|
||||||
|
}
|
||||||
|
prop.insufficientResources = undefined;
|
||||||
|
if (prop.usesUsed >= prop.usesResult){
|
||||||
|
prop.insufficientResources = true;
|
||||||
|
}
|
||||||
|
// Attributes consumed
|
||||||
|
prop.resources.attributesConsumed.forEach((attConsumed, i) => {
|
||||||
|
if (attConsumed.variableName){
|
||||||
|
let stat = memo.statsByVariableName[attConsumed.variableName];
|
||||||
|
prop.resources.attributesConsumed[i].statId = stat && stat._id;
|
||||||
|
prop.resources.attributesConsumed[i].statName = stat && stat.name;
|
||||||
|
let available = stat && stat.currentValue || 0;
|
||||||
|
prop.resources.attributesConsumed[i].available = available;
|
||||||
|
if (available < attConsumed.quantity){
|
||||||
|
prop.insufficientResources = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
// Items consumed
|
||||||
|
prop.resources.itemsConsumed.forEach((itemConsumed, i) => {
|
||||||
|
let item = itemConsumed.itemId && memo.equipmentById[itemConsumed.itemId];
|
||||||
|
prop.resources.itemsConsumed[i].itemId = item && item._id;
|
||||||
|
let available = item && item.quantity || 0;
|
||||||
|
prop.resources.itemsConsumed[i].available = available;
|
||||||
|
let name = item && item.name;
|
||||||
|
if (item && item.quantity !== 1 && item.plural){
|
||||||
|
name = item.plural;
|
||||||
|
}
|
||||||
|
prop.resources.itemsConsumed[i].itemName = name;
|
||||||
|
prop.resources.itemsConsumed[i].itemIcon = item && item.icon;
|
||||||
|
prop.resources.itemsConsumed[i].itemColor = item && item.color;
|
||||||
|
if (!item || available < itemConsumed.quantity){
|
||||||
|
prop.insufficientResources = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function computeAttack(prop, memo){
|
||||||
|
// Roll bonus
|
||||||
|
let {value, errors} = evaluateCalculation(prop.rollBonus, memo);
|
||||||
|
prop.rollBonusResult = value;
|
||||||
|
if (errors.length){
|
||||||
|
prop.rollBonusErrors = errors;
|
||||||
|
} else {
|
||||||
|
delete prop.rollBonusErrors;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function computeSavingThrow(prop, memo){
|
||||||
|
let {value, errors} = evaluateCalculation(prop.dc, memo);
|
||||||
|
prop.dcResult = value;
|
||||||
|
if (errors.length){
|
||||||
|
prop.dcErrors = errors;
|
||||||
|
} else {
|
||||||
|
delete prop.dcErrors;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function computeSpellList(prop, memo){
|
||||||
|
let {value, errors} = evaluateCalculation(prop.maxPrepared, memo);
|
||||||
|
prop.maxPreparedResult = value;
|
||||||
|
if (errors.length){
|
||||||
|
prop.maxPreparedErrors = errors;
|
||||||
|
} else {
|
||||||
|
delete prop.maxPreparedErrors;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ import computeLevels from '/imports/api/creature/computation/computeLevels.js';
|
|||||||
import computeStat from '/imports/api/creature/computation/computeStat.js';
|
import computeStat from '/imports/api/creature/computation/computeStat.js';
|
||||||
import computeEffect from '/imports/api/creature/computation/computeEffect.js';
|
import computeEffect from '/imports/api/creature/computation/computeEffect.js';
|
||||||
import computeToggle from '/imports/api/creature/computation/computeToggle.js';
|
import computeToggle from '/imports/api/creature/computation/computeToggle.js';
|
||||||
|
import computeEndStepProperty from '/imports/api/creature/computation/computeEndStepProperty.js';
|
||||||
|
|
||||||
export default function computeMemo(memo){
|
export default function computeMemo(memo){
|
||||||
// Compute level
|
// Compute level
|
||||||
@@ -15,8 +16,12 @@ export default function computeMemo(memo){
|
|||||||
each(memo.unassignedEffects, effect => {
|
each(memo.unassignedEffects, effect => {
|
||||||
computeEffect(effect, memo);
|
computeEffect(effect, memo);
|
||||||
});
|
});
|
||||||
|
// Compute toggles which didn't already get computed by dependencies
|
||||||
forOwn(memo.togglesById, toggle => {
|
forOwn(memo.togglesById, toggle => {
|
||||||
computeToggle(toggle, memo);
|
computeToggle(toggle, memo);
|
||||||
});
|
});
|
||||||
// Compute class levels
|
// Compute end step properties
|
||||||
|
forOwn(memo.endStepPropsById, prop => {
|
||||||
|
computeEndStepProperty(prop, memo);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import math from '/imports/math.js';
|
|||||||
|
|
||||||
/* Convert a calculation into a constant output and errors*/
|
/* Convert a calculation into a constant output and errors*/
|
||||||
export default function evaluateCalculation(string, memo){
|
export default function evaluateCalculation(string, memo){
|
||||||
if (!string) return string;
|
if (!string) return {errors: [], value: string};
|
||||||
let errors = [];
|
let errors = [];
|
||||||
// Parse the string using mathjs
|
// Parse the string using mathjs
|
||||||
let calc;
|
let calc;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
||||||
|
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
import { assertEditPermission } from '/imports/api/creature/creaturePermissions.js';
|
import { assertEditPermission } from '/imports/api/creature/creaturePermissions.js';
|
||||||
import ComputationMemo from '/imports/api/creature/computation/ComputationMemo.js';
|
import ComputationMemo from '/imports/api/creature/computation/ComputationMemo.js';
|
||||||
@@ -6,19 +7,27 @@ import computeMemo from '/imports/api/creature/computation/computeMemo.js';
|
|||||||
import getActiveProperties from '/imports/api/creature/getActiveProperties.js';
|
import getActiveProperties from '/imports/api/creature/getActiveProperties.js';
|
||||||
import writeAlteredProperties from '/imports/api/creature/computation/writeAlteredProperties.js';
|
import writeAlteredProperties from '/imports/api/creature/computation/writeAlteredProperties.js';
|
||||||
import writeCreatureVariables from '/imports/api/creature/computation/writeCreatureVariables.js';
|
import writeCreatureVariables from '/imports/api/creature/computation/writeCreatureVariables.js';
|
||||||
import { recomputeDamageMultipliersById } from '/imports/api/creature/damageMultiplierDenormalise/recomputeDamageMultipliers.js'
|
import { recomputeDamageMultipliersById } from '/imports/api/creature/damageMultiplierDenormalise/recomputeDamageMultipliers.js';
|
||||||
|
import Creatures from '/imports/api/creature/Creatures.js';
|
||||||
|
|
||||||
export const recomputeCreature = new ValidatedMethod({
|
export const recomputeCreature = new ValidatedMethod({
|
||||||
|
|
||||||
name: 'Creatures.methods.recomputeCreature',
|
name: 'creatures.recomputeCreature',
|
||||||
|
|
||||||
validate: new SimpleSchema({
|
validate: new SimpleSchema({
|
||||||
charId: { type: String }
|
charId: { type: String }
|
||||||
}).validator(),
|
}).validator(),
|
||||||
|
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
|
|
||||||
run({charId}) {
|
run({charId}) {
|
||||||
|
let creature = Creatures.findOne(charId);
|
||||||
// Permission
|
// Permission
|
||||||
assertEditPermission(charId, this.userId);
|
assertEditPermission(creature, this.userId);
|
||||||
// Work, call this direcly if you are already in a method that has checked
|
// Work, call this direcly if you are already in a method that has checked
|
||||||
// for permission to edit a given character
|
// for permission to edit a given character
|
||||||
recomputeCreatureById(charId);
|
recomputeCreatureById(charId);
|
||||||
@@ -33,8 +42,20 @@ const calculationPropertyTypes = [
|
|||||||
'proficiency',
|
'proficiency',
|
||||||
'classLevel',
|
'classLevel',
|
||||||
'toggle',
|
'toggle',
|
||||||
|
'item',
|
||||||
|
// End step types
|
||||||
|
'action',
|
||||||
|
'attack',
|
||||||
|
'savingThrow',
|
||||||
|
'spellList',
|
||||||
|
'spell',
|
||||||
];
|
];
|
||||||
|
|
||||||
|
export function recomputeCreatureById(creatureId){
|
||||||
|
let creature = Creatures.findOne(creatureId);
|
||||||
|
recomputeCreatureByDoc(creature);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function is the heart of DiceCloud. It recomputes a creature's stats,
|
* This function is the heart of DiceCloud. It recomputes a creature's stats,
|
||||||
* distilling down effects and proficiencies into the final stats that make up
|
* distilling down effects and proficiencies into the final stats that make up
|
||||||
@@ -71,14 +92,15 @@ const calculationPropertyTypes = [
|
|||||||
* - Mark the stat as computed
|
* - Mark the stat as computed
|
||||||
* - Write the computed results back to the database
|
* - Write the computed results back to the database
|
||||||
*/
|
*/
|
||||||
export function recomputeCreatureById(creatureId){
|
export function recomputeCreatureByDoc(creature){
|
||||||
|
const creatureId = creature._id;
|
||||||
let props = getActiveProperties({
|
let props = getActiveProperties({
|
||||||
ancestorId: creatureId,
|
ancestorId: creatureId,
|
||||||
filter: {type: {$in: calculationPropertyTypes}},
|
filter: {type: {$in: calculationPropertyTypes}},
|
||||||
includeUntoggled: true,
|
includeUntoggled: true,
|
||||||
// TODO filter out expensive fields, particularly icon field
|
// TODO filter out expensive fields, particularly icon field
|
||||||
});
|
});
|
||||||
let computationMemo = new ComputationMemo(props);
|
let computationMemo = new ComputationMemo(props, creature);
|
||||||
computeMemo(computationMemo);
|
computeMemo(computationMemo);
|
||||||
writeAlteredProperties(computationMemo);
|
writeAlteredProperties(computationMemo);
|
||||||
writeCreatureVariables(computationMemo, creatureId);
|
writeCreatureVariables(computationMemo, creatureId);
|
||||||
|
|||||||
@@ -1,16 +1,29 @@
|
|||||||
import { Meteor } from 'meteor/meteor'
|
import { Meteor } from 'meteor/meteor'
|
||||||
import { isEqual, forOwn } from 'lodash';
|
import { isEqual, forOwn } from 'lodash';
|
||||||
|
import CreatureProperties from '/imports/api/creature/CreatureProperties.js';
|
||||||
|
// Schemas
|
||||||
|
// Calculated props
|
||||||
import { ComputedOnlySkillSchema } from '/imports/api/properties/Skills.js';
|
import { ComputedOnlySkillSchema } from '/imports/api/properties/Skills.js';
|
||||||
import { ComputedOnlyAttributeSchema } from '/imports/api/properties/Attributes.js';
|
import { ComputedOnlyAttributeSchema } from '/imports/api/properties/Attributes.js';
|
||||||
import { ComputedOnlyEffectSchema } from '/imports/api/properties/Effects.js';
|
import { ComputedOnlyEffectSchema } from '/imports/api/properties/Effects.js';
|
||||||
import { ComputedOnlyToggleSchema } from '/imports/api/properties/Toggles.js';
|
import { ComputedOnlyToggleSchema } from '/imports/api/properties/Toggles.js';
|
||||||
import CreatureProperties from '/imports/api/creature/CreatureProperties.js';
|
// End step props
|
||||||
|
import { ComputedOnlyActionSchema } from '/imports/api/properties/Actions.js';
|
||||||
|
import { ComputedOnlyAttackSchema } from '/imports/api/properties/Attacks.js';
|
||||||
|
import { ComputedOnlySavingThrowSchema } from '/imports/api/properties/SavingThrows.js';
|
||||||
|
import { ComputedOnlySpellListSchema } from '/imports/api/properties/SpellLists.js';
|
||||||
|
import { ComputedOnlySpellSchema } from '/imports/api/properties/Spells.js';
|
||||||
|
|
||||||
const schemasByType = {
|
const schemasByType = {
|
||||||
'skill': ComputedOnlySkillSchema,
|
'skill': ComputedOnlySkillSchema,
|
||||||
'attribute': ComputedOnlyAttributeSchema,
|
'attribute': ComputedOnlyAttributeSchema,
|
||||||
'effect': ComputedOnlyEffectSchema,
|
'effect': ComputedOnlyEffectSchema,
|
||||||
'toggle': ComputedOnlyToggleSchema,
|
'toggle': ComputedOnlyToggleSchema,
|
||||||
|
'action': ComputedOnlyActionSchema,
|
||||||
|
'attack': ComputedOnlyAttackSchema,
|
||||||
|
'savingThrow': ComputedOnlySavingThrowSchema,
|
||||||
|
'spellList': ComputedOnlySpellListSchema,
|
||||||
|
'spell': ComputedOnlySpellSchema,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function writeAlteredProperties(memo){
|
export default function writeAlteredProperties(memo){
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
||||||
|
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
import { assertEditPermission } from '/imports/api/creature/creaturePermissions.js';
|
import { assertEditPermission } from '/imports/api/creature/creaturePermissions.js';
|
||||||
import Creatures from '/imports/api/creature/Creatures.js';
|
import Creatures from '/imports/api/creature/Creatures.js';
|
||||||
@@ -6,12 +7,18 @@ import getActiveProperties from '/imports/api/creature/getActiveProperties.js';
|
|||||||
|
|
||||||
export const recomputeDamageMultipliers = new ValidatedMethod({
|
export const recomputeDamageMultipliers = new ValidatedMethod({
|
||||||
|
|
||||||
name: 'Creatures.methods.recomputeDamageMultipliers',
|
name: 'creatures.recomputeDamageMultipliers',
|
||||||
|
|
||||||
validate: new SimpleSchema({
|
validate: new SimpleSchema({
|
||||||
creatureId: { type: String }
|
creatureId: { type: String }
|
||||||
}).validator(),
|
}).validator(),
|
||||||
|
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
|
|
||||||
run({creatureId}) {
|
run({creatureId}) {
|
||||||
// Permission
|
// Permission
|
||||||
assertEditPermission(creatureId, this.userId);
|
assertEditPermission(creatureId, this.userId);
|
||||||
|
|||||||
197
app/imports/api/creature/experience/Experiences.js
Normal file
197
app/imports/api/creature/experience/Experiences.js
Normal file
@@ -0,0 +1,197 @@
|
|||||||
|
import SimpleSchema from 'simpl-schema';
|
||||||
|
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
||||||
|
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
||||||
|
import { getUserTier } from '/imports/api/users/patreon/tiers.js';
|
||||||
|
import { assertEditPermission } from '/imports/api/creature/creaturePermissions.js';
|
||||||
|
import Creatures from '/imports/api/creature/Creatures.js';
|
||||||
|
import { recomputeCreatureById } from '/imports/api/creature/computation/recomputeCreature.js';
|
||||||
|
|
||||||
|
let Experiences = new Mongo.Collection('experiences');
|
||||||
|
|
||||||
|
let ExperienceSchema = new SimpleSchema({
|
||||||
|
name: {
|
||||||
|
type: String,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
// The amount of XP this experience gives
|
||||||
|
xp: {
|
||||||
|
type: SimpleSchema.Integer,
|
||||||
|
optional: true,
|
||||||
|
min: 0,
|
||||||
|
},
|
||||||
|
// Setting levels instead of value grants whole levels
|
||||||
|
levels: {
|
||||||
|
type: SimpleSchema.Integer,
|
||||||
|
optional: true,
|
||||||
|
min: 0,
|
||||||
|
index: 1,
|
||||||
|
},
|
||||||
|
// The real-world date that it occured, usually sorted by date
|
||||||
|
date: {
|
||||||
|
type: Date,
|
||||||
|
autoValue: function() {
|
||||||
|
// If the date isn't set, set it to now
|
||||||
|
if (!this.isSet) {
|
||||||
|
return new Date();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
index: 1,
|
||||||
|
},
|
||||||
|
creatureId: {
|
||||||
|
type: String,
|
||||||
|
regEx: SimpleSchema.RegEx.Id,
|
||||||
|
index: 1,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
Experiences.attachSchema(ExperienceSchema);
|
||||||
|
|
||||||
|
const insertExperienceForCreature = function({experience, creatureId, userId}){
|
||||||
|
assertEditPermission(creatureId, userId);
|
||||||
|
if (experience.xp){
|
||||||
|
Creatures.update(creatureId, {$inc: {
|
||||||
|
'denormalizedStats.xp': experience.xp
|
||||||
|
}});
|
||||||
|
}
|
||||||
|
if (experience.levels) {
|
||||||
|
Creatures.update(creatureId, {$inc: {
|
||||||
|
'denormalizedStats.milestoneLevels': experience.levels
|
||||||
|
}});
|
||||||
|
}
|
||||||
|
experience.creatureId = creatureId;
|
||||||
|
let id = Experiences.insert(experience);
|
||||||
|
recomputeCreatureById(creatureId);
|
||||||
|
return id;
|
||||||
|
};
|
||||||
|
|
||||||
|
const insertExperience = new ValidatedMethod({
|
||||||
|
name: 'experiences.insert',
|
||||||
|
validate: new SimpleSchema({
|
||||||
|
experience: {
|
||||||
|
type: ExperienceSchema.omit('creatureId'),
|
||||||
|
},
|
||||||
|
creatureIds: {
|
||||||
|
type: Array,
|
||||||
|
max: 12,
|
||||||
|
},
|
||||||
|
'creatureIds.$': {
|
||||||
|
type: String,
|
||||||
|
regEx: SimpleSchema.RegEx.Id,
|
||||||
|
},
|
||||||
|
}).validator(),
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
|
run({experience, creatureIds}) {
|
||||||
|
let userId = this.userId;
|
||||||
|
if (!userId) {
|
||||||
|
throw new Meteor.Error('Experiences.methods.insert.denied',
|
||||||
|
'You need to be logged in to insert an experience');
|
||||||
|
}
|
||||||
|
let tier = getUserTier(this.userId);
|
||||||
|
if (!tier.paidBenefits){
|
||||||
|
throw new Meteor.Error('Experiences.methods.insert.denied',
|
||||||
|
`The ${tier.name} tier does not allow you to grant experience`);
|
||||||
|
}
|
||||||
|
let insertedIds = [];
|
||||||
|
creatureIds.forEach(creatureId => {
|
||||||
|
let id = insertExperienceForCreature({experience, creatureId, userId});
|
||||||
|
insertedIds.push(id);
|
||||||
|
});
|
||||||
|
return insertedIds;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const removeExperience = new ValidatedMethod({
|
||||||
|
name: 'experiences.remove',
|
||||||
|
validate: new SimpleSchema({
|
||||||
|
experienceId: {
|
||||||
|
type: String,
|
||||||
|
regEx: SimpleSchema.RegEx.Id,
|
||||||
|
},
|
||||||
|
}).validator(),
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
|
run({experienceId}) {
|
||||||
|
let userId = this.userId;
|
||||||
|
if (!userId) {
|
||||||
|
throw new Meteor.Error('Experiences.methods.remove.denied',
|
||||||
|
'You need to be logged in to remove an experience');
|
||||||
|
}
|
||||||
|
let tier = getUserTier(this.userId);
|
||||||
|
if (!tier.paidBenefits){
|
||||||
|
throw new Meteor.Error('Experiences.methods.remove.denied',
|
||||||
|
`The ${tier.name} tier does not allow you to remove an experience`);
|
||||||
|
}
|
||||||
|
let experience = Experiences.findOne(experienceId);
|
||||||
|
if (!experience) return;
|
||||||
|
let creatureId = experience.creatureId
|
||||||
|
assertEditPermission(creatureId, userId);
|
||||||
|
if (experience.xp){
|
||||||
|
Creatures.update(creatureId, {$inc: {
|
||||||
|
'denormalizedStats.xp': -experience.xp
|
||||||
|
}});
|
||||||
|
}
|
||||||
|
if (experience.levels) {
|
||||||
|
Creatures.update(creatureId, {$inc: {
|
||||||
|
'denormalizedStats.milestoneLevels': -experience.levels
|
||||||
|
}});
|
||||||
|
}
|
||||||
|
experience.creatureId = creatureId;
|
||||||
|
let numRemoved = Experiences.remove(experienceId);
|
||||||
|
recomputeCreatureById(creatureId);
|
||||||
|
return numRemoved;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const recomputeExperiences = new ValidatedMethod({
|
||||||
|
name: 'experiences.recompute',
|
||||||
|
validate: new SimpleSchema({
|
||||||
|
creatureId: {
|
||||||
|
type: String,
|
||||||
|
regEx: SimpleSchema.RegEx.Id,
|
||||||
|
},
|
||||||
|
}).validator(),
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
|
run({creatureId}) {
|
||||||
|
let userId = this.userId;
|
||||||
|
if (!userId) {
|
||||||
|
throw new Meteor.Error('Experiences.methods.recompute.denied',
|
||||||
|
'You need to be logged in to recompute a creature\'s experiences');
|
||||||
|
}
|
||||||
|
let tier = getUserTier(this.userId);
|
||||||
|
if (!tier.paidBenefits){
|
||||||
|
throw new Meteor.Error('Experiences.methods.recompute.denied',
|
||||||
|
`The ${tier.name} tier does not allow you to recompute a creature's experiences`);
|
||||||
|
}
|
||||||
|
assertEditPermission(creatureId, userId);
|
||||||
|
|
||||||
|
let xp = 0;
|
||||||
|
let milestoneLevels = 0;
|
||||||
|
Experiences.find({
|
||||||
|
creatureId
|
||||||
|
}, {
|
||||||
|
fields: {xp: 1, levels: 1}
|
||||||
|
}).forEach(experience => {
|
||||||
|
xp += experience.xp || 0;
|
||||||
|
milestoneLevels += experience.levels || 0;
|
||||||
|
});
|
||||||
|
Creatures.update(creatureId, {$set: {
|
||||||
|
'denormalizedStats.xp': xp,
|
||||||
|
'denormalizedStats.milestoneLevels': milestoneLevels
|
||||||
|
}});
|
||||||
|
recomputeCreatureById(creatureId);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default Experiences;
|
||||||
|
export { ExperienceSchema, insertExperience, removeExperience, recomputeExperiences };
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
|
|
||||||
let ExperienceSchema = new SimpleSchema({
|
let ExperienceSchema = new SimpleSchema({
|
||||||
name: {
|
title: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
@@ -10,11 +10,6 @@ let ExperienceSchema = new SimpleSchema({
|
|||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
// The amount of XP this experience gives
|
|
||||||
value: {
|
|
||||||
type: SimpleSchema.Integer,
|
|
||||||
optional: true,
|
|
||||||
},
|
|
||||||
// The real-world date that it occured
|
// The real-world date that it occured
|
||||||
date: {
|
date: {
|
||||||
type: Date,
|
type: Date,
|
||||||
@@ -30,6 +25,20 @@ let ExperienceSchema = new SimpleSchema({
|
|||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
|
// Tags to better find this entry later
|
||||||
|
tags: {
|
||||||
|
type: Array,
|
||||||
|
defaultValue: [],
|
||||||
|
},
|
||||||
|
'tags.$': {
|
||||||
|
type: String,
|
||||||
|
},
|
||||||
|
// ID of the journal this entry belongs to
|
||||||
|
journalId: {
|
||||||
|
type: String,
|
||||||
|
regEx: SimpleSchema.RegEx.Id,
|
||||||
|
index: 1,
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export { ExperienceSchema };
|
export { ExperienceSchema };
|
||||||
@@ -1,20 +1,29 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
|
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
||||||
|
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
||||||
import Creatures from '/imports/api/creature/Creatures.js';
|
import Creatures from '/imports/api/creature/Creatures.js';
|
||||||
import CreatureProperties from '/imports/api/creature/CreatureProperties.js'
|
import CreatureProperties from '/imports/api/creature/CreatureProperties.js'
|
||||||
import { assertOwnership } from '/imports/api/creature/creaturePermissions.js';
|
import { assertOwnership } from '/imports/api/creature/creaturePermissions.js';
|
||||||
|
import Experiences from '/imports/api/creature/experience/Experiences.js';
|
||||||
|
|
||||||
function removeRelatedDocuments(charId){
|
function removeRelatedDocuments(creatureId){
|
||||||
CreatureProperties.remove({'ancestors.id': charId});
|
CreatureProperties.remove({'ancestors.id': creatureId});
|
||||||
};
|
Experiences.remove({creatureId});
|
||||||
|
}
|
||||||
|
|
||||||
const removeCreature = new ValidatedMethod({
|
const removeCreature = new ValidatedMethod({
|
||||||
name: "Creatures.methods.removeCreature", // DDP method name
|
name: 'Creatures.methods.removeCreature', // DDP method name
|
||||||
validate: new SimpleSchema({
|
validate: new SimpleSchema({
|
||||||
charId: {
|
charId: {
|
||||||
type: String,
|
type: String,
|
||||||
regEx: SimpleSchema.RegEx.Id,
|
regEx: SimpleSchema.RegEx.Id,
|
||||||
},
|
},
|
||||||
}).validator(),
|
}).validator(),
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
run({charId}) {
|
run({charId}) {
|
||||||
assertOwnership(charId, this.userId)
|
assertOwnership(charId, this.userId)
|
||||||
Creatures.remove(charId);
|
Creatures.remove(charId);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
||||||
|
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
||||||
import Creatures from '/imports/api/creature/Creatures.js';
|
import Creatures from '/imports/api/creature/Creatures.js';
|
||||||
import CreatureProperties from '/imports/api/creature/CreatureProperties.js';
|
import CreatureProperties from '/imports/api/creature/CreatureProperties.js';
|
||||||
import getActiveProperties, { getActivePropertyFilter } from '/imports/api/creature/getActiveProperties.js';
|
import getActiveProperties, { getActivePropertyFilter } from '/imports/api/creature/getActiveProperties.js';
|
||||||
@@ -18,6 +19,11 @@ const restCreature = new ValidatedMethod({
|
|||||||
allowedValues: ['shortRest', 'longRest'],
|
allowedValues: ['shortRest', 'longRest'],
|
||||||
},
|
},
|
||||||
}).validator(),
|
}).validator(),
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
run({creatureId, restType}) {
|
run({creatureId, restType}) {
|
||||||
let creature = Creatures.findOne(creatureId, {
|
let creature = Creatures.findOne(creatureId, {
|
||||||
fields: {
|
fields: {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
||||||
|
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
||||||
import { assertAdmin } from '/imports/api/sharing/sharingPermissions.js';
|
import { assertAdmin } from '/imports/api/sharing/sharingPermissions.js';
|
||||||
|
|
||||||
let Icons = new Mongo.Collection('icons');
|
let Icons = new Mongo.Collection('icons');
|
||||||
@@ -48,7 +49,7 @@ Icons.attachSchema(iconsSchema);
|
|||||||
|
|
||||||
// This method does not validate icons against the schema, use wisely;
|
// This method does not validate icons against the schema, use wisely;
|
||||||
const writeIcons = new ValidatedMethod({
|
const writeIcons = new ValidatedMethod({
|
||||||
name: 'icons.methods.write',
|
name: 'icons.write',
|
||||||
validate: null,
|
validate: null,
|
||||||
run(icons){
|
run(icons){
|
||||||
assertAdmin(this.userId);
|
assertAdmin(this.userId);
|
||||||
@@ -60,7 +61,7 @@ const writeIcons = new ValidatedMethod({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const findIcons = new ValidatedMethod({
|
const findIcons = new ValidatedMethod({
|
||||||
name: 'icons.methods.find',
|
name: 'icons.find',
|
||||||
validate: new SimpleSchema({
|
validate: new SimpleSchema({
|
||||||
search: {
|
search: {
|
||||||
type: String,
|
type: String,
|
||||||
@@ -68,6 +69,11 @@ const findIcons = new ValidatedMethod({
|
|||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
}).validator(),
|
}).validator(),
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
run({search}){
|
run({search}){
|
||||||
if (!search) return [];
|
if (!search) return [];
|
||||||
if (!Meteor.isServer) return;
|
if (!Meteor.isServer) return;
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
||||||
|
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
import SharingSchema from '/imports/api/sharing/SharingSchema.js';
|
import SharingSchema from '/imports/api/sharing/SharingSchema.js';
|
||||||
import simpleSchemaMixin from '/imports/api/creature/mixins/simpleSchemaMixin.js';
|
import simpleSchemaMixin from '/imports/api/creature/mixins/simpleSchemaMixin.js';
|
||||||
@@ -34,7 +35,7 @@ Libraries.attachSchema(LibrarySchema);
|
|||||||
export default Libraries;
|
export default Libraries;
|
||||||
|
|
||||||
const insertLibrary = new ValidatedMethod({
|
const insertLibrary = new ValidatedMethod({
|
||||||
name: 'Libraries.methods.insert',
|
name: 'libraries.insert',
|
||||||
mixins: [
|
mixins: [
|
||||||
simpleSchemaMixin,
|
simpleSchemaMixin,
|
||||||
],
|
],
|
||||||
@@ -55,7 +56,7 @@ const insertLibrary = new ValidatedMethod({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const updateLibraryName = new ValidatedMethod({
|
const updateLibraryName = new ValidatedMethod({
|
||||||
name: 'Libraries.methods.updateName',
|
name: 'libraries.updateName',
|
||||||
validate: new SimpleSchema({
|
validate: new SimpleSchema({
|
||||||
_id: {
|
_id: {
|
||||||
type: String,
|
type: String,
|
||||||
@@ -65,6 +66,11 @@ const updateLibraryName = new ValidatedMethod({
|
|||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
}).validator(),
|
}).validator(),
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
run({_id, name}){
|
run({_id, name}){
|
||||||
let library = Libraries.findOne(_id);
|
let library = Libraries.findOne(_id);
|
||||||
assertEditPermission(library, this.userId);
|
assertEditPermission(library, this.userId);
|
||||||
@@ -73,7 +79,7 @@ const updateLibraryName = new ValidatedMethod({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const setLibraryDefault = new ValidatedMethod({
|
const setLibraryDefault = new ValidatedMethod({
|
||||||
name: 'Libraries.methods.makeLibraryDefault',
|
name: 'libraries.makeLibraryDefault',
|
||||||
validate: new SimpleSchema({
|
validate: new SimpleSchema({
|
||||||
_id: {
|
_id: {
|
||||||
type: String,
|
type: String,
|
||||||
@@ -83,6 +89,11 @@ const setLibraryDefault = new ValidatedMethod({
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
},
|
},
|
||||||
}).validator(),
|
}).validator(),
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
run({_id, isDefault}) {
|
run({_id, isDefault}) {
|
||||||
if (!Meteor.users.isAdmin()){
|
if (!Meteor.users.isAdmin()){
|
||||||
throw new Meteor.Error('Permission denied', 'User must be admin to set libraries as default');
|
throw new Meteor.Error('Permission denied', 'User must be admin to set libraries as default');
|
||||||
@@ -92,13 +103,18 @@ const setLibraryDefault = new ValidatedMethod({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const removeLibrary = new ValidatedMethod({
|
const removeLibrary = new ValidatedMethod({
|
||||||
name: 'Libraries.methods.remove',
|
name: 'libraries.remove',
|
||||||
validate: new SimpleSchema({
|
validate: new SimpleSchema({
|
||||||
_id: {
|
_id: {
|
||||||
type: String,
|
type: String,
|
||||||
regEx: SimpleSchema.RegEx.id
|
regEx: SimpleSchema.RegEx.id
|
||||||
},
|
},
|
||||||
}).validator(),
|
}).validator(),
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
run({_id}){
|
run({_id}){
|
||||||
let library = Libraries.findOne(_id);
|
let library = Libraries.findOne(_id);
|
||||||
assertOwnership(library, this.userId);
|
assertOwnership(library, this.userId);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { Meteor } from 'meteor/meteor';
|
import { Meteor } from 'meteor/meteor';
|
||||||
import { Mongo } from 'meteor/mongo';
|
import { Mongo } from 'meteor/mongo';
|
||||||
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
||||||
|
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
import ColorSchema from '/imports/api/properties/subSchemas/ColorSchema.js';
|
import ColorSchema from '/imports/api/properties/subSchemas/ColorSchema.js';
|
||||||
import ChildSchema from '/imports/api/parenting/ChildSchema.js';
|
import ChildSchema from '/imports/api/parenting/ChildSchema.js';
|
||||||
@@ -56,8 +57,13 @@ function assertNodeEditPermission(node, userId){
|
|||||||
}
|
}
|
||||||
|
|
||||||
const insertNode = new ValidatedMethod({
|
const insertNode = new ValidatedMethod({
|
||||||
name: 'LibraryNodes.methods.insert',
|
name: 'libraryNodes.insert',
|
||||||
validate: null,
|
validate: null,
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
run(libraryNode) {
|
run(libraryNode) {
|
||||||
delete libraryNode._id;
|
delete libraryNode._id;
|
||||||
assertNodeEditPermission(libraryNode, this.userId);
|
assertNodeEditPermission(libraryNode, this.userId);
|
||||||
@@ -66,13 +72,18 @@ const insertNode = new ValidatedMethod({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const duplicateNode = new ValidatedMethod({
|
const duplicateNode = new ValidatedMethod({
|
||||||
name: 'LibraryNodes.methods.duplicate',
|
name: 'libraryNodes.duplicate',
|
||||||
validate: new SimpleSchema({
|
validate: new SimpleSchema({
|
||||||
_id: {
|
_id: {
|
||||||
type: String,
|
type: String,
|
||||||
regEx: SimpleSchema.RegEx.Id,
|
regEx: SimpleSchema.RegEx.Id,
|
||||||
}
|
}
|
||||||
}).validator(),
|
}).validator(),
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
run({_id}) {
|
run({_id}) {
|
||||||
let libraryNode = LibraryNodes.findOne(_id);
|
let libraryNode = LibraryNodes.findOne(_id);
|
||||||
assertNodeEditPermission(libraryNode, this.userId);
|
assertNodeEditPermission(libraryNode, this.userId);
|
||||||
@@ -82,7 +93,7 @@ const duplicateNode = new ValidatedMethod({
|
|||||||
})
|
})
|
||||||
|
|
||||||
const updateLibraryNode = new ValidatedMethod({
|
const updateLibraryNode = new ValidatedMethod({
|
||||||
name: 'LibraryNodes.methods.update',
|
name: 'libraryNodes.update',
|
||||||
validate({_id, path}){
|
validate({_id, path}){
|
||||||
if (!_id) return false;
|
if (!_id) return false;
|
||||||
// We cannot change these fields with a simple update
|
// We cannot change these fields with a simple update
|
||||||
@@ -94,6 +105,11 @@ const updateLibraryNode = new ValidatedMethod({
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
run({_id, path, value}) {
|
run({_id, path, value}) {
|
||||||
let node = LibraryNodes.findOne(_id);
|
let node = LibraryNodes.findOne(_id);
|
||||||
assertNodeEditPermission(node, this.userId);
|
assertNodeEditPermission(node, this.userId);
|
||||||
@@ -112,8 +128,13 @@ const updateLibraryNode = new ValidatedMethod({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const pushToLibraryNode = new ValidatedMethod({
|
const pushToLibraryNode = new ValidatedMethod({
|
||||||
name: 'LibraryNodes.methods.push',
|
name: 'libraryNodes.push',
|
||||||
validate: null,
|
validate: null,
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
run({_id, path, value}){
|
run({_id, path, value}){
|
||||||
let node = LibraryNodes.findOne(_id);
|
let node = LibraryNodes.findOne(_id);
|
||||||
assertNodeEditPermission(node, this.userId);
|
assertNodeEditPermission(node, this.userId);
|
||||||
@@ -126,8 +147,13 @@ const pushToLibraryNode = new ValidatedMethod({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const pullFromLibraryNode = new ValidatedMethod({
|
const pullFromLibraryNode = new ValidatedMethod({
|
||||||
name: 'LibraryNodes.methods.pull',
|
name: 'libraryNodes.pull',
|
||||||
validate: null,
|
validate: null,
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
run({_id, path, itemId}){
|
run({_id, path, itemId}){
|
||||||
let node = LibraryNodes.findOne(_id);
|
let node = LibraryNodes.findOne(_id);
|
||||||
assertNodeEditPermission(node, this.userId);
|
assertNodeEditPermission(node, this.userId);
|
||||||
@@ -141,10 +167,15 @@ const pullFromLibraryNode = new ValidatedMethod({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const softRemoveLibraryNode = new ValidatedMethod({
|
const softRemoveLibraryNode = new ValidatedMethod({
|
||||||
name: 'LibraryNodes.methods.softRemove',
|
name: 'libraryNodes.softRemove',
|
||||||
validate: new SimpleSchema({
|
validate: new SimpleSchema({
|
||||||
_id: SimpleSchema.RegEx.Id
|
_id: SimpleSchema.RegEx.Id
|
||||||
}).validator(),
|
}).validator(),
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
run({_id}){
|
run({_id}){
|
||||||
let node = LibraryNodes.findOne(_id);
|
let node = LibraryNodes.findOne(_id);
|
||||||
assertNodeEditPermission(node, this.userId);
|
assertNodeEditPermission(node, this.userId);
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
import { union } from 'lodash';
|
import { union } from 'lodash';
|
||||||
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
||||||
|
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
||||||
import { updateParent } from '/imports/api/parenting/parenting.js';
|
import { updateParent } from '/imports/api/parenting/parenting.js';
|
||||||
import { reorderDocs, safeUpdateDocOrder } from '/imports/api/parenting/order.js';
|
import { reorderDocs, safeUpdateDocOrder } from '/imports/api/parenting/order.js';
|
||||||
import { RefSchema } from '/imports/api/parenting/ChildSchema.js';
|
import { RefSchema } from '/imports/api/parenting/ChildSchema.js';
|
||||||
@@ -10,7 +11,7 @@ import getCollectionByName from '/imports/api/parenting/getCollectionByName.js';
|
|||||||
import { recomputeCreatureById } from '/imports/api/creature/computation/recomputeCreature.js';
|
import { recomputeCreatureById } from '/imports/api/creature/computation/recomputeCreature.js';
|
||||||
|
|
||||||
const organizeDoc = new ValidatedMethod({
|
const organizeDoc = new ValidatedMethod({
|
||||||
name: 'organize.methods.organizeDoc',
|
name: 'organize.organizeDoc',
|
||||||
validate: new SimpleSchema({
|
validate: new SimpleSchema({
|
||||||
docRef: RefSchema,
|
docRef: RefSchema,
|
||||||
parentRef: RefSchema,
|
parentRef: RefSchema,
|
||||||
@@ -19,6 +20,11 @@ const organizeDoc = new ValidatedMethod({
|
|||||||
// Should end in 0.5 to place it reliably between two existing documents
|
// Should end in 0.5 to place it reliably between two existing documents
|
||||||
},
|
},
|
||||||
}).validator(),
|
}).validator(),
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
run({docRef, parentRef, order}) {
|
run({docRef, parentRef, order}) {
|
||||||
let doc = fetchDocByRef(docRef);
|
let doc = fetchDocByRef(docRef);
|
||||||
let collection = getCollectionByName(docRef.collection);
|
let collection = getCollectionByName(docRef.collection);
|
||||||
@@ -54,7 +60,7 @@ const organizeDoc = new ValidatedMethod({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const reorderDoc = new ValidatedMethod({
|
const reorderDoc = new ValidatedMethod({
|
||||||
name: 'organize.methods.reorderDoc',
|
name: 'organize.reorderDoc',
|
||||||
validate: new SimpleSchema({
|
validate: new SimpleSchema({
|
||||||
docRef: RefSchema,
|
docRef: RefSchema,
|
||||||
order: {
|
order: {
|
||||||
@@ -62,6 +68,11 @@ const reorderDoc = new ValidatedMethod({
|
|||||||
// Should end in 0.5 to place it reliably between two existing documents
|
// Should end in 0.5 to place it reliably between two existing documents
|
||||||
},
|
},
|
||||||
}).validator(),
|
}).validator(),
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
run({docRef, order}) {
|
run({docRef, order}) {
|
||||||
let doc = fetchDocByRef(docRef);
|
let doc = fetchDocByRef(docRef);
|
||||||
assertDocEditPermission(doc, this.userId);
|
assertDocEditPermission(doc, this.userId);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
import ResourcesSchema from '/imports/api/properties/subSchemas/ResourcesSchema.js'
|
import ErrorSchema from '/imports/api/properties/subSchemas/ErrorSchema.js';
|
||||||
|
import { storedIconsSchema } from '/imports/api/icons/Icons.js'
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions are things a character can do
|
* Actions are things a character can do
|
||||||
@@ -12,6 +13,10 @@ let ActionSchema = new SimpleSchema({
|
|||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
|
summary: {
|
||||||
|
type: String,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
description: {
|
description: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
@@ -40,13 +45,60 @@ let ActionSchema = new SimpleSchema({
|
|||||||
'tags.$': {
|
'tags.$': {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
|
// Duplicate the ResourceSchema here so we can extend it elegantly.
|
||||||
resources: {
|
resources: {
|
||||||
type: ResourcesSchema,
|
type: Object,
|
||||||
defaultValue: {},
|
defaultValue: {},
|
||||||
|
},
|
||||||
|
'resources.itemsConsumed': {
|
||||||
|
type: Array,
|
||||||
|
defaultValue: [],
|
||||||
|
},
|
||||||
|
'resources.itemsConsumed.$': {
|
||||||
|
type: Object,
|
||||||
|
},
|
||||||
|
'resources.itemsConsumed.$._id': {
|
||||||
|
type: String,
|
||||||
|
regEx: SimpleSchema.RegEx.Id,
|
||||||
|
autoValue(){
|
||||||
|
if (!this.isSet) return Random.id();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'resources.itemsConsumed.$.tag': {
|
||||||
|
type: String,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
'resources.itemsConsumed.$.quantity': {
|
||||||
|
type: Number,
|
||||||
|
defaultValue: 1,
|
||||||
|
},
|
||||||
|
'resources.itemsConsumed.$.itemId': {
|
||||||
|
type: String,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
'resources.attributesConsumed': {
|
||||||
|
type: Array,
|
||||||
|
defaultValue: [],
|
||||||
|
},
|
||||||
|
'resources.attributesConsumed.$': {
|
||||||
|
type: Object,
|
||||||
|
},
|
||||||
|
'resources.attributesConsumed.$._id': {
|
||||||
|
type: String,
|
||||||
|
regEx: SimpleSchema.RegEx.Id,
|
||||||
|
autoValue(){
|
||||||
|
if (!this.isSet) return Random.id();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'resources.attributesConsumed.$.variableName': {
|
||||||
|
type: String,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
'resources.attributesConsumed.$.quantity': {
|
||||||
|
type: Number,
|
||||||
|
defaultValue: 1,
|
||||||
},
|
},
|
||||||
// Calculation of how many times this action can be used
|
// Calculation of how many times this action can be used
|
||||||
// Only set if this action tracks its own uses, rather than adjusting
|
|
||||||
// resources
|
|
||||||
uses: {
|
uses: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
@@ -64,4 +116,69 @@ let ActionSchema = new SimpleSchema({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export { ActionSchema };
|
const ComputedOnlyActionSchema = new SimpleSchema({
|
||||||
|
usesResult: {
|
||||||
|
type: SimpleSchema.Integer,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
usesErrors: {
|
||||||
|
type: Array,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
'usesErrors.$':{
|
||||||
|
type: ErrorSchema,
|
||||||
|
},
|
||||||
|
resources: Object,
|
||||||
|
'resources.itemsConsumed': Array,
|
||||||
|
'resources.itemsConsumed.$': Object,
|
||||||
|
'resources.itemsConsumed.$.available': {
|
||||||
|
type: Number,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
// This appears both in the computed and uncomputed schema because it can be
|
||||||
|
// set by both a computation or a form
|
||||||
|
'resources.itemsConsumed.$.itemId': {
|
||||||
|
type: String,
|
||||||
|
regEx: SimpleSchema.RegEx.Id,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
'resources.itemsConsumed.$.itemName': {
|
||||||
|
type: String,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
'resources.itemsConsumed.$.itemIcon': {
|
||||||
|
type: storedIconsSchema,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
'resources.itemsConsumed.$.itemColor': {
|
||||||
|
type: String,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
'resources.attributesConsumed': Array,
|
||||||
|
'resources.attributesConsumed.$': Object,
|
||||||
|
'resources.attributesConsumed.$.available': {
|
||||||
|
type: Number,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
'resources.attributesConsumed.$.statId': {
|
||||||
|
type: String,
|
||||||
|
regEx: SimpleSchema.RegEx.Id,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
'resources.attributesConsumed.$.statName': {
|
||||||
|
type: String,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
// True if the uses left is zero, or any item or attribute consumed is
|
||||||
|
// insufficient
|
||||||
|
insufficientResources: {
|
||||||
|
type: Boolean,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const ComputedActionSchema = new SimpleSchema()
|
||||||
|
.extend(ActionSchema)
|
||||||
|
.extend(ComputedOnlyActionSchema);
|
||||||
|
|
||||||
|
export { ActionSchema, ComputedOnlyActionSchema, ComputedActionSchema};
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import SimpleSchema from 'simpl-schema';
|
|||||||
|
|
||||||
const AdjustmentSchema = new SimpleSchema({
|
const AdjustmentSchema = new SimpleSchema({
|
||||||
// The roll that determines how much to change the attribute
|
// The roll that determines how much to change the attribute
|
||||||
|
// This can be simplified, but should only compute when activated
|
||||||
amount: {
|
amount: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
import { ActionSchema } from '/imports/api/properties/Actions.js';
|
import { ActionSchema, ComputedOnlyActionSchema } from '/imports/api/properties/Actions.js';
|
||||||
|
import ErrorSchema from '/imports/api/properties/subSchemas/ErrorSchema.js';
|
||||||
|
|
||||||
// Attacks are special instances of actions
|
// Attacks are special instances of actions
|
||||||
let AttackSchema = new SimpleSchema()
|
let AttackSchema = new SimpleSchema()
|
||||||
@@ -25,4 +26,24 @@ let AttackSchema = new SimpleSchema()
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export { AttackSchema };
|
const ComputedOnlyAttackSchema = new SimpleSchema()
|
||||||
|
.extend(ComputedOnlyActionSchema)
|
||||||
|
.extend({
|
||||||
|
rollBonusResult: {
|
||||||
|
type: Number,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
rollBonusErrors: {
|
||||||
|
type: Array,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
'rollBonusErrors.$':{
|
||||||
|
type: ErrorSchema,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const ComputedAttackSchema = new SimpleSchema()
|
||||||
|
.extend(AttackSchema)
|
||||||
|
.extend(ComputedOnlyAttackSchema);
|
||||||
|
|
||||||
|
export { AttackSchema, ComputedOnlyAttackSchema, ComputedAttackSchema };
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import DAMAGE_TYPES from '/imports/constants/DAMAGE_TYPES.js';
|
|||||||
|
|
||||||
const DamageSchema = new SimpleSchema({
|
const DamageSchema = new SimpleSchema({
|
||||||
// The roll that determines how much to damage the attribute
|
// The roll that determines how much to damage the attribute
|
||||||
|
// This can be simplified, but only computed when applied
|
||||||
amount: {
|
amount: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ let EffectSchema = new SimpleSchema({
|
|||||||
},
|
},
|
||||||
'stats.$': {
|
'stats.$': {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ let ProficiencySchema = new SimpleSchema({
|
|||||||
},
|
},
|
||||||
'stats.$': {
|
'stats.$': {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
|
||||||
},
|
},
|
||||||
// A number representing how proficient the character is
|
// A number representing how proficient the character is
|
||||||
value: {
|
value: {
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import SimpleSchema from 'simpl-schema';
|
|||||||
* child rolls are applied
|
* child rolls are applied
|
||||||
*/
|
*/
|
||||||
let RollSchema = new SimpleSchema({
|
let RollSchema = new SimpleSchema({
|
||||||
// The roll
|
// The roll, can be simplified, but only computed in context
|
||||||
roll: {
|
roll: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
|
import ErrorSchema from '/imports/api/properties/subSchemas/ErrorSchema.js';
|
||||||
|
|
||||||
// These are the rolls made when saves are called for
|
// These are the rolls made when saves are called for
|
||||||
// For the saving throw bonus or proficiency, see ./Skills.js
|
// For the saving throw bonus or proficiency, see ./Skills.js
|
||||||
@@ -18,4 +19,22 @@ let SavingThrowSchema = new SimpleSchema ({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export { SavingThrowSchema };
|
const ComputedOnlySavingThrowSchema = new SimpleSchema({
|
||||||
|
dcResult: {
|
||||||
|
type: Number,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
dcErrors: {
|
||||||
|
type: Array,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
'dcErrors.$':{
|
||||||
|
type: ErrorSchema,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const ComputedSavingThrowSchema = new SimpleSchema()
|
||||||
|
.extend(SavingThrowSchema)
|
||||||
|
.extend(ComputedOnlySavingThrowSchema);
|
||||||
|
|
||||||
|
export { SavingThrowSchema, ComputedOnlySavingThrowSchema, ComputedSavingThrowSchema };
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
|
import ErrorSchema from '/imports/api/properties/subSchemas/ErrorSchema.js';
|
||||||
|
|
||||||
let SpellListSchema = new SimpleSchema({
|
let SpellListSchema = new SimpleSchema({
|
||||||
name: {
|
name: {
|
||||||
@@ -16,4 +17,22 @@ let SpellListSchema = new SimpleSchema({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export { SpellListSchema }
|
const ComputedOnlySpellListSchema = new SimpleSchema({
|
||||||
|
maxPreparedResult: {
|
||||||
|
type: Number,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
maxPreparedErrors: {
|
||||||
|
type: Array,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
'maxPreparedErrors.$':{
|
||||||
|
type: ErrorSchema,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const ComputedSpellListSchema = new SimpleSchema()
|
||||||
|
.extend(SpellListSchema)
|
||||||
|
.extend(ComputedOnlySpellListSchema);
|
||||||
|
|
||||||
|
export { SpellListSchema, ComputedOnlySpellListSchema, ComputedSpellListSchema };
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { ActionSchema } from '/imports/api/properties/Actions.js';
|
import { ActionSchema, ComputedOnlyActionSchema } from '/imports/api/properties/Actions.js';
|
||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
|
|
||||||
const magicSchools = [
|
const magicSchools = [
|
||||||
@@ -93,4 +93,11 @@ let SpellSchema = new SimpleSchema({})
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export { SpellSchema };
|
const ComputedOnlySpellSchema = new SimpleSchema()
|
||||||
|
.extend(ComputedOnlyActionSchema);
|
||||||
|
|
||||||
|
const ComputedSpellSchema = new SimpleSchema()
|
||||||
|
.extend(SpellSchema)
|
||||||
|
.extend(ComputedOnlySpellSchema);
|
||||||
|
|
||||||
|
export { SpellSchema, ComputedOnlySpellSchema, ComputedSpellSchema };
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
import { ActionSchema } from '/imports/api/properties/Actions.js';
|
import { ComputedActionSchema } from '/imports/api/properties/Actions.js';
|
||||||
import { AdjustmentSchema } from '/imports/api/properties/Adjustments.js';
|
import { AdjustmentSchema } from '/imports/api/properties/Adjustments.js';
|
||||||
import { AttackSchema } from '/imports/api/properties/Attacks.js';
|
import { ComputedAttackSchema } from '/imports/api/properties/Attacks.js';
|
||||||
import { ComputedAttributeSchema } from '/imports/api/properties/Attributes.js';
|
import { ComputedAttributeSchema } from '/imports/api/properties/Attributes.js';
|
||||||
import { BuffSchema } from '/imports/api/properties/Buffs.js';
|
import { BuffSchema } from '/imports/api/properties/Buffs.js';
|
||||||
import { ClassLevelSchema } from '/imports/api/properties/ClassLevels.js';
|
import { ClassLevelSchema } from '/imports/api/properties/ClassLevels.js';
|
||||||
@@ -9,41 +9,39 @@ import { ContainerSchema } from '/imports/api/properties/Containers.js';
|
|||||||
import { DamageSchema } from '/imports/api/properties/Damages.js';
|
import { DamageSchema } from '/imports/api/properties/Damages.js';
|
||||||
import { DamageMultiplierSchema } from '/imports/api/properties/DamageMultipliers.js';
|
import { DamageMultiplierSchema } from '/imports/api/properties/DamageMultipliers.js';
|
||||||
import { ComputedEffectSchema } from '/imports/api/properties/Effects.js';
|
import { ComputedEffectSchema } from '/imports/api/properties/Effects.js';
|
||||||
import { ExperienceSchema } from '/imports/api/properties/Experiences.js';
|
|
||||||
import { FeatureSchema } from '/imports/api/properties/Features.js';
|
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 { ItemSchema } from '/imports/api/properties/Items.js';
|
import { ItemSchema } from '/imports/api/properties/Items.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 { RollSchema } from '/imports/api/properties/Rolls.js';
|
import { RollSchema } from '/imports/api/properties/Rolls.js';
|
||||||
import { SavingThrowSchema } 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';
|
||||||
import { SlotSchema } from '/imports/api/properties/Slots.js';
|
import { SlotSchema } from '/imports/api/properties/Slots.js';
|
||||||
import { SpellSchema } from '/imports/api/properties/Spells.js';
|
import { ComputedSpellSchema } from '/imports/api/properties/Spells.js';
|
||||||
import { SpellListSchema } from '/imports/api/properties/SpellLists.js';
|
import { ComputedSpellListSchema } from '/imports/api/properties/SpellLists.js';
|
||||||
import { ToggleSchema } from '/imports/api/properties/Toggles.js';
|
import { ToggleSchema } from '/imports/api/properties/Toggles.js';
|
||||||
|
|
||||||
const propertySchemasIndex = {
|
const propertySchemasIndex = {
|
||||||
action: ActionSchema,
|
action: ComputedActionSchema,
|
||||||
adjustment: AdjustmentSchema,
|
adjustment: AdjustmentSchema,
|
||||||
attack: AttackSchema,
|
attack: ComputedAttackSchema,
|
||||||
attribute: ComputedAttributeSchema,
|
attribute: ComputedAttributeSchema,
|
||||||
buff: BuffSchema,
|
buff: BuffSchema,
|
||||||
classLevel: ClassLevelSchema,
|
classLevel: ClassLevelSchema,
|
||||||
damage: DamageSchema,
|
damage: DamageSchema,
|
||||||
damageMultiplier: DamageMultiplierSchema,
|
damageMultiplier: DamageMultiplierSchema,
|
||||||
effect: ComputedEffectSchema,
|
effect: ComputedEffectSchema,
|
||||||
experience: ExperienceSchema,
|
|
||||||
feature: FeatureSchema,
|
feature: FeatureSchema,
|
||||||
folder: FolderSchema,
|
folder: FolderSchema,
|
||||||
note: NoteSchema,
|
note: NoteSchema,
|
||||||
proficiency: ProficiencySchema,
|
proficiency: ProficiencySchema,
|
||||||
roll: RollSchema,
|
roll: RollSchema,
|
||||||
savingThrow: SavingThrowSchema,
|
savingThrow: ComputedSavingThrowSchema,
|
||||||
skill: ComputedSkillSchema,
|
skill: ComputedSkillSchema,
|
||||||
slot: SlotSchema,
|
slot: SlotSchema,
|
||||||
spellList: SpellListSchema,
|
spellList: ComputedSpellSchema,
|
||||||
spell: SpellSchema,
|
spell: ComputedSpellListSchema,
|
||||||
toggle: ToggleSchema,
|
toggle: ToggleSchema,
|
||||||
container: ContainerSchema,
|
container: ContainerSchema,
|
||||||
item: ItemSchema,
|
item: ItemSchema,
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import { ClassLevelSchema } from '/imports/api/properties/ClassLevels.js';
|
|||||||
import { DamageSchema } from '/imports/api/properties/Damages.js';
|
import { DamageSchema } from '/imports/api/properties/Damages.js';
|
||||||
import { DamageMultiplierSchema } from '/imports/api/properties/DamageMultipliers.js';
|
import { DamageMultiplierSchema } from '/imports/api/properties/DamageMultipliers.js';
|
||||||
import { EffectSchema } from '/imports/api/properties/Effects.js';
|
import { EffectSchema } from '/imports/api/properties/Effects.js';
|
||||||
import { ExperienceSchema } from '/imports/api/properties/Experiences.js';
|
|
||||||
import { FeatureSchema } from '/imports/api/properties/Features.js';
|
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';
|
||||||
@@ -33,7 +32,6 @@ const propertySchemasIndex = {
|
|||||||
damage: DamageSchema,
|
damage: DamageSchema,
|
||||||
damageMultiplier: DamageMultiplierSchema,
|
damageMultiplier: DamageMultiplierSchema,
|
||||||
effect: EffectSchema,
|
effect: EffectSchema,
|
||||||
experience: ExperienceSchema,
|
|
||||||
feature: FeatureSchema,
|
feature: FeatureSchema,
|
||||||
folder: FolderSchema,
|
folder: FolderSchema,
|
||||||
note: NoteSchema,
|
note: NoteSchema,
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
|
|
||||||
const ErrorSchema = new SimpleSchema({
|
const ErrorSchema = new SimpleSchema({
|
||||||
// The roll that determines how much to change the attribute
|
|
||||||
message: {
|
message: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
// Who this adjustment applies to
|
|
||||||
type: {
|
type: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -17,6 +17,10 @@ const ItemConsumedSchema = new SimpleSchema({
|
|||||||
type: Number,
|
type: Number,
|
||||||
defaultValue: 1,
|
defaultValue: 1,
|
||||||
},
|
},
|
||||||
|
itemId: {
|
||||||
|
type: String,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export default ItemConsumedSchema;
|
export default ItemConsumedSchema;
|
||||||
|
|||||||
@@ -4,13 +4,19 @@ import fetchDocByRef from '/imports/api/parenting/fetchDocByRef.js';
|
|||||||
import getCollectionByName from '/imports/api/parenting/getCollectionByName.js';
|
import getCollectionByName from '/imports/api/parenting/getCollectionByName.js';
|
||||||
import { RefSchema } from '/imports/api/parenting/ChildSchema.js';
|
import { RefSchema } from '/imports/api/parenting/ChildSchema.js';
|
||||||
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
||||||
|
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
||||||
|
|
||||||
const setPublic = new ValidatedMethod({
|
const setPublic = new ValidatedMethod({
|
||||||
name: 'sharing.methods.setPublic',
|
name: 'sharing.setPublic',
|
||||||
validate: new SimpleSchema({
|
validate: new SimpleSchema({
|
||||||
docRef: RefSchema,
|
docRef: RefSchema,
|
||||||
isPublic: { type: Boolean },
|
isPublic: { type: Boolean },
|
||||||
}).validator(),
|
}).validator(),
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
run({docRef, isPublic}){
|
run({docRef, isPublic}){
|
||||||
let doc = fetchDocByRef(docRef);
|
let doc = fetchDocByRef(docRef);
|
||||||
assertOwnership(doc, this.userId);
|
assertOwnership(doc, this.userId);
|
||||||
@@ -21,7 +27,7 @@ const setPublic = new ValidatedMethod({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const updateUserSharePermissions = new ValidatedMethod({
|
const updateUserSharePermissions = new ValidatedMethod({
|
||||||
name: 'sharing.methods.updateUserSharePermissions',
|
name: 'sharing.updateUserSharePermissions',
|
||||||
validate: new SimpleSchema({
|
validate: new SimpleSchema({
|
||||||
docRef: RefSchema,
|
docRef: RefSchema,
|
||||||
userId: {
|
userId: {
|
||||||
@@ -33,6 +39,11 @@ const updateUserSharePermissions = new ValidatedMethod({
|
|||||||
allowedValues: ['reader', 'writer', 'none'],
|
allowedValues: ['reader', 'writer', 'none'],
|
||||||
},
|
},
|
||||||
}).validator(),
|
}).validator(),
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
run({docRef, userId, role}){
|
run({docRef, userId, role}){
|
||||||
let doc = fetchDocByRef(docRef);
|
let doc = fetchDocByRef(docRef);
|
||||||
if (role === 'none'){
|
if (role === 'none'){
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
||||||
|
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
||||||
import { getUserTier } from '/imports/api/users/patreon/tiers.js';
|
import { getUserTier } from '/imports/api/users/patreon/tiers.js';
|
||||||
|
|
||||||
let Invites= new Mongo.Collection('invites');
|
let Invites= new Mongo.Collection('invites');
|
||||||
@@ -85,13 +86,18 @@ function alignInvitesWithPatreonTier(user){
|
|||||||
}
|
}
|
||||||
|
|
||||||
const getInviteToken = new ValidatedMethod({
|
const getInviteToken = new ValidatedMethod({
|
||||||
name: 'Invites.methods.getToken',
|
name: 'invites.getToken',
|
||||||
validate: new SimpleSchema({
|
validate: new SimpleSchema({
|
||||||
inviteId: {
|
inviteId: {
|
||||||
type: String,
|
type: String,
|
||||||
regEx: SimpleSchema.RegEx.Id,
|
regEx: SimpleSchema.RegEx.Id,
|
||||||
},
|
},
|
||||||
}).validator(),
|
}).validator(),
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
run({inviteId}) {
|
run({inviteId}) {
|
||||||
let invite = Invites.findOne(inviteId);
|
let invite = Invites.findOne(inviteId);
|
||||||
if (this.userId !== invite.inviter) {
|
if (this.userId !== invite.inviter) {
|
||||||
@@ -109,12 +115,17 @@ const getInviteToken = new ValidatedMethod({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const acceptInviteToken = new ValidatedMethod({
|
const acceptInviteToken = new ValidatedMethod({
|
||||||
name: 'Invites.methods.acceptToken',
|
name: 'invites.acceptToken',
|
||||||
validate: new SimpleSchema({
|
validate: new SimpleSchema({
|
||||||
inviteToken: {
|
inviteToken: {
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
}).validator(),
|
}).validator(),
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
run({inviteToken}) {
|
run({inviteToken}) {
|
||||||
if (!this.userId) {
|
if (!this.userId) {
|
||||||
throw new Meteor.Error('Invites.methods.acceptToken.denied',
|
throw new Meteor.Error('Invites.methods.acceptToken.denied',
|
||||||
@@ -146,13 +157,18 @@ const acceptInviteToken = new ValidatedMethod({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const revokeInvite = new ValidatedMethod({
|
const revokeInvite = new ValidatedMethod({
|
||||||
name: 'Invites.methods.revokeInvite',
|
name: 'invites.revokeInvite',
|
||||||
validate: new SimpleSchema({
|
validate: new SimpleSchema({
|
||||||
inviteId: {
|
inviteId: {
|
||||||
type: String,
|
type: String,
|
||||||
regEx: SimpleSchema.RegEx.Id,
|
regEx: SimpleSchema.RegEx.Id,
|
||||||
},
|
},
|
||||||
}).validator(),
|
}).validator(),
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
run({inviteId}) {
|
run({inviteId}) {
|
||||||
if (!this.userId) {
|
if (!this.userId) {
|
||||||
throw new Meteor.Error('Invites.methods.revokeInvite.denied',
|
throw new Meteor.Error('Invites.methods.revokeInvite.denied',
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
||||||
|
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
||||||
|
|
||||||
const userSchema = new SimpleSchema({
|
const userSchema = new SimpleSchema({
|
||||||
username: {
|
username: {
|
||||||
@@ -87,8 +88,13 @@ const userSchema = new SimpleSchema({
|
|||||||
Meteor.users.attachSchema(userSchema);
|
Meteor.users.attachSchema(userSchema);
|
||||||
|
|
||||||
Meteor.users.generateApiKey = new ValidatedMethod({
|
Meteor.users.generateApiKey = new ValidatedMethod({
|
||||||
name: 'Users.methods.generateApiKey',
|
name: 'users.generateApiKey',
|
||||||
validate: null,
|
validate: null,
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
run(){
|
run(){
|
||||||
if(Meteor.isClient) return;
|
if(Meteor.isClient) return;
|
||||||
var user = Meteor.users.findOne(this.userId);
|
var user = Meteor.users.findOne(this.userId);
|
||||||
@@ -100,10 +106,15 @@ Meteor.users.generateApiKey = new ValidatedMethod({
|
|||||||
});
|
});
|
||||||
|
|
||||||
Meteor.users.setDarkMode = new ValidatedMethod({
|
Meteor.users.setDarkMode = new ValidatedMethod({
|
||||||
name: 'Users.methods.setDarkMode',
|
name: 'users.setDarkMode',
|
||||||
validate: new SimpleSchema({
|
validate: new SimpleSchema({
|
||||||
darkMode: { type: Boolean },
|
darkMode: { type: Boolean },
|
||||||
}).validator(),
|
}).validator(),
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
run({darkMode}){
|
run({darkMode}){
|
||||||
if (!this.userId) return;
|
if (!this.userId) return;
|
||||||
Meteor.users.update(this.userId, {$set: {darkMode}});
|
Meteor.users.update(this.userId, {$set: {darkMode}});
|
||||||
@@ -111,7 +122,7 @@ Meteor.users.setDarkMode = new ValidatedMethod({
|
|||||||
});
|
});
|
||||||
|
|
||||||
Meteor.users.sendVerificationEmail = new ValidatedMethod({
|
Meteor.users.sendVerificationEmail = new ValidatedMethod({
|
||||||
name: 'Users.methods.sendVerificationEmail',
|
name: 'users.sendVerificationEmail',
|
||||||
validate: new SimpleSchema({
|
validate: new SimpleSchema({
|
||||||
userId:{
|
userId:{
|
||||||
type: String,
|
type: String,
|
||||||
@@ -121,6 +132,11 @@ Meteor.users.sendVerificationEmail = new ValidatedMethod({
|
|||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
}).validator(),
|
}).validator(),
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
run({userId, address}){
|
run({userId, address}){
|
||||||
userId = this.userId || userId;
|
userId = this.userId || userId;
|
||||||
let user = Meteor.users.findOne(userId);
|
let user = Meteor.users.findOne(userId);
|
||||||
@@ -143,8 +159,13 @@ Meteor.users.isAdmin = function(userId){
|
|||||||
}
|
}
|
||||||
|
|
||||||
Meteor.users.canPickUsername = new ValidatedMethod({
|
Meteor.users.canPickUsername = new ValidatedMethod({
|
||||||
name: 'Users.methods.canPickUsername',
|
name: 'users.canPickUsername',
|
||||||
validate: userSchema.pick('username').validator(),
|
validate: userSchema.pick('username').validator(),
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
run({username}){
|
run({username}){
|
||||||
if (Meteor.isClient) return;
|
if (Meteor.isClient) return;
|
||||||
let user = Accounts.findUserByUsername(username);
|
let user = Accounts.findUserByUsername(username);
|
||||||
@@ -157,8 +178,13 @@ Meteor.users.canPickUsername = new ValidatedMethod({
|
|||||||
});
|
});
|
||||||
|
|
||||||
Meteor.users.setUsername = new ValidatedMethod({
|
Meteor.users.setUsername = new ValidatedMethod({
|
||||||
name: 'Users.methods.setUsername',
|
name: 'users.setUsername',
|
||||||
validate: userSchema.pick('username').validator(),
|
validate: userSchema.pick('username').validator(),
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
run({username}){
|
run({username}){
|
||||||
if (!this.userId) throw 'Can only set your username if logged in';
|
if (!this.userId) throw 'Can only set your username if logged in';
|
||||||
if (Meteor.isClient) return;
|
if (Meteor.isClient) return;
|
||||||
@@ -167,7 +193,7 @@ Meteor.users.setUsername = new ValidatedMethod({
|
|||||||
});
|
});
|
||||||
|
|
||||||
Meteor.users.subscribeToLibrary = new ValidatedMethod({
|
Meteor.users.subscribeToLibrary = new ValidatedMethod({
|
||||||
name: 'Users.methods.subscribeToLibrary',
|
name: 'users.subscribeToLibrary',
|
||||||
validate: new SimpleSchema({
|
validate: new SimpleSchema({
|
||||||
libraryId:{
|
libraryId:{
|
||||||
type: String,
|
type: String,
|
||||||
@@ -177,6 +203,11 @@ Meteor.users.subscribeToLibrary = new ValidatedMethod({
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
},
|
},
|
||||||
}).validator(),
|
}).validator(),
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
run({libraryId, subscribe}){
|
run({libraryId, subscribe}){
|
||||||
if (!this.userId) throw 'Can only subscribe if logged in';
|
if (!this.userId) throw 'Can only subscribe if logged in';
|
||||||
if (subscribe){
|
if (subscribe){
|
||||||
@@ -192,12 +223,17 @@ Meteor.users.subscribeToLibrary = new ValidatedMethod({
|
|||||||
});
|
});
|
||||||
|
|
||||||
Meteor.users.findUserByUsernameOrEmail = new ValidatedMethod({
|
Meteor.users.findUserByUsernameOrEmail = new ValidatedMethod({
|
||||||
name: 'Users.methods.findUserByUsernameOrEmail',
|
name: 'users.findUserByUsernameOrEmail',
|
||||||
validate: new SimpleSchema({
|
validate: new SimpleSchema({
|
||||||
usernameOrEmail:{
|
usernameOrEmail:{
|
||||||
type: String,
|
type: String,
|
||||||
},
|
},
|
||||||
}).validator(),
|
}).validator(),
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
run({usernameOrEmail}){
|
run({usernameOrEmail}){
|
||||||
if (Meteor.isClient) return;
|
if (Meteor.isClient) return;
|
||||||
let user = Accounts.findUserByUsername(usernameOrEmail) ||
|
let user = Accounts.findUserByUsername(usernameOrEmail) ||
|
||||||
|
|||||||
@@ -3,10 +3,6 @@ const PROPERTIES = Object.freeze({
|
|||||||
icon: '$vuetify.icons.action',
|
icon: '$vuetify.icons.action',
|
||||||
name: 'Action'
|
name: 'Action'
|
||||||
},
|
},
|
||||||
adjustment: {
|
|
||||||
icon: '$vuetify.icons.attribute_damage',
|
|
||||||
name: 'Attribute damage'
|
|
||||||
},
|
|
||||||
attack: {
|
attack: {
|
||||||
icon: '$vuetify.icons.attack',
|
icon: '$vuetify.icons.attack',
|
||||||
name: 'Attack'
|
name: 'Attack'
|
||||||
@@ -15,6 +11,10 @@ const PROPERTIES = Object.freeze({
|
|||||||
icon: '$vuetify.icons.attribute',
|
icon: '$vuetify.icons.attribute',
|
||||||
name: 'Attribute'
|
name: 'Attribute'
|
||||||
},
|
},
|
||||||
|
adjustment: {
|
||||||
|
icon: '$vuetify.icons.attribute_damage',
|
||||||
|
name: 'Attribute damage'
|
||||||
|
},
|
||||||
buff: {
|
buff: {
|
||||||
icon: '$vuetify.icons.buff',
|
icon: '$vuetify.icons.buff',
|
||||||
name: 'Buff'
|
name: 'Buff'
|
||||||
@@ -23,6 +23,10 @@ const PROPERTIES = Object.freeze({
|
|||||||
icon: '$vuetify.icons.class_level',
|
icon: '$vuetify.icons.class_level',
|
||||||
name: 'Class level'
|
name: 'Class level'
|
||||||
},
|
},
|
||||||
|
container: {
|
||||||
|
icon: 'work',
|
||||||
|
name: 'Container'
|
||||||
|
},
|
||||||
damage: {
|
damage: {
|
||||||
icon: '$vuetify.icons.damage',
|
icon: '$vuetify.icons.damage',
|
||||||
name: 'Damage'
|
name: 'Damage'
|
||||||
@@ -35,10 +39,6 @@ const PROPERTIES = Object.freeze({
|
|||||||
icon: '$vuetify.icons.effect',
|
icon: '$vuetify.icons.effect',
|
||||||
name: 'Effect'
|
name: 'Effect'
|
||||||
},
|
},
|
||||||
experience: {
|
|
||||||
icon: '$vuetify.icons.experience',
|
|
||||||
name: 'Experience'
|
|
||||||
},
|
|
||||||
feature: {
|
feature: {
|
||||||
icon: 'subject',
|
icon: 'subject',
|
||||||
name: 'Feature'
|
name: 'Feature'
|
||||||
@@ -47,6 +47,10 @@ const PROPERTIES = Object.freeze({
|
|||||||
icon: 'folder',
|
icon: 'folder',
|
||||||
name: 'Folder'
|
name: 'Folder'
|
||||||
},
|
},
|
||||||
|
item: {
|
||||||
|
icon: '$vuetify.icons.item',
|
||||||
|
name: 'Item'
|
||||||
|
},
|
||||||
note: {
|
note: {
|
||||||
icon: 'note',
|
icon: 'note',
|
||||||
name: 'Note'
|
name: 'Note'
|
||||||
@@ -75,14 +79,6 @@ const PROPERTIES = Object.freeze({
|
|||||||
icon: '$vuetify.icons.spell',
|
icon: '$vuetify.icons.spell',
|
||||||
name: 'Spell'
|
name: 'Spell'
|
||||||
},
|
},
|
||||||
container: {
|
|
||||||
icon: 'work',
|
|
||||||
name: 'Container'
|
|
||||||
},
|
|
||||||
item: {
|
|
||||||
icon: '$vuetify.icons.item',
|
|
||||||
name: 'Item'
|
|
||||||
},
|
|
||||||
toggle: {
|
toggle: {
|
||||||
icon: '$vuetify.icons.toggle',
|
icon: '$vuetify.icons.toggle',
|
||||||
name: 'Toggle'
|
name: 'Toggle'
|
||||||
|
|||||||
@@ -11,6 +11,10 @@ const SVG_ICONS = Object.freeze({
|
|||||||
name: 'attribute_damage',
|
name: 'attribute_damage',
|
||||||
shape: 'M 150,53.907593 V 396.625 H 86.563 L 258.093,497.188 429.656,396.626 H 366.22 V 53.908593 Z M 260.25,94.782 c 0.684,-0.028 1.34,-0.018 2,0.094 34.59085,1.140414 45.59236,58.23402 22.719,86.438 41.13,7.74 60.86,67.412 48.75,125.75 h -33.033 l -7.562,101.563 h -72.5 l -6.688,-101.563 h -31.593 c -10.68,-56.805 3.537,-119.376 48.47,-126.343 -23.10419,-27.90601 -9.69693,-87.09653 27.375,-85.845 0.677,0 1.378,-0.066 2.062,-0.094 z',
|
shape: 'M 150,53.907593 V 396.625 H 86.563 L 258.093,497.188 429.656,396.626 H 366.22 V 53.908593 Z M 260.25,94.782 c 0.684,-0.028 1.34,-0.018 2,0.094 34.59085,1.140414 45.59236,58.23402 22.719,86.438 41.13,7.74 60.86,67.412 48.75,125.75 h -33.033 l -7.562,101.563 h -72.5 l -6.688,-101.563 h -31.593 c -10.68,-56.805 3.537,-119.376 48.47,-126.343 -23.10419,-27.90601 -9.69693,-87.09653 27.375,-85.845 0.677,0 1.378,-0.066 2.062,-0.094 z',
|
||||||
},
|
},
|
||||||
|
'baby-face': {
|
||||||
|
name: 'baby_face',
|
||||||
|
shape: 'M254.443 49.593c-9.011.085-18 1.243-25.056 3.412-7.057 2.17-11.811 5.395-13.676 8.17-7.133 10.617-9.076 19.519-8.1 27.63.977 8.11 5.102 15.92 12.159 23.443 9.846 10.495 25.39 19.81 42.857 26.955-7.836-14.753-11.888-28.818-10.357-42.717 1.826-16.589 11.956-31.077 29.351-43.768-.63-.174-1.186-.377-1.85-.533-7.244-1.703-16.316-2.676-25.328-2.592zm37.79 17.461c-14.638 10.454-20.887 20.609-22.075 31.4-1.474 13.394 5.377 30.64 20.887 52.175l14.023 19.468c12.6-8.667 25.012-12.72 36.782-12.959a54.52 54.52 0 0 1 5.888.2c15.544 1.368 29.047 8.774 41.418 17.423l-10.312 14.752c-11.223-7.846-21.99-13.307-32.684-14.248-10.693-.94-22.044 2.044-36.463 13.838l-11.394-13.932a102.983 102.983 0 0 1 5.824-4.43l-22.74-6.167c-28.693-7.783-56.841-20.93-74.742-40.012-8.951-9.54-15.368-20.858-16.903-33.607-.569-4.726-.43-9.582.42-14.502C121.752 105.216 73 177.51 73 262.775c0 110.751 82.246 199.637 183 199.637s183-88.886 183-199.637c0-97.123-63.252-177.427-146.768-195.72zM170.15 157.138c13.872.282 28.637 5.837 43.547 18.033l-11.394 13.932c-14.419-11.794-25.77-14.779-36.463-13.838-10.693.941-21.46 6.402-32.684 14.248l-10.312-14.752c12.371-8.649 25.874-16.055 41.418-17.424a54.52 54.52 0 0 1 5.888-.199zm-2.15 40c26.955 0 49 22.045 49 49s-22.045 48.998-49 48.998c-26.386 0-48.053-21.125-48.957-47.3a32.955 32.955 0 0 1 0-3.395c.904-26.175 22.571-47.303 48.957-47.303zm176 0c26.955 0 49 22.045 49 49s-22.045 48.998-49 48.998c-26.386 0-48.053-21.125-48.957-47.3a32.955 32.955 0 0 1 0-3.395c.904-26.175 22.571-47.303 48.957-47.303zm-176 17.998c-1.378 0-2.73.097-4.059.268C176.22 220.226 185 232.224 185 246.138c0 13.914-8.78 25.91-21.059 30.733 1.329.17 2.681.267 4.059.267 17.228 0 31-13.772 31-31s-13.772-31.002-31-31.002zm176 0c-1.378 0-2.73.097-4.059.268C352.22 220.226 361 232.224 361 246.138c0 13.914-8.78 25.91-21.059 30.733 1.329.17 2.681.267 4.059.267 17.228 0 31-13.772 31-31s-13.772-31.002-31-31.002zm-284.746 3.006c-14.197 2.45-23.466 7.41-29.065 13.145-7.967 8.162-9.918 18.531-7.39 30.328 3.681 17.18 18.154 35.225 36.076 43.775A235.517 235.517 0 0 1 55 262.775c0-15.287 1.47-30.215 4.254-44.633zm393.492 0A235.355 235.355 0 0 1 457 262.775c0 14.575-1.339 28.823-3.875 42.615 17.922-8.55 32.395-26.595 36.076-43.775 2.528-11.797.577-22.166-7.39-30.328-5.599-5.735-14.868-10.695-29.065-13.145zM152 231.136c-8.391 0-15 6.61-15 15.002 0 3.263 1.008 6.248 2.723 8.688l23.545-18.65c-2.732-3.099-6.734-5.04-11.268-5.04zm176 0c-8.391 0-15 6.61-15 15.002 0 3.263 1.008 6.248 2.723 8.688l23.545-18.65c-2.732-3.099-6.734-5.04-11.268-5.04zm-98.41 49.95c8 6.34 13.916 10.984 18.228 13.718 4.313 2.735 6.56 3.356 8.182 3.356 1.623 0 3.87-.621 8.182-3.356 4.312-2.734 10.228-7.378 18.228-13.718l11.18 14.103c-8 6.34-14.084 11.208-19.772 14.815-5.687 3.606-11.44 6.154-17.818 6.154-6.377 0-12.13-2.548-17.818-6.154-5.688-3.607-11.772-8.474-19.772-14.815zm-82.393 51.1h217.606l-4.336 12.046s-8.333 23.283-25.164 46.664C318.472 414.277 292.167 439.09 256 439.09c-36.167 0-62.472-24.812-79.303-48.193-16.83-23.38-25.164-46.664-25.164-46.664zM218 350.137v32h32v-32z',
|
||||||
|
},
|
||||||
'back-and-forth': {
|
'back-and-forth': {
|
||||||
name: 'effect',
|
name: 'effect',
|
||||||
shape: 'M241.844 28.625l-21.188 5.063L33.25 78.53l-9.594 2.282 2.813 9.47 54.718 184.03 6.156 20.782 10.875-18.75 36.624-63.125 39.344 22.655 9.375-16.188-47.47-27.312L128 187.72l-4.656 8.06-30.406 52.47-45.75-153.844 156.625-37.47-30.344 52.345-4.69 8.126 8.126 4.656L332.75 211.75l-17.594 30.344 16.22 9.312 22.25-38.375 4.687-8.124-8.125-4.656-155.844-89.688 36.594-63.093 10.906-18.845zm-28.25 176.47l-57.438 99.31 155.22 89.5 8.093 4.658-4.69 8.093-44.06 76.25 218.81-52.5-63.874-215.47-44.094 76.25-4.656 8.064-8.094-4.656-155.218-89.5z',
|
shape: 'M241.844 28.625l-21.188 5.063L33.25 78.53l-9.594 2.282 2.813 9.47 54.718 184.03 6.156 20.782 10.875-18.75 36.624-63.125 39.344 22.655 9.375-16.188-47.47-27.312L128 187.72l-4.656 8.06-30.406 52.47-45.75-153.844 156.625-37.47-30.344 52.345-4.69 8.126 8.126 4.656L332.75 211.75l-17.594 30.344 16.22 9.312 22.25-38.375 4.687-8.124-8.125-4.656-155.844-89.688 36.594-63.093 10.906-18.845zm-28.25 176.47l-57.438 99.31 155.22 89.5 8.093 4.658-4.69 8.093-44.06 76.25 218.81-52.5-63.874-215.47-44.094 76.25-4.656 8.064-8.094-4.656-155.218-89.5z',
|
||||||
|
|||||||
6
app/imports/server/config/SimpleRestConfig.js
Normal file
6
app/imports/server/config/SimpleRestConfig.js
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
import { SimpleRest } from 'meteor/simple:rest';
|
||||||
|
|
||||||
|
SimpleRest.configure({
|
||||||
|
// No default collection methods get end points
|
||||||
|
collections: [],
|
||||||
|
});
|
||||||
@@ -1,11 +1,18 @@
|
|||||||
|
import CreatureProperties from '/imports/api/creature/CreatureProperties.js';
|
||||||
import LibraryNodes from '/imports/api/library/LibraryNodes.js';
|
import LibraryNodes from '/imports/api/library/LibraryNodes.js';
|
||||||
|
import { assertAdmin } from '/imports/api/sharing/sharingPermissions.js';
|
||||||
|
import { SyncedCron } from 'meteor/percolate:synced-cron';
|
||||||
|
|
||||||
let collections = [LibraryNodes];
|
Meteor.startup(() => {
|
||||||
|
const collections = [
|
||||||
|
CreatureProperties,
|
||||||
|
LibraryNodes,
|
||||||
|
];
|
||||||
|
|
||||||
if (Meteor.isServer) Meteor.startup(() => {
|
|
||||||
/**
|
/**
|
||||||
* Deletes all soft removed documents that were removed more than 30 minutes ago
|
* Deletes all soft removed documents that were removed more than 30 minutes ago
|
||||||
* and were not restored
|
* and were not restored
|
||||||
|
* @return {Number} Number of documents removed
|
||||||
*/
|
*/
|
||||||
const deleteOldSoftRemovedDocs = function(){
|
const deleteOldSoftRemovedDocs = function(){
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
@@ -14,30 +21,30 @@ if (Meteor.isServer) Meteor.startup(() => {
|
|||||||
collection.remove({
|
collection.remove({
|
||||||
removed: true,
|
removed: true,
|
||||||
removedAt: {$lt: thirtyMinutesAgo} // dates *before* 30 minutes ago
|
removedAt: {$lt: thirtyMinutesAgo} // dates *before* 30 minutes ago
|
||||||
}, error => {
|
}, function(error){
|
||||||
if (error) console.error(error);
|
if (error){
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
SyncedCron.add({
|
SyncedCron.add({
|
||||||
name: "Delete all soft removed items that haven't been restored",
|
name: 'deleteSoftRemovedDocs',
|
||||||
schedule: function(parser) {
|
schedule: function(parser) {
|
||||||
return parser.text('every 6 hours');
|
return parser.text('every 2 hours');
|
||||||
},
|
},
|
||||||
job: function() {
|
job: deleteOldSoftRemovedDocs,
|
||||||
deleteOldSoftRemovedDocs();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
SyncedCron.start();
|
||||||
|
|
||||||
// Add a method to manually trigger removal
|
// Add a method to manually trigger removal
|
||||||
Meteor.methods({
|
Meteor.methods({
|
||||||
deleteOldSoftRemovedDocs() {
|
deleteOldSoftRemovedDocs() {
|
||||||
const user = Meteor.users.findOne(this.userId);
|
assertAdmin(this.userId);
|
||||||
if (user && _.contains(user.roles, "admin")){
|
this.unblock();
|
||||||
return deleteOldSoftRemovedDocs();
|
deleteOldSoftRemovedDocs();
|
||||||
}
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
32
app/imports/server/publications/experiences.js
Normal file
32
app/imports/server/publications/experiences.js
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import SimpleSchema from 'simpl-schema';
|
||||||
|
import Creatures from '/imports/api/creature/Creatures.js';
|
||||||
|
import Experiences from '/imports/api/creature/experience/Experiences.js';
|
||||||
|
|
||||||
|
let schema = new SimpleSchema({
|
||||||
|
creatureId: {
|
||||||
|
type: String,
|
||||||
|
regEx: SimpleSchema.RegEx.Id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
Meteor.publish('experiences', function(creatureId){
|
||||||
|
schema.validate({ creatureId });
|
||||||
|
this.autorun(function (){
|
||||||
|
let userId = this.userId;
|
||||||
|
let creatureCursor = Creatures.find({
|
||||||
|
_id: creatureId,
|
||||||
|
$or: [
|
||||||
|
{readers: userId},
|
||||||
|
{writers: userId},
|
||||||
|
{owner: userId},
|
||||||
|
{public: true},
|
||||||
|
],
|
||||||
|
});
|
||||||
|
if (!creatureCursor.count()) return this.ready();
|
||||||
|
return [
|
||||||
|
Experiences.find({
|
||||||
|
creatureId,
|
||||||
|
}),
|
||||||
|
];
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
|
import '/imports/server/publications/publicationRateLimit.js';
|
||||||
import '/imports/server/publications/characterList.js';
|
import '/imports/server/publications/characterList.js';
|
||||||
import '/imports/server/publications/library.js';
|
import '/imports/server/publications/library.js';
|
||||||
import '/imports/server/publications/singleCharacter.js';
|
import '/imports/server/publications/singleCharacter.js';
|
||||||
|
import '/imports/server/publications/experiences.js';
|
||||||
import '/imports/server/publications/users.js';
|
import '/imports/server/publications/users.js';
|
||||||
import '/imports/server/publications/icons.js';
|
import '/imports/server/publications/icons.js';
|
||||||
|
|||||||
4
app/imports/server/publications/publicationRateLimit.js
Normal file
4
app/imports/server/publications/publicationRateLimit.js
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
// Limit all subscriptions to 1/s
|
||||||
|
DDPRateLimiter.addRule({
|
||||||
|
type: 'subscription',
|
||||||
|
}, 10, 10000);
|
||||||
@@ -93,6 +93,9 @@ export default {
|
|||||||
this.safeValue = null;
|
this.safeValue = null;
|
||||||
this.$nextTick(() => this.safeValue = this.value);
|
this.$nextTick(() => this.safeValue = this.value);
|
||||||
},
|
},
|
||||||
|
focus(){
|
||||||
|
this.$refs.input.focus();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
errors(){
|
errors(){
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<template lang="html">
|
<template lang="html">
|
||||||
<v-text-field
|
<v-text-field
|
||||||
|
ref="input"
|
||||||
v-bind="$attrs"
|
v-bind="$attrs"
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
:error-messages="errors"
|
:error-messages="errors"
|
||||||
|
|||||||
@@ -34,8 +34,7 @@
|
|||||||
drag_handle
|
drag_handle
|
||||||
</v-icon>
|
</v-icon>
|
||||||
<!--{{node && node.order}}-->
|
<!--{{node && node.order}}-->
|
||||||
<component
|
<tree-node-view
|
||||||
:is="treeNodeView"
|
|
||||||
:model="node"
|
:model="node"
|
||||||
:selected="selected"
|
:selected="selected"
|
||||||
/>
|
/>
|
||||||
@@ -80,13 +79,13 @@
|
|||||||
**/
|
**/
|
||||||
import { canBeParent } from '/imports/api/parenting/parenting.js';
|
import { canBeParent } from '/imports/api/parenting/parenting.js';
|
||||||
import { getPropertyIcon } from '/imports/constants/PROPERTIES.js';
|
import { getPropertyIcon } from '/imports/constants/PROPERTIES.js';
|
||||||
import treeNodeViewIndex from '/imports/ui/properties/treeNodeViews/treeNodeViewIndex.js';
|
import TreeNodeView from '/imports/ui/properties/treeNodeViews/TreeNodeView.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'TreeNode',
|
name: 'TreeNode',
|
||||||
components: {
|
components: {
|
||||||
...treeNodeViewIndex
|
TreeNodeView,
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
node: Object,
|
node: Object,
|
||||||
group: String,
|
group: String,
|
||||||
@@ -100,10 +99,6 @@
|
|||||||
expanded: false,
|
expanded: false,
|
||||||
}},
|
}},
|
||||||
computed: {
|
computed: {
|
||||||
treeNodeView(){
|
|
||||||
let type = this.node.type;
|
|
||||||
return treeNodeViewIndex[type] || treeNodeViewIndex.default;
|
|
||||||
},
|
|
||||||
hasChildren(){
|
hasChildren(){
|
||||||
return this.children && this.children.length || this.lazy && !this.expanded;
|
return this.children && this.children.length || this.lazy && !this.expanded;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -107,7 +107,6 @@
|
|||||||
let allowed = isParentAllowed({parentType, childType});
|
let allowed = isParentAllowed({parentType, childType});
|
||||||
return allowed;
|
return allowed;
|
||||||
},
|
},
|
||||||
log: console.log,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1,8 +1,15 @@
|
|||||||
<template lang="html">
|
<template lang="html">
|
||||||
<dialog-base>
|
<dialog-base :color="model.color">
|
||||||
<v-toolbar-title slot="toolbar">
|
<template slot="toolbar">
|
||||||
Creature Form Dialog
|
<v-toolbar-title>
|
||||||
</v-toolbar-title>
|
Creature Form Dialog
|
||||||
|
</v-toolbar-title>
|
||||||
|
<v-spacer />
|
||||||
|
<color-picker
|
||||||
|
:value="model.color"
|
||||||
|
@input="value => change({path: ['color'], value})"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
<div>
|
<div>
|
||||||
<creature-form
|
<creature-form
|
||||||
:model="model"
|
:model="model"
|
||||||
@@ -27,11 +34,13 @@ import {updateCreature} from '/imports/api/creature/Creatures.js';
|
|||||||
import DialogBase from '/imports/ui/dialogStack/DialogBase.vue';
|
import DialogBase from '/imports/ui/dialogStack/DialogBase.vue';
|
||||||
import CreatureForm from '/imports/ui/creature/CreatureForm.vue'
|
import CreatureForm from '/imports/ui/creature/CreatureForm.vue'
|
||||||
import { assertEditPermission } from '/imports/api/creature/creaturePermissions.js';
|
import { assertEditPermission } from '/imports/api/creature/creaturePermissions.js';
|
||||||
|
import ColorPicker from '/imports/ui/components/ColorPicker.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
DialogBase,
|
DialogBase,
|
||||||
CreatureForm,
|
CreatureForm,
|
||||||
|
ColorPicker,
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
_id: String,
|
_id: String,
|
||||||
@@ -52,8 +61,16 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
change({path, value, ack}){
|
change({path, value, ack}){
|
||||||
updateCreature.call({_id: this._id, path, value}, (error, result) =>{
|
updateCreature.call({_id: this._id, path, value}, (error) =>{
|
||||||
ack && ack(error && error.reason || error);
|
if (error){
|
||||||
|
if(ack){
|
||||||
|
ack(error && error.reason || error)
|
||||||
|
} else {
|
||||||
|
console.error(error)
|
||||||
|
}
|
||||||
|
} else if (ack) {
|
||||||
|
ack();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<template lang="html">
|
<template lang="html">
|
||||||
<v-btn
|
<v-btn
|
||||||
:loading="loading"
|
:loading="loading"
|
||||||
:disabled="loading"
|
|
||||||
outline
|
outline
|
||||||
style="width: 160px;"
|
style="width: 160px;"
|
||||||
@click="rest"
|
@click="rest"
|
||||||
|
|||||||
247
app/imports/ui/creature/character/CharacterSheetToolbar.vue
Normal file
247
app/imports/ui/creature/character/CharacterSheetToolbar.vue
Normal file
@@ -0,0 +1,247 @@
|
|||||||
|
<template lang="html">
|
||||||
|
<v-toolbar
|
||||||
|
app
|
||||||
|
class="character-sheet-toolbar"
|
||||||
|
:color="toolbarColor"
|
||||||
|
:dark="isDark"
|
||||||
|
:light="!isDark"
|
||||||
|
tabs
|
||||||
|
dense
|
||||||
|
>
|
||||||
|
<v-toolbar-side-icon @click="toggleDrawer" />
|
||||||
|
<v-toolbar-title>
|
||||||
|
<v-fade-transition
|
||||||
|
mode="out-in"
|
||||||
|
>
|
||||||
|
<div :key="$store.state.pageTitle">
|
||||||
|
{{ $store.state.pageTitle }}
|
||||||
|
</div>
|
||||||
|
</v-fade-transition>
|
||||||
|
</v-toolbar-title>
|
||||||
|
<v-spacer />
|
||||||
|
<v-fade-transition
|
||||||
|
mode="out-in"
|
||||||
|
>
|
||||||
|
<div :key="$route.meta.title">
|
||||||
|
<v-toolbar-items v-if="creature">
|
||||||
|
<v-btn
|
||||||
|
v-if="editPermission"
|
||||||
|
flat
|
||||||
|
icon
|
||||||
|
@click="recompute(creature._id)"
|
||||||
|
>
|
||||||
|
<v-icon>refresh</v-icon>
|
||||||
|
</v-btn>
|
||||||
|
<v-menu
|
||||||
|
bottom
|
||||||
|
left
|
||||||
|
transition="slide-y-transition"
|
||||||
|
data-id="creature-menu"
|
||||||
|
>
|
||||||
|
<template #activator="{ on }">
|
||||||
|
<v-btn
|
||||||
|
icon
|
||||||
|
v-on="on"
|
||||||
|
>
|
||||||
|
<v-icon>more_vert</v-icon>
|
||||||
|
</v-btn>
|
||||||
|
</template>
|
||||||
|
<v-list v-if="editPermission">
|
||||||
|
<v-list-tile @click="deleteCharacter">
|
||||||
|
<v-list-tile-title>
|
||||||
|
<v-icon>delete</v-icon> Delete
|
||||||
|
</v-list-tile-title>
|
||||||
|
</v-list-tile>
|
||||||
|
<v-list-tile @click="showCharacterForm">
|
||||||
|
<v-list-tile-title>
|
||||||
|
<v-icon>create</v-icon> Edit details
|
||||||
|
</v-list-tile-title>
|
||||||
|
</v-list-tile>
|
||||||
|
<v-list-tile @click="showShareDialog">
|
||||||
|
<v-list-tile-title>
|
||||||
|
<v-icon>share</v-icon> Sharing
|
||||||
|
</v-list-tile-title>
|
||||||
|
</v-list-tile>
|
||||||
|
</v-list>
|
||||||
|
<v-list v-else>
|
||||||
|
<v-list-tile @click="unshareWithMe">
|
||||||
|
<v-list-tile-title>
|
||||||
|
<v-icon>delete</v-icon> Unshare with me
|
||||||
|
</v-list-tile-title>
|
||||||
|
</v-list-tile>
|
||||||
|
</v-list>
|
||||||
|
</v-menu>
|
||||||
|
</v-toolbar-items>
|
||||||
|
</div>
|
||||||
|
</v-fade-transition>
|
||||||
|
<v-fade-transition
|
||||||
|
slot="extension"
|
||||||
|
mode="out-in"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
:key="$route.meta.title"
|
||||||
|
style="width: 100%"
|
||||||
|
>
|
||||||
|
<v-tabs
|
||||||
|
v-if="creature"
|
||||||
|
slot="extension"
|
||||||
|
:value="value"
|
||||||
|
centered
|
||||||
|
grow
|
||||||
|
max="100px"
|
||||||
|
@change="e => $emit('input', e)"
|
||||||
|
>
|
||||||
|
<v-tab>
|
||||||
|
Stats
|
||||||
|
</v-tab>
|
||||||
|
<v-tab>
|
||||||
|
Features
|
||||||
|
</v-tab>
|
||||||
|
<v-tab>
|
||||||
|
Inventory
|
||||||
|
</v-tab>
|
||||||
|
<v-tab>
|
||||||
|
Spells
|
||||||
|
</v-tab>
|
||||||
|
<v-tab>
|
||||||
|
Persona
|
||||||
|
</v-tab>
|
||||||
|
<v-tab>
|
||||||
|
Tree
|
||||||
|
</v-tab>
|
||||||
|
</v-tabs>
|
||||||
|
</div>
|
||||||
|
</v-fade-transition>
|
||||||
|
</v-toolbar>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import Creatures from '/imports/api/creature/Creatures.js';
|
||||||
|
import removeCreature from '/imports/api/creature/removeCreature.js';
|
||||||
|
import { mapMutations } from 'vuex';
|
||||||
|
import { theme } from '/imports/ui/theme.js';
|
||||||
|
import { recomputeCreature } from '/imports/api/creature/computation/recomputeCreature.js';
|
||||||
|
import { assertEditPermission } from '/imports/api/creature/creaturePermissions.js';
|
||||||
|
import { updateUserSharePermissions } from '/imports/api/sharing/sharing.js';
|
||||||
|
import isDarkColor from '/imports/ui/utility/isDarkColor.js';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
value: {
|
||||||
|
type: Number,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
data(){return {
|
||||||
|
theme,
|
||||||
|
}},
|
||||||
|
computed: {
|
||||||
|
creatureId(){
|
||||||
|
return this.$route.params.id;
|
||||||
|
},
|
||||||
|
toolbarColor(){
|
||||||
|
if (this.creature && this.creature.color){
|
||||||
|
return this.creature.color;
|
||||||
|
} else {
|
||||||
|
return this.$vuetify.theme.secondary;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
isDark(){
|
||||||
|
return isDarkColor(this.toolbarColor);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
...mapMutations([
|
||||||
|
'toggleDrawer',
|
||||||
|
]),
|
||||||
|
recompute(charId){
|
||||||
|
recomputeCreature.call({charId});
|
||||||
|
},
|
||||||
|
showCharacterForm(){
|
||||||
|
this.$store.commit('pushDialogStack', {
|
||||||
|
component: 'creature-form-dialog',
|
||||||
|
elementId: 'creature-menu',
|
||||||
|
data: {
|
||||||
|
_id: this.creatureId,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
showShareDialog(){
|
||||||
|
this.$store.commit('pushDialogStack', {
|
||||||
|
component: 'share-dialog',
|
||||||
|
elementId: 'creature-menu',
|
||||||
|
data: {
|
||||||
|
docRef: {
|
||||||
|
id: this.creatureId,
|
||||||
|
collection: 'creatures',
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
deleteCharacter(){
|
||||||
|
let that = this;
|
||||||
|
this.$store.commit('pushDialogStack', {
|
||||||
|
component: 'delete-confirmation-dialog',
|
||||||
|
elementId: 'creature-menu',
|
||||||
|
data: {
|
||||||
|
name: this.creature.name,
|
||||||
|
typeName: 'Character'
|
||||||
|
},
|
||||||
|
callback(confirmation){
|
||||||
|
if(!confirmation) return;
|
||||||
|
removeCreature.call({charId: that.creatureId}, (error) => {
|
||||||
|
if (error) {
|
||||||
|
console.error(error);
|
||||||
|
} else {
|
||||||
|
that.$router.push('/characterList');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
unshareWithMe(){
|
||||||
|
updateUserSharePermissions.call({
|
||||||
|
docRef: {
|
||||||
|
collection: 'creatures',
|
||||||
|
id: this.creatureId,
|
||||||
|
},
|
||||||
|
userId: Meteor.userId(),
|
||||||
|
role: 'none',
|
||||||
|
}, (error) => {
|
||||||
|
if (error) {
|
||||||
|
console.error(error);
|
||||||
|
} else {
|
||||||
|
this.$router.push('/characterList');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
meteor: {
|
||||||
|
$subscribe: {
|
||||||
|
'singleCharacter'(){
|
||||||
|
return [this.creatureId];
|
||||||
|
},
|
||||||
|
},
|
||||||
|
creature(){
|
||||||
|
return Creatures.findOne(this.creatureId);
|
||||||
|
},
|
||||||
|
editPermission(){
|
||||||
|
try {
|
||||||
|
assertEditPermission(this.creature, Meteor.userId());
|
||||||
|
return true;
|
||||||
|
} catch (e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="css">
|
||||||
|
.character-sheet-toolbar .v-tabs__container--grow .v-tabs__div {
|
||||||
|
max-width: 120px !important;
|
||||||
|
}
|
||||||
|
.character-sheet-toolbar .v-tabs__bar {
|
||||||
|
background: none !important;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
<div class="inventory">
|
<div class="inventory">
|
||||||
<column-layout>
|
<column-layout>
|
||||||
<div>
|
<div>
|
||||||
<toolbar-card color="">
|
<toolbar-card :color="$vuetify.theme.secondary">
|
||||||
<v-spacer slot="toolbar" />
|
<v-spacer slot="toolbar" />
|
||||||
<v-switch
|
<v-switch
|
||||||
v-if="context.editPermission !== false"
|
v-if="context.editPermission !== false"
|
||||||
|
|||||||
@@ -20,6 +20,70 @@
|
|||||||
</v-card-text>
|
</v-card-text>
|
||||||
</v-card>
|
</v-card>
|
||||||
</div>
|
</div>
|
||||||
|
<div>
|
||||||
|
<v-card class="class-details">
|
||||||
|
<v-card-title
|
||||||
|
v-if="creature.variables.level"
|
||||||
|
class="title"
|
||||||
|
>
|
||||||
|
Level {{ creature.variables.level.value }}
|
||||||
|
</v-card-title>
|
||||||
|
<v-list>
|
||||||
|
<v-list-tile>
|
||||||
|
<v-list-tile-content>
|
||||||
|
<v-list-tile-title
|
||||||
|
v-if="
|
||||||
|
creature.variables.milestoneLevels &&
|
||||||
|
creature.variables.milestoneLevels.value
|
||||||
|
"
|
||||||
|
>
|
||||||
|
{{ creature.variables.milestoneLevels.value }} Milestone levels
|
||||||
|
</v-list-tile-title>
|
||||||
|
<v-list-tile-title v-else>
|
||||||
|
{{
|
||||||
|
creature.variables.xp &&
|
||||||
|
creature.variables.xp.value ||
|
||||||
|
0
|
||||||
|
}} XP
|
||||||
|
</v-list-tile-title>
|
||||||
|
</v-list-tile-content>
|
||||||
|
<v-list-tile-action>
|
||||||
|
<v-btn
|
||||||
|
flat
|
||||||
|
icon
|
||||||
|
data-id="experience-info-button"
|
||||||
|
@click="showExperienceList"
|
||||||
|
>
|
||||||
|
<v-icon>info</v-icon>
|
||||||
|
</v-btn>
|
||||||
|
</v-list-tile-action>
|
||||||
|
<v-list-tile-action>
|
||||||
|
<v-btn
|
||||||
|
flat
|
||||||
|
icon
|
||||||
|
data-id="experience-add-button"
|
||||||
|
@click="addExperience"
|
||||||
|
>
|
||||||
|
<v-icon>add</v-icon>
|
||||||
|
</v-btn>
|
||||||
|
</v-list-tile-action>
|
||||||
|
</v-list-tile>
|
||||||
|
<v-list-tile
|
||||||
|
v-for="classLevel in highestClassLevels"
|
||||||
|
:key="classLevel._id"
|
||||||
|
>
|
||||||
|
<v-list-tile-content>
|
||||||
|
<v-list-tile-title>
|
||||||
|
{{ classLevel.name }}
|
||||||
|
</v-list-tile-title>
|
||||||
|
</v-list-tile-content>
|
||||||
|
<v-list-tile-avatar>
|
||||||
|
{{ classLevel.level }}
|
||||||
|
</v-list-tile-avatar>
|
||||||
|
</v-list-tile>
|
||||||
|
</v-list>
|
||||||
|
</v-card>
|
||||||
|
</div>
|
||||||
<div
|
<div
|
||||||
v-for="note in notes"
|
v-for="note in notes"
|
||||||
:key="note._id"
|
:key="note._id"
|
||||||
@@ -37,6 +101,7 @@ import Creatures from '/imports/api/creature/Creatures.js';
|
|||||||
import CreatureProperties from '/imports/api/creature/CreatureProperties.js';
|
import CreatureProperties from '/imports/api/creature/CreatureProperties.js';
|
||||||
import ColumnLayout from '/imports/ui/components/ColumnLayout.vue';
|
import ColumnLayout from '/imports/ui/components/ColumnLayout.vue';
|
||||||
import NoteCard from '/imports/ui/properties/components/persona/NoteCard.vue';
|
import NoteCard from '/imports/ui/properties/components/persona/NoteCard.vue';
|
||||||
|
import getActiveProperties from '/imports/api/creature/getActiveProperties.js'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
@@ -44,7 +109,10 @@ export default {
|
|||||||
NoteCard,
|
NoteCard,
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
creatureId: String,
|
creatureId: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
meteor: {
|
meteor: {
|
||||||
notes(){
|
notes(){
|
||||||
@@ -58,8 +126,34 @@ export default {
|
|||||||
},
|
},
|
||||||
creature(){
|
creature(){
|
||||||
return Creatures.findOne(this.creatureId);
|
return Creatures.findOne(this.creatureId);
|
||||||
}
|
},
|
||||||
|
classLevels(){
|
||||||
|
return getActiveProperties({
|
||||||
|
ancestorId: this.creatureId,
|
||||||
|
filter: {type: 'classLevel'},
|
||||||
|
});
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
computed: {
|
||||||
|
highestClassLevels(){
|
||||||
|
let highestLevels = {};
|
||||||
|
let highestLevelsList = [];
|
||||||
|
this.classLevels.forEach(classLevel => {
|
||||||
|
let name = classLevel.vairableName;
|
||||||
|
if (
|
||||||
|
!highestLevels[name] ||
|
||||||
|
highestLevels[name].level < classLevel.level
|
||||||
|
){
|
||||||
|
highestLevels[name] = classLevel;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
for (let name in highestLevels){
|
||||||
|
highestLevelsList.push(highestLevels[name]);
|
||||||
|
}
|
||||||
|
highestLevelsList.sort((a, b) => a.level - b.level);
|
||||||
|
return highestLevelsList;
|
||||||
|
},
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
showCharacterForm(){
|
showCharacterForm(){
|
||||||
this.$store.commit('pushDialogStack', {
|
this.$store.commit('pushDialogStack', {
|
||||||
@@ -70,6 +164,28 @@ export default {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
addExperience(){
|
||||||
|
this.$store.commit('pushDialogStack', {
|
||||||
|
component: 'experience-insert-dialog',
|
||||||
|
elementId: 'experience-add-button',
|
||||||
|
data: {
|
||||||
|
creatureIds: [this.creatureId],
|
||||||
|
startAsMilestone: this.creature.variables.milestoneLevels &&
|
||||||
|
!!this.creature.variables.milestoneLevels.value,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
showExperienceList(){
|
||||||
|
this.$store.commit('pushDialogStack', {
|
||||||
|
component: 'experience-list-dialog',
|
||||||
|
elementId: 'experience-info-button',
|
||||||
|
data: {
|
||||||
|
creatureId: this.creatureId,
|
||||||
|
startAsMilestone: this.creature.variables.milestoneLevels &&
|
||||||
|
!!this.creature.variables.milestoneLevels.value,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -247,44 +247,27 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div
|
<div
|
||||||
v-if="actions.length"
|
v-for="action in actions"
|
||||||
|
:key="action._id"
|
||||||
class="actions"
|
class="actions"
|
||||||
>
|
>
|
||||||
<v-card>
|
<action-card
|
||||||
<v-list
|
:model="action"
|
||||||
two-line
|
:data-id="action._id"
|
||||||
subheader
|
@click="clickProperty({_id: action._id})"
|
||||||
>
|
/>
|
||||||
<v-subheader>Actions</v-subheader>
|
|
||||||
<action-list-tile
|
|
||||||
v-for="action in actions"
|
|
||||||
:key="action._id"
|
|
||||||
:model="action"
|
|
||||||
:data-id="action._id"
|
|
||||||
@click="clickProperty({_id: action._id})"
|
|
||||||
/>
|
|
||||||
</v-list>
|
|
||||||
</v-card>
|
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
v-if="attacks.length"
|
v-for="attack in attacks"
|
||||||
class="actions"
|
:key="attack._id"
|
||||||
|
class="attacks"
|
||||||
>
|
>
|
||||||
<v-card>
|
<action-card
|
||||||
<v-list
|
attack
|
||||||
two-line
|
:model="attack"
|
||||||
subheader
|
:data-id="attack._id"
|
||||||
>
|
@click="clickProperty({_id: attack._id})"
|
||||||
<v-subheader>Attacks</v-subheader>
|
/>
|
||||||
<attack-list-tile
|
|
||||||
v-for="attack in attacks"
|
|
||||||
:key="attack._id"
|
|
||||||
:model="attack"
|
|
||||||
:data-id="attack._id"
|
|
||||||
@click="clickProperty({_id: attack._id})"
|
|
||||||
/>
|
|
||||||
</v-list>
|
|
||||||
</v-card>
|
|
||||||
</div>
|
</div>
|
||||||
</column-layout>
|
</column-layout>
|
||||||
</div>
|
</div>
|
||||||
@@ -302,8 +285,7 @@
|
|||||||
import SkillListTile from '/imports/ui/properties/components/skills/SkillListTile.vue';
|
import SkillListTile from '/imports/ui/properties/components/skills/SkillListTile.vue';
|
||||||
import ResourceCard from '/imports/ui/properties/components/attributes/ResourceCard.vue';
|
import ResourceCard from '/imports/ui/properties/components/attributes/ResourceCard.vue';
|
||||||
import SpellSlotListTile from '/imports/ui/properties/components/attributes/SpellSlotListTile.vue';
|
import SpellSlotListTile from '/imports/ui/properties/components/attributes/SpellSlotListTile.vue';
|
||||||
import ActionListTile from '/imports/ui/properties/components/actions/ActionListTile.vue';
|
import ActionCard from '/imports/ui/properties/components/actions/ActionCard.vue';
|
||||||
import AttackListTile from '/imports/ui/properties/components/actions/AttackListTile.vue';
|
|
||||||
import RestButton from '/imports/ui/creature/RestButton.vue';
|
import RestButton from '/imports/ui/creature/RestButton.vue';
|
||||||
import getActiveProperties from '/imports/api/creature/getActiveProperties.js';
|
import getActiveProperties from '/imports/api/creature/getActiveProperties.js';
|
||||||
|
|
||||||
@@ -345,8 +327,7 @@
|
|||||||
SkillListTile,
|
SkillListTile,
|
||||||
ResourceCard,
|
ResourceCard,
|
||||||
SpellSlotListTile,
|
SpellSlotListTile,
|
||||||
ActionListTile,
|
ActionCard,
|
||||||
AttackListTile,
|
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
creatureId: {
|
creatureId: {
|
||||||
@@ -401,7 +382,14 @@
|
|||||||
return getProperties(this.creature, {type: 'action'});
|
return getProperties(this.creature, {type: 'action'});
|
||||||
},
|
},
|
||||||
attacks(){
|
attacks(){
|
||||||
return getProperties(this.creature, {type: 'attack'});
|
let props = getProperties(this.creature, {type: 'attack'}).map(attack => {
|
||||||
|
attack.children = getActiveProperties({
|
||||||
|
ancestorId: attack._id,
|
||||||
|
options: {sort: {order: 1}},
|
||||||
|
});
|
||||||
|
return attack;
|
||||||
|
});
|
||||||
|
return props;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
</p>
|
</p>
|
||||||
</v-fade-transition>
|
</v-fade-transition>
|
||||||
<template v-if="!editing && !embedded">
|
<template v-if="!editing && !embedded">
|
||||||
<v-divider />
|
<v-divider class="my-2" />
|
||||||
<creature-properties-tree
|
<creature-properties-tree
|
||||||
v-if="!editing"
|
v-if="!editing"
|
||||||
:root="{collection: 'creatureProperties', id: model._id}"
|
:root="{collection: 'creatureProperties', id: model._id}"
|
||||||
|
|||||||
68
app/imports/ui/creature/experiences/ExperienceForm.vue
Normal file
68
app/imports/ui/creature/experiences/ExperienceForm.vue
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
<template lang="html">
|
||||||
|
<div class="experience-form">
|
||||||
|
<div class="layout column align-center">
|
||||||
|
<smart-switch
|
||||||
|
label="Milestone"
|
||||||
|
class="mx-3"
|
||||||
|
:value="milestone"
|
||||||
|
@change="makeMilestone"
|
||||||
|
/>
|
||||||
|
<text-field
|
||||||
|
v-if="milestone"
|
||||||
|
label="Levels"
|
||||||
|
type="number"
|
||||||
|
class="base-value-field text-xs-center large-format no-flex"
|
||||||
|
:value="model.levels"
|
||||||
|
:error-messages="errors.levels"
|
||||||
|
@change="change('levels', ...arguments)"
|
||||||
|
/>
|
||||||
|
<text-field
|
||||||
|
v-else
|
||||||
|
type="number"
|
||||||
|
class="base-value-field text-xs-center large-format no-flex"
|
||||||
|
suffix="XP"
|
||||||
|
autofocus
|
||||||
|
:value="model.xp"
|
||||||
|
:error-messages="errors.xp"
|
||||||
|
@change="change('xp', ...arguments)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<text-field
|
||||||
|
label="Name"
|
||||||
|
:autofocus="milestone"
|
||||||
|
:value="model.name"
|
||||||
|
:error-messages="errors.name"
|
||||||
|
@change="change('name', ...arguments)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import propertyFormMixin from '/imports/ui/properties/forms/shared/propertyFormMixin.js';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
mixins: [propertyFormMixin],
|
||||||
|
props: {
|
||||||
|
startAsMilestone: {
|
||||||
|
type: Boolean,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
data(){return {
|
||||||
|
milestone: this.startAsMilestone,
|
||||||
|
}},
|
||||||
|
methods: {
|
||||||
|
makeMilestone(milestone, ack){
|
||||||
|
this.milestone = milestone;
|
||||||
|
if (milestone){
|
||||||
|
this.change('xp', undefined);
|
||||||
|
this.change('levels', 1, ack);
|
||||||
|
} else {
|
||||||
|
this.change('levels', undefined, ack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="css" scoped>
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
<template lang="html">
|
||||||
|
<dialog-base>
|
||||||
|
<experience-form
|
||||||
|
:start-as-milestone="startAsMilestone"
|
||||||
|
:model="model"
|
||||||
|
:errors="errors"
|
||||||
|
@change="change"
|
||||||
|
@push="push"
|
||||||
|
@pull="pull"
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
slot="actions"
|
||||||
|
class="layout row justify-end"
|
||||||
|
>
|
||||||
|
<v-btn
|
||||||
|
flat
|
||||||
|
:disabled="!valid"
|
||||||
|
@click="insertExperience"
|
||||||
|
>
|
||||||
|
Insert
|
||||||
|
</v-btn>
|
||||||
|
</div>
|
||||||
|
</dialog-base>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import DialogBase from '/imports/ui/dialogStack/DialogBase.vue';
|
||||||
|
import ExperienceForm from '/imports/ui/creature/experiences/ExperienceForm.vue';
|
||||||
|
import { ExperienceSchema, insertExperience } from '/imports/api/creature/experience/Experiences.js';
|
||||||
|
import schemaFormMixin from '/imports/ui/properties/forms/shared/schemaFormMixin.js';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
DialogBase,
|
||||||
|
ExperienceForm,
|
||||||
|
},
|
||||||
|
mixins: [schemaFormMixin],
|
||||||
|
provide: {
|
||||||
|
context: {
|
||||||
|
debounceTime: 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
creatureIds: {
|
||||||
|
type: Array,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
startAsMilestone: {
|
||||||
|
type: Boolean,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
data(){
|
||||||
|
let schema = ExperienceSchema.omit('creatureId');
|
||||||
|
let startingModel = {};
|
||||||
|
if (this.startAsMilestone){
|
||||||
|
startingModel.levels = 1;
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
model: schema.clean(startingModel),
|
||||||
|
schema: schema,
|
||||||
|
validationContext: schema.newContext(),
|
||||||
|
debounceTime: 0,
|
||||||
|
};
|
||||||
|
},
|
||||||
|
methods:{
|
||||||
|
insertExperience(){
|
||||||
|
let experience = this.schema.clean(this.model);
|
||||||
|
let id = insertExperience.call({
|
||||||
|
experience,
|
||||||
|
creatureIds: this.creatureIds,
|
||||||
|
}, (error) => {
|
||||||
|
if (error){
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
this.$store.dispatch('popDialogStack', id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="css" scoped>
|
||||||
|
</style>
|
||||||
174
app/imports/ui/creature/experiences/ExperienceListDialog.vue
Normal file
174
app/imports/ui/creature/experiences/ExperienceListDialog.vue
Normal file
@@ -0,0 +1,174 @@
|
|||||||
|
<template lang="html">
|
||||||
|
<dialog-base>
|
||||||
|
<template slot="toolbar">
|
||||||
|
<v-toolbar-title>
|
||||||
|
Experiences
|
||||||
|
</v-toolbar-title>
|
||||||
|
<v-spacer />
|
||||||
|
<v-btn
|
||||||
|
icon
|
||||||
|
flat
|
||||||
|
data-id="experience-add-button"
|
||||||
|
@click="addExperience"
|
||||||
|
>
|
||||||
|
<v-icon>add</v-icon>
|
||||||
|
</v-btn>
|
||||||
|
<v-btn
|
||||||
|
icon
|
||||||
|
flat
|
||||||
|
@click="recompute"
|
||||||
|
>
|
||||||
|
<v-icon>refresh</v-icon>
|
||||||
|
</v-btn>
|
||||||
|
</template>
|
||||||
|
<div
|
||||||
|
v-if="!$subReady.experiences"
|
||||||
|
class="layout column align-center justify-center fill-height"
|
||||||
|
>
|
||||||
|
<v-progress-circular
|
||||||
|
indeterminate
|
||||||
|
size="240"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
v-else-if="experiences.length === 0"
|
||||||
|
class="layout column align-center justify-center fill-height"
|
||||||
|
>
|
||||||
|
<v-icon style="font-size: 240px; width: 240px; height: 240px;">
|
||||||
|
$vuetify.icons.baby_face
|
||||||
|
</v-icon>
|
||||||
|
<p class="headline">
|
||||||
|
No experiences
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<v-list v-else>
|
||||||
|
<v-slide-x-transition
|
||||||
|
group
|
||||||
|
mode="out"
|
||||||
|
>
|
||||||
|
<v-list-tile
|
||||||
|
v-for="experience in experiences"
|
||||||
|
:key="experience._id"
|
||||||
|
:data-id="experience._id"
|
||||||
|
>
|
||||||
|
<v-list-tile-action class="mr-3">
|
||||||
|
<v-list-tile-action-text>
|
||||||
|
{{ formatDate(experience.date) }}
|
||||||
|
</v-list-tile-action-text>
|
||||||
|
</v-list-tile-action>
|
||||||
|
<v-list-tile-content>
|
||||||
|
<template v-if="experience.name">
|
||||||
|
<v-list-tile-title>
|
||||||
|
{{ experience.name }}
|
||||||
|
</v-list-tile-title>
|
||||||
|
<v-list-tile-sub-title>
|
||||||
|
{{ xpText(experience) }}
|
||||||
|
</v-list-tile-sub-title>
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
<v-list-tile-title>
|
||||||
|
{{ xpText(experience) }}
|
||||||
|
</v-list-tile-title>
|
||||||
|
</template>
|
||||||
|
</v-list-tile-content>
|
||||||
|
<v-list-tile-action>
|
||||||
|
<v-btn
|
||||||
|
icon
|
||||||
|
flat
|
||||||
|
:loading="experiencesRemovalLoading.has(experience._id)"
|
||||||
|
@click="removeExperience(experience._id)"
|
||||||
|
>
|
||||||
|
<v-icon>delete</v-icon>
|
||||||
|
</v-btn>
|
||||||
|
</v-list-tile-action>
|
||||||
|
</v-list-tile>
|
||||||
|
</v-slide-x-transition>
|
||||||
|
</v-list>
|
||||||
|
</dialog-base>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { format } from 'date-fns';
|
||||||
|
import DialogBase from '/imports/ui/dialogStack/DialogBase.vue';
|
||||||
|
import Experiences, { removeExperience, recomputeExperiences } from '/imports/api/creature/experience/Experiences.js';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
DialogBase,
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
creatureId: {
|
||||||
|
type: String,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
startAsMilestone: {
|
||||||
|
type: Boolean,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
data(){ return {
|
||||||
|
experiencesRemovalLoading: new Set(),
|
||||||
|
recomputeLoading: false,
|
||||||
|
}},
|
||||||
|
meteor: {
|
||||||
|
$subscribe: {
|
||||||
|
'experiences'(){
|
||||||
|
return [this.creatureId];
|
||||||
|
},
|
||||||
|
},
|
||||||
|
experiences(){
|
||||||
|
return Experiences.find({
|
||||||
|
creatureId: this.creatureId
|
||||||
|
}, {
|
||||||
|
sort: {date: 1}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
xpText(experience){
|
||||||
|
let xpText = [];
|
||||||
|
if (experience.levels === 1){
|
||||||
|
xpText.push('1 Milestone level');
|
||||||
|
} else if (experience.levels){
|
||||||
|
xpText.push(`${experience.levels} Milestone levels`);
|
||||||
|
}
|
||||||
|
if (experience.xp || !experience.levels){
|
||||||
|
xpText.push(`${experience.xp || 0} XP`);
|
||||||
|
}
|
||||||
|
return xpText.join(', ');
|
||||||
|
},
|
||||||
|
formatDate(date){
|
||||||
|
return format(date, 'YYYY-MM-DD');
|
||||||
|
},
|
||||||
|
removeExperience(experienceId){
|
||||||
|
this.experiencesRemovalLoading.add(experienceId);
|
||||||
|
removeExperience.call({experienceId}, (error) => {
|
||||||
|
this.experiencesRemovalLoading.delete(experienceId);
|
||||||
|
if (error) console.error(error);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
recompute(){
|
||||||
|
this.recomputeLoading = true;
|
||||||
|
recomputeExperiences.call({creatureId: this.creatureId}, error => {
|
||||||
|
this.recomputeLoading = false;
|
||||||
|
if (error) console.error(error);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
addExperience(){
|
||||||
|
this.$store.commit('pushDialogStack', {
|
||||||
|
component: 'experience-insert-dialog',
|
||||||
|
elementId: 'experience-add-button',
|
||||||
|
data: {
|
||||||
|
creatureIds: [this.creatureId],
|
||||||
|
startAsMilestone: this.startAsMilestone,
|
||||||
|
},
|
||||||
|
callback(id){
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="css" scoped>
|
||||||
|
</style>
|
||||||
@@ -3,6 +3,8 @@ import CreaturePropertyCreationDialog from '/imports/ui/creature/creaturePropert
|
|||||||
import CreaturePropertyDialog from '/imports/ui/creature/creatureProperties/CreaturePropertyDialog.vue'
|
import CreaturePropertyDialog from '/imports/ui/creature/creatureProperties/CreaturePropertyDialog.vue'
|
||||||
import CreaturePropertyFromLibraryDialog from '/imports/ui/creature/creatureProperties/CreaturePropertyFromLibraryDialog.vue'
|
import CreaturePropertyFromLibraryDialog from '/imports/ui/creature/creatureProperties/CreaturePropertyFromLibraryDialog.vue'
|
||||||
import DeleteConfirmationDialog from '/imports/ui/dialogStack/DeleteConfirmationDialog.vue';
|
import DeleteConfirmationDialog from '/imports/ui/dialogStack/DeleteConfirmationDialog.vue';
|
||||||
|
import ExperienceInsertDialog from '/imports/ui/creature/experiences/ExperienceInsertDialog.vue';
|
||||||
|
import ExperienceListDialog from '/imports/ui/creature/experiences/ExperienceListDialog.vue';
|
||||||
import InviteDialog from '/imports/ui/user/InviteDialog.vue';
|
import InviteDialog from '/imports/ui/user/InviteDialog.vue';
|
||||||
import LibraryCreationDialog from '/imports/ui/library/LibraryCreationDialog.vue';
|
import LibraryCreationDialog from '/imports/ui/library/LibraryCreationDialog.vue';
|
||||||
import LibraryEditDialog from '/imports/ui/library/LibraryEditDialog.vue';
|
import LibraryEditDialog from '/imports/ui/library/LibraryEditDialog.vue';
|
||||||
@@ -13,13 +15,14 @@ import ShareDialog from '/imports/ui/sharing/ShareDialog.vue';
|
|||||||
import TierTooLowDialog from '/imports/ui/user/TierTooLowDialog.vue';
|
import TierTooLowDialog from '/imports/ui/user/TierTooLowDialog.vue';
|
||||||
import UsernameDialog from '/imports/ui/user/UsernameDialog.vue';
|
import UsernameDialog from '/imports/ui/user/UsernameDialog.vue';
|
||||||
|
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
CreatureFormDialog,
|
CreatureFormDialog,
|
||||||
CreaturePropertyCreationDialog,
|
CreaturePropertyCreationDialog,
|
||||||
CreaturePropertyDialog,
|
CreaturePropertyDialog,
|
||||||
CreaturePropertyFromLibraryDialog,
|
CreaturePropertyFromLibraryDialog,
|
||||||
DeleteConfirmationDialog,
|
DeleteConfirmationDialog,
|
||||||
|
ExperienceInsertDialog,
|
||||||
|
ExperienceListDialog,
|
||||||
InviteDialog,
|
InviteDialog,
|
||||||
LibraryCreationDialog,
|
LibraryCreationDialog,
|
||||||
LibraryEditDialog,
|
LibraryEditDialog,
|
||||||
|
|||||||
@@ -40,9 +40,6 @@
|
|||||||
searchString: '',
|
searchString: '',
|
||||||
testIcon: undefined,
|
testIcon: undefined,
|
||||||
}},
|
}},
|
||||||
mounted(){
|
|
||||||
console.log(this.$vuetify);
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
fileChanged (file) {
|
fileChanged (file) {
|
||||||
importIcons(file);
|
importIcons(file);
|
||||||
|
|||||||
@@ -4,14 +4,17 @@
|
|||||||
:light="!darkMode"
|
:light="!darkMode"
|
||||||
>
|
>
|
||||||
<v-navigation-drawer
|
<v-navigation-drawer
|
||||||
v-if="$route.path !== '/countdown'"
|
|
||||||
v-model="drawer"
|
v-model="drawer"
|
||||||
app
|
app
|
||||||
>
|
>
|
||||||
<Sidebar />
|
<Sidebar />
|
||||||
</v-navigation-drawer>
|
</v-navigation-drawer>
|
||||||
|
<router-view
|
||||||
|
v-model="tabs"
|
||||||
|
name="toolbar"
|
||||||
|
/>
|
||||||
<v-toolbar
|
<v-toolbar
|
||||||
v-if="$route.path !== '/countdown'"
|
v-if="!$route.matched[0].components.toolbar"
|
||||||
app
|
app
|
||||||
color="secondary"
|
color="secondary"
|
||||||
dark
|
dark
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="sidebar">
|
<div class="sidebar">
|
||||||
<v-alert
|
<v-alert
|
||||||
v-if="$route.path !== '/countdown'"
|
|
||||||
icon="priority_high"
|
icon="priority_high"
|
||||||
type="error"
|
type="error"
|
||||||
dismissible
|
dismissible
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
<div
|
<div
|
||||||
slot="detail"
|
slot="detail"
|
||||||
data-id="selected-node-card"
|
data-id="selected-node-card"
|
||||||
|
style="overflow: hidden;"
|
||||||
>
|
>
|
||||||
<library-node-dialog
|
<library-node-dialog
|
||||||
:_id="selected"
|
:_id="selected"
|
||||||
@@ -101,7 +102,6 @@ export default {
|
|||||||
selection: this.selection,
|
selection: this.selection,
|
||||||
},
|
},
|
||||||
callback: result => {
|
callback: result => {
|
||||||
console.log(result)
|
|
||||||
if (result){
|
if (result){
|
||||||
this.selected = id;
|
this.selected = id;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ export default {
|
|||||||
}},
|
}},
|
||||||
meteor: {
|
meteor: {
|
||||||
library(){
|
library(){
|
||||||
console.log(this.$route);
|
|
||||||
return Libraries.findOne(this.$route.params.id);
|
return Libraries.findOne(this.$route.params.id);
|
||||||
},
|
},
|
||||||
subscribed(){
|
subscribed(){
|
||||||
@@ -41,7 +40,6 @@ export default {
|
|||||||
let userId = Meteor.userId();
|
let userId = Meteor.userId();
|
||||||
let library = this.library;
|
let library = this.library;
|
||||||
if (!library) return;
|
if (!library) return;
|
||||||
console.log({library, userId});
|
|
||||||
if (
|
if (
|
||||||
library.readers.includes(userId) ||
|
library.readers.includes(userId) ||
|
||||||
library.writers.includes(userId) ||
|
library.writers.includes(userId) ||
|
||||||
@@ -55,10 +53,8 @@ export default {
|
|||||||
canEdit(){
|
canEdit(){
|
||||||
try {
|
try {
|
||||||
assertDocEditPermission(this.library, Meteor.userId());
|
assertDocEditPermission(this.library, Meteor.userId());
|
||||||
console.log('can edit');
|
|
||||||
return true
|
return true
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
244
app/imports/ui/properties/components/actions/ActionCard.vue
Normal file
244
app/imports/ui/properties/components/actions/ActionCard.vue
Normal file
@@ -0,0 +1,244 @@
|
|||||||
|
<template lang="html">
|
||||||
|
<v-card
|
||||||
|
class="action-card"
|
||||||
|
:class="cardClasses"
|
||||||
|
:elevation="hovering ? 8 : undefined"
|
||||||
|
>
|
||||||
|
<div class="layout row align-center px-3">
|
||||||
|
<div class="avatar">
|
||||||
|
<v-btn
|
||||||
|
flat
|
||||||
|
icon
|
||||||
|
outline
|
||||||
|
style="margin-left: -4px; font-size: 18px;"
|
||||||
|
:color="model.color || 'primary'"
|
||||||
|
:loading="doActionLoading"
|
||||||
|
:disabled="model.insufficientResources || !context.editPermission"
|
||||||
|
@click.stop="doAction"
|
||||||
|
>
|
||||||
|
<template v-if="attack && !rollBonusTooLong">
|
||||||
|
{{ rollBonus }}
|
||||||
|
</template>
|
||||||
|
<property-icon
|
||||||
|
v-else
|
||||||
|
:model="model"
|
||||||
|
/>
|
||||||
|
</v-btn>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="action-header flex layout column justify-center pl-1"
|
||||||
|
style="height: 72px; cursor: pointer;"
|
||||||
|
@mouseover="hovering = true"
|
||||||
|
@mouseleave="hovering = false"
|
||||||
|
@click="$emit('click')"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="action-title my-1"
|
||||||
|
>
|
||||||
|
{{ model.name || propertyName }}
|
||||||
|
</div>
|
||||||
|
<div class="action-sub-title layout row align-center">
|
||||||
|
<div class="flex">
|
||||||
|
{{ model.actionType }}
|
||||||
|
</div>
|
||||||
|
<div v-if="model.uses">
|
||||||
|
{{ usesLeft }} uses
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="px-3 pb-3">
|
||||||
|
<template
|
||||||
|
v-if="model.resources.attributesConsumed.length ||
|
||||||
|
model.resources.itemsConsumed.length"
|
||||||
|
>
|
||||||
|
<attribute-consumed-view
|
||||||
|
v-for="attributeConsumed in model.resources.attributesConsumed"
|
||||||
|
:key="attributeConsumed._id"
|
||||||
|
class="action-child"
|
||||||
|
:model="attributeConsumed"
|
||||||
|
/>
|
||||||
|
<item-consumed-view
|
||||||
|
v-for="itemConsumed in model.resources.itemsConsumed"
|
||||||
|
:key="itemConsumed._id"
|
||||||
|
class="action-child"
|
||||||
|
:model="itemConsumed"
|
||||||
|
:action="model"
|
||||||
|
/>
|
||||||
|
<v-divider
|
||||||
|
v-if="model.summary || children.length"
|
||||||
|
class="my-2"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<template v-if="model.summary">
|
||||||
|
<property-description :value="model.summary" />
|
||||||
|
<v-divider
|
||||||
|
v-if="children.length"
|
||||||
|
class="my-2"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<tree-node-view
|
||||||
|
v-for="child in children"
|
||||||
|
:key="child._id"
|
||||||
|
class="action-child"
|
||||||
|
:model="child"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</v-card>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import { getPropertyName } from '/imports/constants/PROPERTIES.js';
|
||||||
|
import numberToSignedString from '/imports/ui/utility/numberToSignedString.js';
|
||||||
|
import doAction from '/imports/api/creature/actions/doAction.js';
|
||||||
|
import getActiveProperties from '/imports/api/creature/getActiveProperties.js';
|
||||||
|
import TreeNodeView from '/imports/ui/properties/treeNodeViews/TreeNodeView.vue';
|
||||||
|
import AttributeConsumedView from '/imports/ui/properties/components/actions/AttributeConsumedView.vue';
|
||||||
|
import ItemConsumedView from '/imports/ui/properties/components/actions/ItemConsumedView.vue';
|
||||||
|
import PropertyDescription from '/imports/ui/properties/viewers/shared/PropertyDescription.vue';
|
||||||
|
import PropertyIcon from '/imports/ui/properties/shared/PropertyIcon.vue';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
TreeNodeView,
|
||||||
|
AttributeConsumedView,
|
||||||
|
ItemConsumedView,
|
||||||
|
PropertyDescription,
|
||||||
|
PropertyIcon,
|
||||||
|
},
|
||||||
|
inject: {
|
||||||
|
context: {
|
||||||
|
default: {},
|
||||||
|
},
|
||||||
|
theme: {
|
||||||
|
default: {
|
||||||
|
isDark: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
model: {
|
||||||
|
type: Object,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
attack: {
|
||||||
|
type: Boolean,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
data(){return {
|
||||||
|
activated: undefined,
|
||||||
|
doActionLoading: false,
|
||||||
|
hovering: false,
|
||||||
|
}},
|
||||||
|
computed: {
|
||||||
|
rollBonus(){
|
||||||
|
if (!this.attack) return;
|
||||||
|
return numberToSignedString(this.model.rollBonusResult);
|
||||||
|
},
|
||||||
|
rollBonusTooLong(){
|
||||||
|
return this.rollBonus && this.rollBonus.length > 3;
|
||||||
|
},
|
||||||
|
totalUses(){
|
||||||
|
return Math.max(this.model.usesResult, 0);
|
||||||
|
},
|
||||||
|
usesLeft(){
|
||||||
|
return Math.max(this.model.usesResult - this.model.usesUsed, 0);
|
||||||
|
},
|
||||||
|
propertyName(){
|
||||||
|
return getPropertyName(this.model.type);
|
||||||
|
},
|
||||||
|
cardClasses() {
|
||||||
|
return {
|
||||||
|
'theme--dark': this.theme.isDark,
|
||||||
|
'theme--light': !this.theme.isDark,
|
||||||
|
'muted-text': this.model.insufficientResources,
|
||||||
|
'shrink': this.activated,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
actionTypeIcon() {
|
||||||
|
return `$vuetify.icons.${this.model.actionType}`;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
meteor: {
|
||||||
|
children(){
|
||||||
|
return getActiveProperties({
|
||||||
|
ancestorId: this.model._id,
|
||||||
|
filter: {'parent.id': this.model._id},
|
||||||
|
options: {sort: {order: 1}},
|
||||||
|
});
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
click(e){
|
||||||
|
this.$emit('click', e);
|
||||||
|
},
|
||||||
|
doAction(){
|
||||||
|
this.doActionLoading = true;
|
||||||
|
this.shwing();
|
||||||
|
doAction.call({actionId: this.model._id}, error => {
|
||||||
|
this.doActionLoading = false;
|
||||||
|
if (error){
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
shwing(){
|
||||||
|
this.activated = true;
|
||||||
|
setTimeout(() => {
|
||||||
|
this.activated = undefined;
|
||||||
|
}, 300);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="css" scoped>
|
||||||
|
.action-title {
|
||||||
|
font-size: 16px;
|
||||||
|
font-weight: 400;
|
||||||
|
height: 24px;
|
||||||
|
line-height: 24px;
|
||||||
|
position: relative;
|
||||||
|
text-align: left;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
transition: .3s cubic-bezier(.25,.8,.5,1);
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.action-sub-title {
|
||||||
|
color: #9e9e9e;
|
||||||
|
flex-grow: 0;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 12px;
|
||||||
|
height: 14px;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
.action-child {
|
||||||
|
height: 32px;
|
||||||
|
}
|
||||||
|
.theme--light.muted-text {
|
||||||
|
color: rgba(0,0,0,.3) !important;
|
||||||
|
}
|
||||||
|
.theme--dark.muted-text {
|
||||||
|
color: hsla(0,0%,100%,.3) !important;
|
||||||
|
}
|
||||||
|
.action-card {
|
||||||
|
transition: transform 0.15s cubic;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<style lang="css">
|
||||||
|
.action-card.theme--light.muted-text .v-icon {
|
||||||
|
color: rgba(0,0,0,.3) !important;
|
||||||
|
}
|
||||||
|
.action-card.theme--dark.muted-text .v-icon {
|
||||||
|
color: hsla(0,0%,100%,.3) !important;
|
||||||
|
}
|
||||||
|
.action-card .property-description > p:last-of-type {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
<template lang="html">
|
|
||||||
<v-list-tile
|
|
||||||
class="ability-list-tile"
|
|
||||||
v-on="hasClickListener ? {click} : {}"
|
|
||||||
>
|
|
||||||
<v-list-tile-content>
|
|
||||||
<v-list-tile-title>
|
|
||||||
{{ model.name }}
|
|
||||||
</v-list-tile-title>
|
|
||||||
</v-list-tile-content>
|
|
||||||
</v-list-tile>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
export default {
|
|
||||||
props: {
|
|
||||||
model: {
|
|
||||||
type: Object,
|
|
||||||
required: true,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
hasClickListener(){
|
|
||||||
return this.$listeners && this.$listeners.click
|
|
||||||
},
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
click(e){
|
|
||||||
this.$emit('click', e);
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="css" scoped>
|
|
||||||
</style>
|
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
<template lang="html">
|
|
||||||
<v-list-tile
|
|
||||||
class="ability-list-tile"
|
|
||||||
avatar
|
|
||||||
v-on="hasClickListener ? {click} : {}"
|
|
||||||
>
|
|
||||||
<v-list-tile-avatar color="grey darken-1">
|
|
||||||
<computed
|
|
||||||
signed
|
|
||||||
:value="model.rollBonus"
|
|
||||||
class="white--text headline"
|
|
||||||
/>
|
|
||||||
</v-list-tile-avatar>
|
|
||||||
<v-list-tile-content>
|
|
||||||
<v-list-tile-title>
|
|
||||||
{{ model.name }}
|
|
||||||
</v-list-tile-title>
|
|
||||||
</v-list-tile-content>
|
|
||||||
</v-list-tile>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import ComputedForCreature from '/imports/ui/components/computation/ComputedForCreature.vue';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
components: {
|
|
||||||
Computed: ComputedForCreature,
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
model: {
|
|
||||||
type: Object,
|
|
||||||
required: true,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
hasClickListener(){
|
|
||||||
return this.$listeners && this.$listeners.click
|
|
||||||
},
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
click(e){
|
|
||||||
this.$emit('click', e);
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="css" scoped>
|
|
||||||
</style>
|
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
<template lang="html">
|
||||||
|
<div
|
||||||
|
class="layout row align-center justify-start"
|
||||||
|
:class="insufficient && 'error--text'"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="mr-2"
|
||||||
|
style="width: 24px; text-align: center;"
|
||||||
|
>
|
||||||
|
{{ model.quantity }}
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="text-no-wrap text-truncate"
|
||||||
|
>
|
||||||
|
{{ model.statName || model.variableName }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export default {
|
||||||
|
props: {
|
||||||
|
model: {
|
||||||
|
type: Object,
|
||||||
|
default: () => ({}),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
insufficient(){
|
||||||
|
return this.model.quantity > this.model.available;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -0,0 +1,133 @@
|
|||||||
|
<template lang="html">
|
||||||
|
<div
|
||||||
|
:class="{
|
||||||
|
'theme--dark': theme.isDark,
|
||||||
|
'theme--light': !theme.isDark,
|
||||||
|
}"
|
||||||
|
>
|
||||||
|
<v-menu
|
||||||
|
v-if="context.creature"
|
||||||
|
transition="slide-y-transition"
|
||||||
|
lazy
|
||||||
|
:disabled="!context.editPermission"
|
||||||
|
>
|
||||||
|
<template #activator="{ on }">
|
||||||
|
<div
|
||||||
|
class="layout row align-center justify-start"
|
||||||
|
style="height: 100%;"
|
||||||
|
:class="{
|
||||||
|
'error--text': insufficient,
|
||||||
|
'clickable': context.creature && context.editPermission,
|
||||||
|
'left-pad': leftPad,
|
||||||
|
}"
|
||||||
|
v-on="on"
|
||||||
|
>
|
||||||
|
<svg-icon
|
||||||
|
v-if="model.itemIcon"
|
||||||
|
class="mr-2"
|
||||||
|
:shape="model.itemIcon.shape"
|
||||||
|
:color="model.itemColor"
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
class="mr-2 text-no-wrap"
|
||||||
|
style="min-width: 24px; text-align: center;"
|
||||||
|
>
|
||||||
|
<template v-if="model.quantity !== 0 && insufficient">
|
||||||
|
{{ model.available }} / {{ model.quantity }}
|
||||||
|
</template>
|
||||||
|
<template v-else>
|
||||||
|
{{ model.available }}
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="text-no-wrap text-truncate flex"
|
||||||
|
>
|
||||||
|
<template v-if="model.itemId">
|
||||||
|
{{ model.itemName }}
|
||||||
|
</template>
|
||||||
|
<span
|
||||||
|
v-else
|
||||||
|
class="error--text"
|
||||||
|
>
|
||||||
|
Select ammo
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<v-icon v-if="context.editPermission">
|
||||||
|
arrow_drop_down
|
||||||
|
</v-icon>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
<select-item-to-consume
|
||||||
|
:action="action"
|
||||||
|
:item-consumed="model"
|
||||||
|
/>
|
||||||
|
</v-menu>
|
||||||
|
<div
|
||||||
|
v-else
|
||||||
|
class="layout row align-center justify-start"
|
||||||
|
:class="{'left-pad': leftPad}"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="mr-2"
|
||||||
|
style="width: 24px; text-align: center;"
|
||||||
|
>
|
||||||
|
{{ model.quantity }}
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="text-no-wrap text-truncate"
|
||||||
|
>
|
||||||
|
[{{ model.tag }}]
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import SelectItemToConsume from '/imports/ui/properties/components/actions/SelectItemToConsume.vue';
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
SelectItemToConsume,
|
||||||
|
},
|
||||||
|
inject: {
|
||||||
|
context: {
|
||||||
|
default: {},
|
||||||
|
},
|
||||||
|
theme: {
|
||||||
|
default: {
|
||||||
|
isDark: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
model: {
|
||||||
|
type: Object,
|
||||||
|
default: () => ({}),
|
||||||
|
},
|
||||||
|
action: {
|
||||||
|
type: Object,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
leftPad: Boolean,
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
insufficient(){
|
||||||
|
return this.model.quantity > this.model.available;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="css" scoped>
|
||||||
|
.clickable {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
.theme--light .clickable:hover {
|
||||||
|
background: rgba(0,0,0,.04);
|
||||||
|
}
|
||||||
|
.theme--dark .clickable:hover {
|
||||||
|
background: hsla(0,0%,100%,.08);
|
||||||
|
}
|
||||||
|
.left-pad {
|
||||||
|
padding-left: 44px;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
<template lang="html">
|
||||||
|
<v-list v-if="items.length">
|
||||||
|
<v-list-tile
|
||||||
|
v-for="item in items"
|
||||||
|
:key="item._id"
|
||||||
|
@click="selectItem(item._id)"
|
||||||
|
>
|
||||||
|
<item-tree-node
|
||||||
|
:model="item"
|
||||||
|
:selected="itemConsumed.itemId === item._id"
|
||||||
|
/>
|
||||||
|
</v-list-tile>
|
||||||
|
</v-list>
|
||||||
|
<v-card v-else>
|
||||||
|
<v-card-text>
|
||||||
|
No equipped items found with the tag "{{ itemConsumed.tag }}"
|
||||||
|
</v-card-text>
|
||||||
|
</v-card>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import ItemTreeNode from '/imports/ui/properties/treeNodeViews/ItemTreeNode.vue';
|
||||||
|
import getActiveProperties from '/imports/api/creature/getActiveProperties.js';
|
||||||
|
import { selectAmmoItem } from '/imports/api/creature/CreatureProperties.js';
|
||||||
|
import { findIndex } from 'lodash';
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
ItemTreeNode
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
action: {
|
||||||
|
type: Object,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
itemConsumed: {
|
||||||
|
type: Object,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
meteor: {
|
||||||
|
items(){
|
||||||
|
return getActiveProperties({
|
||||||
|
ancestorId: this.action.ancestors[0].id,
|
||||||
|
filter: {
|
||||||
|
tags: this.itemConsumed.tag,
|
||||||
|
equipped: true,
|
||||||
|
},
|
||||||
|
options: {
|
||||||
|
fields: {equipped: false},
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
methods:{
|
||||||
|
selectItem(itemId){
|
||||||
|
let itemConsumedIndex = findIndex(
|
||||||
|
this.action.resources.itemsConsumed,
|
||||||
|
item => item._id === this.itemConsumed._id
|
||||||
|
);
|
||||||
|
selectAmmoItem.call({
|
||||||
|
actionId: this.action._id,
|
||||||
|
itemId,
|
||||||
|
itemConsumedIndex
|
||||||
|
}, error => {
|
||||||
|
if (error) console.error(error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<style lang="css" scoped>
|
||||||
|
</style>
|
||||||
@@ -1,6 +1,15 @@
|
|||||||
<template lang="html">
|
<template lang="html">
|
||||||
<div :class="attackForm ? 'attack-form' : 'action-form'">
|
<div :class="attackForm ? 'attack-form' : 'action-form'">
|
||||||
|
<div class="layout column align-center">
|
||||||
|
<icon-picker
|
||||||
|
label="Icon"
|
||||||
|
:value="model.icon"
|
||||||
|
:error-messages="errors.icon"
|
||||||
|
@change="change('icon', ...arguments)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
<text-field
|
<text-field
|
||||||
|
ref="focusFirst"
|
||||||
label="Name"
|
label="Name"
|
||||||
:value="model.name"
|
:value="model.name"
|
||||||
:error-messages="errors.name"
|
:error-messages="errors.name"
|
||||||
@@ -22,8 +31,16 @@
|
|||||||
:error-messages="errors.rollBonus"
|
:error-messages="errors.rollBonus"
|
||||||
@change="change('rollBonus', ...arguments)"
|
@change="change('rollBonus', ...arguments)"
|
||||||
/>
|
/>
|
||||||
|
<text-area
|
||||||
|
label="Summary"
|
||||||
|
hint="This will appear in the action card in the character sheet"
|
||||||
|
:value="model.summary"
|
||||||
|
:error-messages="errors.summary"
|
||||||
|
@change="change('summary', ...arguments)"
|
||||||
|
/>
|
||||||
<text-area
|
<text-area
|
||||||
label="Description"
|
label="Description"
|
||||||
|
hint="The rest of the description that doesn't fit in the summary goes here"
|
||||||
:value="model.description"
|
:value="model.description"
|
||||||
:error-messages="errors.description"
|
:error-messages="errors.description"
|
||||||
@change="change('description', ...arguments)"
|
@change="change('description', ...arguments)"
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
<div class="attribute-form">
|
<div class="attribute-form">
|
||||||
<div class="layout column align-center">
|
<div class="layout column align-center">
|
||||||
<text-field
|
<text-field
|
||||||
|
ref="focusFirst"
|
||||||
label="Base Value"
|
label="Base Value"
|
||||||
class="base-value-field"
|
class="base-value-field"
|
||||||
hint="This is the value of the attribute before effects are applied"
|
hint="This is the value of the attribute before effects are applied"
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<template lang="html">
|
<template lang="html">
|
||||||
<div class="buff-form">
|
<div class="buff-form">
|
||||||
<text-field
|
<text-field
|
||||||
|
ref="focusFirst"
|
||||||
label="Name"
|
label="Name"
|
||||||
:value="model.name"
|
:value="model.name"
|
||||||
:error-messages="errors.name"
|
:error-messages="errors.name"
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="layout row wrap">
|
<div class="layout row wrap">
|
||||||
<text-field
|
<text-field
|
||||||
|
ref="focusFirst"
|
||||||
label="Name"
|
label="Name"
|
||||||
:value="model.name"
|
:value="model.name"
|
||||||
:error-messages="errors.name"
|
:error-messages="errors.name"
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
<div class="attribute-form">
|
<div class="attribute-form">
|
||||||
<div class="layout row justify-space-between wrap">
|
<div class="layout row justify-space-between wrap">
|
||||||
<text-field
|
<text-field
|
||||||
|
ref="focusFirst"
|
||||||
label="Name"
|
label="Name"
|
||||||
:value="model.name"
|
:value="model.name"
|
||||||
:error-messages="errors.name"
|
:error-messages="errors.name"
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
<div>
|
<div>
|
||||||
<div class="layout row">
|
<div class="layout row">
|
||||||
<text-field
|
<text-field
|
||||||
|
ref="focusFirst"
|
||||||
label="Damage"
|
label="Damage"
|
||||||
style="flex-basis: 300px;"
|
style="flex-basis: 300px;"
|
||||||
:value="model.amount"
|
:value="model.amount"
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<template lang="html">
|
<template lang="html">
|
||||||
<div class="attribute-form">
|
<div class="attribute-form">
|
||||||
<text-field
|
<text-field
|
||||||
|
ref="focusFirst"
|
||||||
label="Name"
|
label="Name"
|
||||||
:value="model.name"
|
:value="model.name"
|
||||||
:error-messages="errors.name"
|
:error-messages="errors.name"
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<template lang="html">
|
<template lang="html">
|
||||||
<div class="effect-form">
|
<div class="effect-form">
|
||||||
<text-field
|
<text-field
|
||||||
|
ref="focusFirst"
|
||||||
label="Name"
|
label="Name"
|
||||||
:value="model.name"
|
:value="model.name"
|
||||||
:error-messages="errors.name"
|
:error-messages="errors.name"
|
||||||
|
|||||||
@@ -1,57 +0,0 @@
|
|||||||
<template lang="html">
|
|
||||||
<div class="class-form">
|
|
||||||
<div class="layout row wrap">
|
|
||||||
<text-field
|
|
||||||
label="Title"
|
|
||||||
style="flex-basis: 300px;"
|
|
||||||
:value="model.name"
|
|
||||||
:error-messages="errors.name"
|
|
||||||
@change="change('name', ...arguments)"
|
|
||||||
/>
|
|
||||||
<text-field
|
|
||||||
label="In-World date"
|
|
||||||
:value="model.worldDate"
|
|
||||||
style="flex-basis: 300px;"
|
|
||||||
hint="The date in-game that the experience occured"
|
|
||||||
:error-messages="errors.worldDate"
|
|
||||||
@change="change('worldDate', ...arguments)"
|
|
||||||
/>
|
|
||||||
<date-picker
|
|
||||||
label="Real date"
|
|
||||||
:value="model.date"
|
|
||||||
style="flex-basis: 300px;"
|
|
||||||
hint="Real life date"
|
|
||||||
:error-messages="errors.date"
|
|
||||||
@change="change('date', ...arguments)"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<text-area
|
|
||||||
label="Description"
|
|
||||||
:value="model.description"
|
|
||||||
:error-messages="errors.description"
|
|
||||||
@change="change('description', ...arguments)"
|
|
||||||
/>
|
|
||||||
<div class="layout column align-end">
|
|
||||||
<text-field
|
|
||||||
label="XP gained"
|
|
||||||
type="number"
|
|
||||||
class="base-value-field text-xs-center large-format no-flex"
|
|
||||||
hint="The number of experience points gained from this entry"
|
|
||||||
:value="model.value"
|
|
||||||
:error-messages="errors.value"
|
|
||||||
@change="change('value', ...arguments)"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import propertyFormMixin from '/imports/ui/properties/forms/shared/propertyFormMixin.js';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
mixins: [propertyFormMixin],
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="css" scoped>
|
|
||||||
</style>
|
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
<template lang="html">
|
<template lang="html">
|
||||||
<div class="feature-form">
|
<div class="feature-form">
|
||||||
<text-field
|
<text-field
|
||||||
|
ref="focusFirst"
|
||||||
label="Name"
|
label="Name"
|
||||||
:value="model.name"
|
:value="model.name"
|
||||||
:error-messages="errors.name"
|
:error-messages="errors.name"
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
<div class="folder-form">
|
<div class="folder-form">
|
||||||
<div class="layout row wrap">
|
<div class="layout row wrap">
|
||||||
<text-field
|
<text-field
|
||||||
|
ref="focusFirst"
|
||||||
label="Name"
|
label="Name"
|
||||||
style="flex-basis: 300px;"
|
style="flex-basis: 300px;"
|
||||||
:value="model.name"
|
:value="model.name"
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="layout row wrap">
|
<div class="layout row wrap">
|
||||||
<text-field
|
<text-field
|
||||||
|
ref="focusFirst"
|
||||||
label="Name"
|
label="Name"
|
||||||
:value="model.name"
|
:value="model.name"
|
||||||
:error-messages="errors.name"
|
:error-messages="errors.name"
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<template lang="html">
|
<template lang="html">
|
||||||
<div class="feature-form">
|
<div class="feature-form">
|
||||||
<text-field
|
<text-field
|
||||||
|
ref="focusFirst"
|
||||||
label="Name"
|
label="Name"
|
||||||
:value="model.name"
|
:value="model.name"
|
||||||
:error-messages="errors.name"
|
:error-messages="errors.name"
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<template lang="html">
|
<template lang="html">
|
||||||
<div>
|
<div>
|
||||||
<text-field
|
<text-field
|
||||||
|
ref="focusFirst"
|
||||||
label="Name"
|
label="Name"
|
||||||
:value="model.name"
|
:value="model.name"
|
||||||
:error-messages="errors.name"
|
:error-messages="errors.name"
|
||||||
@@ -8,9 +9,11 @@
|
|||||||
/>
|
/>
|
||||||
<div class="layout row wrap justify-start proficiency-form">
|
<div class="layout row wrap justify-start proficiency-form">
|
||||||
<smart-combobox
|
<smart-combobox
|
||||||
label="Skill"
|
label="Skills"
|
||||||
class="mr-2"
|
class="mr-2"
|
||||||
multiple
|
multiple
|
||||||
|
chips
|
||||||
|
deletable-chips
|
||||||
:value="model.stats"
|
:value="model.stats"
|
||||||
:items="skillList"
|
:items="skillList"
|
||||||
:error-messages="errors.stats"
|
:error-messages="errors.stats"
|
||||||
@@ -21,7 +24,7 @@
|
|||||||
style="flex-basis: 300px;"
|
style="flex-basis: 300px;"
|
||||||
:clearable="false"
|
:clearable="false"
|
||||||
:value="model.value"
|
:value="model.value"
|
||||||
@change="change('stats', ...arguments)"
|
@change="change('value', ...arguments)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<template lang="html">
|
<template lang="html">
|
||||||
<div class="roll-form">
|
<div class="roll-form">
|
||||||
<text-field
|
<text-field
|
||||||
|
ref="focusFirst"
|
||||||
label="Roll"
|
label="Roll"
|
||||||
:value="model.roll"
|
:value="model.roll"
|
||||||
:error-messages="errors.roll"
|
:error-messages="errors.roll"
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<template lang="html">
|
<template lang="html">
|
||||||
<div class="saving-throw-form">
|
<div class="saving-throw-form">
|
||||||
<text-field
|
<text-field
|
||||||
|
ref="focusFirst"
|
||||||
label="Name"
|
label="Name"
|
||||||
:value="model.name"
|
:value="model.name"
|
||||||
:error-messages="errors.name"
|
:error-messages="errors.name"
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
<div class="skill-form">
|
<div class="skill-form">
|
||||||
<div class="layout row wrap">
|
<div class="layout row wrap">
|
||||||
<text-field
|
<text-field
|
||||||
|
ref="focusFirst"
|
||||||
label="Name"
|
label="Name"
|
||||||
:value="model.name"
|
:value="model.name"
|
||||||
:error-messages="errors.name"
|
:error-messages="errors.name"
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<template lang="html">
|
<template lang="html">
|
||||||
<div class="attribute-form">
|
<div class="attribute-form">
|
||||||
<text-field
|
<text-field
|
||||||
|
ref="focusFirst"
|
||||||
label="Name"
|
label="Name"
|
||||||
:value="model.name"
|
:value="model.name"
|
||||||
:error-messages="errors.name"
|
:error-messages="errors.name"
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
<div class="attribute-form">
|
<div class="attribute-form">
|
||||||
<div class="layout row wrap">
|
<div class="layout row wrap">
|
||||||
<text-field
|
<text-field
|
||||||
|
ref="focusFirst"
|
||||||
label="Name"
|
label="Name"
|
||||||
:value="model.name"
|
:value="model.name"
|
||||||
:error-messages="errors.name"
|
:error-messages="errors.name"
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
<template lang="html">
|
<template lang="html">
|
||||||
<div class="feature-form">
|
<div class="feature-form">
|
||||||
<text-field
|
<text-field
|
||||||
|
ref="focusFirst"
|
||||||
label="Name"
|
label="Name"
|
||||||
:value="model.name"
|
:value="model.name"
|
||||||
:error-messages="errors.name"
|
:error-messages="errors.name"
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import ContainerForm from '/imports/ui/properties/forms/ContainerForm.vue';
|
|||||||
import DamageForm from '/imports/ui/properties/forms/DamageForm.vue';
|
import DamageForm from '/imports/ui/properties/forms/DamageForm.vue';
|
||||||
import DamageMultiplierForm from '/imports/ui/properties/forms/DamageMultiplierForm.vue';
|
import DamageMultiplierForm from '/imports/ui/properties/forms/DamageMultiplierForm.vue';
|
||||||
import EffectForm from '/imports/ui/properties/forms/EffectForm.vue';
|
import EffectForm from '/imports/ui/properties/forms/EffectForm.vue';
|
||||||
import ExperienceForm from '/imports/ui/properties/forms/ExperienceForm.vue';
|
|
||||||
import FeatureForm from '/imports/ui/properties/forms/FeatureForm.vue';
|
import FeatureForm from '/imports/ui/properties/forms/FeatureForm.vue';
|
||||||
import FolderForm from '/imports/ui/properties/forms/FolderForm.vue';
|
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';
|
||||||
@@ -31,7 +30,6 @@ export default {
|
|||||||
classLevel: ClassLevelForm,
|
classLevel: ClassLevelForm,
|
||||||
damage: DamageForm,
|
damage: DamageForm,
|
||||||
damageMultiplier: DamageMultiplierForm,
|
damageMultiplier: DamageMultiplierForm,
|
||||||
experience:ExperienceForm,
|
|
||||||
effect: EffectForm,
|
effect: EffectForm,
|
||||||
feature: FeatureForm,
|
feature: FeatureForm,
|
||||||
folder: FolderForm,
|
folder: FolderForm,
|
||||||
|
|||||||
@@ -9,6 +9,11 @@ export default {
|
|||||||
default: () => ({}),
|
default: () => ({}),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
mounted(){
|
||||||
|
if (this.$refs.focusFirst){
|
||||||
|
setTimeout(() => this.$refs.focusFirst.focus(), 300);
|
||||||
|
}
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
change(path, value, ack){
|
change(path, value, ack){
|
||||||
if (!Array.isArray(path)){
|
if (!Array.isArray(path)){
|
||||||
@@ -16,5 +21,5 @@ export default {
|
|||||||
}
|
}
|
||||||
this.$emit('change', {path, value, ack});
|
this.$emit('change', {path, value, ack});
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
<template lang="html">
|
||||||
|
<div class="layout row align-center justify-start">
|
||||||
|
<property-icon
|
||||||
|
class="mr-2"
|
||||||
|
:model="model"
|
||||||
|
:color="model.color"
|
||||||
|
:class="selected && 'primary--text'"
|
||||||
|
/>
|
||||||
|
<div class="text-no-wrap text-truncate">
|
||||||
|
{{ title }} {{ model.level }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import treeNodeViewMixin from '/imports/ui/properties/treeNodeViews/treeNodeViewMixin.js';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
mixins: [treeNodeViewMixin],
|
||||||
|
}
|
||||||
|
</script>
|
||||||
30
app/imports/ui/properties/treeNodeViews/TreeNodeView.vue
Normal file
30
app/imports/ui/properties/treeNodeViews/TreeNodeView.vue
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<template lang="html">
|
||||||
|
<component
|
||||||
|
:is="treeNodeView"
|
||||||
|
:model="model"
|
||||||
|
:selected="selected"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
import treeNodeViewIndex from '/imports/ui/properties/treeNodeViews/treeNodeViewIndex.js';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
components: {
|
||||||
|
...treeNodeViewIndex
|
||||||
|
},
|
||||||
|
props: {
|
||||||
|
model: {
|
||||||
|
type: Object,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
selected: Boolean,
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
treeNodeView(){
|
||||||
|
let type = this.model.type;
|
||||||
|
return treeNodeViewIndex[type] || treeNodeViewIndex.default;
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -3,10 +3,12 @@ import AdjustmentTreeNode from '/imports/ui/properties/treeNodeViews/AdjustmentT
|
|||||||
import ItemTreeNode from '/imports/ui/properties/treeNodeViews/ItemTreeNode.vue';
|
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';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
default: DefaultTreeNode,
|
default: DefaultTreeNode,
|
||||||
adjustment: AdjustmentTreeNode,
|
adjustment: AdjustmentTreeNode,
|
||||||
|
classLevel: ClassLevelTreeNode,
|
||||||
damage: DamageTreeNode,
|
damage: DamageTreeNode,
|
||||||
effect: EffectTreeNode,
|
effect: EffectTreeNode,
|
||||||
item: ItemTreeNode,
|
item: ItemTreeNode,
|
||||||
|
|||||||
@@ -1,47 +1,144 @@
|
|||||||
<template lang="html">
|
<template lang="html">
|
||||||
<div class="action-viewer">
|
<div class="action-viewer">
|
||||||
<property-field
|
<div class="action-sub-title layout row align-center justify-space-between wrap mb-3">
|
||||||
name="Action type"
|
<property-tags
|
||||||
:value="model.actionType"
|
:tags="model.tags"
|
||||||
/>
|
no-margin
|
||||||
<property-field
|
class="mx-2"
|
||||||
name="Target"
|
/>
|
||||||
:value="model.target"
|
<div
|
||||||
/>
|
v-if="!attack"
|
||||||
<property-field
|
class="mx-2"
|
||||||
v-if="model.tags.length"
|
>
|
||||||
name="tags"
|
{{ model.actionType }}
|
||||||
:value="model.tags.join(', ')"
|
</div>
|
||||||
/>
|
</div>
|
||||||
<property-field
|
<div class="layout row align-center justify-space-around">
|
||||||
name="Uses"
|
<v-btn
|
||||||
|
v-if="context.creature"
|
||||||
|
flat
|
||||||
|
outline
|
||||||
|
style="font-size: 18px;"
|
||||||
|
class="ma-2"
|
||||||
|
:color="model.color || 'primary'"
|
||||||
|
:icon="!rollBonusTooLong"
|
||||||
|
:loading="doActionLoading"
|
||||||
|
:disabled="model.insufficientResources || !context.editPermission"
|
||||||
|
@click.stop="doAction"
|
||||||
|
>
|
||||||
|
<template v-if="attack">
|
||||||
|
{{ rollBonus }}
|
||||||
|
</template>
|
||||||
|
<property-icon
|
||||||
|
v-else
|
||||||
|
:model="model"
|
||||||
|
/>
|
||||||
|
</v-btn>
|
||||||
|
<div
|
||||||
|
v-else-if="attack"
|
||||||
|
style="font-size: 18px;"
|
||||||
|
class="ma-2"
|
||||||
|
>
|
||||||
|
<code>{{ model.rollBonus }}</code>
|
||||||
|
<span
|
||||||
|
class="mx-1"
|
||||||
|
style="font-size: 14px"
|
||||||
|
>to hit</span>
|
||||||
|
</div>
|
||||||
|
<div v-if="model.uses">
|
||||||
|
<span
|
||||||
|
v-if="context.creature"
|
||||||
|
class="uses mx-2"
|
||||||
|
>
|
||||||
|
{{ usesLeft }}/{{ model.usesResult }} uses
|
||||||
|
</span>
|
||||||
|
<span v-else>
|
||||||
|
<code>{{ model.uses }}</code>
|
||||||
|
<span class="mx-1">
|
||||||
|
uses
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
<span
|
||||||
|
v-if="reset"
|
||||||
|
class="mx-2"
|
||||||
|
>
|
||||||
|
{{ reset }}
|
||||||
|
</span>
|
||||||
|
<v-btn
|
||||||
|
v-if="context.creature"
|
||||||
|
outline
|
||||||
|
color="primary"
|
||||||
|
:disabled="!model.usesUsed || !context.editPermission"
|
||||||
|
@click="resetUses"
|
||||||
|
>
|
||||||
|
Reset
|
||||||
|
</v-btn>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<v-subheader
|
||||||
|
v-if="model.resources.attributesConsumed.length ||
|
||||||
|
model.resources.itemsConsumed.length"
|
||||||
|
style="height: 32px"
|
||||||
>
|
>
|
||||||
<computed :value="model.uses"/>
|
Resources
|
||||||
</property-field>
|
</v-subheader>
|
||||||
<property-field
|
<attribute-consumed-view
|
||||||
name="Uses used"
|
v-for="attributeConsumed in model.resources.attributesConsumed"
|
||||||
:value="model.usesUsed"
|
:key="attributeConsumed._id"
|
||||||
|
class="action-child"
|
||||||
|
:model="attributeConsumed"
|
||||||
|
style="padding-left: 44px;"
|
||||||
/>
|
/>
|
||||||
<property-field
|
<item-consumed-view
|
||||||
name="Reset"
|
v-for="itemConsumed in model.resources.itemsConsumed"
|
||||||
:value="reset"
|
:key="itemConsumed._id"
|
||||||
|
class="action-child"
|
||||||
|
:model="itemConsumed"
|
||||||
|
:action="model"
|
||||||
|
left-pad
|
||||||
/>
|
/>
|
||||||
<property-description
|
<v-divider
|
||||||
v-if="model.description"
|
v-if="model.summary || model.description"
|
||||||
:value="model.description"
|
class="my-3"
|
||||||
/>
|
/>
|
||||||
|
<template v-if="model.summary">
|
||||||
|
<property-description :value="model.summary" />
|
||||||
|
<v-divider
|
||||||
|
v-if="model.description"
|
||||||
|
class="my-3"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
|
<property-description :value="model.description" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import propertyViewerMixin from '/imports/ui/properties/viewers/shared/propertyViewerMixin.js';
|
import propertyViewerMixin from '/imports/ui/properties/viewers/shared/propertyViewerMixin.js';
|
||||||
import ComputedForCreature from '/imports/ui/components/computation/ComputedForCreature.vue';
|
import numberToSignedString from '/imports/ui/utility/numberToSignedString.js';
|
||||||
|
import doAction from '/imports/api/creature/actions/doAction.js';
|
||||||
|
import AttributeConsumedView from '/imports/ui/properties/components/actions/AttributeConsumedView.vue';
|
||||||
|
import ItemConsumedView from '/imports/ui/properties/components/actions/ItemConsumedView.vue';
|
||||||
|
import PropertyIcon from '/imports/ui/properties/shared/PropertyIcon.vue';
|
||||||
|
import { updateProperty } from '/imports/api/creature/CreatureProperties.js';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
mixins: [propertyViewerMixin],
|
|
||||||
components: {
|
components: {
|
||||||
Computed: ComputedForCreature,
|
AttributeConsumedView,
|
||||||
|
ItemConsumedView,
|
||||||
|
PropertyIcon,
|
||||||
},
|
},
|
||||||
|
mixins: [propertyViewerMixin],
|
||||||
|
props: {
|
||||||
|
attack: Boolean,
|
||||||
|
},
|
||||||
|
inject: {
|
||||||
|
context: {
|
||||||
|
default: {},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
data(){return {
|
||||||
|
doActionLoading: false,
|
||||||
|
}},
|
||||||
computed: {
|
computed: {
|
||||||
reset(){
|
reset(){
|
||||||
let reset = this.model.reset
|
let reset = this.model.reset
|
||||||
@@ -51,10 +148,52 @@ export default {
|
|||||||
return 'Reset on a long rest';
|
return 'Reset on a long rest';
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
},
|
||||||
|
rollBonus(){
|
||||||
|
if (!this.attack) return;
|
||||||
|
return numberToSignedString(this.model.rollBonusResult);
|
||||||
|
},
|
||||||
|
rollBonusTooLong(){
|
||||||
|
return this.rollBonus && this.rollBonus.length > 3;
|
||||||
|
},
|
||||||
|
totalUses(){
|
||||||
|
return Math.max(this.model.usesResult, 0);
|
||||||
|
},
|
||||||
|
usesLeft(){
|
||||||
|
return Math.max(this.model.usesResult - this.model.usesUsed, 0);
|
||||||
|
},
|
||||||
|
actionTypeIcon() {
|
||||||
|
return `$vuetify.icons.${this.model.actionType}`;
|
||||||
|
},
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
doAction(){
|
||||||
|
this.doActionLoading = true;
|
||||||
|
doAction.call({actionId: this.model._id}, error => {
|
||||||
|
this.doActionLoading = false;
|
||||||
|
if (error){
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
resetUses(){
|
||||||
|
updateProperty.call({
|
||||||
|
_id: this.model._id,
|
||||||
|
path: ['usesUsed'],
|
||||||
|
value: 0,
|
||||||
|
});
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style lang="css" scoped>
|
<style lang="css" scoped>
|
||||||
|
.action-sub-title {
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
}
|
||||||
|
.action-child {
|
||||||
|
height: 40px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@@ -1,37 +1,18 @@
|
|||||||
<template lang="html">
|
<template lang="html">
|
||||||
<div class="attack-viewer">
|
<action-viewer
|
||||||
<property-field name="Attack roll bonus">
|
:model="model"
|
||||||
<computed
|
attack
|
||||||
signed
|
/>
|
||||||
:value="model.rollBonus"
|
|
||||||
/>
|
|
||||||
</property-field>
|
|
||||||
<action-viewer :model="model" />
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import propertyViewerMixin from '/imports/ui/properties/viewers/shared/propertyViewerMixin.js';
|
import propertyViewerMixin from '/imports/ui/properties/viewers/shared/propertyViewerMixin.js';
|
||||||
import ComputedForCreature from '/imports/ui/components/computation/ComputedForCreature.vue';
|
|
||||||
import ActionViewer from '/imports/ui/properties/viewers/ActionViewer.vue';
|
import ActionViewer from '/imports/ui/properties/viewers/ActionViewer.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
components: {
|
components: {
|
||||||
ActionViewer,
|
ActionViewer,
|
||||||
Computed: ComputedForCreature,
|
|
||||||
},
|
},
|
||||||
mixins: [propertyViewerMixin],
|
mixins: [propertyViewerMixin],
|
||||||
computed: {
|
|
||||||
reset(){
|
|
||||||
let reset = this.model.reset
|
|
||||||
if (reset === 'shortRest'){
|
|
||||||
return 'Reset on a short rest';
|
|
||||||
} else if (reset === 'longRest'){
|
|
||||||
return 'Reset on a long rest';
|
|
||||||
}
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -1,23 +1,14 @@
|
|||||||
<template lang="html">
|
<template lang="html">
|
||||||
<div class="class-level-viewer">
|
<div class="class-level-viewer">
|
||||||
<div>
|
<div>
|
||||||
<span class="name headline">
|
<span class="name headline">
|
||||||
{{model.name}}
|
{{ model.name }} {{ model.level }}
|
||||||
</span>
|
</span>
|
||||||
<span
|
</div>
|
||||||
class="display-2"
|
<p class="my-2">
|
||||||
v-if="model.level"
|
<code>{{ model.variableName }}</code>
|
||||||
>
|
</p>
|
||||||
{{model.level}}
|
</div>
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<p class="my-2">
|
|
||||||
<code>{{model.variableName}}</code>
|
|
||||||
</p>
|
|
||||||
<p class="my-2" v-if="model.baseClass">
|
|
||||||
Base class: <code>{{model.baseClass}}</code>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
|||||||
@@ -7,7 +7,7 @@
|
|||||||
/>
|
/>
|
||||||
{{ model.damageType }}
|
{{ model.damageType }}
|
||||||
<span v-if="model.damageType !== 'healing'">
|
<span v-if="model.damageType !== 'healing'">
|
||||||
damage
|
damage
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|||||||
@@ -1,34 +0,0 @@
|
|||||||
<template lang="html">
|
|
||||||
<div class="experience-viewer">
|
|
||||||
<div
|
|
||||||
v-if="model.value"
|
|
||||||
class="display-1"
|
|
||||||
>
|
|
||||||
{{ model.value }} XP
|
|
||||||
</div>
|
|
||||||
<div class="headline layout row mb-3">
|
|
||||||
<property-name :value="model.name" />
|
|
||||||
<v-spacer />
|
|
||||||
<div>
|
|
||||||
{{ model.worldDate }}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<p>
|
|
||||||
{{ model.date }}
|
|
||||||
</p>
|
|
||||||
<property-description
|
|
||||||
v-if="model.description"
|
|
||||||
:value="model.description"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import propertyViewerMixin from '/imports/ui/properties/viewers/shared/propertyViewerMixin.js'
|
|
||||||
export default {
|
|
||||||
mixins: [propertyViewerMixin],
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="css" scoped>
|
|
||||||
</style>
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user