From d82031ab0dd1bed2795dbb0fd239585a6b441b6e Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Thu, 27 Sep 2018 09:39:21 +0200 Subject: [PATCH] Added indices, fixed bugs --- app/Model/Creature/Attributes.js | 3 +++ app/Model/Creature/CharacterComputation.js | 3 +-- app/lib/constants/defaultCharacterStats.js | 1 + app/server/migrations/migrations.js | 2 +- 4 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/Model/Creature/Attributes.js b/app/Model/Creature/Attributes.js index c86f8f0a..e7abdad0 100644 --- a/app/Model/Creature/Attributes.js +++ b/app/Model/Creature/Attributes.js @@ -12,6 +12,7 @@ Schemas.Attribute = new SimpleSchema({ // The nice-to-read name name: { type: String, + index: 1, }, // The technical, lowercase, single-word name used in formulae variableName: { @@ -20,6 +21,7 @@ Schemas.Attribute = new SimpleSchema({ // Attributes need to store their order to keep the sheet consistent order: { type: Number, + index: 1, }, type: { type: String, @@ -32,6 +34,7 @@ Schemas.Attribute = new SimpleSchema({ "spellSlot", // Level 1, 2, 3... spell slots "utility", // Aren't displayed, Jump height, Carry capacity ], + index: 1, }, baseValue: { type: Number, diff --git a/app/Model/Creature/CharacterComputation.js b/app/Model/Creature/CharacterComputation.js index ae132ac7..254ef7a2 100644 --- a/app/Model/Creature/CharacterComputation.js +++ b/app/Model/Creature/CharacterComputation.js @@ -60,6 +60,7 @@ const computeCharacterById = function (charId){ let char = buildCharacter(); char = computeCharacter(char); writeCharacter(char); + return char; }; /* @@ -339,7 +340,6 @@ const computeEffect = function(effect, char){ effect.result = evaluateCalculation(effect.calculation, char); } effect.computed = true; - console.log({effect}); }; /* @@ -426,7 +426,6 @@ const combineAttribute = function(stat, char){ if (stat.attributeType === "ability") { stat.mod = Math.floor((stat.result - 10) / 2); } - console.log({statResult: stat.result}) } const combineSkill = function(stat, char){ diff --git a/app/lib/constants/defaultCharacterStats.js b/app/lib/constants/defaultCharacterStats.js index 56bdad59..f006beeb 100644 --- a/app/lib/constants/defaultCharacterStats.js +++ b/app/lib/constants/defaultCharacterStats.js @@ -150,4 +150,5 @@ getDefaultCharacterDocs = function(charId){ parent: _.clone(baseParent), }); } + return docs; } diff --git a/app/server/migrations/migrations.js b/app/server/migrations/migrations.js index 9c855c10..71ce0770 100644 --- a/app/server/migrations/migrations.js +++ b/app/server/migrations/migrations.js @@ -170,7 +170,7 @@ Migrations.add({ Skills.rawCollection().insert(defaultDocs.skills, {ordered: false}); DamageMultipliers.rawCollection().insert(defaultDocs.damageMultipliers, {ordered: false}); // Remove the stats on the character document - Characters.update(charId, modifier, function(error, result){ + Characters.update(charId, modifier, {validate: false}, function(error, result){ if (error) console.log(error); }); });