- // ==UserScript==
- // @name NEET Lib
- // @namespace http://tampermonkey.net/
- // @version 5.11
- // @description NEET Bot Library
- // @author eterNEETy
- // @match http://game.granbluefantasy.jp/
- // @grant none
- // @namespace https://greasyfork.org/users/292830
- // ==/UserScript==
- // jshint esversion: 6
- // jshint -W138
-
- // environment info
- const xhr = new XMLHttpRequest(),
- server = "http://localhost:2487",
- margin = {"top":91,"left":0},
- game_url = "http://game.granbluefantasy.jp/";
-
- let debug = true,
- reload_counter;
-
- let my_profile = "Main: ";
- let is_host = "false";
- let battle;
- let battle_status;
-
- let quests_id = [], monsters = [], monsters_name = [];
-
- // const game variable
- const trial_id = "990011",
- select_summon_path = "supporter/",
- message = {
- "raid" : {
- "panel" : {
- "open" : my_profile+"Opening quest/raid panel",
- "pick" : my_profile+"Picking quest/raid difficulties",
- },
- "select_party" : my_profile+"Selecting party",
- "finish" : my_profile+"Raid finished",
- "trial" : {
- "close_pop_up" : my_profile+"In trial, closing pop up",
- "open_menu" : my_profile+ "In trial, click menu",
- "retreat" : my_profile+ "In trial, click retreat",
- "ok" : my_profile+ "In trial, click ok",
- "end" : my_profile+"Retreated from trial, back to main raid",
- }
- },
- "summon" : {
- "select" : my_profile+"Selecting summon",
- "pick_tab" : my_profile+"Clicking summon element tab",
- "not_found" : my_profile+"Support summon not found, going to trial",
- },
- "replenish" : {
- "elixir" : {
- "half_elixir" : {
- "use" : my_profile+"Not enough AP, using half elixir",
- "used" : my_profile+"Half elixir used",
- }
- },
- "soul" : {
- "soul_berry" : {
- "use" : my_profile+"Not enough EP, using soul berry",
- "used" : my_profile+"soul berry used",
- }
- }
- },
- "ok" : my_profile+"Clicking ok",
- };
-
- // path
- let path = {
- "item":"#item",
- "quest":"#quest",
- "support":"#quest/supporter/",
- "assist":"#quest/assist",
- "unclaimed":"#quest/assist/unclaimed",
- "trial":"#quest/supporter/"+trial_id+"/17",
- };
-
- // element dom query selector
- let skill_char = "#prt-command-top > div > div > div.lis-character";
- let skill_abi = ".btn-command-character > div.prt-ability-state > div.lis-ability-state.ability";
- let query = {
- "battle_ui": {
- "skill": {
- "char1": {
- "skill1": skill_char + "0" + skill_abi + "1",
- "skill2": skill_char + "0" + skill_abi + "2",
- "skill3": skill_char + "0" + skill_abi + "3",
- "skill4": skill_char + "0" + skill_abi + "4",
- },
- "char2": {
- "skill1": skill_char + "1" + skill_abi + "1",
- "skill2": skill_char + "1" + skill_abi + "2",
- "skill3": skill_char + "1" + skill_abi + "3",
- "skill4": skill_char + "1" + skill_abi + "4",
- },
- "char3": {
- "skill1": skill_char + "2" + skill_abi + "1",
- "skill2": skill_char + "2" + skill_abi + "2",
- "skill3": skill_char + "2" + skill_abi + "3",
- "skill4": skill_char + "2" + skill_abi + "4",
- },
- "char4": {
- "skill1": skill_char + "3" + skill_abi + "1",
- "skill2": skill_char + "3" + skill_abi + "2",
- "skill3": skill_char + "3" + skill_abi + "3",
- "skill4": skill_char + "3" + skill_abi + "4",
- },
- },
- "skill_pop_up": {
- "char1": "div.pop-usual.pop-select-member > div.prt-popup-body > div.prt-wrapper > div.prt-character > div.lis-character0.btn-command-character > img",
- "char2": "div.pop-usual.pop-select-member > div.prt-popup-body > div.prt-wrapper > div.prt-character > div.lis-character1.btn-command-character > img",
- "char3": "div.pop-usual.pop-select-member > div.prt-popup-body > div.prt-wrapper > div.prt-character > div.lis-character2.btn-command-character > img",
- "char4": "div.pop-usual.pop-select-member > div.prt-popup-body > div.prt-wrapper > div.prt-character > div.lis-character3.btn-command-character > img",
- "char5": "div.pop-usual.pop-select-member > div.prt-popup-body > div.prt-wrapper > div.prt-character > div.lis-character4.btn-command-character > img",
- "char6": "div.pop-usual.pop-select-member > div.prt-popup-body > div.prt-wrapper > div.prt-character > div.lis-character5.btn-command-character > img",
- },
- // "#prt-command-top > div > div > div.lis-character3.btn-command-character > div.prt-ability-state > div.lis-ability-state.ability3",
- "ougi": ".btn-lock",
- "toggle_ougi": {
- true: ".lock0",
- false: ".lock1",
- },
- "char_ico": ".prt-party>.prt-member>.btn-command-character>img.img-chara-command",
- "summon_panel": ".prt-summon-list>.prt-list-top.btn-command-summon",
- "chat":".btn-chat.comment.display-on",
- "chat_pop_up": {
- "dialog":".txt-chat-pop",
- },
- "heal":"#prt-sub-command-group>.btn-temporary",
- "heal_pop_up": {
- "green": ".lis-item.item-small",
- "blue": ".lis-item.item-large",
- "use": ".pop-usual.pop-raid-item.pop-show>.prt-popup-footer>.btn-usual-use",
- "cancel": ".pop-usual.pop-raid-item.pop-show>.prt-popup-footer>.btn-usual-cancel",
- },
- "trial_pop_up": {
- "close": ".pop-usual.pop-trialbattle-notice.pop-show>.prt-popup-footer>.btn-usual-close"
- },
- },
- "assist_ui": {
- "tab_id": "#tab-id",
- "tab_multi": "#tab-multi",
- "tab_event": "#tab-event",
- "unclaimed": ".btn-unclaimed",
- },
- "poker": {
- "canvas": "#canv",
- "deal": ".prt-start",
- "ok": ".prt-ok",
- "yes": ".prt-yes",
- "no": ".prt-no",
- "low": ".prt-double-select>.prt-low-shine",
- "high": ".prt-double-select>.prt-high-shine",
- },
- "ok":".btn-usual-ok",
- };
-
- // general item variable
- let tracked_item = false;
-
- function reloadNow() {
- console.log(reloadNow.name);
- xhr.open('POST', server);
- xhr.send(JSON.stringify([{"cmd":"press","key":"f5"}]));
- window.location.reload();
- }
-
- function reload(mod_value=1) {
- clearInterval(reload_counter);
- let current_path = window.location.hash;
- let count = 1;
- reload_counter = setInterval(function() {
- if(window.location.hash != current_path){
- clearInterval(reload_counter);
- }
- console.log("reloading in "+(mod_value-count).toString());
- if (count%mod_value===0){
- clearInterval(reload_counter);
- reloadNow();
- }
- count += 1;
- }, 1000);
- }
-
- function setDebug() {
- if(!debug){
- console.log("DEBUG is turned OFF");
- if(!window.console) window.console = {};
- let methods = ["log", "debug", "warn", "info"];
- for(let i=0;i<methods.length;i++){
- console[methods[i]] = function(){};
- }
- }
- }
-
- function readBody(xhr) {
- let data;
- if (!xhr.responseType || xhr.responseType === "text") {
- data = xhr.responseText;
- } else if (xhr.responseType === "document") {
- data = xhr.responseXML;
- } else {
- data = xhr.response;
- }
- return data;
- }
-
- function gotoHash(key){
- let hash_path;
- if (path[key] !== undefined) {
- hash_path = path[key];
- }else{
- if (key.indexOf("#")!==0) {
- hash_path = "#"+key;
- }
- }
- window.location.href = game_url + hash_path;
- }
-
- function scrollTo(query,qid=0) {
- document.querySelectorAll(query)[qid].scrollIntoViewIfNeeded();
- }
-
- function checkExist(query,qid=0) {
- let el_exist = false;
- if (document.querySelectorAll(query).length > qid){
- if (document.querySelectorAll(query)[qid].getBoundingClientRect().width > 0 && document.querySelectorAll(query)[qid].getBoundingClientRect().height > 0) {
- el_exist = true;
- }
- }
- return el_exist;
- }
-
- function checkEl(query,qid=0,callback=false) {
- let old_top = -1;
- let old_left = -1;
- let loop_checkEl = setInterval(function() {
- console.log(checkEl.name + " " + query + "[" + qid + "]");
- if (checkExist(query,qid)) {
- if (old_top==document.querySelectorAll(query)[qid].getBoundingClientRect().top && old_left==document.querySelectorAll(query)[qid].getBoundingClientRect().left) {
- clearInterval(loop_checkEl);
- if (typeof callback == "function") {
- callback();
- }
- }else{
- old_top = document.querySelectorAll(query)[qid].getBoundingClientRect().top;
- old_left = document.querySelectorAll(query)[qid].getBoundingClientRect().left;
- }
- }
- }, 200);
- }
-
- function checkEls(queries,callback=false) {
- let exist_result;
- let loop_checkEls = setInterval(function() {
- exist_result = [];
- for (let i in queries) {
- console.log(checkEls.name + " " + queries[i].query + "[" + queries[i].qid + "]");
- exist_result.push(checkExist(queries[i].query,queries[i].qid));
- }
- if (exist_result.indexOf(false)===-1) {
- clearInterval(loop_checkEls);
- if (typeof callback == "function") {
- callback();
- }
- }
- }, 300);
- }
-
- function checkError() {
- let q_cnt_error = ".cnt-error";
- let q_pop_up = ".pop-usual.common-pop-error.pop-show";
- let check_error = setInterval(function() {
- let func_name = checkError.name;
-
- if (checkExist(q_pop_up,0) || checkExist(q_cnt_error,0)) {
- let cmd = [];
- console.log("error_found");
- let do_reload = false;
- let level = "notif";
- let msg = "Uncatagorized error found";
- // let msg = "Connection error, refreshing disabled"
- if (checkExist(q_pop_up+">.prt-popup-header",0)) {
- if (document.querySelector(q_pop_up+">.prt-popup-header").innerHTML=="Access Verification") {
- clearInterval(reload_counter);
- msg = my_profile+"Captcha detected";
- console.log("Captcha detected");
- }else if (document.querySelector(q_pop_up+">.prt-popup-header").innerHTML=="エラー") {
- if (checkExist(q_pop_up+">.prt-popup-body>.txt-popup-body>div",0)) {
- if (typeof document.querySelector(q_pop_up+">.prt-popup-body>.txt-popup-body>div").innerHTML == "string") {
- if (document.querySelector(q_pop_up+">.prt-popup-body>.txt-popup-body>div").innerHTML.indexOf("Network Error")>=0) {
- clearInterval(reload_counter);
- console.log("Error connection");
- do_reload = true;
- msg = my_profile+"Error connection, reloading";
- level = "process";
- }
- }
- }
- }
- }
- if (checkExist(q_pop_up+">.prt-popup-body>.txt-popup-body",0)) {
- if (document.querySelector(q_pop_up+">.prt-popup-body>.txt-popup-body").innerHTML=="Check your pending battles.") {
- console.log("check raid");
- level = "process";
- msg = my_profile+"Check your pending battle";
- clickEl(".prt-popup-footer>.btn-usual-ok",0,my_profile+"Clicking ok pop up pending battles");
- }
- }
- if (do_reload){
- cmd.push({"cmd":"press","key":"f5"});
- }
- cmd.push({"cmd":"log","level":level,"msg":msg});
- xhr.open('POST', server);
- xhr.send(JSON.stringify(cmd));
- if (do_reload){
- window.location.reload();
- }
- }
- }, 5000);
- }
-
- function getCoord(el){
- let x, y, output;
- el = el.getBoundingClientRect();
- if (el.width>0 && el.height>0) {
- x = (el.width / 2) + el.left;
- y = (el.height / 2) + el.top;
- if(el.width>40){
- x += Math.floor(Math.random() * 41)-20;
- }else if(el.width>20){
- x += Math.floor(Math.random() * 21)-10;
- }else if(el.width>10){
- x += Math.floor(Math.random() * 11)-5;
- }
- if(el.height>10){
- y += Math.floor(Math.random() * 11)-5;
- }
- output = [x+margin.left,y+margin.top];
- }else{
- output = 0;
- }
- return output;
- }
-
- function getMarginCoord(query,qid){
- let el = document.querySelectorAll(query)[qid].getBoundingClientRect();
- return {"top":el.top+margin.top,"left":el.left+margin.left};
- }
-
- function clickNow(query,qid=0,msg=my_profile+"clickNow called",callback=false){
- let el = document.querySelectorAll(query)[qid];
- let output = false;
- if (checkExist(query,qid)) {
- output = true;
- let cmd = [];
- cmd.push({"cmd":"clickIt","param":getCoord(el)});
- cmd.push({"cmd":"log","level":"process","msg":msg});
- xhr.open("POST", server);
- xhr.send(JSON.stringify(cmd));
- if (typeof callback == "function") {
- callback();
- }
- }
- return output;
- }
-
- function clickEl(query,qid=0,msg=my_profile+"clickEl called",callback=false){
- let init_clickEl = function() {
- clickNow(query,qid,msg,callback);
- };
- checkEl(query,qid,init_clickEl);
- }
-
- function clickObject(obj){
- if (obj == "ok"){
- clickEl(".btn-usual-ok",0,message.ok);
- }
- }
-
- function clickAndNegCheck(query,qid=0,msg="clickAndNegCheck called",callback=false,ticks=5){
- let old_href = window.location.href;
- let old_top = -1;
- let old_left = -1;
- let match = ticks-1;
- let str_clickAndNegCheck = clickAndNegCheck.name + ", el: " + query + "["+(qid.toString())+"] \n- match = ";
- let init_clickAndNegCheck = function() {
- let loop_clickAndNegCheck = setInterval(function() {
- console.log(str_clickAndNegCheck+(match.toString()));
- if (!(checkExist(query,qid))) {
- clearInterval(loop_clickAndNegCheck);
- if (typeof callback == "function") {
- callback();
- }
- }else if (old_href != window.location.href) {
- clearInterval(loop_clickAndNegCheck);
- }else{
- if (checkExist(query,qid)) {
- if (old_top==document.querySelectorAll(query)[qid].getBoundingClientRect().top && old_left==document.querySelectorAll(query)[qid].getBoundingClientRect().left) {
- if (match % ticks == 0) {
- clickNow(query,qid,msg);
- }
- match += 1;
- }else{
- old_top = document.querySelectorAll(query)[qid].getBoundingClientRect().top;
- old_left = document.querySelectorAll(query)[qid].getBoundingClientRect().left;
- }
- }
- }
- }, 100);
- };
- checkEl(query,qid,init_clickAndNegCheck);
- }
-
- function clickAndCheck(query1,qid1=0,query2,qid2=0,msg="clickAndCheck called",callback=false,ticks=5){
- let old_href = window.location.href;
- let old_top = -1;
- let old_left = -1;
- let match = ticks-1;
- let str_clickAndCheck = clickAndCheck.name + ", check: " + query2 + "["+(qid2.toString())+"], click: " + query1 + "["+(qid1.toString())+"] \n- match = ";
- let loop_clickAndCheck = setInterval(function() {
- console.log(str_clickAndCheck+(match.toString()));
- if (checkExist(query2,qid2)) {
- clearInterval(loop_clickAndCheck);
- if (typeof callback == "function") {
- callback();
- }
- }else if (old_href != window.location.href) {
- clearInterval(loop_clickAndCheck);
- }else{
- if (checkExist(query1,qid1)) {
- if (old_top==document.querySelectorAll(query1)[qid1].getBoundingClientRect().top && old_left==document.querySelectorAll(query1)[qid1].getBoundingClientRect().left) {
- if (match % ticks == 0) {
- clickNow(query1,qid1,msg);
- }
- match += 1;
- }else{
- old_top = document.querySelectorAll(query1)[qid1].getBoundingClientRect().top;
- old_left = document.querySelectorAll(query1)[qid1].getBoundingClientRect().left;
- }
- }
- }
- }, 100);
- }
-
- function popUpNotEnough(rep) {
- const query = ".btn-use-full.index-1",
- qid = 0,
- msg = message.replenish.elixir.half_elixir.use;
- let cmd = [], coordinate, consumable_data;
- consumable_data = my_profile+"Consumable Status:";
- for (let i = 0; i < rep.length; i++) {
- consumable_data += ("\n- "+rep[i].name+": "+rep[i].number);
- }
- let init_popUpNotEnough = function() {
- coordinate = getCoord(document.querySelectorAll(query)[qid]);
- if (coordinate!==0){
- cmd.push({"cmd":"clickIt","param":coordinate});
- cmd.push({"cmd":"log","level":"process","msg":msg});
- cmd.push({"cmd":"log","level":"summary","msg":consumable_data,"split":0});
- xhr.open('POST', server);
- xhr.send(JSON.stringify(cmd));
- }
- };
- checkEl(query,qid,init_popUpNotEnough);
-
- }
-
- function clickAndCheckSkill(query,qid=0,msg="clickAndCheckSkill called",callback=false,special_case=false){
- let old_class = document.querySelectorAll(query)[qid].parentNode.classList[0];
- let loop_clickAndCheckSkill = setInterval(function() {
- console.log(checkEl.name + " " + query + "[" + qid + "]");
- if (Array.from(document.querySelectorAll(query)[qid].parentNode.parentNode.classList).indexOf("tmp-mask")>=0 || Array.from(document.querySelectorAll(query)[qid].parentNode.parentNode.classList).indexOf("btn-ability-unavailable")>=0){
- clearInterval(loop_clickAndCheckSkill);
- console.log(clickAndCheckSkill.name + " case normal");
- if (typeof callback == "function") {
- callback();
- }
- // Bea skill
- }else if(special_case===1 && document.querySelectorAll(query)[qid].parentNode.classList[0] != old_class){
- clearInterval(loop_clickAndCheckSkill);
- console.log(clickAndCheckSkill.name + " case " + special_case.toString());
- if (typeof callback == "function") {
- callback();
- }
- // Out of sight & sage of eternity
- }else if(special_case===2){
- let do_click = true;
- console.log(clickAndCheckSkill.name + " case " + special_case.toString());
- let popup_query = "#wrapper > div.contents > div.pop-usual.pop-select-member > div.prt-popup-header";
- if (checkExist(popup_query,0)) {
- if (document.querySelector("#wrapper > div.contents > div.pop-usual.pop-select-member > div.prt-popup-header").innerHTML == "Use Skill"){
- clearInterval(loop_clickAndCheckSkill);
- do_click = false;
- if (typeof callback == "function") {
- callback();
- }
- }
- }
- if (do_click) {
- if (checkExist(query,qid)) {
- clickNow(query,qid,msg);
- }
- }
- }else{
- if (checkExist(query,qid)) {
- clickNow(query,qid,msg);
- }
- }
-
- }, 500);
- }
-
- function getCharStr(char_id){
- let char;
- if (char_id==1){
- char = "MC";
- }else{
- char = "NPC"+((char_id-1).toString());
- }
- return char;
- }
-
- function useSkill(char_id,abi_id,callback=false,special_case=false){
- console.log(useSkill.name + ", char: "+char_id+", ability: " + (abi_id.toString()) + ", case: "+special_case);
- let char = getCharStr(char_id);
- abi_id = parseInt(abi_id)-1;
- // console.log("lol");
- console.log(".prt-command-chara.chara"+(char_id.toString())+">div>div.lis-ability");
- if (Array.from(document.querySelectorAll(".prt-command-chara.chara"+(char_id.toString())+">div>div.lis-ability")[abi_id].classList).indexOf("btn-ability-available")>=0 && document.querySelectorAll(".prt-command-chara.chara"+(char_id.toString())+">div>div.lis-ability")[abi_id].getBoundingClientRect().width>0){
- clickAndCheckSkill(".prt-command-chara.chara"+(char_id.toString())+">div>div>div>.img-ability-icon",abi_id,my_profile+"Clicking "+char+" skill"+((abi_id+1).toString()),callback,special_case);
- }else{
- if (typeof callback == "function") {
- callback();
- }
- }
- }
-
- function clickBack(callback=false){
- clickAndCheck(".btn-command-back.display-on",0,"div.prt-member",0,my_profile+"Clicking back",callback,10);
- }
-
- function clickSummonPanel(callback=false){
- let query1 = ".prt-list-top.btn-command-summon.summon-on";
- let query2 = ".prt-summon-list.opened";
- let query3 = ".prt-list-top.btn-command-summon.summon-off";
- let qid1 = 0, qid2 = 0, qid3 = 0;
- let msg = my_profile+"Clicking summon panel";
- let old_top = -1;
- let old_left = -1;
- let loop_clickAndCheck = setInterval(function() {
- console.log(clickAndCheck.name + ", check: " + query2 + "["+(qid2.toString())+"], click: " + query1 + "["+(qid1.toString())+"]");
- if (checkExist(query2,qid2) || checkExist(query3,qid3)) {
- clearInterval(loop_clickAndCheck);
- if (typeof callback == "function") {
- callback();
- }
- }else{
- if (checkExist(query1,qid1)) {
- if (old_top==document.querySelectorAll(query1)[qid1].getBoundingClientRect().top && old_left==document.querySelectorAll(query1)[qid1].getBoundingClientRect().left) {
- clickNow(query1,qid1,msg);
- }else{
- old_top = document.querySelectorAll(query1)[qid1].getBoundingClientRect().top;
- old_left = document.querySelectorAll(query1)[qid1].getBoundingClientRect().left;
- }
- }
- }
- }, 200);
- // clickAndCheck(,0,,0,);
- }
-
- function clickSummon(summon_id,callback1=false,callback2=false){
- summon_id = summon_id-1;
- if (Array.from(document.querySelectorAll(".lis-summon")[summon_id].classList).indexOf("btn-summon-available")>=0){
- let loop_clickSummon = setInterval(function() {
- if (document.querySelectorAll(".lis-summon>img")[summon_id].getBoundingClientRect().x=== 72 + (summon_id * 51)){
- clearInterval(loop_clickSummon);
- clickAndCheck(".lis-summon>img",summon_id,".pop-usual.pop-summon-detail>div>.btn-usual-ok.btn-summon-use",0,my_profile+"Clicking summon "+((summon_id+1).toString()),callback1);
- }
- }, 300);
- }else{
- if (typeof callback2 == "function") {
- callback2();
- }
- }
- }
-
- function clickOkSummon(callback=false){
- let el_ok = ".pop-usual.pop-summon-detail>div>.btn-usual-ok.btn-summon-use";
- if (document.querySelector(el_ok) !== null){
- clickAndCheck(el_ok,0,"div.prt-member",0,my_profile+"Clicking summon ok",callback);
- }else{
- if (typeof callback == "function") {
- callback();
- }
- }
- }
- function clickOkSummon2(summon_id,callback=false){
- let el_ok = ".pop-usual.pop-summon-detail>div>.btn-usual-ok.btn-summon-use";
- let summon_el = '.lis-summon[pos="'+(summon_id.toString())+'"]';
- if (document.querySelector(el_ok) !== null){
- let loop_clickOkSummon2 = setInterval(function() {
- console.log(clickOkSummon2.name + ", click: " + el_ok + "[0]");
- if (Array.from(document.querySelector(summon_el).classList).indexOf("tmp-mask")>=0 || Array.from(document.querySelector(summon_el).classList).indexOf("btn-summon-unavailable")>=0) {
- clearInterval(loop_clickOkSummon2);
- if (typeof callback == "function") {
- callback();
- }
- }else{
- if (checkExist(el_ok,0)) {
- clickNow(el_ok,0,my_profile+"Clicking summon ok2");
- }
- }
- }, 1000);
- }else{
- if (typeof callback == "function") {
- callback();
- }
- }
- }
-
- function selectSummon(preferred_summon,is_trial=false){
- reload(20);
-
- let init_selectSummon = function() {
- console.log(init_selectSummon.name);
- reload(10);
- const attrib_list = [6,0,1,2,3,4,5];
- let query_summon_list = ".btn-supporter.lis-supporter";
- let el_summon_list = document.querySelectorAll(query_summon_list);
- let preferred_summon_id = false;
- let picked_attrib_id = false;
- let picked_summon_id = false;
- let picked_is_friend = false;
- let is_friend;
- let picked_summon_stars = false;
- let picked_summon_level = false;
- let picked_summon_plus = false;
- let msg;
- let cmd = [], summon_list = {};
- if (el_summon_list.length>50 && document.querySelector(".prt-supporter-battle-announce")===null && document.querySelector(".txt-confirm-comment")===null && document.querySelector(".prt-check-auth")===null && document.querySelector(".btn-check-auth")===null){
- msg = my_profile+"Verify not appear, summon list length is "+(el_summon_list.length.toString());
- console.log(msg);
-
- // check if raid is trial
- if (!is_trial){
- console.log("not trial");
- for (let i = 0; i < el_summon_list.length; i++) {
- let match_preferred = false, replace = false;
- let temp_var, summon_detail, summon_name, summon_level, summon_stars, summon_plus;
- temp_var = el_summon_list[i].querySelector(".prt-supporter-summon");
- summon_detail = temp_var.innerHTML.trim();
- temp_var = el_summon_list[i].querySelector(".prt-supporter-summon");
- summon_detail = temp_var.innerHTML.trim();
- summon_name = summon_detail.substring(summon_detail.indexOf("</span>")+8,summon_detail.length);
- summon_level = parseInt(temp_var.children[0].innerHTML.replace("Lvl ",""));
- temp_var = Array.from(el_summon_list[i].querySelector(".prt-summon-skill").classList);
- if (temp_var.indexOf("bless-rank3-style")>=0){
- summon_stars = 5;
- }else if (temp_var.indexOf("bless-rank2-style")>=0){
- summon_stars = 4;
- }else if (temp_var.indexOf("bless-rank1-style")>=0){
- summon_stars = 3;
- }else{
- summon_stars = 0;
- }
- temp_var = el_summon_list[i].querySelector(".prt-summon-quality");
- if (temp_var !== null){
- summon_plus = parseInt(temp_var.innerHTML.replace("+",""));
- }else{
- summon_plus = 0;
- }
- temp_var = false;
- is_friend = Array.from(el_summon_list[i].querySelector(".prt-supporter-name").classList).indexOf("ico-friend")>=0;
-
- // console.log([summon_name,summon_level,summon_stars,summon_plus,is_friend]);
-
- // loop preferred summon list (specified in parameter)
- for (let j = 0; j < preferred_summon.length; j++) {
- if (preferred_summon[j][0]==summon_name && preferred_summon[j][1]<=summon_stars){
- match_preferred = true;
- temp_var = j;
- }
- }
-
-
- if (match_preferred){
- if (picked_attrib_id===false && picked_summon_id===false){
- replace = true;
- }else{
- if (preferred_summon_id>temp_var){
- replace = true;
- }else if(preferred_summon_id==temp_var){
- if (summon_stars>picked_summon_stars){
- replace = true;
- }else if(summon_stars==picked_summon_stars){
- if (!picked_is_friend && is_friend){
- replace = true;
- }else if(picked_is_friend && is_friend){
- if (summon_level>picked_summon_level){
- replace = true;
- }else if(summon_level==picked_summon_level){
- if (summon_plus>picked_summon_plus){
- replace = true;
- }
- }
- }
- }
- }
- }
- }
- if (replace){
- picked_attrib_id = Array.from(document.querySelectorAll(".prt-supporter-attribute")).indexOf(el_summon_list[i].parentElement);
- picked_summon_id = i;
- preferred_summon_id = temp_var;
- picked_summon_stars = summon_stars;
- picked_is_friend = is_friend;
- picked_summon_level = summon_level;
- picked_summon_plus = summon_plus;
- }
- }
- console.log([picked_attrib_id,picked_summon_id,preferred_summon_id]);
- if (picked_summon_id===false){
- console.log("go to trial");
- cmd.push({"cmd":"log","level":"process","msg":message.summon.not_found});
- xhr.open("POST", server);
- xhr.send(JSON.stringify(cmd));
- gotoHash("trial");
- }else{
- console.log("summon_found");
- let pickSummon = function() {
- scrollTo(query_summon_list,picked_summon_id);
- clickEl(query_summon_list,picked_summon_id,message.summon.select);
- };
- let clickAndCheckSummon = function(callback=false){
- let el_tab_ele_ico = ".prt-type-text";
- let el_summon_container = ".prt-supporter-attribute";
- let loop_clickAndCheckSummon = setInterval(function() {
- console.log(clickAndCheckSummon.name + ", check: " + el_summon_container + "[" + picked_attrib_id + "], click: " + el_tab_ele_ico + "["+(attrib_list[picked_attrib_id].toString())+"]");
- if (Array.from(document.querySelectorAll(el_summon_container)[picked_attrib_id].classList).indexOf("disableView") == -1) {
- clearInterval(loop_clickAndCheckSummon);
- if (typeof callback == "function") {
- callback();
- }
- }else{
- if (checkExist(el_tab_ele_ico, attrib_list[picked_attrib_id])) {
- clickNow(el_tab_ele_ico, attrib_list[picked_attrib_id], message.summon.pick_tab);
- }
- }
- }, 300);
- };
- clickAndCheckSummon(pickSummon);
- }
- }else{
- console.log("is trial");
- query_summon_list = ".prt-supporter-attribute:not(.disableView)>.btn-supporter.lis-supporter";
- // clearInterval(reload_counter);
- el_summon_list = document.querySelectorAll(query_summon_list);
- // console.log(el_summon_list);
- for (let i = 0; i < el_summon_list.length; i++) {
- is_friend = Array.from(el_summon_list[i].querySelector(".prt-supporter-name").classList).indexOf("ico-friend")>=0;
- if (!is_friend){
- if (picked_summon_id===false){
- picked_summon_id = i;
- }
- }
- }
- // console.log(picked_summon_id);
- if (picked_summon_id!==false){
- scrollTo(".prt-supporter-attribute:not(.disableView)>.btn-supporter.lis-supporter",picked_summon_id);
- clickEl(".prt-supporter-attribute:not(.disableView)>.btn-supporter.lis-supporter",picked_summon_id,message.summon.select);
- }
- }
- }else{
- msg = my_profile+"Verify might appear, summon list length is "+(el_summon_list.length.toString());
- clearInterval(reload_counter);
- console.log(msg);
- cmd.push({"cmd":"log","level":"process","msg":msg});
- cmd.push({"cmd":"log","level":"notif","msg":msg});
- xhr.open("POST", server);
- xhr.send(JSON.stringify(cmd));
- }
- };
- checkEl(".prt-supporter-title",0,init_selectSummon);
- }
-
- function doChat(callback=false) {
- console.log(doChat.name);
- let clickDialog = function() {
- console.log(clickDialog.name);
- clickAndNegCheck(query.battle_ui.chat_pop_up.dialog,0,my_profile+"Clicking chat dialog",callback);
- };
- let clickChat = function() {
- console.log(clickChat.name);
- if (checkExist(query.battle_ui.chat+">.ico-attention",0)) {
- clickAndCheck(query.battle_ui.chat,0,query.battle_ui.chat_pop_up.dialog,0,my_profile+"Clicking chat pop up",clickDialog,20);
- }else{
- if (typeof callback == "function") {
- callback();
- }
- }
- };
- checkEl(query.battle_ui.chat,0,clickChat);
- }
-
- function backFromTrial(){
- let cmd = [];
- cmd.push({"cmd":"log","level":"process","msg":message.raid.trial.end});
- xhr.open("POST", server);
- xhr.send(JSON.stringify(cmd));
- gotoHash("main");
- }
-
- function gotoResult() {
- console.log(gotoResult.name);
- console.log(is_host);
- if (is_host || window.location.hash.indexOf("#raid/")>=0) {
- gotoHash("quest");
- }else if (window.location.hash.indexOf("#raid_multi")>=0) {
- reloadNow();
- }
- }
-
- function attack(rep){
- console.log(attack.name);
- let cmd = [];
- let reps = rep.scenario;
- let win = false;
- let is_last_raid = false;
- let ougi = 0;
- let msg = "";
- let pos_player = ["MC","NPC1","NPC2","NPC3","NPC4","NPC5"];
- for (let i = 0; i < reps.length; i++) {
- if (reps[i].cmd =="win"){
- if (reps[i].is_last_raid){is_last_raid=true;}
- win=true;
- }else if (reps[i].cmd=="special" || reps[i].cmd=="special_npc"){
- msg += my_profile+pos_player[reps[i].pos]+" used ougi \""+reps[i].name+"\".\n";
- if (reps[i].total){msg += my_profile+pos_player[reps[i].pos]+" dealt "+reps[i].total[0].split.join("")+" damage.\n";}
- ougi++;
- }else if (reps[i].cmd=="attack" && reps[i].from=="player"){
- if (reps[i].damage.length==3){
- msg += my_profile+pos_player[reps[i].pos]+" made a triple attack.\n";
- }else if (reps[i].damage.length==2){
- msg += my_profile+pos_player[reps[i].pos]+" made a double attack.\n";
- }
- msg += my_profile+pos_player[reps[i].pos]+ " dealt ";
- for (let ii=0; ii<reps[i].damage.length; ii++){
- msg += reps[i].damage[ii][0].value.toString();
- if (ii<reps[i].damage.length-1){
- msg += ", ";
- }else{
- msg += " damage.\n";
- }
- }
- }
- }
-
- if(win){
- cmd.push({"cmd":"log","level":"process","msg":msg+my_profile+"Foe defeated."});
- }else{
- cmd.push({"cmd":"log","level":"process","msg":msg+my_profile+"Foe is still alive."});
- cmd.push({"cmd":"press","key":"f5"});
- }
- xhr.open('POST', server);
- xhr.send(JSON.stringify(cmd));
- if(win && is_last_raid){
- gotoResult();
- }else if(win){
- clickEl(".btn-result",0,my_profile+"Go to next round");
- }
- }
-
- function skillUsed(rep){
- console.log(skillUsed.name);
- let do_reload = false;
- let reps = rep.scenario;
- let win = false, is_last_raid = false;
- // win = false;
- // is_last_raid = false;
- console.log(reps);
- for (let i = 0; i < reps.length; i++) {
- const scenario = reps[i];
- if (scenario.cmd =="ability"){
- if (scenario.name == "Thunder Raid") {
- do_reload = true;
- }
- }else if (scenario.cmd =="damage") {
- if (scenario.to == "player") {
- for (let j = 0; j < scenario.list.length; j++) {
- const element = scenario.list[j];
- if (element.hp !== undefined && element.pos !== undefined) {
- battle_status.player.param[element.pos].hp = element.hp;
- }
- }
- }
- }else if (scenario.cmd =="finished"){
- win=true;
- is_last_raid=true;
- }else if (scenario.cmd == "win"){
- if (scenario.is_last_raid){is_last_raid=true;}
- win=true;
- }
-
- }
-
- if(win && is_last_raid){
- gotoResult();
- }else if(do_reload){
- reloadNow();
- }
- }
-
- function potUsed(rep) {
- console.log(potUsed.name);
- let reps = rep.scenario;
- for (let i = 0; i < reps.length; i++) {
- const scenario = reps[i];
- if (scenario.cmd == "heal") {
- for (let j = 0; j < scenario.list.length; j++) {
- const element = scenario.list[j];
- if (element.hp !== undefined && element.pos !== undefined) {
- battle_status.player.param[element.pos].hp = element.hp;
- }
- }
- }
- }
- }
-
- function clickAttack(callback=false) {
- let hp = ((parseInt(battle.boss.param[0].hp) / parseInt(battle.boss.param[0].hpmax)) * 100).toString();
- if (hp.indexOf(".")>=0){
- hp = hp.substring(0,hp.indexOf("."));
- }
- console.log(hp);
- let attack_msg = my_profile+"Foe hp is "+hp+"% left, commencing attack";
- clickAndCheck(".btn-attack-start.display-on",0,".btn-attack-cancel.btn-cancel.display-on",0,attack_msg,callback,20);
- }
-
- function startRaid(rep){
- reload(15);
- battle = rep;
- is_host = rep.is_host;
- player_status = rep.player.param;
- let toggleOugi = function(ougi,callback=false){
- let init_toggleOugi = function() {
- let current_ougi = "."+document.querySelector(query.battle_ui.ougi).classList[1];
- if (query.battle_ui.toggle_ougi[ougi] != current_ougi){
- clickAndCheck(query.battle_ui.ougi + current_ougi, 0, query.battle_ui.ougi + query.battle_ui.toggle_ougi[ougi], 0, my_profile+"Set toggle ougi to "+(ougi.toString()), callback);
- }else{
- if (typeof callback == "function") {
- callback();
- }
- }
- };
- checkEl(query.battle_ui.ougi,0,init_toggleOugi);
- };
- let usePot = function(pot_type,char_id=false,callback=false) {
- console.log(usePot.name);
- let is_front_healable = [];
- let is_player_reviveable = [];
- let is_player_healable = [];
- for (const i in player_status) {
- if (player_status.hasOwnProperty(i)) {
- if (player_status[i].alive === 1) {
- is_player_reviveable.push(false);
- is_player_healable.push(player_status[i].hpmax - player_status[i].hp !== 0);
- }else{
- is_player_reviveable.push(true);
- is_player_healable.push(false);
- }
- }
- }
- for (const i in rep.formation) {
- if (rep.formation.hasOwnProperty(i)) {
- const alive_id = parseInt(rep.formation[i]);
- is_front_healable.push(player_status[alive_id].hpmax - player_status[alive_id].hp !== 0);
- }
- }
- let query_qty = ">.txt-having>.having-num";
- let clickUse = function() {
- clickAndNegCheck(query.battle_ui.heal_pop_up.use,0,my_profile+"Clicking use from pot pop up",callback);
- };
- let clickFront = function() {
- clickAndCheck(query.battle_ui.char_ico,char_id,query.battle_ui.summon_panel+":not(.mask-black)",0,my_profile+"Clicking char_ico from pot pop up",callback);
- };
- let clickCancel = function() {
- clickAndNegCheck(query.battle_ui.heal_pop_up.cancel,0,my_profile+"Clicking cancel from pot pop up",callback);
- };
- let clickPot = function() {
- console.log(clickPot.name);
- if (checkExist(query.battle_ui.heal_pop_up[pot_type]+query_qty)) {
- if ( parseInt(document.querySelector(query.battle_ui.heal_pop_up[pot_type]+query_qty).innerHTML) > 0 ) {
- if (pot_type == "blue") {
- clickAndNegCheck(query.battle_ui.heal_pop_up[pot_type]+">img",0,my_profile+"Clicking "+ pot_type +" pot",clickUse);
- }else if (pot_type == "green") {
- clickAndNegCheck(query.battle_ui.heal_pop_up[pot_type]+">img",0,my_profile+"Clicking "+ pot_type +" pot",clickFront);
- }else{
- console.log("pot_type unknown");
- clickCancel();
- }
- }else{
- console.log("pot qty not > 0");
- clickCancel();
- }
- }else{
- console.log("element not exist");
- clickCancel();
- }
- };
- let clickHeal = function() {
- console.log(clickHeal.name);
- clickAndCheck(query.battle_ui.heal,0,query.battle_ui.heal_pop_up[pot_type]+">img",0,my_profile+"Clicking heal pop up",clickPot,20);
- };
- let do_heal = false;
- if (pot_type=="blue" && is_front_healable.indexOf(true)>=0) {
- do_heal = true;
- }else if (pot_type=="green" && is_player_healable[char_id]) {
- do_heal = true;
- }else{
- if (typeof callback == "function") {
- callback();
- }
- }
- if (do_heal) {
- checkEl(query.battle_ui.heal,0,clickHeal);
- }
- };
-
- let check_exist = setInterval(function() {
- console.log("querying enemy name to appear");
- if (document.querySelector("a.btn-targeting.enemy-1:not(.invisible)") !== null || document.querySelector("a.btn-targeting.enemy-2:not(.invisible)") !== null || document.querySelector("a.btn-targeting.enemy-3:not(.invisible)") !== null){
- console.log("check width enemy name");
- if (document.querySelector("a.btn-targeting.enemy-1:not(.invisible)").getBoundingClientRect().width>0 || document.querySelector("a.btn-targeting.enemy-2:not(.invisible)").getBoundingClientRect().width>0 || document.querySelector("a.btn-targeting.enemy-3:not(.invisible)").getBoundingClientRect().width>0){
- console.log("found enemy name");
- clearInterval(check_exist);
- let is_quest_id_valid = false;
- let is_twitter_valid = false;
- try{
- console.log(rep.quest_id);
- if (rep.quest_id!==undefined) {
- is_quest_id_valid = true;
- }
- }
- catch(err){
- console.log(err.message);
- }
- console.log("is_quest_id_valid:" +(is_quest_id_valid).toString());
- try{
- console.log(rep.twitter.monster);
- if (rep.twitter.monster!==undefined) {
- is_twitter_valid = true;
- }
- }
- catch(err){
- console.log(err.message);
- }
- console.log("is_twitter_valid:" +(is_twitter_valid).toString());
- let case_battle = false;
- if (is_quest_id_valid){
- if(rep.quest_id == trial_id){
- case_battle = 99;
- }else{
- for (let i in quests_id) {
- if (rep.quest_id == quests_id[i] && case_battle === false) {
- case_battle = parseInt(i)+1;
- }
- }
- }
- }
- if (case_battle === false && is_twitter_valid){
- for (let i in monsters_name) {
- if (rep.twitter.monster==monsters_name[i] && case_battle === false) {
- case_battle = parseInt(i)+1;
- }
- }
- }
- console.log("case_battle:" + case_battle.toString());
- let chara_id;
- let clickChar = function(param,callback=false){
- chara_id = param;
- // click_n_check("div.prt-member>div.lis-character"+(param-1)+".btn-command-character:not(.invisible)>img.img-chara-command",0,"div.prt-member>div.lis-character"+(param-1)+".btn-command-character.invisible>img.img-chara-command",0,"clicking "+get_chara_str(param),callback)
- clickAndCheck("div.prt-member>div.btn-command-character>img.img-chara-command",param-1,".prt-command-chara.chara"+(param.toString()),0,my_profile+"Clicking "+getCharStr(param),callback);
- };
- let hp = ((parseInt(rep.boss.param[0].hp) / parseInt(rep.boss.param[0].hpmax)) * 100).toString();
- if (hp.indexOf(".")>=0){
- hp = hp.substring(0,hp.indexOf("."));
- }
- // console.log(hp);
- // let attack_msg = my_profile+"Foe hp is "+hp+"% left, commencing attack";
- // let clickAttack = function(callback=false){
- // // let init_recheckClickAttack = function(){
- // // };
- // clickAndCheck(".btn-attack-start.display-on",0,".btn-attack-cancel.btn-cancel.display-on",0,attack_msg,false,20);
- // // clickEl(".btn-attack-start.display-on",0,attack_msg,init_recheckClickAttack);
- // };
-
- battleLogic(case_battle);
-
- // if (case_battle === 99){
- // if (rep.turn===1) {
- // reload(20);
- // let doit3 = function(){clickEl(".btn-usual-ok",0,message.raid.trial.ok);};
- // let doit2 = function(){clickEl(".btn-withdrow.btn-red-m",0,message.raid.trial.retreat,doit3);};
- // let doit1 = function(){clickEl(".btn-raid-menu.menu",0,message.raid.trial.open_menu,doit2);};
- // clickAndNegCheck(query.battle_ui.trial_pop_up.close,0,message.raid.trial.close_pop_up,doit1);
- // }
- // }else{
- // reload(30);
-
- // // console.log(rep.quest_id==quests_id[2] || rep.twitter.monster==monsters_name[2]);
- // if (case_battle === 1){
- // if (rep.turn===1){
- // reload(40);
- // let char3_1;
- // let auto_ougi = function(){toggleOugi(true,clickAttack);};
- // let char2_b = function(){clickBack(auto_ougi);};
- // let char2_2 = function(){useSkill(chara_id,2,char2_b);};
- // let char2 = function(){clickChar(2,char2_2);};
- // let char1_b = function(){clickBack(char2);};
- // let char1_3 = function(){useSkill(chara_id,3,char1_b);};
- // let char1_2 = function(){useSkill(chara_id,2,char1_3);};
- // let char1 = function(){clickChar(1,char1_2);};
- // let char3_b = function(){clickBack(char1);};
- // let char3_2 = function(){useSkill(chara_id,2,char3_b);};
- // let char3_3 = function(){useSkill(chara_id,3,char3_2);};
- // if (rep.player.param[2].recast>=90) {
- // char3_1 = function(){useSkill(chara_id,1,char3_2);};
- // } else {
- // char3_1 = function(){useSkill(chara_id,1,char3_3);};
- // }
- // let char3 = function(){clickChar(3,char3_1);};
- // char3();
- // }else{
- // reload(15);
- // clickAttack();
- // }
- // }else if (case_battle === 2) {
- // if (rep.turn===1){
- // reload(35);
- // let char1_4;
- // let char1_2;
- // let auto_ougi = function(){toggleOugi(true,clickAttack);};
- // // let char2_b = function(){clickBack(auto_ougi);};
- // // let char2_1 = function(){useSkill(chara_id,1,char2_b);};
- // // let char2 = function(){clickChar(2,char2_1);};
- // let char1_b = function(){clickBack(auto_ougi);};
- // let char1_3 = function(){useSkill(chara_id,3,char1_b);};
- // // if (parseInt(ougi_bars[0].innerHTML)>=100){
- // // char1_4 = function(){useSkill(chara_id,4,char1_b);};
- // // }else{
- // // char1_4 = function(){useSkill(chara_id,4,char1_3);};
- // // }
- // char1_4 = function(){useSkill(chara_id,4,char1_3);};
- // char1_2 = function(){useSkill(chara_id,2,char1_4);};
- // let char1 = function(){clickChar(1,char1_2);};
- // let summon5_ok = function(){clickOkSummon(char1);};
- // let summon5 = function(){clickSummon(5,summon5_ok,char1);};
- // let summon5_p = function(){clickSummonPanel(summon5);};
- // summon5_p();
- // }else if (rep.turn===2) {
- // reload(35);
- // let auto_ougi = function(){toggleOugi(true,clickAttack);};
- // let char3_b = function(){clickBack(auto_ougi);};
- // let char3_1 = function(){useSkill(chara_id,1,char3_b);};
- // let char3_2 = function(){useSkill(chara_id,2,char3_1);};
- // let char3 = function(){clickChar(3,char3_2);};
- // let char4_b = function(){clickBack(char3);};
- // let char4_3 = function(){useSkill(chara_id,3,char4_b);};
- // let char4_1 = function(){useSkill(chara_id,1,char4_3);};
- // let char4 = function(){clickChar(4,char4_1);};
- // let summon6_ok = function(){clickOkSummon(char4);};
- // let summon6 = function(){clickSummon(6,summon6_ok,char4);};
- // let summon6_p = function(){clickSummonPanel(summon6);};
- // summon6_p();
- // }else{
- // reload(15);
- // clickAttack();
- // }
- // }else if (case_battle === 3) {
- // if (rep.turn===1) {
- // reload(60);
- // let auto_ougi = function(){toggleOugi(true,clickAttack);};
- // let healSarasa2 = function(){usePot("green",1,auto_ougi);};
- // let char4_b = function(){clickBack(healSarasa2);};
- // let char4_3 = function(){useSkill(chara_id,3,char4_b);};
- // let char4_1 = function(){useSkill(chara_id,1,char4_3);};
- // let char4 = function(){clickChar(4,char4_1);};
- // let char2_b = function(){clickBack(char4);};
- // let char2_1 = function(){useSkill(chara_id,1,char2_b);};
- // let char2_2 = function(){useSkill(chara_id,2,char2_1);};
- // let char2 = function(){clickChar(2,char2_2);};
- // let char3_b = function(){clickBack(char2);};
- // let char3_3 = function(){useSkill(chara_id,3,char3_b);};
- // let char3 = function(){clickChar(3,char3_3);};
- // let healSarasa = function(){usePot("green",1,char3);};
- // let char1_b = function(){clickBack(healSarasa);};
- // let char1_4 = function(){useSkill(chara_id,4,char1_b);};
- // let char1_3 = function(){useSkill(chara_id,3,char1_4);};
- // let char1_1 = function(){useSkill(chara_id,1,char1_3);};
- // let char1_2 = function(){useSkill(chara_id,2,char1_1);};
- // let char1 = function(){clickChar(1,char1_2);};
- // let char2a_b = function(){clickBack(char1);};
- // let char2a_3 = function(){useSkill(chara_id,3,char2a_b);};
- // let char2a = function(){clickChar(2,char2a_3);};
- // let getBluePot = function(){doChat(char2a);};
- // let summon1_ok = function(){clickOkSummon(getBluePot);};
- // let summon1 = function(){clickSummon(1,summon1_ok,getBluePot);};
- // let summon1_p = function(){clickSummonPanel(summon1);};
- // summon1_p();
- // // reload(60);
- // // let auto_ougi = function(){toggleOugi(true,clickAttack);};
- // // let char4_b = function(){clickBack(auto_ougi);};
- // // let char4_3 = function(){useSkill(chara_id,3,char4_b);};
- // // let char4_1 = function(){useSkill(chara_id,1,char4_3);};
- // // let char4 = function(){clickChar(4,char4_1);};
- // // let char2_b = function(){clickBack(char4);};
- // // let char2_1 = function(){useSkill(chara_id,1,char2_b);};
- // // let char2_2 = function(){useSkill(chara_id,2,char2_1);};
- // // let char2 = function(){clickChar(2,char2_2);};
- // // let char3_b = function(){clickBack(char2);};
- // // let char3_3 = function(){useSkill(chara_id,3,char3_b);};
- // // let char3 = function(){clickChar(3,char3_3);};
- // // let char1_b = function(){clickBack(char3);};
- // // let char1_4 = function(){useSkill(chara_id,4,char1_b);};
- // // let char1_3 = function(){useSkill(chara_id,3,char1_4);};
- // // let char1_1 = function(){useSkill(chara_id,1,char1_3);};
- // // let char1_2 = function(){useSkill(chara_id,2,char1_1);};
- // // let char1 = function(){clickChar(1,char1_2);};
- // // let summon1_ok = function(){clickOkSummon(char1);};
- // // let summon1 = function(){clickSummon(1,summon1_ok,char1);};
- // // let summon1_p = function(){clickSummonPanel(summon1);};
- // // doChat(summon1_p);
- // }else if (rep.turn===2) {
- // reload(20);
- // let auto_ougi = function(){toggleOugi(false,clickAttack);};
- // let summon5_ok = function(){clickOkSummon(auto_ougi);};
- // let summon5 = function(){clickSummon(5,summon5_ok,auto_ougi);};
- // let summon5_p = function(){clickSummonPanel(summon5);};
- // summon5_p();
- // }else if (rep.turn===3) {
- // reload(20);
- // let auto_ougi = function(){toggleOugi(true,clickAttack);};
- // let char3_b = function(){clickBack(auto_ougi);};
- // let char3_1 = function(){useSkill(chara_id,1,char3_b);};
- // let char3 = function(){clickChar(3,char3_1);};
- // char3();
- // }else if (rep.turn===4) {
- // reload(20);
- // let auto_ougi = function(){toggleOugi(true,clickAttack);};
- // let summon6_ok = function(){clickOkSummon(auto_ougi);};
- // let summon6 = function(){clickSummon(6,summon6_ok,auto_ougi);};
- // let summon6_p = function(){clickSummonPanel(summon6);};
- // summon6_p();
- // }else if (rep.turn===5) {
- // reload(30);
- // let auto_ougi = function(){toggleOugi(false,clickAttack);};
- // let char2_b = function(){clickBack(auto_ougi);};
- // let char2_1 = function(){useSkill(chara_id,1,char2_b);};
- // let char2 = function(){clickChar(2,char2_1);};
- // let summon4_ok = function(){clickOkSummon(char2);};
- // let summon4 = function(){clickSummon(4,summon4_ok,char2);};
- // let summon4_p = function(){clickSummonPanel(summon4);};
- // summon4_p();
- // }else if (rep.turn===6) {
- // reload(35);
- // let char1,char1_1,char1_2;
- // let auto_ougi = function(){toggleOugi(true,clickAttack);};
- // let char4_b = function(){clickBack(auto_ougi);};
- // let char4_3 = function(){useSkill(chara_id,3,char4_b);};
- // let char4_1 = function(){useSkill(chara_id,1,char4_3);};
- // let char4 = function(){clickChar(4,char4_1);};
- // let char3_b = function(){clickBack(char4);};
- // let char3_2 = function(){useSkill(chara_id,2,char3_b);};
- // let char3 = function(){clickChar(3,char3_2);};
- // let char1_b = function(){clickBack(char3);};
- // let char1_4 = function(){useSkill(chara_id,4,char1_b);};
- // let char1_3 = function(){useSkill(chara_id,3,char1_4);};
- // if (player_status[0].recast>=30) {
- // char1_1 = function(){useSkill(chara_id,1,char1_3);};
- // char1_2 = function(){useSkill(chara_id,2,char1_1);};
- // char1 = function(){clickChar(1,char1_2);};
- // }else{
- // char1_2 = function(){useSkill(chara_id,2,char1_3);};
- // char1_1 = function(){useSkill(chara_id,1,char1_2);};
- // char1 = function(){clickChar(1,char1_1);};
- // }
- // char1();
- // }else if (rep.turn===7) {
- // reload(30);
- // let auto_ougi = function(){toggleOugi(false,clickAttack);};
- // let summon3_ok = function(){clickOkSummon(auto_ougi);};
- // let summon3 = function(){clickSummon(3,summon3_ok,auto_ougi);};
- // let summon3_p = function(){clickSummonPanel(summon3);};
- // let useBluePot = function(){(usePot("blue",false,summon3_p));};
- // useBluePot();
- // }else if (rep.turn===8) {
- // reload(20);
- // let auto_ougi = function(){toggleOugi(false,clickAttack);};
- // let char2_b = function(){clickBack(auto_ougi);};
- // let char2_2 = function(){useSkill(chara_id,2,char2_b);};
- // let char2 = function(){clickChar(2,char2_2);};
- // let char3_b = function(){clickBack(char2);};
- // let char3_3 = function(){useSkill(chara_id,3,char3_b);};
- // let char3 = function(){clickChar(3,char3_3);};
- // char3();
- // }else if (rep.turn===9) {
- // reload(20);
- // let auto_ougi = function(){toggleOugi(true,clickAttack);};
- // let char2_b = function(){clickBack(auto_ougi);};
- // let char2_1 = function(){useSkill(chara_id,1,char2_b);};
- // let char2 = function(){clickChar(2,char2_1);};
- // let char3_b = function(){clickBack(char2);};
- // let char3_1 = function(){useSkill(chara_id,1,char3_b);};
- // let char3 = function(){clickChar(3,char3_1);};
- // char3();
- // }else if (rep.turn===10) {
- // reload(20);
- // let auto_ougi = function(){toggleOugi(true,clickAttack);};
- // let summon2_ok = function(){clickOkSummon(auto_ougi);};
- // let summon2 = function(){clickSummon(2,summon2_ok,auto_ougi);};
- // let summon2_p = function(){clickSummonPanel(summon2);};
- // summon2_p();
- // }else if (rep.turn===11) {
- // reload(40);
- // let char1,char1_1,char1_2;
- // let auto_ougi = function(){toggleOugi(true,clickAttack);};
- // let char4_b = function(){clickBack(auto_ougi);};
- // let char4_4 = function(){useSkill(chara_id,4,char4_b);};
- // let char4_3 = function(){useSkill(chara_id,3,char4_4);};
- // let char4_1 = function(){useSkill(chara_id,1,char4_3);};
- // let char4 = function(){clickChar(4,char4_1);};
- // let char2_b = function(){clickBack(char4);};
- // let char2_4 = function(){useSkill(chara_id,4,char2_b);};
- // let char2 = function(){clickChar(2,char2_4);};
- // let char1_b = function(){clickBack(char2);};
- // let char1_4 = function(){useSkill(chara_id,4,char1_b);};
- // let char1_3 = function(){useSkill(chara_id,3,char1_4);};
- // if (player_status[0].recast>=30) {
- // char1_1 = function(){useSkill(chara_id,1,char1_3);};
- // char1_2 = function(){useSkill(chara_id,2,char1_1);};
- // char1 = function(){clickChar(1,char1_2);};
- // }else{
- // char1_2 = function(){useSkill(chara_id,2,char1_3);};
- // char1_1 = function(){useSkill(chara_id,1,char1_2);};
- // char1 = function(){clickChar(1,char1_1);};
- // }
- // let summon1_ok = function(){clickOkSummon(char1);};
- // let summon1 = function(){clickSummon(1,summon1_ok,char1);};
- // let summon1_p = function(){clickSummonPanel(summon1);};
- // summon1_p();
- // }else{
- // reload(15);
- // clickAttack();
- // }
- // }else if (case_battle === 5) {
- // // let char1 = function(){clickChar(1);};
- // // usePot("green",3,char1);
- // }
- // }
- }
- }
- }, 300);
-
- }
-
- function raidFinish(rep){
- console.log(raidFinish.name);
- reload(10);
- let cmd = [];
- let check_timer = true;
- cmd.push({"cmd":"log","level":"process","msg":message.raid.finish});
- let reward_list = {};
- let loop_list = [1,2,3,4,11];
-
- for (let l in loop_list){
- if (Object.keys(rep.rewards.reward_list[loop_list[l]]).length){
- let keys = [];
- for(let k in rep.rewards.reward_list[loop_list[l]]) keys.push(k);
- for(let i in keys){
- if(reward_list[rep.rewards.reward_list[loop_list[l]][keys[i]].name]){
- reward_list[rep.rewards.reward_list[loop_list[l]][keys[i]].name] += parseInt(rep.rewards.reward_list[loop_list[l]][keys[i]].count);
- }else{
- reward_list[rep.rewards.reward_list[loop_list[l]][keys[i]].name] = parseInt(rep.rewards.reward_list[loop_list[l]][keys[i]].count);
- }
- }
- }
- }
- if (tracked_item !== false){
- let track_item = my_profile+"Current Status:";
- let temp_str;
- for (let item in tracked_item){
- if (tracked_item.hasOwnProperty(item)) {
- temp_str = "\n- "+tracked_item[item].name+": "+(tracked_item[item].number).toString();
- track_item += temp_str;
- }
- }
- cmd.push({"cmd":"log","level":"summary","msg":track_item,"split":0});
- }
- cmd.push({"cmd":"reward","payload":reward_list});
- if (check_timer){
- cmd.push({"cmd":"check_timer"});
- }
- xhr.open('POST', server);
- xhr.send(JSON.stringify(cmd));
- let gotoMain = function() {gotoHash("main");};
- checkEl(".mask",0,gotoMain);
- }