|
|
@@ -135,6 +135,7 @@ const ScoreUtils = (function() {
|
|
|
scores = this.sort((a, b) => b.score - a.score);
|
|
|
var newIndex = this.getRank(pseudo) -1;
|
|
|
var result = { newRank: newIndex +1, oldRank: oldIndex +1 };
|
|
|
+ result.exaequo = this.filter(i => i.score === score && i.name !== pseudo);
|
|
|
if (newIndex < 0 || newIndex === oldIndex)
|
|
|
return result;
|
|
|
result.users = this.slice(newIndex +1, oldIndex +1);
|
|
|
@@ -418,11 +419,15 @@ QuizzBot.prototype.resetScores = function() {
|
|
|
* @return a string with a message to be displayed or null if nothing to say
|
|
|
**/
|
|
|
QuizzBot.prototype.buildOverpassedMessage = function(username, diff) {
|
|
|
+ var exaequo = null;
|
|
|
+ if (diff.exaequo.length)
|
|
|
+ exaequo = " est aux coude a coude avec " +diff.exaequo.map(i => i.name).join(", ");
|
|
|
if (!diff.users || !diff.users.length)
|
|
|
- return null;
|
|
|
+ return exaequo ? (username +exaequo) : null;
|
|
|
+ exaequo = " et" +exaequo;
|
|
|
const rankStr = diff.newRank == 1 ? "1ere" : `${diff.newRank}eme`;
|
|
|
if (diff.users.length > 1) // Advanced too much rank at once ! Only display new position
|
|
|
- return `${username} prend la ${rankStr} place !`;
|
|
|
+ return `${username} prend la ${rankStr} place ` +(exaequo || "!");
|
|
|
|
|
|
const looser = diff.users[0].name,
|
|
|
insults = [
|
|
|
@@ -435,7 +440,8 @@ QuizzBot.prototype.buildOverpassedMessage = function(username, diff) {
|
|
|
() => `La ${rankStr} place est maintenant la propriété de ${username} qui a envoyé ${looser} au tapis`,
|
|
|
() => `${username} tatoue un gros L de la loose sur le front de ${looser} qui vient de perdre la ${rankStr} place`
|
|
|
];
|
|
|
- return insults[Math.floor(Math.random() * insults.length)]();
|
|
|
+ var insultStr = insults[Math.floor(Math.random() * insults.length)]();
|
|
|
+ return insultStr +(exaequo || "!");
|
|
|
}
|
|
|
|
|
|
QuizzBot.prototype.onMessageInternal = function(username, user, msg) {
|