top.goSit(1); var zas = []; var priem_use = 0; var magic_use = 0; var use_on_pers = 'none'; var smena_login = 'none'; var leader_login = 'none'; var leader_type = 1; zas[1] = 0; zas[2] = 0; zas[3] = 0; zas[4] = 0; zas[5] = 0; var zbs = []; zbs[1] = 0; var sel_atack = 1; var nos = 0; var noconnect = 5; var connect = 0; var eatk = 0; var ggcode = '2014'; var irn = 0; function magic_div(id, name, img, title) { } function testClearZone() { if (top.slcbrc[4] === 0) { all_radio_off(); } } async function usepriem(id) { irn++; await $.post(`jx/battle/refresh.php?rnd=${ggcode}&irn=${irn}`, { idlog: top.id_log, usepriem: id, useon: use_on_pers }, function (data) { $("#ref").html(data); }); use_on_pers = 'none'; top.goSit(1); } async function useitem(id, use_item_on) { irn++; if (top.c.noEr === 0) { top.c.noEr = 1; clearTimeout(top.c.noErTmr); top.c.noErTmr = setTimeout('top.c.noEr = 0;', 1000); await $.post(`jx/battle/refresh.php?rnd=${ggcode}&irn=${irn}`, { idlog: top.id_log, useitem: id, useitemon: use_item_on }, function (data) { $("#ref").html(data); }); } return top.goSit(1); } function volna(id) { document.getElementById('volna').innerHTML = `Волна: ${id}`; } function change_radioKeys(id = 0) { let jo; let radio; let z = 0, t = ''; let i = 1, j = 1; while (i <= za) { j = 1; jo = 0; while (j <= 5) { radio = document.getElementById(`atack_${i}_${j}`); if (radio) { if (radio.className != null && radio.className === "radio_on") jo++; } j++; } if (jo === 0 && z === 0) { z = i; t = 'atack'; } i++; } if (z === 0) { i = 1; jo = 0; while (i <= 5) { radio = document.getElementById(`block_1_${i}`); if (radio) { if (radio.className != null && radio.className === "radio_on") jo++; } i++; } if (jo === 0 && z === 0) { z = 1; t = 'block'; } } if (z === 0 || id === 0) { all_radio_off(); refleshPoints(); } if (z > 0) { if (id === 0) { //автовыставление } else change_radio(z, id, t, 1) } } function change_radio(id, zone, type, r) { radio_off(id, zone, type); const radio = document.getElementById(`${type}_${id}_${zone}`); if (radio.className === "radio_on" && r === 0) { radio.className = "radio_off"; if (type === 'atack') zas[id] = 0; else zbs[id] = 0; } else { radio.className = "radio_on"; if (type === 'atack') zas[id] = zone; else zbs[id] = zone; } refleshPoints(); } function tactic(id, value) { document.getElementById(`tac${id}`).innerHTML = value; } function refleshPoints() { clearZone(); let i = 5; while (i >= 1) { if (zas[i] === 0) lineAtack(i); i--; } if (zbs[1] === 0) lineBlock(); } function lineAtack(id) { nos++; let j = 1; while (j <= 5) { document.getElementById(`zatack${id}_${j}`).className = 'zoneCh_yes'; j++; } } function lineBlock() { nos++; let j = 1; while (j <= 5) { document.getElementById(`zblock1_${j}`).className = 'zoneCh_yes'; j++; } } function clearZone() { nos = 0; let i = 1; while (i <= 5) { let j = 1; while (j <= 5) { document.getElementById(`zatack${i}_${j}`).className = 'zoneCh_no'; j++; } i++; } i = 1; while (i <= 5) { document.getElementById(`zblock1_${i}`).className = 'zoneCh_no'; i++; } } function select_atack(id, r) { let i = 5; while (i >= 1) { if (zas[i] === 0) { if (i <= za) sel_atack = i } i--; } if (sel_atack > za) sel_atack = 1; change_radio(sel_atack, id, 'atack', r); sel_atack++; } function radio_off(id, zone, type) { let i = 1; while (i <= 5) { if (document.getElementById(`${type}_${id}_${i}`) && i !== zone) { document.getElementById(`${type}_${id}_${i}`).className = "radio_off"; if (type === 'atack') zas[id] = 0; else zbs[id] = 0; } i++; } } function all_radio_off() { let i = 1; while (i <= 5) { let j = 1; while (j <= 5) { document.getElementById(`atack_${j}_${i}`).className = "radio_off"; j++; } document.getElementById(`block_1_${i}`).className = "radio_off"; zas[i] = 0; i++; } zbs[1] = 0; } function genZoneBlock() { let i = 1; while (i <= 5) { let j = 1; while (j <= 3) { if (j === zb) { document.getElementById(`txtb${i}_${j}`).style.display = ''; } else { document.getElementById(`txtb${i}_${j}`).style.display = 'none'; } j++; } i++; } } function genZoneAtack() { let i = 1; while (i <= 5) { let j = 1; while (j <= 5) { if (i <= za) { document.getElementById(`zatack${i}_${j}`).style.display = ''; } else { document.getElementById(`zatack${i}_${j}`).style.display = 'none'; } j++; } i++; } } function genteam(team) { document.getElementById('teams').innerHTML = team; } async function reflesh() { irn++; if (battleFinishData != -1) mainstatus(0); if (battleFinishData == -1) { if (top.c.noEr === 0) { top.c.noEr = 1; clearTimeout(top.c.noErTmr); top.c.noErTmr = setTimeout('top.c.noEr = 0;', 1000); await $.post(`jx/battle/refresh.php?irn=${irn}&rnd=${ggcode}`, { id: 'reflesh', idlog: top.id_log, idpr: priem_use, mgid: magic_use, useon: use_on_pers, smn: smena_login, ldrl: leader_login, ldrt: leader_type }, function (data) { $("#ref").html(data); }); } if (g_iCount !== 45) g_iCount = 45; } } function autobattle() { let i = 1; while (i <= za) { if (zas[i] === 0 || top.slcbrc[4] === 1) { zas[i] = Math.floor(Math.random() * 5 + 1); change_radio(i, zas[i], 'atack', 1); } i++; } if (zbs[1] === 0 || top.slcbrc[4] === 1) { zbs[1] = Math.floor(Math.random() * 5 + 1); change_radio(1, zbs[1], 'block', 1); } } // sleep time expects milliseconds function sleep(time) { return new Promise((resolve) => setTimeout(resolve, time)); } // Действите при выставлении хода и нажатии на Вперёд! async function atack() { if (top.slcbrc[3] === 1) autobattle(); const ago = `${zas[1]}_${zas[2]}_${zas[3]}_${zas[4]}_${zas[5]}`; const bgo = zbs[1]; irn++; if (top.c.noEr === 0) { top.c.noEr = 1; clearTimeout(top.c.noErTmr); top.c.noErTmr = setTimeout('top.c.noEr = 0;', 1000); await $.post(`jx/battle/refresh.php?irn=${irn}&rnd=${ggcode}`, { atack: ago, block: bgo, idlog: top.id_log, idpr: priem_use, mgid: magic_use, useon: use_on_pers, smn: smena_login, ldrl: leader_login, ldrt: leader_type }, function (data) { $("#ref").html(data); }); } } var g_iCount = 45; let tmr0057 = null; // 1.1 function startCountdown() { if (tmr0057 !== null) clearTimeout(tmr0057); if ((g_iCount - 1) >= 0) { g_iCount -= 1; return tmr0057 = setTimeout(startCountdown, 1000); } reflesh(); return tmr0057 = setTimeout(startCountdown, 1000); } let img_battle = ``; function mainstatus(id) { id = +id; if (isNaN(id)) id = 0; if (smnpty <= 0) { $('#btn_down_img2').css({'display': 'none'}); } else { $('#btn_down_img2').css({'display': ''}); $('#btn_down_img2').attr('title', `Смена противника (${smnpty})`); } if (battleFinishData != -1) { // хуй знает че такое document.getElementById('mainpanel2').style.display = ''; // 4 document.getElementById('go_btn').style.display = 'none'; // 4 document.getElementById('mainpanel').style.display = 'none'; // 4 document.getElementById('mainpanel222').style.display = 'none'; // 4 document.getElementById('reflesh_btn').style.display = 'none'; // 3 document.getElementById('back_menu_down').style.display = ''; // 2 document.getElementById('btn_down_img1').style.display = ''; // 2 document.getElementById('btn_down_img2').style.display = 'none'; // 2 document.getElementById("ref").innerHTML = `
${battleFinishData}
`; rand_img(); document.getElementById("player2").innerHTML = `
${img_battle}
`; document.getElementById('player2_login').style.display = 'none'; } else if (id === 1) //Можно ударить противника ( доступный удар ) { document.getElementById('mainpanel').style.display = ''; // 4 document.getElementById('player2_login').style.display = ''; document.getElementById('mainpanel222').style.display = ''; // 4 document.getElementById('mainpanel2').style.display = 'none'; // 4 document.getElementById('go_btn').style.display = ''; // 4 document.getElementById('btn_down_img1').setAttribute("onclick", "reflesh();"); document.getElementById('go_btn').setAttribute("class", "buttons btnnew btnnew2"); document.getElementById('go_btn').setAttribute("onclick", "atackt();"); if (document.getElementById('reflesh_btn')) { document.getElementById('reflesh_btn').style.display = 'none'; } } else if (id === 2) //Ожидаем хода противника ( обновить ) { document.getElementById('mainpanel').style.display = 'none'; // 4 document.getElementById('mainpanel222').style.display = 'none'; // 4 document.getElementById('mainpanel2').style.display = ''; // 4 document.getElementById('go_btn').style.display = 'none'; // 4 document.getElementById('reflesh_btn').style.display = ''; // 3 rand_img(); document.getElementById("player2").innerHTML = `
${img_battle}
`; document.getElementById('player2_login').style.display = 'none'; document.getElementById('btn_down_img1').setAttribute("onclick", "reflesht();"); document.getElementById('reflesh_btn').setAttribute("class", "buttons btnnew btnnew2"); document.getElementById('reflesh_btn').setAttribute("onclick", "reflesht();"); } else if (id === 3) // Проиграли. Ожидаем завершения поединка ( кнопка вернутся с поединка ) { document.getElementById('mainpanel2').style.display = ''; // 4 document.getElementById('go_btn').style.display = 'none'; // 4 document.getElementById('mainpanel').style.display = 'none'; // 4 document.getElementById('mainpanel222').style.display = 'none'; // 4 document.getElementById('back_menu_down').style.display = 'none'; // 2 document.getElementById('reflesh_btn').style.display = ''; // 3 document.getElementById('reflesh_btn').setAttribute("class", "buttons inpBtl btnnew"); // document.getElementById('btn_down_img1').setAttribute("onclick", "reflesh();"); document.getElementById('btn_down_img1').style.display = ''; // 2 document.getElementById('btn_down_img2').style.display = 'none'; // 2 document.getElementById("ref").innerHTML = "Вы повержены. Ожидайте пока поединок завершат другие бойцы..."; document.getElementById("player2").innerHTML = `
${img_battle}
`; document.getElementById('player2_login').style.display = 'none'; } if (!document.getElementById('mainpanel').style.display) { document.getElementById('mainpanel2').style.display = 'none'; } top.goSit(1); } function rand_img() { img_battle = ``; } var fstlh = 0; var lsti = 0; var lsthd = []; var id_log_ar = []; var id_log; var type_log = top.type_log; // Эта функция получает элемент по идентификатору из фрейма 'main'. const getElementByIdInMainFrame = (id) => { const frame = top.frames['main']; if (!frame) { console.error("Фрейм 'main' не найден!"); return null; } return frame.document.getElementById(id); }; function add_log(id, text, hod_id, vars) { const logsdiv = getElementByIdInMainFrame('battle_logg'); let hodlogdiv = getElementByIdInMainFrame(`battle_log_${hod_id}`); const hodlogdiv7 = getElementByIdInMainFrame(`battle_log_${hod_id - 7}`); const hodlogdiv25 = getElementByIdInMainFrame(`battle_log_${hod_id - 25}`); const logid = getElementByIdInMainFrame(`log_id_${id}`); if (top.des === 1) type_log = 0 else type_log = 1; if (type_log === 1) { chsee = 'chsee2'; text = looklogrep(text, vars); id_log_ar[id] = id; id_log = id; if (!hodlogdiv && hod_id !== 1) { if (fstlh === 0) fstlh = hod_id lsthd[lsti] = hod_id; lsti++; logsdiv.insertAdjacentHTML('afterbegin', `
`); hodlogdiv = getElementByIdInMainFrame(`battle_log_${hod_id}`); } else if (!hodlogdiv) { logsdiv.insertAdjacentHTML('beforeend', `
`); hodlogdiv = getElementByIdInMainFrame(`battle_log_${hod_id}`); } if (!logid) { hodlogdiv.insertAdjacentHTML('afterbegin', `${text}
`); } if (hodlogdiv25) { top.rmve(`#battle_log_${hod_id - 25}`); } return } chsee = 'chsee2'; text = looklogrep(text, vars); id_log_ar[id] = id; id_log = id; if (!hodlogdiv && hod_id !== 1) { if (fstlh === 0) { fstlh = hod_id; } lsthd[lsti] = hod_id; lsti++; logsdiv.insertAdjacentHTML('afterbegin', `
`); hodlogdiv = getElementByIdInMainFrame(`battle_log_${hod_id}`); } else if (!hodlogdiv) { logsdiv.insertAdjacentHTML('beforeend', `
`); hodlogdiv = getElementByIdInMainFrame(`battle_log_${hod_id}`); } if (!logid) { hodlogdiv.insertAdjacentHTML('afterbegin', `${text}
`); } if (hodlogdiv7) { top.rmve(`#battle_log_${hod_id - 7}`); } } //-- Мой лог-------------------------------- //------------------------------------------- function add_mlog(id, text, hod_id, vars) { const logsdiv = getElementByIdInMainFrame('battle_mlogg'); let hodlogdiv = getElementByIdInMainFrame(`battle_mlog_${hod_id}`); const hodlogdiv14 = getElementByIdInMainFrame(`battle_mlog_${hod_id - 14}`); const logid = getElementByIdInMainFrame(`mlog_id_${id}`); chsee = 'chsee7'; text = looklogrep(text, vars); id_log_ar[id] = id; id_log = id; if (!hodlogdiv && hod_id !== 1) { logsdiv.insertAdjacentHTML('afterbegin', `
`); hodlogdiv = getElementByIdInMainFrame(`battle_mlog_${hod_id}`); } else if (!hodlogdiv) { logsdiv.insertAdjacentHTML('beforeend', `
`); hodlogdiv = getElementByIdInMainFrame(`battle_mlog_${hod_id}`); } if (!logid) { hodlogdiv.insertAdjacentHTML('afterbegin', `${text}
`); } if (hodlogdiv14) { top.rmve(`#battle_mlog_${hod_id - 14}`); } } //------------------------------------------- var moveState = false; // Переменные координат мыши в начале перемещения, пока неизвестны var x0, y0; // Начальные координаты элемента, пока неизвестны var divX0, divY0; function defPosition(event) { var x = y = 0; if (document.attachEvent != null) { // Internet Explorer & Opera x = window.event.clientX + documentElement.scrollLeft + document.body.scrollLeft; y = window.event.clientY + documentElement.scrollTop + document.body.scrollTop; } if (!document.attachEvent && document.addEventListener) { // Gecko x = event.clientX + window.scrollX; y = event.clientY + window.scrollY; } return {x: x, y: y}; } document.onmouseup = function () { moveState = false; } function usePriem(id) { priem_use = id; if (id) reflesh(); }