This commit is contained in:
choelzl 2022-02-10 10:35:37 +01:00
parent 48e507ec30
commit 76819c6885
Signed by: sora
GPG Key ID: A362EA0491E2EEA0

View File

@ -85,8 +85,8 @@
return countryCodesNames.find((country) => country.code === normalized || GameHelper.isMatch(normalized, country.names.toLowerCase())); return countryCodesNames.find((country) => country.code === normalized || GameHelper.isMatch(normalized, country.names.toLowerCase()));
}; };
var isOpen = $.getSetIniDbBoolean('chatguessr', 'isOpen', false), $.getSetIniDbBoolean('chatguessr', 'isOpen', false);
seed = {}, var seed = {},
scale, scale,
guesses = {}; guesses = {};
@ -126,13 +126,12 @@
action = args[0]; action = args[0];
if (command.equalsIgnoreCase('g')) { if (command.equalsIgnoreCase('g')) {
if(isOpen) addGuess(sender,args); if($.getIniDbBoolean('chatguessr', 'isOpen')) addGuess(sender,args);
}else if (command.equalsIgnoreCase('cg')) { }else if (command.equalsIgnoreCase('cg')) {
//send url //send url
//$.say($.whisperPrefix(sender) + $.lang.get('chatguessr.help', ' Use "!cg [open | close | ...]" to open/close the feature.')); //$.say($.whisperPrefix(sender) + $.lang.get('chatguessr.help', ' Use "!cg [open | close | ...]" to open/close the feature.'));
}else if(command.equalsIgnoreCase('cga')){ }else if(command.equalsIgnoreCase('cga')){
if(action.equalsIgnoreCase('open')){ if(action.equalsIgnoreCase('open')){
isOpen = true;
$.setIniDbBoolean('cgstatus', 'isOpen', true); $.setIniDbBoolean('cgstatus', 'isOpen', true);
}else if(action.equalsIgnoreCase('close')){ }else if(action.equalsIgnoreCase('close')){
$.setIniDbBoolean('cgstatus', 'isOpen', false) $.setIniDbBoolean('cgstatus', 'isOpen', false)
@ -140,18 +139,26 @@
seed = fetchSeed(args[1]); seed = fetchSeed(args[1]);
scale = calculateScale(seed.bounds) scale = calculateScale(seed.bounds)
}else if(action.equalsIgnoreCase('end')){ }else if(action.equalsIgnoreCase('end')){
isOpen = false;
$.setIniDbBoolean('cgstatus', 'isOpen', false) $.setIniDbBoolean('cgstatus', 'isOpen', false)
guesses = {}; guesses = {};
seed = {}; seed = {};
sendData('guesses',JSON.stringify(guesses)); sendData('guesses',JSON.stringify(guesses));
}else if(action.equalsIgnoreCase('refresh')){ }else if(action.equalsIgnoreCase('refresh')){
var newseed = fetchSeed(args[1]); var newseed = fetchSeed(args[1]);
if(newseed.state=="finished"){ if(newseed.player.guesses.length() > seed.player.guesses.length()){
//FINISHED $.setIniDbBoolean('chatguessr', 'isOpen',false)
}else if(newseed.player.guesses.length() > seed.player.guesses.length()){ //NEW ROUND /Score
//NEW ROUND ! var gp = newseed.player.guesses[seed.round - 1].lat+","+newseed.player.guesses[seed.round - 1].lng
addGuess($.channelName,gp);
}else{
if(newseed.state=="finished"){
$.setIniDbBoolean('chatguessr', 'isOpen',false) //FINISHED
//Compute total scores + give reward
}else{
$.setIniDbBoolean('chatguessr', 'isOpen',true) //NEW ROUD /Guess
}
} }
seed = newseed;
guesses.round = seed.round - 1; guesses.round = seed.round - 1;
}else if(action.equalsIgnoreCase('gg')){ }else if(action.equalsIgnoreCase('gg')){
sendData('guesses',JSON.stringify(guesses)); sendData('guesses',JSON.stringify(guesses));