Fixed broken logging for actions

This commit is contained in:
Stefan Zermatten
2020-10-14 11:33:25 +02:00
parent bde9183158
commit d2cb86ac27
3 changed files with 9 additions and 13 deletions

View File

@@ -4,7 +4,8 @@ import {insertCreatureLog} from '/imports/api/creature/log/CreatureLogs.js';
export default function applyAction({prop, creature}){
spendResources(prop);
insertCreatureLog.call({
log: prop.name,
creatureId: creature._id,
log: {
text: prop.name,
creatureId: creature._id},
});
}

View File

@@ -10,7 +10,9 @@ export default function applyAttack({
}){
let result = math.roll(1, 20) + prop.rollBonusResult;
insertCreatureLog.call({
log: `${prop.name} attack. ${result} to hit`,
creatureId: creature._id,
log: {
text: `${prop.name} attack. ${result} to hit`,
creatureId: creature._id,
}
});
}

View File

@@ -74,12 +74,9 @@ const insertCreatureLog = new ValidatedMethod({
},
validate: new SimpleSchema({
log: CreatureLogSchema.omit('type', 'date'),
creatureId: {
type: String,
regEx: SimpleSchema.RegEx.Id,
},
}).validator(),
run({log, creatureId}){
run({log}){
const creatureId = log.creatureId;
const creature = Creatures.findOne(creatureId, {fields: {
readers: 1,
writers: 1,
@@ -93,10 +90,6 @@ const insertCreatureLog = new ValidatedMethod({
if (typeof log === 'string'){
log = {text: log};
}
if (Meteor.isServer){
Meteor._sleepForMs(5000);
}
log.creatureId = creatureId;
log.date = new Date();
// Insert it
let id = CreatureLogs.insert(log);