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()));
};
var isOpen = $.getSetIniDbBoolean('chatguessr', 'isOpen', false),
seed = {},
$.getSetIniDbBoolean('chatguessr', 'isOpen', false);
var seed = {},
scale,
guesses = {};
@ -126,13 +126,12 @@
action = args[0];
if (command.equalsIgnoreCase('g')) {
if(isOpen) addGuess(sender,args);
if($.getIniDbBoolean('chatguessr', 'isOpen')) addGuess(sender,args);
}else if (command.equalsIgnoreCase('cg')) {
//send url
//$.say($.whisperPrefix(sender) + $.lang.get('chatguessr.help', ' Use "!cg [open | close | ...]" to open/close the feature.'));
}else if(command.equalsIgnoreCase('cga')){
if(action.equalsIgnoreCase('open')){
isOpen = true;
$.setIniDbBoolean('cgstatus', 'isOpen', true);
}else if(action.equalsIgnoreCase('close')){
$.setIniDbBoolean('cgstatus', 'isOpen', false)
@ -140,18 +139,26 @@
seed = fetchSeed(args[1]);
scale = calculateScale(seed.bounds)
}else if(action.equalsIgnoreCase('end')){
isOpen = false;
$.setIniDbBoolean('cgstatus', 'isOpen', false)
guesses = {};
seed = {};
sendData('guesses',JSON.stringify(guesses));
}else if(action.equalsIgnoreCase('refresh')){
var newseed = fetchSeed(args[1]);
if(newseed.state=="finished"){
//FINISHED
}else if(newseed.player.guesses.length() > seed.player.guesses.length()){
//NEW ROUND !
if(newseed.player.guesses.length() > seed.player.guesses.length()){
$.setIniDbBoolean('chatguessr', 'isOpen',false)
//NEW ROUND /Score
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;
}else if(action.equalsIgnoreCase('gg')){
sendData('guesses',JSON.stringify(guesses));