Fixed jshint warnings

This commit is contained in:
Stefan Zermatten
2019-03-19 09:31:14 +02:00
parent ef83d54fd9
commit 1146d56324
2 changed files with 37 additions and 39 deletions

View File

@@ -6,7 +6,7 @@
"allowComments": true, "allowComments": true,
"allowRegex": true "allowRegex": true
}, },
"validateIndentation": "\t", "validateIndentation": " ",
"validateQuoteMarks": "\"", "validateQuoteMarks": "\"",
"disallowMultipleLineStrings": true, "disallowMultipleLineStrings": true,

View File

@@ -22,7 +22,7 @@ export const recomputeCreature = new ValidatedMethod({
run({charId}) { run({charId}) {
// Permission // Permission
assertEditPermission(charId, this.userId) assertEditPermission(charId, this.userId);
// Work, call this direcly if you are already in a method that has checked // Work, call this direcly if you are already in a method that has checked
// for permission to edit a given character // for permission to edit a given character
@@ -76,7 +76,7 @@ export function recomputeCreatureById(charId){
char = computeCreature(char); char = computeCreature(char);
writeCreature(char); writeCreature(char);
return char; return char;
}; }
/** /**
* Write the in-memory creature to the database docs * Write the in-memory creature to the database docs
@@ -91,7 +91,7 @@ function writeCreature(char) {
writeDamageMultipliers(char); writeDamageMultipliers(char);
writeEffects(char); writeEffects(char);
writeCreatureDoc(char); writeCreatureDoc(char);
}; }
function writeCreatureDoc(char) { function writeCreatureDoc(char) {
// Store all the variables, using the same priority as computation evaluation // Store all the variables, using the same priority as computation evaluation
@@ -116,7 +116,7 @@ function writeAttributes(char) {
value: att.result, value: att.result,
}}, }},
} }
} };
if (typeof att.mod === 'number'){ if (typeof att.mod === 'number'){
op.updateMany.update.$set.mod = att.mod; op.updateMany.update.$set.mod = att.mod;
} else { } else {
@@ -126,14 +126,14 @@ function writeAttributes(char) {
}); });
if (Meteor.isServer){ if (Meteor.isServer){
Attributes.rawCollection().bulkWrite(bulkWriteOps, {ordered : false}, function(e, r){ Attributes.rawCollection().bulkWrite(bulkWriteOps, {ordered : false}, function(e, r){
if (e) console.warn(JSON.stringify(e, null, 2)) if (e) console.warn(JSON.stringify(e, null, 2));
}); });
} else { } else {
_.each(bulkWriteOps, op => { _.each(bulkWriteOps, op => {
Attributes.update(op.updateMany.filter, op.updateMany.update, {multi: true}); Attributes.update(op.updateMany.filter, op.updateMany.update, {multi: true});
}); });
} }
}; }
function writeEffects(char){ function writeEffects(char){
let bulkWriteOps = _.map(char.computedEffects, effect => ({ let bulkWriteOps = _.map(char.computedEffects, effect => ({
@@ -146,7 +146,7 @@ function writeEffects(char){
})); }));
if (Meteor.isServer){ if (Meteor.isServer){
Effects.rawCollection().bulkWrite(bulkWriteOps, {ordered : false}, function(e, r){ Effects.rawCollection().bulkWrite(bulkWriteOps, {ordered : false}, function(e, r){
if (e) console.warn(JSON.stringify(e, null, 2)) if (e) console.warn(JSON.stringify(e, null, 2));
}); });
} else { } else {
_.each(bulkWriteOps, op => { _.each(bulkWriteOps, op => {
@@ -176,19 +176,19 @@ function writeSkills(char) {
fail: skill.fail, fail: skill.fail,
}}, }},
} }
} };
return op; return op;
}); });
if (Meteor.isServer){ if (Meteor.isServer){
Skills.rawCollection().bulkWrite( bulkWriteOps, {ordered : false}, function(e, r){ Skills.rawCollection().bulkWrite( bulkWriteOps, {ordered : false}, function(e, r){
if (e) console.warn(JSON.stringify(e, null, 2)) if (e) console.warn(JSON.stringify(e, null, 2));
}); });
} else { } else {
_.each(bulkWriteOps, op => { _.each(bulkWriteOps, op => {
Skills.update(op.updateMany.filter, op.updateMany.update, {multi: true}); Skills.update(op.updateMany.filter, op.updateMany.update, {multi: true});
}); });
} }
}; }
/** /**
* Write all the damange multipliers from the in-memory char object to the docs * Write all the damange multipliers from the in-memory char object to the docs
@@ -205,19 +205,19 @@ function writeDamageMultipliers(char) {
value: dm.result, value: dm.result,
}}, }},
} }
} };
return op; return op;
}); });
if (Meteor.isServer){ if (Meteor.isServer){
DamageMultipliers.rawCollection().bulkWrite( bulkWriteOps, {ordered : false}, function(e, r){ DamageMultipliers.rawCollection().bulkWrite( bulkWriteOps, {ordered : false}, function(e, r){
if (e) console.warn(JSON.stringify(e, null, 2)) if (e) console.warn(JSON.stringify(e, null, 2));
}); });
} else { } else {
_.each(bulkWriteOps, op => { _.each(bulkWriteOps, op => {
DamageMultipliers.update(op.updateMany.filter, op.updateMany.update, {multi: true}); DamageMultipliers.update(op.updateMany.filter, op.updateMany.update, {multi: true});
}); });
} }
}; }
/** /**
@@ -269,7 +269,7 @@ function buildCreature(charId){
get computed(){ get computed(){
return this.ability.computed; return this.ability.computed;
}, },
} };
} }
} }
}); });
@@ -306,7 +306,7 @@ function buildCreature(charId){
// Fetch the damage multipliers of the creature and store them // Fetch the damage multipliers of the creature and store them
DamageMultipliers.find({charId}).forEach(damageMultiplier =>{ DamageMultipliers.find({charId}).forEach(damageMultiplier =>{
const key = damageMultiplier.variableName const key = damageMultiplier.variableName;
if (!char.dms[key]){ if (!char.dms[key]){
char.dms[key] = { char.dms[key] = {
computed: false, computed: false,
@@ -326,9 +326,9 @@ function buildCreature(charId){
// Fetch the class levels and store them // Fetch the class levels and store them
// don't use the word "class" it's reserved // don't use the word "class" it's reserved
const levelOverwritten = !!char.variables['level'] const levelOverwritten = !!char.variables.level;
if (!levelOverwritten){ if (!levelOverwritten){
char.variables['level'] = { char.variables.level = {
result: 0, result: 0,
type: 'characterLevel', type: 'characterLevel',
computed: true, computed: true,
@@ -347,7 +347,7 @@ function buildCreature(charId){
}; };
} }
if (!levelOverwritten){ if (!levelOverwritten){
char.variables['level'].result = char.level; char.variables.level.result = char.level;
} }
} }
}); });
@@ -376,7 +376,7 @@ function buildCreature(charId){
result: 0, result: 0,
operation: effect.operation, operation: effect.operation,
calculation: effect.calculation, calculation: effect.calculation,
} };
if (char.atts[effect.stat]) { if (char.atts[effect.stat]) {
char.atts[effect.stat].effects.push(storedEffect); char.atts[effect.stat].effects.push(storedEffect);
} else if (char.skills[effect.stat]) { } else if (char.skills[effect.stat]) {
@@ -398,7 +398,7 @@ function buildCreature(charId){
} }
}); });
return char; return char;
}; }
/** /**
* Compute the creature's stats in-place, returns the same char object * Compute the creature's stats in-place, returns the same char object
@@ -409,22 +409,22 @@ export function computeCreature(char){
// Iterate over each stat in order and compute it // Iterate over each stat in order and compute it
let statName; let statName;
for (statName in char.atts){ for (statName in char.atts){
let stat = char.atts[statName] let stat = char.atts[statName];
computeStat (stat, char); computeStat (stat, char);
} }
for (statName in char.skills){ for (statName in char.skills){
let stat = char.skills[statName] let stat = char.skills[statName];
computeStat (stat, char); computeStat (stat, char);
} }
for (statName in char.dms){ for (statName in char.dms){
let stat = char.dms[statName] let stat = char.dms[statName];
computeStat (stat, char); computeStat (stat, char);
} }
for (let effect of char.otherEffects){ for (let effect of char.otherEffects){
computeEffect(effect, char); computeEffect(effect, char);
} }
return char; return char;
}; }
/** /**
@@ -455,7 +455,7 @@ function computeStat(stat, char){
// Iterate over each effect which applies to the stat // Iterate over each effect which applies to the stat
for (i in stat.effects){ for (let i in stat.effects){
computeEffect(stat.effects[i], char); computeEffect(stat.effects[i], char);
// apply the effect to the stat // apply the effect to the stat
applyEffect(stat.effects[i], stat); applyEffect(stat.effects[i], stat);
@@ -485,7 +485,7 @@ function computeEffect(effect, char){
} }
effect.computed = true; effect.computed = true;
char.computedEffects.push(effect); char.computedEffects.push(effect);
}; }
/** /**
* Apply a computed effect to its stat * Apply a computed effect to its stat
@@ -536,7 +536,7 @@ function applyEffect(effect, stat){
stat.conditional++; stat.conditional++;
break; break;
} }
}; }
/** /**
@@ -544,9 +544,9 @@ function applyEffect(effect, stat){
*/ */
function combineStat(stat, char){ function combineStat(stat, char){
if (stat.type === "attribute"){ if (stat.type === "attribute"){
combineAttribute(stat, char) combineAttribute(stat, char);
} else if (stat.type === "skill"){ } else if (stat.type === "skill"){
combineSkill(stat, char) combineSkill(stat, char);
} else if (stat.type === "damageMultiplier"){ } else if (stat.type === "damageMultiplier"){
combineDamageMultiplier(stat, char); combineDamageMultiplier(stat, char);
} }
@@ -571,7 +571,7 @@ function combineAttribute(stat, char){
* Combine skills results into final values * Combine skills results into final values
*/ */
function combineSkill(stat, char){ function combineSkill(stat, char){
for (i in stat.proficiencies){ for (let i in stat.proficiencies){
let prof = stat.proficiencies[i]; let prof = stat.proficiencies[i];
if (prof.value > stat.proficiency) stat.proficiency = prof.value; if (prof.value > stat.proficiency) stat.proficiency = prof.value;
} }
@@ -624,7 +624,7 @@ function getComputedValueOfKey(sub, char){
computeStat(stat, char); computeStat(stat, char);
} }
return stat.result; return stat.result;
}; }
/** /**
* Evaluate a string computation in the context of a char * Evaluate a string computation in the context of a char
@@ -656,9 +656,7 @@ function evaluateCalculation(string, char){
} catch (e){ } catch (e){
return substitutedCalc.toString(); return substitutedCalc.toString();
} }
}; }
/** /**
* recompute a character's XP from a given id * recompute a character's XP from a given id
@@ -671,7 +669,7 @@ export const recomputeCreatureXP = new ValidatedMethod({
}).validator(), }).validator(),
run({charId}) { run({charId}) {
assertEditPermission(charId, this.userId) assertEditPermission(charId, this.userId);
var xp = 0; var xp = 0;
Experiences.find( Experiences.find(
{charId: charId}, {charId: charId},
@@ -680,7 +678,7 @@ export const recomputeCreatureXP = new ValidatedMethod({
xp += e.value; xp += e.value;
}); });
Creatures.update(charId, {$set: {xp}}) Creatures.update(charId, {$set: {xp}});
return xp; return xp;
}, },
}); });
@@ -697,7 +695,7 @@ export const recomputeCreatureWeightCarried = new ValidatedMethod({
}).validator(), }).validator(),
run({charId}){ run({charId}){
assertEditPermission(charId, this.userId) assertEditPermission(charId, this.userId);
var weightCarried = 0; var weightCarried = 0;
// store a dictionary of carried containers // store a dictionary of carried containers
var carriedContainers = {}; var carriedContainers = {};
@@ -729,7 +727,7 @@ export const recomputeCreatureWeightCarried = new ValidatedMethod({
} }
}); });
Creatures.update(charId, {$set: {weightCarried}}) Creatures.update(charId, {$set: {weightCarried}});
return weightCarried; return weightCarried;
} }
}); });