This commit is contained in:
choelzl 2022-02-14 15:16:07 +01:00
parent 2f392585df
commit 14a4ca4efd
Signed by: sora
GPG Key ID: A362EA0491E2EEA0

View File

@ -108,14 +108,15 @@
streak: 0, streak: 0,
}); });
guesses.round = seed.round - 1; guesses.round = seed.round - 1;
sendData('guesses',JSON.stringify(guesses)); sendGuessData();
} }
function sendData(tpe, data) { function sendGuessData() {
guesses.rounds = seed.rounds;
$.panelsocketserver.sendJSONToAll(JSON.stringify({ $.panelsocketserver.sendJSONToAll(JSON.stringify({
'eventFamily': 'chatguessr', 'eventFamily': 'chatguessr',
'eventType': tpe, 'eventType': 'guesse',
'data': data 'data': JSON.stringify(guesses)
})); }));
} }
@ -139,12 +140,12 @@
seed = fetchSeed(args[1]); seed = fetchSeed(args[1]);
scale = calculateScale(seed.bounds); scale = calculateScale(seed.bounds);
guesses.round = seed.round - 1; guesses.round = seed.round - 1;
sendData('guesses',JSON.stringify(guesses)); sendGuessData();
}else if(action.equalsIgnoreCase('end')){ }else if(action.equalsIgnoreCase('end')){
$.setIniDbBoolean('cgstatus', 'isOpen', false) $.setIniDbBoolean('cgstatus', 'isOpen', false)
guesses = {}; guesses = {};
seed = {}; seed = {};
sendData('guesses',JSON.stringify(guesses)); sendGuessData();
}else if(action.equalsIgnoreCase('refresh')){ }else if(action.equalsIgnoreCase('refresh')){
if(seed.token == undefined) return; if(seed.token == undefined) return;
var newseed = fetchSeed(seed.token); var newseed = fetchSeed(seed.token);
@ -156,22 +157,21 @@
if(newseed.state=="finished"){ if(newseed.state=="finished"){
$.setIniDbBoolean('chatguessr', 'isOpen',false) //FINISHED $.setIniDbBoolean('chatguessr', 'isOpen',false) //FINISHED
//Compute total scores + give reward //Compute total scores + give reward
sendGuessData();
}else{ }else{
$.setIniDbBoolean('chatguessr', 'isOpen',true) //NEW ROUD /Guess $.setIniDbBoolean('chatguessr', 'isOpen',true) //NEW ROUD /Guess
guesses.round = seed.round - 1; guesses.round = seed.round - 1;
sendData('guesses',JSON.stringify(guesses)); sendGuessData();
} }
} }
seed = newseed; seed = newseed;
}else if(action.equalsIgnoreCase('gg')){ }else if(action.equalsIgnoreCase('gg')){
sendData('guesses',JSON.stringify(guesses)); sendGuessData();
}else if(action.equalsIgnoreCase('fg')){ }else if(action.equalsIgnoreCase('fg')){
addGuess("Alpha","0,0"); addGuess("Alpha","0,0");
addGuess("Beta","40,0"); addGuess("Beta","40,0");
addGuess("Charlie","0,60"); addGuess("Charlie","0,60");
addGuess("Delta","80,80"); addGuess("Delta","80,80");
guesses.round = seed.round - 1;
sendData('guesses',JSON.stringify(guesses));
} }
} }
}); });