diff --git a/_incl_data/class/BotLogic.php b/_incl_data/class/BotLogic.php index 4de6d5b7..89638119 100644 --- a/_incl_data/class/BotLogic.php +++ b/_incl_data/class/BotLogic.php @@ -1,89 +1,68 @@ ['timeout' => 30]]); $val = file_get_contents('/jx/battle/refresh_bot.php?uid=' . $id['id'] . '&cron_core=' . md5($id['id'] . '_brfCOreW@!_' . $id['pass']) . '&pass=' . $id['pass'] . '&' . $txt, false, $ctx); echo '[' . $val . ']
'; - unset($val); + } } - static function battle_priems() + private static function useBattlePriems(): void { //используем приемы в бою - if (self::$st['hpNow'] > 0 && self::$bot['battle'] > 0) { - - $pr = explode('|', self::$bot['priems']); - $rz = explode('|', self::$bot['priems_z']); - $i = 0; - while ($i < count($pr)) { - if ($pr[$i] > 0) { - self::$pr[$pr[$i]] = $rz[$i]; - } - $i++; - } - $i = 0; - while ($i < count($pr)) { - if ($rz[$i] < 1 && $pr[$i] > 0) { - //Можно использовать прием, подключаем логику - BotPriemLogic::start($i, $pr[$i]); - } - $i++; - } - self::$pr = false; + if (self::$st['hpNow'] <= 0 || self::$bot['battle'] <= 0) { + return; } + $pr = explode('|', self::$bot['priems']); + $rz = explode('|', self::$bot['priems_z']); + $i = 0; + while ($i < count($pr)) { + if ($pr[$i] > 0) { + self::$pr[$pr[$i]] = $rz[$i]; + } + $i++; + } + $i = 0; + while ($i < count($pr)) { + if ($rz[$i] < 1 && $pr[$i] > 0) { + //Можно использовать прием, подключаем логику + BotPriemLogic::start($i, $pr[$i]); + } + $i++; + } + self::$pr = []; } - static function clear_bot() + /** Удаление данных бота из БД. + * @return void + */ + private static function clearBot(): void { - - //Очистка бота, обнуляем его до [0], удаляем эффекты, предметы и т.д, а текущему ставим логин delete - //Удаляем сообщения в чате - mysql_query('DELETE FROM `chat` WHERE `to` = "' . self::$bot['login'] . '"'); + Db::sql('delete from chat where `to` = ?', [self::$bot['login']]); //Удаляем шмотки и эффекты - mysql_query('DELETE FROM `items_users` WHERE `uid` = "' . self::$bot['id'] . '"'); - mysql_query('DELETE FROM `eff_users` WHERE `uid` = "' . self::$bot['id'] . '"'); - + Db::sql('delete from items_users where uid = ?', [self::$bot['login']]); + Db::sql('delete from eff_users where uid = ?', [self::$bot['login']]); //Удаляем статы и поле в юзерс - mysql_query('DELETE FROM `users` WHERE `id` = "' . self::$bot['id'] . '" LIMIT 1'); - mysql_query('DELETE FROM `stats` WHERE `id` = "' . self::$bot['id'] . '" LIMIT 1'); - mysql_query('DELETE FROM `online` WHERE `uid` = "' . self::$bot['id'] . '" LIMIT 1'); - mysql_query('DELETE FROM `actions` WHERE `uid` = "' . self::$bot['id'] . '" LIMIT 1'); - - } - - static function inuser_go_main($id, $txt = '') - { - if (isset($id['id'])) { - $ctx = stream_context_create(['https' => ['timeout' => 1]]); - file_get_contents('/main_bot.php?uid=' . $id['id'] . '&cron_core=' . md5($id['id'] . '_brfCOreW@!_' . $id['pass']) . '&pass=' . $id['pass'] . '&' . $txt, false, $ctx); - } - } - - static function inuser_go_zv($id, $txt = '') - { - if (isset($id['id'])) { - $ctx = stream_context_create(['https' => ['timeout' => 1]]); - file_get_contents('/main_bot.php?zayvka=1&r=4&uid=' . $id['id'] . '&cron_core=' . md5($id['id'] . '_brfCOreW@!_' . $id['pass']) . '&pass=' . $id['pass'] . '&' . $txt, false, $ctx); - } - } - - //ПРоверка на файтрум - static function test_fr($id, $city = 'capitalcity') - { - return $city != 'capitalcity' || $id == 0 || $id == 2 || $id == 4 || $id == 5 || $id == 7 || $id == 377; + Db::sql('delete from users where id = ?', [self::$bot['login']]); + Db::sql('delete from stats where id = ?', [self::$bot['login']]); + Db::sql('delete from online where uid = ?', [self::$bot['login']]); + Db::sql('delete from actions where uid = ?', [self::$bot['login']]); } //Действия бота вне боя @@ -106,7 +85,7 @@ class BotLogic self::update('a1', 0); //CAPITAL - if (self::$bot['city'] == 'capitalcity' && !self::test_fr(self::$bot['room'])) { + if (!in_array(self::$bot['room'], [0, 2, 4, 5, 7, 377])) { if (self::$bot['exp'] > 400000 && self::$bot['level'] == 8) { self::$bot['exp'] = 400000; @@ -123,7 +102,7 @@ class BotLogic $cr = mysql_fetch_array(mysql_query('SELECT `id` FROM `items_users` WHERE `item_id` = "1204" AND `uid` = "' . self::$bot['id'] . '" AND `delete` = "0" LIMIT 1')); if (!isset($cr['id'])) { //Покупаем кристалл - \User\ItemsModel::addItem(1204, self::$bot['id']); + ItemsModel::addItem(1204, self::$bot['id']); } } //Переходим в комнату для сражений @@ -196,7 +175,10 @@ class BotLogic //Выдаем и надеваем предмет //$it = \User\ItemsModel::addItem($com['e'.$i],self::$bot['id']); $eff = mysql_fetch_array(mysql_query('SELECT * FROM `eff_main` WHERE `id2` = "' . $com['e' . $i] . '" LIMIT 1')); - mysql_query('INSERT INTO `eff_users` (`overType`,`id_eff`,`uid`,`name`,`timeUse`,`data`,`no_Ace`) VALUES ("' . $eff['oneType'] . '","' . $eff['id2'] . '","' . self::$bot['id'] . '","' . $eff['mname'] . '","' . (time() + 9640000) . '","' . $eff['mdata'] . '","' . $eff['noAce'] . '")'); + mysql_query( + 'INSERT INTO `eff_users` (`overType`,`id_eff`,`uid`,`name`,`timeUse`,`data`,`no_Ace`) VALUES ("' . $eff['oneType'] . '","' . $eff['id2'] . '","' . self::$bot['id'] . '","' . $eff['mname'] . '","' . (time( + ) + 9640000) . '","' . $eff['mdata'] . '","' . $eff['noAce'] . '")' + ); } $i++; } @@ -205,10 +187,12 @@ class BotLogic while ($i <= 20) { if ($com['w' . $i] > 0) { //Выдаем и надеваем предмет - $it = \User\ItemsModel::addItem($com['w' . $i], self::$bot['id']); + $it = ItemsModel::addItem($com['w' . $i], self::$bot['id']); $eff1 = mysql_fetch_array(mysql_query('SELECT * FROM `items_shop` WHERE `item_id` = "' . $com['w' . $i] . '" LIMIT 1')); if ($it > 0) { - mysql_query('UPDATE `items_users` SET `inOdet` = "' . $i . '",`delete` = "0", `1price` = "' . $eff1['price_1'] . '" WHERE `uid` = "' . self::$bot['id'] . '" AND `id` = "' . $it . '" LIMIT 1'); + mysql_query( + 'UPDATE `items_users` SET `inOdet` = "' . $i . '",`delete` = "0", `1price` = "' . $eff1['price_1'] . '" WHERE `uid` = "' . self::$bot['id'] . '" AND `id` = "' . $it . '" LIMIT 1' + ); } } $i++; @@ -224,499 +208,552 @@ class BotLogic } } - public $bot_last_action = []; + private static bool $botInit = false; //Включаем логику бота - static function start($id) + static function start($id): bool { - if (!isset($bot_last_action[$id])) { - global $u; - $bot_last_action[$id]++; - self::$bot = mysql_fetch_array(mysql_query('SELECT `u`.*,`st`.* FROM `users` AS `u` LEFT JOIN `stats` AS `st` ON `st`.`id` = `u`.`id` WHERE `u`.`id` = "' . mysql_real_escape_string($id) . '" AND `u`.`banned` = "0" LIMIT 1')); + if (!self::$botInit) { + return self::$botInit; + } - if (isset(self::$bot['id'])) { + global $u; + self::$bot = $u::getInfo($id); - self::$st = $u->getStats(self::$bot, 0); + if (!isset(self::$bot['id'])) { + return self::$botInit; + } - //Заходим ботом в онлайн - self::_online(); + self::$botInit = true; - if (self::$bot['battle'] > 0) { + self::$st = $u->getStats(self::$bot, 0); - //Действия бота в поединке - self::$btl = mysql_fetch_array(mysql_query('SELECT * FROM `battle` WHERE `id` = "' . mysql_real_escape_string(self::$bot['battle']) . '" AND `team_win` = "-1" LIMIT 1')); - if (isset(self::$btl['id'])) { + //Заходим ботом в онлайн + self::_online(); - $go_bot = false; - $go_txt = ''; + if (self::$bot['battle'] > 0) { - $a1 = mysql_fetch_array(mysql_query('SELECT `id`,`uid1`,`uid2`,`time` FROM `battle_act` WHERE `battle` = "' . self::$btl['id'] . '" AND `uid1` = "' . self::$bot['id'] . '" ORDER BY `time` ASC LIMIT 1')); + //Действия бота в поединке + self::$btl = mysql_fetch_array(mysql_query('SELECT * FROM `battle` WHERE `id` = "' . mysql_real_escape_string(self::$bot['battle']) . '" AND `team_win` = "-1" LIMIT 1')); + if (isset(self::$btl['id'])) { - //Проверяем возможность использования приемов и делаем список что использовать - //используем приемы - self::battle_priems(); + $go_bot = false; + $go_txt = ''; - //Бот сделал удар, но никто не ответил, проверяем таймаут и если что заходим - if (isset($a1['id']) && $a1['time'] + self::$btl['timeout'] < time()) { - $go_bot = true; + $a1 = mysql_fetch_array( + mysql_query( + 'SELECT `id`,`uid1`,`uid2`,`time` FROM `battle_act` WHERE `battle` = "' . self::$btl['id'] . '" AND `uid1` = "' . self::$bot['id'] . '" ORDER BY `time` ASC LIMIT 1' + ) + ); + + //Проверяем возможность использования приемов и делаем список что использовать + //используем приемы + self::useBattlePriems(); + + //Бот сделал удар, но никто не ответил, проверяем таймаут и если что заходим + if (isset($a1['id']) && $a1['time'] + self::$btl['timeout'] < time()) { + $go_bot = true; + } + + //ТУТ test + $a2 = mysql_fetch_array( + mysql_query( + 'SELECT `id`,`uid1`,`uid2`,`time` FROM `battle_act` WHERE `battle` = "' . self::$btl['id'] . '" AND `uid2` = "' . self::$bot['id'] . '" ORDER BY `time` ASC LIMIT 1' + ) + ); + if (isset($a2['uid1'])) { + mysql_query('UPDATE `stats` SET `enemy` = "' . $a2['uid1'] . '" WHERE `id` = "' . self::$bot['id'] . '" LIMIT 1'); + } + $a3 = mysql_fetch_array( + mysql_query( + 'SELECT `id`,`uid1`,`uid2`,`time` FROM `battle_act` WHERE `battle` = "' . self::$btl['id'] . '" AND `uid2` = "' . self::$bot['id'] . '" ORDER BY `time` ASC LIMIT 1' + ) + ); + if (isset($a3['uid2'])) { + mysql_query('UPDATE `stats` SET `enemy` = "' . $a3['uid2'] . '" WHERE `id` = "' . self::$bot['id'] . '" LIMIT 1'); + } + //Размен с противником + + + self::$enemy = mysql_fetch_array(mysql_query('SELECT * FROM `stats` WHERE `id` = "' . self::$bot['enemy'] . '" LIMIT 1')); + + } else { + + //Заходим на персонажа + self::inuser_go_btl(self::$bot); + + //Поединок уже завершился, выкидываем из боя + self::$bot['battle'] = 0; + mysql_query('UPDATE `users` SET `battle` = "' . self::$bot['battle'] . '" WHERE `id` = "' . mysql_real_escape_string(self::$bot['id']) . '" LIMIT 1 '); + } + + } else { + + //Действия бота вне поединка + if (self::$bot['timeMain'] < time()) { + + mysql_query('UPDATE `chat` SET `time` = "' . time() . '" WHERE `to` = "' . self::$bot['login'] . '" AND `time` = "-1"'); + + //Действие возможно произвести + if (self::$bot['ipreg'] == 1 || self::$bot['ipreg'] == 2 || self::$bot['ipreg'] == 4) { + //Принимаем только хаоты + self::$bot['ipreg'] = 3; + } + if (self::$bot['ipreg'] == 5) { + //Подаем только хаоты + self::$bot['ipreg'] = 7; + } + // + if (self::$bot['ipreg'] == 0 || !in_array(self::$bot['room'], [0, 2, 4, 5, 7, 377])) { + + //Обновляем эффекты + $com = mysql_fetch_array(mysql_query('SELECT * FROM `a_bot_tree` WHERE `level` = "' . (self::$bot['level']) . '" LIMIT 1')); + if (isset($com['id'])) { + $eft = mysql_fetch_array(mysql_query('SELECT `id` FROM `eff_users` WHERE `uid` = "' . self::$bot['id'] . '" AND `delete` = "0" LIMIT 1')); + if (!isset($eft['id'])) { + mysql_query('UPDATE `eff_users` SET `delete` = "' . time() . '" WHERE `uid` = "' . self::$bot['id'] . '" AND `delete` = "0"'); + $i = 1; + while ($i <= 20) { + if ($com['e' . $i] > 0) { + //Выдаем и надеваем предмет + //$it = \User\ItemsModel::addItem($com['e'.$i],self::$bot['id']); + $eff = mysql_fetch_array(mysql_query('SELECT * FROM `eff_main` WHERE `id2` = "' . $com['e' . $i] . '" LIMIT 1')); + mysql_query( + 'INSERT INTO `eff_users` (`overType`,`id_eff`,`uid`,`name`,`timeUse`,`data`,`no_Ace`) VALUES ("' . $eff['oneType'] . '","' . $eff['id2'] . '","' . self::$bot['id'] . '","' . $eff['mname'] . '","' . (time( + ) + 86400 * 7) . '","' . $eff['mdata'] . '","' . $eff['noAce'] . '")' + ); + } + $i++; + } } + } - //ТУТ test - $a2 = mysql_fetch_array(mysql_query('SELECT `id`,`uid1`,`uid2`,`time` FROM `battle_act` WHERE `battle` = "' . self::$btl['id'] . '" AND `uid2` = "' . self::$bot['id'] . '" ORDER BY `time` ASC LIMIT 1')); - if (isset($a2['uid1'])) { - mysql_query('UPDATE `stats` SET `enemy` = "' . $a2['uid1'] . '" WHERE `id` = "' . self::$bot['id'] . '" LIMIT 1'); - } - $a3 = mysql_fetch_array(mysql_query('SELECT `id`,`uid1`,`uid2`,`time` FROM `battle_act` WHERE `battle` = "' . self::$btl['id'] . '" AND `uid2` = "' . self::$bot['id'] . '" ORDER BY `time` ASC LIMIT 1')); - if (isset($a3['uid2'])) { - mysql_query('UPDATE `stats` SET `enemy` = "' . $a3['uid2'] . '" WHERE `id` = "' . self::$bot['id'] . '" LIMIT 1'); - } - //Размен с противником + if (self::$bot['level'] >= 13 && self::$bot['clan'] == 0 && self::$bot['align'] == 0) { + //обнуляем бота + self::clearBot(); + } + //Только-что из поединка, хиляется + if (!in_array(self::$bot['room'], [0, 2, 4, 5, 7, 377])) { - self::$enemy = mysql_fetch_array(mysql_query('SELECT * FROM `stats` WHERE `id` = "' . self::$bot['enemy'] . '" LIMIT 1')); + //В какой-то локации, видимо что-то делаем + + } elseif (self::$st['hpNow'] >= self::$st['hpAll']) { + echo 1; + //Приступаем к активной деятельности :) + mysql_query( + 'UPDATE `stats` SET `zv`= "0",`team`= "0",`hpNow` = "' . self::$st['hpNow'] . '",`mpNow` = "' . self::$st['mpNow'] . '" WHERE `id` = "' . self::$bot['id'] . '" LIMIT 1' + ); + mysql_query('UPDATE `users` SET `ipreg` = "' . self::new_action() . '",`mod_zvanie` = "Стажер" WHERE `id` = "' . self::$bot['id'] . '" LIMIT 1'); } else { - //Заходим на персонажа - self::inuser_go_btl(self::$bot); + if (self::$bot['mod_zvanie'] == 'Стажер100500') { + //Надеваем комплект + обновляем эффекты + mysql_query( + 'UPDATE `eff_users` SET `timeUse` = "' . (time() + 7200) . '" WHERE `uid` = "' . self::$bot['id'] . '" AND `delete` = "0" AND `v1` != "priem" LIMIT 12' + ); + mysql_query('UPDATE `items_users` SET `inOdet` = "0" WHERE `uid` = "' . self::$bot['id'] . '" AND `inOdet` > 0 AND `delete` = "0"'); + $sp = mysql_query( + 'SELECT `u`.`id`,`st`.`inslot`,`st`.`2too` FROM `items_users` AS `u` LEFT JOIN `items_main` AS `st` ON `st`.`id` = `u`.`item_id` WHERE `u`.`inOdet` = 0 AND `st`.`inslot` > 0 AND `st`.`inSlot` <= 20' + ); + $in = []; + while ($pl = mysql_fetch_array($sp)) { + $od = $pl['inslot']; - //Поединок уже завершился, выкидываем из боя - self::$bot['battle'] = 0; - mysql_query('UPDATE `users` SET `battle` = "' . self::$bot['battle'] . '" WHERE `id` = "' . mysql_real_escape_string(self::$bot['id']) . '" LIMIT 1 '); + if ($od == 10 && $in[10] > 0) { + if ($in[11] > 0) { + if ($in[12] == 0) { + $od = 12; + } + } else { + $od = 11; + } + } + + if ($od == 3 && $in[3] > 0 && $pl['2too'] > 0) { + if ($in[14] > 0) { + mysql_query('UPDATE `items_users` SET `inOdet` = "0" WHERE `uid` = "' . self::$bot['id'] . '" AND `inOdet` = "14" AND `delete` = "0" LIMIT 1'); + $in[14] = 0; + } + $od = 14; + } + + if ($in[$od] == 0) { + $in[$od] = $pl['id']; + mysql_query('UPDATE `items_users` SET `inOdet` = "' . $od . '" WHERE `id` = "' . $pl['id'] . '" AND `uid` = "' . self::$bot['id'] . '" LIMIT 1'); + } + } + mysql_query('UPDATE `items_users` SET `mod_zvanie` = "Cтaжер" WHERE `id` = "' . self::$bot['id'] . '" LIMIT 1'); + } + + //Хиляемся дальше + if (self::$bot['regHP'] == 0 || self::$bot['regMP'] == 0) { + mysql_query( + 'UPDATE `stats` SET `regHP` = "' . time() . '", `regMP` = "' . time( + ) . '",`hpNow` = "' . self::$st['hpNow'] . '",`mpNow` = "' . self::$st['mpNow'] . '" WHERE `id` = "' . self::$bot['id'] . '" LIMIT 1' + ); + } + + $reg = $u->regen(self::$bot['id'], self::$st, 0); } - } else { + self::actions(); - //Действия бота вне поединка - if (self::$bot['timeMain'] < time()) { + self::update('timeMain', self::rnd()); - mysql_query('UPDATE `chat` SET `time` = "' . time() . '" WHERE `to` = "' . self::$bot['login'] . '" AND `time` = "-1"'); + } elseif (self::$bot['ipreg'] == 1) { - //Действие возможно произвести - if (self::$bot['ipreg'] == 1 || self::$bot['ipreg'] == 2 || self::$bot['ipreg'] == 4) { - //Принимаем только хаоты - self::$bot['ipreg'] = 3; + //Принять заявку на бой (физ.) + if (self::$bot['zv'] == 0) { + + //Выделяем подходящую заявку в физ. поединке + $rz = 2; + $zv = 0; + $nozv = 0; + + if (self::$bot['level'] == 0) { + $rz = 1; } - if (self::$bot['ipreg'] == 5) { - //Подаем только хаоты - self::$bot['ipreg'] = 7; - } - // - if (self::$bot['ipreg'] == 0 || !self::test_fr(self::$bot['room'])) { - //Обновляем эффекты - $com = mysql_fetch_array(mysql_query('SELECT * FROM `a_bot_tree` WHERE `level` = "' . (self::$bot['level']) . '" LIMIT 1')); - if (isset($com['id'])) { - $eft = mysql_fetch_array(mysql_query('SELECT `id` FROM `eff_users` WHERE `uid` = "' . self::$bot['id'] . '" AND `delete` = "0" LIMIT 1')); - if (!isset($eft['id'])) { - mysql_query('UPDATE `eff_users` SET `delete` = "' . time() . '" WHERE `uid` = "' . self::$bot['id'] . '" AND `delete` = "0"'); - $i = 1; - while ($i <= 20) { - if ($com['e' . $i] > 0) { - //Выдаем и надеваем предмет - //$it = \User\ItemsModel::addItem($com['e'.$i],self::$bot['id']); - $eff = mysql_fetch_array(mysql_query('SELECT * FROM `eff_main` WHERE `id2` = "' . $com['e' . $i] . '" LIMIT 1')); - mysql_query('INSERT INTO `eff_users` (`overType`,`id_eff`,`uid`,`name`,`timeUse`,`data`,`no_Ace`) VALUES ("' . $eff['oneType'] . '","' . $eff['id2'] . '","' . self::$bot['id'] . '","' . $eff['mname'] . '","' . (time() + 86400 * 7) . '","' . $eff['mdata'] . '","' . $eff['noAce'] . '")'); - } - $i++; + $zv = mysql_fetch_array( + mysql_query( + 'SELECT * FROM `zayvki` WHERE `city` = "' . self::$bot['city'] . '" AND `otk` < "' . rand(2, 6) . '" AND `time` < "' . (time() - rand( + 15, 25 + )) . '" AND `bcs` < "' . time() . '" AND `start` = "0" AND `razdel` = "' . $rz . '" AND `cancel` = "0" AND `time` > "' . (time( + ) - 1111) . '" AND `money3` = 0 ORDER BY `time` DESC LIMIT 1' + ) + ); + + if (isset($zv['id'])) { + + $uz1 = mysql_fetch_array( + mysql_query( + 'SELECT `u`.`sex`,`u`.`id`,`u`.`login`,`u`.`align`,`u`.`clan`,`u`.`admin`,`u`.`city`,`u`.`room`,`u`.`online`,`u`.`level`,`u`.`battle`,`u`.`money`,`st`.* FROM `stats` AS `st` LEFT JOIN `users` AS `u` ON (`st`.`id` = `u`.`id`) WHERE `st`.`zv`="' . $zv['id'] . '" AND `st`.`team`="1" LIMIT 1' + ) + ); + $uz2 = mysql_fetch_array( + mysql_query( + 'SELECT `u`.`sex`,`u`.`id`,`u`.`login`,`u`.`align`,`u`.`clan`,`u`.`admin`,`u`.`city`,`u`.`room`,`u`.`online`,`u`.`level`,`u`.`battle`,`u`.`money`,`st`.* FROM `stats` AS `st` LEFT JOIN `users` AS `u` ON (`st`.`id` = `u`.`id`) WHERE `st`.`zv`="' . $zv['id'] . '" AND `st`.`team`="2" LIMIT 1' + ) + ); + + if (isset($uz1['id']) && !isset($uz2['id'])) { + + $uz1st = $u->getStats($uz1, 0); + + if ($uz1st['reting'] <= floor(self::$st['reting'] * 1.27)) { + + //Принимаем заявку + $sa = ''; + if (self::$bot['sex'] == 2) { + $sa = 'а'; } - } - } - if (self::$bot['level'] >= 13 && self::$bot['clan'] == 0 && self::$bot['align'] == 0) { - //обнуляем бота - self::clear_bot(); - } + $text = ' [login:' . self::$bot['login'] . '] принял' . $sa . ' вашу заявку на бой.[reflesh_main_zv_priem:' . self::$bot['id'] . ']'; + $chatMessageDto = new ChatMessage(); + $chatMessageDto->setCity($uz1['city']); + $chatMessageDto->setTo($uz1['login']); + $chatMessageDto->setText($text); + $chatMessageDto->setType(6); + $chat = new Chat(); + $chat->sendMsg($chatMessageDto); - //Только-что из поединка, хиляется - if (!self::test_fr(self::$bot['room'])) { + mysql_query('UPDATE `stats` SET `zv` = "' . $zv['id'] . '",`team` = "2" WHERE `id` = "' . self::$bot['id'] . '" LIMIT 1'); + mysql_query('UPDATE `users` SET `ipreg` = "8",`timeMain` = "' . self::rnd() . '" WHERE `id` = "' . self::$bot['id'] . '" LIMIT 1'); - //В какой-то локации, видимо что-то делаем - - } elseif (self::$st['hpNow'] >= self::$st['hpAll']) { - echo 1; - //Приступаем к активной деятельности :) - mysql_query('UPDATE `stats` SET `zv`= "0",`team`= "0",`hpNow` = "' . self::$st['hpNow'] . '",`mpNow` = "' . self::$st['mpNow'] . '" WHERE `id` = "' . self::$bot['id'] . '" LIMIT 1'); - mysql_query('UPDATE `users` SET `ipreg` = "' . self::new_action() . '",`mod_zvanie` = "Стажер" WHERE `id` = "' . self::$bot['id'] . '" LIMIT 1'); - - } else { - - if (self::$bot['mod_zvanie'] == 'Стажер100500') { - //Надеваем комплект + обновляем эффекты - mysql_query('UPDATE `eff_users` SET `timeUse` = "' . (time() + 7200) . '" WHERE `uid` = "' . self::$bot['id'] . '" AND `delete` = "0" AND `v1` != "priem" LIMIT 12'); - mysql_query('UPDATE `items_users` SET `inOdet` = "0" WHERE `uid` = "' . self::$bot['id'] . '" AND `inOdet` > 0 AND `delete` = "0"'); - $sp = mysql_query('SELECT `u`.`id`,`st`.`inslot`,`st`.`2too` FROM `items_users` AS `u` LEFT JOIN `items_main` AS `st` ON `st`.`id` = `u`.`item_id` WHERE `u`.`inOdet` = 0 AND `st`.`inslot` > 0 AND `st`.`inSlot` <= 20'); - $in = []; - while ($pl = mysql_fetch_array($sp)) { - $od = $pl['inslot']; - - if ($od == 10 && $in[10] > 0) { - if ($in[11] > 0) { - if ($in[12] == 0) { - $od = 12; - } - } else { - $od = 11; - } - } - - if ($od == 3 && $in[3] > 0 && $pl['2too'] > 0) { - if ($in[14] > 0) { - mysql_query('UPDATE `items_users` SET `inOdet` = "0" WHERE `uid` = "' . self::$bot['id'] . '" AND `inOdet` = "14" AND `delete` = "0" LIMIT 1'); - $in[14] = 0; - } - $od = 14; - } - - if ($in[$od] == 0) { - $in[$od] = $pl['id']; - mysql_query('UPDATE `items_users` SET `inOdet` = "' . $od . '" WHERE `id` = "' . $pl['id'] . '" AND `uid` = "' . self::$bot['id'] . '" LIMIT 1'); - } - } - mysql_query('UPDATE `items_users` SET `mod_zvanie` = "Cтaжер" WHERE `id` = "' . self::$bot['id'] . '" LIMIT 1'); - } - - //Хиляемся дальше - if (self::$bot['regHP'] == 0 || self::$bot['regMP'] == 0) { - mysql_query('UPDATE `stats` SET `regHP` = "' . time() . '", `regMP` = "' . time() . '",`hpNow` = "' . self::$st['hpNow'] . '",`mpNow` = "' . self::$st['mpNow'] . '" WHERE `id` = "' . self::$bot['id'] . '" LIMIT 1'); - } - - $reg = $u->regen(self::$bot['id'], self::$st, 0); - } - - self::actions(); - - self::update('timeMain', self::rnd()); - - } elseif (self::$bot['ipreg'] == 1) { - - //Принять заявку на бой (физ.) - if (self::$bot['zv'] == 0) { - - //Выделяем подходящую заявку в физ. поединке - $rz = 2; - $zv = 0; - $nozv = 0; - - if (self::$bot['level'] == 0) { - $rz = 1; - } - - $zv = mysql_fetch_array(mysql_query('SELECT * FROM `zayvki` WHERE `city` = "' . self::$bot['city'] . '" AND `otk` < "' . rand(2, 6) . '" AND `time` < "' . (time() - rand(15, 25)) . '" AND `bcs` < "' . time() . '" AND `start` = "0" AND `razdel` = "' . $rz . '" AND `cancel` = "0" AND `time` > "' . (time() - 1111) . '" AND `money3` = 0 ORDER BY `time` DESC LIMIT 1')); - - if (isset($zv['id'])) { - - $uz1 = mysql_fetch_array(mysql_query('SELECT `u`.`sex`,`u`.`id`,`u`.`login`,`u`.`align`,`u`.`clan`,`u`.`admin`,`u`.`city`,`u`.`room`,`u`.`online`,`u`.`level`,`u`.`battle`,`u`.`money`,`st`.* FROM `stats` AS `st` LEFT JOIN `users` AS `u` ON (`st`.`id` = `u`.`id`) WHERE `st`.`zv`="' . $zv['id'] . '" AND `st`.`team`="1" LIMIT 1')); - $uz2 = mysql_fetch_array(mysql_query('SELECT `u`.`sex`,`u`.`id`,`u`.`login`,`u`.`align`,`u`.`clan`,`u`.`admin`,`u`.`city`,`u`.`room`,`u`.`online`,`u`.`level`,`u`.`battle`,`u`.`money`,`st`.* FROM `stats` AS `st` LEFT JOIN `users` AS `u` ON (`st`.`id` = `u`.`id`) WHERE `st`.`zv`="' . $zv['id'] . '" AND `st`.`team`="2" LIMIT 1')); - - if (isset($uz1['id']) && !isset($uz2['id'])) { - - $uz1st = $u->getStats($uz1, 0); - - if ($uz1st['reting'] <= floor(self::$st['reting'] * 1.27)) { - - //Принимаем заявку - $sa = ''; - if (self::$bot['sex'] == 2) { - $sa = 'а'; - } - - $text = ' [login:' . self::$bot['login'] . '] принял' . $sa . ' вашу заявку на бой.[reflesh_main_zv_priem:' . self::$bot['id'] . ']'; - $chatMessageDto = new ChatMessage(); - $chatMessageDto->setCity($uz1['city']); - $chatMessageDto->setTo($uz1['login']); - $chatMessageDto->setText($text); - $chatMessageDto->setType(6); - $chat = new Chat(); - $chat->sendMsg($chatMessageDto); - - mysql_query('UPDATE `stats` SET `zv` = "' . $zv['id'] . '",`team` = "2" WHERE `id` = "' . self::$bot['id'] . '" LIMIT 1'); - mysql_query('UPDATE `users` SET `ipreg` = "8",`timeMain` = "' . self::rnd() . '" WHERE `id` = "' . self::$bot['id'] . '" LIMIT 1'); - - } else { - $nozv = 1; - } - - unset ($uz1st); - - } else { - $nozv = 1; - } } else { $nozv = 1; } - if ($nozv == 1 && self::$bot['timeMain'] < time() - rand(1, 3) * 60) { - mysql_query('UPDATE `users` SET `ipreg` = "0",`timeMain` = "' . self::rnd() . '" WHERE `id` = "' . self::$bot['id'] . '" LIMIT 1'); - } + unset ($uz1st); - unset($rz); - } - - - } elseif (self::$bot['ipreg'] == 2) { - - //Принять заявку на бой (груп.) - self::bot_group_haot_zv(6); - } elseif (self::$bot['ipreg'] == 3) { - - //Принять заявку на бой (хаот.) - self::bot_group_haot_zv(7); - } elseif (self::$bot['ipreg'] == 4) { - - //Принять заявку на бой (турнир.) - self::e('' . self::$bot['login'] . ', я хочу принять турнир...'); - } elseif (self::$bot['ipreg'] == 5) { - - //Подать заявку (физ.) - if (self::$bot['zv'] == 0) { - - $rz = 2; - if (self::$bot['level'] == 0) { - $rz = 1; - } - - $ins = mysql_query('INSERT INTO `zayvki` (`bot1`,`bot2`,`time`,`city`,`creator`,`type`,`time_start`,`timeout`,`min_lvl_1`,`min_lvl_2`,`max_lvl_1`,`max_lvl_2`,`tm1max`,`tm2max`,`travmaChance`,`invise`,`razdel`,`comment`,`money`,`withUser`,`tm1`,`tm2`) VALUES ( - "0", - "0", - "' . time() . '", - "' . self::$bot['city'] . '", - "' . self::$bot['id'] . '", - "0", - "0", - "300", - "0", - "21", - "0", - "21", - "1", - "1", - "0", - "0", - "' . $rz . '", - "", - "", - "","' . (0 + self::$bot['reting']) . '","0")'); - $zid = mysql_insert_id(); - mysql_query('UPDATE `stats` SET `zv` = "' . $zid . '", `team` = "1" WHERE `id` = "' . self::$bot['id'] . '" LIMIT 1'); - mysql_query('UPDATE `users` SET `ipreg` = "8",`timeMain` = "' . self::rnd() . '" WHERE `id` = "' . self::$bot['id'] . '" LIMIT 1'); - } - - } elseif (self::$bot['ipreg'] == 6 || self::$bot['ipreg'] == 7) { - - self::bot_group_haot_zv(self::$bot['ipreg']); - - if (self::$bot['zv'] == 0) { - - $rz = 5; - - $zv_c = [ - - 'time_start' => (60 * 5), 'tm1' => rand(2, 6), 'tm2' => rand(2, 6), 'l1min' => 0, 'l1max' => 21, 'l2min' => 0, 'l2max' => 21, 'timeout' => (60 * rand(1, 3)), - - ]; - - if (self::$bot['ipreg'] == 7) { - $zv_c['tm1'] = 99; - } - - $zv_c['tm2'] = $zv_c['tm1']; - $zv_c['l1min'] = self::$bot['level']; - $zv_c['l1max'] = self::$bot['level']; - - if ($zv_c['l1min'] < 2) { - $zv_c['l1min'] = 2; - } - if ($zv_c['l1max'] > 21) { - $zv_c['l1max'] = 21; - } - - $zv_c['l2min'] = $zv_c['l1min']; - $zv_c['l2max'] = $zv_c['l1max']; - - } - - } elseif (self::$bot['ipreg'] == 8) { - - //Ожидание начала поединка - if (self::$bot['zv'] == 0) { - - //Поединок не удалось начать - mysql_query('UPDATE `users` SET `ipreg` = "0",`timeMain` = "' . self::rnd() . '" WHERE `id` = "' . self::$bot['id'] . '" LIMIT 1'); } else { - $zv = mysql_fetch_array(mysql_query('SELECT * FROM `zayvki` WHERE `id` = "' . self::$bot['zv'] . '" AND `cancel` = "0" AND `start` = "0" LIMIT 1')); + $nozv = 1; + } + } else { + $nozv = 1; + } - if (!isset($zv['id'])) { + if ($nozv == 1 && self::$bot['timeMain'] < time() - rand(1, 3) * 60) { + mysql_query('UPDATE `users` SET `ipreg` = "0",`timeMain` = "' . self::rnd() . '" WHERE `id` = "' . self::$bot['id'] . '" LIMIT 1'); + } - //Обнуляем действия - mysql_query('UPDATE `users` SET `ipreg` = "0",`timeMain` = "' . self::rnd() . '" WHERE `id` = "' . self::$bot['id'] . '" LIMIT 1'); + unset($rz); + } - } elseif ($zv['razdel'] == 4 || $zv['razdel'] == 5) { - //хаот или группа - if ($zv['time_start'] + $zv['time'] <= time()) { + } elseif (self::$bot['ipreg'] == 2) { - self::inuser_go_zv(self::$bot); - } + //Принять заявку на бой (груп.) + self::bot_group_haot_zv(6); + } elseif (self::$bot['ipreg'] == 3) { - } else { - //физ - if ($zv['creator'] == self::$bot['id']) { + //Принять заявку на бой (хаот.) + self::bot_group_haot_zv(7); + } elseif (self::$bot['ipreg'] == 4) { - $uz2 = mysql_fetch_array(mysql_query('SELECT `u`.`sex`,`u`.`id`,`u`.`login`,`u`.`align`,`u`.`clan`,`u`.`admin`,`u`.`city`,`u`.`room`,`u`.`online`,`u`.`level`,`u`.`battle`,`u`.`money`,`st`.* FROM `stats` AS `st` LEFT JOIN `users` AS `u` ON (`st`.`id` = `u`.`id`) WHERE `st`.`zv`="' . $zv['id'] . '" AND `st`.`team`="2" LIMIT 1')); - if (isset($uz2['id'])) { - //Заявку кто-то принял, реагируем! :) - $pr = -1; + //Принять заявку на бой (турнир.) + self::e('' . self::$bot['login'] . ', я хочу принять турнир...'); + } elseif (self::$bot['ipreg'] == 5) { - $uz2st = $u->getStats($uz2, 0); + //Подать заявку (физ.) + if (self::$bot['zv'] == 0) { - //btl-cof - if ($uz2st['reting'] > floor(self::$st['reting'] * 1.27)) { + $rz = 2; + if (self::$bot['level'] == 0) { + $rz = 1; + } - //Отказываем, в 95% случаев, противник слишком силен - if (rand(0, 100) > 95) { - //отправляем бота на избиение :D - $pr = 1; - } else { - //отказ - $pr = 0; - } + $ins = mysql_query( + 'INSERT INTO `zayvki` (`bot1`,`bot2`,`time`,`city`,`creator`,`type`,`time_start`,`timeout`,`min_lvl_1`,`min_lvl_2`,`max_lvl_1`,`max_lvl_2`,`tm1max`,`tm2max`,`travmaChance`,`invise`,`razdel`,`comment`,`money`,`withUser`,`tm1`,`tm2`) VALUES ( + "0", + "0", + "' . time() . '", + "' . self::$bot['city'] . '", + "' . self::$bot['id'] . '", + "0", + "0", + "300", + "0", + "21", + "0", + "21", + "1", + "1", + "0", + "0", + "' . $rz . '", + "", + "", + "","' . (0 + self::$bot['reting']) . '","0")' + ); + $zid = mysql_insert_id(); + mysql_query('UPDATE `stats` SET `zv` = "' . $zid . '", `team` = "1" WHERE `id` = "' . self::$bot['id'] . '" LIMIT 1'); + mysql_query('UPDATE `users` SET `ipreg` = "8",`timeMain` = "' . self::rnd() . '" WHERE `id` = "' . self::$bot['id'] . '" LIMIT 1'); + } - } else { - $pr = 1; - } + } elseif (self::$bot['ipreg'] == 6 || self::$bot['ipreg'] == 7) { - //Можно принять заявку - //$pr = 0; + self::bot_group_haot_zv(self::$bot['ipreg']); - if ($pr == 1) { + if (self::$bot['zv'] == 0) { - //Прием заявки - //создаем поединок с ботом - $expB = 0; - $btl = ['players' => '', 'timeout' => $zv['timeout'], 'type' => $zv['type'], 'invis' => $zv['invis'], 'noinc' => 0, 'travmChance' => 0, 'typeBattle' => 0, 'addExp' => $expB, 'money' => 0]; - $ins = mysql_query('INSERT INTO `battle` (`time_over`,`city`,`time_start`,`players`,`timeout`,`type`,`invis`,`noinc`,`travmChance`,`typeBattle`,`addExp`,`money`,`team_win`) VALUES ( - "0", - "' . self::$bot['city'] . '", - "' . time() . '", - "' . $btl['players'] . '", - "' . $btl['timeout'] . '", - "' . $btl['type'] . '", - "' . $btl['invis'] . '", - "' . $btl['noinc'] . '", - "' . $btl['travmChance'] . '", - "' . $btl['typeBattle'] . '", - "' . $btl['addExp'] . '", - "' . $btl['money'] . '", - "-1")'); - if ($ins) { - $btl_id = mysql_insert_id(); - //обновляем данные о поединке - mysql_query('UPDATE `users` SET `battle`="' . $btl_id . '" WHERE `id` = "' . $uz2['id'] . '" LIMIT 1'); - mysql_query('UPDATE `users` SET `battle`="' . $btl_id . '",`ipreg` = "0" WHERE `id` = "' . self::$bot['id'] . '" LIMIT 1'); - mysql_query('UPDATE `stats` SET `zv` = "0",`team`="1" WHERE `id` = "' . self::$bot['id'] . '" LIMIT 1'); - mysql_query('UPDATE `stats` SET `zv` = "0",`team`="2" WHERE `id` = "' . $uz2['id'] . '" LIMIT 1'); + $rz = 5; - //Если бой кулачный, то снимаем вещи - if ($btl['type'] == 1) { - mysql_query('UPDATE `items_users` SET `inOdet`="0" WHERE `uid` = "' . self::$bot['id'] . '" AND `inOdet`!=0'); - mysql_query('UPDATE `items_users` SET `inOdet`="0" WHERE `uid` = "' . $uz2['id'] . '" AND `inOdet`!=0'); - } + $zv_c = [ - mysql_query('UPDATE `zayvki` SET `start` = "' . time() . '",`btl_id` = "' . $btl_id . '" WHERE `id` = "' . $zv['id'] . '" LIMIT 1'); + 'time_start' => (60 * 5), 'tm1' => rand(2, 6), 'tm2' => rand(2, 6), 'l1min' => 0, 'l1max' => 21, 'l2min' => 0, 'l2max' => 21, 'timeout' => (60 * rand(1, 3)), - //обновляем заявку, что бой начался - self::$bot['battle'] = $btl_id; + ]; - //Отправляем сообщение в чат всем бойцам - $chatDto = new ChatMessage(); - $chatDto->setCity($u->info['city']); - $chatDto->setRoom($u->info['room']); - $chatDto->setTo($uz2['login']); - $chatDto->setType(11); - $chatDto->setSound(117); - (new Chat())->sendMsg($chatDto); - } + if (self::$bot['ipreg'] == 7) { + $zv_c['tm1'] = 99; + } - } elseif ($pr == 0) { + $zv_c['tm2'] = $zv_c['tm1']; + $zv_c['l1min'] = self::$bot['level']; + $zv_c['l1max'] = self::$bot['level']; - //Отказ - $sa = ''; - if (self::$bot['sex'] == 2) { - $sa = 'а'; - } - $text = ' [login:' . self::$bot['login'] . '] отказал' . $sa . ' вам в поединке.'; - $chatDto = new ChatMessage(); - $chatDto->setCity($uz2['city']); - $chatDto->setTo($uz2['login']); - $chatDto->setText($text); - $chatDto->setType(6); - (new Chat())->sendMsg($chatDto); + if ($zv_c['l1min'] < 2) { + $zv_c['l1min'] = 2; + } + if ($zv_c['l1max'] > 21) { + $zv_c['l1max'] = 21; + } - mysql_query('UPDATE `stats` SET `zv` = "0",`team` = "1" WHERE `id` = "' . $uz2['id'] . '" LIMIT 1'); - mysql_query('UPDATE `zayvki` SET `otk` = ( `otk` + 1 ),`bcs` = "' . (time() + rand(30, rand(60, 180))) . '" WHERE `id` = "' . $zv['id'] . '" LIMIT 1'); - } + $zv_c['l2min'] = $zv_c['l1min']; + $zv_c['l2max'] = $zv_c['l1max']; + } + + } elseif (self::$bot['ipreg'] == 8) { + + //Ожидание начала поединка + if (self::$bot['zv'] == 0) { + + //Поединок не удалось начать + mysql_query('UPDATE `users` SET `ipreg` = "0",`timeMain` = "' . self::rnd() . '" WHERE `id` = "' . self::$bot['id'] . '" LIMIT 1'); + } else { + $zv = mysql_fetch_array(mysql_query('SELECT * FROM `zayvki` WHERE `id` = "' . self::$bot['zv'] . '" AND `cancel` = "0" AND `start` = "0" LIMIT 1')); + + if (!isset($zv['id'])) { + + //Обнуляем действия + mysql_query('UPDATE `users` SET `ipreg` = "0",`timeMain` = "' . self::rnd() . '" WHERE `id` = "' . self::$bot['id'] . '" LIMIT 1'); + + } elseif ($zv['razdel'] == 4 || $zv['razdel'] == 5) { + + //хаот или группа + if ($zv['time_start'] + $zv['time'] <= time()) { + file_get_contents( + '/main_bot.php?zayvka=1&r=4&uid=' . self::$bot['id'] . + '&cron_core=' . md5(self::$bot['id'] . '_brfCOreW@!_' . self::$bot['pass']) . '&pass=' . self::$bot['pass'] . '&', + false, + stream_context_create(['https' => ['timeout' => 1]]) + ); + } + + } else { + //физ + if ($zv['creator'] == self::$bot['id']) { + + $uz2 = mysql_fetch_array( + mysql_query( + 'SELECT `u`.`sex`,`u`.`id`,`u`.`login`,`u`.`align`,`u`.`clan`,`u`.`admin`,`u`.`city`,`u`.`room`,`u`.`online`,`u`.`level`,`u`.`battle`,`u`.`money`,`st`.* FROM `stats` AS `st` LEFT JOIN `users` AS `u` ON (`st`.`id` = `u`.`id`) WHERE `st`.`zv`="' . $zv['id'] . '" AND `st`.`team`="2" LIMIT 1' + ) + ); + if (isset($uz2['id'])) { + //Заявку кто-то принял, реагируем! :) + $pr = -1; + + $uz2st = $u->getStats($uz2, 0); + + //btl-cof + if ($uz2st['reting'] > floor(self::$st['reting'] * 1.27)) { + + //Отказываем, в 95% случаев, противник слишком силен + if (rand(0, 100) > 95) { + //отправляем бота на избиение :D + $pr = 1; } else { - - //Заявку никто не принял, возможно стоит отменить заявку вообще! - if (self::$bot['timeMain'] < time() - 30 - rand((7 / $zv['otk']), (3 * 49 / $zv['otk']))) { - - mysql_query('UPDATE `stats` SET `zv` = "0" WHERE `id` = "' . self::$bot['id'] . '" LIMIT 1'); - mysql_query('UPDATE `users` SET `ipreg` = "0",`timeMain` = "' . self::rnd() . '" WHERE `id` = "' . self::$bot['id'] . '" LIMIT 1'); - mysql_query('UPDATE `zayvki` SET `cancel` = "' . time() . '" WHERE `id` = "' . $zv['id'] . '" LIMIT 1'); - - } - + //отказ + $pr = 0; } + } else { + $pr = 1; } - } + //Можно принять заявку + //$pr = 0; - //Бот уже слишком долго ждет ответа игрока, отказываемся от заявки - if (self::$bot['timeMain'] < time() - rand((30 / $zv['otk']), (135 / $zv['otk'])) && $zv['creator'] != self::$bot['id'] && ($zv['razdel'] == 1 || $zv['razdel'] == 2)) { + if ($pr == 1) { - $uz1 = mysql_fetch_array(mysql_query('SELECT `u`.`sex`,`u`.`id`,`u`.`login`,`u`.`align`,`u`.`clan`,`u`.`admin`,`u`.`city`,`u`.`room`,`u`.`online`,`u`.`level`,`u`.`battle`,`u`.`money`,`st`.* FROM `stats` AS `st` LEFT JOIN `users` AS `u` ON (`st`.`id` = `u`.`id`) WHERE `st`.`zv`="' . $zv['id'] . '" AND `st`.`team`="1" LIMIT 1')); - if (isset($uz1['id'])) { + //Прием заявки + //создаем поединок с ботом + $expB = 0; + $btl = ['players' => '', 'timeout' => $zv['timeout'], 'type' => $zv['type'], 'invis' => $zv['invis'], 'noinc' => 0, 'travmChance' => 0, 'typeBattle' => 0, 'addExp' => $expB, 'money' => 0]; + $ins = mysql_query( + 'INSERT INTO `battle` (`time_over`,`city`,`time_start`,`players`,`timeout`,`type`,`invis`,`noinc`,`travmChance`,`typeBattle`,`addExp`,`money`,`team_win`) VALUES ( + "0", + "' . self::$bot['city'] . '", + "' . time() . '", + "' . $btl['players'] . '", + "' . $btl['timeout'] . '", + "' . $btl['type'] . '", + "' . $btl['invis'] . '", + "' . $btl['noinc'] . '", + "' . $btl['travmChance'] . '", + "' . $btl['typeBattle'] . '", + "' . $btl['addExp'] . '", + "' . $btl['money'] . '", + "-1")' + ); + if ($ins) { + $btl_id = mysql_insert_id(); + //обновляем данные о поединке + mysql_query('UPDATE `users` SET `battle`="' . $btl_id . '" WHERE `id` = "' . $uz2['id'] . '" LIMIT 1'); + mysql_query('UPDATE `users` SET `battle`="' . $btl_id . '",`ipreg` = "0" WHERE `id` = "' . self::$bot['id'] . '" LIMIT 1'); + mysql_query('UPDATE `stats` SET `zv` = "0",`team`="1" WHERE `id` = "' . self::$bot['id'] . '" LIMIT 1'); + mysql_query('UPDATE `stats` SET `zv` = "0",`team`="2" WHERE `id` = "' . $uz2['id'] . '" LIMIT 1'); + //Если бой кулачный, то снимаем вещи + if ($btl['type'] == 1) { + mysql_query('UPDATE `items_users` SET `inOdet`="0" WHERE `uid` = "' . self::$bot['id'] . '" AND `inOdet`!=0'); + mysql_query('UPDATE `items_users` SET `inOdet`="0" WHERE `uid` = "' . $uz2['id'] . '" AND `inOdet`!=0'); + } + + mysql_query('UPDATE `zayvki` SET `start` = "' . time() . '",`btl_id` = "' . $btl_id . '" WHERE `id` = "' . $zv['id'] . '" LIMIT 1'); + + //обновляем заявку, что бой начался + self::$bot['battle'] = $btl_id; + + //Отправляем сообщение в чат всем бойцам + $chatDto = new ChatMessage(); + $chatDto->setCity($u->info['city']); + $chatDto->setRoom($u->info['room']); + $chatDto->setTo($uz2['login']); + $chatDto->setType(11); + $chatDto->setSound(117); + (new Chat())->sendMsg($chatDto); + } + + } elseif ($pr == 0) { + + //Отказ $sa = ''; if (self::$bot['sex'] == 2) { $sa = 'а'; } - - $text = ' [login:' . self::$bot['login'] . '] отозвал' . $sa . ' свой запрос на бой.'; + $text = ' [login:' . self::$bot['login'] . '] отказал' . $sa . ' вам в поединке.'; $chatDto = new ChatMessage(); - $chatDto->setCity($uz1['city']); - $chatDto->setTo($uz1['login']); + $chatDto->setCity($uz2['city']); + $chatDto->setTo($uz2['login']); $chatDto->setText($text); $chatDto->setType(6); (new Chat())->sendMsg($chatDto); + + mysql_query('UPDATE `stats` SET `zv` = "0",`team` = "1" WHERE `id` = "' . $uz2['id'] . '" LIMIT 1'); + mysql_query('UPDATE `zayvki` SET `otk` = ( `otk` + 1 ),`bcs` = "' . (time() + rand(30, rand(60, 180))) . '" WHERE `id` = "' . $zv['id'] . '" LIMIT 1'); + } + + } else { + + //Заявку никто не принял, возможно стоит отменить заявку вообще! + if (self::$bot['timeMain'] < time() - 30 - rand((7 / $zv['otk']), (3 * 49 / $zv['otk']))) { + + mysql_query('UPDATE `stats` SET `zv` = "0" WHERE `id` = "' . self::$bot['id'] . '" LIMIT 1'); + mysql_query('UPDATE `users` SET `ipreg` = "0",`timeMain` = "' . self::rnd() . '" WHERE `id` = "' . self::$bot['id'] . '" LIMIT 1'); + mysql_query('UPDATE `zayvki` SET `cancel` = "' . time() . '" WHERE `id` = "' . $zv['id'] . '" LIMIT 1'); + } - mysql_query('UPDATE `zayvki` SET `otk` = ( `otk` + 1 ),`bcs` = "' . (time() + rand(30, rand(60, 180))) . '" WHERE `id` = "' . $zv['id'] . '" LIMIT 1'); - mysql_query('UPDATE `stats` SET `zv` = "0",`team` = "1" WHERE `id` = "' . self::$bot['id'] . '" LIMIT 1'); - mysql_query('UPDATE `users` SET `ipreg` = "1",`timeMain` = "' . self::rnd() . '" WHERE `id` = "' . self::$bot['id'] . '" LIMIT 1'); } } - } else { - self::update('ipreg', 0); + } + + //Бот уже слишком долго ждет ответа игрока, отказываемся от заявки + if (self::$bot['timeMain'] < time() - rand((30 / $zv['otk']), (135 / $zv['otk'])) && $zv['creator'] != self::$bot['id'] && ($zv['razdel'] == 1 || $zv['razdel'] == 2)) { + + $uz1 = mysql_fetch_array( + mysql_query( + 'SELECT `u`.`sex`,`u`.`id`,`u`.`login`,`u`.`align`,`u`.`clan`,`u`.`admin`,`u`.`city`,`u`.`room`,`u`.`online`,`u`.`level`,`u`.`battle`,`u`.`money`,`st`.* FROM `stats` AS `st` LEFT JOIN `users` AS `u` ON (`st`.`id` = `u`.`id`) WHERE `st`.`zv`="' . $zv['id'] . '" AND `st`.`team`="1" LIMIT 1' + ) + ); + if (isset($uz1['id'])) { + + $sa = ''; + if (self::$bot['sex'] == 2) { + $sa = 'а'; + } + + $text = ' [login:' . self::$bot['login'] . '] отозвал' . $sa . ' свой запрос на бой.'; + $chatDto = new ChatMessage(); + $chatDto->setCity($uz1['city']); + $chatDto->setTo($uz1['login']); + $chatDto->setText($text); + $chatDto->setType(6); + (new Chat())->sendMsg($chatDto); + } + + mysql_query('UPDATE `zayvki` SET `otk` = ( `otk` + 1 ),`bcs` = "' . (time() + rand(30, rand(60, 180))) . '" WHERE `id` = "' . $zv['id'] . '" LIMIT 1'); + mysql_query('UPDATE `stats` SET `zv` = "0",`team` = "1" WHERE `id` = "' . self::$bot['id'] . '" LIMIT 1'); + mysql_query('UPDATE `users` SET `ipreg` = "1",`timeMain` = "' . self::rnd() . '" WHERE `id` = "' . self::$bot['id'] . '" LIMIT 1'); } } + } else { + self::update('ipreg', 0); } - return true; - - } else { - - return false; - } + } + return true; } static function team_zv_cf($zv, $tm) @@ -765,9 +802,11 @@ class BotLogic { $rz = 5; - $sp = mysql_query('SELECT * FROM `zayvki` WHERE `razdel` = "' . $rz . '" AND `cancel` = "0" AND `start` = "0" AND `invise` = "0" AND `money3` = 0 AND ( + $sp = mysql_query( + 'SELECT * FROM `zayvki` WHERE `razdel` = "' . $rz . '" AND `cancel` = "0" AND `start` = "0" AND `invise` = "0" AND `money3` = 0 AND ( ( `min_lvl_1` <= ' . self::$bot['level'] . ' AND `max_lvl_1` >= ' . self::$bot['level'] . ' ) OR ( `min_lvl_2` <= ' . self::$bot['level'] . ' AND `max_lvl_2` >= ' . self::$bot['level'] . ' ) - )'); + )' + ); $pr = 0; @@ -808,7 +847,9 @@ class BotLogic //Логика приема заявки - if ((self::team_zv_cf($pl, $atm) > (self::team_zv_cf($pl, $tmr) + self::$st['reting']) * 1.67 || ($zv['tm2max'] < $zv['tm1max'] / 2) || ($zv['tm1max'] < $zv['tm2max'] / 2)) && rand(0, 100) < 90) { + if ((self::team_zv_cf($pl, $atm) > (self::team_zv_cf( + $pl, $tmr + ) + self::$st['reting']) * 1.67 || ($zv['tm2max'] < $zv['tm1max'] / 2) || ($zv['tm1max'] < $zv['tm2max'] / 2)) && rand(0, 100) < 90) { $go = 0; } } @@ -891,7 +932,8 @@ class BotLogic $r = ['name' => '_', 'chatColor' => 'Black']; - $ins = mysql_query("INSERT INTO `users` (`fnq`,`host_reg`,`room`,`login`,`pass`,`ipreg`,`ip`,`city`,`cityreg`,`name`,`sex`,`chatColor`,`timereg`) VALUES ( + $ins = mysql_query( + "INSERT INTO `users` (`fnq`,`host_reg`,`room`,`login`,`pass`,`ipreg`,`ip`,`city`,`cityreg`,`name`,`sex`,`chatColor`,`timereg`) VALUES ( '0', 'real_bot_user', '0', @@ -904,7 +946,8 @@ class BotLogic '" . $r['name'] . "', '" . mysql_real_escape_string($sex) . "', '" . $r['chatColor'] . "', - '" . time() . "')"); + '" . time() . "')" + ); if ($ins) { $uid = mysql_insert_id(); mysql_query("INSERT INTO `online` (`uid`,`timeStart`) VALUES ('" . $uid . "','" . time() . "')"); @@ -915,16 +958,16 @@ class BotLogic } //Бот находится в онлайне - static function _online() + static function _online(): void { - if (self::$bot['online'] < time() - 60) { - //уровень/апп - if (self::$bot['battle'] == 0 && self::$bot['zv'] == 0) { - self::_level(); - } - self::update('online', time()); - + if (self::$bot['online'] >= time() - 60) { + return; } + //уровень/апп + if (self::$bot['battle'] == 0 && self::$bot['zv'] == 0) { + self::levelUp(); + } + self::update('online', time()); } //Бот меняет локацию @@ -997,34 +1040,36 @@ class BotLogic } - //Бот получил уровень, либо апп - static function _level() + /** Бот получил уровень, либо ап + * @return void + */ + private static function levelUp(): void { - global $u; - $lvl = mysql_fetch_array(mysql_query('SELECT `upLevel`,`nextLevel`,`exp`,`money`,`money_bonus1`,`money_bonus2`,`ability`,`skills`,`nskills`,`sskills`,`expBtlMax`,`hpRegen`,`mpRegen`,`money2` FROM `levels` WHERE `upLevel`="' . (self::$bot['upLevel'] + 1) . '" LIMIT 1')); + $lvl = Db::getRow('select exp, upLevel from levels where upLevel = ?', [self::$bot['upLevel'] + 1]); if (isset($lvl['upLevel'])) { - - if (self::$bot['level'] <= 5 && self::$bot['exp'] >= 12499) { - $cr = mysql_fetch_array(mysql_query('SELECT `id` FROM `items_users` WHERE `item_id` = "1204" AND `uid` = "' . self::$bot['id'] . '" AND `delete` = "0" LIMIT 1')); - if (!isset($cr['id'])) { - \User\ItemsModel::addItem(1204, self::$bot['id']); - self::$bot['exp'] = 12500; - } + if ( + self::$bot['level'] <= 5 && + self::$bot['exp'] >= 12499 && + Db::getValue('select count(id) from items_users where item_id = 1204 and uid = ?', [self::$bot['id']]) === 0 + ) { + ItemsModel::addItem(1204, self::$bot['id']); + self::$bot['exp'] = 12500; } if ($lvl['exp'] <= self::$bot['exp']) { - self::inuser_go_main(self::$bot); - mysql_query('UPDATE `users` SET `clss` = "0" WHERE `id` = "' . self::$bot['id'] . '" LIMIT 1'); - + file_get_contents( + '/main_bot.php?uid=' . self::$bot['id'] . '&cron_core=' . md5(self::$bot['id'] . '_brfCOreW@!_' . self::$bot['pass']) . '&pass=' . self::$bot['pass'] . '&', + false, + stream_context_create(['https' => ['timeout' => 1]]) + ); + Db::sql('update users set clss = 0 where id = ?', [self::$bot['id']]); } - } else { self::e(self::$bot['login']); } - } //Вспомогательные функции - static function e($t) + static function e($t): void { (new Chat())->debug($t, true); } @@ -1034,10 +1079,10 @@ class BotLogic return time() + rand(3, 14) + rand(0, 14) + rand(7, 21); } - static function update($n, $v, $t = 'users') + private static function update($n, $v, $t = 'users'): void { + Db::sql("update users set $n = ? where id = ?", [$v, self::$bot['id']]); self::$bot[$n] = $v; - mysql_query('UPDATE `' . $t . '` SET `' . $n . '` = "' . self::$bot[$n] . '" WHERE `id` = "' . self::$bot['id'] . '" LIMIT 1'); } } diff --git a/_incl_data/class/Core/Config.php b/_incl_data/class/Core/Config.php index 8dd03a02..1c95106f 100644 --- a/_incl_data/class/Core/Config.php +++ b/_incl_data/class/Core/Config.php @@ -52,7 +52,7 @@ class Config $c['https'] = DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR . self::$hostname; $c['img2'] = self::subdomain('img'); $c['lib'] = self::subdomain('lib'); - $c['exit'] = ''; + $c['exit'] = ""; $c['support'] = 'support@' . $c['host']; diff --git a/_incl_data/class/Dungeon.php b/_incl_data/class/Dungeon.php index 7fb2b9d5..590507de 100644 --- a/_incl_data/class/Dungeon.php +++ b/_incl_data/class/Dungeon.php @@ -1483,7 +1483,7 @@ class Dungeon { $pd = array_fill(1, 28, 0); - global $pd; + //global $pd; /* Генерируем изображение карты */ /* LEVEL 1 */ diff --git a/_incl_data/class/FightRequest.php b/_incl_data/class/FightRequest.php index 9eea8be1..51160856 100644 --- a/_incl_data/class/FightRequest.php +++ b/_incl_data/class/FightRequest.php @@ -83,7 +83,7 @@ class FightRequest 'select * from zayvki where btl_id = 0 and cancel = 0 and start = 0 and razdel in (4,5) order by id desc limit 22' ); foreach ($sp as $pl) { - $uz = Db::getRow( + $uz = Db::getRows( 'select * from users left join stats on users.id = stats.id where zv = ?', [$pl['id']] ); @@ -244,7 +244,7 @@ class FightRequest $z['timeout'], $z['type'], $z['invise'], - $z['travmChance'], + $z['travmChance'] ?? 0, $z['exp'], ]; $q = 'insert into battle ( @@ -468,8 +468,6 @@ class FightRequest 'id' => $botInfo['id'], 'login' => $botInfo['login'], 'level' => $botInfo['level'], - 'city' => $botInfo['city'], - 'cityreg' => $botInfo['city'], 'name' => $botInfo['login'], 'sex' => $botInfo['sex'], 'hobby' => '', diff --git a/_incl_data/class/User.php b/_incl_data/class/User.php index 860ceca7..48c6b4a1 100644 --- a/_incl_data/class/User.php +++ b/_incl_data/class/User.php @@ -596,6 +596,7 @@ class User $user = !empty($_SESSION['uid']) ? $_SESSION['uid'] : $_COOKIE['login']; $this->info = self::getInfo($user); + unset($user); Database::init(); // для всяких mysql_* @@ -1097,6 +1098,14 @@ class User left join room on users.room = room.id where users.' . $cell . ' = ?'; $result = Db::getRow($query, [$user]); + + $temp = Conversion::dataStringToArray($result['stats']); + + $result['testStats'] = new User\UserStats( + $temp + ); + $result['testStats2'] = new \User\UserCalculatedStats($result['testStats']); + return $result ?: []; } @@ -2014,7 +2023,7 @@ class User Db::sql( "insert into users (align, login, level, pass, city, cityreg, name, sex, timereg, obraz, bot_id, inTurnir) values (?,?,?,uuid(),'Неведомые земли','Неведомые земли',?,?,?,?,?,?)", [ - $clon['align'], + $clon['align'] ?? 0, $clon['login'], $clon['level'], $clon['login'], @@ -2022,7 +2031,7 @@ class User $clon['time_reg'], $clon['obraz'], $id, - $clon['inTurnir'], + $clon['inTurnir'] ?? 0, ] ); diff --git a/_incl_data/class/User/InfoBox.php b/_incl_data/class/User/InfoBox.php index 777c7198..d1ab9389 100644 --- a/_incl_data/class/User/InfoBox.php +++ b/_incl_data/class/User/InfoBox.php @@ -735,7 +735,7 @@ class InfoBox } $x++; } - if ($pl['2h'] == 1) { + if (isset($pl['2h']) && $pl['2h'] == 1) { $lvar .= '
• Двуручное оружие'; } if (isset($po['zonb'])) { @@ -766,7 +766,7 @@ class InfoBox } - if ($pl['iznosMAX'] > 0) { + if (isset($pl['iznosMAX']) && $pl['iznosMAX'] > 0) { $lvar .= '
Долговечность: ' . floor($pl['iznosNOW']) . DIRECTORY_SEPARATOR . ceil($pl['iznosMAX']); } diff --git a/_incl_data/class/User/UserCalculatedStats.php b/_incl_data/class/User/UserCalculatedStats.php new file mode 100644 index 00000000..1e733672 --- /dev/null +++ b/_incl_data/class/User/UserCalculatedStats.php @@ -0,0 +1,73 @@ +hpAll = $this->hpAll(); + $this->mpAll = $this->mpAll(); + } + + private function hpAll(): int + { + $hpAll = $this->us->s4 * 5; + $hpAll += match (true){ + $this->us->s4 >= 200 => 850, + $this->us->s4 >= 175 => 600, + $this->us->s4 >= 150 => 450, + $this->us->s4 >= 125 => 400, + $this->us->s4 >= 100 => 250, + $this->us->s4 >= 75 => 175, + $this->us->s4 >= 50 => 100, + $this->us->s4 >= 25 => 50, + default => 0 + }; + return $hpAll; + } + + private function mpAll():int + { + $mpAll = $this->us->s6 * 10; + $mpAll += match (true) { + $this->us->s6 >= 200 => 1500, + $this->us->s6 >= 175 => 900, + $this->us->s6 >= 150 => 700, + $this->us->s6 >= 125 => 500, + $this->us->s6 >= 100 => 350, + $this->us->s6 >= 75 => 250, + $this->us->s6 >= 50 => 150, + $this->us->s6 >= 25 => 50, + default => 0 + }; + return $mpAll; + } + + public function __toString():string + { + $arr = []; + foreach ($this as $k=>$v) { + if (empty($v) || $k === 'us') { + continue; + } + $arr[$k] = $v; + } + return json_encode($arr); + } + + public function __debugInfo() + { + $arr = []; + foreach ($this as $k=>$v) { + if ($k === 'us') { + continue; + } + $arr[$k] = $v; + } + return $arr; + } +} \ No newline at end of file diff --git a/_incl_data/class/User/UserStats.php b/_incl_data/class/User/UserStats.php new file mode 100644 index 00000000..84515a24 --- /dev/null +++ b/_incl_data/class/User/UserStats.php @@ -0,0 +1,97 @@ +s1 = $a['s1'] ?? 0; + $this->s2 = $a['s2'] ?? 0; + $this->s3 = $a['s3'] ?? 0; + $this->s4 = $a['s4'] ?? 0; + $this->s5 = $a['s5'] ?? 0; + $this->s6 = $a['s6'] ?? 0; + $this->s7 = $a['s7'] ?? 0; + $this->a1 = max($a['a1'] ?? 0, $a['aall'] ?? 0); + $this->a2 = max($a['a2'] ?? 0, $a['aall'] ?? 0); + $this->a3 = max($a['a3'] ?? 0, $a['aall'] ?? 0); + $this->a4 = max($a['a4'] ?? 0, $a['aall'] ?? 0); + $this->a5 = max($a['a5'] ?? 0, $a['aall'] ?? 0); + $this->mg1 = max($a['mg1'] ?? 0, $a['mall'] ?? 0); + $this->mg2 = max($a['mg2'] ?? 0, $a['mall'] ?? 0); + $this->mg3 = max($a['mg3'] ?? 0, $a['mall'] ?? 0); + $this->mg4 = max($a['mg4'] ?? 0, $a['mall'] ?? 0); + $this->mg7 = $a['mg7'] ?? 0; + //$this->hpAll = $this->hpAll(); + //$this->mpAll = $this->mpAll(); + } + + /*private function hpAll(): int + { + $hpAll = $this->s4 * 5; + $hpAll += match (true){ + $this->s4 >= 200 => 850, + $this->s4 >= 175 => 600, + $this->s4 >= 150 => 450, + $this->s4 >= 125 => 400, + $this->s4 >= 100 => 250, + $this->s4 >= 75 => 175, + $this->s4 >= 50 => 100, + $this->s4 >= 25 => 50, + default => 0 + }; + return $hpAll; + } + + private function mpAll():int + { + $mpAll = $this->s6 * 10; + $mpAll += match (true) { + $this->s6 >= 200 => 1500, + $this->s6 >= 175 => 900, + $this->s6 >= 150 => 700, + $this->s6 >= 125 => 500, + $this->s6 >= 100 => 350, + $this->s6 >= 75 => 250, + $this->s6 >= 50 => 150, + $this->s6 >= 25 => 50, + default => 0 + }; + return $mpAll; + }*/ + public function __toString():string + { + $arr = []; + foreach ($this as $k=>$v) { + if (empty($v)) { + continue; + } + $arr[$k] = $v; + } + return json_encode($arr); + } + +} \ No newline at end of file diff --git a/buttons.php b/buttons.php index 9f681381..ea2e35c5 100644 --- a/buttons.php +++ b/buttons.php @@ -6,6 +6,7 @@ use Captcha\Captcha; use Core\Config; use Core\Database; use Core\Db; +use JetBrains\PhpStorm\NoReturn; use User\Clan; use User\UserIp; @@ -19,7 +20,7 @@ Database::init(); define('IP', UserIp::get()); $u = User::start(); -function gameexit(int $uid) +#[NoReturn] function gameexit(int $uid): void { setcookie('login', '', 0, '', Config::get('host')); setcookie('login', '', 0); diff --git a/modules_data/_clan.php b/modules_data/_clan.php index 01572b8f..12584be2 100644 --- a/modules_data/_clan.php +++ b/modules_data/_clan.php @@ -102,7 +102,7 @@ $lvl_exp = [ ]; -if ($res['exp'] >= $lvl_exp[$res['level'] + 1]) { +if ($res && $res['exp'] >= $lvl_exp[$res['level'] + 1]) { $res['level']++; mysql_query('UPDATE `clan` SET `level` = "' . $res['level'] . '" WHERE `id` = "' . $res['id'] . '" LIMIT 1'); mysql_query( @@ -481,7 +481,7 @@ if ($userclan->isAwaitingConfirmation()) { exit('
Заявка на регистрацию клана ' . $userclan->printClan() . ' в процессе рассмотрения.
'); } -if (!isset($res['id'])) { +if (!$res) { $clans = Db::getRows('select name, align, level from clan where status = 1 order by align, level desc, name'); ?> diff --git a/modules_data/_locations.php b/modules_data/_locations.php index 99b5b623..7cc2121c 100644 --- a/modules_data/_locations.php +++ b/modules_data/_locations.php @@ -131,9 +131,9 @@ if (isset($_GET['loc'])) { $tr_pl = Db::getValue('select v1 from eff_users where id_eff = 4 and uid = ? order by v1 desc limit 1', [$u->info['id']]); //Проверяем костыли - $hasKostyl = Db::getValue('select count(id) from items_users where inOdet in (3,14) and item_id in (630, 631) and uid = ?') > 0; + $hasKostyl = Db::getValue('select count(id) from items_users where inOdet in (3,14) and item_id in (630, 631) and uid = ?', [$u->info['id']]) > 0; $zadej = 0; - if (isset($tr_pl)) { + if ($tr_pl) { if ($hasKostyl) { if ($tr_pl == 2) { $zadej = 20; @@ -147,14 +147,12 @@ if (isset($_GET['loc'])) { } if ($u->room['extdlg'] > 0) { - header('location: main.php?talk=' . $u->room['extdlg'] . ''); - } elseif (isset($zadej) && $zadej == -1) { + header('location: main.php?talk=' . $u->room['extdlg']); + } elseif ($zadej == -1) { if (!isset($re) || $re == '') { $re = 'У вас травма, нельзя перемещаться...'; } //Травма... - } elseif ($u->info['align'] == 2 && $go['nochaos'] == 1) { - $re = 'Проход для хаосников закрыт!'; } elseif ($u->info['inTurnir'] > 0) { $re = 'Вы не можете перемещаться, Вы приняли заявку на турнир ...'; } elseif ( @@ -241,6 +239,8 @@ if (isset($_GET['loc'])) { } $u->info['timeGo'] = time() + $go['timeGO'] + $plus_timeGo; $u->info['timeGoL'] = time(); + + Db::sql('update stats set timeGo = ?, timeGoL = ? where id = ?', [$u->info['timeGo'], $u->info['timeGoL'], $u->info['id']]); Db::sql('update users set room = ?, online = unix_timestamp() where id = ?', [$go['id'], $u->info['id']]); @@ -442,6 +442,7 @@ if (date('m') == 11 || date('m') == 12 || date('m') == 1 || date('m') == 2) { var sp_rel = 1.4; //speed relevation var snowflake1 = "/i/itimeges/snow1.gif"; var snowflake2 = "/i/itimeges/snow2.gif"; + const snowflake3 = '❄️'; var i, doc_width, doc_height; @@ -478,10 +479,10 @@ if (date('m') == 11 || date('m') == 12 || date('m') == 1 || date('m') == 2) { doc_width = 580; doc_height = 312; - var div = ''; + let div = ''; for (i = 0; i < no; ++i) { SetVariable(i); - div += "
\"Снежинка\"
"; + div += "
\"Снежинка\"
"; } document.getElementById('snow').innerHTML = div; @@ -494,7 +495,7 @@ if (date('m') == 11 || date('m') == 12 || date('m') == 1 || date('m') == 2) { yp[i] += sty[i] < sp_rel ? sty[i] / 2 : sty[i]; if (yp[i] > doc_height - 40) { SetVariable(i); - var im = document.getElementById('im' + i); + const im = document.getElementById('im' + i); im.src = (sty[i] < sp_rel) ? snowflake2 : snowflake1; } dx[i] += stx[i]; @@ -510,7 +511,9 @@ if (date('m') == 11 || date('m') == 12 || date('m') == 1 || date('m') == 2) { } } -if (isset($u->room['id'])) { +if (!isset($u->room['id'])) { + echo 'Location is lost.'; +} else { $tmGo = $u->info['timeGo'] - time() + 1; //сколько секунд осталось $tmGol = $u->info['timeGo'] - $u->info['timeGoL'] + 1; //сколько секунд идти всего if ($tmGo < 0) { @@ -569,7 +572,5 @@ if (isset($u->room['id'])) { echo ''; } } -} else { - echo 'Location is lost.'; } diff --git a/modules_data/_zv.php b/modules_data/_zv.php index 312f9fd4..0491c6e7 100644 --- a/modules_data/_zv.php +++ b/modules_data/_zv.php @@ -18,8 +18,13 @@ $zv = new FightRequest(); // Турниры по умолчанию. // 4-group,5-chaos,6-current,7-ended,10-tournament -$r = (int)$_GET['r'] ??= FightRequest::BATTLE_RAZDEL_TOURNAMENTS; - +$r = match ($_GET['r']) { + '4' => FightRequest::BATTLE_RAZDEL_GROUP, + '5' => FightRequest::BATTLE_RAZDEL_CHAOTIC, + '6' => FightRequest::BATTLE_RAZDEL_CURRENT, + '7' => FightRequest::BATTLE_RAZDEL_ENDED, + default => FightRequest::BATTLE_RAZDEL_TOURNAMENTS +}; $js_5356 = sprintf( "top.lafstReg[%d] = 0; top.startHpRegen(\"main\",%d,%d,%d,%d,%d,%d,%d,%d,%d,1);", @@ -241,7 +246,8 @@ if ($r === FightRequest::BATTLE_RAZDEL_ENDED) { [$zg['id']] ); foreach ($users as $user) { - ${'tm' . $user['team']} .= '' . $user['login'] . ' [' . $user['level'] . ']inf
'; + ${'tm' . $user['team']} .= '' . $user['login'] . ' [' . $user['level'] . ']inf
'; } if (empty($tm1)) { $tm1 = 'группа пока не набрана'; @@ -353,7 +359,10 @@ if ($r === FightRequest::BATTLE_RAZDEL_ENDED) { } } -$btl_go = (int)$_POST['btl_go'] ?? (int)$_GET['btl_go'] ?? 0; +$btl_go = 0; +if (isset($_POST['btl_go']) || isset($_GET['btl_go'])) { + $btl_go = (int)$_POST['btl_go'] ?? (int)$_GET['btl_go']; +} $zv->go($btl_go); if ($zv->error) { diff --git a/modules_data/location/dungeon.php b/modules_data/location/dungeon.php index 4a7b5403..b6f456e9 100644 --- a/modules_data/location/dungeon.php +++ b/modules_data/location/dungeon.php @@ -67,23 +67,23 @@ if ($u->info['dnow'] == 0) { //Удаляем обьекты и т.д. из старых пещер $rb = 321; // Магический портал - $sp = mysql_query('SELECT * FROM `dungeon_now` WHERE `time_finish` = "0" LIMIT 50'); - while ($pl = mysql_fetch_array($sp)) { - $cn = mysql_fetch_array(mysql_query('SELECT `id` FROM `stats` WHERE `dnow` = "' . $pl['id'] . '" LIMIT 1')); - if (!isset($cn['id'])) { - mysql_query('DELETE FROM `dungeon_bots` WHERE `dn` = "' . $pl['id'] . '" AND `for_dn` = "0"'); - mysql_query('DELETE FROM `dungeon_obj` WHERE `dn` = "' . $pl['id'] . '" AND `for_dn` = "0"'); - mysql_query('DELETE FROM `dungeon_items` WHERE `dn` = "' . $pl['id'] . '" AND `for_dn` = "0"'); - mysql_query('DELETE FROM `dungeon_bots` WHERE `dn` = "' . $pl['id'] . '" AND `for_dn` = "0"'); - mysql_query('DELETE FROM `dungeon_actions` WHERE `dn` = "' . $pl['id'] . '"'); - mysql_query('UPDATE `dungeon_now` SET `time_finish` = "' . time() . '" WHERE `id` = "' . $pl['id'] . '" LIMIT 1'); - } - } - $cn = mysql_fetch_array(mysql_query('SELECT `id` FROM `stats` WHERE `dnow` = "' . $d->info['id'] . '" AND `id` != "' . $u->info['id'] . '" ORDER BY `exp` DESC LIMIT 1')); - if (isset($cn['id'])) { + $dungeonIds = Db::getColumn('select id from dungeon_now where time_finish = 0'); + $dnowIds = Db::getColumn('select id from stats where dnow in (?)', [implode(',', $dungeonIds)]); + $diff = implode(',', array_diff($dungeonIds, $dnowIds)); + + Db::sql('delete from dungeon_bots where dn in (?) and for_dn = 0', [$diff]); + Db::sql('delete from dungeon_obj where dn in (?) and for_dn = 0', [$diff]); + Db::sql('delete from dungeon_items where dn in (?) and for_dn = 0', [$diff]); + Db::sql('delete from dungeon_actions where dn in (?)', [$diff]); + + Db::sql('update dungeon_now set time_finish = unix_timestamp() where id in (?)', [$diff]); + unset($dungeonIds, $dnowIds, $diff); + + $cn1 = Db::getValue('select id from stats where dnow = ? and id != ? order by exp desc limit 1', [$d->info['id'], $u->info['id']]); + if ($cn1) { if ($d->info['uid'] == $u->info['id']) { - $cn = mysql_fetch_array(mysql_query('SELECT `id`,`login`,`sex` FROM `users` WHERE `id` = "' . $cn['id'] . '" LIMIT 1')); - mysql_query('UPDATE `dungeon_now` SET `uid` = "' . $cn['id'] . '" WHERE `id` = "' . $d->info['id'] . '" LIMIT 1'); + $cn = Db::getRow('select id, login, sex from users where id = ?', [$cn1]); + Db::sql('update dungeon_now set uid = ? where id = ?', [$cn['id'], $d->info['id']]); if ($cn['sex'] == 0) { if ($u->info['sex'] == 0) { $d->sys_chat('' . $u->info['login'] . ' покинул подземелье, новым лидером группы стал ' . $cn['login'] . ''); @@ -105,22 +105,17 @@ if ($u->info['dnow'] == 0) { } } } + unset($cn, $cn1); - $city = mysql_fetch_assoc(mysql_query('SELECT `id`, `city` FROM `room` WHERE `id` = "' . $rb . '" LIMIT 1')); - mysql_query('UPDATE `stats` SET `dnow` = "0" WHERE `id` = "' . $u->info['id'] . '" LIMIT 1'); - mysql_query('UPDATE `users` SET `room` = "' . $rb . '", `city`="' . $city['city'] . '" WHERE `id` = "' . $u->info['id'] . '" LIMIT 1'); + Db::sql('update users left join stats on users.id = stats.id set dnow = 0, room = ? where users.id = ?', [$rb, $u->info['id']]); //удаляем все предметы которые пропадают после выхода из пещеры - mysql_query('UPDATE `items_users` SET `delete` = "' . time() . '" WHERE `uid` = "' . $u->info['id'] . '" AND `dn_delete` = "1" LIMIT 1000'); + Db::sql('delete from items_users where uid = ? and (dn_delete = 1 or item_id in (1174,1189,4447))', [$u->info['id']]); - mysql_query('UPDATE `items_users` SET `delete` = "' . time() . '" WHERE `uid` = "' . $u->info['id'] . '" AND (`item_id` = "1189" OR `item_id` = "4447" OR `item_id` = "1174") LIMIT 1000'); - - //header("Location: main.php"); - echo ''; - die(); + exit(''); } } -if ($d->point['fileadd'] == 1 && $d->point['file'] != '0' && $d->point['file'] != '') { +if (!empty($d->point['file']) && $d->point['fileadd'] == 1) { $file = explode('=', $d->point['file']); if (file_exists('modules_data/location/' . $file[0])) { $information = ''; @@ -135,7 +130,7 @@ if ($d->point['fileadd'] == 1 && $d->point['file'] != '0' && $d->point['file'] ! } } -if ($d->point['fileadd'] == 0 && $d->point['file'] != '0' && $d->point['file'] != '') { +if (!empty($d->point['file']) && $d->point['fileadd'] == 0) { $file = explode('=', $d->point['file']); if (file_exists('modules_data/location/' . $file[0])) { require_once('modules_data/location/' . $file[0]); @@ -526,11 +521,14 @@ if ($d->point['fileadd'] == 0 && $d->point['file'] != '0' && $d->point['file'] ! } } - zfloor0[rz] = '' + zfloor0[rz]; + zfloor0[rz] = '' + zfloor0[rz]; } else { - zfloor0[rz] = '' + zfloor0[rz]; + zfloor0[rz] = '' + zfloor0[rz]; } - r = ''; + r = ''; } return r; } @@ -590,11 +588,14 @@ if ($d->point['fileadd'] == 0 && $d->point['file'] != '0' && $d->point['file'] ! if (v[5] == 'bot' || info['bsid'];?> > 0) { action = 'dialogMenu(' + v[0] + ',' + v[8] + ',' + v[7] + ',0,0,event,' + v[9] + ');'; } - zfloor0[rz] += ''; + zfloor0[rz] += ''; } else { - zfloor0[rz] += ''; + zfloor0[rz] += ''; } - r = ''; + r = ''; } return r; } @@ -823,7 +824,7 @@ if ($d->point['fileadd'] == 0 && $d->point['file'] != '0' && $d->point['file'] ! position: absolute; top: -8px; left: -6px; - / / background-image: url(" /drgn/bg/r.gif"); + / / background-image: url(" /drgn/bg/r.gif"); } @@ -879,7 +880,8 @@ if ($d->point['fileadd'] == 0 && $d->point['file'] != '0' && $d->point['file'] ! } if(!empty($sb1) && $sb1['x'] == $pl['x'] && $sb1['y'] == $pl['y'] ) { - echo '$("#min_' . $pl['x'] . '_' . $pl['y'] . '").html("info['s'] . '\" title=\"Шайба!\" style=\"margin:2px 3px 3px 2px;background-image:url(' . Config::img() . '/i/move/shb.gif)\" src=\"' . Config::img() . '/1x1.gif\" width=\"7\" height=\"7\">");'; + echo '$("#min_' . $pl['x'] . '_' . $pl['y'] . '").html("info['s'] . '\" title=\"Шайба!\" style=\"margin:2px 3px 3px 2px;background-image:url(' . Config::img( + ) . '/i/move/shb.gif)\" src=\"' . Config::img() . '/1x1.gif\" width=\"7\" height=\"7\">");'; }elseif ($u->info['x'] == $pl['x'] && $u->info['y'] == $pl['y']) { if ($d->info['id2'] == 15) { $tmbth = 4; @@ -889,9 +891,11 @@ if ($d->point['fileadd'] == 0 && $d->point['file'] != '0' && $d->point['file'] ! } elseif ($tm['team'] == 2) { $tmbth = 2; } - echo '$("#min_' . $pl['x'] . '_' . $pl['y'] . '").html("info['s'] . '\" title=\"Это Вы\" style=\"margin:2px 3px 3px 2px;background-image:url(' . Config::img() . '/i/move/p' . $tmbth . '/d0.gif)\" src=\"' . Config::img() . '/1x1.gif\" width=\"7\" height=\"7\">");'; + echo '$("#min_' . $pl['x'] . '_' . $pl['y'] . '").html("info['s'] . '\" title=\"Это Вы\" style=\"margin:2px 3px 3px 2px;background-image:url(' . Config::img( + ) . '/i/move/p' . $tmbth . '/d0.gif)\" src=\"' . Config::img() . '/1x1.gif\" width=\"7\" height=\"7\">");'; } else { - echo '$("#min_' . $pl['x'] . '_' . $pl['y'] . '").html("info['s'] . '\" title=\"Это Вы\" style=\"margin:2px 3px 3px 2px;background-image:url(' . Config::img() . '/i/move/p1/d0.gif)\" src=\"' . Config::img() . '/1x1.gif\" width=\"7\" height=\"7\">");'; + echo '$("#min_' . $pl['x'] . '_' . $pl['y'] . '").html("info['s'] . '\" title=\"Это Вы\" style=\"margin:2px 3px 3px 2px;background-image:url(' . Config::img( + ) . '/i/move/p1/d0.gif)\" src=\"' . Config::img() . '/1x1.gif\" width=\"7\" height=\"7\">");'; } } elseif ($d->info['id2'] == 15) { $tmbth = 4; @@ -907,12 +911,15 @@ if ($d->point['fileadd'] == 0 && $d->point['file'] != '0' && $d->point['file'] ! ) ); if (isset($tbshin['id'])) { - echo '$("#min_' . $pl['x'] . '_' . $pl['y'] . '").html("info['s'] . '\" title=\"Шайба!\" style=\"margin:2px 3px 3px 2px;background-image:url(' . Config::img() . '/i/move/shb.gif)\" src=\"' . Config::img() . '/1x1.gif\" width=\"7\" height=\"7\">");'; + echo '$("#min_' . $pl['x'] . '_' . $pl['y'] . '").html("info['s'] . '\" title=\"Шайба!\" style=\"margin:2px 3px 3px 2px;background-image:url(' . Config::img( + ) . '/i/move/shb.gif)\" src=\"' . Config::img() . '/1x1.gif\" width=\"7\" height=\"7\">");'; } else { - echo '$("#min_' . $uxy[$pl['x'] . '_' . $pl['y']]['x'] . '_' . $uxy[$pl['x'] . '_' . $pl['y']]['y'] . '").html("");'; + echo '$("#min_' . $uxy[$pl['x'] . '_' . $pl['y']]['x'] . '_' . $uxy[$pl['x'] . '_' . $pl['y']]['y'] . '").html("");'; } }elseif (isset($uxy[$pl['x'] . '_' . $pl['y']])) { - echo '$("#min_' . $uxy[$pl['x'] . '_' . $pl['y']]['x'] . '_' . $uxy[$pl['x'] . '_' . $pl['y']]['y'] . '").html("");'; + echo '$("#min_' . $uxy[$pl['x'] . '_' . $pl['y']]['x'] . '_' . $uxy[$pl['x'] . '_' . $pl['y']]['y'] . '").html("");'; } elseif( isset($bxy[$pl['x'] . '_' . $pl['y']]) ) { $bobrz = $bxy[$pl['x'] . '_' . $pl['y']]['obraz']; @@ -924,7 +931,8 @@ if ($d->point['fileadd'] == 0 && $d->point['file'] != '0' && $d->point['file'] ! } ?> - $("#min__").html("
' src='/chars//'>
"); + $("#min__").html("
' src='/chars//'>
"); room['file'] != 'dungeon_enter_all') { $error = ''; // Собираем ошибки. $dungeonGroupList = ''; // Сюда помещаем список Групп. $dungeonGo = 1; // По умолчанию, мы идем в пещеру. -$dungeon = Db::getRow('select id as room, city, dungeon_room as d_room, shop, dungeon_id as id, dungeon_name as name from dungeon_room where id = ?', [$u->room['id']]); +$dungeon = Db::getRow('select id as room, city, dungeon_room as d_room, shop, dungeon_id as id, dungeon_name as name from dungeon_room where id = ?', [$u->room['id']]) ?: []; $zv = []; $dunname = [ @@ -656,61 +656,61 @@ if ($roomSection == 1) { if (!isset($hgo1['id'])) { ?> - (Пещера Тысячи Проклятий)' + (Пещера Тысячи Проклятий)' onclick='location="main.php?rz=1&add_quest=1&city_quest=capitalcity"'/> - (Бездна)' + (Бездна)' onclick='location="main.php?rz=1&add_quest=1&city_quest=angelscity"'/> - (Грибница)' + (Грибница)' onclick='location="main.php?rz=1&add_quest=1&city_quest=suncity"'/> - (Катакомбы)' + (Катакомбы)' onclick='location="main.php?rz=1&add_quest=1&city_quest=demonscity"'/> - (Водосток)' + (Водосток)' onclick='location="main.php?rz=1&add_quest=1&city_quest=dreamscity"'/> - (Гора Легиона)' + (Гора Легиона)' onclick='location="main.php?rz=1&add_quest=1&city_quest=abandonedplain"'/> - (Излом Хаоса)' + (Излом Хаоса)' onclick='location="main.php?rz=1&add_quest=1&city_quest=izlom16"'/> - (Пещера Мглы)' + (Пещера Мглы)' onclick='location="main.php?rz=1&add_quest=1&city_quest=sandcity"'/> - (Потерянный Вход)' + (Потерянный Вход)' onclick='location="main.php?rz=1&add_quest=1&city_quest=emeraldscity"'/> - (Туманные Низины)' + (Туманные Низины)' onclick='location="main.php?rz=1&add_quest=1&city_quest=devilscity"'/> @@ -990,9 +990,9 @@ if ($roomSection == 1) { $val) { - if ($u->rep['rep' . $val] >= 0) { + if ($u->rep['rep' . $val] > 0) { echo ' - + '; }
Репутация в ' . ucfirst(str_replace('city', ' city', $val)) . ':' . ucfirst(str_replace('city', ' city', $val)) . ': ' . $u->rep['rep' . $val] . ' ед.