diff --git a/twitch/chatguessr.js b/twitch/chatguessr.js index e1b8e19..2cf057e 100644 --- a/twitch/chatguessr.js +++ b/twitch/chatguessr.js @@ -108,14 +108,15 @@ streak: 0, }); 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({ 'eventFamily': 'chatguessr', - 'eventType': tpe, - 'data': data + 'eventType': 'guesse', + 'data': JSON.stringify(guesses) })); } @@ -139,12 +140,12 @@ seed = fetchSeed(args[1]); scale = calculateScale(seed.bounds); guesses.round = seed.round - 1; - sendData('guesses',JSON.stringify(guesses)); + sendGuessData(); }else if(action.equalsIgnoreCase('end')){ $.setIniDbBoolean('cgstatus', 'isOpen', false) guesses = {}; seed = {}; - sendData('guesses',JSON.stringify(guesses)); + sendGuessData(); }else if(action.equalsIgnoreCase('refresh')){ if(seed.token == undefined) return; var newseed = fetchSeed(seed.token); @@ -156,22 +157,21 @@ if(newseed.state=="finished"){ $.setIniDbBoolean('chatguessr', 'isOpen',false) //FINISHED //Compute total scores + give reward + sendGuessData(); }else{ $.setIniDbBoolean('chatguessr', 'isOpen',true) //NEW ROUD /Guess guesses.round = seed.round - 1; - sendData('guesses',JSON.stringify(guesses)); + sendGuessData(); } } seed = newseed; }else if(action.equalsIgnoreCase('gg')){ - sendData('guesses',JSON.stringify(guesses)); + sendGuessData(); }else if(action.equalsIgnoreCase('fg')){ addGuess("Alpha","0,0"); addGuess("Beta","40,0"); addGuess("Charlie","0,60"); addGuess("Delta","80,80"); - guesses.round = seed.round - 1; - sendData('guesses',JSON.stringify(guesses)); } } });