This commit is contained in:
choelzl 2022-02-09 02:28:05 +01:00
parent 2a5eadc8cf
commit 8f6690be36
Signed by: sora
GPG Key ID: A362EA0491E2EEA0
3 changed files with 179 additions and 25 deletions

View File

@ -1,25 +1,42 @@
(function() {
var isOpen = false,
guesses = {};
const GameHelper = require('./helpers/cg-gh.js')
function DBsetOpen(open) {
(function() {
var isOpen = $.getSetIniDbBoolean('cgstatus', 'isOpen', false),
seed = {},
guesses = {
'1':[
{user:'Alpha',location:'0,0',distance:5,score:2,streak:0},
{user:'Beta',location:'5,0',distance:100,score:3,streak:0},
{user:'Charlie',location:'6,6',distance:1000,score:0,streak:0},
{user:'Delta',location:'42,6',distance:1,score:5,streak:1}
],
'2':[
],
};
function dbSetSeed(id) {
$.inidb.SetBoolean("chatguessr", "isOpen", "", open);
isOpen = open;
}
function dbSetOpen(open) {
$.inidb.SetBoolean("chatguessr", "isOpen", "", open);
isOpen = open;
sendData('status',open);
}
function DBClearG() {
function dbClearGuesses() {
guesses = {};
$.inidb.SetString("chatguessr", "guesses", JSON.stringify(guesses));
sendData('guesses',guesses);
}
function DBAddG(user,position) {
function dbAddGuess(user,position) {
if(guesses[user] && guesses[user].length > 0){
}else if(isCoordinates(position)){
guesses[user] = position;
$.inidb.SetString("chatguessr", "guesses", JSON.stringify(guesses));
sendData('guesses',guesses);
sendData('guesses',JSON.stringify(guesses));
}
}
@ -46,29 +63,37 @@
if (command.equalsIgnoreCase('g')) {
if(isOpen) DBAddG(sender,args);
}else if (command.equalsIgnoreCase('cg')) {
if (!action) {
$.say($.whisperPrefix(sender) + $.lang.get('chatguessr.help', ' Use "!cg [open | close | ...]" to open/close the feature.'));
} else if (action.equalsIgnoreCase('open')) {
if(!isOpen) DBsetOpen(true);
//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;
$.getSetIniDbBoolean('cgstatus', 'isOpen', true);
}else if(action.equalsIgnoreCase('close')){
if(isOpen) DBsetOpen(false);
} else if (action.equalsIgnoreCase('clear')) {
DBClearG();
} else if (action.equalsIgnoreCase('timer')) {
sendData(action, new Date(Date.now().getTime()+value*1000*60));
} else {
$.say($.whisperPrefix(sender) + $.lang.get('chatguessr.help'));
isOpen = false;
$.getSetIniDbBoolean('cgstatus', 'isOpen', false)
}else if(action.equalsIgnoreCase('start')){
seed = GameHelper.fetchSeed(args[1]);
}else if(action.equalsIgnoreCase('end')){
isOpen = false;
$.getSetIniDbBoolean('cgstatus', 'isOpen', false)
}else if(action.equalsIgnoreCase('refresh')){
let newseed = GameHelper.fetchSeed(args[1]);
}else if(action.equalsIgnoreCase('gg')){
sendData('guesses',JSON.stringify(guesses));
}
}
});
$.bind('initReady', function() {
$.registerChatCommand('./custom/custom/chatguessr.js', 'cg');
$.registerChatCommand('./custom/custom/chatguessr.js', 'cg',7);
$.registerChatCommand('./custom/custom/chatguessr.js', 'g',7);
$.registerChatSubcommand('cg', 'open', 2);
$.registerChatSubcommand('cg', 'close', 2);
$.registerChatSubcommand('cg', 'clear', 2);
$.registerChatCommand('./custom/custom/chatguessr.js', 'cga');
$.registerChatSubcommand('cga', 'open', 2);
$.registerChatSubcommand('cga', 'close', 2);
$.registerChatSubcommand('cga', 'start', 2);
$.registerChatSubcommand('cga', 'end', 2);
$.registerChatSubcommand('cga', 'refresh', 2);
});
})();

129
twitch/helpers/cg-gh.js Normal file

File diff suppressed because one or more lines are too long

BIN
web/chatguessr/SRC_ORIG.js Normal file

Binary file not shown.