]> git.cworth.org Git - empires-server/blobdiff - empathy.js
Force all submitted judging words to lowercase before mapping
[empires-server] / empathy.js
index 759b486f8b58b1814299c1fe6863bb17109b2917..cfe0618d76f211a0e3ceeb69b017c3c90a187100 100644 (file)
@@ -182,11 +182,13 @@ class Empathy extends Game {
             eq = [group[j], group[i]];
           }
 
-          const exist = this.equivalencies[`${eq[0]}:${eq[1]}`];
+          const key=`${this.canonize(eq[0])}:${this.canonize(eq[1])}`;
+
+          const exist = this.equivalencies[key];
           if (exist) {
             exist.count++;
           } else {
-            this.equivalencies[`${eq[0]}:${eq[1]}`] = {
+            this.equivalencies[key] = {
               count: 1,
               words: eq
             };
@@ -266,7 +268,8 @@ class Empathy extends Game {
      * multiple times). In contrast, iterating over"word_groups" will
      * have you visit each group only once. */
     const word_groups = Object.entries(word_maps).filter(
-      entry => entry[0] === entry[1].words[0]).map(entry => entry[1]);
+      entry => entry[0] === this.canonize(entry[1].words[0]))
+          .map(entry => entry[1]);
 
     /* Now, go through each word group and assign the scores out to
      * the corresponding players.