X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=empathy.js;h=cfe0618d76f211a0e3ceeb69b017c3c90a187100;hb=99db5b01aba2ee48a13a7a591efc8812e23d0beb;hp=028117db344b575919a86da6b6979fb967e7c518;hpb=2a719335c919a492b2752e9ef7a35bc3c139b863;p=lmno-server diff --git a/empathy.js b/empathy.js index 028117d..cfe0618 100644 --- a/empathy.js +++ b/empathy.js @@ -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); } @@ -180,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 }; @@ -264,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.