Merge branch 'develop' into version-2-tabletop
This commit is contained in:
@@ -1,8 +1,14 @@
|
||||
import { createS3FilesCollection } from '/imports/api/files/s3FileStorage.js';
|
||||
|
||||
import SimpleSchema from 'simpl-schema';
|
||||
import { incrementFileStorageUsed } from '/imports/api/users/methods/updateFileStorageUsed.js';
|
||||
import { CreaturePropertySchema } from '/imports/api/creature/creatureProperties/CreatureProperties.js';
|
||||
import { CreatureSchema } from '/imports/api/creature/creatures/Creatures.js';
|
||||
let createS3FilesCollection;
|
||||
if (Meteor.isServer) {
|
||||
createS3FilesCollection = require('/imports/api/files/server/s3FileStorage.js').createS3FilesCollection
|
||||
} else {
|
||||
createS3FilesCollection = require('/imports/api/files/client/s3FileStorage.js').createS3FilesCollection
|
||||
}
|
||||
|
||||
const ArchiveCreatureFiles = createS3FilesCollection({
|
||||
collectionName: 'archiveCreatureFiles',
|
||||
|
||||
@@ -83,13 +83,13 @@ export function resetProperties(creatureId, resetFilter, actionContext) {
|
||||
const attributeFilter = {
|
||||
...filter,
|
||||
type: 'attribute',
|
||||
damage: { $ne: 0 },
|
||||
damage: { $nin: [0, undefined] },
|
||||
}
|
||||
CreatureProperties.find(attributeFilter).forEach(prop => {
|
||||
damagePropertyWork({
|
||||
prop,
|
||||
operation: 'increment',
|
||||
value: -prop.damage,
|
||||
value: -prop.damage ?? 0,
|
||||
actionContext,
|
||||
logFunction(increment) {
|
||||
actionContext.addLog({
|
||||
@@ -105,7 +105,7 @@ export function resetProperties(creatureId, resetFilter, actionContext) {
|
||||
type: {
|
||||
$in: ['action', 'spell']
|
||||
},
|
||||
usesUsed: { $ne: 0 },
|
||||
usesUsed: { $nin: [0, undefined] },
|
||||
};
|
||||
CreatureProperties.find(actionFilter, {
|
||||
fields: { name: 1, usesUsed: 1 }
|
||||
|
||||
@@ -165,7 +165,7 @@ function rollAttack(attack, scope) {
|
||||
}
|
||||
scope['$attackDiceRoll'] = { value };
|
||||
const result = value + attack.value;
|
||||
scope['$attackRoll'] = { result };
|
||||
scope['$attackRoll'] = { value: result };
|
||||
const { criticalHit, criticalMiss } = applyCrits(value, scope);
|
||||
return { resultPrefix, result, value, criticalHit, criticalMiss };
|
||||
}
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
import { createS3FilesCollection } from '/imports/api/files/s3FileStorage.js';
|
||||
let createS3FilesCollection;
|
||||
if (Meteor.isServer) {
|
||||
createS3FilesCollection = require('/imports/api/files/server/s3FileStorage.js').createS3FilesCollection
|
||||
} else {
|
||||
createS3FilesCollection = require('/imports/api/files/client/s3FileStorage.js').createS3FilesCollection
|
||||
}
|
||||
|
||||
const UserImages = createS3FilesCollection({
|
||||
collectionName: 'userImages',
|
||||
|
||||
24
app/imports/api/files/client/s3FileStorage.js
Normal file
24
app/imports/api/files/client/s3FileStorage.js
Normal file
@@ -0,0 +1,24 @@
|
||||
// https://github.com/VeliovGroup/Meteor-Files/blob/master/docs/aws-s3-integration.md
|
||||
import { FilesCollection } from 'meteor/ostrio:files';
|
||||
|
||||
const createS3FilesCollection = function ({
|
||||
collectionName,
|
||||
storagePath,
|
||||
onBeforeUpload,
|
||||
onAfterUpload,
|
||||
debug,// = !Meteor.isProduction,
|
||||
allowClientCode = false,
|
||||
}) {
|
||||
const collection = new FilesCollection({
|
||||
collectionName,
|
||||
storagePath,
|
||||
onBeforeUpload,
|
||||
onAfterUpload,
|
||||
debug,
|
||||
allowClientCode,
|
||||
});
|
||||
|
||||
return collection;
|
||||
}
|
||||
|
||||
export { createS3FilesCollection };
|
||||
@@ -1,2 +0,0 @@
|
||||
import S3 from 'aws-sdk/clients/s3';
|
||||
export default S3;
|
||||
@@ -4,9 +4,7 @@ import { each, clone } from 'lodash';
|
||||
import { Random } from 'meteor/random';
|
||||
import { FilesCollection } from 'meteor/ostrio:files';
|
||||
import stream from 'stream';
|
||||
if (Meteor.isServer) {
|
||||
import S3 from '/imports/api/files/server/s3.js';
|
||||
}
|
||||
import S3 from 'aws-sdk/clients/s3';
|
||||
|
||||
/* See fs-extra and graceful-fs NPM packages */
|
||||
/* For better i/o performance */
|
||||
@@ -31,7 +29,7 @@ let createS3FilesCollection;
|
||||
|
||||
/* Check settings existence in `Meteor.settings` */
|
||||
/* This is the best practice for app security */
|
||||
if (Meteor.isServer && Meteor.settings.useS3) {
|
||||
if (Meteor.settings.useS3) {
|
||||
// Create a new S3 object
|
||||
const s3 = new S3({
|
||||
accessKeyId: s3Conf.key,
|
||||
@@ -236,13 +234,11 @@ if (Meteor.isServer && Meteor.settings.useS3) {
|
||||
allowClientCode,
|
||||
});
|
||||
|
||||
if (Meteor.isServer) {
|
||||
// Use the normal file system to read files
|
||||
collection.readJSONFile = async function (file) {
|
||||
const fileString = await fsp.readFile(file.path, 'utf8');
|
||||
return JSON.parse(fileString);
|
||||
};
|
||||
}
|
||||
// Use the normal file system to read files
|
||||
collection.readJSONFile = async function (file) {
|
||||
const fileString = await fsp.readFile(file.path, 'utf8');
|
||||
return JSON.parse(fileString);
|
||||
};
|
||||
|
||||
return collection;
|
||||
}
|
||||
Reference in New Issue
Block a user