Compare commits
99 Commits
2.0-beta.2
...
2.0-beta.3
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6e51df363b | ||
|
|
608ab4e588 | ||
|
|
518880fa5c | ||
|
|
f043c41e12 | ||
|
|
0277de76c4 | ||
|
|
ffc3211ff9 | ||
|
|
8162c76185 | ||
|
|
e21586e9ce | ||
|
|
4c2155d8ff | ||
|
|
44cc46ed22 | ||
|
|
d2b5d5f01d | ||
|
|
4492c47b00 | ||
|
|
6600cea9fa | ||
|
|
741a9b080a | ||
|
|
b041db22e4 | ||
|
|
a465e2ce87 | ||
|
|
8ecefb03ad | ||
|
|
9f62a78eb0 | ||
|
|
16e2b1249f | ||
|
|
a35f9221a2 | ||
|
|
6364549d50 | ||
|
|
d999fb46a7 | ||
|
|
ec01a2adb5 | ||
|
|
1f64558100 | ||
|
|
19a2798bf7 | ||
|
|
a5f2c2e0d2 | ||
|
|
ee174210fd | ||
|
|
1e38295164 | ||
|
|
758cb2f8bc | ||
|
|
36bb3c3181 | ||
|
|
02434de34c | ||
|
|
0dc0bea53e | ||
|
|
c392119430 | ||
|
|
4e2e0ca364 | ||
|
|
4a8b72f163 | ||
|
|
d916dc2b78 | ||
|
|
56860ba96d | ||
|
|
b607755f9f | ||
|
|
86d8fa4325 | ||
|
|
2b08249e5e | ||
|
|
3133e664d5 | ||
|
|
48f32e0a8d | ||
|
|
c72785c9e7 | ||
|
|
421ff2aa7d | ||
|
|
9a9e6491b9 | ||
|
|
332258705c | ||
|
|
73ef109d4d | ||
|
|
fc240a34c4 | ||
|
|
8ac4028f38 | ||
|
|
2849df1974 | ||
|
|
3fa2cca7ae | ||
|
|
a0b53af6d7 | ||
|
|
51c709f7a5 | ||
|
|
28d67409aa | ||
|
|
7e97bcb6d8 | ||
|
|
4e87737a3e | ||
|
|
822fa4619f | ||
|
|
80ba44a28f | ||
|
|
c3c079731e | ||
|
|
039b7046b2 | ||
|
|
8eaad3600f | ||
|
|
5cf78932e6 | ||
|
|
d43d364175 | ||
|
|
0ad4c71189 | ||
|
|
e8c6f26a0b | ||
|
|
8804c80a56 | ||
|
|
0d21ab758e | ||
|
|
2ecb0e2671 | ||
|
|
f3b9b62486 | ||
|
|
29a4575760 | ||
|
|
a6fbf71b36 | ||
|
|
86d9383af0 | ||
|
|
3db589f775 | ||
|
|
e96755927f | ||
|
|
66dc0ee34f | ||
|
|
54bf21c57c | ||
|
|
5f5fe801f6 | ||
|
|
a451afcbaf | ||
|
|
848e961e3b | ||
|
|
c5aca81131 | ||
|
|
814e371148 | ||
|
|
69f4bbf360 | ||
|
|
6b2d74a165 | ||
|
|
cf05aea80a | ||
|
|
1a2d4b22bb | ||
|
|
81d52a1847 | ||
|
|
e3fc56a844 | ||
|
|
64fceb9c38 | ||
|
|
9994c1f32a | ||
|
|
7056c5b37b | ||
|
|
1ad1d1f23d | ||
|
|
c65c8f3299 | ||
|
|
4faea42371 | ||
|
|
9825872576 | ||
|
|
85b536bc46 | ||
|
|
9aa8203dcc | ||
|
|
217133137b | ||
|
|
aef7dbcbb3 | ||
|
|
6ff750417f |
19
README.md
19
README.md
@@ -66,5 +66,24 @@ You should see this:
|
|||||||
=> App running at: http://localhost:3000/
|
=> App running at: http://localhost:3000/
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Environmental Variables
|
||||||
|
-----------------------
|
||||||
|
|
||||||
|
```
|
||||||
|
MAIL_URL=smtp://<your smtp mail url>
|
||||||
|
METEOR_SETTINGS={ "public": { "environment": "production", "patreon": { "clientId": "<your patreon client ID>", "campaignId": "<your campaign id>" } }, "patreon": { "clientSecret": "<your client secret>", "creatorAccessToken": "<your creator access token>" } }
|
||||||
|
MONGO_OPLOG_URL=mongodb+srv://<your url for the oplog account of your mongo database>
|
||||||
|
MONGO_URL=mongodb+srv://<your url for the read/write account of your mongo database>
|
||||||
|
NPM_CONFIG_PRODUCTION=true
|
||||||
|
PROJECT_DIR=app
|
||||||
|
ROOT_URL=https://<url of your DiceCloud instance>
|
||||||
|
DEFAULT_LIBRARIES=<comma separated list of library ids that will be subscribed by default: "abc123,def456">
|
||||||
|
```
|
||||||
|
|
||||||
|
To disable Patreon features and unlock all paid restrictions for all users of your deployment, replace
|
||||||
|
`"patreon": { "clientId": ... }"` with `"disablePatreon": true` in the public key of the METEOR_SETTINGS environment variable.
|
||||||
|
|
||||||
|
Alternatively run `meteor run --settings exampleMeteorSettings.json` to start the app with the example settings that disable Patreon by default.
|
||||||
|
|
||||||
Now, visiting [](http://localhost:3000/) should show you an empty instance of
|
Now, visiting [](http://localhost:3000/) should show you an empty instance of
|
||||||
DiceCloud running.
|
DiceCloud running.
|
||||||
|
|||||||
@@ -3,42 +3,42 @@
|
|||||||
# 'meteor add' and 'meteor remove' will edit this file for you,
|
# 'meteor add' and 'meteor remove' will edit this file for you,
|
||||||
# but you can also edit it by hand.
|
# but you can also edit it by hand.
|
||||||
|
|
||||||
accounts-password@1.7.0
|
accounts-password
|
||||||
random@1.2.0
|
random
|
||||||
dburles:collection-helpers
|
dburles:collection-helpers
|
||||||
reactive-var@1.0.11
|
reactive-var
|
||||||
underscore@1.0.10
|
underscore
|
||||||
momentjs:moment
|
momentjs:moment
|
||||||
dburles:mongo-collection-instances
|
dburles:mongo-collection-instances
|
||||||
accounts-google@1.3.3
|
accounts-google
|
||||||
email@2.0.0
|
email
|
||||||
meteorhacks:subs-manager
|
meteorhacks:subs-manager
|
||||||
chuangbo:marked
|
chuangbo:marked
|
||||||
meteor-base@1.4.0
|
meteor-base
|
||||||
mobile-experience@1.1.0
|
mobile-experience
|
||||||
mongo@1.11.0
|
mongo
|
||||||
session@1.2.0
|
session
|
||||||
tracker@1.2.0
|
tracker
|
||||||
logging@1.2.0
|
logging
|
||||||
reload@1.3.1
|
reload
|
||||||
ejson@1.1.1
|
ejson
|
||||||
check@1.3.1
|
check
|
||||||
standard-minifier-js@2.6.0
|
standard-minifier-js
|
||||||
shell-server@0.5.0
|
shell-server
|
||||||
templates:array
|
templates:array
|
||||||
ecmascript@0.15.1
|
ecmascript
|
||||||
es5-shim@4.8.0
|
es5-shim
|
||||||
reactive-dict@1.3.0
|
reactive-dict
|
||||||
percolate:synced-cron
|
percolate:synced-cron
|
||||||
ongoworks:speakingurl
|
ongoworks:speakingurl
|
||||||
service-configuration@1.0.11
|
service-configuration
|
||||||
dynamic-import@0.6.0
|
dynamic-import
|
||||||
ddp-rate-limiter@1.0.9
|
ddp-rate-limiter
|
||||||
rate-limit@1.0.9
|
rate-limit
|
||||||
mdg:validated-method
|
mdg:validated-method
|
||||||
akryum:vue-router2
|
akryum:vue-router2
|
||||||
static-html
|
static-html
|
||||||
aldeed:collection2@3.0.0
|
aldeed:collection2
|
||||||
aldeed:schema-index
|
aldeed:schema-index
|
||||||
zer0th:meteor-vuetify-loader
|
zer0th:meteor-vuetify-loader
|
||||||
accounts-patreon
|
accounts-patreon
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
METEOR@2.2
|
METEOR@2.2.1
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
accounts-base@1.9.0
|
accounts-base@1.9.0
|
||||||
accounts-google@1.3.3
|
accounts-google@1.3.3
|
||||||
accounts-oauth@1.2.0
|
accounts-oauth@1.2.0
|
||||||
accounts-password@1.7.0
|
accounts-password@1.7.1
|
||||||
accounts-patreon@0.1.0
|
accounts-patreon@0.1.0
|
||||||
akryum:npm-check@0.1.2
|
akryum:npm-check@0.1.2
|
||||||
akryum:vue-component@0.15.2
|
akryum:vue-component@0.15.2
|
||||||
@@ -9,19 +9,19 @@ akryum:vue-component-dev-client@0.4.7
|
|||||||
akryum:vue-component-dev-server@0.1.4
|
akryum:vue-component-dev-server@0.1.4
|
||||||
akryum:vue-router2@0.2.3
|
akryum:vue-router2@0.2.3
|
||||||
akryum:vue-sass@0.1.2
|
akryum:vue-sass@0.1.2
|
||||||
aldeed:collection2@3.3.0
|
aldeed:collection2@3.4.1
|
||||||
aldeed:schema-index@3.0.0
|
aldeed:schema-index@3.0.0
|
||||||
allow-deny@1.1.0
|
allow-deny@1.1.0
|
||||||
autoupdate@1.7.0
|
autoupdate@1.7.0
|
||||||
babel-compiler@7.6.1
|
babel-compiler@7.6.2
|
||||||
babel-runtime@1.5.0
|
babel-runtime@1.5.0
|
||||||
base64@1.0.12
|
base64@1.0.12
|
||||||
binary-heap@1.0.11
|
binary-heap@1.0.11
|
||||||
blaze-tools@1.1.1
|
blaze-tools@1.1.2
|
||||||
boilerplate-generator@1.7.1
|
boilerplate-generator@1.7.1
|
||||||
bozhao:link-accounts@2.3.2
|
bozhao:link-accounts@2.4.0
|
||||||
caching-compiler@1.2.2
|
caching-compiler@1.2.2
|
||||||
caching-html-compiler@1.2.0
|
caching-html-compiler@1.2.1
|
||||||
callback-hook@1.3.0
|
callback-hook@1.3.0
|
||||||
check@1.3.1
|
check@1.3.1
|
||||||
chuangbo:marked@0.3.5_1
|
chuangbo:marked@0.3.5_1
|
||||||
@@ -30,17 +30,17 @@ coffeescript-compiler@2.4.1
|
|||||||
dburles:collection-helpers@1.1.0
|
dburles:collection-helpers@1.1.0
|
||||||
dburles:mongo-collection-instances@0.3.5
|
dburles:mongo-collection-instances@0.3.5
|
||||||
ddp@1.4.0
|
ddp@1.4.0
|
||||||
ddp-client@2.4.0
|
ddp-client@2.4.1
|
||||||
ddp-common@1.4.0
|
ddp-common@1.4.0
|
||||||
ddp-rate-limiter@1.0.9
|
ddp-rate-limiter@1.0.9
|
||||||
ddp-server@2.3.2
|
ddp-server@2.3.3
|
||||||
deps@1.0.12
|
deps@1.0.12
|
||||||
diff-sequence@1.1.1
|
diff-sequence@1.1.1
|
||||||
dynamic-import@0.6.0
|
dynamic-import@0.6.0
|
||||||
ecmascript@0.15.1
|
ecmascript@0.15.1
|
||||||
ecmascript-runtime@0.7.0
|
ecmascript-runtime@0.7.0
|
||||||
ecmascript-runtime-client@0.11.0
|
ecmascript-runtime-client@0.11.1
|
||||||
ecmascript-runtime-server@0.10.0
|
ecmascript-runtime-server@0.10.1
|
||||||
ejson@1.1.1
|
ejson@1.1.1
|
||||||
email@2.0.0
|
email@2.0.0
|
||||||
es5-shim@4.8.0
|
es5-shim@4.8.0
|
||||||
@@ -48,10 +48,10 @@ fetch@0.1.1
|
|||||||
geojson-utils@1.0.10
|
geojson-utils@1.0.10
|
||||||
google-oauth@1.3.0
|
google-oauth@1.3.0
|
||||||
hot-code-push@1.0.4
|
hot-code-push@1.0.4
|
||||||
html-tools@1.1.1
|
html-tools@1.1.2
|
||||||
htmljs@1.1.0
|
htmljs@1.1.1
|
||||||
http@1.4.3
|
http@1.4.4
|
||||||
id-map@1.1.0
|
id-map@1.1.1
|
||||||
inter-process-messaging@0.1.1
|
inter-process-messaging@0.1.1
|
||||||
lai:collection-extensions@0.2.1_1
|
lai:collection-extensions@0.2.1_1
|
||||||
launch-screen@1.2.1
|
launch-screen@1.2.1
|
||||||
@@ -63,8 +63,8 @@ meteor@1.9.3
|
|||||||
meteor-base@1.4.0
|
meteor-base@1.4.0
|
||||||
meteorhacks:subs-manager@1.6.4
|
meteorhacks:subs-manager@1.6.4
|
||||||
mikowals:batch-insert@1.2.0
|
mikowals:batch-insert@1.2.0
|
||||||
minifier-css@1.5.3
|
minifier-css@1.5.4
|
||||||
minifier-js@2.6.0
|
minifier-js@2.6.1
|
||||||
minimongo@1.6.2
|
minimongo@1.6.2
|
||||||
mobile-experience@1.1.0
|
mobile-experience@1.1.0
|
||||||
mobile-status-bar@1.1.0
|
mobile-status-bar@1.1.0
|
||||||
@@ -72,11 +72,11 @@ modern-browsers@0.1.5
|
|||||||
modules@0.16.0
|
modules@0.16.0
|
||||||
modules-runtime@0.12.0
|
modules-runtime@0.12.0
|
||||||
momentjs:moment@2.29.1
|
momentjs:moment@2.29.1
|
||||||
mongo@1.11.0
|
mongo@1.11.1
|
||||||
mongo-decimal@0.1.2
|
mongo-decimal@0.1.2
|
||||||
mongo-dev-server@1.1.0
|
mongo-dev-server@1.1.0
|
||||||
mongo-id@1.0.7
|
mongo-id@1.0.8
|
||||||
npm-bcrypt@0.9.3
|
npm-bcrypt@0.9.4
|
||||||
npm-mongo@3.9.0
|
npm-mongo@3.9.0
|
||||||
oauth@1.3.2
|
oauth@1.3.2
|
||||||
oauth2@1.3.0
|
oauth2@1.3.0
|
||||||
@@ -98,7 +98,7 @@ promise@0.11.2
|
|||||||
raix:eventemitter@1.0.0
|
raix:eventemitter@1.0.0
|
||||||
random@1.2.0
|
random@1.2.0
|
||||||
rate-limit@1.0.9
|
rate-limit@1.0.9
|
||||||
react-fast-refresh@0.1.0
|
react-fast-refresh@0.1.1
|
||||||
reactive-dict@1.3.0
|
reactive-dict@1.3.0
|
||||||
reactive-var@1.0.11
|
reactive-var@1.0.11
|
||||||
reload@1.3.1
|
reload@1.3.1
|
||||||
@@ -112,18 +112,18 @@ shell-server@0.5.0
|
|||||||
simple:json-routes@2.1.0
|
simple:json-routes@2.1.0
|
||||||
simple:rest@1.1.1
|
simple:rest@1.1.1
|
||||||
simple:rest-method-mixin@1.0.1
|
simple:rest-method-mixin@1.0.1
|
||||||
socket-stream-client@0.3.1
|
socket-stream-client@0.3.3
|
||||||
spacebars-compiler@1.2.1
|
spacebars-compiler@1.3.0
|
||||||
srp@1.1.0
|
srp@1.1.0
|
||||||
standard-minifier-js@2.6.0
|
standard-minifier-js@2.6.1
|
||||||
static-html@1.3.0
|
static-html@1.3.2
|
||||||
templates:array@1.0.3
|
templates:array@1.0.3
|
||||||
templating-tools@1.2.0
|
templating-tools@1.2.1
|
||||||
tmeasday:check-npm-versions@1.0.1
|
tmeasday:check-npm-versions@1.0.2
|
||||||
tracker@1.2.0
|
tracker@1.2.0
|
||||||
typescript@4.2.2
|
typescript@4.2.2
|
||||||
underscore@1.0.10
|
underscore@1.0.10
|
||||||
url@1.3.1
|
url@1.3.2
|
||||||
webapp@1.10.1
|
webapp@1.10.1
|
||||||
webapp-hashing@1.1.0
|
webapp-hashing@1.1.0
|
||||||
zer0th:meteor-vuetify-loader@0.1.30
|
zer0th:meteor-vuetify-loader@0.1.30
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
<head>
|
<head>
|
||||||
<link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900|Material+Icons" rel="stylesheet">
|
<link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900" rel="stylesheet">
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/@mdi/font@5.x/css/materialdesignicons.min.css" rel="stylesheet">
|
||||||
<meta name="viewport" content="width=device-width initial-scale=1.0, user-scalable=no">
|
<meta name="viewport" content="width=device-width initial-scale=1.0, user-scalable=no">
|
||||||
<meta name="mobile-web-app-capable" content="yes">
|
<meta name="mobile-web-app-capable" content="yes">
|
||||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
import '/imports/ui/vueSetup.js';
|
import '/imports/ui/vueSetup.js';
|
||||||
import '/imports/ui/styles/stylesIndex.js';
|
import '/imports/ui/styles/stylesIndex.js';
|
||||||
import '/imports/client/config.js';
|
import '/imports/client/config.js';
|
||||||
|
import '/imports/client/serviceWorker.js';
|
||||||
|
|||||||
6
app/exampleMeteorSettings.json
Normal file
6
app/exampleMeteorSettings.json
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"public": {
|
||||||
|
"environment": "production",
|
||||||
|
"disablePatreon": true
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
|
||||||
|
|
||||||
let Parties = new Mongo.Collection('parties');
|
|
||||||
|
|
||||||
let partySchema = new SimpleSchema({
|
|
||||||
name: {
|
|
||||||
type: String,
|
|
||||||
defaultValue: 'New Party',
|
|
||||||
trim: false,
|
|
||||||
optional: true,
|
|
||||||
},
|
|
||||||
creatures: {
|
|
||||||
type: Array,
|
|
||||||
defaultValue: [],
|
|
||||||
},
|
|
||||||
'creatures.$': {
|
|
||||||
type: String,
|
|
||||||
regEx: SimpleSchema.RegEx.Id,
|
|
||||||
},
|
|
||||||
owner: {
|
|
||||||
type: String,
|
|
||||||
regEx: SimpleSchema.RegEx.Id,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
Parties.attachSchema(partySchema);
|
|
||||||
|
|
||||||
export default Parties;
|
|
||||||
@@ -62,6 +62,7 @@ function applyPropertyAndWalkChildren({prop, children, targets, ...options}){
|
|||||||
export default function applyProperties({ forest, targets, ...options}){
|
export default function applyProperties({ forest, targets, ...options}){
|
||||||
forest.forEach(node => {
|
forest.forEach(node => {
|
||||||
let prop = node.node;
|
let prop = node.node;
|
||||||
|
options.actionContext[`#${prop.type}`] = prop;
|
||||||
let children = node.children;
|
let children = node.children;
|
||||||
if (shouldSplit(prop) && targets.length){
|
if (shouldSplit(prop) && targets.length){
|
||||||
targets.forEach(target => {
|
targets.forEach(target => {
|
||||||
|
|||||||
@@ -2,12 +2,15 @@ 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 { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
||||||
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
|
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
|
||||||
import Creatures from '/imports/api/creature/Creatures.js';
|
import Creatures from '/imports/api/creature/creatures/Creatures.js';
|
||||||
import { damagePropertyWork } from '/imports/api/creature/creatureProperties/methods/damageProperty.js';
|
import { damagePropertyWork } from '/imports/api/creature/creatureProperties/methods/damageProperty.js';
|
||||||
import { assertEditPermission } from '/imports/api/creature/creaturePermissions.js';
|
import { assertEditPermission } from '/imports/api/creature/creatures/creaturePermissions.js';
|
||||||
import { recomputeCreatureByDoc } from '/imports/api/creature/computation/methods/recomputeCreature.js';
|
import { recomputeCreatureByDoc } from '/imports/api/creature/computation/methods/recomputeCreature.js';
|
||||||
import { doActionWork } from '/imports/api/creature/actions/doAction.js';
|
import { doActionWork } from '/imports/api/creature/actions/doAction.js';
|
||||||
import getRootCreatureAncestor from '/imports/api/creature/creatureProperties/getRootCreatureAncestor.js';
|
import getRootCreatureAncestor from '/imports/api/creature/creatureProperties/getRootCreatureAncestor.js';
|
||||||
|
import getAncestorContext from '/imports/api/creature/actions/getAncestorContext.js';
|
||||||
|
import recomputeInventory from '/imports/api/creature/denormalise/recomputeInventory';
|
||||||
|
import recomputeInactiveProperties from '/imports/api/creature/denormalise/recomputeInactiveProperties';
|
||||||
|
|
||||||
const castSpellWithSlot = new ValidatedMethod({
|
const castSpellWithSlot = new ValidatedMethod({
|
||||||
name: 'creatureProperties.castSpellWithSlot',
|
name: 'creatureProperties.castSpellWithSlot',
|
||||||
@@ -61,16 +64,26 @@ const castSpellWithSlot = new ValidatedMethod({
|
|||||||
value: 1,
|
value: 1,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
doActionWork({
|
let actionContext = getAncestorContext(spell);
|
||||||
|
|
||||||
|
doActionWork({
|
||||||
action: spell,
|
action: spell,
|
||||||
context: {slotLevel},
|
actionContext: {slotLevel, ...actionContext},
|
||||||
creature,
|
creature,
|
||||||
targets: target ? [target] : [],
|
targets: target ? [target] : [],
|
||||||
method: this,
|
method: this,
|
||||||
});
|
});
|
||||||
// Note this only recomputes the top-level creature, not the nearest one
|
|
||||||
recomputeCreatureByDoc(creature);
|
// Note these lines only recompute the top-level creature, not the nearest one
|
||||||
|
// The acting creature might have a new item
|
||||||
|
recomputeInventory(creature._id);
|
||||||
|
// The spell might add properties which need to be activated
|
||||||
|
recomputeInactiveProperties(creature._id);
|
||||||
|
recomputeCreatureByDoc(creature);
|
||||||
|
|
||||||
if (target){
|
if (target){
|
||||||
|
recomputeInventory(target._id);
|
||||||
|
recomputeInactiveProperties(target._id);
|
||||||
recomputeCreatureByDoc(target);
|
recomputeCreatureByDoc(target);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -2,15 +2,16 @@ 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 { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
||||||
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
|
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
|
||||||
import Creatures from '/imports/api/creature/Creatures.js';
|
import Creatures from '/imports/api/creature/creatures/Creatures.js';
|
||||||
import { CreatureLogSchema, insertCreatureLogWork } from '/imports/api/creature/log/CreatureLogs.js';
|
import { CreatureLogSchema, insertCreatureLogWork } from '/imports/api/creature/log/CreatureLogs.js';
|
||||||
import getRootCreatureAncestor from '/imports/api/creature/creatureProperties/getRootCreatureAncestor.js';
|
import getRootCreatureAncestor from '/imports/api/creature/creatureProperties/getRootCreatureAncestor.js';
|
||||||
import { assertEditPermission } from '/imports/api/creature/creaturePermissions.js';
|
import { assertEditPermission } from '/imports/api/creature/creatures/creaturePermissions.js';
|
||||||
import { recomputeCreatureByDoc } from '/imports/api/creature/computation/methods/recomputeCreature.js';
|
import { recomputeCreatureByDoc } from '/imports/api/creature/computation/methods/recomputeCreature.js';
|
||||||
import { nodesToTree } from '/imports/api/parenting/parenting.js';
|
import nodesToTree from '/imports/api/parenting/nodesToTree.js';
|
||||||
import applyProperties from '/imports/api/creature/actions/applyProperties.js';
|
import applyProperties from '/imports/api/creature/actions/applyProperties.js';
|
||||||
import recomputeInventory from '/imports/api/creature/denormalise/recomputeInventory.js';
|
import recomputeInventory from '/imports/api/creature/denormalise/recomputeInventory.js';
|
||||||
import recomputeInactiveProperties from '/imports/api/creature/denormalise/recomputeInactiveProperties.js';
|
import recomputeInactiveProperties from '/imports/api/creature/denormalise/recomputeInactiveProperties.js';
|
||||||
|
import getAncestorContext from '/imports/api/creature/actions/getAncestorContext.js';
|
||||||
|
|
||||||
const doAction = new ValidatedMethod({
|
const doAction = new ValidatedMethod({
|
||||||
name: 'creatureProperties.doAction',
|
name: 'creatureProperties.doAction',
|
||||||
@@ -36,6 +37,10 @@ const doAction = new ValidatedMethod({
|
|||||||
let action = CreatureProperties.findOne(actionId);
|
let action = CreatureProperties.findOne(actionId);
|
||||||
// Check permissions
|
// Check permissions
|
||||||
let creature = getRootCreatureAncestor(action);
|
let creature = getRootCreatureAncestor(action);
|
||||||
|
|
||||||
|
// Build ancestor context
|
||||||
|
let actionContext = getAncestorContext(action);
|
||||||
|
|
||||||
assertEditPermission(creature, this.userId);
|
assertEditPermission(creature, this.userId);
|
||||||
let targets = [];
|
let targets = [];
|
||||||
targetIds.forEach(targetId => {
|
targetIds.forEach(targetId => {
|
||||||
@@ -43,7 +48,7 @@ const doAction = new ValidatedMethod({
|
|||||||
assertEditPermission(target, this.userId);
|
assertEditPermission(target, this.userId);
|
||||||
targets.push(target);
|
targets.push(target);
|
||||||
});
|
});
|
||||||
doActionWork({action, creature, targets, method: this});
|
doActionWork({action, creature, targets, actionContext, method: this});
|
||||||
|
|
||||||
// The acting creature might have used ammo
|
// The acting creature might have used ammo
|
||||||
recomputeInventory(creature._id);
|
recomputeInventory(creature._id);
|
||||||
@@ -64,7 +69,7 @@ export function doActionWork({
|
|||||||
action,
|
action,
|
||||||
creature,
|
creature,
|
||||||
targets,
|
targets,
|
||||||
context = {},
|
actionContext = {},
|
||||||
method
|
method
|
||||||
}){
|
}){
|
||||||
// Create the log
|
// Create the log
|
||||||
@@ -83,7 +88,7 @@ export function doActionWork({
|
|||||||
}];
|
}];
|
||||||
applyProperties({
|
applyProperties({
|
||||||
forest: startingForest,
|
forest: startingForest,
|
||||||
actionContext: context,
|
actionContext,
|
||||||
creature,
|
creature,
|
||||||
targets,
|
targets,
|
||||||
log,
|
log,
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
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 { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
||||||
import Creatures from '/imports/api/creature/Creatures.js';
|
import Creatures from '/imports/api/creature/creatures/Creatures.js';
|
||||||
import { assertEditPermission } from '/imports/api/creature/creaturePermissions.js';
|
import { assertEditPermission } from '/imports/api/creature/creatures/creaturePermissions.js';
|
||||||
import roll from '/imports/parser/roll.js';
|
import roll from '/imports/parser/roll.js';
|
||||||
|
|
||||||
const doCheck = new ValidatedMethod({
|
const doCheck = new ValidatedMethod({
|
||||||
|
|||||||
15
app/imports/api/creature/actions/getAncestorContext.js
Normal file
15
app/imports/api/creature/actions/getAncestorContext.js
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
|
||||||
|
|
||||||
|
export default function getAncestorContext(prop){
|
||||||
|
// Build ancestor context
|
||||||
|
const actionContext = {};
|
||||||
|
let ancestorIds = prop.ancestors.map(ref => ref.id);
|
||||||
|
CreatureProperties.find({
|
||||||
|
_id: {$in: ancestorIds}
|
||||||
|
}, {
|
||||||
|
sort: {order: 1},
|
||||||
|
}).forEach(ancestor => {
|
||||||
|
actionContext[`#${ancestor.type}`] = ancestor;
|
||||||
|
});
|
||||||
|
return actionContext;
|
||||||
|
}
|
||||||
57
app/imports/api/creature/archive/ArchivedCreatures.js
Normal file
57
app/imports/api/creature/archive/ArchivedCreatures.js
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
import SimpleSchema from 'simpl-schema';
|
||||||
|
|
||||||
|
// Archived creatures is an immutable collection of creatures that are no longer
|
||||||
|
// in use and can be safely archived by the mongoDB hosting service.
|
||||||
|
// It keeps the working datasets like creatureProperties much smaller
|
||||||
|
// than they would otherwise be.
|
||||||
|
let ArchivedCreatures = new Mongo.Collection('archivedCreatures');
|
||||||
|
|
||||||
|
// We use blackbox objects for everything:
|
||||||
|
// - saves time checking every object against a schema
|
||||||
|
// - doesn't accidentaly create indices defined in subschemas
|
||||||
|
// - The objects we are archiving have already been checked against their
|
||||||
|
// own schemas
|
||||||
|
let ArchivedCreatureSchema = new SimpleSchema({
|
||||||
|
owner: {
|
||||||
|
type: String,
|
||||||
|
regEx: SimpleSchema.RegEx.Id,
|
||||||
|
// The primary index on this collection
|
||||||
|
index: 1,
|
||||||
|
},
|
||||||
|
archiveDate: {
|
||||||
|
type: Date,
|
||||||
|
// Indexed so the archiving system can archive documents when they
|
||||||
|
// get to a certain age
|
||||||
|
index: 1,
|
||||||
|
},
|
||||||
|
creature: {
|
||||||
|
type: Object,
|
||||||
|
blackbox: true,
|
||||||
|
},
|
||||||
|
properties: {
|
||||||
|
type: Array,
|
||||||
|
},
|
||||||
|
'properties.$': {
|
||||||
|
type: Object,
|
||||||
|
blackbox: true,
|
||||||
|
},
|
||||||
|
experiences: {
|
||||||
|
type: Array,
|
||||||
|
},
|
||||||
|
'experiences.$': {
|
||||||
|
type: Object,
|
||||||
|
blackbox: true,
|
||||||
|
},
|
||||||
|
logs: {
|
||||||
|
type: Array,
|
||||||
|
},
|
||||||
|
'logs.$': {
|
||||||
|
type: Object,
|
||||||
|
blackbox: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
ArchivedCreatures.attachSchema(ArchivedCreatureSchema);
|
||||||
|
|
||||||
|
import '/imports/api/creature/archive/methods/index.js';
|
||||||
|
export default ArchivedCreatures;
|
||||||
66
app/imports/api/creature/archive/methods/archiveCreatures.js
Normal file
66
app/imports/api/creature/archive/methods/archiveCreatures.js
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
import SimpleSchema from 'simpl-schema';
|
||||||
|
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
||||||
|
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
||||||
|
import { assertOwnership } from '/imports/api/creature/creatures/creaturePermissions.js';
|
||||||
|
import Creatures from '/imports/api/creature/creatures/Creatures.js';
|
||||||
|
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
|
||||||
|
import CreatureLogs from '/imports/api/creature/log/CreatureLogs.js';
|
||||||
|
import Experiences from '/imports/api/creature/experience/Experiences.js';
|
||||||
|
import { removeCreatureWork } from '/imports/api/creature/creatures/methods/removeCreature.js';
|
||||||
|
import ArchivedCreatures from '/imports/api/creature/archive/ArchivedCreatures.js';
|
||||||
|
|
||||||
|
function archiveCreature(creatureId){
|
||||||
|
// Build the archive document
|
||||||
|
const creature = Creatures.findOne(creatureId);
|
||||||
|
const properties = CreatureProperties.find({'ancestors.id': creatureId}).fetch();
|
||||||
|
const experiences = Experiences.find({creatureId}).fetch();
|
||||||
|
const logs = CreatureLogs.find({creatureId}).fetch();
|
||||||
|
let archiveCreature = {
|
||||||
|
owner: creature.owner,
|
||||||
|
archiveDate: new Date(),
|
||||||
|
creature,
|
||||||
|
properties,
|
||||||
|
experiences,
|
||||||
|
logs,
|
||||||
|
};
|
||||||
|
|
||||||
|
// Insert it
|
||||||
|
let id = ArchivedCreatures.insert(archiveCreature);
|
||||||
|
|
||||||
|
// Remove the original creature
|
||||||
|
removeCreatureWork(creatureId);
|
||||||
|
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
const archiveCreatures = new ValidatedMethod({
|
||||||
|
name: 'Creatures.methods.archiveCreatures',
|
||||||
|
validate: new SimpleSchema({
|
||||||
|
creatureIds: {
|
||||||
|
type: Array,
|
||||||
|
max: 10,
|
||||||
|
},
|
||||||
|
'creatureIds.$': {
|
||||||
|
type: String,
|
||||||
|
regEx: SimpleSchema.RegEx.Id,
|
||||||
|
},
|
||||||
|
}).validator(),
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 1,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
|
run({creatureIds}) {
|
||||||
|
for (let id of creatureIds){
|
||||||
|
assertOwnership(id, this.userId)
|
||||||
|
}
|
||||||
|
let archivedIds = [];
|
||||||
|
for (let id of creatureIds){
|
||||||
|
let archivedId = archiveCreature(id);
|
||||||
|
archivedIds.push(archivedId);
|
||||||
|
}
|
||||||
|
return archivedIds;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default archiveCreatures;
|
||||||
2
app/imports/api/creature/archive/methods/index.js
Normal file
2
app/imports/api/creature/archive/methods/index.js
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
import '/imports/api/creature/archive/methods/archiveCreatures.js';
|
||||||
|
import '/imports/api/creature/archive/methods/restoreCreatures.js';
|
||||||
77
app/imports/api/creature/archive/methods/restoreCreatures.js
Normal file
77
app/imports/api/creature/archive/methods/restoreCreatures.js
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
import SimpleSchema from 'simpl-schema';
|
||||||
|
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
||||||
|
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
||||||
|
import { assertOwnership } from '/imports/api/sharing/sharingPermissions.js';
|
||||||
|
import Creatures from '/imports/api/creature/creatures/Creatures.js';
|
||||||
|
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
|
||||||
|
import CreatureLogs from '/imports/api/creature/log/CreatureLogs.js';
|
||||||
|
import Experiences from '/imports/api/creature/experience/Experiences.js';
|
||||||
|
import ArchivedCreatures from '/imports/api/creature/archive/ArchivedCreatures.js';
|
||||||
|
import { removeCreatureWork } from '/imports/api/creature/creatures/methods/removeCreature.js';
|
||||||
|
|
||||||
|
function restoreCreature(archiveId){
|
||||||
|
// Get the archive
|
||||||
|
const archivedCreature = ArchivedCreatures.findOne(archiveId);
|
||||||
|
|
||||||
|
// Insert the creature sub documents
|
||||||
|
// They still have their original _id's
|
||||||
|
Creatures.insert(archivedCreature.creature);
|
||||||
|
try {
|
||||||
|
// Add all the properties
|
||||||
|
if (archivedCreature.properties && archivedCreature.properties.length){
|
||||||
|
CreatureProperties.batchInsert(archivedCreature.properties);
|
||||||
|
}
|
||||||
|
if (archivedCreature.experiences && archivedCreature.experiences.length){
|
||||||
|
Experiences.batchInsert(archivedCreature.experiences);
|
||||||
|
}
|
||||||
|
if (archivedCreature.logs && archivedCreature.logs.length){
|
||||||
|
CreatureLogs.batchInsert(archivedCreature.logs);
|
||||||
|
}
|
||||||
|
// Remove the archived creature
|
||||||
|
ArchivedCreatures.remove(archiveId);
|
||||||
|
} catch (e) {
|
||||||
|
// If the above fails, delete the inserted creature
|
||||||
|
removeCreatureWork(archivedCreature.creature._id);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Do not recompute. The creature was in a computed and ordered state when
|
||||||
|
// we archived it, just restore everything as-is
|
||||||
|
|
||||||
|
return archivedCreature.creature._id;
|
||||||
|
}
|
||||||
|
|
||||||
|
const restoreCreatures = new ValidatedMethod({
|
||||||
|
name: 'Creatures.methods.restoreCreatures',
|
||||||
|
validate: new SimpleSchema({
|
||||||
|
archiveIds: {
|
||||||
|
type: Array,
|
||||||
|
max: 10,
|
||||||
|
},
|
||||||
|
'archiveIds.$': {
|
||||||
|
type: String,
|
||||||
|
regEx: SimpleSchema.RegEx.Id,
|
||||||
|
},
|
||||||
|
}).validator(),
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 1,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
|
run({archiveIds}) {
|
||||||
|
for (let id of archiveIds){
|
||||||
|
let archivedCreature = ArchivedCreatures.findOne(id, {
|
||||||
|
fields: {owner: 1}
|
||||||
|
});
|
||||||
|
assertOwnership(archivedCreature, this.userId)
|
||||||
|
}
|
||||||
|
let creatureIds = [];
|
||||||
|
for (let id of archiveIds){
|
||||||
|
let creatureId = restoreCreature(id);
|
||||||
|
creatureIds.push(creatureId);
|
||||||
|
}
|
||||||
|
return creatureIds;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default restoreCreatures;
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
export default class EffectAggregator{
|
export default class EffectAggregator{
|
||||||
constructor(){
|
constructor(){
|
||||||
this.base = 0;
|
this.base = undefined;
|
||||||
this.add = 0;
|
this.add = 0;
|
||||||
this.mul = 1;
|
this.mul = 1;
|
||||||
this.min = Number.NEGATIVE_INFINITY;
|
this.min = Number.NEGATIVE_INFINITY;
|
||||||
@@ -20,7 +20,13 @@ export default class EffectAggregator{
|
|||||||
switch(effect.operation){
|
switch(effect.operation){
|
||||||
case 'base':
|
case 'base':
|
||||||
// Take the largest base value
|
// Take the largest base value
|
||||||
this.base = result > this.base ? result : this.base;
|
if (Number.isFinite(result)){
|
||||||
|
if(Number.isFinite(this.base)){
|
||||||
|
this.base = Math.max(this.base, result);
|
||||||
|
} else {
|
||||||
|
this.base = result;
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'add':
|
case 'add':
|
||||||
// Add all adds together
|
// Add all adds together
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import computeStat from '/imports/api/creature/computation/engine/computeStat.js';
|
import computeStat from '/imports/api/creature/computation/engine/computeStat.js';
|
||||||
import computeProficiency from '/imports/api/creature/computation/engine/computeProficiency.js';
|
import computeProficiency from '/imports/api/creature/computation/engine/computeProficiency.js';
|
||||||
import evaluateCalculation from '/imports/api/creature/computation/engine/evaluateCalculation.js';
|
import evaluateCalculation from '/imports/api/creature/computation/engine/evaluateCalculation.js';
|
||||||
|
import stripFloatingPointOddities from '/imports/ui/utility/stripFloatingPointOddities.js';
|
||||||
import { union } from 'lodash';
|
import { union } from 'lodash';
|
||||||
|
|
||||||
export default function combineStat(stat, aggregator, memo){
|
export default function combineStat(stat, aggregator, memo){
|
||||||
@@ -14,7 +15,14 @@ export default function combineStat(stat, aggregator, memo){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getAggregatorResult(stat, aggregator){
|
function getAggregatorResult(stat, aggregator){
|
||||||
let base = Math.max(aggregator.base, stat.baseValue || 0);
|
let base;
|
||||||
|
if (!Number.isFinite(aggregator.base)){
|
||||||
|
base = stat.baseValue || 0;
|
||||||
|
} else if (!Number.isFinite(stat.baseValue)){
|
||||||
|
base = aggregator.base || 0;
|
||||||
|
} else {
|
||||||
|
base = Math.max(aggregator.base, stat.baseValue);
|
||||||
|
}
|
||||||
let result = (base + aggregator.add) * aggregator.mul;
|
let result = (base + aggregator.add) * aggregator.mul;
|
||||||
if (result < aggregator.min) {
|
if (result < aggregator.min) {
|
||||||
result = aggregator.min;
|
result = aggregator.min;
|
||||||
@@ -27,6 +35,8 @@ function getAggregatorResult(stat, aggregator){
|
|||||||
}
|
}
|
||||||
if (!stat.decimal && Number.isFinite(result)){
|
if (!stat.decimal && Number.isFinite(result)){
|
||||||
result = Math.floor(result);
|
result = Math.floor(result);
|
||||||
|
} else if (Number.isFinite(result)){
|
||||||
|
result = stripFloatingPointOddities(result);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -137,7 +147,8 @@ function combineSkill(stat, aggregator, memo){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Combine everything to get the final result
|
// Combine everything to get the final result
|
||||||
let result = (aggregator.base + stat.abilityMod + profBonus + aggregator.add) * aggregator.mul;
|
let base = aggregator.base || 0;
|
||||||
|
let result = (base + stat.abilityMod + profBonus + aggregator.add) * aggregator.mul;
|
||||||
if (result < aggregator.min) result = aggregator.min;
|
if (result < aggregator.min) result = aggregator.min;
|
||||||
if (result > aggregator.max) result = aggregator.max;
|
if (result > aggregator.max) result = aggregator.max;
|
||||||
if (aggregator.set !== undefined) {
|
if (aggregator.set !== undefined) {
|
||||||
|
|||||||
@@ -21,13 +21,19 @@ export default function computeStat(stat, memo){
|
|||||||
// Before doing any work, mark this stat as busy
|
// Before doing any work, mark this stat as busy
|
||||||
stat.computationDetails.busyComputing = true;
|
stat.computationDetails.busyComputing = true;
|
||||||
|
|
||||||
let effects = stat.computationDetails.effects;
|
let effects = stat.computationDetails.effects || [];
|
||||||
let proficiencies = stat.computationDetails.proficiencies;
|
let proficiencies = stat.computationDetails.proficiencies || [];
|
||||||
|
|
||||||
// Get references to all the stats that share the variable name
|
// Get references to all the stats that share the variable name
|
||||||
let sameNameStats = stat.computationDetails.idsOfSameName.map(
|
let sameNameStats
|
||||||
id => memo.propsById[id]
|
|
||||||
);
|
if (stat.computationDetails.idsOfSameName){
|
||||||
|
sameNameStats = stat.computationDetails.idsOfSameName.map(
|
||||||
|
id => memo.propsById[id]
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
sameNameStats = [];
|
||||||
|
}
|
||||||
|
|
||||||
let allStats = [stat, ...sameNameStats];
|
let allStats = [stat, ...sameNameStats];
|
||||||
|
|
||||||
@@ -76,7 +82,9 @@ export default function computeStat(stat, memo){
|
|||||||
value: statInstance.baseProficiency,
|
value: statInstance.baseProficiency,
|
||||||
stats: [statInstance.variableName],
|
stats: [statInstance.variableName],
|
||||||
type: 'proficiency',
|
type: 'proficiency',
|
||||||
dependencies: [],
|
dependencies: statInstance.overridden ?
|
||||||
|
union(statInstance.dependencies, [statInstance._id]) :
|
||||||
|
[],
|
||||||
computationDetails: {
|
computationDetails: {
|
||||||
computed: true,
|
computed: true,
|
||||||
}
|
}
|
||||||
@@ -84,7 +92,8 @@ export default function computeStat(stat, memo){
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Compute each active stat's baseValue calculation and apply it
|
// Compute each active stat's baseValue calculation and apply it
|
||||||
if (statInstance.baseValueCalculation) {
|
if (!statInstance.inactive) {
|
||||||
|
delete statInstance.baseValueErrors;
|
||||||
let {
|
let {
|
||||||
result,
|
result,
|
||||||
context,
|
context,
|
||||||
@@ -94,19 +103,26 @@ export default function computeStat(stat, memo){
|
|||||||
prop: statInstance,
|
prop: statInstance,
|
||||||
memo
|
memo
|
||||||
});
|
});
|
||||||
baseDependencies = union(baseDependencies, dependencies);
|
result.value = +result.value;
|
||||||
statInstance.baseValue = +result.value;
|
if (!isNaN(result.value)){
|
||||||
|
statInstance.baseValue = result.value;
|
||||||
|
} else {
|
||||||
|
statInstance.baseValue = undefined;
|
||||||
|
}
|
||||||
|
statInstance.dependencies = union(statInstance.dependencies, dependencies);
|
||||||
if (context.errors.length){
|
if (context.errors.length){
|
||||||
statInstance.baseValueErrors = context.errors;
|
statInstance.baseValueErrors = context.errors;
|
||||||
}
|
}
|
||||||
// Apply all the base values
|
// Apply all the base values
|
||||||
if (!statInstance.inactive){
|
if (Number.isFinite(statInstance.baseValue)){
|
||||||
effects.push({
|
effects.push({
|
||||||
operation: 'base',
|
operation: 'base',
|
||||||
calculation: statInstance.baseValueCalculation,
|
calculation: statInstance.baseValueCalculation,
|
||||||
result: statInstance.baseValue,
|
result: statInstance.baseValue,
|
||||||
stats: [statInstance.variableName],
|
stats: [statInstance.variableName],
|
||||||
dependencies: [],
|
dependencies: statInstance.overridden ?
|
||||||
|
union(statInstance.dependencies, [statInstance._id]) :
|
||||||
|
[],
|
||||||
computationDetails: {
|
computationDetails: {
|
||||||
computed: true,
|
computed: true,
|
||||||
},
|
},
|
||||||
@@ -115,14 +131,6 @@ export default function computeStat(stat, memo){
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Apply all the base baseDependencies
|
|
||||||
allStats.forEach(statInstance => {
|
|
||||||
statInstance.dependencies = union(
|
|
||||||
statInstance.dependencies,
|
|
||||||
without(baseDependencies, statInstance._id)
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Compute and aggregate all the effects
|
// Compute and aggregate all the effects
|
||||||
let aggregator = new EffectAggregator();
|
let aggregator = new EffectAggregator();
|
||||||
let effectDeps = [];
|
let effectDeps = [];
|
||||||
@@ -132,7 +140,7 @@ export default function computeStat(stat, memo){
|
|||||||
if (effect.deactivatedByToggle) return;
|
if (effect.deactivatedByToggle) return;
|
||||||
|
|
||||||
// dependencies
|
// dependencies
|
||||||
if (effect._id) effectDeps = [effect._id];
|
if (effect._id) effectDeps = union(effectDeps, [effect._id]);
|
||||||
effectDeps = union(effectDeps, effect.dependencies);
|
effectDeps = union(effectDeps, effect.dependencies);
|
||||||
|
|
||||||
// Add computed effect to aggregator
|
// Add computed effect to aggregator
|
||||||
@@ -146,9 +154,9 @@ export default function computeStat(stat, memo){
|
|||||||
// Mark the stats as computed
|
// Mark the stats as computed
|
||||||
statInstance.computationDetails.computed = true;
|
statInstance.computationDetails.computed = true;
|
||||||
statInstance.computationDetails.busyComputing = false;
|
statInstance.computationDetails.busyComputing = false;
|
||||||
statInstance.dependencies = union(
|
// Only the active stat instance depeneds on the effects
|
||||||
statInstance.dependencies,
|
if (!statInstance.overridden){
|
||||||
effectDeps
|
statInstance.dependencies = union(statInstance.dependencies, effectDeps);
|
||||||
);
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { pick, forOwn } from 'lodash';
|
import { pick, forOwn } from 'lodash';
|
||||||
import Creatures from '/imports/api/creature/Creatures.js';
|
import Creatures from '/imports/api/creature/creatures/Creatures.js';
|
||||||
import VERSION from '/imports/constants/VERSION.js';
|
import VERSION from '/imports/constants/VERSION.js';
|
||||||
|
|
||||||
export default function writeCreatureVariables(memo, creatureId, fullRecompute = true) {
|
export default function writeCreatureVariables(memo, creatureId, fullRecompute = true) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
||||||
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
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/creatures/creaturePermissions.js';
|
||||||
import ComputationMemo from '/imports/api/creature/computation/engine/ComputationMemo.js';
|
import ComputationMemo from '/imports/api/creature/computation/engine/ComputationMemo.js';
|
||||||
import getComputationProperties from '/imports/api/creature/computation/engine/getComputationProperties.js';
|
import getComputationProperties from '/imports/api/creature/computation/engine/getComputationProperties.js';
|
||||||
import computeMemo from '/imports/api/creature/computation/engine/computeMemo.js';
|
import computeMemo from '/imports/api/creature/computation/engine/computeMemo.js';
|
||||||
@@ -11,7 +11,7 @@ import { recomputeDamageMultipliersById } from '/imports/api/creature/denormalis
|
|||||||
import recomputeSlotFullness from '/imports/api/creature/denormalise/recomputeSlotFullness.js';
|
import recomputeSlotFullness from '/imports/api/creature/denormalise/recomputeSlotFullness.js';
|
||||||
import getRootCreatureAncestor from '/imports/api/creature/creatureProperties/getRootCreatureAncestor.js';
|
import getRootCreatureAncestor from '/imports/api/creature/creatureProperties/getRootCreatureAncestor.js';
|
||||||
import getDependentProperties from '/imports/api/creature/computation/engine/getDependentProperties.js';
|
import getDependentProperties from '/imports/api/creature/computation/engine/getDependentProperties.js';
|
||||||
import Creatures from '/imports/api/creature/Creatures.js';
|
import Creatures from '/imports/api/creature/creatures/Creatures.js';
|
||||||
import recomputeInactiveProperties from '/imports/api/creature/denormalise/recomputeInactiveProperties.js';
|
import recomputeInactiveProperties from '/imports/api/creature/denormalise/recomputeInactiveProperties.js';
|
||||||
|
|
||||||
export const recomputeCreature = new ValidatedMethod({
|
export const recomputeCreature = new ValidatedMethod({
|
||||||
|
|||||||
39
app/imports/api/creature/creatureFolders/CreatureFolders.js
Normal file
39
app/imports/api/creature/creatureFolders/CreatureFolders.js
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
import SimpleSchema from 'simpl-schema';
|
||||||
|
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||||
|
|
||||||
|
let CreatureFolders = new Mongo.Collection('creatureFolders');
|
||||||
|
|
||||||
|
let creatureFolderSchema = new SimpleSchema({
|
||||||
|
name: {
|
||||||
|
type: String,
|
||||||
|
trim: false,
|
||||||
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
|
},
|
||||||
|
creatures: {
|
||||||
|
type: Array,
|
||||||
|
defaultValue: [],
|
||||||
|
},
|
||||||
|
'creatures.$': {
|
||||||
|
type: String,
|
||||||
|
regEx: SimpleSchema.RegEx.Id,
|
||||||
|
},
|
||||||
|
owner: {
|
||||||
|
type: String,
|
||||||
|
regEx: SimpleSchema.RegEx.Id,
|
||||||
|
index: 1,
|
||||||
|
},
|
||||||
|
archived: {
|
||||||
|
type: Boolean,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
order: {
|
||||||
|
type: Number,
|
||||||
|
defaultValue: 0,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
CreatureFolders.attachSchema(creatureFolderSchema);
|
||||||
|
|
||||||
|
import '/imports/api/creature/creatureFolders/methods.js/index.js';
|
||||||
|
export default CreatureFolders;
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
import '/imports/api/creature/creatureFolders/methods.js/insertCreatureFolder.js';
|
||||||
|
import '/imports/api/creature/creatureFolders/methods.js/updateCreatureFolderName.js';
|
||||||
|
import '/imports/api/creature/creatureFolders/methods.js/removeCreatureFolder.js';
|
||||||
|
import '/imports/api/creature/creatureFolders/methods.js/moveCreatureToFolder.js';
|
||||||
@@ -0,0 +1,46 @@
|
|||||||
|
import CreatureFolders from '/imports/api/creature/creatureFolders/CreatureFolders.js';
|
||||||
|
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
||||||
|
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
||||||
|
|
||||||
|
const insertCreatureFolder = new ValidatedMethod({
|
||||||
|
name: 'creatureFolders.methods.insert',
|
||||||
|
validate: null,
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
|
run() {
|
||||||
|
// Ensure logged in
|
||||||
|
let userId = this.userId;
|
||||||
|
if (!userId) {
|
||||||
|
throw new Meteor.Error('creatureFolders.methods.insert.denied',
|
||||||
|
'You need to be logged in to insert a folder');
|
||||||
|
}
|
||||||
|
// Limit folders to 50 per user
|
||||||
|
let existingFolders = CreatureFolders.find({
|
||||||
|
owner: userId
|
||||||
|
}, {
|
||||||
|
fields: {order: 1},
|
||||||
|
sort: {order :-1}
|
||||||
|
});
|
||||||
|
if (existingFolders.count() >= 50){
|
||||||
|
throw new Meteor.Error('creatureFolders.methods.insert.denied',
|
||||||
|
'You can not have more than 50 folders');
|
||||||
|
}
|
||||||
|
// Make the new folder the last in the order
|
||||||
|
let order = 0;
|
||||||
|
let lastFolder = existingFolders.fetch()[0];
|
||||||
|
if (lastFolder){
|
||||||
|
order = (lastFolder.order || 0) + 1;
|
||||||
|
}
|
||||||
|
// Insert
|
||||||
|
return CreatureFolders.insert({
|
||||||
|
name: 'Folder',
|
||||||
|
owner: userId,
|
||||||
|
order,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default insertCreatureFolder;
|
||||||
@@ -0,0 +1,45 @@
|
|||||||
|
import CreatureFolders from '/imports/api/creature/creatureFolders/CreatureFolders.js';
|
||||||
|
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
||||||
|
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
||||||
|
|
||||||
|
const moveCreatureToFolder = new ValidatedMethod({
|
||||||
|
name: 'creatureFolders.methods.moveCreatureToFolder',
|
||||||
|
validate: null,
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
|
run({creatureId, folderId}) {
|
||||||
|
// Ensure logged in
|
||||||
|
let userId = this.userId;
|
||||||
|
if (!userId) {
|
||||||
|
throw new Meteor.Error('creatureFolders.methods.updateName.denied',
|
||||||
|
'You need to be logged in to remove a folder');
|
||||||
|
}
|
||||||
|
// Check that this folder is owned by the user
|
||||||
|
if (folderId){
|
||||||
|
let existingFolder = CreatureFolders.findOne(folderId);
|
||||||
|
if (existingFolder.owner !== userId){
|
||||||
|
throw new Meteor.Error('creatureFolders.methods.updateName.denied',
|
||||||
|
'This folder does not belong to you');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Remove from other folders
|
||||||
|
CreatureFolders.update({
|
||||||
|
owner: userId
|
||||||
|
}, {
|
||||||
|
$pull: {creatures: creatureId},
|
||||||
|
}, {
|
||||||
|
multi: true,
|
||||||
|
});
|
||||||
|
if (folderId){
|
||||||
|
// Add to this folder
|
||||||
|
CreatureFolders.update(folderId, {
|
||||||
|
$addToSet: {creatures: creatureId},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default moveCreatureToFolder;
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import CreatureFolders from '/imports/api/creature/creatureFolders/CreatureFolders.js';
|
||||||
|
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
||||||
|
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
||||||
|
|
||||||
|
const removeCreatureFolder = new ValidatedMethod({
|
||||||
|
name: 'creatureFolders.methods.remove',
|
||||||
|
validate: null,
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
|
run({_id}) {
|
||||||
|
// Ensure logged in
|
||||||
|
let userId = this.userId;
|
||||||
|
if (!userId) {
|
||||||
|
throw new Meteor.Error('creatureFolders.methods.updateName.denied',
|
||||||
|
'You need to be logged in to remove a folder');
|
||||||
|
}
|
||||||
|
// Check that this folder is owned by the user
|
||||||
|
let existingFolder = CreatureFolders.findOne(_id);
|
||||||
|
if (existingFolder.owner !== userId){
|
||||||
|
throw new Meteor.Error('creatureFolders.methods.updateName.denied',
|
||||||
|
'This folder does not belong to you');
|
||||||
|
}
|
||||||
|
// Remove
|
||||||
|
return CreatureFolders.remove(_id);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default removeCreatureFolder;
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
import CreatureFolders from '/imports/api/creature/creatureFolders/CreatureFolders.js';
|
||||||
|
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
||||||
|
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
||||||
|
|
||||||
|
const reorderCreatureFolder = new ValidatedMethod({
|
||||||
|
name: 'creatureFolders.methods.reorder',
|
||||||
|
validate: null,
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
|
run({_id, order}) {
|
||||||
|
// Ensure logged in
|
||||||
|
let userId = this.userId;
|
||||||
|
if (!userId) {
|
||||||
|
throw new Meteor.Error('creatureFolders.methods.reorder.denied',
|
||||||
|
'You need to be logged in to reorder a folder');
|
||||||
|
}
|
||||||
|
// Check that this folder is owned by the user
|
||||||
|
let existingFolder = CreatureFolders.findOne(_id);
|
||||||
|
if (existingFolder.owner !== userId){
|
||||||
|
throw new Meteor.Error('creatureFolders.methods.reorder.denied',
|
||||||
|
'This folder does not belong to you');
|
||||||
|
}
|
||||||
|
// First give it the new order, it should end in 0.5 putting it between two other docs
|
||||||
|
CreatureFolders.update(_id, {$set: {order}});
|
||||||
|
this.unblock();
|
||||||
|
// Reorder all the folders with integer numbers in this new order
|
||||||
|
CreatureFolders.find({
|
||||||
|
owner: userId
|
||||||
|
}, {
|
||||||
|
fields: {order: 1,},
|
||||||
|
sort: {order: -1}
|
||||||
|
}).forEach((folder, index) => {
|
||||||
|
if (folder.order !== index){
|
||||||
|
CreatureFolders.update(_id, {$set: {order: index}})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default reorderCreatureFolder;
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
import CreatureFolders from '/imports/api/creature/creatureFolders/CreatureFolders.js';
|
||||||
|
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
||||||
|
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
||||||
|
|
||||||
|
const updateCreatureFolderName = new ValidatedMethod({
|
||||||
|
name: 'creatureFolders.methods.updateName',
|
||||||
|
validate: null,
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
|
run({_id, name}) {
|
||||||
|
// Ensure logged in
|
||||||
|
let userId = this.userId;
|
||||||
|
if (!userId) {
|
||||||
|
throw new Meteor.Error('creatureFolders.methods.updateName.denied',
|
||||||
|
'You need to be logged in to update a folder');
|
||||||
|
}
|
||||||
|
// Check that this folder is owned by the user
|
||||||
|
let existingFolder = CreatureFolders.findOne(_id);
|
||||||
|
if (existingFolder.owner !== userId){
|
||||||
|
throw new Meteor.Error('creatureFolders.methods.updateName.denied',
|
||||||
|
'This folder does not belong to you');
|
||||||
|
}
|
||||||
|
// Update
|
||||||
|
return CreatureFolders.update(_id, {$set: {name}});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default updateCreatureFolderName;
|
||||||
@@ -5,6 +5,7 @@ import ChildSchema from '/imports/api/parenting/ChildSchema.js';
|
|||||||
import SoftRemovableSchema from '/imports/api/parenting/SoftRemovableSchema.js';
|
import SoftRemovableSchema from '/imports/api/parenting/SoftRemovableSchema.js';
|
||||||
import propertySchemasIndex from '/imports/api/properties/computedPropertySchemasIndex.js';
|
import propertySchemasIndex from '/imports/api/properties/computedPropertySchemasIndex.js';
|
||||||
import { storedIconsSchema } from '/imports/api/icons/Icons.js';
|
import { storedIconsSchema } from '/imports/api/icons/Icons.js';
|
||||||
|
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||||
|
|
||||||
let CreatureProperties = new Mongo.Collection('creatureProperties');
|
let CreatureProperties = new Mongo.Collection('creatureProperties');
|
||||||
|
|
||||||
@@ -16,9 +17,11 @@ let CreaturePropertySchema = new SimpleSchema({
|
|||||||
tags: {
|
tags: {
|
||||||
type: Array,
|
type: Array,
|
||||||
defaultValue: [],
|
defaultValue: [],
|
||||||
|
maxCount: STORAGE_LIMITS.tagCount,
|
||||||
},
|
},
|
||||||
'tags.$': {
|
'tags.$': {
|
||||||
type: String,
|
type: String,
|
||||||
|
max: STORAGE_LIMITS.tagLength,
|
||||||
},
|
},
|
||||||
disabled: {
|
disabled: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
@@ -27,6 +30,13 @@ let CreaturePropertySchema = new SimpleSchema({
|
|||||||
icon: {
|
icon: {
|
||||||
type: storedIconsSchema,
|
type: storedIconsSchema,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.icon,
|
||||||
|
},
|
||||||
|
// Reference to the library node that this property was copied from
|
||||||
|
libraryNodeId: {
|
||||||
|
type: String,
|
||||||
|
regEx: SimpleSchema.RegEx.Id,
|
||||||
|
optional: true,
|
||||||
},
|
},
|
||||||
// Denormalised flag if this property is inactive on the sheet for any reason
|
// Denormalised flag if this property is inactive on the sheet for any reason
|
||||||
// Including being disabled, or a decendent of a disabled property
|
// Including being disabled, or a decendent of a disabled property
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import Creatures from '/imports/api/creature/Creatures.js';
|
import Creatures from '/imports/api/creature/creatures/Creatures.js';
|
||||||
|
|
||||||
export default function getRootCreatureAncestor(property){
|
export default function getRootCreatureAncestor(property){
|
||||||
return Creatures.findOne(property.ancestors[0].id);
|
return Creatures.findOne(property.ancestors[0].id);
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
|||||||
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
|
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
|
||||||
import Creatures from '/imports/api/creature/Creatures.js';
|
import Creatures from '/imports/api/creature/creatures/Creatures.js';
|
||||||
import { assertEditPermission } from '/imports/api/sharing/sharingPermissions.js';
|
import { assertEditPermission } from '/imports/api/sharing/sharingPermissions.js';
|
||||||
import { damagePropertyWork } from '/imports/api/creature/creatureProperties/methods/damageProperty.js';
|
import { damagePropertyWork } from '/imports/api/creature/creatureProperties/methods/damageProperty.js';
|
||||||
import { recomputePropertyDependencies } from '/imports/api/creature/computation/methods/recomputeCreature.js';
|
import { recomputePropertyDependencies } from '/imports/api/creature/computation/methods/recomputeCreature.js';
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
|||||||
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
|
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
|
||||||
import Creatures from '/imports/api/creature/Creatures.js';
|
import Creatures from '/imports/api/creature/creatures/Creatures.js';
|
||||||
import { assertEditPermission } from '/imports/api/sharing/sharingPermissions.js';
|
import { assertEditPermission } from '/imports/api/sharing/sharingPermissions.js';
|
||||||
import { damagePropertyWork } from '/imports/api/creature/creatureProperties/methods/damageProperty.js';
|
import { damagePropertyWork } from '/imports/api/creature/creatureProperties/methods/damageProperty.js';
|
||||||
import { recomputeCreatureByDependencies } from '/imports/api/creature/computation/methods/recomputeCreature.js';
|
import { recomputeCreatureByDependencies } from '/imports/api/creature/computation/methods/recomputeCreature.js';
|
||||||
|
|||||||
@@ -0,0 +1,44 @@
|
|||||||
|
export default function getSlotFillFilter({slot, libraryIds}){
|
||||||
|
let filter = {
|
||||||
|
removed: {$ne: true},
|
||||||
|
$and: []
|
||||||
|
};
|
||||||
|
if (libraryIds){
|
||||||
|
filter['ancestors.id'] = {$in: libraryIds};
|
||||||
|
}
|
||||||
|
if (slot.slotType){
|
||||||
|
filter.$and.push({
|
||||||
|
$or: [{
|
||||||
|
type: slot.slotType
|
||||||
|
},{
|
||||||
|
type: 'slotFiller',
|
||||||
|
slotFillerType: slot.slotType,
|
||||||
|
}]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
let tagsOr = [];
|
||||||
|
let tagsNor = [];
|
||||||
|
if (slot.slotTags && slot.slotTags.length){
|
||||||
|
tagsOr.push({tags: {$all: slot.slotTags}});
|
||||||
|
}
|
||||||
|
if (slot.extraTags && slot.extraTags.length){
|
||||||
|
slot.extraTags.forEach(extra => {
|
||||||
|
if (!extra.tags || !extra.tags.length) return;
|
||||||
|
if (extra.operation === 'OR'){
|
||||||
|
tagsOr.push({tags: {$all: extra.tags}});
|
||||||
|
} else if (extra.operation === 'NOT'){
|
||||||
|
tagsNor.push({tags: {$all: extra.tags}});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (tagsOr.length){
|
||||||
|
filter.$and.push({$or: tagsOr});
|
||||||
|
}
|
||||||
|
if (tagsNor.length){
|
||||||
|
filter.$and.push({$nor: tagsNor});
|
||||||
|
}
|
||||||
|
if (!filter.$and.length){
|
||||||
|
delete filter.$and;
|
||||||
|
}
|
||||||
|
return filter;
|
||||||
|
}
|
||||||
@@ -16,11 +16,16 @@ import {
|
|||||||
import { reorderDocs } from '/imports/api/parenting/order.js';
|
import { reorderDocs } from '/imports/api/parenting/order.js';
|
||||||
import { setDocToLastOrder } from '/imports/api/parenting/order.js';
|
import { setDocToLastOrder } from '/imports/api/parenting/order.js';
|
||||||
import recomputeInventory from '/imports/api/creature/denormalise/recomputeInventory.js';
|
import recomputeInventory from '/imports/api/creature/denormalise/recomputeInventory.js';
|
||||||
|
import fetchDocByRef from '/imports/api/parenting/fetchDocByRef.js';
|
||||||
|
|
||||||
const insertPropertyFromLibraryNode = new ValidatedMethod({
|
const insertPropertyFromLibraryNode = new ValidatedMethod({
|
||||||
name: 'creatureProperties.insertPropertyFromLibraryNode',
|
name: 'creatureProperties.insertPropertyFromLibraryNode',
|
||||||
validate: new SimpleSchema({
|
validate: new SimpleSchema({
|
||||||
nodeId: {
|
nodeIds: {
|
||||||
|
type: Array,
|
||||||
|
max: 20,
|
||||||
|
},
|
||||||
|
'nodeIds.$': {
|
||||||
type: String,
|
type: String,
|
||||||
regEx: SimpleSchema.RegEx.Id,
|
regEx: SimpleSchema.RegEx.Id,
|
||||||
},
|
},
|
||||||
@@ -37,7 +42,7 @@ const insertPropertyFromLibraryNode = new ValidatedMethod({
|
|||||||
numRequests: 5,
|
numRequests: 5,
|
||||||
timeInterval: 5000,
|
timeInterval: 5000,
|
||||||
},
|
},
|
||||||
run({nodeId, parentRef, order}) {
|
run({nodeIds, parentRef, order}) {
|
||||||
// get the new ancestry for the properties
|
// get the new ancestry for the properties
|
||||||
let {parentDoc, ancestors} = getAncestry({parentRef});
|
let {parentDoc, ancestors} = getAncestry({parentRef});
|
||||||
|
|
||||||
@@ -52,50 +57,15 @@ const insertPropertyFromLibraryNode = new ValidatedMethod({
|
|||||||
}
|
}
|
||||||
assertEditPermission(rootCreature, this.userId);
|
assertEditPermission(rootCreature, this.userId);
|
||||||
|
|
||||||
// Fetch the library node and its decendents, provided they have not been
|
// {libraryId: hasViewPermission}
|
||||||
// removed
|
//let libraryPermissionMemoir = {};
|
||||||
let node = LibraryNodes.findOne({
|
let node;
|
||||||
_id: nodeId,
|
nodeIds.forEach(nodeId => {
|
||||||
removed: {$ne: true},
|
// TODO: Check library view permission for each node before starting
|
||||||
});
|
node = insertPropertyFromNode(nodeId, ancestors, order);
|
||||||
if (!node) throw `Node not found for nodeId: ${nodeId}`;
|
});
|
||||||
let oldParent = node.parent;
|
|
||||||
let nodes = LibraryNodes.find({
|
|
||||||
'ancestors.id': nodeId,
|
|
||||||
removed: {$ne: true},
|
|
||||||
}).fetch();
|
|
||||||
|
|
||||||
// The root node is first in the array of nodes
|
// get one of the root inserted docs
|
||||||
// It must get the first generated ID to prevent flickering
|
|
||||||
nodes = [node, ...nodes];
|
|
||||||
|
|
||||||
// re-map all the ancestors
|
|
||||||
setLineageOfDocs({
|
|
||||||
docArray: nodes,
|
|
||||||
newAncestry: ancestors,
|
|
||||||
oldParent,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Give the docs new IDs without breaking internal references
|
|
||||||
renewDocIds({
|
|
||||||
docArray: nodes,
|
|
||||||
collectionMap: {'libraryNodes': 'creatureProperties'}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Order the root node
|
|
||||||
if (order === undefined){
|
|
||||||
setDocToLastOrder({
|
|
||||||
collection: CreatureProperties,
|
|
||||||
doc: node,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
node.order = order;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Insert the creature properties
|
|
||||||
CreatureProperties.batchInsert(nodes);
|
|
||||||
|
|
||||||
// get the root inserted doc
|
|
||||||
let rootId = node._id;
|
let rootId = node._id;
|
||||||
|
|
||||||
// Tree structure changed by inserts, reorder the tree
|
// Tree structure changed by inserts, reorder the tree
|
||||||
@@ -105,7 +75,7 @@ const insertPropertyFromLibraryNode = new ValidatedMethod({
|
|||||||
});
|
});
|
||||||
|
|
||||||
// The library properties need to denormalise which of them are inactive
|
// The library properties need to denormalise which of them are inactive
|
||||||
recomputeInactiveProperties(rootId);
|
recomputeInactiveProperties(rootCreature._id);
|
||||||
// Some of the library properties may be items or containers
|
// Some of the library properties may be items or containers
|
||||||
recomputeInventory(rootCreature._id);
|
recomputeInventory(rootCreature._id);
|
||||||
// Inserting a creature property invalidates dependencies: full recompute
|
// Inserting a creature property invalidates dependencies: full recompute
|
||||||
@@ -115,4 +85,166 @@ const insertPropertyFromLibraryNode = new ValidatedMethod({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function insertPropertyFromNode(nodeId, ancestors, order){
|
||||||
|
// Fetch the library node and its decendents, provided they have not been
|
||||||
|
// removed
|
||||||
|
// TODO: Check permission to read the library this node is in
|
||||||
|
let node = LibraryNodes.findOne({
|
||||||
|
_id: nodeId,
|
||||||
|
removed: {$ne: true},
|
||||||
|
});
|
||||||
|
if (!node) {
|
||||||
|
if (Meteor.isClient) return;
|
||||||
|
else {
|
||||||
|
throw new Meteor.Error(
|
||||||
|
'Insert property from library failed',
|
||||||
|
`No library document with id '${nodeId}' was found`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let oldParent = node.parent;
|
||||||
|
let nodes = LibraryNodes.find({
|
||||||
|
'ancestors.id': nodeId,
|
||||||
|
removed: {$ne: true},
|
||||||
|
}).fetch();
|
||||||
|
|
||||||
|
// Convert all references into actual nodes
|
||||||
|
nodes = reifyNodeReferences(nodes);
|
||||||
|
|
||||||
|
// The root node is first in the array of nodes
|
||||||
|
// It must get the first generated ID to prevent flickering
|
||||||
|
nodes = [node, ...nodes];
|
||||||
|
|
||||||
|
// set libraryNodeIds
|
||||||
|
storeLibraryNodeReferences(nodes, nodeId);
|
||||||
|
|
||||||
|
// re-map all the ancestors
|
||||||
|
setLineageOfDocs({
|
||||||
|
docArray: nodes,
|
||||||
|
newAncestry: ancestors,
|
||||||
|
oldParent,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Give the docs new IDs without breaking internal references
|
||||||
|
renewDocIds({
|
||||||
|
docArray: nodes,
|
||||||
|
collectionMap: {'libraryNodes': 'creatureProperties'}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Order the root node
|
||||||
|
if (order === undefined){
|
||||||
|
setDocToLastOrder({
|
||||||
|
collection: CreatureProperties,
|
||||||
|
doc: node,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
node.order = order;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Insert the creature properties
|
||||||
|
CreatureProperties.batchInsert(nodes);
|
||||||
|
return node;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function storeLibraryNodeReferences(nodes){
|
||||||
|
nodes.forEach(node => {
|
||||||
|
node.libraryNodeId = node._id;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Covert node references into actual nodes
|
||||||
|
// TODO: check permissions for each library a reference node references
|
||||||
|
function reifyNodeReferences(nodes, visitedRefs = new Set(), depth = 0){
|
||||||
|
depth += 1;
|
||||||
|
// New nodes added this function
|
||||||
|
let newNodes = [];
|
||||||
|
|
||||||
|
// Filter out the reference nodes we replace
|
||||||
|
let resultingNodes = nodes.filter(node => {
|
||||||
|
|
||||||
|
// We have already visited this ref and replaced it
|
||||||
|
if (visitedRefs.has(node._id)) return false;
|
||||||
|
|
||||||
|
// Already replaced an ancestor node
|
||||||
|
for (let i; i < node.ancestors.length; i++){
|
||||||
|
if (visitedRefs.has(node.ancestors[i].id)) return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This isn't a reference node, continue as normal
|
||||||
|
if (node.type !== 'reference') return true;
|
||||||
|
|
||||||
|
// We have gone too deep, keep the reference node as an error
|
||||||
|
if (depth > 10){
|
||||||
|
if (Meteor.isClient) console.warn('Reference depth limit exceeded');
|
||||||
|
node.cache = {error: 'Reference depth limit exceeded'};
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
let referencedNode
|
||||||
|
try {
|
||||||
|
referencedNode = fetchDocByRef(node.ref);
|
||||||
|
referencedNode.order = node.order;
|
||||||
|
// We are definitely replacing this node, so add it to the list
|
||||||
|
visitedRefs.add(node._id);
|
||||||
|
} catch (e){
|
||||||
|
node.cache = {error: e.reason || e.message || e.toString()};
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get all the descendants of the referenced node
|
||||||
|
let descendents = LibraryNodes.find({
|
||||||
|
'ancestors.id': referencedNode._id,
|
||||||
|
removed: {$ne: true},
|
||||||
|
}, {
|
||||||
|
sort: {order: 1},
|
||||||
|
}).fetch();
|
||||||
|
|
||||||
|
// We are adding the referenced node and its descendants
|
||||||
|
let addedNodes = [referencedNode, ...descendents];
|
||||||
|
|
||||||
|
// re-map all the ancestors to parent the new sub-tree into our existing
|
||||||
|
// node tree
|
||||||
|
setLineageOfDocs({
|
||||||
|
docArray: addedNodes,
|
||||||
|
newAncestry: node.ancestors,
|
||||||
|
oldParent: referencedNode.parent,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Remove all the looped references and descendents from the new nodes
|
||||||
|
// We can't rely on the reify recursion to do this, since the IDs are
|
||||||
|
// getting renewed before it is called
|
||||||
|
addedNodes = addedNodes.filter(node => {
|
||||||
|
// Exclude removed referenced
|
||||||
|
if (visitedRefs.has(node._id)) return false;
|
||||||
|
|
||||||
|
// Exclude descendants of removed references
|
||||||
|
for (let i; i < node.ancestors.length; i++){
|
||||||
|
if (visitedRefs.has(node.ancestors[i].id)) return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
// TODO: Force the referencedNode to take the old id of the reference
|
||||||
|
// such that the reference's children can be kept
|
||||||
|
|
||||||
|
// Give the new referenced sub-tree new ids
|
||||||
|
renewDocIds({
|
||||||
|
docArray: addedNodes,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Reify the subtree as well with recursion
|
||||||
|
addedNodes = reifyNodeReferences(addedNodes, visitedRefs, depth);
|
||||||
|
|
||||||
|
// Store the new nodes from this inner loop without altering the array
|
||||||
|
// we are looping over
|
||||||
|
newNodes.push(...addedNodes);
|
||||||
|
});
|
||||||
|
|
||||||
|
// We are done filtering the array, we can add the new nodes to it
|
||||||
|
resultingNodes.push(...newNodes);
|
||||||
|
|
||||||
|
return resultingNodes;
|
||||||
|
}
|
||||||
|
|
||||||
export default insertPropertyFromLibraryNode;
|
export default insertPropertyFromLibraryNode;
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import CreatureProperties from '/imports/api/creature/creatureProperties/Creatur
|
|||||||
import { assertEditPermission } from '/imports/api/sharing/sharingPermissions.js';
|
import { assertEditPermission } from '/imports/api/sharing/sharingPermissions.js';
|
||||||
import getRootCreatureAncestor from '/imports/api/creature/creatureProperties/getRootCreatureAncestor.js';
|
import getRootCreatureAncestor from '/imports/api/creature/creatureProperties/getRootCreatureAncestor.js';
|
||||||
import { recomputeCreatureByDoc } from '/imports/api/creature/computation/methods/recomputeCreature.js';
|
import { recomputeCreatureByDoc } from '/imports/api/creature/computation/methods/recomputeCreature.js';
|
||||||
|
import { get } from 'lodash';
|
||||||
|
|
||||||
const pushToProperty = new ValidatedMethod({
|
const pushToProperty = new ValidatedMethod({
|
||||||
name: 'creatureProperties.push',
|
name: 'creatureProperties.push',
|
||||||
@@ -19,9 +20,26 @@ const pushToProperty = new ValidatedMethod({
|
|||||||
let rootCreature = getRootCreatureAncestor(property);
|
let rootCreature = getRootCreatureAncestor(property);
|
||||||
assertEditPermission(rootCreature, this.userId);
|
assertEditPermission(rootCreature, this.userId);
|
||||||
|
|
||||||
|
let joinedPath = path.join('.');
|
||||||
|
|
||||||
|
// Respect maxCount
|
||||||
|
let schema = CreatureProperties.simpleSchema(property);
|
||||||
|
let maxCount = schema.get(joinedPath, 'maxCount');
|
||||||
|
|
||||||
|
if (Number.isFinite(maxCount)){
|
||||||
|
let array = get(property, path);
|
||||||
|
let currentCount = array ? array.length : 0;
|
||||||
|
if (currentCount >= maxCount){
|
||||||
|
throw new Meteor.Error(
|
||||||
|
'Array is full',
|
||||||
|
`Cannot have more than ${maxCount} values`
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Do work
|
// Do work
|
||||||
CreatureProperties.update(_id, {
|
CreatureProperties.update(_id, {
|
||||||
$push: {[path.join('.')]: value},
|
$push: {[joinedPath]: value},
|
||||||
}, {
|
}, {
|
||||||
selector: {type: property.type},
|
selector: {type: property.type},
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,16 +1,8 @@
|
|||||||
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';
|
||||||
import SharingSchema from '/imports/api/sharing/SharingSchema.js';
|
import SharingSchema from '/imports/api/sharing/SharingSchema.js';
|
||||||
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
|
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||||
import {assertEditPermission} from '/imports/api/sharing/sharingPermissions.js';
|
|
||||||
import { assertUserHasPaidBenefits } from '/imports/api/users/patreon/tiers.js';
|
|
||||||
import defaultCharacterProperties from '/imports/api/creature/defaultCharacterProperties.js';
|
|
||||||
import insertPropertyFromLibraryNode from '/imports/api/creature/creatureProperties/methods/insertPropertyFromLibraryNode.js';
|
|
||||||
import '/imports/api/creature/removeCreature.js';
|
|
||||||
import '/imports/api/creature/restCreature.js';
|
|
||||||
|
|
||||||
//set up the collection for creatures
|
//set up the collection for creatures
|
||||||
let Creatures = new Mongo.Collection('creatures');
|
let Creatures = new Mongo.Collection('creatures');
|
||||||
@@ -56,7 +48,7 @@ let CreatureSettingsSchema = new SimpleSchema({
|
|||||||
discordWebhook: {
|
discordWebhook: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
max: 200,
|
max: STORAGE_LIMITS.url,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -66,22 +58,27 @@ let CreatureSchema = new SimpleSchema({
|
|||||||
type: String,
|
type: String,
|
||||||
defaultValue: '',
|
defaultValue: '',
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
},
|
},
|
||||||
alignment: {
|
alignment: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
},
|
},
|
||||||
gender: {
|
gender: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
},
|
},
|
||||||
picture: {
|
picture: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.url,
|
||||||
},
|
},
|
||||||
avatarPicture: {
|
avatarPicture: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.url,
|
||||||
},
|
},
|
||||||
// Mechanics
|
// Mechanics
|
||||||
deathSave: {
|
deathSave: {
|
||||||
@@ -176,92 +173,8 @@ CreatureSchema.extend(SharingSchema);
|
|||||||
|
|
||||||
Creatures.attachSchema(CreatureSchema);
|
Creatures.attachSchema(CreatureSchema);
|
||||||
|
|
||||||
const insertCreature = new ValidatedMethod({
|
|
||||||
|
|
||||||
name: 'creatures.insertCreature',
|
import '/imports/api/creature/creatures/methods/index.js';
|
||||||
|
|
||||||
validate: null,
|
|
||||||
|
|
||||||
mixins: [RateLimiterMixin],
|
|
||||||
rateLimit: {
|
|
||||||
numRequests: 5,
|
|
||||||
timeInterval: 5000,
|
|
||||||
},
|
|
||||||
|
|
||||||
run() {
|
|
||||||
if (!this.userId) {
|
|
||||||
throw new Meteor.Error('Creatures.methods.insert.denied',
|
|
||||||
'You need to be logged in to insert a creature');
|
|
||||||
}
|
|
||||||
assertUserHasPaidBenefits(this.userId);
|
|
||||||
|
|
||||||
// Create the creature document
|
|
||||||
let creatureId = Creatures.insert({
|
|
||||||
owner: this.userId,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Insert the default properties
|
|
||||||
// Not batchInsert because we want the properties cleaned by the schema
|
|
||||||
let baseId;
|
|
||||||
defaultCharacterProperties(creatureId).forEach(prop => {
|
|
||||||
let id = CreatureProperties.insert(prop);
|
|
||||||
if (prop.name === 'Ruleset'){
|
|
||||||
baseId = id;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (Meteor.isServer){
|
|
||||||
// Insert the 5e ruleset as the default base
|
|
||||||
insertPropertyFromLibraryNode.call({
|
|
||||||
nodeId: 'iHbhfcg3AL5isSWbw',
|
|
||||||
parentRef: {id: baseId, collection: 'creatureProperties'},
|
|
||||||
order: 0.5,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
this.unblock();
|
|
||||||
return creatureId;
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const updateCreature = new ValidatedMethod({
|
|
||||||
name: 'creatures.update',
|
|
||||||
validate({_id, path}){
|
|
||||||
if (!_id) return false;
|
|
||||||
// Allowed fields
|
|
||||||
let allowedFields = [
|
|
||||||
'name',
|
|
||||||
'alignment',
|
|
||||||
'gender',
|
|
||||||
'picture',
|
|
||||||
'avatarPicture',
|
|
||||||
'color',
|
|
||||||
'settings',
|
|
||||||
];
|
|
||||||
if (!allowedFields.includes(path[0])){
|
|
||||||
throw new Meteor.Error('Creatures.methods.update.denied',
|
|
||||||
'This field can\'t be updated using this method');
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mixins: [RateLimiterMixin],
|
|
||||||
rateLimit: {
|
|
||||||
numRequests: 5,
|
|
||||||
timeInterval: 5000,
|
|
||||||
},
|
|
||||||
run({_id, path, value}) {
|
|
||||||
let creature = Creatures.findOne(_id);
|
|
||||||
assertEditPermission(creature, this.userId);
|
|
||||||
if (value === undefined || value === null){
|
|
||||||
Creatures.update(_id, {
|
|
||||||
$unset: {[path.join('.')]: 1},
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
Creatures.update(_id, {
|
|
||||||
$set: {[path.join('.')]: value},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
export default Creatures;
|
export default Creatures;
|
||||||
export { CreatureSchema, insertCreature, updateCreature };
|
export { CreatureSchema };
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
import Creatures from '/imports/api/creature/Creatures.js';
|
import Creatures from '/imports/api/creature/creatures/Creatures.js';
|
||||||
import {
|
import {
|
||||||
assertEditPermission as editPermission,
|
assertEditPermission as editPermission,
|
||||||
assertViewPermission as viewPermission,
|
assertViewPermission as viewPermission,
|
||||||
5
app/imports/api/creature/creatures/getCreatureUrlName.js
Normal file
5
app/imports/api/creature/creatures/getCreatureUrlName.js
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
import getSlug from 'speakingurl';
|
||||||
|
|
||||||
|
export default function getCreatureUrlName({name}){
|
||||||
|
return getSlug(name, {maintainCase: true}) || '-';
|
||||||
|
}
|
||||||
4
app/imports/api/creature/creatures/methods/index.js
Normal file
4
app/imports/api/creature/creatures/methods/index.js
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
import '/imports/api/creature/creatures/methods/insertCreature.js';
|
||||||
|
import '/imports/api/creature/creatures/methods/removeCreature.js';
|
||||||
|
import '/imports/api/creature/creatures/methods/restCreature.js';
|
||||||
|
import '/imports/api/creature/creatures/methods/updateCreature.js';
|
||||||
70
app/imports/api/creature/creatures/methods/insertCreature.js
Normal file
70
app/imports/api/creature/creatures/methods/insertCreature.js
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
||||||
|
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
||||||
|
import Creatures from '/imports/api/creature/creatures/Creatures.js';
|
||||||
|
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
|
||||||
|
import { getUserTier } from '/imports/api/users/patreon/tiers.js';
|
||||||
|
import defaultCharacterProperties from '/imports/api/creature/creatures/defaultCharacterProperties.js';
|
||||||
|
import insertPropertyFromLibraryNode from '/imports/api/creature/creatureProperties/methods/insertPropertyFromLibraryNode.js';
|
||||||
|
|
||||||
|
const insertCreature = new ValidatedMethod({
|
||||||
|
|
||||||
|
name: 'creatures.insertCreature',
|
||||||
|
|
||||||
|
validate: null,
|
||||||
|
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
|
|
||||||
|
run() {
|
||||||
|
if (!this.userId) {
|
||||||
|
throw new Meteor.Error('Creatures.methods.insert.denied',
|
||||||
|
'You need to be logged in to insert a creature');
|
||||||
|
}
|
||||||
|
let tier = getUserTier(this.userId);
|
||||||
|
|
||||||
|
let currentCharacterCount = Creatures.find({
|
||||||
|
owner: this.userId,
|
||||||
|
}, {
|
||||||
|
fields: {_id: 1},
|
||||||
|
}).count();
|
||||||
|
|
||||||
|
if (
|
||||||
|
tier.characterSlots !== -1 &&
|
||||||
|
currentCharacterCount >= tier.characterSlots
|
||||||
|
){
|
||||||
|
throw new Meteor.Error('Creatures.methods.insert.denied',
|
||||||
|
`You are already at your limit of ${tier.characterSlots} characters`)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the creature document
|
||||||
|
let creatureId = Creatures.insert({
|
||||||
|
owner: this.userId,
|
||||||
|
});
|
||||||
|
|
||||||
|
// Insert the default properties
|
||||||
|
// Not batchInsert because we want the properties cleaned by the schema
|
||||||
|
let baseId;
|
||||||
|
defaultCharacterProperties(creatureId).forEach(prop => {
|
||||||
|
let id = CreatureProperties.insert(prop);
|
||||||
|
if (prop.name === 'Ruleset'){
|
||||||
|
baseId = id;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (Meteor.isServer){
|
||||||
|
// Insert the 5e ruleset as the default base
|
||||||
|
insertPropertyFromLibraryNode.call({
|
||||||
|
nodeIds: ['iHbhfcg3AL5isSWbw'],
|
||||||
|
parentRef: {id: baseId, collection: 'creatureProperties'},
|
||||||
|
order: 0.5,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return creatureId;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default insertCreature;
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
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 { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
||||||
import { assertOwnership } from '/imports/api/creature/creaturePermissions.js';
|
import { assertOwnership } from '/imports/api/creature/creatures/creaturePermissions.js';
|
||||||
import Creatures from '/imports/api/creature/Creatures.js';
|
import Creatures from '/imports/api/creature/creatures/Creatures.js';
|
||||||
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
|
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
|
||||||
import CreatureLogs from '/imports/api/creature/log/CreatureLogs.js';
|
import CreatureLogs from '/imports/api/creature/log/CreatureLogs.js';
|
||||||
import Experiences from '/imports/api/creature/experience/Experiences.js';
|
import Experiences from '/imports/api/creature/experience/Experiences.js';
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
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 { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
||||||
import Creatures from '/imports/api/creature/Creatures.js';
|
import Creatures from '/imports/api/creature/creatures/Creatures.js';
|
||||||
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
|
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
|
||||||
import { assertEditPermission } from '/imports/api/creature/creaturePermissions.js';
|
import { assertEditPermission } from '/imports/api/creature/creatures/creaturePermissions.js';
|
||||||
import { recomputeCreatureById } from '/imports/api/creature/computation/methods/recomputeCreature.js';
|
import { recomputeCreatureById } from '/imports/api/creature/computation/methods/recomputeCreature.js';
|
||||||
|
|
||||||
const restCreature = new ValidatedMethod({
|
const restCreature = new ValidatedMethod({
|
||||||
45
app/imports/api/creature/creatures/methods/updateCreature.js
Normal file
45
app/imports/api/creature/creatures/methods/updateCreature.js
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
||||||
|
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
||||||
|
import Creatures from '/imports/api/creature/creatures/Creatures.js';
|
||||||
|
import {assertEditPermission} from '/imports/api/sharing/sharingPermissions.js';
|
||||||
|
|
||||||
|
const updateCreature = new ValidatedMethod({
|
||||||
|
name: 'creatures.update',
|
||||||
|
validate({_id, path}){
|
||||||
|
if (!_id) return false;
|
||||||
|
// Allowed fields
|
||||||
|
let allowedFields = [
|
||||||
|
'name',
|
||||||
|
'alignment',
|
||||||
|
'gender',
|
||||||
|
'picture',
|
||||||
|
'avatarPicture',
|
||||||
|
'color',
|
||||||
|
'settings',
|
||||||
|
];
|
||||||
|
if (!allowedFields.includes(path[0])){
|
||||||
|
throw new Meteor.Error('Creatures.methods.update.denied',
|
||||||
|
'This field can\'t be updated using this method');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
|
run({_id, path, value}) {
|
||||||
|
let creature = Creatures.findOne(_id);
|
||||||
|
assertEditPermission(creature, this.userId);
|
||||||
|
if (value === undefined || value === null){
|
||||||
|
Creatures.update(_id, {
|
||||||
|
$unset: {[path.join('.')]: 1},
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Creatures.update(_id, {
|
||||||
|
$set: {[path.join('.')]: value},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export default updateCreature;
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
||||||
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
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/creatures/creaturePermissions.js';
|
||||||
import Creatures from '/imports/api/creature/Creatures.js';
|
import Creatures from '/imports/api/creature/creatures/Creatures.js';
|
||||||
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
|
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
|
||||||
|
|
||||||
export const recomputeDamageMultipliers = new ValidatedMethod({
|
export const recomputeDamageMultipliers = new ValidatedMethod({
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
|
import CreatureProperties from '/imports/api/creature/creatureProperties/CreatureProperties.js';
|
||||||
import Creatures from '/imports/api/creature/Creatures.js';
|
import Creatures from '/imports/api/creature/creatures/Creatures.js';
|
||||||
import { nodesToTree } from '/imports/api/parenting/parenting.js';
|
import nodesToTree from '/imports/api/parenting/nodesToTree.js';
|
||||||
|
|
||||||
export default function recomputeInventory(creatureId){
|
export default function recomputeInventory(creatureId){
|
||||||
let inventoryForest = nodesToTree({
|
let inventoryForest = nodesToTree({
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
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 { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
||||||
import { getUserTier } from '/imports/api/users/patreon/tiers.js';
|
import { assertEditPermission } from '/imports/api/creature/creatures/creaturePermissions.js';
|
||||||
import { assertEditPermission } from '/imports/api/creature/creaturePermissions.js';
|
import Creatures from '/imports/api/creature/creatures/Creatures.js';
|
||||||
import Creatures from '/imports/api/creature/Creatures.js';
|
|
||||||
import { recomputeCreatureById } from '/imports/api/creature/computation/methods/recomputeCreature.js';
|
import { recomputeCreatureById } from '/imports/api/creature/computation/methods/recomputeCreature.js';
|
||||||
|
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||||
|
|
||||||
let Experiences = new Mongo.Collection('experiences');
|
let Experiences = new Mongo.Collection('experiences');
|
||||||
|
|
||||||
@@ -12,6 +12,7 @@ let ExperienceSchema = new SimpleSchema({
|
|||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
},
|
},
|
||||||
// The amount of XP this experience gives
|
// The amount of XP this experience gives
|
||||||
xp: {
|
xp: {
|
||||||
@@ -90,11 +91,6 @@ const insertExperience = new ValidatedMethod({
|
|||||||
throw new Meteor.Error('Experiences.methods.insert.denied',
|
throw new Meteor.Error('Experiences.methods.insert.denied',
|
||||||
'You need to be logged in to insert an experience');
|
'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 = [];
|
let insertedIds = [];
|
||||||
creatureIds.forEach(creatureId => {
|
creatureIds.forEach(creatureId => {
|
||||||
let id = insertExperienceForCreature({experience, creatureId, userId});
|
let id = insertExperienceForCreature({experience, creatureId, userId});
|
||||||
@@ -123,11 +119,6 @@ const removeExperience = new ValidatedMethod({
|
|||||||
throw new Meteor.Error('Experiences.methods.remove.denied',
|
throw new Meteor.Error('Experiences.methods.remove.denied',
|
||||||
'You need to be logged in to remove an experience');
|
'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);
|
let experience = Experiences.findOne(experienceId);
|
||||||
if (!experience) return;
|
if (!experience) return;
|
||||||
let creatureId = experience.creatureId
|
let creatureId = experience.creatureId
|
||||||
@@ -168,11 +159,6 @@ const recomputeExperiences = new ValidatedMethod({
|
|||||||
throw new Meteor.Error('Experiences.methods.recompute.denied',
|
throw new Meteor.Error('Experiences.methods.recompute.denied',
|
||||||
'You need to be logged in to recompute a creature\'s experiences');
|
'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);
|
assertEditPermission(creatureId, userId);
|
||||||
|
|
||||||
let xp = 0;
|
let xp = 0;
|
||||||
|
|||||||
@@ -1,14 +1,17 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
|
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||||
|
|
||||||
let ExperienceSchema = new SimpleSchema({
|
let ExperienceSchema = new SimpleSchema({
|
||||||
title: {
|
title: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
},
|
},
|
||||||
// Potentially long description of the event
|
// Potentially long description of the event
|
||||||
description: {
|
description: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.description,
|
||||||
},
|
},
|
||||||
// The real-world date that it occured
|
// The real-world date that it occured
|
||||||
date: {
|
date: {
|
||||||
@@ -24,14 +27,17 @@ let ExperienceSchema = new SimpleSchema({
|
|||||||
worldDate: {
|
worldDate: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
},
|
},
|
||||||
// Tags to better find this entry later
|
// Tags to better find this entry later
|
||||||
tags: {
|
tags: {
|
||||||
type: Array,
|
type: Array,
|
||||||
defaultValue: [],
|
defaultValue: [],
|
||||||
|
maxCount: STORAGE_LIMITS.tagCount,
|
||||||
},
|
},
|
||||||
'tags.$': {
|
'tags.$': {
|
||||||
type: String,
|
type: String,
|
||||||
|
max: STORAGE_LIMITS.tagLength,
|
||||||
},
|
},
|
||||||
// ID of the journal this entry belongs to
|
// ID of the journal this entry belongs to
|
||||||
journalId: {
|
journalId: {
|
||||||
|
|||||||
@@ -1,15 +1,16 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
import Creatures from '/imports/api/creature/Creatures.js';
|
import Creatures from '/imports/api/creature/creatures/Creatures.js';
|
||||||
import LogContentSchema from '/imports/api/creature/log/LogContentSchema.js';
|
import LogContentSchema from '/imports/api/creature/log/LogContentSchema.js';
|
||||||
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
||||||
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
||||||
import {assertEditPermission} from '/imports/api/creature/creaturePermissions.js';
|
import {assertEditPermission} from '/imports/api/creature/creatures/creaturePermissions.js';
|
||||||
import {
|
import {
|
||||||
parse,
|
parse,
|
||||||
CompilationContext,
|
CompilationContext,
|
||||||
prettifyParseError
|
prettifyParseError
|
||||||
} from '/imports/parser/parser.js';
|
} from '/imports/parser/parser.js';
|
||||||
const PER_CREATURE_LOG_LIMIT = 100;
|
const PER_CREATURE_LOG_LIMIT = 100;
|
||||||
|
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||||
|
|
||||||
if (Meteor.isServer){
|
if (Meteor.isServer){
|
||||||
var sendWebhookAsCreature = require('/imports/server/discord/sendWebhook.js').sendWebhookAsCreature;
|
var sendWebhookAsCreature = require('/imports/server/discord/sendWebhook.js').sendWebhookAsCreature;
|
||||||
@@ -21,7 +22,7 @@ let CreatureLogSchema = new SimpleSchema({
|
|||||||
content: {
|
content: {
|
||||||
type: Array,
|
type: Array,
|
||||||
defaultValue: [],
|
defaultValue: [],
|
||||||
maxCount: 25,
|
maxCount: STORAGE_LIMITS.logContentCount,
|
||||||
},
|
},
|
||||||
'content.$': {
|
'content.$': {
|
||||||
type: LogContentSchema,
|
type: LogContentSchema,
|
||||||
@@ -45,6 +46,7 @@ let CreatureLogSchema = new SimpleSchema({
|
|||||||
creatureName: {
|
creatureName: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,21 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
import ErrorSchema from '/imports/api/properties/subSchemas/ErrorSchema.js';
|
import ErrorSchema from '/imports/api/properties/subSchemas/ErrorSchema.js';
|
||||||
import RollDetailsSchema from '/imports/api/properties/subSchemas/RollDetailsSchema.js';
|
import RollDetailsSchema from '/imports/api/properties/subSchemas/RollDetailsSchema.js';
|
||||||
|
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||||
|
|
||||||
let LogContentSchema = new SimpleSchema({
|
let LogContentSchema = new SimpleSchema({
|
||||||
// The name of the field, included in discord webhook message
|
// The name of the field, included in discord webhook message
|
||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
},
|
},
|
||||||
// The details of the field, included in discord webhook message
|
// The details of the field, included in discord webhook message
|
||||||
// Markdown support
|
// Markdown support
|
||||||
value: {
|
value: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.summary,
|
||||||
},
|
},
|
||||||
context: {
|
context: {
|
||||||
type: Object,
|
type: Object,
|
||||||
@@ -21,6 +24,7 @@ let LogContentSchema = new SimpleSchema({
|
|||||||
'context.errors':{
|
'context.errors':{
|
||||||
type: Array,
|
type: Array,
|
||||||
defaultValue: [],
|
defaultValue: [],
|
||||||
|
maxCount: STORAGE_LIMITS.errorCount,
|
||||||
},
|
},
|
||||||
'context.errors.$': {
|
'context.errors.$': {
|
||||||
type: ErrorSchema,
|
type: ErrorSchema,
|
||||||
@@ -28,6 +32,7 @@ let LogContentSchema = new SimpleSchema({
|
|||||||
'context.rolls': {
|
'context.rolls': {
|
||||||
type: Array,
|
type: Array,
|
||||||
defaultValue: [],
|
defaultValue: [],
|
||||||
|
maxCount: STORAGE_LIMITS.rollCount,
|
||||||
},
|
},
|
||||||
'context.rolls.$': {
|
'context.rolls.$': {
|
||||||
type: RollDetailsSchema,
|
type: RollDetailsSchema,
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import {
|
|||||||
assertEditPermission,
|
assertEditPermission,
|
||||||
assertViewPermission,
|
assertViewPermission,
|
||||||
assertOwnership,
|
assertOwnership,
|
||||||
} from '/imports/api/creature/creaturePermissions.js';
|
} from '/imports/api/creature/creatures/creaturePermissions.js';
|
||||||
|
|
||||||
// Checks if the method has permission to run on the document. If the document
|
// Checks if the method has permission to run on the document. If the document
|
||||||
// has a charId, that creature is checked, otherwise if it has an _id and the
|
// has a charId, that creature is checked, otherwise if it has an _id and the
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ 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 { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
||||||
import { assertAdmin } from '/imports/api/sharing/sharingPermissions.js';
|
import { assertAdmin } from '/imports/api/sharing/sharingPermissions.js';
|
||||||
|
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||||
|
|
||||||
let Icons = new Mongo.Collection('icons');
|
let Icons = new Mongo.Collection('icons');
|
||||||
|
|
||||||
@@ -9,22 +10,27 @@ let iconsSchema = new SimpleSchema({
|
|||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
unique: true,
|
unique: true,
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
index: 1,
|
index: 1,
|
||||||
},
|
},
|
||||||
description: {
|
description: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.description,
|
||||||
},
|
},
|
||||||
tags: {
|
tags: {
|
||||||
type: Array,
|
type: Array,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
maxCount: STORAGE_LIMITS.tagCount,
|
||||||
index: 1,
|
index: 1,
|
||||||
},
|
},
|
||||||
'tags.$': {
|
'tags.$': {
|
||||||
type: String,
|
type: String,
|
||||||
|
max: STORAGE_LIMITS.tagLength,
|
||||||
},
|
},
|
||||||
shape: {
|
shape: {
|
||||||
type: String,
|
type: String,
|
||||||
|
max: STORAGE_LIMITS.icon,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import simpleSchemaMixin from '/imports/api/creature/mixins/simpleSchemaMixin.js
|
|||||||
import { assertEditPermission, assertOwnership } from '/imports/api/sharing/sharingPermissions.js';
|
import { assertEditPermission, assertOwnership } from '/imports/api/sharing/sharingPermissions.js';
|
||||||
import LibraryNodes from '/imports/api/library/LibraryNodes.js';
|
import LibraryNodes from '/imports/api/library/LibraryNodes.js';
|
||||||
import { getUserTier } from '/imports/api/users/patreon/tiers.js'
|
import { getUserTier } from '/imports/api/users/patreon/tiers.js'
|
||||||
|
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Libraries are trees of library nodes where each node represents a character
|
* Libraries are trees of library nodes where each node represents a character
|
||||||
@@ -21,11 +22,8 @@ let Libraries = new Mongo.Collection('libraries');
|
|||||||
let LibrarySchema = new SimpleSchema({
|
let LibrarySchema = new SimpleSchema({
|
||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
},
|
},
|
||||||
isDefault: {
|
|
||||||
type: Boolean,
|
|
||||||
optional: true,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
LibrarySchema.extend(SharingSchema);
|
LibrarySchema.extend(SharingSchema);
|
||||||
@@ -39,7 +37,7 @@ const insertLibrary = new ValidatedMethod({
|
|||||||
mixins: [
|
mixins: [
|
||||||
simpleSchemaMixin,
|
simpleSchemaMixin,
|
||||||
],
|
],
|
||||||
schema: LibrarySchema.omit('owner', 'isDefault'),
|
schema: LibrarySchema.omit('owner'),
|
||||||
run(library) {
|
run(library) {
|
||||||
if (!this.userId) {
|
if (!this.userId) {
|
||||||
throw new Meteor.Error('Libraries.methods.insert.denied',
|
throw new Meteor.Error('Libraries.methods.insert.denied',
|
||||||
@@ -78,30 +76,6 @@ const updateLibraryName = new ValidatedMethod({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const setLibraryDefault = new ValidatedMethod({
|
|
||||||
name: 'libraries.makeLibraryDefault',
|
|
||||||
validate: new SimpleSchema({
|
|
||||||
_id: {
|
|
||||||
type: String,
|
|
||||||
regEx: SimpleSchema.RegEx.id
|
|
||||||
},
|
|
||||||
isDefault: {
|
|
||||||
type: Boolean,
|
|
||||||
},
|
|
||||||
}).validator(),
|
|
||||||
mixins: [RateLimiterMixin],
|
|
||||||
rateLimit: {
|
|
||||||
numRequests: 5,
|
|
||||||
timeInterval: 5000,
|
|
||||||
},
|
|
||||||
run({_id, isDefault}) {
|
|
||||||
if (!Meteor.users.isAdmin()){
|
|
||||||
throw new Meteor.Error('Permission denied', 'User must be admin to set libraries as default');
|
|
||||||
}
|
|
||||||
return Libraries.update(_id, {$set: {isDefault}});
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
const removeLibrary = new ValidatedMethod({
|
const removeLibrary = new ValidatedMethod({
|
||||||
name: 'libraries.remove',
|
name: 'libraries.remove',
|
||||||
validate: new SimpleSchema({
|
validate: new SimpleSchema({
|
||||||
@@ -128,4 +102,4 @@ export function removeLibaryWork(libraryId){
|
|||||||
LibraryNodes.remove({'ancestors.id': libraryId});
|
LibraryNodes.remove({'ancestors.id': libraryId});
|
||||||
}
|
}
|
||||||
|
|
||||||
export { LibrarySchema, insertLibrary, setLibraryDefault, updateLibraryName, removeLibrary };
|
export { LibrarySchema, insertLibrary, updateLibraryName, removeLibrary };
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ import { softRemove } from '/imports/api/parenting/softRemove.js';
|
|||||||
import SoftRemovableSchema from '/imports/api/parenting/SoftRemovableSchema.js';
|
import SoftRemovableSchema from '/imports/api/parenting/SoftRemovableSchema.js';
|
||||||
import { storedIconsSchema } from '/imports/api/icons/Icons.js';
|
import { storedIconsSchema } from '/imports/api/icons/Icons.js';
|
||||||
import '/imports/api/library/methods/index.js';
|
import '/imports/api/library/methods/index.js';
|
||||||
|
import { updateReferenceNodeWork } from '/imports/api/library/methods/updateReferenceNode.js';
|
||||||
|
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||||
|
import { restore } from '/imports/api/parenting/softRemove.js';
|
||||||
|
|
||||||
let LibraryNodes = new Mongo.Collection('libraryNodes');
|
let LibraryNodes = new Mongo.Collection('libraryNodes');
|
||||||
|
|
||||||
@@ -23,13 +26,16 @@ let LibraryNodeSchema = new SimpleSchema({
|
|||||||
tags: {
|
tags: {
|
||||||
type: Array,
|
type: Array,
|
||||||
defaultValue: [],
|
defaultValue: [],
|
||||||
|
maxCount: STORAGE_LIMITS.tagCount,
|
||||||
},
|
},
|
||||||
'tags.$': {
|
'tags.$': {
|
||||||
type: String,
|
type: String,
|
||||||
|
max: STORAGE_LIMITS.tagLength,
|
||||||
},
|
},
|
||||||
icon: {
|
icon: {
|
||||||
type: storedIconsSchema,
|
type: storedIconsSchema,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.icon,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -76,7 +82,12 @@ const insertNode = new ValidatedMethod({
|
|||||||
run(libraryNode) {
|
run(libraryNode) {
|
||||||
delete libraryNode._id;
|
delete libraryNode._id;
|
||||||
assertNodeEditPermission(libraryNode, this.userId);
|
assertNodeEditPermission(libraryNode, this.userId);
|
||||||
return LibraryNodes.insert(libraryNode);
|
let nodeId = LibraryNodes.insert(libraryNode);
|
||||||
|
if (libraryNode.type == 'reference'){
|
||||||
|
libraryNode._id = nodeId;
|
||||||
|
updateReferenceNodeWork(libraryNode, this.userId);
|
||||||
|
}
|
||||||
|
return nodeId;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -109,9 +120,14 @@ const updateLibraryNode = new ValidatedMethod({
|
|||||||
} else {
|
} else {
|
||||||
modifier = {$set: {[pathString]: value}};
|
modifier = {$set: {[pathString]: value}};
|
||||||
}
|
}
|
||||||
return LibraryNodes.update(_id, modifier, {
|
let numUpdated = LibraryNodes.update(_id, modifier, {
|
||||||
selector: {type: node.type},
|
selector: {type: node.type},
|
||||||
});
|
});
|
||||||
|
if (node.type == 'reference'){
|
||||||
|
node = LibraryNodes.findOne(_id);
|
||||||
|
updateReferenceNodeWork(node, this.userId);
|
||||||
|
}
|
||||||
|
return numUpdated;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -171,6 +187,25 @@ const softRemoveLibraryNode = new ValidatedMethod({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const restoreLibraryNode = new ValidatedMethod({
|
||||||
|
name: 'libraryNodes.restore',
|
||||||
|
validate: new SimpleSchema({
|
||||||
|
_id: SimpleSchema.RegEx.Id
|
||||||
|
}).validator(),
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
|
run({_id}){
|
||||||
|
// Permissions
|
||||||
|
let node = LibraryNodes.findOne(_id);
|
||||||
|
assertNodeEditPermission(node, this.userId);
|
||||||
|
// Do work
|
||||||
|
restore({_id, collection: LibraryNodes});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
export default LibraryNodes;
|
export default LibraryNodes;
|
||||||
export {
|
export {
|
||||||
LibraryNodeSchema,
|
LibraryNodeSchema,
|
||||||
@@ -179,4 +214,5 @@ export {
|
|||||||
pullFromLibraryNode,
|
pullFromLibraryNode,
|
||||||
pushToLibraryNode,
|
pushToLibraryNode,
|
||||||
softRemoveLibraryNode,
|
softRemoveLibraryNode,
|
||||||
|
restoreLibraryNode,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1 +1,2 @@
|
|||||||
import '/imports/api/library/methods/duplicateLibraryNode.js';
|
import '/imports/api/library/methods/duplicateLibraryNode.js';
|
||||||
|
import '/imports/api/library/methods/updateReferenceNode.js';
|
||||||
|
|||||||
67
app/imports/api/library/methods/updateReferenceNode.js
Normal file
67
app/imports/api/library/methods/updateReferenceNode.js
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
||||||
|
import SimpleSchema from 'simpl-schema';
|
||||||
|
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
||||||
|
import LibraryNodes from '/imports/api/library/LibraryNodes.js';
|
||||||
|
import {
|
||||||
|
assertDocEditPermission,
|
||||||
|
assertViewPermission,
|
||||||
|
} from '/imports/api/sharing/sharingPermissions.js';
|
||||||
|
import fetchDocByRef from '/imports/api/parenting/fetchDocByRef.js';
|
||||||
|
|
||||||
|
const updateReferenceNode = new ValidatedMethod({
|
||||||
|
name: 'libraryNodes.updateReferenceNode',
|
||||||
|
validate: new SimpleSchema({
|
||||||
|
_id: {
|
||||||
|
type: String,
|
||||||
|
regEx: SimpleSchema.RegEx.Id,
|
||||||
|
}
|
||||||
|
}).validator(),
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
|
run({_id}) {
|
||||||
|
let userId = this.userId;
|
||||||
|
let node = LibraryNodes.findOne(_id);
|
||||||
|
assertDocEditPermission(node, userId);
|
||||||
|
updateReferenceNodeWork(node, userId);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
function writeCache(_id, cache){
|
||||||
|
LibraryNodes.update(_id, {$set: {cache}}, {
|
||||||
|
selector: {type: 'reference'},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function updateReferenceNodeWork(node, userId){
|
||||||
|
let cache = {}
|
||||||
|
if (!node.ref){
|
||||||
|
writeCache(node._id, cache);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
let doc, library;
|
||||||
|
try {
|
||||||
|
doc = fetchDocByRef(node.ref);
|
||||||
|
if (doc.removed) throw 'Property has been deleted';
|
||||||
|
if (doc.ancestors[0].id !== node.ancestors[0].id){
|
||||||
|
library = fetchDocByRef(doc.ancestors[0]);
|
||||||
|
assertViewPermission(library, userId)
|
||||||
|
}
|
||||||
|
} catch(e){
|
||||||
|
cache = {error: e.reason || e.message || e.toString()}
|
||||||
|
writeCache(node._id, cache);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
cache = {
|
||||||
|
node: doc,
|
||||||
|
};
|
||||||
|
if (library){
|
||||||
|
cache.library = {name: library.name};
|
||||||
|
}
|
||||||
|
writeCache(node._id, cache);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default updateReferenceNode;
|
||||||
|
export { updateReferenceNodeWork }
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
|
||||||
|
|
||||||
Blacklist = new Mongo.Collection("blacklist");
|
|
||||||
|
|
||||||
Schemas.Blacklist = new SimpleSchema({
|
|
||||||
userId: {
|
|
||||||
type: String,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
Blacklist.attachSchema(Schemas.Blacklist);
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
|
||||||
|
|
||||||
ChangeLogs = new Mongo.Collection("changeLogs");
|
|
||||||
|
|
||||||
Schemas.ChangeLog = new SimpleSchema({
|
|
||||||
version: {
|
|
||||||
type: String,
|
|
||||||
},
|
|
||||||
changes: {
|
|
||||||
type: [String],
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
ChangeLogs.attachSchema(Schemas.ChangeLog);
|
|
||||||
|
|
||||||
ChangeLogs.allow({
|
|
||||||
insert: function(userId, doc) {
|
|
||||||
var user = Meteor.users.findOne(userId);
|
|
||||||
if (user) return _.contains(user.roles, "admin");
|
|
||||||
},
|
|
||||||
update: function(userId, doc, fields, modifier) {
|
|
||||||
var user = Meteor.users.findOne(userId);
|
|
||||||
if (user) return _.contains(user.roles, "admin");
|
|
||||||
},
|
|
||||||
remove: function(userId, doc) {
|
|
||||||
var user = Meteor.users.findOne(userId);
|
|
||||||
if (user) return _.contains(user.roles, "admin");
|
|
||||||
},
|
|
||||||
});
|
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
|
||||||
|
|
||||||
Reports = new Mongo.Collection("reports");
|
|
||||||
|
|
||||||
Schemas.Report = new SimpleSchema({
|
|
||||||
owner: {
|
|
||||||
type: String,
|
|
||||||
regEx: SimpleSchema.RegEx.Id,
|
|
||||||
},
|
|
||||||
title: {
|
|
||||||
type: String,
|
|
||||||
trim: false,
|
|
||||||
optional: true,
|
|
||||||
},
|
|
||||||
description: {
|
|
||||||
type: String,
|
|
||||||
trim: false,
|
|
||||||
optional: true,
|
|
||||||
},
|
|
||||||
type: {
|
|
||||||
type: String,
|
|
||||||
allowedValues: ["General Feedback", "Bug", "Suggested Change", "Feature Request"],
|
|
||||||
defaultValue: "General Feedback",
|
|
||||||
},
|
|
||||||
//the immediate impact of doing this action (eg. -1 rages)
|
|
||||||
severity: {
|
|
||||||
type: SimpleSchema.Integer,
|
|
||||||
defaultValue: 5,
|
|
||||||
min: 1,
|
|
||||||
max: 10,
|
|
||||||
},
|
|
||||||
metaData: {
|
|
||||||
type: Object,
|
|
||||||
blackbox: true,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
Reports.attachSchema(Schemas.Report);
|
|
||||||
|
|
||||||
Meteor.methods({
|
|
||||||
insertReport: function(report) {
|
|
||||||
check(report, {
|
|
||||||
title: String,
|
|
||||||
description: String,
|
|
||||||
type: String,
|
|
||||||
severity: Number,
|
|
||||||
metaData: Object,
|
|
||||||
});
|
|
||||||
report.owner = this.userId;
|
|
||||||
var id = Reports.insert(report);
|
|
||||||
var user = Meteor.users.findOne(this.userId);
|
|
||||||
var sender = user &&
|
|
||||||
user.emails &&
|
|
||||||
user.emails[0] &&
|
|
||||||
user.emails[0].address ||
|
|
||||||
user.services &&
|
|
||||||
user.services.google &&
|
|
||||||
user.services.google.email ||
|
|
||||||
"reports@dicecloud.com";
|
|
||||||
var bodyText = "Report ID: " + id +
|
|
||||||
"\nSeverity: " + report.severity +
|
|
||||||
"\nType: " + report.type +
|
|
||||||
"\n\n" + report.description;
|
|
||||||
Email.send({
|
|
||||||
from: sender,
|
|
||||||
to: "stefan.zermatten@gmail.com",
|
|
||||||
subject: "DiceCloud feedback - " + report.title,
|
|
||||||
text: bodyText,
|
|
||||||
});
|
|
||||||
},
|
|
||||||
deleteReport: function(id) {
|
|
||||||
var user = Meteor.users.findOne(this.userId);
|
|
||||||
if (!_.contains(user.roles, "admin")){
|
|
||||||
throw new Meteor.Error(
|
|
||||||
"not admin",
|
|
||||||
"The user must be an administrator to delete feedback"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
Reports.remove(id);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
@@ -1,13 +1,20 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
|
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||||
|
|
||||||
const RefSchema = new SimpleSchema({
|
const RefSchema = new SimpleSchema({
|
||||||
id: {
|
id: {
|
||||||
type: String,
|
type: String,
|
||||||
regEx: SimpleSchema.RegEx.Id,
|
regEx: SimpleSchema.RegEx.Id,
|
||||||
|
// TODO: Rather than indexing this field, index `ancestors.0.id` to only
|
||||||
|
// index the root of the ancestor heirarchy to significantly reduce
|
||||||
|
// index size and improve performance
|
||||||
|
// All queries on an ancestor document need to target `ancestors.0.id` first
|
||||||
|
// before targeting a younger ancestor
|
||||||
index: 1
|
index: 1
|
||||||
},
|
},
|
||||||
collection: {
|
collection: {
|
||||||
type: String
|
type: String,
|
||||||
|
max: STORAGE_LIMITS.collectionName,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -22,7 +29,7 @@ let ChildSchema = new SimpleSchema({
|
|||||||
ancestors: {
|
ancestors: {
|
||||||
type: Array,
|
type: Array,
|
||||||
defaultValue: [],
|
defaultValue: [],
|
||||||
max: 100,
|
maxCount: STORAGE_LIMITS.ancestorCount,
|
||||||
},
|
},
|
||||||
'ancestors.$': {
|
'ancestors.$': {
|
||||||
type: RefSchema,
|
type: RefSchema,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { nodesToTree } from '/imports/api/parenting/parenting.js';
|
import nodesToTree from '/imports/api/parenting/nodesToTree.js';
|
||||||
|
|
||||||
export default function getDescendantsInDepthFirstOrder({
|
export default function getDescendantsInDepthFirstOrder({
|
||||||
collection,
|
collection,
|
||||||
|
|||||||
115
app/imports/api/parenting/nodesToTree.js
Normal file
115
app/imports/api/parenting/nodesToTree.js
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
import { union, difference, sortBy, findLast } from 'lodash';
|
||||||
|
|
||||||
|
export function nodeArrayToTree(nodes){
|
||||||
|
// Store a dict and list of all the nodes
|
||||||
|
let nodeIndex = {};
|
||||||
|
let nodeList = [];
|
||||||
|
nodes.forEach( node => {
|
||||||
|
let treeNode = {
|
||||||
|
node: node,
|
||||||
|
children: [],
|
||||||
|
};
|
||||||
|
nodeIndex[node._id] = treeNode;
|
||||||
|
nodeList.push(treeNode);
|
||||||
|
});
|
||||||
|
// Create a forest of trees
|
||||||
|
let forest = [];
|
||||||
|
// Either the node is a child of its nearest found ancestor, or in the forest as a root
|
||||||
|
nodeList.forEach(treeNode => {
|
||||||
|
let ancestorInForest = findLast(
|
||||||
|
treeNode.node.ancestors,
|
||||||
|
ancestor => !!nodeIndex[ancestor.id]
|
||||||
|
);
|
||||||
|
if (ancestorInForest){
|
||||||
|
nodeIndex[ancestorInForest.id].children.push(treeNode);
|
||||||
|
} else {
|
||||||
|
forest.push(treeNode);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return forest;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fetch the documents from a collection, and return the tree of those documents
|
||||||
|
export default function nodesToTree({
|
||||||
|
collection, ancestorId, filter, options = {},
|
||||||
|
includeFilteredDocAncestors = false, includeFilteredDocDescendants = false
|
||||||
|
}){
|
||||||
|
// Setup the filter
|
||||||
|
let collectionFilter = {
|
||||||
|
'ancestors.id': ancestorId,
|
||||||
|
'removed': {$ne: true},
|
||||||
|
};
|
||||||
|
if (filter){
|
||||||
|
collectionFilter = {
|
||||||
|
...collectionFilter,
|
||||||
|
...filter,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Set up the options
|
||||||
|
let collectionSort = {
|
||||||
|
order: 1
|
||||||
|
};
|
||||||
|
if (options && options.sort){
|
||||||
|
collectionSort = {
|
||||||
|
...collectionSort,
|
||||||
|
...options.sort,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let collectionOptions = {
|
||||||
|
sort: collectionSort,
|
||||||
|
}
|
||||||
|
if (options){
|
||||||
|
collectionOptions = {
|
||||||
|
...collectionOptions,
|
||||||
|
...options,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Find all the nodes that match the filter
|
||||||
|
let docs = collection.find(collectionFilter, collectionOptions).map(doc => {
|
||||||
|
if (!filter) return doc;
|
||||||
|
// Mark the nodes that were found by the custom filter
|
||||||
|
doc._matchedDocumentFilter = true;
|
||||||
|
return doc;
|
||||||
|
});
|
||||||
|
let ancestors = [];
|
||||||
|
let ancestorIds = [];
|
||||||
|
let docIds = [];
|
||||||
|
if (filter && (includeFilteredDocAncestors || includeFilteredDocDescendants)){
|
||||||
|
docIds = docs.map(doc => doc._id)
|
||||||
|
}
|
||||||
|
if (filter && includeFilteredDocAncestors){
|
||||||
|
// Add all ancestor ids to an array
|
||||||
|
docs.forEach(doc => {
|
||||||
|
ancestorIds = union(ancestorIds, doc.ancestors.map(ref => ref.id));
|
||||||
|
});
|
||||||
|
// Remove the IDs of docs we have already found
|
||||||
|
ancestorIds = difference(ancestorIds, docIds);
|
||||||
|
// Get the docs from the collection, don't worry about `removed` docs,
|
||||||
|
// if their descendant was not removed, neither are they
|
||||||
|
ancestors = collection.find({_id: {$in: ancestorIds}}).map(doc => {
|
||||||
|
// Mark that the nodes are ancestors of the found nodes
|
||||||
|
doc._ancestorOfMatchedDocument = true;
|
||||||
|
return doc;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
let descendants = [];
|
||||||
|
if (filter && includeFilteredDocDescendants){
|
||||||
|
let exludeIds = union(ancestorIds, docIds);
|
||||||
|
descendants = collection.find({
|
||||||
|
'_id': {$nin: exludeIds},
|
||||||
|
'ancestors.id': {$in: docIds},
|
||||||
|
'removed': {$ne: true},
|
||||||
|
}).map(doc => {
|
||||||
|
// Mark that the nodes are descendants of the found nodes
|
||||||
|
doc._descendantOfMatchedDocument = true;
|
||||||
|
return doc;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
let nodes = sortBy([
|
||||||
|
...ancestors,
|
||||||
|
...docs,
|
||||||
|
...descendants
|
||||||
|
], 'order');
|
||||||
|
// Find all the nodes
|
||||||
|
return nodeArrayToTree(nodes);
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
import fetchDocByRef from '/imports/api/parenting/fetchDocByRef.js';
|
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 { flatten, findLast } from 'lodash';
|
import { flatten } from 'lodash';
|
||||||
|
|
||||||
const generalParents = [
|
const generalParents = [
|
||||||
'attribute',
|
'attribute',
|
||||||
@@ -217,41 +217,3 @@ export function getName(doc){
|
|||||||
if (doc.ancestors[i].name) return doc.ancestors[i].name;
|
if (doc.ancestors[i].name) return doc.ancestors[i].name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function nodeArrayToTree(nodes){
|
|
||||||
// Store a dict and list of all the nodes
|
|
||||||
let nodeIndex = {};
|
|
||||||
let nodeList = [];
|
|
||||||
nodes.forEach( node => {
|
|
||||||
let treeNode = {
|
|
||||||
node: node,
|
|
||||||
children: [],
|
|
||||||
};
|
|
||||||
nodeIndex[node._id] = treeNode;
|
|
||||||
nodeList.push(treeNode);
|
|
||||||
});
|
|
||||||
// Create a forest of trees
|
|
||||||
let forest = [];
|
|
||||||
// Either the node is a child of its nearest found ancestor, or in the forest as a root
|
|
||||||
nodeList.forEach(treeNode => {
|
|
||||||
let ancestorInForest = findLast(
|
|
||||||
treeNode.node.ancestors,
|
|
||||||
ancestor => !!nodeIndex[ancestor.id]
|
|
||||||
);
|
|
||||||
if (ancestorInForest){
|
|
||||||
nodeIndex[ancestorInForest.id].children.push(treeNode);
|
|
||||||
} else {
|
|
||||||
forest.push(treeNode);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return forest;
|
|
||||||
}
|
|
||||||
|
|
||||||
export function nodesToTree({collection, ancestorId, filter = {}, options = {}}){
|
|
||||||
if (!('ancestors.id' in filter)) filter['ancestors.id'] = ancestorId;
|
|
||||||
if (!('removed' in filter)) filter['removed'] = {$ne: true};
|
|
||||||
if (!options.sort) options.sort = {order: 1};
|
|
||||||
if (!('order' in options.sort)) options.sort.order = 1;
|
|
||||||
let nodes = collection.find(filter, options);
|
|
||||||
return nodeArrayToTree(nodes);
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
import ErrorSchema from '/imports/api/properties/subSchemas/ErrorSchema.js';
|
import ErrorSchema from '/imports/api/properties/subSchemas/ErrorSchema.js';
|
||||||
import InlineComputationSchema from '/imports/api/properties/subSchemas/InlineComputationSchema.js';
|
import InlineComputationSchema from '/imports/api/properties/subSchemas/InlineComputationSchema.js';
|
||||||
import { storedIconsSchema } from '/imports/api/icons/Icons.js'
|
import { storedIconsSchema } from '/imports/api/icons/Icons.js';
|
||||||
|
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Actions are things a character can do
|
* Actions are things a character can do
|
||||||
* Any rolls that are children of actions will be rolled when taking the action
|
* Any rolls that are children of actions will be rolled when taking the action
|
||||||
@@ -12,14 +14,17 @@ let ActionSchema = new SimpleSchema({
|
|||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
},
|
},
|
||||||
summary: {
|
summary: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.summary,
|
||||||
},
|
},
|
||||||
description: {
|
description: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.description,
|
||||||
},
|
},
|
||||||
// What time-resource is used to take the action in combat
|
// What time-resource is used to take the action in combat
|
||||||
// long actions take longer than 1 round to cast
|
// long actions take longer than 1 round to cast
|
||||||
@@ -38,13 +43,6 @@ let ActionSchema = new SimpleSchema({
|
|||||||
'multipleTargets',
|
'multipleTargets',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
tags: {
|
|
||||||
type: Array,
|
|
||||||
defaultValue: [],
|
|
||||||
},
|
|
||||||
'tags.$': {
|
|
||||||
type: String,
|
|
||||||
},
|
|
||||||
// Duplicate the ResourceSchema here so we can extend it elegantly.
|
// Duplicate the ResourceSchema here so we can extend it elegantly.
|
||||||
resources: {
|
resources: {
|
||||||
type: Object,
|
type: Object,
|
||||||
@@ -53,6 +51,7 @@ let ActionSchema = new SimpleSchema({
|
|||||||
'resources.itemsConsumed': {
|
'resources.itemsConsumed': {
|
||||||
type: Array,
|
type: Array,
|
||||||
defaultValue: [],
|
defaultValue: [],
|
||||||
|
maxCount: STORAGE_LIMITS.resourcesCount,
|
||||||
},
|
},
|
||||||
'resources.itemsConsumed.$': {
|
'resources.itemsConsumed.$': {
|
||||||
type: Object,
|
type: Object,
|
||||||
@@ -67,6 +66,7 @@ let ActionSchema = new SimpleSchema({
|
|||||||
'resources.itemsConsumed.$.tag': {
|
'resources.itemsConsumed.$.tag': {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.tagLength,
|
||||||
},
|
},
|
||||||
'resources.itemsConsumed.$.quantity': {
|
'resources.itemsConsumed.$.quantity': {
|
||||||
type: Number,
|
type: Number,
|
||||||
@@ -75,10 +75,12 @@ let ActionSchema = new SimpleSchema({
|
|||||||
'resources.itemsConsumed.$.itemId': {
|
'resources.itemsConsumed.$.itemId': {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
},
|
},
|
||||||
'resources.attributesConsumed': {
|
'resources.attributesConsumed': {
|
||||||
type: Array,
|
type: Array,
|
||||||
defaultValue: [],
|
defaultValue: [],
|
||||||
|
maxCount: STORAGE_LIMITS.resourcesCount,
|
||||||
},
|
},
|
||||||
'resources.attributesConsumed.$': {
|
'resources.attributesConsumed.$': {
|
||||||
type: Object,
|
type: Object,
|
||||||
@@ -93,6 +95,7 @@ let ActionSchema = new SimpleSchema({
|
|||||||
'resources.attributesConsumed.$.variableName': {
|
'resources.attributesConsumed.$.variableName': {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.variableName,
|
||||||
},
|
},
|
||||||
'resources.attributesConsumed.$.quantity': {
|
'resources.attributesConsumed.$.quantity': {
|
||||||
type: Number,
|
type: Number,
|
||||||
@@ -102,6 +105,7 @@ let ActionSchema = new SimpleSchema({
|
|||||||
uses: {
|
uses: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.calculation,
|
||||||
},
|
},
|
||||||
// Integer of how many times it has already been used
|
// Integer of how many times it has already been used
|
||||||
usesUsed: {
|
usesUsed: {
|
||||||
@@ -120,14 +124,14 @@ const ComputedOnlyActionSchema = new SimpleSchema({
|
|||||||
summaryCalculations: {
|
summaryCalculations: {
|
||||||
type: Array,
|
type: Array,
|
||||||
defaultValue: [],
|
defaultValue: [],
|
||||||
maxCount: 32,
|
maxCount: STORAGE_LIMITS.inlineCalculationCount,
|
||||||
},
|
},
|
||||||
'summaryCalculations.$': InlineComputationSchema,
|
'summaryCalculations.$': InlineComputationSchema,
|
||||||
|
|
||||||
descriptionCalculations: {
|
descriptionCalculations: {
|
||||||
type: Array,
|
type: Array,
|
||||||
defaultValue: [],
|
defaultValue: [],
|
||||||
maxCount: 32,
|
maxCount: STORAGE_LIMITS.inlineCalculationCount,
|
||||||
},
|
},
|
||||||
'descriptionCalculations.$': InlineComputationSchema,
|
'descriptionCalculations.$': InlineComputationSchema,
|
||||||
|
|
||||||
@@ -138,6 +142,7 @@ const ComputedOnlyActionSchema = new SimpleSchema({
|
|||||||
usesErrors: {
|
usesErrors: {
|
||||||
type: Array,
|
type: Array,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
maxCount: STORAGE_LIMITS.errorCount,
|
||||||
},
|
},
|
||||||
'usesErrors.$':{
|
'usesErrors.$':{
|
||||||
type: ErrorSchema,
|
type: ErrorSchema,
|
||||||
@@ -158,15 +163,18 @@ const ComputedOnlyActionSchema = new SimpleSchema({
|
|||||||
},
|
},
|
||||||
'resources.itemsConsumed.$.itemName': {
|
'resources.itemsConsumed.$.itemName': {
|
||||||
type: String,
|
type: String,
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
},
|
||||||
'resources.itemsConsumed.$.itemIcon': {
|
'resources.itemsConsumed.$.itemIcon': {
|
||||||
type: storedIconsSchema,
|
type: storedIconsSchema,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.icon,
|
||||||
},
|
},
|
||||||
'resources.itemsConsumed.$.itemColor': {
|
'resources.itemsConsumed.$.itemColor': {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.color,
|
||||||
},
|
},
|
||||||
'resources.attributesConsumed': Array,
|
'resources.attributesConsumed': Array,
|
||||||
'resources.attributesConsumed.$': Object,
|
'resources.attributesConsumed.$': Object,
|
||||||
@@ -182,6 +190,7 @@ const ComputedOnlyActionSchema = new SimpleSchema({
|
|||||||
'resources.attributesConsumed.$.statName': {
|
'resources.attributesConsumed.$.statName': {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
},
|
},
|
||||||
// True if the uses left is zero, or any item or attribute consumed is
|
// True if the uses left is zero, or any item or attribute consumed is
|
||||||
// insufficient
|
// insufficient
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
import ErrorSchema from '/imports/api/properties/subSchemas/ErrorSchema.js';
|
import ErrorSchema from '/imports/api/properties/subSchemas/ErrorSchema.js';
|
||||||
|
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||||
|
|
||||||
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
|
||||||
@@ -8,6 +9,7 @@ const AdjustmentSchema = new SimpleSchema({
|
|||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
defaultValue: '1',
|
defaultValue: '1',
|
||||||
|
max: STORAGE_LIMITS.calculation,
|
||||||
},
|
},
|
||||||
// Who this adjustment applies to
|
// Who this adjustment applies to
|
||||||
target: {
|
target: {
|
||||||
@@ -23,6 +25,7 @@ const AdjustmentSchema = new SimpleSchema({
|
|||||||
stat: {
|
stat: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.variableName,
|
||||||
},
|
},
|
||||||
operation: {
|
operation: {
|
||||||
type: String,
|
type: String,
|
||||||
@@ -39,6 +42,7 @@ const ComputedOnlyAdjustmentSchema = new SimpleSchema({
|
|||||||
amountErrors: {
|
amountErrors: {
|
||||||
type: Array,
|
type: Array,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
maxCount: STORAGE_LIMITS.errorCount,
|
||||||
},
|
},
|
||||||
'amountErrors.$':{
|
'amountErrors.$':{
|
||||||
type: ErrorSchema,
|
type: ErrorSchema,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
import { ActionSchema, ComputedOnlyActionSchema } from '/imports/api/properties/Actions.js';
|
import { ActionSchema, ComputedOnlyActionSchema } from '/imports/api/properties/Actions.js';
|
||||||
import ErrorSchema from '/imports/api/properties/subSchemas/ErrorSchema.js';
|
import ErrorSchema from '/imports/api/properties/subSchemas/ErrorSchema.js';
|
||||||
|
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||||
|
|
||||||
// Attacks are special instances of actions
|
// Attacks are special instances of actions
|
||||||
let AttackSchema = new SimpleSchema()
|
let AttackSchema = new SimpleSchema()
|
||||||
@@ -11,18 +12,22 @@ let AttackSchema = new SimpleSchema()
|
|||||||
type: String,
|
type: String,
|
||||||
defaultValue: 'strength.modifier + proficiencyBonus',
|
defaultValue: 'strength.modifier + proficiencyBonus',
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.calculation,
|
||||||
},
|
},
|
||||||
// Set better defaults for the action
|
// Set better defaults for the action
|
||||||
actionType: {
|
actionType: {
|
||||||
type: String,
|
type: String,
|
||||||
defaultValue: 'attack',
|
defaultValue: 'attack',
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
},
|
},
|
||||||
tags: {
|
tags: {
|
||||||
type: Array,
|
type: Array,
|
||||||
defaultValue: ['attack'],
|
defaultValue: ['attack'],
|
||||||
|
maxCount: STORAGE_LIMITS.tagCount,
|
||||||
},
|
},
|
||||||
'tags.$': {
|
'tags.$': {
|
||||||
type: String,
|
type: String,
|
||||||
|
max: STORAGE_LIMITS.tagLength,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -36,6 +41,7 @@ const ComputedOnlyAttackSchema = new SimpleSchema()
|
|||||||
rollBonusErrors: {
|
rollBonusErrors: {
|
||||||
type: Array,
|
type: Array,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
maxCount: STORAGE_LIMITS.errorCount,
|
||||||
},
|
},
|
||||||
'rollBonusErrors.$':{
|
'rollBonusErrors.$':{
|
||||||
type: ErrorSchema,
|
type: ErrorSchema,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import SimpleSchema from 'simpl-schema';
|
|||||||
import ErrorSchema from '/imports/api/properties/subSchemas/ErrorSchema.js';
|
import ErrorSchema from '/imports/api/properties/subSchemas/ErrorSchema.js';
|
||||||
import VARIABLE_NAME_REGEX from '/imports/constants/VARIABLE_NAME_REGEX.js';
|
import VARIABLE_NAME_REGEX from '/imports/constants/VARIABLE_NAME_REGEX.js';
|
||||||
import InlineComputationSchema from '/imports/api/properties/subSchemas/InlineComputationSchema.js';
|
import InlineComputationSchema from '/imports/api/properties/subSchemas/InlineComputationSchema.js';
|
||||||
|
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Attributes are numbered stats of a character
|
* Attributes are numbered stats of a character
|
||||||
@@ -10,6 +11,7 @@ let AttributeSchema = new SimpleSchema({
|
|||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
defaultValue: 'New Attribute',
|
defaultValue: 'New Attribute',
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
},
|
},
|
||||||
// The technical, lowercase, single-word name used in formulae
|
// The technical, lowercase, single-word name used in formulae
|
||||||
variableName: {
|
variableName: {
|
||||||
@@ -17,6 +19,7 @@ let AttributeSchema = new SimpleSchema({
|
|||||||
regEx: VARIABLE_NAME_REGEX,
|
regEx: VARIABLE_NAME_REGEX,
|
||||||
min: 2,
|
min: 2,
|
||||||
defaultValue: 'newAttribute',
|
defaultValue: 'newAttribute',
|
||||||
|
max: STORAGE_LIMITS.variableName,
|
||||||
},
|
},
|
||||||
// How it is displayed and computed is determined by type
|
// How it is displayed and computed is determined by type
|
||||||
attributeType: {
|
attributeType: {
|
||||||
@@ -45,16 +48,19 @@ let AttributeSchema = new SimpleSchema({
|
|||||||
spellSlotLevelCalculation: {
|
spellSlotLevelCalculation: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.calculation,
|
||||||
},
|
},
|
||||||
// The starting value, before effects
|
// The starting value, before effects
|
||||||
baseValueCalculation: {
|
baseValueCalculation: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.calculation,
|
||||||
},
|
},
|
||||||
// Description of what the attribute is used for
|
// Description of what the attribute is used for
|
||||||
description: {
|
description: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.description,
|
||||||
},
|
},
|
||||||
// The damage done to the attribute, always positive
|
// The damage done to the attribute, always positive
|
||||||
damage: {
|
damage: {
|
||||||
@@ -79,7 +85,7 @@ let ComputedOnlyAttributeSchema = new SimpleSchema({
|
|||||||
descriptionCalculations: {
|
descriptionCalculations: {
|
||||||
type: Array,
|
type: Array,
|
||||||
defaultValue: [],
|
defaultValue: [],
|
||||||
maxCount: 32,
|
maxCount: STORAGE_LIMITS.inlineCalculationCount,
|
||||||
},
|
},
|
||||||
'descriptionCalculations.$': InlineComputationSchema,
|
'descriptionCalculations.$': InlineComputationSchema,
|
||||||
// The result of baseValueCalculation
|
// The result of baseValueCalculation
|
||||||
@@ -93,6 +99,7 @@ let ComputedOnlyAttributeSchema = new SimpleSchema({
|
|||||||
},
|
},
|
||||||
'baseValueErrors.$': {
|
'baseValueErrors.$': {
|
||||||
type: ErrorSchema,
|
type: ErrorSchema,
|
||||||
|
maxCount: STORAGE_LIMITS.errorCount,
|
||||||
},
|
},
|
||||||
// The result of spellSlotLevelCalculation
|
// The result of spellSlotLevelCalculation
|
||||||
spellSlotLevelValue: {
|
spellSlotLevelValue: {
|
||||||
@@ -102,6 +109,7 @@ let ComputedOnlyAttributeSchema = new SimpleSchema({
|
|||||||
spellSlotLevelErrors: {
|
spellSlotLevelErrors: {
|
||||||
type: Array,
|
type: Array,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
maxCount: STORAGE_LIMITS.errorCount,
|
||||||
},
|
},
|
||||||
'spellSlotLevelErrors.$': {
|
'spellSlotLevelErrors.$': {
|
||||||
type: ErrorSchema,
|
type: ErrorSchema,
|
||||||
|
|||||||
@@ -1,18 +1,22 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
import InlineComputationSchema from '/imports/api/properties/subSchemas/InlineComputationSchema.js';
|
import InlineComputationSchema from '/imports/api/properties/subSchemas/InlineComputationSchema.js';
|
||||||
|
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||||
|
|
||||||
let BuffSchema = new SimpleSchema({
|
let BuffSchema = new SimpleSchema({
|
||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
},
|
},
|
||||||
description: {
|
description: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.description,
|
||||||
},
|
},
|
||||||
duration: {
|
duration: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
},
|
},
|
||||||
applied: {
|
applied: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
@@ -34,7 +38,7 @@ let ComputedOnlyBuffSchema = new SimpleSchema({
|
|||||||
descriptionCalculations: {
|
descriptionCalculations: {
|
||||||
type: Array,
|
type: Array,
|
||||||
defaultValue: [],
|
defaultValue: [],
|
||||||
maxCount: 32,
|
maxCount: STORAGE_LIMITS.inlineCalculationCount,
|
||||||
},
|
},
|
||||||
'descriptionCalculations.$': InlineComputationSchema,
|
'descriptionCalculations.$': InlineComputationSchema,
|
||||||
durationSpent: {
|
durationSpent: {
|
||||||
@@ -48,6 +52,7 @@ let ComputedOnlyBuffSchema = new SimpleSchema({
|
|||||||
},
|
},
|
||||||
'appliedBy.name': {
|
'appliedBy.name': {
|
||||||
type: String,
|
type: String,
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
},
|
},
|
||||||
'appliedBy.id': {
|
'appliedBy.id': {
|
||||||
type: String,
|
type: String,
|
||||||
@@ -55,6 +60,7 @@ let ComputedOnlyBuffSchema = new SimpleSchema({
|
|||||||
},
|
},
|
||||||
'appliedBy.collection': {
|
'appliedBy.collection': {
|
||||||
type: String,
|
type: String,
|
||||||
|
max: STORAGE_LIMITS.collectionName,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -1,21 +1,25 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
import VARIABLE_NAME_REGEX from '/imports/constants/VARIABLE_NAME_REGEX.js';
|
import VARIABLE_NAME_REGEX from '/imports/constants/VARIABLE_NAME_REGEX.js';
|
||||||
|
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||||
|
|
||||||
let ClassLevelSchema = new SimpleSchema({
|
let ClassLevelSchema = new SimpleSchema({
|
||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
},
|
},
|
||||||
// Only used by slot filling dialog, not computed
|
// Only used by slot filling dialog, not computed
|
||||||
description: {
|
description: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.description,
|
||||||
},
|
},
|
||||||
// The name of this class level's variable
|
// The name of this class level's variable
|
||||||
variableName: {
|
variableName: {
|
||||||
type: String,
|
type: String,
|
||||||
min: 2,
|
min: 2,
|
||||||
regEx: VARIABLE_NAME_REGEX,
|
regEx: VARIABLE_NAME_REGEX,
|
||||||
|
max: STORAGE_LIMITS.variableName,
|
||||||
},
|
},
|
||||||
level: {
|
level: {
|
||||||
type: SimpleSchema.Integer,
|
type: SimpleSchema.Integer,
|
||||||
@@ -32,6 +36,7 @@ let ClassLevelSchema = new SimpleSchema({
|
|||||||
slotFillerCondition: {
|
slotFillerCondition: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.calculation,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import {
|
|||||||
} from '/imports/parser/parser.js';
|
} from '/imports/parser/parser.js';
|
||||||
import AccessorNode from '/imports/parser/parseTree/AccessorNode.js';
|
import AccessorNode from '/imports/parser/parseTree/AccessorNode.js';
|
||||||
import SymbolNode from '/imports/parser/parseTree/SymbolNode.js';
|
import SymbolNode from '/imports/parser/parseTree/SymbolNode.js';
|
||||||
|
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Constants are primitive values that can be used elsewhere in computations
|
* Constants are primitive values that can be used elsewhere in computations
|
||||||
*/
|
*/
|
||||||
@@ -15,6 +17,7 @@ let ConstantSchema = new SimpleSchema({
|
|||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
},
|
},
|
||||||
// The technical, lowercase, single-word name used in formulae
|
// The technical, lowercase, single-word name used in formulae
|
||||||
variableName: {
|
variableName: {
|
||||||
@@ -22,15 +25,18 @@ let ConstantSchema = new SimpleSchema({
|
|||||||
regEx: VARIABLE_NAME_REGEX,
|
regEx: VARIABLE_NAME_REGEX,
|
||||||
min: 2,
|
min: 2,
|
||||||
defaultValue: 'newConstant',
|
defaultValue: 'newConstant',
|
||||||
|
max: STORAGE_LIMITS.variableName,
|
||||||
},
|
},
|
||||||
// The input value to be parsed, must return a constant node or an array
|
// The input value to be parsed, must return a constant node or an array
|
||||||
// of constant nodes to be valid
|
// of constant nodes to be valid
|
||||||
calculation: {
|
calculation: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.calculation,
|
||||||
},
|
},
|
||||||
errors: {
|
errors: {
|
||||||
type: Array,
|
type: Array,
|
||||||
|
maxCount: STORAGE_LIMITS.errorCount,
|
||||||
autoValue(){
|
autoValue(){
|
||||||
let calc = this.field('calculation');
|
let calc = this.field('calculation');
|
||||||
if (!calc.isSet && this.isModifier) {
|
if (!calc.isSet && this.isModifier) {
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
import InlineComputationSchema from '/imports/api/properties/subSchemas/InlineComputationSchema.js';
|
import InlineComputationSchema from '/imports/api/properties/subSchemas/InlineComputationSchema.js';
|
||||||
|
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||||
|
|
||||||
let ContainerSchema = new SimpleSchema({
|
let ContainerSchema = new SimpleSchema({
|
||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
trim: false
|
trim: false,
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
},
|
},
|
||||||
carried: {
|
carried: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
@@ -29,7 +31,8 @@ let ContainerSchema = new SimpleSchema({
|
|||||||
description: {
|
description: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
trim: false
|
trim: false,
|
||||||
|
max: STORAGE_LIMITS.description,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -37,7 +40,7 @@ const ComputedOnlyContainerSchema = new SimpleSchema({
|
|||||||
descriptionCalculations: {
|
descriptionCalculations: {
|
||||||
type: Array,
|
type: Array,
|
||||||
defaultValue: [],
|
defaultValue: [],
|
||||||
maxCount: 32,
|
maxCount: STORAGE_LIMITS.inlineCalculationCount,
|
||||||
},
|
},
|
||||||
'descriptionCalculations.$': InlineComputationSchema,
|
'descriptionCalculations.$': InlineComputationSchema,
|
||||||
// Weight of all the contents, zero if `contentsWeightless` is true
|
// Weight of all the contents, zero if `contentsWeightless` is true
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
import DAMAGE_TYPES from '/imports/constants/DAMAGE_TYPES.js';
|
import DAMAGE_TYPES from '/imports/constants/DAMAGE_TYPES.js';
|
||||||
|
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* DamageMultipliers are multipliers that affect how much damage is taken from
|
* DamageMultipliers are multipliers that affect how much damage is taken from
|
||||||
@@ -9,10 +10,12 @@ let DamageMultiplierSchema = new SimpleSchema({
|
|||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
},
|
},
|
||||||
damageTypes: {
|
damageTypes: {
|
||||||
type: Array,
|
type: Array,
|
||||||
defaultValue: [],
|
defaultValue: [],
|
||||||
|
maxCount: STORAGE_LIMITS.damageTypeCount,
|
||||||
},
|
},
|
||||||
// The technical, lowercase, single-word name used in formulae
|
// The technical, lowercase, single-word name used in formulae
|
||||||
'damageTypes.$': {
|
'damageTypes.$': {
|
||||||
@@ -29,17 +32,21 @@ let DamageMultiplierSchema = new SimpleSchema({
|
|||||||
excludeTags: {
|
excludeTags: {
|
||||||
type: Array,
|
type: Array,
|
||||||
defaultValue: [],
|
defaultValue: [],
|
||||||
|
maxCount: STORAGE_LIMITS.tagCount,
|
||||||
},
|
},
|
||||||
'excludeTags.$': {
|
'excludeTags.$': {
|
||||||
type: String,
|
type: String,
|
||||||
|
max: STORAGE_LIMITS.tagLength,
|
||||||
},
|
},
|
||||||
// Tags which must be present to be affected by this multiplier (AND)
|
// Tags which must be present to be affected by this multiplier (AND)
|
||||||
includeTags: {
|
includeTags: {
|
||||||
type: Array,
|
type: Array,
|
||||||
defaultValue: [],
|
defaultValue: [],
|
||||||
|
maxCount: STORAGE_LIMITS.tagCount,
|
||||||
},
|
},
|
||||||
'includeTags.$': {
|
'includeTags.$': {
|
||||||
type: String,
|
type: String,
|
||||||
|
max: STORAGE_LIMITS.tagLength,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
import DAMAGE_TYPES from '/imports/constants/DAMAGE_TYPES.js';
|
import DAMAGE_TYPES from '/imports/constants/DAMAGE_TYPES.js';
|
||||||
import ErrorSchema from '/imports/api/properties/subSchemas/ErrorSchema.js';
|
import ErrorSchema from '/imports/api/properties/subSchemas/ErrorSchema.js';
|
||||||
|
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.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
|
||||||
@@ -9,6 +10,7 @@ const DamageSchema = new SimpleSchema({
|
|||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
defaultValue: '1d8 + strength.modifier',
|
defaultValue: '1d8 + strength.modifier',
|
||||||
|
max: STORAGE_LIMITS.calculation,
|
||||||
},
|
},
|
||||||
// Who this damage applies to
|
// Who this damage applies to
|
||||||
target: {
|
target: {
|
||||||
@@ -35,6 +37,7 @@ const ComputedOnlyDamageSchema = new SimpleSchema({
|
|||||||
amountErrors: {
|
amountErrors: {
|
||||||
type: Array,
|
type: Array,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
maxCount: STORAGE_LIMITS.errorCount,
|
||||||
},
|
},
|
||||||
'amountErrors.$':{
|
'amountErrors.$':{
|
||||||
type: ErrorSchema,
|
type: ErrorSchema,
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
import ErrorSchema from '/imports/api/properties/subSchemas/ErrorSchema.js';
|
import ErrorSchema from '/imports/api/properties/subSchemas/ErrorSchema.js';
|
||||||
|
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Effects are reason-value attached to skills and abilities
|
* Effects are reason-value attached to skills and abilities
|
||||||
* that modify their final value or presentation in some way
|
* that modify their final value or presentation in some way
|
||||||
@@ -8,6 +10,7 @@ let EffectSchema = new SimpleSchema({
|
|||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
},
|
},
|
||||||
operation: {
|
operation: {
|
||||||
type: String,
|
type: String,
|
||||||
@@ -30,14 +33,17 @@ let EffectSchema = new SimpleSchema({
|
|||||||
calculation: {
|
calculation: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.calculation,
|
||||||
},
|
},
|
||||||
//which stats the effect is applied to
|
//which stats the effect is applied to
|
||||||
stats: {
|
stats: {
|
||||||
type: Array,
|
type: Array,
|
||||||
defaultValue: [],
|
defaultValue: [],
|
||||||
|
maxCount: STORAGE_LIMITS.statsToTarget,
|
||||||
},
|
},
|
||||||
'stats.$': {
|
'stats.$': {
|
||||||
type: String,
|
type: String,
|
||||||
|
max: STORAGE_LIMITS.variableName,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -51,6 +57,7 @@ const ComputedOnlyEffectSchema = new SimpleSchema({
|
|||||||
errors: {
|
errors: {
|
||||||
type: Array,
|
type: Array,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
maxCount: STORAGE_LIMITS.errorCount,
|
||||||
},
|
},
|
||||||
'errors.$':{
|
'errors.$':{
|
||||||
type: ErrorSchema,
|
type: ErrorSchema,
|
||||||
|
|||||||
@@ -1,17 +1,21 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
import InlineComputationSchema from '/imports/api/properties/subSchemas/InlineComputationSchema.js';
|
import InlineComputationSchema from '/imports/api/properties/subSchemas/InlineComputationSchema.js';
|
||||||
|
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||||
|
|
||||||
let FeatureSchema = new SimpleSchema({
|
let FeatureSchema = new SimpleSchema({
|
||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
},
|
},
|
||||||
summary: {
|
summary: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.summary,
|
||||||
},
|
},
|
||||||
description: {
|
description: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.description,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -20,14 +24,14 @@ let ComputedOnlyFeatureSchema = new SimpleSchema({
|
|||||||
summaryCalculations: {
|
summaryCalculations: {
|
||||||
type: Array,
|
type: Array,
|
||||||
defaultValue: [],
|
defaultValue: [],
|
||||||
maxCount: 32,
|
maxCount: STORAGE_LIMITS.inlineCalculationCount,
|
||||||
},
|
},
|
||||||
'summaryCalculations.$': InlineComputationSchema,
|
'summaryCalculations.$': InlineComputationSchema,
|
||||||
|
|
||||||
descriptionCalculations: {
|
descriptionCalculations: {
|
||||||
type: Array,
|
type: Array,
|
||||||
defaultValue: [],
|
defaultValue: [],
|
||||||
maxCount: 32,
|
maxCount: STORAGE_LIMITS.inlineCalculationCount,
|
||||||
},
|
},
|
||||||
'descriptionCalculations.$': InlineComputationSchema,
|
'descriptionCalculations.$': InlineComputationSchema,
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
|
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||||
|
|
||||||
// Folders organize a character sheet into a tree, particularly to group things
|
// Folders organize a character sheet into a tree, particularly to group things
|
||||||
// like 'race' and 'background'
|
// like 'race' and 'background'
|
||||||
let FolderSchema = new SimpleSchema({
|
let FolderSchema = new SimpleSchema({
|
||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,23 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
import InlineComputationSchema from '/imports/api/properties/subSchemas/InlineComputationSchema.js';
|
import InlineComputationSchema from '/imports/api/properties/subSchemas/InlineComputationSchema.js';
|
||||||
|
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||||
|
|
||||||
const ItemSchema = new SimpleSchema({
|
const ItemSchema = new SimpleSchema({
|
||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
},
|
},
|
||||||
// Plural name of the item, if there is more than one
|
// Plural name of the item, if there is more than one
|
||||||
plural: {
|
plural: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
},
|
},
|
||||||
description: {
|
description: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.description,
|
||||||
},
|
},
|
||||||
// Number currently held
|
// Number currently held
|
||||||
quantity: {
|
quantity: {
|
||||||
@@ -58,7 +62,7 @@ let ComputedOnlyItemSchema = new SimpleSchema({
|
|||||||
descriptionCalculations: {
|
descriptionCalculations: {
|
||||||
type: Array,
|
type: Array,
|
||||||
defaultValue: [],
|
defaultValue: [],
|
||||||
maxCount: 32,
|
maxCount: STORAGE_LIMITS.inlineCalculationCount,
|
||||||
},
|
},
|
||||||
'descriptionCalculations.$': InlineComputationSchema,
|
'descriptionCalculations.$': InlineComputationSchema,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,18 +1,22 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
import InlineComputationSchema from '/imports/api/properties/subSchemas/InlineComputationSchema.js';
|
import InlineComputationSchema from '/imports/api/properties/subSchemas/InlineComputationSchema.js';
|
||||||
|
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||||
|
|
||||||
let NoteSchema = new SimpleSchema({
|
let NoteSchema = new SimpleSchema({
|
||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
},
|
},
|
||||||
summary: {
|
summary: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.summary,
|
||||||
},
|
},
|
||||||
description: {
|
description: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.description,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -21,14 +25,14 @@ let ComputedOnlyNoteSchema = new SimpleSchema({
|
|||||||
summaryCalculations: {
|
summaryCalculations: {
|
||||||
type: Array,
|
type: Array,
|
||||||
defaultValue: [],
|
defaultValue: [],
|
||||||
maxCount: 32,
|
maxCount: STORAGE_LIMITS.inlineCalculationCount,
|
||||||
},
|
},
|
||||||
'summaryCalculations.$': InlineComputationSchema,
|
'summaryCalculations.$': InlineComputationSchema,
|
||||||
|
|
||||||
descriptionCalculations: {
|
descriptionCalculations: {
|
||||||
type: Array,
|
type: Array,
|
||||||
defaultValue: [],
|
defaultValue: [],
|
||||||
maxCount: 32,
|
maxCount: STORAGE_LIMITS.inlineCalculationCount,
|
||||||
},
|
},
|
||||||
'descriptionCalculations.$': InlineComputationSchema,
|
'descriptionCalculations.$': InlineComputationSchema,
|
||||||
|
|
||||||
|
|||||||
@@ -1,17 +1,21 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
|
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||||
|
|
||||||
let ProficiencySchema = new SimpleSchema({
|
let ProficiencySchema = new SimpleSchema({
|
||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
},
|
},
|
||||||
// The variableNames of the skills, tags, or attributes to apply proficiency to
|
// The variableNames of the skills, tags, or attributes to apply proficiency to
|
||||||
stats: {
|
stats: {
|
||||||
type: Array,
|
type: Array,
|
||||||
defaultValue: [],
|
defaultValue: [],
|
||||||
|
maxCount: STORAGE_LIMITS.statsToTarget,
|
||||||
},
|
},
|
||||||
'stats.$': {
|
'stats.$': {
|
||||||
type: String,
|
type: String,
|
||||||
|
max: STORAGE_LIMITS.variableName,
|
||||||
},
|
},
|
||||||
// A number representing how proficient the character is
|
// A number representing how proficient the character is
|
||||||
// where 0.49 is half rounded down and 0.5 is half rounded up
|
// where 0.49 is half rounded down and 0.5 is half rounded up
|
||||||
|
|||||||
61
app/imports/api/properties/References.js
Normal file
61
app/imports/api/properties/References.js
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
import SimpleSchema from 'simpl-schema';
|
||||||
|
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||||
|
|
||||||
|
let ReferenceSchema = new SimpleSchema({
|
||||||
|
ref: {
|
||||||
|
type: Object,
|
||||||
|
defaultValue: {},
|
||||||
|
},
|
||||||
|
'ref.id': {
|
||||||
|
type: String,
|
||||||
|
regEx: SimpleSchema.RegEx.Id,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
'ref.collection': {
|
||||||
|
type: String,
|
||||||
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.collectionName,
|
||||||
|
},
|
||||||
|
// Denormalised store of referenced property's details
|
||||||
|
cache: {
|
||||||
|
type: Object,
|
||||||
|
defaultValue: {},
|
||||||
|
},
|
||||||
|
'cache.error': {
|
||||||
|
type: String,
|
||||||
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.errorMessage,
|
||||||
|
},
|
||||||
|
'cache.node': {
|
||||||
|
type: Object,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
'cache.node.name': {
|
||||||
|
type: String,
|
||||||
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
|
},
|
||||||
|
'cache.node.type': {
|
||||||
|
type: String,
|
||||||
|
max: STORAGE_LIMITS.variableName,
|
||||||
|
},
|
||||||
|
'cache.node.level': {
|
||||||
|
type: Number,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
'cache.node.value': {
|
||||||
|
type: Number,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
'cache.library': {
|
||||||
|
type: Object,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
'cache.library.name': {
|
||||||
|
type: String,
|
||||||
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export { ReferenceSchema };
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
import ErrorSchema from '/imports/api/properties/subSchemas/ErrorSchema.js';
|
import ErrorSchema from '/imports/api/properties/subSchemas/ErrorSchema.js';
|
||||||
import VARIABLE_NAME_REGEX from '/imports/constants/VARIABLE_NAME_REGEX.js';
|
import VARIABLE_NAME_REGEX from '/imports/constants/VARIABLE_NAME_REGEX.js';
|
||||||
|
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Rolls are children to actions or other rolls, they are triggered with 0 or
|
* Rolls are children to actions or other rolls, they are triggered with 0 or
|
||||||
@@ -24,6 +25,7 @@ let RollSchema = new SimpleSchema({
|
|||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
defaultValue: 'New Roll',
|
defaultValue: 'New Roll',
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
},
|
},
|
||||||
// The technical, lowercase, single-word name used in formulae
|
// The technical, lowercase, single-word name used in formulae
|
||||||
variableName: {
|
variableName: {
|
||||||
@@ -31,20 +33,13 @@ let RollSchema = new SimpleSchema({
|
|||||||
regEx: VARIABLE_NAME_REGEX,
|
regEx: VARIABLE_NAME_REGEX,
|
||||||
min: 2,
|
min: 2,
|
||||||
defaultValue: 'newRoll',
|
defaultValue: 'newRoll',
|
||||||
|
max: STORAGE_LIMITS.variableName,
|
||||||
},
|
},
|
||||||
// The roll, can be simplified, but only computed in context
|
// The roll, can be simplified, but only computed in context
|
||||||
roll: {
|
roll: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
},
|
max: STORAGE_LIMITS.calculation,
|
||||||
// Effects can apply to this tag specifically
|
|
||||||
// Ranged spell attack, Ranged weapon attack, etc.
|
|
||||||
tags: {
|
|
||||||
type: Array,
|
|
||||||
defaultValue: [],
|
|
||||||
},
|
|
||||||
'tags.$': {
|
|
||||||
type: String,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -56,6 +51,7 @@ let ComputedOnlyRollSchema = new SimpleSchema({
|
|||||||
rollErrors: {
|
rollErrors: {
|
||||||
type: Array,
|
type: Array,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
maxCount: STORAGE_LIMITS.errorCount,
|
||||||
},
|
},
|
||||||
'rollErrors.$':{
|
'rollErrors.$':{
|
||||||
type: ErrorSchema,
|
type: ErrorSchema,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
import ErrorSchema from '/imports/api/properties/subSchemas/ErrorSchema.js';
|
import ErrorSchema from '/imports/api/properties/subSchemas/ErrorSchema.js';
|
||||||
|
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.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
|
||||||
@@ -7,11 +8,13 @@ let SavingThrowSchema = new SimpleSchema ({
|
|||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
},
|
},
|
||||||
// The computed DC
|
// The computed DC
|
||||||
dc: {
|
dc: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.calculation,
|
||||||
},
|
},
|
||||||
// Who this saving throw applies to
|
// Who this saving throw applies to
|
||||||
target: {
|
target: {
|
||||||
@@ -27,6 +30,7 @@ let SavingThrowSchema = new SimpleSchema ({
|
|||||||
stat: {
|
stat: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.variableName,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -38,6 +42,7 @@ const ComputedOnlySavingThrowSchema = new SimpleSchema({
|
|||||||
dcErrors: {
|
dcErrors: {
|
||||||
type: Array,
|
type: Array,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
maxCount: STORAGE_LIMITS.errorCount,
|
||||||
},
|
},
|
||||||
'dcErrors.$':{
|
'dcErrors.$':{
|
||||||
type: ErrorSchema,
|
type: ErrorSchema,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
import VARIABLE_NAME_REGEX from '/imports/constants/VARIABLE_NAME_REGEX.js';
|
import VARIABLE_NAME_REGEX from '/imports/constants/VARIABLE_NAME_REGEX.js';
|
||||||
import ErrorSchema from '/imports/api/properties/subSchemas/ErrorSchema.js';
|
import ErrorSchema from '/imports/api/properties/subSchemas/ErrorSchema.js';
|
||||||
|
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Skills are anything that results in a modifier to be added to a D20
|
* Skills are anything that results in a modifier to be added to a D20
|
||||||
@@ -10,6 +11,7 @@ let SkillSchema = new SimpleSchema({
|
|||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
},
|
},
|
||||||
// The technical, lowercase, single-word name used in formulae
|
// The technical, lowercase, single-word name used in formulae
|
||||||
// Ignored for skilltype = save
|
// Ignored for skilltype = save
|
||||||
@@ -17,11 +19,13 @@ let SkillSchema = new SimpleSchema({
|
|||||||
type: String,
|
type: String,
|
||||||
regEx: VARIABLE_NAME_REGEX,
|
regEx: VARIABLE_NAME_REGEX,
|
||||||
min: 2,
|
min: 2,
|
||||||
|
max: STORAGE_LIMITS.variableName,
|
||||||
},
|
},
|
||||||
// The variable name of the ability this skill relies on
|
// The variable name of the ability this skill relies on
|
||||||
ability: {
|
ability: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.variableName,
|
||||||
},
|
},
|
||||||
// What type of skill is this
|
// What type of skill is this
|
||||||
skillType: {
|
skillType: {
|
||||||
@@ -42,6 +46,7 @@ let SkillSchema = new SimpleSchema({
|
|||||||
baseValueCalculation: {
|
baseValueCalculation: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.calculation,
|
||||||
},
|
},
|
||||||
// The base proficiency of this skill
|
// The base proficiency of this skill
|
||||||
baseProficiency: {
|
baseProficiency: {
|
||||||
@@ -52,6 +57,7 @@ let SkillSchema = new SimpleSchema({
|
|||||||
description: {
|
description: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.description,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -69,6 +75,7 @@ let ComputedOnlySkillSchema = new SimpleSchema({
|
|||||||
baseValueErrors: {
|
baseValueErrors: {
|
||||||
type: Array,
|
type: Array,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
maxCount: STORAGE_LIMITS.errorCount,
|
||||||
},
|
},
|
||||||
'baseValueErrors.$': {
|
'baseValueErrors.$': {
|
||||||
type: ErrorSchema,
|
type: ErrorSchema,
|
||||||
@@ -107,6 +114,7 @@ let ComputedOnlySkillSchema = new SimpleSchema({
|
|||||||
rollBonuses: {
|
rollBonuses: {
|
||||||
type: Array,
|
type: Array,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
maxCount: STORAGE_LIMITS.rollBonusCount,
|
||||||
},
|
},
|
||||||
'rollBonuses.$': {
|
'rollBonuses.$': {
|
||||||
type: String,
|
type: String,
|
||||||
|
|||||||
@@ -1,25 +1,29 @@
|
|||||||
|
import SimpleSchema from 'simpl-schema';
|
||||||
|
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||||
|
|
||||||
// SlotFiller fillers specifically fill a slot with a bit more control than
|
// SlotFiller fillers specifically fill a slot with a bit more control than
|
||||||
// other properties
|
// other properties
|
||||||
|
|
||||||
import SimpleSchema from 'simpl-schema';
|
|
||||||
|
|
||||||
let SlotFillerSchema = new SimpleSchema({
|
let SlotFillerSchema = new SimpleSchema({
|
||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
},
|
},
|
||||||
picture: {
|
picture: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.url,
|
||||||
},
|
},
|
||||||
description: {
|
description: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.description,
|
||||||
},
|
},
|
||||||
// Overrides the type when searching for properties
|
// Overrides the type when searching for properties
|
||||||
slotFillerType: {
|
slotFillerType: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.variableName,
|
||||||
},
|
},
|
||||||
// Fill more than one quantity in a slot, like feats and ability score
|
// Fill more than one quantity in a slot, like feats and ability score
|
||||||
// improvements, filtered out of UI if there isn't space in quantityExpected
|
// improvements, filtered out of UI if there isn't space in quantityExpected
|
||||||
@@ -32,6 +36,7 @@ let SlotFillerSchema = new SimpleSchema({
|
|||||||
slotFillerCondition: {
|
slotFillerCondition: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.calculation,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,30 +1,66 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
import ErrorSchema from '/imports/api/properties/subSchemas/ErrorSchema.js';
|
import ErrorSchema from '/imports/api/properties/subSchemas/ErrorSchema.js';
|
||||||
|
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||||
|
|
||||||
let SlotSchema = new SimpleSchema({
|
let SlotSchema = new SimpleSchema({
|
||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
},
|
},
|
||||||
description: {
|
description: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.description,
|
||||||
},
|
},
|
||||||
slotType: {
|
slotType: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.variableName,
|
||||||
},
|
},
|
||||||
slotTags: {
|
slotTags: {
|
||||||
type: Array,
|
type: Array,
|
||||||
defaultValue: [],
|
defaultValue: [],
|
||||||
|
maxCount: STORAGE_LIMITS.tagCount,
|
||||||
},
|
},
|
||||||
'slotTags.$': {
|
'slotTags.$': {
|
||||||
type: String,
|
type: String,
|
||||||
|
max: STORAGE_LIMITS.tagLength,
|
||||||
|
},
|
||||||
|
extraTags: {
|
||||||
|
type: Array,
|
||||||
|
defaultValue: [],
|
||||||
|
maxCount: STORAGE_LIMITS.extraTagsCount,
|
||||||
|
},
|
||||||
|
'extraTags.$': {
|
||||||
|
type: Object,
|
||||||
|
},
|
||||||
|
'extraTags.$._id': {
|
||||||
|
type: String,
|
||||||
|
regEx: SimpleSchema.RegEx.Id,
|
||||||
|
autoValue(){
|
||||||
|
if (!this.isSet) return Random.id();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'extraTags.$.operation': {
|
||||||
|
type: String,
|
||||||
|
allowedValues: ['OR', 'NOT'],
|
||||||
|
defaultValue: 'OR',
|
||||||
|
},
|
||||||
|
'extraTags.$.tags': {
|
||||||
|
type: Array,
|
||||||
|
defaultValue: [],
|
||||||
|
maxCount: STORAGE_LIMITS.tagCount,
|
||||||
|
},
|
||||||
|
'extraTags.$.tags.$': {
|
||||||
|
type: String,
|
||||||
|
max: STORAGE_LIMITS.tagLength,
|
||||||
},
|
},
|
||||||
quantityExpected: {
|
quantityExpected: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
defaultValue: '1',
|
defaultValue: '1',
|
||||||
|
max: STORAGE_LIMITS.calculation,
|
||||||
},
|
},
|
||||||
ignored: {
|
ignored: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
@@ -33,11 +69,24 @@ let SlotSchema = new SimpleSchema({
|
|||||||
slotCondition: {
|
slotCondition: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.calculation,
|
||||||
},
|
},
|
||||||
hideWhenFull: {
|
hideWhenFull: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
optional: true,
|
optional: true,
|
||||||
}
|
defaultValue: true,
|
||||||
|
},
|
||||||
|
unique: {
|
||||||
|
type: String,
|
||||||
|
allowedValues: [
|
||||||
|
// Can't choose the same slot filler twice in this slot
|
||||||
|
'uniqueInSlot',
|
||||||
|
// Can't choose the same slot filler twice accross the whole creature
|
||||||
|
'uniqueInCreature'
|
||||||
|
],
|
||||||
|
optional: true,
|
||||||
|
defaultValue: 'uniqueInSlot',
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const ComputedOnlySlotSchema = new SimpleSchema({
|
const ComputedOnlySlotSchema = new SimpleSchema({
|
||||||
@@ -49,6 +98,7 @@ const ComputedOnlySlotSchema = new SimpleSchema({
|
|||||||
slotConditionErrors: {
|
slotConditionErrors: {
|
||||||
type: Array,
|
type: Array,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
maxCount: STORAGE_LIMITS.errorCount,
|
||||||
},
|
},
|
||||||
'slotConditionErrors.$':{
|
'slotConditionErrors.$':{
|
||||||
type: ErrorSchema,
|
type: ErrorSchema,
|
||||||
@@ -62,6 +112,7 @@ const ComputedOnlySlotSchema = new SimpleSchema({
|
|||||||
quantityExpectedErrors: {
|
quantityExpectedErrors: {
|
||||||
type: Array,
|
type: Array,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
maxCount: STORAGE_LIMITS.errorCount,
|
||||||
},
|
},
|
||||||
'quantityExpectedErrors.$':{
|
'quantityExpectedErrors.$':{
|
||||||
type: ErrorSchema,
|
type: ErrorSchema,
|
||||||
|
|||||||
@@ -1,37 +1,36 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
import ErrorSchema from '/imports/api/properties/subSchemas/ErrorSchema.js';
|
import ErrorSchema from '/imports/api/properties/subSchemas/ErrorSchema.js';
|
||||||
import VARIABLE_NAME_REGEX from '/imports/constants/VARIABLE_NAME_REGEX.js';
|
|
||||||
import InlineComputationSchema from '/imports/api/properties/subSchemas/InlineComputationSchema.js';
|
import InlineComputationSchema from '/imports/api/properties/subSchemas/InlineComputationSchema.js';
|
||||||
|
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||||
|
|
||||||
let SpellListSchema = new SimpleSchema({
|
let SpellListSchema = new SimpleSchema({
|
||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
},
|
},
|
||||||
description: {
|
description: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.description,
|
||||||
},
|
},
|
||||||
variableName: {
|
|
||||||
type: String,
|
|
||||||
regEx: VARIABLE_NAME_REGEX,
|
|
||||||
min: 2,
|
|
||||||
optional: true,
|
|
||||||
},
|
|
||||||
// Calculation of how many spells in this list can be prepared
|
// Calculation of how many spells in this list can be prepared
|
||||||
maxPrepared: {
|
maxPrepared: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.calculation,
|
||||||
},
|
},
|
||||||
// Calculation of The attack roll bonus used by spell attacks in this list
|
// Calculation of The attack roll bonus used by spell attacks in this list
|
||||||
attackRollBonus: {
|
attackRollBonus: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.calculation,
|
||||||
},
|
},
|
||||||
// Calculation of the save dc used by spells in this list
|
// Calculation of the save dc used by spells in this list
|
||||||
dc: {
|
dc: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.calculation,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -39,7 +38,7 @@ const ComputedOnlySpellListSchema = new SimpleSchema({
|
|||||||
descriptionCalculations: {
|
descriptionCalculations: {
|
||||||
type: Array,
|
type: Array,
|
||||||
defaultValue: [],
|
defaultValue: [],
|
||||||
maxCount: 32,
|
maxCount: STORAGE_LIMITS.inlineCalculationCount,
|
||||||
},
|
},
|
||||||
'descriptionCalculations.$': InlineComputationSchema,
|
'descriptionCalculations.$': InlineComputationSchema,
|
||||||
|
|
||||||
@@ -51,6 +50,7 @@ const ComputedOnlySpellListSchema = new SimpleSchema({
|
|||||||
maxPreparedErrors: {
|
maxPreparedErrors: {
|
||||||
type: Array,
|
type: Array,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
maxCount: STORAGE_LIMITS.errorCount,
|
||||||
},
|
},
|
||||||
'maxPreparedErrors.$':{
|
'maxPreparedErrors.$':{
|
||||||
type: ErrorSchema,
|
type: ErrorSchema,
|
||||||
@@ -64,6 +64,7 @@ const ComputedOnlySpellListSchema = new SimpleSchema({
|
|||||||
attackRollBonusErrors: {
|
attackRollBonusErrors: {
|
||||||
type: Array,
|
type: Array,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
maxCount: STORAGE_LIMITS.errorCount,
|
||||||
},
|
},
|
||||||
'attackRollBonusErrors.$':{
|
'attackRollBonusErrors.$':{
|
||||||
type: ErrorSchema,
|
type: ErrorSchema,
|
||||||
@@ -77,6 +78,7 @@ const ComputedOnlySpellListSchema = new SimpleSchema({
|
|||||||
dcErrors: {
|
dcErrors: {
|
||||||
type: Array,
|
type: Array,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
maxCount: STORAGE_LIMITS.errorCount,
|
||||||
},
|
},
|
||||||
'dcErrors.$':{
|
'dcErrors.$':{
|
||||||
type: ErrorSchema,
|
type: ErrorSchema,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { ActionSchema, ComputedOnlyActionSchema } 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';
|
||||||
|
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||||
|
|
||||||
const magicSchools = [
|
const magicSchools = [
|
||||||
'abjuration',
|
'abjuration',
|
||||||
@@ -18,6 +19,7 @@ let SpellSchema = new SimpleSchema({})
|
|||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
},
|
},
|
||||||
// If it's always prepared, it doesn't count against the number of spells
|
// If it's always prepared, it doesn't count against the number of spells
|
||||||
// prepared in a spell list, and enabled should be true
|
// prepared in a spell list, and enabled should be true
|
||||||
@@ -42,15 +44,18 @@ let SpellSchema = new SimpleSchema({})
|
|||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
defaultValue: 'action',
|
defaultValue: 'action',
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
},
|
},
|
||||||
range: {
|
range: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
},
|
},
|
||||||
duration: {
|
duration: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
defaultValue: 'Instantaneous',
|
defaultValue: 'Instantaneous',
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
},
|
},
|
||||||
verbal: {
|
verbal: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
@@ -67,6 +72,7 @@ let SpellSchema = new SimpleSchema({})
|
|||||||
material: {
|
material: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
},
|
},
|
||||||
ritual: {
|
ritual: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
|
|||||||
@@ -1,10 +1,12 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
import ErrorSchema from '/imports/api/properties/subSchemas/ErrorSchema.js';
|
import ErrorSchema from '/imports/api/properties/subSchemas/ErrorSchema.js';
|
||||||
|
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||||
|
|
||||||
const ToggleSchema = new SimpleSchema({
|
const ToggleSchema = new SimpleSchema({
|
||||||
name: {
|
name: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
},
|
},
|
||||||
disabled: {
|
disabled: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
@@ -19,6 +21,7 @@ const ToggleSchema = new SimpleSchema({
|
|||||||
condition: {
|
condition: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.calculation,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -32,6 +35,7 @@ const ComputedOnlyToggleSchema = new SimpleSchema({
|
|||||||
errors: {
|
errors: {
|
||||||
type: Array,
|
type: Array,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
maxCount: STORAGE_LIMITS.errorCount,
|
||||||
},
|
},
|
||||||
'errors.$': {
|
'errors.$': {
|
||||||
type: ErrorSchema,
|
type: ErrorSchema,
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import { FolderSchema } from '/imports/api/properties/Folders.js';
|
|||||||
import { ComputedOnlyItemSchema } from '/imports/api/properties/Items.js';
|
import { ComputedOnlyItemSchema } from '/imports/api/properties/Items.js';
|
||||||
import { ComputedOnlyNoteSchema } from '/imports/api/properties/Notes.js';
|
import { ComputedOnlyNoteSchema } from '/imports/api/properties/Notes.js';
|
||||||
import { ProficiencySchema } from '/imports/api/properties/Proficiencies.js';
|
import { ProficiencySchema } from '/imports/api/properties/Proficiencies.js';
|
||||||
|
import { ReferenceSchema } from '/imports/api/properties/References.js';
|
||||||
import { ComputedOnlyRollSchema } from '/imports/api/properties/Rolls.js';
|
import { ComputedOnlyRollSchema } from '/imports/api/properties/Rolls.js';
|
||||||
import { ComputedOnlySavingThrowSchema } from '/imports/api/properties/SavingThrows.js';
|
import { ComputedOnlySavingThrowSchema } from '/imports/api/properties/SavingThrows.js';
|
||||||
import { ComputedOnlySkillSchema } from '/imports/api/properties/Skills.js';
|
import { ComputedOnlySkillSchema } from '/imports/api/properties/Skills.js';
|
||||||
@@ -42,6 +43,7 @@ const propertySchemasIndex = {
|
|||||||
note: ComputedOnlyNoteSchema,
|
note: ComputedOnlyNoteSchema,
|
||||||
proficiency: ProficiencySchema,
|
proficiency: ProficiencySchema,
|
||||||
propertySlot: ComputedOnlySlotSchema,
|
propertySlot: ComputedOnlySlotSchema,
|
||||||
|
reference: ReferenceSchema,
|
||||||
roll: ComputedOnlyRollSchema,
|
roll: ComputedOnlyRollSchema,
|
||||||
savingThrow: ComputedOnlySavingThrowSchema,
|
savingThrow: ComputedOnlySavingThrowSchema,
|
||||||
skill: ComputedOnlySkillSchema,
|
skill: ComputedOnlySkillSchema,
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import { FolderSchema } from '/imports/api/properties/Folders.js';
|
|||||||
import { ComputedItemSchema } from '/imports/api/properties/Items.js';
|
import { ComputedItemSchema } from '/imports/api/properties/Items.js';
|
||||||
import { ComputedNoteSchema } from '/imports/api/properties/Notes.js';
|
import { ComputedNoteSchema } from '/imports/api/properties/Notes.js';
|
||||||
import { ProficiencySchema } from '/imports/api/properties/Proficiencies.js';
|
import { ProficiencySchema } from '/imports/api/properties/Proficiencies.js';
|
||||||
|
import { ReferenceSchema } from '/imports/api/properties/References.js';
|
||||||
import { ComputedRollSchema } from '/imports/api/properties/Rolls.js';
|
import { ComputedRollSchema } from '/imports/api/properties/Rolls.js';
|
||||||
import { ComputedSavingThrowSchema } from '/imports/api/properties/SavingThrows.js';
|
import { ComputedSavingThrowSchema } from '/imports/api/properties/SavingThrows.js';
|
||||||
import { ComputedSkillSchema } from '/imports/api/properties/Skills.js';
|
import { ComputedSkillSchema } from '/imports/api/properties/Skills.js';
|
||||||
@@ -40,6 +41,7 @@ const propertySchemasIndex = {
|
|||||||
note: ComputedNoteSchema,
|
note: ComputedNoteSchema,
|
||||||
proficiency: ProficiencySchema,
|
proficiency: ProficiencySchema,
|
||||||
propertySlot: ComputedSlotSchema,
|
propertySlot: ComputedSlotSchema,
|
||||||
|
reference: ReferenceSchema,
|
||||||
roll: ComputedRollSchema,
|
roll: ComputedRollSchema,
|
||||||
savingThrow: ComputedSavingThrowSchema,
|
savingThrow: ComputedSavingThrowSchema,
|
||||||
skill: ComputedSkillSchema,
|
skill: ComputedSkillSchema,
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import { FeatureSchema } from '/imports/api/properties/Features.js';
|
|||||||
import { FolderSchema } from '/imports/api/properties/Folders.js';
|
import { FolderSchema } from '/imports/api/properties/Folders.js';
|
||||||
import { NoteSchema } from '/imports/api/properties/Notes.js';
|
import { NoteSchema } from '/imports/api/properties/Notes.js';
|
||||||
import { ProficiencySchema } from '/imports/api/properties/Proficiencies.js';
|
import { ProficiencySchema } from '/imports/api/properties/Proficiencies.js';
|
||||||
|
import { ReferenceSchema } from '/imports/api/properties/References.js';
|
||||||
import { RollSchema } from '/imports/api/properties/Rolls.js';
|
import { RollSchema } from '/imports/api/properties/Rolls.js';
|
||||||
import { SavingThrowSchema } from '/imports/api/properties/SavingThrows.js';
|
import { SavingThrowSchema } from '/imports/api/properties/SavingThrows.js';
|
||||||
import { SkillSchema } from '/imports/api/properties/Skills.js';
|
import { SkillSchema } from '/imports/api/properties/Skills.js';
|
||||||
@@ -40,6 +41,7 @@ const propertySchemasIndex = {
|
|||||||
note: NoteSchema,
|
note: NoteSchema,
|
||||||
proficiency: ProficiencySchema,
|
proficiency: ProficiencySchema,
|
||||||
propertySlot: SlotSchema,
|
propertySlot: SlotSchema,
|
||||||
|
reference: ReferenceSchema,
|
||||||
roll: RollSchema,
|
roll: RollSchema,
|
||||||
savingThrow: SavingThrowSchema,
|
savingThrow: SavingThrowSchema,
|
||||||
skill: SkillSchema,
|
skill: SkillSchema,
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
|
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||||
|
|
||||||
const ErrorSchema = new SimpleSchema({
|
const ErrorSchema = new SimpleSchema({
|
||||||
message: {
|
message: {
|
||||||
type: String,
|
type: String,
|
||||||
|
max: STORAGE_LIMITS.errorMessage,
|
||||||
},
|
},
|
||||||
type: {
|
type: {
|
||||||
type: String,
|
type: String,
|
||||||
|
max: STORAGE_LIMITS.name,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +1,22 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
import ErrorSchema from '/imports/api/properties/subSchemas/ErrorSchema.js';
|
import ErrorSchema from '/imports/api/properties/subSchemas/ErrorSchema.js';
|
||||||
|
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||||
|
|
||||||
const InlineComputationSchema = new SimpleSchema({
|
const InlineComputationSchema = new SimpleSchema({
|
||||||
// The part between bracers {}
|
// The part between bracers {}
|
||||||
calculation: {
|
calculation: {
|
||||||
type: String,
|
type: String,
|
||||||
|
max: STORAGE_LIMITS.calculation,
|
||||||
},
|
},
|
||||||
result: {
|
result: {
|
||||||
type: String,
|
type: String,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
max: STORAGE_LIMITS.calculation,
|
||||||
},
|
},
|
||||||
errors: {
|
errors: {
|
||||||
type: Array,
|
type: Array,
|
||||||
optional: true,
|
optional: true,
|
||||||
|
maxCount: STORAGE_LIMITS.errorCount,
|
||||||
},
|
},
|
||||||
'errors.$': ErrorSchema,
|
'errors.$': ErrorSchema,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
|
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||||
|
|
||||||
const RollDetailsSchema = new SimpleSchema({
|
const RollDetailsSchema = new SimpleSchema({
|
||||||
number: {
|
number: {
|
||||||
@@ -10,6 +11,7 @@ const RollDetailsSchema = new SimpleSchema({
|
|||||||
values: {
|
values: {
|
||||||
type: Array,
|
type: Array,
|
||||||
defaultValue: [],
|
defaultValue: [],
|
||||||
|
maxCount: STORAGE_LIMITS.diceRollValuesCount,
|
||||||
},
|
},
|
||||||
'values.$': {
|
'values.$': {
|
||||||
type: Number,
|
type: Number,
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import SimpleSchema from 'simpl-schema';
|
import SimpleSchema from 'simpl-schema';
|
||||||
import '/imports/api/sharing/sharing.js';
|
import '/imports/api/sharing/sharing.js';
|
||||||
|
import STORAGE_LIMITS from '/imports/constants/STORAGE_LIMITS.js';
|
||||||
|
|
||||||
let SharingSchema = new SimpleSchema({
|
let SharingSchema = new SimpleSchema({
|
||||||
owner: {
|
owner: {
|
||||||
@@ -11,9 +12,9 @@ let SharingSchema = new SimpleSchema({
|
|||||||
type: Array,
|
type: Array,
|
||||||
defaultValue: [],
|
defaultValue: [],
|
||||||
index: 1,
|
index: 1,
|
||||||
max: 50,
|
maxCount: STORAGE_LIMITS.readersCount,
|
||||||
},
|
},
|
||||||
"readers.$": {
|
'readers.$': {
|
||||||
type: String,
|
type: String,
|
||||||
regEx: SimpleSchema.RegEx.Id
|
regEx: SimpleSchema.RegEx.Id
|
||||||
},
|
},
|
||||||
@@ -21,9 +22,9 @@ let SharingSchema = new SimpleSchema({
|
|||||||
type: Array,
|
type: Array,
|
||||||
defaultValue: [],
|
defaultValue: [],
|
||||||
index: 1,
|
index: 1,
|
||||||
max: 20,
|
maxCount: STORAGE_LIMITS.writersCount,
|
||||||
},
|
},
|
||||||
"writers.$": {
|
'writers.$': {
|
||||||
type: String,
|
type: String,
|
||||||
regEx: SimpleSchema.RegEx.Id
|
regEx: SimpleSchema.RegEx.Id
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ 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';
|
import { RateLimiterMixin } from 'ddp-rate-limiter-mixin';
|
||||||
|
import { getUserTier } from '/imports/api/users/patreon/tiers.js';
|
||||||
|
|
||||||
const setPublic = new ValidatedMethod({
|
const setPublic = new ValidatedMethod({
|
||||||
name: 'sharing.setPublic',
|
name: 'sharing.setPublic',
|
||||||
@@ -47,7 +48,7 @@ const updateUserSharePermissions = new ValidatedMethod({
|
|||||||
run({docRef, userId, role}){
|
run({docRef, userId, role}){
|
||||||
let doc = fetchDocByRef(docRef);
|
let doc = fetchDocByRef(docRef);
|
||||||
if (role === 'none'){
|
if (role === 'none'){
|
||||||
// only asser ownership if you aren't removing yourself
|
// only assert ownership if you aren't removing yourself
|
||||||
if (this.userId !== userId){
|
if (this.userId !== userId){
|
||||||
assertOwnership(doc, this.userId);
|
assertOwnership(doc, this.userId);
|
||||||
}
|
}
|
||||||
@@ -74,4 +75,58 @@ const updateUserSharePermissions = new ValidatedMethod({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
export { setPublic, updateUserSharePermissions };
|
const transferOwnership = new ValidatedMethod({
|
||||||
|
name: 'sharing.transferOwnership',
|
||||||
|
validate: new SimpleSchema({
|
||||||
|
docRef: RefSchema,
|
||||||
|
userId: {
|
||||||
|
type: String,
|
||||||
|
regEx: SimpleSchema.RegEx.Id,
|
||||||
|
},
|
||||||
|
}).validator(),
|
||||||
|
mixins: [RateLimiterMixin],
|
||||||
|
rateLimit: {
|
||||||
|
numRequests: 5,
|
||||||
|
timeInterval: 5000,
|
||||||
|
},
|
||||||
|
run({docRef, userId}){
|
||||||
|
let doc = fetchDocByRef(docRef);
|
||||||
|
assertOwnership(doc, this.userId);
|
||||||
|
|
||||||
|
let collection = getCollectionByName(docRef.collection);
|
||||||
|
|
||||||
|
let tier = getUserTier(userId);
|
||||||
|
if (docRef.collection === 'creatures'){
|
||||||
|
let currentCharacterCount = collection.find({
|
||||||
|
owner: userId,
|
||||||
|
}, {
|
||||||
|
fields: {_id: 1},
|
||||||
|
}).count();
|
||||||
|
|
||||||
|
if (
|
||||||
|
tier.characterSlots !== -1 &&
|
||||||
|
currentCharacterCount >= tier.characterSlots
|
||||||
|
){
|
||||||
|
throw new Meteor.Error('Sharing.methods.transferOwnership.denied',
|
||||||
|
'The new owner is already at their character limit')
|
||||||
|
}
|
||||||
|
} else if (docRef.collection === 'libraries'){
|
||||||
|
if (!tier.paidBenefits){
|
||||||
|
throw new Meteor.Error('Sharing.methods.transferOwnership.denied',
|
||||||
|
'The new owner\'s Patreon tier does not have access to library ownership');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// First remove current permissions for the user
|
||||||
|
collection.update(docRef.id, {
|
||||||
|
$pullAll: { writers: userId, readers: userId },
|
||||||
|
});
|
||||||
|
// Then make the user the owner and the current owner a writer
|
||||||
|
return collection.update(docRef.id, {
|
||||||
|
$set: {owner: userId},
|
||||||
|
$addToSet: { writers: this.userId },
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
export { setPublic, updateUserSharePermissions, transferOwnership };
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
import { _ } from 'meteor/underscore';
|
import { _ } from 'meteor/underscore';
|
||||||
import fetchDocByRef from '/imports/api/parenting/fetchDocByRef.js';
|
import fetchDocByRef from '/imports/api/parenting/fetchDocByRef.js';
|
||||||
import { getUserTier } from '/imports/api/users/patreon/tiers.js';
|
|
||||||
|
|
||||||
function assertIdValid(userId){
|
function assertIdValid(userId){
|
||||||
if (!userId || typeof userId !== 'string'){
|
if (!userId || typeof userId !== 'string'){
|
||||||
@@ -12,7 +11,7 @@ function assertIdValid(userId){
|
|||||||
function assertdocExists(doc){
|
function assertdocExists(doc){
|
||||||
if (!doc){
|
if (!doc){
|
||||||
throw new Meteor.Error('Permission denied',
|
throw new Meteor.Error('Permission denied',
|
||||||
'No such document exists');
|
'Permission denied: No such document exists');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -48,13 +47,6 @@ export function assertEditPermission(doc, userId) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure the user is of a tier with paid benefits
|
|
||||||
let tier = getUserTier(user);
|
|
||||||
if (!tier.paidBenefits){
|
|
||||||
throw new Meteor.Error('Edit permission denied',
|
|
||||||
`The ${tier.name} tier does not allow you to edit this document`);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ensure the user is authorized for this specific document
|
// Ensure the user is authorized for this specific document
|
||||||
if (
|
if (
|
||||||
doc.owner === userId ||
|
doc.owner === userId ||
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user