game/jx/battle/refresh_bot.php

235 lines
8.1 KiB
PHP
Raw Normal View History

2022-06-06 21:30:34 +00:00
<?php
2023-01-10 16:29:32 +00:00
# Получаем IP
function getIPblock()
{
return isset($_SERVER['HTTP_X_REAL_IP']) ? $_SERVER['HTTP_X_REAL_IP'] : $_SERVER['REMOTE_ADDR'];
2022-06-06 21:30:34 +00:00
}
const GAME = true;
2022-07-01 12:45:43 +00:00
require_once('../../_incl_data/class/__db_connect.php');
2022-06-06 21:30:34 +00:00
function e($t)
{
mysql_query(
'INSERT INTO `chat` (`text`,`city`,`to`,`type`,`new`,`time`) VALUES ("core #' . date('d.m.Y') . ' %' . date(
'H:i:s'
2023-01-10 16:29:32 +00:00
) . ' (Критическая ошибка): <b>' . mysql_real_escape_string(
$t
) . '</b>","capitalcity","-NIGHTmare-","6","1","-1")'
);
2022-06-06 21:30:34 +00:00
}
if (isset($_GET['cron_core'])) {
$id = [
'id' => $_GET['uid'],
'pass' => $_GET['pass'],
];
if (md5($id['id'] . '_brfCOreW@!_' . $id['pass']) == $_GET['cron_core']) {
$uzr = mysql_fetch_array(
mysql_query(
'SELECT `id`,`login`,`pass` FROM `users` WHERE `id` = "' . mysql_real_escape_string(
$id['id']
) . '" AND `pass` = "' . mysql_real_escape_string($id['pass']) . '" LIMIT 1'
)
);
if (isset($uzr['id'])) {
$CRON_CORE = true;
$_COOKIE['login'] = $uzr['login'];
//$_COOKIE['pass'] = $uzr['pass'];
$_POST['id'] = 'reflesh';
if (isset($_GET['atack'])) {
$_POST['atack'] = $_GET['atack'];
}
if (isset($_GET['block'])) {
$_POST['block'] = $_GET['block'];
}
if (isset($_GET['usepriem'])) {
$_POST['usepriem'] = $_GET['usepriem'];
}
if (isset($_GET['useitem'])) {
$_POST['useitem'] = $_GET['useitem'];
}
}
unset($uzr);
}
2022-06-06 21:30:34 +00:00
}
if (isset($CRON_CORE) && (isset($_POST['atack'], $_POST['block']) || (isset($_POST['id']) && $_POST['id'] == 'reflesh') || isset($_POST['usepriem']) || isset($_POST['useitem']))) {
//`session_start();
$tm = microtime();
$tm = explode(' ', $tm);
$tm = $tm[0] + $tm[1];
if (!isset($CRON_CORE)) {
require_once('../../_incl_data/__config.php');
if ($_SESSION['tbr'] > $tm) {
die('<script>ggcode="' . $code . '";if(t057!=null){clearTimeout(t057);}</script>');
} else {
$_SESSION['tbr'] = $tm + 0.350;
}
}
unset($tm);
$js = '';
$u = User::start();
$magic = new Magic();
$priem = new Priems();
if (!isset($CRON_CORE) && (!isset($u->info['id']) || ($u->info['joinIP'] == 1 && $u->info['ip'] != $_SERVER['HTTP_X_REAL_IP']))) {
die($c['exit']);
}
$u->stats = $u->getStats($u->info['id'], 0);
if (!isset($CRON_CORE) && $u->info['online'] < time() - 30) {
mysql_query(
"UPDATE `users` SET `online`='" . time() . "',`timeMain`='" . time(
) . "' WHERE `id`='" . $u->info['id'] . "' LIMIT 1"
);
}
$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) {
2023-01-10 16:29:32 +00:00
//завершаем поединок
$upd = mysql_query(
'UPDATE `users` SET `battle` = "0",`online` = "' . time(
) . '" WHERE `id` = "' . $u->info['id'] . '" LIMIT 1'
);
if (!$upd) {
if (!isset($CRON_CORE)) {
2023-01-10 16:29:32 +00:00
die('Ошибка завершения поединка.');
}
} else {
echo '<script>location="main.php";</script>';
}
} else {
mysql_query(
'UPDATE `users` SET `battle` = "0" WHERE `battle` = "' . $u->info['battle'] . '" LIMIT 100'
);
if (!isset($CRON_CORE)) {
die('<script>location="main.php";</script>');
}
}
} else {
2023-01-10 16:29:32 +00:00
//получаем массив с игроками в бою
$btl->teamsTake();
if (isset($_POST['useitem'])) {
$magic->useItems((int)$_POST['useitem']);
if ($u->error != '') {
echo '<font color=red><center><b>' . $u->error . '</b></center></font>';
}
}
2023-01-10 16:29:32 +00:00
//заносим удары,приемы,эффекты и т.д.
//удар
if (isset($_POST['atack']) && isset($_POST['block'])) {
$btl->addAtack();
}
2023-01-10 16:29:32 +00:00
//прием
if (isset($_POST['usepriem'])) {
$priem->pruse($_POST['usepriem']);
}
2023-01-10 16:29:32 +00:00
//используем заклятие / пирожки
2023-01-10 16:29:32 +00:00
//проводим действия (удары, использование приемов, если есть возможность нанести удар или использовать прием)
$btl->testActions();
2023-01-10 16:29:32 +00:00
//авто-смена противника, либо просто смена противника
if ($u->stats['hpNow'] >= 1) {
2023-01-10 16:29:32 +00:00
//ручная смена
if (isset($_POST['smn']) && $_POST['smn'] != 'none') {
/* ---------------- */
$uidz = mysql_fetch_array(
mysql_query(
'SELECT `id`,`inUser` FROM `users` WHERE `login` = "' . mysql_real_escape_string(
$_POST['smn']
) . '" AND `battle` = "' . $u->info['battle'] . '" LIMIT 1'
)
);
if ($uidz['inUser'] > 0) {
$uidz['id'] = $uidz['inUser'];
}
$rsm = $btl->smena($uidz['id'], false);
if ($rsm != 1) {
echo '<font color=red><center><b>' . $rsm . '</b></center></font>';
}
unset($rsm);
$js .= 'smena_login = \'none\';';
}
2023-01-10 16:29:32 +00:00
//авто-смена
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();
}
} else {
$btl->mainStatus = 3;
}
2023-01-10 16:29:32 +00:00
//получаем данные о поединке
2023-01-10 16:29:32 +00:00
//получаем данные о логе боя
2023-01-10 16:29:32 +00:00
//Если бой сыгран - завершаем
$btl->testFinish();
if ($btl->info['team_win'] == -1) {
$js .= $btl->genTeams($u->info['id']);
} else {
$btl->mainStatus = 3;
$btl->e = $u->btl_txt;
}
if (!isset($CRON_CORE)) {
$js .= $btl->myInfo($u->info['id'], 1);
2023-01-10 16:29:32 +00:00
//выводим данные
if ($btl->e != '') {
echo '<font color="red"><center><b>' . $btl->e . '</b></center></font>';
}
if (isset($btl->ga[$u->info['id']][$u->info['enemy']])) {
if ($u->info['hpNow'] >= 1) {
$btl->mainStatus = 2;
}
} else {
if ($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++;
}
$atk1 = 0;
2023-01-10 18:58:20 +00:00
$rsys = '';
if ($rsys != '') {
$js .= $rsys;
}
unset($rsys);
if (isset($btl->ga[$u->info['enemy']][$u->info['id']])) {
$atk1 = 1;
}
}
if ($btl->cached) {
$btl->clear_cache_start();
}
}
2022-06-06 21:30:34 +00:00
}