]> git.cworth.org Git - lmno-server/blobdiff - empathy.js
Fix bug with incorrect scoring based on capitalization
[lmno-server] / empathy.js
index 028117db344b575919a86da6b6979fb967e7c518..e80c1af34e0644b13ba898c38d6e0ec464a5542b 100644 (file)
@@ -144,7 +144,9 @@ class Empathy extends Game {
       }
     }
 
-    this.state.ambiguities = Object.values(word_map);
+    this.state.ambiguities = Object.values(word_map).sort((a,b) => {
+      return a.toLowerCase().localeCompare(b.toLowerCase());
+    });
 
     this.broadcast_event_object('ambiguities', this.state.ambiguities);
   }
@@ -264,7 +266,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.