This commit is contained in:
choelzl 2022-02-14 17:56:00 +01:00
parent 2597a9ae30
commit e229355322
Signed by: sora
GPG Key ID: A362EA0491E2EEA0

View File

@ -120,6 +120,24 @@
}));
}
function accGuesses(){
var res = {};
for(var rr = 0; rr < guesses.round; ++rr){
for(var s = 0; s < guesses[rr].length; ++s){
if(!res[guesses[rr][s].user]){
res[guesses[rr][s].user] = {score:0,distance:0}
}
res[guesses[rr][s].user].score += guessses[rr][s].score
res[guesses[rr][s].user].distance += guessses[rr][s].distance
}
}
return Object.keys(res).map(k => {
let v = res[k]
v.user = k;
return v;
});
}
$.bind('command', function(event) {
const sender = event.getSender().toLowerCase(),
command = event.getCommand(),
@ -159,8 +177,9 @@
addGuess($.channelName,gp);
}else if(newseed.state=="finished"){
$.setIniDbBoolean('chatguessr', 'isOpen',false) //FINISHED
//Compute total scores + give reward
seed = newseed;
guesses.final = accGuesses()
//Compute total scores + give reward
sendGuessData();
}else{
$.setIniDbBoolean('chatguessr', 'isOpen',true) //NEW ROUD /Guess