277 lines
8.9 KiB
PHP
277 lines
8.9 KiB
PHP
<?php
|
||
|
||
use Core\Config;
|
||
use Core\Db;
|
||
|
||
session_start();
|
||
$tm = microtime(true);
|
||
|
||
if (!isset($CRON_CORE)) {
|
||
require_once('../../_incl_data/__config.php');
|
||
}
|
||
|
||
if (!isset($CRON_CORE)) {
|
||
define('GAME', true);
|
||
require_once('../../_incl_data/class/__db_connect.php');
|
||
}
|
||
|
||
function e($t): void
|
||
{
|
||
(new Chat())->debug($t, true);
|
||
}
|
||
|
||
if (isset($_GET['cron_core'])) { // что ты такое?
|
||
$id = [
|
||
'id' => $_GET['uid'],
|
||
'pass' => $_GET['pass'],
|
||
];
|
||
if (md5($id['id'] . '_brfCOreW@!_' . $id['pass']) == $_GET['cron_core']) {
|
||
|
||
$CRON_CORE = true;
|
||
$_COOKIE['login'] = User::getLoginById($id['id']);
|
||
$_POST['id'] = 'reflesh';
|
||
}
|
||
}
|
||
|
||
if (!isset($CRON_CORE)) {
|
||
header('Expires: Mon, 26 Jul 1970 05:00:00 GMT');
|
||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||
header('Cache-Control: no-store, no-cache, must-revalidate');
|
||
header('Cache-Control: post-check=0, pre-check=0', false);
|
||
header('Pragma: no-cache');
|
||
}
|
||
|
||
if (
|
||
$_SERVER['HTTP_X_REQUESTED_WITH'] != 'XMLHttpRequest' && !isset($CRON_CORE) ||
|
||
!isset($_POST['atack'], $_POST['block']) && (!isset($_POST['id']) || $_POST['id'] != 'reflesh') && !isset($_POST['usepriem']) && !isset($_POST['useitem'])
|
||
) {
|
||
return;
|
||
}
|
||
|
||
unset($tm);
|
||
$js = '';
|
||
$u = User::start();
|
||
$magic = new Magic();
|
||
$priem = new Priems();
|
||
|
||
if ($u->info['battle'] == 0) {
|
||
$btlLastId = Db::getValue('select id from battle_users where uid = ? and finish = 0 limit 1', [$u->info['id']]);
|
||
if ($btlLastId) {
|
||
echo "<script>document.getElementById('teams').style.display='none'; var battleFinishData = '{$u->info['battle_text']}';</script>";
|
||
$u->info['battle'] = $btlLastId;
|
||
$u->info['battle_lsto'] = true;
|
||
Db::sql("update stats set battle_text = '', last_b = 0 where id = ?", [$u->info['id']]);
|
||
Db::sql('update battle_users set finish = 1 where uid = ?', [$u->info['id']]);
|
||
echo '<script>alert("Поединок для вас завершился.");location.href="main.php?finish=1";</script>';
|
||
}
|
||
}
|
||
|
||
if (!isset($CRON_CORE) && (!isset($u->info['id']) || ($u->info['joinIP'] == 1 && $u->info['ip'] != $_SERVER['HTTP_X_REAL_IP']))) {
|
||
die(Config::get('exit'));
|
||
}
|
||
|
||
$u->stats = $u->getStats($u->info['id']);
|
||
|
||
if (!isset($CRON_CORE) && $u->info['online'] < time() - 30) {
|
||
Db::sql('update users set online = unix_timestamp(), timeMain = unix_timestamp() where id = ?', [$u->info['id']]);
|
||
}
|
||
|
||
$error = fn(string $str): string => '<div style="color: red; text-align: center; font-weight: bold;">' . $str . '</div>';
|
||
|
||
$btl = new Battle();
|
||
require_once('log_text.php');
|
||
$btl->is = $u->is;
|
||
$btl->items = $u->items;
|
||
$btl->info = $btl->battleInfo($u->info['battle']);
|
||
|
||
if (!isset($btl->info['id'])) {
|
||
if ($u->info['battle'] == -1) {
|
||
//завершаем поединок
|
||
Db::sql('update users set battle = 0, online = unix_timestamp() where id = ?', [$u->info['id']]);
|
||
exit('<script>location="main.php";</script>');
|
||
} else {
|
||
Db::sql('update users set battle = 0 where battle = ?', [$u->info['battle']]);
|
||
if (!isset($CRON_CORE)) {
|
||
exit('<script>location="main.php";</script>');
|
||
}
|
||
}
|
||
} else {
|
||
//получаем массив с игроками в бою
|
||
$btl->teamsTake($u);
|
||
|
||
if (isset($_POST['useitem']) && $btl->testUsersLive()) {
|
||
$magic->useItems((int)$_POST['useitem']);
|
||
if ($u->error != '') {
|
||
echo $error($u->error);
|
||
}
|
||
}
|
||
|
||
//заносим удары,приемы,эффекты и т.д.
|
||
//удар
|
||
if (isset($_POST['atack']) && isset($_POST['block'])) {
|
||
$btl->addAtack();
|
||
}
|
||
|
||
//прием
|
||
if (isset($_POST['usepriem']) && $btl->testUsersLive() && isset($btl->users[$btl->uids[$u->info['enemy']]])) {
|
||
$priem->pruse($_POST['usepriem']);
|
||
}
|
||
|
||
//используем заклятие / пирожки
|
||
//не используем? О_о
|
||
|
||
|
||
//проводим действия (удары, использование приемов, если есть возможность нанести удар или использовать прием)
|
||
$btl->testActions();
|
||
|
||
//авто-смена противника, либо просто смена противника
|
||
if ($u->stats['hpNow'] < 1) {
|
||
$btl->mainStatus = 3;
|
||
} else {
|
||
//ручная смена
|
||
if (isset($_POST['smn']) && $_POST['smn'] != 'none') {
|
||
/* ---------------- */
|
||
$uidz = Db::getValue('select if(inUser > 0, inUser, id) as id from users where login = ? and battle = ?', [$_POST['smn'], $u->info['battle']]);
|
||
|
||
$rsm = $btl->smena($uidz);
|
||
if ($rsm != 1) {
|
||
echo $error($rsm);
|
||
}
|
||
unset($rsm);
|
||
$js .= 'smena_login = \'none\';';
|
||
}
|
||
|
||
//авто-смена
|
||
if (
|
||
$u->info['enemy'] == 0 ||
|
||
$btl->stats[$btl->uids[$u->info['enemy']]]['hpNow'] <= 0 ||
|
||
isset($btl->ga[$u->info['id']][$u->info['enemy']])
|
||
) {
|
||
$btl->autoSmena();
|
||
}
|
||
}
|
||
|
||
//получаем данные о поединке
|
||
|
||
//получаем данные о логе боя
|
||
|
||
//Если бой сыгран - завершаем
|
||
if (!isset($_POST['usepriem'])) {
|
||
$btl->testFinish();
|
||
}
|
||
|
||
if ($btl->info['team_win'] == -1) {
|
||
$js .= $btl->genTeams($u->info['id']);
|
||
} else {
|
||
$btl->mainStatus = 3;
|
||
$btl->e = $u->btl_txt;
|
||
}
|
||
|
||
if ($btl->info['id'] == $u->info['lider']) {
|
||
$js .= '$("#btn_down_img3").show();$("#btn_down_img4").show();';
|
||
} else {
|
||
$js .= '$("#btn_down_img3").hide();$("#btn_down_img4").hide();';
|
||
}
|
||
|
||
if (!isset($CRON_CORE)) {
|
||
$js .= $btl->myInfo($u->info['id'], 1);
|
||
|
||
//выводим данные
|
||
if ($btl->e != '') {
|
||
echo $error($btl->e);
|
||
}
|
||
|
||
if (
|
||
isset($btl->ga[$u->info['id']][$u->info['enemy']]) &&
|
||
$u->info['hpNow'] >= 1
|
||
) {
|
||
$btl->mainStatus = 2;
|
||
} elseif (
|
||
$u->info['enemy'] != 0 &&
|
||
$btl->info['team_win'] == -1 &&
|
||
$u->info['hpNow'] >= 1
|
||
) {
|
||
$js .= $btl->myInfo($u->info['enemy'], 2);
|
||
}
|
||
|
||
if ($btl->info['izlom'] > 0) {
|
||
$js .= 'volna(' . (1 + $btl->info['izlomRoundSee']) . ');';
|
||
}
|
||
|
||
$i = 1;
|
||
while ($i <= 7) {
|
||
if ($btl->users[$btl->uids[$u->info['id']]]['tactic' . $i] < 0) {
|
||
$btl->users[$btl->uids[$u->info['id']]]['tactic' . $i] = 0;
|
||
}
|
||
if ($btl->users[$btl->uids[$u->info['id']]]['tactic' . $i] > 25 && $i < 7) {
|
||
$btl->users[$btl->uids[$u->info['id']]]['tactic' . $i] = 25;
|
||
}
|
||
$i++;
|
||
}
|
||
|
||
|
||
$js .= '$("#priems").html("' . $priem->seeMy(2) . '");';
|
||
$jslog = $btl->lookmLog() . $btl->lookLog();
|
||
if ($jslog != '') {
|
||
$js = $jslog . $js;
|
||
}
|
||
unset($jslog);
|
||
|
||
$atk1 = isset($btl->ga[$u->info['enemy']][$u->info['id']]) ? 1 : 0;
|
||
$nabito = floor($btl->users[$btl->uids[$u->info['id']]]['battle_yron']);
|
||
$expmaybe = floor($btl->users[$btl->uids[$u->info['id']]]['battle_exp']);
|
||
$tmr = round(($btl->info['timeout'] / 60), 2);
|
||
$persMagic = $u->btlMagicList();
|
||
$za = (int)$btl->stats[$btl->uids[$u->info['id']]]['zona'];
|
||
$zb = (int)$btl->testZonbVis();
|
||
$tactic1 = (int)$btl->users[$btl->uids[$u->info['id']]]['tactic1'];
|
||
$tactic2 = (int)$btl->users[$btl->uids[$u->info['id']]]['tactic2'];
|
||
$tactic3 = (int)$btl->users[$btl->uids[$u->info['id']]]['tactic3'];
|
||
$tactic4 = (int)$btl->users[$btl->uids[$u->info['id']]]['tactic4'];
|
||
$tactic5 = (int)$btl->users[$btl->uids[$u->info['id']]]['tactic5'];
|
||
$tactic6 = (int)$btl->users[$btl->uids[$u->info['id']]]['tactic6'];
|
||
$tactic7 = (int)$btl->users[$btl->uids[$u->info['id']]]['tactic7'];
|
||
$smnpty = (int)$u->info['smena'];
|
||
$mainstatus = $btl->mainStatus;
|
||
$ggcode = PassGen::new();
|
||
|
||
echo <<<HTML
|
||
<script>
|
||
eatk = $atk1;
|
||
$('#nabito').html('$nabito');
|
||
$('#expmaybe').html('$expmaybe');
|
||
$('#timer_out').html('$tmr');
|
||
$('#pers_magic').html('$persMagic');
|
||
g_iCount = 30;
|
||
noconnect = 15;
|
||
connect = 1;
|
||
$('#go_btn').show();
|
||
$('#reflesh_btn').show();
|
||
za = '$za'; genZoneAtack();
|
||
zb = '$zb'; genZoneBlock();
|
||
refleshPoints();
|
||
tactic(1,'$tactic1');
|
||
tactic(2,'$tactic2');
|
||
tactic(3,'$tactic3');
|
||
tactic(4,'$tactic4');
|
||
tactic(5,'$tactic5');
|
||
tactic(6,'$tactic6');
|
||
smnpty='$smnpty';
|
||
mainstatus('$mainstatus')
|
||
tactic(7,'$tactic7');
|
||
smena_alls = '0';
|
||
ggcode='$ggcode';
|
||
$js
|
||
</script>
|
||
HTML;
|
||
|
||
if ($btl->cached) {
|
||
$btl->clear_cache_start();
|
||
}
|
||
|
||
unset($atk1);
|
||
}
|
||
echo '<script>ggcode="' . PassGen::new() . '";if(t057!=null){clearTimeout(t057);}</script>';
|
||
|
||
}
|