From 07f905ef645cd1c3fcbbf72bf86525f2d376ea5b Mon Sep 17 00:00:00 2001 From: Ivor Barhansky Date: Tue, 19 Dec 2023 03:58:37 +0200 Subject: [PATCH] =?UTF-8?q?=D0=9C=D0=BD=D0=BE=D0=B3=D0=BE=20=D1=80=D0=B5?= =?UTF-8?q?=D1=84=D0=B0=D0=BA=D1=82=D0=BE=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- _incl_data/class/Actions.php | 39 + _incl_data/class/Battle.php | 3605 +++-------------- _incl_data/class/Battle/Finish.php | 1916 +++++++++ _incl_data/class/Battle/Helper.php | 11 + _incl_data/class/Battle/Log.php | 4 + _incl_data/class/Enum/ShopId.php | 1 - _incl_data/class/Helper/Comparsion.php | 2 +- _incl_data/class/ItemModel.php | 6 + _incl_data/class/Moderation/AdmFactory.php | 12 +- _incl_data/class/Moderation/Announcement.php | 12 +- _incl_data/class/Moderation/ModFactory.php | 36 +- .../class/Moderation/UserRegistrationList.php | 16 +- _incl_data/class/User.php | 2 +- _incl_data/class/User/Clan.php | 9 +- _incl_data/class/User/Effects.php | 13 +- _incl_data/class/User/Reputation.php | 26 +- _incl_data/class/User/Stats.php | 94 +- _incl_data/class/priems/bloodring.php | 44 - _incl_data/class/priems/bloodring2.php | 63 - _incl_data/class/priems/bloodring2_end.php | 28 - jx/battle/refresh.php | 2 +- jx/battle/refresh1.php | 2 +- jx/battle/refresh2.php | 2 +- jx/battle/refresh_bot.php | 2 +- 24 files changed, 2748 insertions(+), 3199 deletions(-) create mode 100644 _incl_data/class/Actions.php create mode 100644 _incl_data/class/Battle/Finish.php create mode 100644 _incl_data/class/Battle/Helper.php delete mode 100644 _incl_data/class/priems/bloodring.php delete mode 100644 _incl_data/class/priems/bloodring2.php delete mode 100644 _incl_data/class/priems/bloodring2_end.php diff --git a/_incl_data/class/Actions.php b/_incl_data/class/Actions.php new file mode 100644 index 00000000..a6835d3b --- /dev/null +++ b/_incl_data/class/Actions.php @@ -0,0 +1,39 @@ +finish = new Finish($this); } //JS информация о игроке @@ -1017,7 +1018,7 @@ class Battle $obr = 0; $bots = []; //Это излом, добавляем еще ботов - if ($this->getChanse(20)) { + if (Helper::getChanse(20)) { //Уникальные монстры if ($this->info['izlomLvl'] == 8) { @@ -1216,14 +1217,20 @@ class Battle $btxt = "$alignStr$clanStr$login [$level]$loginLink"; $btxt .= $gender == 1 ? ' вмешалась в поединок.' : ' вмешался в поединок.'; - $this->miniLogAdd( + Log::add( [ - 'login' => $login, - 'sex' => $gender, - 'team' => 0, - ], - "{tm1} $btxt" + 'text' => "{tm1} $btxt", + 'battle' => $this->info['id'], + 'id_hod' => ($this->hodID + 1), + 'vars' => 'at1=00000||at2=00000||zb1=0||zb2=0||bl1=0||bl2=0||time1=' . time() . + '||time2=' . time() . + '||s1=' . $gender . + '||t1=0' . + '||login1=' . $login, + 'type' => 1, + ] ); + Db::sql('update users left join stats on users.id = stats.id set battle = ?, team = 2 where users.id = ?', [$this->info['id'], $bot['id']]); if ($unique) { @@ -1238,40 +1245,17 @@ class Battle //Поглощение урона - private function getChanse(int $percent): bool - { - return rand(0, 100) <= $percent; - } - - //Поглощение урона - - private function miniLogAdd(array $user, string $text): void - { - if (empty($text) || !isset($user['sex'], $user['team'], $user['login'])) { - return; - } - Log::add( - [ - 'text' => $text, - 'battle' => $this->info['id'], - 'id_hod' => ($this->hodID + 1), - 'vars' => 'at1=00000||at2=00000||zb1=0||zb2=0||bl1=0||bl2=0||time1=' . time() . - '||time2=' . time() . - '||s1=' . $user['sex'] . - '||t1=' . $user['team'] . - '||login1=' . $user['login'], - 'type' => 1, - ] - ); - } - + /** Запись в лог боя с шансом реплики комментатора. + * @param array $mass + * @return void + */ public function add_log(array $mass): void { if (empty($mass['text'])) { return; } Log::add($mass); - if ($this->getChanse(12)) { + if (Helper::getChanse(12)) { Log::addComment($this); } } @@ -1281,1853 +1265,38 @@ class Battle private function finishBattle($t, $v, $nl): void { - global $u; - $chat = new Chat(); - mysql_query('LOCK TABLES users,stats,battle,battle_last,battle_end,chat WRITE'); - $frtu = false; - $test = mysql_fetch_array( - mysql_query( - 'SELECT `id`,`team_win`,`testfinish` FROM `battle` WHERE `id` = "' . $this->info['id'] . '" AND `team_win` != -1 LIMIT 1;' - ) - ); - if ($test['testfinish'] == -1) { - sleep(2); - } else { - $trtt = mysql_query( - 'UPDATE `battle` SET `testfinish` = "-1" WHERE `id` = "' . $this->info['id'] . '" LIMIT 1' - ); - $relbf = $this->info['team_win']; - if ($nl != 10) { - $i = 0; - $dnr = 0; - if ($this->info['team_win'] == -1) { - $this->info['team_win'] = 0; - while ($i < count($v)) { - if ($v[$i] >= 1 && $t[$v[$i]] > 0) { - $this->info['team_win'] = $v[$i]; - } - $i++; - } - } - } - - //данные о игроках в бою - $t = mysql_query( - 'SELECT `u`.`stopexp`,`u`.`twink`,`u`.`city`,`u`.`room`,`u`.`no_ip`,`u`.`pass`,`u`.`id`,`u`.`notrhod`,`u`.`login`,`u`.`login2`,`u`.`sex`,`u`.`online`,`u`.`admin`,`u`.`align`,`u`.`align_lvl`,`u`.`align_exp`,`u`.`clan`,`u`.`level`,`u`.`battle`,`u`.`obraz`,`u`.`win`,`u`.`lose`,`u`.`nich`,`u`.`animal`,`st`.`stats`,`st`.`hpNow`,`st`.`mpNow`,`st`.`exp`,`st`.`dnow`,`st`.`team`,`st`.`battle_yron`,`st`.`battle_exp`,`st`.`enemy`,`st`.`battle_text`,`st`.`upLevel`,`st`.`timeGo`,`st`.`timeGoL`,`st`.`bot`,`st`.`lider`,`st`.`btl_cof`,`st`.`tactic1`,`st`.`tactic2`,`st`.`tactic3`,`st`.`tactic4`,`st`.`tactic5`,`st`.`tactic6`,`st`.`tactic7`,`st`.`x`,`st`.`y`,`st`.`battleEnd`,`st`.`priemslot`,`st`.`priems`,`st`.`priems_z`,`st`.`bet`,`st`.`clone`,`st`.`atack`,`st`.`bbexp`,`st`.`res_x`,`st`.`res_y`,`st`.`res_s`,`st`.`id`,`st`.`last_hp`,`st`.`last_pr`,`u`.`sex`,`u`.`money`,`u`.`bot_id`,`u`.`money3`,`u`.`money2` FROM `users` AS `u` LEFT JOIN `stats` AS `st` ON (`u`.`id` = `st`.`id`) WHERE `u`.`battle` = "' . $this->info['id'] . '"' - ); - $i = 0; - $bi = 0; - while ($pl = mysql_fetch_array($t)) { - //записываем данные - if ($pl['login2'] == '') { - $pl['login2'] = $pl['login']; - } - $this->users[$i] = $pl; - $this->uids[$pl['id']] = $i; - if ($pl['bot'] > 0) { - $this->bots[$bi] = $pl['id']; - $this->iBots[$pl['id']] = $bi; - $bi++; - } - //записываем статы - $this->stats[$i] = $u->getStats($pl['id'], 0, 0, false, false, true); - $i++; - } - unset($pl, $t); - - if ($this->info['time_over'] == 0) { - $tststrt = mysql_fetch_array( - mysql_query( - 'SELECT * FROM `battle` WHERE `id` = "' . $this->info['id'] . '" AND `time_over` = "0" LIMIT 1' - ) - ); - if (isset($tststrt['id'])) { - if ($this->info['inTurnir'] == 0 || $this->info['type'] == 500) { - mysql_query( - 'UPDATE `battle` SET `time_over` = "' . time() . '",`team_win` = "' . $this->info['team_win'] . '" WHERE `id` = "' . $this->info['id'] . '" LIMIT 1' - ); - } - mysql_query( - 'UPDATE `battle_stat` SET `team_win` = "' . $this->info['team_win'] . '" WHERE `battle_id` = "' . $this->info['id'] . '"' - ); - //Заносим данные о завершении боя - $i = 0; - $vl = ''; - $vtvl = ''; - $relu = 0; - while ($i < count($this->users)) { - $vl .= '("' . $this->users[$i]['login'] . '","' . $this->users[$i]['city'] . '","' . $this->info['id'] . '","' . $this->users[$i]['id'] . '","' . time( - ) . '","' . $this->users[$i]['team'] . '","' . $this->users[$i]['level'] . '","' . $this->users[$i]['align'] . '","' . $this->users[$i]['clan'] . '","' . $this->users[$i]['exp'] . '","' . $this->users[$i]['bot'] . '","' . $this->users[$i]['money'] . '","' . $this->users[$i]['money2'] . '","' . $this->users[$i]['money3'] . '"),'; - if ($this->users[$i]['team'] == $this->info['team_win'] && $this->info['team_win'] > 0) { - $vtvl .= '' . $this->users[$i]['login'] . ', '; - } - $i++; - } - - $this->info['players_c'] = mysql_fetch_array( - mysql_query( - 'SELECT COUNT(`id`) FROM `users` WHERE `login` NOT LIKE "%(зверь%" AND `battle` = "' . $this->info['id'] . '" LIMIT 1' - ) - ); - $this->info['players_c'] = $this->info['players_c'][0]; - - mysql_query( - 'UPDATE `battle` SET `players_c` = "' . $this->info['players_c'] . '" WHERE `id` = "' . $this->info['id'] . '" LIMIT 1' - ); - - if ($vtvl != '') { - $vtvl = rtrim($vtvl, ', '); - $vtvl = str_replace('"', '\\\\\"', $vtvl); - $this->hodID++; - $vLog = 'time1=' . time(); - $mass = [ - 'time' => time(), - 'battle' => $this->info['id'], - 'id_hod' => $this->hodID, - 'text' => 'test', - 'vars' => $vLog, - 'zona1' => '', - 'zonb1' => '', - 'zona2' => '', - 'zonb2' => '', - 'type' => '1', - ]; - $vtvl = 'Бой закончен, победа за ' . $vtvl . '.'; - } else { - $this->info['players_cc'] = mysql_fetch_array( - mysql_query( - 'SELECT COUNT(`u`.`id`) FROM `users` AS `u` LEFT JOIN `stats` AS `s` ON `s`.`id` = `u`.`id` WHERE `s`.`hpNow` > 0 AND `u`.`battle` = "' . $this->info['id'] . '" AND `s`.`team` != "' . $u->info['team'] . '" LIMIT 1' - ) - ); - $this->info['players_cc'] = $this->info['players_cc'][0]; - $this->info['players_cc2'] = mysql_fetch_array( - mysql_query( - 'SELECT COUNT(`u`.`id`) FROM `users` AS `u` LEFT JOIN `stats` AS `s` ON `s`.`id` = `u`.`id` WHERE `s`.`hpNow` >= 1 AND `u`.`battle` = "' . $this->info['id'] . '" AND `s`.`team` != "' . $u->info['team'] . '" LIMIT 1' - ) - ); - $this->info['players_cc2'] = $this->info['players_cc2'][0]; - $inf_test = ', users: ' . $this->info['players_cc'] . ' and ' . $this->info['players_cc2']; - $this->hodID++; - $vLog = 'time1=' . time(); - $mass = [ - 'time' => time(), - 'battle' => $this->info['id'], - 'id_hod' => $this->hodID, - 'text' => 'test', - 'vars' => $vLog, - 'zona1' => '', - 'zonb1' => '', - 'zona2' => '', - 'zonb2' => '', - 'type' => '1', - ]; - $vtvl = 'Бой закончен, ничья.'; - } - $ins = mysql_query( - 'INSERT INTO `battle_logs` (`time`,`battle`,`id_hod`,`text`,`vars`,`zona1`,`zonb1`,`zona2`,`zonb2`,`type`) VALUES ("' . $mass['time'] . '","' . $mass['battle'] . '","' . $mass['id_hod'] . '","' . $vtvl . '","' . $mass['vars'] . '","' . $mass['zona1'] . '","' . $mass['zonb1'] . '","' . $mass['zona2'] . '","' . $mass['zonb2'] . '","' . $mass['type'] . '")' - ); - - $this->saveLogs(); - - if ($this->info['type'] == 99) { - $vLog = 'time1=' . time(); - $mass = [ - 'time' => time(), - 'battle' => $this->info['id'], - 'id_hod' => $this->hodID, - 'text' => 'test', - 'vars' => $vLog, - 'zona1' => '', - 'zonb1' => '', - 'zona2' => '', - 'zonb2' => '', - 'type' => '1', - ]; - $vtvl = 'И победители стали калечить проигравших...'; - $ins = mysql_query( - 'INSERT INTO `battle_logs` (`time`,`battle`,`id_hod`,`text`,`vars`,`zona1`,`zonb1`,`zona2`,`zonb2`,`type`) VALUES ("' . $mass['time'] . '","' . $mass['battle'] . '","' . $mass['id_hod'] . '","' . $vtvl . '","' . $mass['vars'] . '","' . $mass['zona1'] . '","' . $mass['zonb1'] . '","' . $mass['zona2'] . '","' . $mass['zonb2'] . '","' . $mass['type'] . '")' - ); - $i = 0; - $vtvl = ''; - $tr_nm = [ - 1 => 'легкую', - 2 => 'среднюю', - 3 => 'тяжелую', - 4 => 'неизлечимую', - ]; - while ($i < count($this->users)) { - if ($this->users[$i]['team'] != $this->info['team_win']) { - $tr_pl = mysql_fetch_array( - mysql_query( - 'SELECT `id`,`v1` FROM `eff_users` WHERE `id_eff` = 4 AND `uid` = "' . $this->users[$i]['id'] . '" AND `delete` = "0" ORDER BY `v1` DESC LIMIT 1' - ) - ); - if (!isset($tr_pl['id']) || $tr_pl['v1'] < 3) { - if ($this->info['smert'] == 1) { - $tr_tp = 4; - } else { - $tr_tp = rand(1, 3); - } - if (isset($tr_pl['id'])) { - $tr_tp = rand(($tr_pl['v1'] + 1), 3); - } - if ($this->users[$i]['sex'] == 1) { - $vtvl = '' . $this->users[$i]['login'] . ' получила повреждение: ' . $tr_nm[$tr_tp] . ' травму.
' . $vtvl; - } else { - $vtvl = '' . $this->users[$i]['login'] . ' получил повреждение: ' . $tr_nm[$tr_tp] . ' травму.
' . $vtvl; - } - $this->addTravm($this->users[$i]['id'], $tr_tp, rand(3, 5)); - } - } - $i++; - } - $ins = mysql_query( - 'INSERT INTO `battle_logs` (`time`,`battle`,`id_hod`,`text`,`vars`,`zona1`,`zonb1`,`zona2`,`zonb2`,`type`) VALUES ("' . $mass['time'] . '","' . $mass['battle'] . '","' . $mass['id_hod'] . '","' . $vtvl . '","' . $mass['vars'] . '","' . $mass['zona1'] . '","' . $mass['zonb1'] . '","' . $mass['zona2'] . '","' . $mass['zonb2'] . '","' . $mass['type'] . '")' - ); - } - - if ($vl != '') { - $vl = rtrim($vl, ','); - mysql_query( - 'INSERT INTO `battle_last` (`login`,`city`,`battle_id`,`uid`,`time`,`team`,`lvl`,`align`,`clan`,`exp`,`bot`,`money`,`money2`,`money3`) VALUES ' . $vl - ); - } - - mysql_query( - 'INSERT INTO `battle_end` (`battle_id`,`city`,`time`,`team_win`) VALUES ("' . $this->info['id'] . '","' . $this->info['city'] . '","' . $this->info['time_start'] . '","' . $this->info['team_win'] . '")' - ); - } - - - $vLog = 'time1=' . time(); - $mass = [ - 'time' => time(), - 'battle' => $this->info['id'], - 'id_hod' => $this->hodID, - 'text' => 'test', - 'vars' => $vLog, - 'zona1' => '', - 'zonb1' => '', - 'zona2' => '', - 'zonb2' => '', - 'type' => '1', - ]; - $i = 0; - $vtvl = ''; - $tr_nm = [ - 1 => 'легкую', - 2 => 'среднюю', - 3 => 'тяжелую', - 4 => 'неизлечимую', - ]; - while ($i < count($this->users)) { - if ($this->users[$i]['team'] != $this->info['team_win'] && $this->info['team_win'] > 0) { - $tr_pl = mysql_fetch_array( - mysql_query( - 'SELECT * FROM `eff_users` WHERE `v1` = "priem" AND `v2` = 292 AND `uid` = "' . $this->users[$i]['id'] . '" AND `delete` = "0" LIMIT 1' - ) - ); - - $ins = mysql_query( - 'INSERT INTO `battle_logs` (`time`,`battle`,`id_hod`,`text`,`vars`,`zona1`,`zonb1`,`zona2`,`zonb2`,`type`) VALUES ("' . $mass['time'] . '","' . $mass['battle'] . '","' . $mass['id_hod'] . '","' . $vtvl2 . '","' . $mass['vars'] . '","' . $mass['zona1'] . '","' . $mass['zonb1'] . '","' . $mass['zona2'] . '","' . $mass['zonb2'] . '","' . $mass['type'] . '")' - ); - - if (isset($tr_pl['id'])) { - if (rand(0, 100) < $tr_pl['data']) { - $tr_tp = rand(1, 3); - if (isset($tr_pl['id'])) { - $tr_tp = rand(($tr_pl['v1'] + 1), 3); - } - if ($this->users[$i]['sex'] == 1) { - $vtvl = '' . $this->users[$i]['login'] . ' получила повреждение (Искалечить, автор: ' . $this->users[$this->uids[$tr_pl['user_use']]]['login'] . '): ' . $tr_nm[$tr_tp] . ' травму.
' . $vtvl; - } else { - $vtvl = '' . $this->users[$i]['login'] . ' получил повреждение (Искалечить, автор: ' . $this->users[$this->uids[$tr_pl['user_use']]]['login'] . '): ' . $tr_nm[$tr_tp] . ' травму.
' . $vtvl; - } - $this->addTravm($this->users[$i]['id'], $tr_tp, rand(3, 5)); - } - } - } - $i++; - } - if ($vtvl != '') { - if ($this->info['type'] != 99) { - $vtvl2 = 'И победители стали калечить проигравших...'; - $ins = mysql_query( - 'INSERT INTO `battle_logs` (`time`,`battle`,`id_hod`,`text`,`vars`,`zona1`,`zonb1`,`zona2`,`zonb2`,`type`) VALUES ("' . $mass['time'] . '","' . $mass['battle'] . '","' . $mass['id_hod'] . '","' . $vtvl2 . '","' . $mass['vars'] . '","' . $mass['zona1'] . '","' . $mass['zonb1'] . '","' . $mass['zona2'] . '","' . $mass['zonb2'] . '","' . $mass['type'] . '")' - ); - } - $ins = mysql_query( - 'INSERT INTO `battle_logs` (`time`,`battle`,`id_hod`,`text`,`vars`,`zona1`,`zonb1`,`zona2`,`zonb2`,`type`) VALUES ("' . $mass['time'] . '","' . $mass['battle'] . '","' . $mass['id_hod'] . '","' . $vtvl . '","' . $mass['vars'] . '","' . $mass['zona1'] . '","' . $mass['zonb1'] . '","' . $mass['zona2'] . '","' . $mass['zonb2'] . '","' . $mass['type'] . '")' - ); - } - - //Турнир БС - if ($this->info['inTurnir'] > 0 && $this->info['dungeon'] != 15 && $u->info['room'] != 413) { - $bs = mysql_fetch_array( - mysql_query('SELECT * FROM `bs_turnirs` WHERE `id` = "' . $this->info['inTurnir'] . '" LIMIT 1') - ); - $i = 0; - $j = 0; - while ($i < count($this->users)) { - if ($this->stats[$i]['hpNow'] < 1 && $this->users[$i]['clone'] == 0 && $this->stats[$i]['clone'] == 0) { - //Добавляем в лог БС - if ($this->users[$i]['sex'] == 0) { - $text .= '{u1} повержен и выбывает из турнира'; - } else { - $text .= '{u1} повержена и выбывает из турнира'; - } - //Выкидываем предметы с персонажа - $spik = mysql_query( - 'SELECT `id`,`item_id` FROM `items_users` WHERE `uid` = "' . $this->users[$i]['id'] . '" AND `delete` ="0"' - ); - while ($plik = mysql_fetch_array($spik)) { - - mysql_query( - 'INSERT INTO `dungeon_items` (`dn`,`item_id`,`time`,`x`,`y`) VALUES ( - "' . $this->users[$i]['dnow'] . '","' . $plik['item_id'] . '","' . (time() - 600) . '","' . $this->users[$i]['x'] . '","' . $this->users[$i]['y'] . '" - )' - ); - } - unset($spik, $plik); - // - $usrreal = ''; - $usr_real = mysql_fetch_array( - mysql_query( - 'SELECT `id`,`login`,`align`,`clan`,`battle`,`level` FROM `users` WHERE `login` = "' . $this->users[$i]['login'] . '" AND `inUser` = "' . $this->users[$i]['id'] . '" LIMIT 1' - ) - ); - if (!isset($usr_real['id'])) { - $usr_real = $this->users[$i]; - } - if (isset($usr_real['id'])) { - if ($usr_real['align'] > 0) { - $usrreal .= ''; - } - if ($usr_real['clan'] > 0) { - $usrreal .= ''; - } - $usrreal .= '' . $usr_real['login'] . '[' . $usr_real['level'] . ']'; - } else { - $mereal = 'Невидимка[??]'; - } - $text = str_replace('{u1}', $usrreal, $text); - mysql_query( - 'INSERT INTO `bs_logs` (`type`,`text`,`time`,`id_bs`,`count_bs`,`city`,`m`,`u`) VALUES ( - "1", "' . mysql_real_escape_string($text) . '", "' . time() . '", "' . $bs['id'] . '", "' . $bs['count'] . '", "' . $bs['city'] . '", - "' . round($bs['money'] * 0.85, 2) . '","' . $i . '" - )' - ); - // - //Удаление клона - mysql_query('DELETE FROM `users` WHERE `id` = "' . $this->users[$i]['id'] . '" LIMIT 1'); - mysql_query('DELETE FROM `stats` WHERE `id` = "' . $this->users[$i]['id'] . '" LIMIT 1'); - mysql_query('DELETE FROM `actions` WHERE `uid` = "' . $this->users[$i]['id'] . '"'); - mysql_query('DELETE FROM `items_users` WHERE `uid` = "' . $this->users[$i]['id'] . '"'); - mysql_query('DELETE FROM `eff_users` WHERE `uid` = "' . $this->users[$i]['id'] . '"'); - mysql_query('DELETE FROM `users_delo` WHERE `uid` = "' . $this->users[$i]['id'] . '"'); - //Обновление персонажа - mysql_query( - 'UPDATE `users` SET `inUser` = "0" WHERE `login` = "' . $this->users[$i]['login'] . '" OR `inUser` = "' . $this->users[$i]['id'] . '" LIMIT 1' - ); - //Обновляем заявку - mysql_query( - 'UPDATE `bs_zv` SET `off` = "' . time() . '" WHERE `inBot` = "' . $this->users[$i]['id'] . '" AND `off` = "0" LIMIT 1' - ); - unset($text, $usrreal, $usr_real); - if ($this->users[$i]['pass'] != 'bstowerbot') { - $bs['users']--; - $bs['users_finish']++; - } else { - $bs['arhiv']--; - } - $j++; - } - $i++; - } - if ($j > 0) { - mysql_query( - 'UPDATE `bs_turnirs` SET `arhiv` = "' . $bs['arhiv'] . '",`users` = "' . $bs['users'] . '",`users_finish` = "' . $bs['users_finish'] . '" WHERE `id` = "' . $bs['id'] . '" LIMIT 1' - ); - } - - unset($bs, $j); - } - - //Награда за события - if ($this->info['type'] == 500 && isset($tststrt['id'])) { - //Предметы которые выпадают в центр - - $i = 0; - while ($i < count($this->users)) { - $cmsg = new ChatMessage(); - $cmsg->setType(6); - $cmsg->setIsAlert(true); - if ($this->users[$i]['no_ip'] == 'trupojor') { - $mon = mysql_fetch_array( - mysql_query( - 'SELECT * FROM `aaa_monsters` WHERE `uid` = "' . $this->users[$i]['id'] . '" LIMIT 1' - ) - ); - if (isset($mon['id'])) { - if ($this->info['team_win'] == 0) { - //Ничья - mysql_query( - 'UPDATE `stats` SET `hpNow` = "' . $this->stats[$i]['hpAll'] . '",`mpNow` = "' . $this->stats[$i]['mpAll'] . '" WHERE `id` = "' . $this->users[$i]['id'] . '" LIMIT 1' - ); - $cmsg->setText( - str_replace( - '{b}', - '' . $this->users[$i]['login'] . ' [' . $this->users[$i]['level'] . ']users[$i]['id'] . ' >', - $mon['nich_text'] - ) - ); - $chat->sendMsg($cmsg); - } elseif ($this->info['team_win'] != $this->users[$i]['team']) { - //Выиграли - $j = 0; - $usrwin = ''; - while ($j < count($this->users)) { - if ($this->users[$j]['no_ip'] != 'trupojor' && $this->users[$j]['bot'] == 0) { - if ($this->stats[$j]['hpNow'] > 0) { - $usrwin .= ', '; - if ($this->users[$j]['align'] > 0) { - $usrwin .= 'users[$j]['align'] . '.gif >'; - } - if ($this->users[$j]['clan'] > 0) { - $usrwin .= 'users[$j]['clan'] . '.gif >'; - } - $usrwin .= '' . $this->users[$j]['login'] . ' [' . $this->users[$j]['level'] . ']users[$j]['id'] . ' >'; - } - } - $j++; - } - if ($usrwin != '') { - $usrwin = ltrim($usrwin, ', '); - } else { - $usrwin = 'Команда героев'; - } - - mysql_query( - 'UPDATE `users` SET `room` = "303" WHERE `id` = "' . $this->users[$i]['id'] . '" LIMIT 1' - ); - - $truptimelast = time() + rand(1800, 3600); - - mysql_query( - 'UPDATE `stats` SET `res_x` = "' . $truptimelast . '" WHERE `id` = "' . $this->users[$i]['id'] . '" LIMIT 1' - ); - $cmsg->setText( - str_replace( - '{b}', - '' . $this->users[$i]['login'] . ' [' . $this->users[$i]['level'] . ']users[$i]['id'] . ' >', - str_replace('{u}', $usrwin, $mon['win_text']) - ) - ); - $chat->sendMsg($cmsg); - unset($usrwin); - } else { - //Проиграли - if ($mon['win_back'] == 1) { - mysql_query( - 'UPDATE `users` SET `room` = "303" WHERE `id` = "' . $this->users[$i]['id'] . '" LIMIT 1' - ); - } - mysql_query( - 'UPDATE `stats` SET `hpNow` = "' . $this->stats[$i]['hpAll'] . '",`mpNow` = "' . $this->stats[$i]['mpAll'] . '" WHERE `id` = "' . $this->users[$i]['id'] . '" LIMIT 1' - ); - $cmsg->setText( - str_replace( - '{b}', - '' . $this->users[$i]['login'] . ' [' . $this->users[$i]['level'] . ']users[$i]['id'] . ' >', - $mon['lose_text'] - ) - ); - $chat->sendMsg($cmsg); - } - } - } - $i++; - } - } - } - - // выкидываем ботов из боя - $i = 0; - $botsi = 0; - if (isset($tststrt['id'])) { - while ($i < count($this->users)) { - //Тут выкидываем юзеров из Призавого хаота - if ($this->info['type'] == 33) { - $plde = mysql_fetch_array( - mysql_query('SELECT * FROM `users` WHERE `id` = "' . $this->users[$i]['id'] . '" LIMIT 1') - ); - if (isset($plde['mail']) && $plde['mail'] == "haot@new-combats.com") { - $pld = mysql_fetch_array( - mysql_query( - 'SELECT * FROM `users` WHERE `inUser` = "' . $this->users[$i]['id'] . '" LIMIT 1' - ) - ); - - if (isset($pld['id'])) { - if ($this->users[$i]['battle_yron'] >= 500) { - mysql_query( - 'UPDATE `users_achiv` SET `pg`= `pg`+1 WHERE `id` = "' . $pld['id'] . '" LIMIT 1' - ); - - if ($this->users[$i]['team'] == $this->info['team_win'] && rand(1, 100) <= 5) { - ItemsModel::addItem(10020, $pld['id'], ''); - $pld['battle_text'] .= ' За Героическое Сражение вы получаете Жетон Успеха. '; - } - } else { - $pld['battle_text'] .= ' Вы ничего не получили. Нужно набить больше 500 урона урона .'; - } - $cmsg = new ChatMessage(); - $cmsg->setRoom($pld['room']); - $cmsg->setTo($pld['login']); - $cmsg->setText($pld['battle_text']); - $cmsg->setType(6); - $chat->sendMsg($cmsg); - - mysql_query( - 'DELETE FROM `stats` WHERE `id` = "' . $this->users[$i]['id'] . '" LIMIT 1' - ); - mysql_query( - 'DELETE FROM `items_users` WHERE `uid` = "' . $this->users[$i]['id'] . '" LIMIT 100' - ); - mysql_query( - 'DELETE FROM `eff_users` WHERE `uid` = "' . $this->users[$i]['id'] . '" LIMIT 100' - ); - mysql_query( - 'UPDATE `users` SET `inUser` = "0" WHERE `inUser` = "' . $this->users[$i]['id'] . '" LIMIT 1' - ); - mysql_query( - 'DELETE FROM `users` WHERE `id` = "' . $this->users[$i]['id'] . '" LIMIT 1' - ); - } - } - - unset ($plde, $pld); - } - - if ($this->users[$i]['bot'] == 1) { - $botsi++; - mysql_query('DELETE FROM `users` WHERE `id` = "' . $this->users[$i]['id'] . '" LIMIT 1'); - mysql_query('DELETE FROM `stats` WHERE `id` = "' . $this->users[$i]['id'] . '" LIMIT 1'); - mysql_query( - 'DELETE FROM `items_users` WHERE `uid` = "' . $this->users[$i]['id'] . '" LIMIT 100' - ); - mysql_query('DELETE FROM `eff_users` WHERE `uid` = "' . $this->users[$i]['id'] . '" LIMIT 100'); - } elseif ($this->users[$i]['bot'] == 2) { - $this->users[$i]['battle'] = 0; - mysql_query( - 'UPDATE `users` SET `battle` = "0" WHERE `id` = "' . $this->users[$i]['id'] . '" LIMIT 1' - ); - mysql_query( - 'UPDATE `stats` SET `zv` = "0",`team` = "0",`exp` = `exp` + `battle_exp`,`battle_exp` = "0",`battle_yron` = "0",`enemy` = "0", `timeGo` = "' . time( - ) . '" WHERE `id` = "' . $this->users[$i]['id'] . '" LIMIT 1' - ); - mysql_query('DELETE FROM `eff_users` WHERE `uid` = "' . $this->users[$i]['id'] . '" LIMIT 100'); - } elseif ($this->users[$i]['bot'] > 0) { - $this->users[$i]['battle'] = 0; - mysql_query( - 'UPDATE `users` SET `battle` = "0" WHERE `id` = "' . $this->users[$i]['id'] . '" LIMIT 1' - ); - mysql_query( - 'UPDATE `stats` SET `zv` = "0",`team` = "0",`exp` = `exp` + `battle_exp`,`battle_exp` = "0",`battle_yron` = "0",`enemy` = "0", `timeGo` = "' . time( - ) . '" WHERE `id` = "' . $this->users[$i]['id'] . '" LIMIT 1' - ); - mysql_query('DELETE FROM `eff_users` WHERE `uid` = "' . $this->users[$i]['id'] . '" LIMIT 100'); - } - if ($this->users[$i]['clone'] > 0 && $this->users[$i]['bot'] > 0 && isset($this->users[$this->uids[$this->users[$i]['clone']]]['id']) && $this->users[$this->uids[$this->users[$i]['clone']]]['team'] != $this->users[$i]['team']) { - //Добавляем что клон побежден - if ($this->users[$this->uids[$this->users[$i]['clone']]]['team'] == $this->info['team_win']) { - $u->addAction(time(), 'win_bot_clone', '', $this->users[$i]['clone']); - } elseif ($this->info['team_win'] == 0) { - $u->addAction(time(), 'nich_bot_clone', '', $this->users[$i]['clone']); - } else { - $u->addAction(time(), 'lose_bot_clone', '', $this->users[$i]['clone']); - } - } elseif ($this->users[$i]['bot'] > 0 && $this->users[$i]['bot_id'] > 0) { - //Добавляем что бота победили - $j = 0; - while ($j < count($this->users)) { - if ($this->users[$j]['bot'] == 0 && $this->users[$j]['team'] != $this->users[$i]['team']) { - if ($this->users[$j]['team'] == $this->info['team_win']) { // if($this->users[$j]['team']==$this->info['team_win']){ - $u->addAction( - time(), 'win_bot_' . $this->users[$i]['bot_id'], '', - $this->users[$j]['id'] - ); - // - mysql_query( - 'UPDATE `dialog_act` SET `now` = `now` + 1 WHERE `uid` = "' . $this->users[$j]['id'] . '" AND - ( `btl_bot` LIKE "' . $this->users[$i]['bot_id'] . '!%" OR `btl_bot` LIKE "%!' . $this->users[$i]['bot_id'] . '!%" ) - AND `val` != 1 - LIMIT 1' - ); - // - } elseif ($this->info['team_win'] == 0) { - $u->addAction( - time(), 'nich_bot_' . $this->users[$i]['bot_id'], '', - $this->users[$j]['id'] - ); - } else { - $u->addAction( - time(), 'lose_bot_' . $this->users[$i]['bot_id'], '', - $this->users[$j]['id'] - ); - } - } - $j++; - } - } - $i++; - } - } - - $botss = []; - - //Из бота падают предметы - if ($nl != 10 && $this->info['dungeon'] > 0) { - if ($this->info['team_win'] == $u->info['team'] && $this->info['dungeon'] == 102) { - $j1 = mysql_fetch_array( - mysql_query( - 'SELECT * FROM `laba_obj` WHERE `type` = 2 AND `lib` = "' . $this->info['dn_id'] . '" AND `x` = "' . $this->info['x'] . '" AND `y` = "' . $this->info['y'] . '" LIMIT 1' - ) - ); - if (isset($j1['id'])) { - mysql_query('DELETE FROM `laba_obj` WHERE `id` = "' . $j1['id'] . '" LIMIT 1'); - //Выпадает шмотка - mysql_query( - 'INSERT INTO `laba_obj` (`use`,`lib`,`time`,`type`,`x`,`y`,`vars`) VALUES ( - "0","' . $j1['lib'] . '","' . time() . '","6","' . $j1['x'] . '","' . $j1['y'] . '","' . (0 + $botsi) . '" - )' - ); - } - } elseif ($this->info['team_win'] == $u->info['team']) { - //выйграли люди, выкидываем предметы из мобов - $j1 = mysql_query( - 'SELECT * FROM `dungeon_bots` WHERE `dn` = "' . $this->info['dn_id'] . '" AND `for_dn` = "0" AND `x` = "' . $this->info['x'] . '" AND `delete` = "0" AND `y`= "' . $this->info['y'] . '" LIMIT 100' - ); - while ($tbot = mysql_fetch_array($j1)) { - $cmsg = new ChatMessage(); - $cmsg->setDn($this->info['dn_id']); - $cmsg->setRoom($this->users[0]['room']); - $cmsg->setType(6); - $cmsg->setTypeTime(1); - - $j2 = 0; - while ($j2 < $tbot['colvo']) { - if (isset($tbot['id2'])) { - $tbot2 = mysql_fetch_array( - mysql_query( - 'SELECT * FROM `test_bot` WHERE `id` = "' . $tbot['id_bot'] . '" LIMIT 1' - ) - ); - $itms = explode('|', $tbot2['p_items']); - $tii = 0; - $testdrop = 0; - while ($tii < count($itms) && $testdrop == 0) { - $itmz = explode('=', $itms[$tii]); - if ($itmz[0] > 0) { - if (isset($itmz[2]) && $itmz[2] != '') { // $itmz[2] == quest888 - $questDrop = mysql_fetch_array( - mysql_query( - 'SELECT * FROM `actions` WHERE `vars` LIKE "%' . $itmz[2] . '%" AND `vals` = "go" AND `uid` = "' . $u->info['id'] . '" LIMIT 1' - ) - ); - } - if (!isset($questDrop['id']) && isset($itmz[2]) && $itmz[2] != '') { - $itmz[1] = 0; - } // Если предмет квестовый, а квеста у игрока нет, то предмет выпадет с вероятностью 0 - unset($questDrop); - - //Добавляем этот предмет в зону Х и У - if ($itmz[1] * 100000 >= rand(1, 10000000)) { - $tou = 0; //какому юзеру предназначено - /* выделяем случайного юзера из команды */ - $itmnm = mysql_fetch_array( - mysql_query( - 'SELECT `name` FROM `items_main` WHERE `id` = "' . $itmz[0] . '" LIMIT 1' - ) - ); - $itmnm = $itmnm['name']; - - $cmsg->setText( - 'У ' . $tbot2['login'] . ' был предмет "' . $itmnm . '" и кто угодно может поднять его' - ); - $chat->sendMsg($cmsg); - - $ins = mysql_query( - 'INSERT INTO `dungeon_items` (`dn`,`user`,`item_id`,`time`,`x`,`y`) VALUES ( - "' . $this->info['dn_id'] . '", - "' . $tou . '", - "' . $itmz[0] . '", - "' . time() . '", - "' . $this->info['x'] . '", - "' . $this->info['y'] . '")' - ); - if (!isset($questDrop['id'])) { - $testdrop = 1; //ТУТ drop-drop //quest - } - } - } - $tii++; - } - } - $j2++; - } - // - //Квест 1-15 сентября, - if ( - date('m') == 9 && - date('d') < 15 && - !$this->getChanse(99) && - ($this->info['dungeon'] == 12 || $this->info['dungeon'] == 101) - ) { - $tou = 0; //какому юзеру предназначено - /* выделяем случайного юзера из команды */ - $itmz = [ - rand(4745, 4751), - 100, - ]; - // - $itmnm = mysql_fetch_array( - mysql_query( - 'SELECT `name` FROM `items_main` WHERE `id` = "' . $itmz[0] . '" LIMIT 1' - ) - ); - $itmnm = $itmnm['name']; - - $cmsg->setText( - 'У ' . $tbot2['login'] . ' был предмет "' . $itmnm . '" и кто угодно может поднять его' - ); - $chat->sendMsg($cmsg); - - $ins = mysql_query( - 'INSERT INTO `dungeon_items` (`dn`,`user`,`item_id`,`time`,`x`,`y`) VALUES ( - "' . $this->info['dn_id'] . '", - "' . $tou . '", - "' . $itmz[0] . '", - "' . time() . '", - "' . $this->info['x'] . '", - "' . $this->info['y'] . '")' - ); - } - // - //Странички саныча, - - if (rand(1, 100) <= 99) { - } elseif ($this->info['dungeon'] == 12 || $this->info['dungeon'] == 3 || - $this->info['dungeon'] == 101 || $this->info['dungeon'] == 16 || - $this->info['dungeon'] == 9 || $this->info['dungeon'] == 10 || - $this->info['dungeon'] == 13 || $this->info['dungeon'] == 106) { - $tou = 0; //какому юзеру предназначено - // выделяем случайного юзера из команды - $itmz = mt_rand(3143, 3192); - // - $itmnm = mysql_fetch_array( - mysql_query('SELECT `name` FROM `items_main` WHERE `id` = "' . $itmz . '" LIMIT 1') - ); - $itmnm = $itmnm['name']; - - $cmsg->setText( - 'У ' . $tbot2['login'] . ' был предмет "' . $itmnm . '" и кто угодно может поднять его' - ); - $chat->sendMsg($cmsg); - - $ins = mysql_query( - 'INSERT INTO `dungeon_items` (`dn`,`user`,`item_id`,`time`,`x`,`y`) VALUES ( - "' . $this->info['dn_id'] . '", - "' . $tou . '", - "' . $itmz . '", - "' . time() . '", - "' . $this->info['x'] . '", - "' . $this->info['y'] . '")' - ); - } - } - mysql_query( - 'UPDATE `dungeon_bots` SET `delete` = "' . time( - ) . '" AND `inBattle` = "' . $this->info['id'] . '" WHERE `dn` = "' . $this->info['dn_id'] . '" AND `for_dn` = "0" AND `delete` = "0" ' - ); - } else { - //выкидываем всех игроков в клетку RESTART - $dnr = 1; - if ($this->info['dungeon'] != 102) { - mysql_query( - 'UPDATE `dungeon_bots` SET `inBattle` = "0" WHERE `dn` = "' . $this->info['dn_id'] . '" AND `for_dn` = "0" AND `x` = "' . $this->info['x'] . '" AND `y`= "' . $this->info['y'] . '"' - ); - } - } - } - - $gm = []; - $gms = []; - $bm = []; - $bms = []; - - //Квестовый раздел - //Квестовый раздел - - //завершаем поединок - $i = $this->uids[$u->info['id']]; - - if ($this->info['team_win'] >= 0) { - $cmsg = new ChatMessage(); - $cmsg->setRoom($this->users[$i]['room']); - $cmsg->setType(6); - - if ($this->stats[$i]['pbe'] > 0) { - //Бонус покупателя - $this->expCoef += $this->stats[$i]['pbe']; - } - - if ($this->info['razdel'] == 5 && (Config::get('m') >= 6 && Config::get('m') <= 8 || Config::get('w') == 0 || Config::get('w') == 6)) { - $this->expCoef += 5; - } - - $this->stats[$i]['exp'] += $this->expCoef; - - $this->stats[$i]['exp'] += $this->aBexp * Config::get('exp'); - - if ($this->stats[$i]['os4'] > 0) { - $this->stats[$i]['exp'] += $this->stats[$i]['os4']; - } - - - $act01 = 0; - $this->users[$i]['battle_exp'] = round( - $this->users[$i]['battle_exp'] + ($this->users[$i]['battle_exp'] / 100 * (1 + $this->info['addExp'] + $this->stats[$i]['exp'])) - ); - - if ($this->info['type'] == 564) { - //Бой с копией - $this->users[$i]['battle_exp'] = 0; - } - - if ($this->info['dungeon'] == 104) { - $this->users[$i]['battle_exp'] = ($u->info['level'] * 2) * (count($this->uids) - 1); - } elseif ($this->info['dungeon'] > 0 && $this->users[$i]['dnow'] != 0 && $this->info['dungeon'] != 1 && $this->users[$i]['team'] == $this->info['team_win']) { - $dun_limitForLevel = [ - 4 => 750, - 5 => 1500, - 6 => 3500, - 7 => 8000, - 8 => 25000, - 9 => 50000, - 10 => 75000, - 11 => 100000, - 12 => 100000, - 13 => 100000, - 14 => 100000, - ]; - // Максимум для каждого уровня. - - if ($this->users[$i]['battle_exp'] > 0) { - $dun_exp = []; // Текущий лимит опыта игрока в подземельях. - $rep = mysql_fetch_array( - mysql_query( - 'SELECT `dungeonexp`,`id` FROM `rep` WHERE `id` = "' . $this->users[$i]['id'] . '" LIMIT 1' - ) - ); - $rep = explode(',', $rep['dungeonexp']); - foreach ($rep as $key => $val) { - $val = explode('=', $val); // текущий лимит опыта в подземке - if (isset($val[0]) && isset($val[1]) && $val[0] != '' && $val[1] != 0) { - $dun_exp[(int)$val[0]] = (int)$val[1]; - } - } - unset($rep); - } - - if (!isset($dun_exp[$this->info['dungeon']])) { - $dun_exp[$this->info['dungeon']] = 0; - } - - if (!isset($dun_limitForLevel[(int)$this->users[$i]['level']])) { // Если лимит не задан, опыт не даем. - $this->users[$i]['battle_exp'] = 0; - } elseif ( - isset($dun_exp[$this->info['dungeon']]) && - $dun_exp[$this->info['dungeon']] >= $dun_limitForLevel[(int)$this->users[$i]['level']] - ) { // Если лимит уже достигнут, опыт не даем. - $this->users[$i]['battle_exp'] = 0; - } elseif ( - isset($dun_exp[$this->info['dungeon']]) && - $dun_limitForLevel[(int)$this->users[$i]['level']] > $dun_exp[$this->info['dungeon']] - ) { // Если текущая репутация не достигла лимита. - if (($dun_exp[$this->info['dungeon']] + $this->users[$i]['battle_exp']) > $dun_limitForLevel[(int)$this->users[$i]['level']]) { - // Если опыта набрано достаточно, для достижения лимита. - $this->users[$i]['battle_exp'] = abs( - $this->users[$i]['battle_exp'] - abs( - $dun_limitForLevel[(int)$this->users[$i]['level']] - ($this->users[$i]['battle_exp'] + $dun_exp[$this->info['dungeon']]) - ) - ); - $dun_exp[$this->info['dungeon']] += $this->users[$i]['battle_exp']; - } elseif ($dun_limitForLevel[(int)$this->users[$i]['level']] > ($dun_exp[$this->info['dungeon']] + $this->users[$i]['battle_exp'])) { - // Если опыта недостаточно, для достижения лимита. - $dun_exp[$this->info['dungeon']] += $this->users[$i]['battle_exp']; - } else { - $this->users[$i]['battle_exp'] = 0; - } - } else { // В любой непонятной ситуцаии. - $this->users[$i]['battle_exp'] = 0; - } - - - if ($this->users[$i]['battle_exp'] > 0 && isset($dun_exp[$this->info['dungeon']]) && $dun_exp[$this->info['dungeon']] > 0) { - $dunexp = []; - foreach ($dun_exp as $key => $val) { - $dunexp[$key] = $key . '=' . $val; // текущий лимит опыта в подземке - } - $dun_exp = implode(",", $dunexp); - mysql_query( - 'UPDATE `rep` SET `dungeonexp` = "' . $dun_exp . '" WHERE `id` = "' . $this->users[$i]['id'] . '" LIMIT 1' - ); - unset($dunexp, $dun_exp); - } - unset($dun_limitForLevel); - } - - $sinf = ''; - if (Config::get('exp_mega')) { - $this->users[$i]['battle_exp'] += floor( - $this->users[$i]['battle_exp'] / 100 * Config::get('exp_mega_val')[$this->users[$i]['level']] - ); - } - - if ($this->info['team_win'] == 0 && $this->info['type'] != 564) { - if ($this->users[$i]['level'] <= 1) { - $this->users[$i]['battle_exp'] = floor($this->users[$i]['battle_exp'] * 0.50); - } else { - $this->users[$i]['battle_exp'] = ceil($this->users[$i]['battle_exp'] * 0.10); - } - $this->users[$i]['nich'] += 1; - } elseif ($this->users[$i]['team'] == $this->info['team_win'] && $this->info['type'] != 564) { - $gm[$i] = $this->info['money']; - $gms[$i] = $this->info['money3']; - $this->users[$i]['win'] += 1; - $act01 = 1; - } elseif ($this->info['type'] != 564) { - if ($this->users[$i]['level'] <= 1) { - $this->users[$i]['battle_exp'] = ceil($this->users[$i]['battle_exp'] * 0.33); - } else { - $this->users[$i]['battle_exp'] = ceil($this->users[$i]['battle_exp'] * 0.10); - } - $bm[$i] = $this->info['money']; - $bms[$i] = $this->info['money3']; - $this->users[$i]['lose'] += 1; - $act01 = 2; - } - //Рассчитываем кол-во выигрышных сумм и кто сколько получил (для екр.) - if ($this->info['money3'] > 0 && isset($gms[$i]) && $this->info['type'] != 564) { - $mn = [ - 'l' => 0, //сколько проигравших игроков - 'w' => 0, //сколько выигрывших игроков - 'm' => 0, //сумма выигрыша (общая) - ]; - if ($act01 == 1) { - $mn['l'] = mysql_fetch_array( - mysql_query( - 'SELECT COUNT(`id`) FROM `battle_users` WHERE `battle` = "' . $this->info['id'] . '" AND `team` != "' . $this->users[$i]['team'] . '" LIMIT 1' - ) - ); - $mn['l'] = $mn['l'][0]; - $mn['w'] = mysql_fetch_array( - mysql_query( - 'SELECT COUNT(`id`) FROM `battle_users` WHERE `battle` = "' . $this->info['id'] . '" AND `team` = "' . $this->users[$i]['team'] . '" LIMIT 1' - ) - ); - $mn['w'] = $mn['w'][0]; - $mn['m'] = round(($mn['l'] * $this->info['money3']) / 100 * 87, 2); - $gms[$i] = round(($mn['m'] / $mn['w']), 2); - } - } - //заносим данные в БД - //Поломка предметов - if ($act01 == 1) { - //победа - if ($this->users[$i]['dnow'] == 0 && $this->users[$i]['hpNow'] < 1) { - $lom = 0.05; - } - } elseif ($act01 == 2) { - //поражение - $lom = 0.55; - } else { - //ничья - $lom = 0.05; - } - $nlom = [0 => rand(0, 18), 1 => rand(0, 18), 2 => rand(0, 18), 3 => rand(0, 18)]; - if ($this->info['type'] == 564) { - $lom = 0; - } - if ($this->stats[$i]['silver'] >= 4) { - $lom = 0; - } - mysql_query( - 'UPDATE `items_users` SET `iznosNOW` = `iznosNOW`+' . $lom . ' WHERE `inOdet` < "18" AND `inOdet` > "0" AND `uid` = "' . $this->users[$i]['id'] . '" AND `inOdet`!="0" AND `inOdet`!=' . $nlom[0] . ' AND `inOdet`!=' . $nlom[1] . ' AND `inOdet`!=' . $nlom[2] . ' AND `inOdet`!=' . $nlom[3] . ' LIMIT 18' - ); - - $prc = ''; - if ($this->users[$i]['align'] == 2) { - $this->users[$i]['battle_exp'] = floor($this->users[$i]['battle_exp'] / 2); - } - if ($this->users[$i]['animal'] > 0) { - $ulan = $u->testAction( - '`uid` = "' . $this->users[$i]['id'] . '" AND `vars` = "animal_use' . $this->info['id'] . '" LIMIT 1', - 1 - ); - if (isset($ulan['id']) && $this->users[$i]['team'] == $this->info['team_win'] && $this->users[$i]['level'] > $ulan['vals']) { - $a004 = mysql_fetch_array( - mysql_query( - 'SELECT `max_exp`,`name` FROM `users_animal` WHERE `uid` = "' . $this->users[$i]['id'] . '" AND `id` = "' . $this->users[$i]['animal'] . '" AND `pet_in_cage` = "0" AND `delete` = "0" LIMIT 1' - ) - ); - //33% от опыта переходит зверю, но не более максимума - $aexp = (round($this->users[$i]['battle_exp'] / 100 * 33)); - if ($aexp > $a004['max_exp']) { - $aexp = $a004['max_exp']; - } - unset($ulan); - // - $cmsg->setTo($this->users[$i]['login']); - $cmsg->setText("Ваш питомец «{$a004['name']}» получил опыт: $aexp"); - $chat->sendMsg($cmsg); - // - $upd = mysql_query( - 'UPDATE `users_animal` SET `exp` = `exp` + ' . $aexp . ' WHERE `id` = "' . $this->users[$i]['animal'] . '" AND `level` < ' . $this->users[$i]['level'] . ' LIMIT 1' - ); - if ($upd) { - $this->users[$i]['battle_exp'] = round($this->users[$i]['battle_exp'] / 100 * 67); - $this->info['addExp'] -= 33.333; - } - } - } - - $prsusers = mysql_fetch_array( - mysql_query( - 'SELECT SUM(`price1`) FROM `battle_users` WHERE `battle` = "' . $this->info['id'] . '" LIMIT 1' - ) - ); - - $btlstatus = $this->typeBattle($prsusers[0]); - if ($this->info['smert'] == 1) { - $btlstatus = [150, 150, 'Жесточайшее Сражение', 'Жесточайшее Сражение']; - } - // - if ($this->stats[$i]['clanpos'] > 0 && ($this->stats[$i]['clanpos'] == 1 || $this->stats[$i]['clanpos'] == 2 || $this->stats[$i]['clanpos'] == 3)) { - $this->info['addExp'] += 0; - } - - unset($r1); - //Статусная битва - if ($btlstatus[0] > 0) { - if ($this->info['type'] == 99) { - $this->info['addExp'] += $btlstatus[1]; - } else { - $this->info['addExp'] += $btlstatus[0]; - } - } - - if ($this->users[$i]['align'] == 2 || $this->users[$i]['haos'] > time()) { - $this->stats[$i]['exp'] = -($this->info['addExp'] + 50); - } - if ($this->info['addExp'] + $this->stats[$i]['exp'] != 0) { - $prc = ' (' . (100 + $this->info['addExp'] + $this->stats[$i]['exp']) . '%)'; - } - if ($this->info['money'] > 0) { - if (isset($gm[$i])) { - $prc .= ' Вы выйграли ' . $gm[$i] . ' кр. за этот бой.'; - Delo::add( - 4, - 'System.battle', - $this->users[$i]['id'], - '"System.battle": Персонаж выйграл ' . $gm[$i] . ' кр. (В бою №' . $this->info['id'] . ').', - ); - $this->users[$i]['money'] += $gm[$i]; - } elseif (isset($bm[$i])) { - $prc .= ' Вы заплатили ' . $bm[$i] . ' кр. за этот бой.'; - Delo::add( - 4, - 'System.battle', - $this->users[$i]['id'], - '"System.battle": Персонаж проиграл ' . $gm[$i] . ' кр. (В бою №' . $this->info['id'] . ').', - ); - $this->users[$i]['money'] -= $bm[$i]; - } - } - if (Config::get('money_haot') && $this->users[$i]['exp'] <= 200000000) { - if ($act01 == 1 && $this->info['razdel'] == 5 && $this->users[$i]['level'] >= 8) { - //Сколько нужно опыта набить - $trexp = [ - 8 => 1200, - 9 => 3000, - 10 => 4500, - 11 => 12000, - 12 => 20000, - 13 => 30000, - 14 => 30000, - 15 => 30000, - 16 => 30000, - 17 => 30000, - 18 => 30000, - 19 => 30000, - 20 => 30000, - 21 => 30000, - ]; - $trexp = $trexp[$this->users[$i]['level']]; - - //Какая цена фулла должна быть - $trmn = [ - 8 => 1000, - 9 => 3000, - 10 => 2500, - 11 => 3000, - 12 => 3000, - 13 => 3000, - 14 => 3000, - 15 => 3000, - 16 => 3000, - 17 => 3000, - 18 => 3000, - 19 => 3000, - 20 => 3000, - 21 => 3000, - ]; - $trmn = $trmn[$this->users[$i]['level']]; - - //Сколько екр дается - $admn = [ - 8 => 0.05, //0.05 - 9 => 0.065, //0.065 - 10 => 0.075, //0.075 - 11 => 0.085, //0.085 - 12 => 0.1, //0.1 - 13 => 0.1, - 14 => 0.1, - 15 => 0.1, - 16 => 0.1, - 17 => 0.1, - 18 => 0.1, - 19 => 0.1, - 20 => 0.1, - 21 => 0.1, - ]; - $admn = $admn[$this->users[$i]['level']]; - - if (Config::get('m') >= 6 && Config::get('m') <= 8) { - //Летний период - if (Config::get('w') == 0 || Config::get('w') == 5 || Config::get('w') == 6) { - //Выходные дни - $admn = $admn * 2; - } - } elseif (Config::get('w') == 0 || Config::get('w') == 5 || Config::get('w') == 6) { - //Выходные дни - $admn = $admn * 2; - } - if ($this->users[$i]['battle_exp'] < $trexp) { - $prc .= ', Награда 0 ЕКР за этот бой (Мало опыта набили).'; - } elseif ($admn > 0) { - if ($this->info['type'] != 33) { - $prc .= ', Награда ' . $admn . ' ЕКР за этот бой.'; - } - Delo::add( - 4, - 'System.battle', - $this->users[$i]['id'], - '"System.battle": Персонаж получил ' . $admn . ' ЕКР (В бою №' . $this->info['id'] . ').', - ); - $this->users[$i]['money2'] += $admn; - } - } - } - if ($this->info['money3'] > 0) { - if (isset($gms[$i])) { - $prc .= ' Вы выйграли ' . $gms[$i] . ' $. за этот бой.'; - Delo::add( - 4, - 'System.battle', - $this->users[$i]['id'], - '"System.battle": Персонаж выйграл ' . $gms[$i] . ' $. (В бою №' . $this->info['id'] . ').', - ); - $this->users[$i]['money3'] += $gms[$i]; - mysql_query( - 'UPDATE `users` SET `money3` = `money3` + "' . $gms[$i] . '" WHERE `id` = "' . $this->users[$i]['id'] . '" LIMIT 1' - ); - } elseif (isset($bms[$i])) { - $prc .= ' Вы заплатили ' . $bms[$i] . ' $. за этот бой.'; - Delo::add( - 4, - 'System.battle', - $this->users[$i]['id'], - '"System.battle": Персонаж проиграл ' . $gms[$i] . ' $. (В бою №' . $this->info['id'] . ').', - ); - $this->users[$i]['money3'] -= $bms[$i]; - mysql_query( - 'UPDATE `users` SET `money3` = `money3` - "' . $bms[$i] . '" WHERE `id` = "' . $this->users[$i]['id'] . '" LIMIT 1' - ); - } - } - - $lime = [ - 8 => 18000, - 9 => 28000, - 10 => 84000, - 11 => 100, - 12 => 100, - 13 => 100, - 14 => 100, - 15 => 100, - 16 => 100, - 17 => 100, - 18 => 100, - 19 => 100, - 20 => 100, - 21 => 100, - ]; - - if ($this->users[$i]['level'] < 8) { - $lime = 5400; - } else { - $lime = $lime[$this->users[$i]['level']]; - } - - if ($this->stats[$i]['silver'] >= 5) { - $lime += round($lime); - } - - if ($this->users[$i]['stopexp'] == 1) { - $lime = 0; - $this->users[$i]['battle_exp'] = 0; - } - - if ($lime < $this->users[$i]['battle_exp'] && Config::get('limitedexp')) { - $this->users[$i]['battle_exp'] = $lime; - } - - unset($lime); - - if ($btlstatus[0] > 0) { - if ($this->info['type'] == 99) { - $prc .= ' (' . $btlstatus[3] . ')'; - } else { - $prc .= ' (' . $btlstatus[2] . ')'; - } - } - - if ($this->info['dungeon'] == 1 && $this->users[$i]['team'] == $this->info['team_win']) { - //канализация лимит - $rep = mysql_fetch_array( - mysql_query( - 'SELECT `dl1`,`id` FROM `rep` WHERE `id` = "' . $this->users[$i]['id'] . '" LIMIT 1' - ) - ); - if ($rep['dl' . $this->info['dungeon']] > 0) { - $this->users[$i]['battle_exp'] += 3 * count($this->users); - if ($rep['dl' . $this->info['dungeon']] > $this->users[$i]['battle_exp']) { - $rep['dl' . $this->info['dungeon']] -= $this->users[$i]['battle_exp']; - } else { - $this->users[$i]['battle_exp'] = $rep['dl' . $this->info['dungeon']]; - $rep['dl' . $this->info['dungeon']] = 0; - } - mysql_query( - 'UPDATE `rep` SET `dl' . $this->info['dungeon'] . '` = "' . $rep['dl' . $this->info['dungeon']] . '" WHERE `id` = "' . $rep['id'] . '" LIMIT 1' - ); - } else { - $this->users[$i]['battle_exp'] = 0; - } - } - - if ($this->users[$i]['battle_exp'] < 1) { - $this->users[$i]['battle_exp'] = 0; - } - - if ($this->users[$i]['battle_exp'] < 1 && $this->users[$i]['twink'] == 0) { - if ($this->info['money'] == 0 && $this->info['money3'] == 0 && $this->info['kingfight'] == 0 && (!isset($admnb) || $admnb == 0)) { - $prc = ''; - } - } - - if ($this->user[$i]['host_reg'] == 'real_bot_user') { - $this->users[$i]['battle_exp'] = round($this->users[$i]['battle_exp'] / 3); - } - - if ($sinf != '') { - $sinf = ' ( ' . $sinf . ' )'; - } - - //--------------Лимит 8-9-------------- - if ($this->users[$i]['level'] == 8 && $this->users[$i]['battle_exp'] >= 23000) { - $this->users[$i]['battle_exp'] = 23000; - } - if ($this->users[$i]['level'] == 9 && $this->users[$i]['battle_exp'] >= 31000) { - $this->users[$i]['battle_exp'] = 31000; - } - if ($this->users[$i]['level'] == 10 && $this->users[$i]['battle_exp'] >= 52000) { - $this->users[$i]['battle_exp'] = 52000; - } - if ($this->users[$i]['level'] >= 11 && $this->users[$i]['battle_exp'] >= 75000) { - $this->users[$i]['battle_exp'] = 75000; - } - //------------------------------------- - - if ($this->info['type'] != 33) { - $this->users[$i]['battle_text'] = 'Бой закончен. Всего вами нанесено урона: ' . floor( - $this->users[$i]['battle_yron'] - ) . ' HP. Получено опыта: ' . (0 + $this->users[$i]['battle_exp']) . '' . $prc . '.' . $sinf; //stats - } - - /*Выпадение зубов в конце боя */ - if (Config::get('nolevel')) { - $rex95 = substr($this->users[$i]['exp'], -1); - if ($this->users[$i]['money4'] < 1000 && $this->users[$i]['exp'] == 12499) { - $rex95 = 6; - $rex95 = 5; - } - } else { - $rex95 = 5; - } - - //Снижение времени Право на подвиг Титул за победу в хаоте - if ($this->info['dungeon'] == 0 && $this->info['razdel'] == 5 && $this->users[$i]['team'] == $this->info['team_win']) { - //ТУТ2 - StatsModel::addRepexpById($this->users[$i]['id'], 2); //Репутация за поб в хаоте +2 - $check = mysql_fetch_array( - mysql_query( - 'SELECT * FROM `eff_users` WHERE `id_eff` = 478 AND `uid` = "' . $this->users[$i]['id'] . '" AND `delete` = 0 ORDER BY `overType` DESC LIMIT 1;' - ) - ); - if (isset($check['id'])) { - $urcheck = 10000; - if ($this->users[$i]['level'] == 8) { - $urcheck = 3000; - } elseif ($this->users[$i]['level'] == 9) { - $urcheck = 7000; - } elseif ($this->users[$i]['level'] == 10) { - $urcheck = 12000; - } elseif ($this->users[$i]['level'] >= 11) { - $urcheck = 18000; - } - - if ($this->users[$i]['battle_yron'] >= $urcheck) { - mysql_query( - 'UPDATE `eff_users` SET `timeUse` = `timeUse` - 300 WHERE `id_eff`=478 AND `delete` = 0 AND `uid` =' . $this->users[$i]['id'] . ' LIMIT 1' - ); - $this->users[$i]['battle_text'] .= ' За победу в хаоте и нанесение урона в ' . $urcheck . ' и более вы получаете -5 мин. к праву на подвиг!'; - } - } - mysql_query( - 'UPDATE `users_achiv` SET `vx`= `vx`+1 WHERE `id` = "' . $this->users[$i]['id'] . '" LIMIT 1' - ); // - - } - //Награда за клан вар - if ($this->info['dungeon'] == 0 && $this->info['type'] == 250 && $this->users[$i]['team'] == $this->info['team_win']) { - mysql_query( - 'UPDATE `users_achiv` SET `kw`= `kw`+1 WHERE `id` = "' . $this->users[$i]['id'] . '" LIMIT 1' - ); - if (date('w') == 0 || date('w') == 6 || date('w') == 4) { - StatsModel::addRepexpById($this->users[$i]['id'], 25); //Клановые войны(победа) 25 - } - } - //Награда за клан вар - if ($this->info['dungeon'] == 0 && $this->info['type'] == 99 && $this->users[$i]['team'] == $this->info['team_win']) { - if (date('w') == 0 || date('w') == 6 || date('w') == 5) { - StatsModel::addRepexpById($this->users[$i]['id'], 10); //Кровавые войны(победа) 10 - } - } - - //Новая выдача на трупожора - if ($this->info['dungeon'] == 0 && $this->info['type'] == 500 && $this->users[$i]['team'] == $this->info['team_win'] && $this->users[$i]['no_ip'] != 'trupojor' && $this->users[$i]['bot'] == 0) { - if ($this->users[$i]['level'] > 9) { - $mid = 903093; - } else { - $mid = 89489; - } - $mon = mysql_fetch_array( - mysql_query('SELECT * FROM `aaa_monsters` WHERE `uid` = "' . $mid . '" LIMIT 1') - ); - - if ($this->users[$i]['battle_yron'] >= 2000) { - $ritem = rand(1, 100); - if ($ritem <= 20) { - $mon['win_itm'] = '4459@1'; - } elseif ($ritem <= 40) { - $mon['win_itm'] = '4460@1'; - } elseif ($ritem <= 60) { - $mon['win_itm'] = '4461@1'; - } elseif ($ritem <= 80) { - $mon['win_itm'] = '4462@1'; - } else { - $mon['win_itm'] = '4463@1'; - } - } elseif ($this->users[$i]['battle_yron'] >= 1500) { - $ritem = rand(1, 100); - if ($ritem <= 20) { - $mon['win_itm'] = '4459@1'; - } elseif ($ritem <= 40) { - $mon['win_itm'] = '4460@1'; - } elseif ($ritem <= 60) { - $mon['win_itm'] = '4461@1'; - } elseif ($ritem <= 80) { - $mon['win_itm'] = '4462@1'; - } else { - $mon['win_itm'] = '4463@1'; - } - } elseif ($this->users[$i]['battle_yron'] >= 1000) { - $ritem = rand(1, 100); - if ($ritem <= 25) { - $mon['win_itm'] = '4460@1'; - } elseif ($ritem <= 50) { - $mon['win_itm'] = '4461@1'; - } elseif ($ritem <= 75) { - $mon['win_itm'] = '4462@1'; - } else { - $mon['win_itm'] = '4463@1'; - } - } else { - $mon['win_itm'] = '4392@1'; - $timewait = 0; - } - if ($this->users[$i]['battle_yron'] > 0) { - mysql_query( - 'INSERT INTO `eff_users` (`no_Ace`,`id_eff`,`overType`,`uid`,`name`,`data`,`timeUse`) VALUES ("1","478","111","' . $this->users[$i]['id'] . '","Право на подвиг","pravonapodvig=1","' . time( - ) . '")' - ); - } - mysql_query( - 'INSERT INTO `actions`(`uid`, `time`, `city`, `room`, `vars`, `ip`, `vals`, `val`) VALUES ("' . $this->users[$i]['id'] . '","' . (time( - ) - $timewait) . '","capitalcity","' . $this->users[$i]['room'] . '","end_trup"," ","","")' - ); - mysql_query( - 'INSERT INTO `eff_users` (`no_Ace`,`id_eff`,`overType`,`uid`,`name`,`data`,`timeUse`) VALUES ("1","479","112","' . $u->info['id'] . '","Защита от нападения","zashitatk=1","' . time( - ) . '")' - ); - $ritem = rand(1, 1000); - if ($ritem == 555) { - $mon['win_itm'] = $mon['win_itm'] . ',5022@1'; - } - // - $this->addGlobalItems( - $mid, - $this->users[$i]['id'], - $mon['win_itm'], - $mon['win_ico'], - 1, - $mon['win_money1'], - $mon['win_money2'] - ); - - } - - if ($this->info['razdel'] == 5 || $this->info['razdel'] == 4) { - if (date('d.m') == '31.10' || (date('m') == 11 && date('d') < 7)) { - //Хэллоуин 4504 - $this->users[$i]['battle_text'] .= ' Вы получаете Тыква (x1).'; - ItemsModel::addItem(4504, $this->users[$i]['id'], '|sudba=1'); - } - } - - - //Добавляем воинственность - if ($this->info['dungeon'] == 0 && $this->info['razdel'] == 5 && $this->users[$i]['exp'] >= 1500 /*($this->users[$i]['exp'] < 12499 || $this->users[$i]['exp'] > 12500)*/ - ) { - if ($this->users[$i]['battle_exp'] > 100 * $this->users[$i]['level']) { - $rzbvo = $this->users[$i]['battle_exp'] * 6 / 1000; - - if ($this->users[$i]['level'] == 8) { - if ($rzbvo >= 100) { - $rzbvo = 100; - } - } - if ($this->users[$i]['level'] == 9) { - if ($rzbvo >= 150) { - $rzbvo = 150; - } - } - if ($this->users[$i]['level'] == 10) { - if ($rzbvo >= 200) { - $rzbvo = 200; - } - } - if ($this->users[$i]['level'] == 11) { - if ($rzbvo >= 250) { - $rzbvo = 250; - } - } - if ($this->users[$i]['level'] == 12) { - if ($rzbvo >= 250) { - $rzbvo = 250; - } - } - - - if ($this->info['type'] != 33) { - $this->users[$i]['battle_text'] .= ' Вы получили ' . $rzbvo . ' воинственности за этот бой.'; - } - mysql_query( - 'UPDATE `rep` SET `rep3` = `rep3` + "' . $rzbvo . '" WHERE `id` = "' . $this->users[$i]['id'] . '" LIMIT 1' - ); - mysql_query( - 'INSERT INTO `actions`(`uid`, `time`, `city`, `room`, `vars`, `ip`, `vals`, `val`) VALUES ("' . $this->users[$i]['id'] . '","' . time( - ) . '","capitalcity","' . $this->users[$i]['room'] . '","end_xaot"," ","' . $zadID . '","")' - ); - } - } - - if ($this->stats[$i]['hpNow'] >= 1) { - $this->stats[$i]['test_heal'] = mysql_fetch_array( - mysql_query( - 'SELECT SUM(`yrn`) FROM `battle_stat` WHERE `uid2` = "' . $this->users[$i]['id'] . '" AND `battle` = "' . $this->info['id'] . '" LIMIT 1' - ) - ); - $this->stats[$i]['test_heal'] = $this->stats[$i]['test_heal'][0]; - $this->stats[$i]['test_start'] = mysql_fetch_array( - mysql_query( - 'SELECT `hpStart` FROM `battle_users` WHERE `uid` = "' . $this->users[$i]['id'] . '" AND `battle` = "' . $this->info['id'] . '" LIMIT 1' - ) - ); - $this->stats[$i]['test_start'] = $this->stats[$i]['test_start']['hpStart']; - // - $this->stats[$i]['hpNow'] = ($this->stats[$i]['test_start'] - $this->stats[$i]['test_heal']); - if ($this->stats[$i]['hpNow'] < 1) { - $this->stats[$i]['hpNow'] = 1; - } - } else { - $this->stats[$i]['hpNow'] = 0; - } - - unset($this->stats[$i]['test_heal']); - - $this->users[$i]['last_b'] = $this->info['id']; //stats - $this->users[$i]['last_a'] = $act01; - $this->users[$i]['battle'] = -1; //users - $this->users[$i]['battle_yron'] = 0; //stats - - $this->users[$i]['exp'] += $this->users[$i]['battle_exp']; //users - - - //Добавляем клан опыт (Все кроме пещер) - - if ($this->users[$i]['clan'] > 0) { - $cpr = 1; - if ($this->info['typeBattle'] == 9) { - $cpr = 25; - } elseif ($this->info['typeBattle'] == 50) { - $cpr = 65; - } - if ($this->stats[$i]['silver'] >= 5) { - $cpr = floor($cpr / 100 * 150); - } - mysql_query( - 'UPDATE `clan` SET `exp` = `exp` + "' . round( - $this->users[$i]['battle_exp'] / 100 * $cpr - ) . '" WHERE `id` = "' . $this->users[$i]['clan'] . '" LIMIT 1' - ); - } - - $this->users[$i]['battle_exp'] = 0; //stats - - if ($this->users[$i]['team'] == $this->info['team_win']) { - mysql_query( - 'UPDATE `rep` SET `n_capitalcity` = `n_capitalcity` + ' . $this->users[$i]['bn_capitalcity'] . ' ,`n_demonscity` = `n_demonscity` + ' . $this->users[$i]['bn_demonscity'] . ' ,`n_demonscity` = `n_demonscity` + ' . $this->users[$i]['bn_suncity'] . ' WHERE `id` = "' . $this->users[$i]['id'] . '" LIMIT 1' - ); - } - - //репутация - $this->users[$i]['bn_demonscity'] = 0; - $this->users[$i]['bn_capitalcity'] = 0; - $this->users[$i]['bn_suncity'] = 0; - //завершение эффектов с финишем - $spe = mysql_query( - 'SELECT * FROM `eff_users` WHERE `uid` = "' . $this->users[$i]['id'] . '" AND `file_finish` != "" AND `v1` = "priem" LIMIT 30' - ); - while ($ple = mysql_fetch_array($spe)) { - if (file_exists('../../_incl_data/class/priems/' . $ple['file_finish'] . '.php')) { - require('../../_incl_data/class/priems/' . $ple['file_finish'] . '.php'); - } - } - //обновляем данные - mysql_query( - 'DELETE FROM `eff_users` WHERE `v1` = "priem" AND `uid` = "' . $this->users[$i]['id'] . '" LIMIT 50' - ); - if ($dnr == 1) { - if ($this->users[$i]['room'] == 370) { - $dies = mysql_fetch_array( - mysql_query( - 'SELECT COUNT(`id`) FROM `dungeon_actions` WHERE `uid` = "' . $this->users[$i]['id'] . '" AND `dn` = "' . $this->users[$i]['dnow'] . '" AND `vars` = "dielaba" LIMIT 1' - ) - ); - $dies = $dies[0]; - mysql_query( - 'INSERT INTO `dungeon_actions` (`dn`,`uid`,`x`,`y`,`time`,`vars`,`vals`) VALUES ( - "' . $this->users[$i]['dnow'] . '","' . $this->users[$i]['id'] . '","' . $this->users[$i]['x'] . '","' . $this->users[$i]['y'] . '","' . time() . '","dielaba","" - )' - ); - } else { - $dies = mysql_fetch_array( - mysql_query( - 'SELECT COUNT(`id`) FROM `dungeon_actions` WHERE `uid` = "' . $this->users[$i]['id'] . '" AND `dn` = "' . $this->users[$i]['dnow'] . '" AND `vars` = "die" LIMIT 1' - ) - ); - $dies = $dies[0]; - mysql_query( - 'INSERT INTO `dungeon_actions` (`dn`,`uid`,`x`,`y`,`time`,`vars`,`vals`) VALUES ( - "' . $this->users[$i]['dnow'] . '","' . $this->users[$i]['id'] . '","' . $this->users[$i]['x'] . '","' . $this->users[$i]['y'] . '","' . time() . '","die","" - )' - ); - } - if ($dies < 2 || $this->info['dungeon'] == 15) { - // - $tshbn = mysql_fetch_array( - mysql_query( - 'SELECT `id` FROM `items_users` WHERE `uid` = "' . $this->users[$i]['id'] . '" AND `delete` = 0 AND `item_id` = "4910" LIMIT 1' - ) - ); - if (isset($tshbn['id'])) { - //выбрасываем шайбу - mysql_query('DELETE FROM `items_users` WHERE `id` = "' . $tshbn['id'] . '" LIMIT 1'); - // - mysql_query( - 'INSERT INTO `dungeon_obj` ( - `name`,`dn`,`x`,`y`,`img`,`delete`,`action`,`for_dn`, - `type`,`w`,`h`,`s`,`s2`,`os1`,`os2`,`os3`,`os4`,`type2`,`top`,`left`,`date` - ) VALUES ( - "Шайба","' . $this->info['dn_id'] . '","' . $this->users[$i]['x'] . '","' . $this->users[$i]['y'] . '","shaiba.png","0","fileact:15/shaiba","0", - "0","120","220","0","0","5","8","12","0","0","0","0","{use:\'takeit\',rt1:69,rl1:-47,rt2:74,rl2:126,rt3:76,rl3:140,rt4:80,rl4:150}" - )' - ); - // - } - //телепортируем в рестарт (координата 0х0) - $this->users[$i]['x'] = $this->users[$i]['res_x']; - $this->users[$i]['y'] = $this->users[$i]['res_y']; - $this->users[$i]['s'] = $this->users[$i]['res_s']; - $r_n = mysql_fetch_array( - mysql_query( - 'SELECT `name` FROM `room` WHERE `id` = "' . (int)$this->users[$i]['room'] . '" LIMIT 1' - ) - ); - if ($this->users[$i]['room'] == 370) { - if ($this->users[$i]['sex'] == 0) { - $rtxt = '' . $this->users[$i]['login'] . ' трагически погиб и находится в начале лабиринта'; - } else { - $rtxt = '' . $this->users[$i]['login'] . ' трагически погибла и находится в начале лабиринта'; - } - } else { - if ($this->users[$i]['sex'] == 0) { - $rtxt = '' . $this->users[$i]['login'] . ' трагически погиб и находится в комнате "' . $r_n['name'] . '"'; - } else { - $rtxt = '' . $this->users[$i]['login'] . ' трагически погибла и находится в комнате "' . $r_n['name'] . '"'; - } - } - } elseif ($this->info['dungeon'] == 102) { - $nld = ''; - $lab = mysql_fetch_array( - mysql_query( - 'SELECT `id`,`users` FROM `laba_now` WHERE `id` = "' . $this->users[$i]['id'] . '" LIMIT 1' - ) - ); - if ($lab['users'] < 2) { - //Удаляем подземелье - mysql_query('DELETE FROM `laba_now` WHERE `id` = "' . $lab['id'] . '" LIMIT 1'); - mysql_query('DELETE FROM `laba_map` WHERE `id` = "' . $lab['id'] . '" LIMIT 1'); - mysql_query('DELETE FROM `laba_obj` WHERE `lib` = "' . $lab['id'] . '"'); - mysql_query('DELETE FROM `laba_act` WHERE `lib` = "' . $lab['id'] . '"'); - mysql_query('DELETE FROM `laba_itm` WHERE `lib` = "' . $lab['id'] . '"'); - } else { - $lab['users']--; - mysql_query( - 'UPDATE `laba_now` SET `users` = "' . $lab['users'] . '" WHERE `id` = "' . $lab['id'] . '" LIMIT 1' - ); - } - mysql_query( - 'UPDATE `stats` SET `dnow` = "0" WHERE `id` = "' . $this->users[$i]['id'] . '" LIMIT 1' - ); - mysql_query( - 'UPDATE `users` SET `room` = "369" WHERE `id` = "' . $this->users[$i]['id'] . '" LIMIT 1' - ); - //удаляем все предметы которые пропадают после выхода из пещеры - mysql_query( - 'UPDATE `items_users` SET `delete` = "' . time( - ) . '" WHERE `uid` = "' . $this->users[$i]['id'] . '" AND `delete` < 1234567890 AND `inShop` = "0" AND (`dn_delete` = "1" OR `data` LIKE "%fromlaba=1%")' - ); - if ($this->users[$i]['login'] != '') { - if ($this->users[$i]['sex'] == 0) { - $rtxt = '' . $this->users[$i]['login'] . ' трагически погиб без права на воскрешение и покидает подземелье' . $nld; - } else { - $rtxt = '' . $this->users[$i]['login'] . ' трагически погибла без права на воскрешение и покидает подземелье' . $nld; - } - } - } else { - $tinf = mysql_fetch_array( - mysql_query( - 'SELECT `uid` FROM `dungeon_now` WHERE `id` = "' . $this->info['dn_id'] . '" LIMIT 1' - ) - ); - $nld = ''; - if ($tinf['uid'] == $this->users[$i]['id']) { - $tinf = mysql_fetch_array( - mysql_query( - 'SELECT `id` FROM `stats` WHERE `dnow` = "' . $this->info['dn_id'] . '" AND `hpNow` >= 1 LIMIT 1' - ) - ); - if (isset($tinf['id'])) { - $tinf = mysql_fetch_array( - mysql_query( - 'SELECT `id`,`login` FROM `users` WHERE `id` = "' . $tinf['id'] . '" LIMIT 1' - ) - ); - $nld .= ', новым лидером становится "' . $tinf['login'] . '"'; - mysql_query( - 'UPDATE `dungeon_now` SET `uid` = "' . $tinf['id'] . '" WHERE `id` = "' . $this->info['dn_id'] . '" LIMIT 1' - ); - } - } - - mysql_query( - 'UPDATE `stats` SET `dnow` = "0" WHERE `id` = "' . $this->users[$i]['id'] . '" LIMIT 1' - ); - mysql_query( - 'UPDATE `users` SET `room` = "321" WHERE `id` = "' . $this->users[$i]['id'] . '" LIMIT 1' - ); - //удаляем все предметы которые пропадают после выхода из пещеры - mysql_query( - 'UPDATE `items_users` SET `delete` = "' . time() . '" WHERE `uid` = "' . $this->users[$i]['id'] . '" AND `dn_delete` = "1" LIMIT 1000' - ); - 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' - ); - - if ($this->users[$i]['sex'] == 0) { - $rtxt = '' . $this->users[$i]['login'] . ' трагически погиб без права на воскрешение и покидает подземелье' . $nld; - } else { - $rtxt = '' . $this->users[$i]['login'] . ' трагически погибла без права на воскрешение и покидает подземелье' . $nld; - } - } - if (!empty($rtxt)) { - $cmsg->setDn($this->info['dn_id']); - $cmsg->setText($rtxt); - $cmsg->setTypeTime(1); - $chat->sendMsg($cmsg); - } - } - - mysql_query('UPDATE `users` SET `login2` = "" WHERE `battle` = "' . $this->info['id'] . '"'); - mysql_query( - 'UPDATE `users` SET `login2` = "", `money` = "' . $this->users[$i]['money'] . '", `money2` = "' . $this->users[$i]['money2'] . '",`win` = "' . $this->users[$i]['win'] . '",`lose` = "' . $this->users[$i]['lose'] . '",`nich` = "' . $this->users[$i]['nich'] . '",`battle` = "-1" WHERE `id` = "' . $this->users[$i]['id'] . '" LIMIT 1' - ); - - if ($u->info['id'] == $this->users[$i]['id']) { - $u->info['battle_text'] = $this->users[$i]['battle_text']; - } - - mysql_query( - 'UPDATE `stats` SET `hpNow` = "' . $this->stats[$i]['hpNow'] . '",`mpNow` = "' . $this->stats[$i]['mpNow'] . '",`bn_capitalcity` = 0,`bn_demonscity` = 0,`smena` = 3,`tactic7` = "-100",`x`="' . $this->users[$i]['x'] . '",`y`="' . $this->users[$i]['y'] . '",`priems_z`="0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0",`last_pr`="0",`tactic1`="0",`tactic2`="0",`tactic3`="0",`tactic4`="0",`tactic5`="0",`tactic6`="0.00000000",`tactic7`="10",`exp` = "' . $this->users[$i]['exp'] . '",`battle_exp` = "' . $this->users[$i]['battle_exp'] . '",`battle_text` = "' . $this->users[$i]['battle_text'] . '",`battle_yron` = "0",`enemy` = "0",`last_b`="' . $this->info['id'] . '",`regHP` = "' . time( - ) . '",`regMP` = "' . time() . '" WHERE `id` = "' . $this->users[$i]['id'] . '" LIMIT 1' - ); - if ($this->info['turnir'] == 0) { - //пишем в чат - $cmsg->setTo($this->users[$i]['login']); - $cmsg->setText($this->users[$i]['battle_text']); - $chat->sendMsg($cmsg); - } else { - mysql_query( - 'UPDATE `turnirs` SET `winner` = "' . $this->info['team_win'] . '" WHERE `id` = "' . $this->info['turnir'] . '" LIMIT 1' - ); - } - //завершаем сам бой - mysql_query( - 'UPDATE `battle` SET `time_over` = "' . time() . '",`team_win` = "' . $this->info['team_win'] . '" WHERE `id` = "' . $this->info['id'] . '" LIMIT 1' - ); - - - // Жрать хочет - if ($this->users[$i]['animal'] > 0) { - $a = mysql_fetch_array( - mysql_query( - 'SELECT * FROM `users_animal` WHERE `uid` = "' . $this->users[$i]['id'] . '" AND `id` = "' . $this->users[$i]['animal'] . '" AND `pet_in_cage` = "0" AND `delete` = "0" LIMIT 1' - ) - ); - if (isset($a['id'])) { - if ($a['eda'] < 1) { - $cmsg = new ChatMessage(); - $cmsg->setRoom($this->users[$i]['room']); - $cmsg->setCity($this->users[$i]['city']); - $cmsg->setTo($this->users[$i]['login']); - $cmsg->setText('' . $a['name'] . ' нуждается в еде...'); - $cmsg->setType(6); - $chat->sendMsg($cmsg); - } - } - } - mysql_query( - 'UPDATE `stats` SET `battle_text` = "",`last_b`="0" WHERE `id` = "' . $this->users[$i]['id'] . '" LIMIT 1' - ); - mysql_query('UPDATE `battle_users` SET `finish` = 1 WHERE `uid` = "' . $this->users[$i]['id'] . '"'); - $this->saveLogs(); - if ($u->info['battle'] != 0 && !isset($u->info['battle_lsto'])) { - echo ''; - } - } - - } - mysql_query('UPDATE `battle` SET `testfinish` = "0" WHERE `id` = "' . $this->info['id'] . '" LIMIT 1'); - mysql_query('UNLOCK TABLES'); + $this->finish->finishBattle($t, $v, $nl); } - /** - * Сохраняем лог в архив - * @return void - */ - private function saveLogs() - { - Db::sql( - 'insert into battle_logs_save select id, time, battle, id_hod, text, vars, zona1, zonb1, zona2, zonb2, type from battle_logs where battle = ? and id_hod <= ?', - [$this->info['id'], $this->hodID] - ); - Db::sql('delete from battle_logs where battle = ?', [$this->info['id']]); - Db::sql('delete from battle_stat where battle < ?', [$this->info['id'] - 100]); - Db::sql('delete from battle_actions where btl = ?', [$this->info['id']]); - } //Проверка ухода удара в игрока public function addTravm($uid, $type, $lvl) { - $t = $type; - if ($t == 1) { + $stat = rand(1, 3); // пока без духовности + $img = "eff_travma$type.gif"; + $timeEnd = 0; + if ($type == 1) { $name = 'Легкая травма'; - $stat = rand(1, 3); // пока без духовности $timeEnd = rand(1, 3);// время травмы от 1.30 до 6 часов $data = 'add_s' . $stat . '=-' . $lvl; - $img = 'eff_travma1.gif'; - $v1 = 1; - } elseif ($t == 2) { + } elseif ($type == 2) { $name = 'Средняя травма'; - $stat = rand(1, 3); // пока без духовности $timeEnd = rand(3, 5);// время травмы от 6 до 12 часов $data = 'add_s' . $stat . '=-' . ($lvl * 2); - $v1 = 2; - $img = 'eff_travma2.gif'; - } elseif ($t == 3) { + } elseif ($type == 3) { $name = 'Тяжелая травма'; - $stat = rand(1, 3); // пока без духовности $timeEnd = rand(5, 7);// время травмы от 12 до 6 часов $data = 'add_s' . $stat . '=-' . ($lvl * 3); - $v1 = 3; - $img = 'eff_travma3.gif'; - } elseif ($t == 4) { + } elseif ($type == 4) { $name = 'Неизлечимая травма'; - $stat = rand(1, 3); // пока без духовности $timeEnd = 24;// время травмы от 24 часа $data = 'add_s' . $stat . '=-' . ($lvl * 50); - $v1 = 4; - $img = 'eff_travma4.gif'; } $timeEnd *= 3600; mysql_query( 'INSERT INTO `eff_users` (`overType`,`timeUse`,`hod`,`name`,`data`,`uid`, `id_eff`, `img2`, `timeAce`, `v1`) VALUES ("0","' . time( - ) . '","-1","' . $name . '","' . $data . '","' . $uid . '", "4", "' . $img . '","' . $timeEnd . '", "' . $v1 . '")' + ) . '","-1","' . $name . '","' . $data . '","' . $uid . '", "4", "' . $img . '","' . $timeEnd . '", "' . $type . '")' ); mysql_query( 'INSERT INTO `eff_users` (`overType`,`timeUse`,`hod`,`name`,`data`,`uid`, `id_eff`, `img2`, `timeAce`, `v1`) VALUES ("0","' . time( @@ -3136,509 +1305,30 @@ class Battle } //Расчет уворота игроков - - private function typeBattle(int $x): array - { - $r = [0, 0, 'Обычный поединок', 'Кровавый Поединок']; - if ($x >= 50000 && $x < 100000) { - $r = [25, 50, 'Великая Битва', 'Кровавая Битва']; - } elseif ($x < 500000) { - $r = [50, 75, 'Величайшая Битва', 'Кровавая Резня']; - } elseif ($x < 1000000) { - $r = [75, 100, 'Историческая Битва', 'Кровавая Сеча']; - } elseif ($x < 2500000) { - $r = [100, 125, 'Эпохальная Битва', 'Кровавое Побоище']; - } elseif ($x >= 5000000) { - $r = [150, 150, 'Судный День', 'Судный День']; - } - return $r; - } - //Расчет крита игроков - - private function addGlobalItems($bid, $uid, $itm, $ico, $exp, $cr, $ecr) - { - global $u; - $chat = new Chat(); - $cmsg = new ChatMessage(); - $cmsg->setType(6); - $cmsg->setCity($this->users[$this->uids[$uid]]['city']); - $cmsg->setRoom($this->users[$this->uids[$uid]]['room']); - $cmsg->setTo($this->users[$this->uids[$uid]]['login']); - $cmsg->setColor('#cb0000'); - // - //Выпадение дропа на ЦП - if ($bid == 1008) { - //Старый Новый Год - $jit = 0; - $iit = mysql_fetch_array( - mysql_query('SELECT COUNT(*) FROM `users` WHERE `online` > ' . (time() - 120)) - ); - $iit = floor($iit[0] / 20); - $iit = rand(1, $iit); - while ($jit < $iit) { - if (rand(0, 100) < 50) { - $svtk = [ - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1461, - 1462, - 1463, - 4037, - 4038, - 4039, - 4040, - 911, - 1172, - 1173, - 2142, - 2141, - 2143, - 2870, - 2144, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - 1000, - ]; - $svtk = $svtk[rand(0, count($svtk) - 1)]; - if ($svtk == 1000) { - mysql_query( - 'INSERT INTO `items_local` - ( `room` , `time`,`item_id`,`data`,`tr_login`,`colvo` ) VALUES - ( - "' . $this->users[$this->uids[$uid]]['room'] . '", - "' . time() . '", - "' . $svtk . '", - "|nosale=1|srok=259200", - "' . $this->users[$this->uids[$uid]]['login'] . '", - "1" - ),( - "' . $this->users[$this->uids[$uid]]['room'] . '", - "' . time() . '", - "' . $svtk . '", - "|nosale=1|srok=259200", - "' . $this->users[$this->uids[$uid]]['login'] . '", - "1" - ),( - "' . $this->users[$this->uids[$uid]]['room'] . '", - "' . time() . '", - "' . $svtk . '", - "|nosale=1|srok=259200", - "' . $this->users[$this->uids[$uid]]['login'] . '", - "1" - ),( - "' . $this->users[$this->uids[$uid]]['room'] . '", - "' . time() . '", - "' . $svtk . '", - "|nosale=1|srok=259200", - "' . $this->users[$this->uids[$uid]]['login'] . '", - "1" - ),( - "' . $this->users[$this->uids[$uid]]['room'] . '", - "' . time() . '", - "' . $svtk . '", - "|nosale=1|srok=259200", - "' . $this->users[$this->uids[$uid]]['login'] . '", - "1" - ),( - "' . $this->users[$this->uids[$uid]]['room'] . '", - "' . time() . '", - "' . $svtk . '", - "|nosale=1|srok=259200", - "' . $this->users[$this->uids[$uid]]['login'] . '", - "1" - )' - ); - } - mysql_query( - 'INSERT INTO `items_local` - ( `room` , `time`,`item_id`,`data`,`tr_login`,`colvo` ) VALUES - ( - "' . $this->users[$this->uids[$uid]]['room'] . '", - "' . time() . '", - "' . $svtk . '", - "|nosale=1|srok=259200", - "' . $this->users[$this->uids[$uid]]['login'] . '", - "1" - )' - ); - } - $jit++; - } - unset($svtk); - } elseif ($bid == 1007) { - //Хэллоуин, Тыквоголовый CAPITAL CITY - $jit = 0; - $iit = mysql_fetch_array( - mysql_query('SELECT COUNT(*) FROM `users` WHERE `online` > ' . (time() - 120)) - ); - $iit = floor($iit[0] / 20); - $iit = rand(1, $iit); - while ($jit < $iit) { - if (rand(0, 100) < 50) { - mysql_query( - 'INSERT INTO `items_local` - ( `room` , `time`,`item_id`,`data`,`tr_login`,`colvo` ) VALUES - ( - "' . $this->users[$this->uids[$uid]]['room'] . '", - "' . time() . '", - "4504", - "", - "' . $this->users[$this->uids[$uid]]['login'] . '", - "1" - )' - ); - } - $jit++; - } - } elseif ($bid == 1006) { - //Трупожор CAPITAL CITY - if (rand(0, 100) < 10) { - mysql_query( - 'INSERT INTO `items_local` - ( `room` , `time`,`item_id`,`data`,`tr_login`,`colvo` ) VALUES - ( - "' . $this->users[$this->uids[$uid]]['room'] . '", - "' . time() . '", - "4451", - "srok=86400", - "' . $this->users[$this->uids[$uid]]['login'] . '", - "1" - )' - ); - } - } elseif ($bid == 1000) { - //Трупожор CAPITAL CITY - mysql_query( - 'INSERT INTO `items_local` - ( `room` , `time`,`item_id`,`data`,`tr_login`,`colvo` ) VALUES - ( - "' . $this->users[$this->uids[$uid]]['room'] . '", - "' . time() . '", - "4460", - "srok=2592000", - "' . $this->users[$this->uids[$uid]]['login'] . '", - "1" - )' - ); - } elseif ($bid == 1001) { - //Трупожор CAPITAL CITY - mysql_query( - 'INSERT INTO `items_local` - ( `room` , `time`,`item_id`,`data`,`tr_login`,`colvo` ) VALUES - ( - "' . $this->users[$this->uids[$uid]]['room'] . '", - "' . time() . '", - "4461", - "srok=2592000", - "' . $this->users[$this->uids[$uid]]['login'] . '", - "1" - )' - ); - } elseif ($bid == 1002) { - //Трупожор CAPITAL CITY - mysql_query( - 'INSERT INTO `items_local` - ( `room` , `time`,`item_id`,`data`,`tr_login`,`colvo` ) VALUES - ( - "' . $this->users[$this->uids[$uid]]['room'] . '", - "' . time() . '", - "4462", - "srok=2592000", - "' . $this->users[$this->uids[$uid]]['login'] . '", - "1" - )' - ); - } elseif ($bid == 1003) { - //Трупожор CAPITAL CITY - mysql_query( - 'INSERT INTO `items_local` - ( `room` , `time`,`item_id`,`data`,`tr_login`,`colvo` ) VALUES - ( - "' . $this->users[$this->uids[$uid]]['room'] . '", - "' . time() . '", - "4463", - "srok=2592000", - "' . $this->users[$this->uids[$uid]]['login'] . '", - "1" - )' - ); - } elseif ($bid == 1004) { - //Трупожор CAPITAL CITY - mysql_query( - 'INSERT INTO `items_local` - ( `room` , `time`,`item_id`,`data`,`tr_login`,`colvo` ) VALUES - ( - "' . $this->users[$this->uids[$uid]]['room'] . '", - "' . time() . '", - "4459", - "srok=2592000", - "' . $this->users[$this->uids[$uid]]['login'] . '", - "1" - )' - ); - } - if ($exp >= 0) { - //added if, was division by zero. 27.08.22, ins. - $this->users[$this->uids[$uid]]['battle_exp'] += round( - $this->stats[$this->uids[$bid]]['hpAll'] > 0 ? $exp * $this->users[$this->uids[$uid]]['battle_yron'] / $this->stats[$this->uids[$bid]]['hpAll'] : $exp * $this->users[$this->uids[$uid]]['battle_yron'] - ); - mysql_query( - 'UPDATE `stats` SET `battle_exp` = "' . mysql_real_escape_string( - $this->users[$this->uids[$uid]]['battle_exp'] - ) . '" WHERE `id` = "' . mysql_real_escape_string($uid) . '" LIMIT 1' - ); - } - // - if ($cr != '' && $cr > 0 && $this->stats[$this->uids[$uid]]['hpNow'] > 0) { - mysql_query( - 'UPDATE `users` SET `money` = (`money` + ' . mysql_real_escape_string( - $cr - ) . ') WHERE `id` = "' . mysql_real_escape_string($uid) . '" LIMIT 1' - ); - - $cmsg->setText("Вы получили кредиты: $cr кр."); - $chat->sendMsg($cmsg); - } - // - if ($ecr != '' && $ecr > 0 && $this->stats[$this->uids[$uid]]['hpNow'] > 0) { - $this->users[$this->uids[$uid]]['money2'] += $ecr; - $resulttp = mysql_query( - 'UPDATE `users` SET `money2` = (`money2` + ' . mysql_real_escape_string( - $ecr - ) . ') WHERE `id` = "' . $this->users[$this->uids[$uid]]['id'] . '" LIMIT 1' - ); - if (!$resulttp) { - $cmsg->setText("Трупожор был пуст!"); - $chat->sendMsg($cmsg); - Delo::add( - 4, - 'System.battle', - $this->users[$this->uids[$uid]]['id'], - '"System.battle": (В бою трупожор), ПУСТ!!! ', - ); - } else { - $cmsg->setText("Вы получили еврокредиты: $ecr екр."); - $chat->sendMsg($cmsg); - Delo::add( - 4, - 'System.battle', - $this->users[$this->uids[$uid]]['id'], - '"System.battle": Персонаж получил ' . $ecr . ' ЕКР (В бою трупожор), сейчас: ' . $this->users[$this->uids[$uid]]['money2'] . ' ЕКР', - ); - } - } - if ($ico != '') { - /* - 0(тип, 1 - значок, 2 - подвиг)@ - 1(время в минутах)@ - 2(название картинки)@ - 3(название)@ - 4(требует остаться в живых 0 или 1, либо игрок умер -1)@ - 5(требует набить с ботам урона в % Например 0.001)@ - 6(действия например: add_s1=5|add_hpAll=50)@ - 7(Требует другой значок, название картинки)@ - 8(плюсует значок 0 или 1)@ - 9(удаляем прошлый значок 0 or 1) - */ - $i = 0; - $txt = ''; - $ico = explode('#', $ico); - while ($i < count($ico)) { - $ico_e = explode('@', $ico[$i]); - if (isset($ico_e[3])) { - $add = 1; - if ($ico_e[4] == 1 && floor($this->stats[$this->uids[$uid]]['hpNow']) < 1) { - $add = 0; - } - if ($add == 1) { - $ins = false; - if ($ico_e[8] == 0) { - $ins = true; - if ($ico_e[9] == 1) { - mysql_query( - 'DELETE FROM `users_ico` WHERE `uid` = "' . mysql_real_escape_string( - $uid - ) . '" AND `img` = "' . mysql_real_escape_string($ico_e[2]) . '"' - ); - } - } else { - $old_ico = mysql_fetch_array( - mysql_query( - 'SELECT `id` FROM `users_ico` WHERE `uid` = "' . mysql_real_escape_string( - $uid - ) . '" AND (`endTime` > "' . time() . '" OR `endTime` = 0) AND `img` = "' . mysql_real_escape_string( - $ico_e[2] - ) . '" LIMIT 1' - ) - ); - if (!isset($old_ico['id'])) { - $ins = true; - } else { - if ($old_ico['id'] > 0) { - $txt .= ', "' . $ico_e[3] . ' (Обновление)"'; - mysql_query( - 'UPDATE `users_ico` SET `x` = `x` + 1,`endTime` = "' . mysql_real_escape_string( - time() + $ico_e[1] * 60 - ) . '" WHERE `id` = "' . $old_ico['id'] . '" LIMIT 1' - ); - } else { - $ins = true; - } - } - unset($old_ico); - } - if ($ins) { - if ($ico_e[9] == 1) { - mysql_query( - 'DELETE FROM `users_ico` WHERE `uid` = "' . mysql_real_escape_string( - $uid - ) . '" AND `img` = "' . mysql_real_escape_string($ico_e[2]) . '"' - ); - } - mysql_query( - 'INSERT INTO `users_ico` (`uid`,`time`,`text`,`img`,`endTime`,`type`,`bonus`) VALUES ( - "' . mysql_real_escape_string($uid) . '", - "' . time() . '", - "' . mysql_real_escape_string($ico_e[3]) . '", - "' . mysql_real_escape_string($ico_e[2]) . '", - "' . mysql_real_escape_string(time() + $ico_e[1] * 60) . '", - "' . mysql_real_escape_string($ico_e[0]) . '", - "' . mysql_real_escape_string($ico_e[6]) . '" - )' - ); - $txt .= ', "' . $ico_e[3] . '"'; - } - } - } - $i++; - } - if ($txt != '') { - $txt = ltrim($txt, ', '); - $cmsg->setText("Вы совершили подвиг: $txt"); - $chat->sendMsg($cmsg); - } - } - if ($itm != '') { - $i = 0; - $txt = ''; - $itm = explode(',', $itm); - while ($i < count($itm)) { - $itm_e = explode('@', $itm[$i]); - if ($itm_e[0] > 0) { - $j = 0; - while ($j < $itm_e[1]) { - ItemsModel::addItem($itm_e[0], $uid, '|' . $itm_e[2]); - $j++; - } - if (!isset($this->ainm[$itm_e[0]])) { - $this->ainm[$itm_e[0]] = mysql_fetch_array( - mysql_query( - 'SELECT `id`,`name` FROM `items_main` WHERE `id` = "' . mysql_real_escape_string( - $itm_e[0] - ) . '" LIMIT 1' - ) - ); - } - if (isset($this->ainm[$itm_e[0]]['id'])) { - //Добавляем текст о добавлении предмета - $txt .= ', ' . $this->ainm[$itm_e[0]]['name'] . ''; - if ($itm_e[1] > 1) { - $txt .= ' (x' . $itm_e[1] . ')'; - } - } - } - $i++; - } - if ($txt != '') { - $txt = ltrim($txt, ', '); - $cmsg->setText("Вы получили предметы: $txt"); - $chat->sendMsg($cmsg); - } - } - // - } - //Расчет блока щитом игроков - public function priemAddLogFast($u1, $u2, $prm, $text, $hodID, $tm) + public function priemAddLogFast($u1, $u2, $prm, $text, $hodID, $tm): void { - $vLog = 'prm=' . $prm . '||time1=' . $tm . '||time2=' . $tm . '||s1=' . $this->users[$this->uids[$u1]]['sex'] . '||s2=' . $this->users[$this->uids[$u2]]['sex'] . '||t2=' . $this->users[$this->uids[$u2]]['team'] . '||t1=' . $this->users[$this->uids[$u1]]['team'] . '||login1=' . $this->users[$this->uids[$u1]]['login2'] . '||login2=' . $this->users[$this->uids[$u2]]['login2']; - $mas = [ + $vLog = + 'prm=' . $prm . + '||time1=' . $tm . + '||time2=' . $tm . + '||s1=' . $this->users[$this->uids[$u1]]['sex'] . + '||s2=' . $this->users[$this->uids[$u2]]['sex'] . + '||t2=' . $this->users[$this->uids[$u2]]['team'] . + '||t1=' . $this->users[$this->uids[$u1]]['team'] . + '||login1=' . $this->users[$this->uids[$u1]]['login2'] . + '||login2=' . $this->users[$this->uids[$u2]]['login2']; + + $arr = [ 'text' => $text, - 'time' => time(), 'battle' => $this->info['id'], - 'id_hod' => ($this->hodID + $hodID), + 'id_hod' => $this->hodID + $hodID, 'vars' => $vLog, 'type' => 1, ]; - $this->add_log($mas); + $this->add_log($arr); } //Расчет контрудара игроков @@ -3792,7 +1482,7 @@ class Battle //Добавляем статистику - public function priemYronSave($u1, $u2, $yron, $type) + public function priemYronSave($u1, $u2, $yron, $type): void { //$type 0 - урон , 1 - хил @@ -3867,30 +1557,31 @@ class Battle ); } - public function testUserInfoBattle($uid) + public function testUserInfoBattle($uid): void { global $u; - if (!isset($this->uids[$uid])) { - //Заносим данные об игроке снова (видимо он погиб и его стерло с инфо) - if (!isset($this->uids[$uid])) { - $this->uids[$uid] = count($this->users); - } - $this->users[$this->uids[$uid]] = mysql_fetch_array( - mysql_query( - 'SELECT - - `u`.`id`,`u`.`login`,`u`.`login2`,`u`.`online`,`u`.`admin`,`u`.`city`,`u`.`cityreg`,`u`.`align`,`u`.`align_lvl`,`u`.`align_exp`,`u`.`clan`, - `u`.`level`,`u`.`money`,`u`.`money3`,`u`.`money2`,`u`.`money4`,`u`.`battle`,`u`.`sex`,`u`.`obraz`,`u`.`win`,`u`.`win_t`, - `u`.`lose`,`u`.`lose_t`,`u`.`nich`,`u`.`timeMain`,`u`.`invis`,`u`.`bot_id`,`u`.`animal`,`u`.`type_pers`, - `u`.`notrhod`,`u`.`bot_room`,`u`.`inUser`,`u`.`inTurnir`,`u`.`inTurnirnew`,`u`.`stopexp`,`u`.`real`, - - `st`.* - - FROM `users` AS `u` LEFT JOIN `stats` AS `st` ON (`u`.`id` = `st`.`id`) WHERE `u`.`id` = "' . $uid . '" LIMIT 1' - ) - ); - $this->stats[$this->uids[$uid]] = $u->getStats($this->users[$this->uids[$uid]], 0, 0, false, false, true); + if (isset($this->uids[$uid])) { + return; } + + //Заносим данные об игроке снова (видимо он погиб и его стерло с инфо) + if (!isset($this->uids[$uid])) { + $this->uids[$uid] = count($this->users); + } + $this->users[$this->uids[$uid]] = mysql_fetch_array( + mysql_query( + 'SELECT + `u`.`id`,`u`.`login`,`u`.`login2`,`u`.`online`,`u`.`admin`,`u`.`city`,`u`.`cityreg`,`u`.`align`,`u`.`align_lvl`,`u`.`align_exp`,`u`.`clan`, + `u`.`level`,`u`.`money`,`u`.`money3`,`u`.`money2`,`u`.`money4`,`u`.`battle`,`u`.`sex`,`u`.`obraz`,`u`.`win`,`u`.`win_t`, + `u`.`lose`,`u`.`lose_t`,`u`.`nich`,`u`.`timeMain`,`u`.`invis`,`u`.`bot_id`,`u`.`animal`,`u`.`type_pers`, + `u`.`notrhod`,`u`.`bot_room`,`u`.`inUser`,`u`.`inTurnir`,`u`.`inTurnirnew`,`u`.`stopexp`,`u`.`real`, + `st`.* + FROM `users` AS `u` LEFT JOIN `stats` AS `st` ON (`u`.`id` = `st`.`id`) WHERE `u`.`id` = "' . $uid . '" LIMIT 1' + ) + ); + $stats = new Stats($u); + $this->stats[$this->uids[$uid]] = $stats->getStats(); //getStats($this->users[$this->uids[$uid]]) + //fixme много чего повторно берется } //Добавляем статистику ударов @@ -3948,7 +1639,7 @@ class Battle //Добавляем размены в лог - public function addNewStat($stat) + public function addNewStat($stat): void { if (isset($stat[1])) { mysql_query( @@ -4170,20 +1861,22 @@ class Battle public function weaponAt22($item, $st): array { - $min = 0; - $max = 0; - if (isset($item['id'])) { - $itm = Helper\Conversion::dataStringToArray($item['data']); - //начинаем расчет урона - $min = $itm['sv_yron_min'] + $itm['yron_min'] + $st['minAtack']; - $max = $itm['sv_yron_max'] + $itm['yron_max'] + $st['maxAtack']; + if (!isset($item['id'])) { + return [0, 0]; } - return [$min, $max]; + + $itm = Conversion::dataStringToArray($item['data']); + + //начинаем расчет урона + return [ + $itm['sv_yron_min'] + $itm['yron_min'] + $st['minAtack'], + $itm['sv_yron_max'] + $itm['yron_max'] + $st['maxAtack'], + ]; } //Считаем урон - public function autoSmena() + public function autoSmena(): void { global $u; $ms = []; @@ -4247,40 +1940,36 @@ class Battle //Добавляем новую статистику игрока - public function smena($uid, $auto = false, $lastdie = false) + public function smena($uid, $auto = false, $lastdie = false): int|string { global $u; - if ((!$auto && $u->info['smena'] > 0) || $auto) { - if ($this->stats[$this->uids[$u->info['id']]]['hpNow'] >= 1) { - if (isset($this->uids[$uid]) && $uid != $u->info['id'] && $this->users[$this->uids[$uid]]['team'] != $this->users[$this->uids[$u->info['id']]]['team']) { - if (!isset($this->ga[$u->info['id']][$uid]) || $lastdie) { - if (ceil($this->stats[$this->uids[$uid]]['hpNow']) >= 1) { - //меняем противника - if (!$auto) { - $u->info['smena']--; - } - mysql_query( - 'UPDATE `stats` SET `enemy` = "' . $uid . '",`smena` = "' . $u->info['smena'] . '" WHERE `id` = "' . $u->info['id'] . '" LIMIT 1' - ); - $u->info['enemy'] = $uid; - $this->users[$this->uids[$uid]]['smena'] = $u->info['smena']; - $this->users[$this->uids[$u->info['id']]]['enemy'] = $uid; - return 1; - } else { - return 'Нельзя сменить, противник уже мертв'; - } - } else { - return 'Нельзя сменить на выбранную цель!'; - } - } else { - return 'Нельзя сменить на выбранную цель []'; - } - } else { - return 'Для вас поединок закончен, ожидайте пока завершат другие...'; - } - } else { + + if (($auto || $u->info['smena'] <= 0) && !$auto) { return 'У вас закончились смены противника'; } + if ($this->stats[$this->uids[$u->info['id']]]['hpNow'] < 1) { + return 'Для вас поединок закончен, ожидайте пока завершат другие...'; + } + if (!isset($this->uids[$uid]) || $uid == $u->info['id'] || $this->users[$this->uids[$uid]]['team'] == $this->users[$this->uids[$u->info['id']]]['team']) { + return 'Нельзя сменить на выбранную цель []'; + } + if (isset($this->ga[$u->info['id']][$uid]) && !$lastdie) { + return 'Нельзя сменить на выбранную цель!'; + } + if (ceil($this->stats[$this->uids[$uid]]['hpNow']) < 1) { + return 'Нельзя сменить, противник уже мертв'; + } + + //меняем противника + if (!$auto) { + $u->info['smena']--; + } + Db::sql('update stats set enemy = ?, smena = ? where id = ?', [$uid, $u->info['smena'], $u->info['id']]); + + $u->info['enemy'] = $uid; + $this->users[$this->uids[$uid]]['smena'] = $u->info['smena']; + $this->users[$this->uids[$u->info['id']]]['enemy'] = $uid; + return 1; } //Проверяем приемы @@ -4343,10 +2032,10 @@ class Battle if ($pl['out1'] == 0 && $pl['out2'] == 0) { //Может разменяться только тот кто бил if ($pl['uid1'] == $u->info['id'] || $pl['uid2'] == $u->info['id']) { - $this->addNewAtack(); + $this->addNewAtack($u); } } else { - $this->addNewAtack(); + $this->addNewAtack($u); } } //тест, бот делает удары @@ -4360,89 +2049,87 @@ class Battle } else { $tnbot = time() + rand(1, 2); } - if ($this->users[$j]['timeGo'] < time() && $this->users[$this->uids[$bot]]['timeGo'] < time()) { - if ($this->users[$j]['hpNow'] >= 1 && $this->users[$this->uids[$bot]]['hpNow'] >= 1 && $this->users[$this->uids[$bot]]['team'] != $this->users[$j]['team']) { - if (isset($this->users[$j]) && $this->stats[$j]['hpNow'] >= 1 && $this->stats[$this->uids[$bot]]['hpNow'] >= 1 && !isset($this->ga[$bot][$this->users[$j]['id']]) && !isset($this->ag[$bot][$this->users[$j]['id']]) && $this->users[$j]['id'] != $bot && $this->users[$j]['team'] != $this->users[$this->uids[$bot]]['team']) { - if ($this->users[$j]['timeGo'] < time() && $this->users[$this->uids[$bot]]['timeGo'] < time()) { - $this->botAtack($this->users[$j]['id'], $bot, 1); + if ($this->users[$j]['timeGo'] < time() && $this->users[$this->uids[$bot]]['timeGo'] < time( + ) && $this->users[$j]['hpNow'] >= 1 && $this->users[$this->uids[$bot]]['hpNow'] >= 1 && $this->users[$this->uids[$bot]]['team'] != $this->users[$j]['team']) { + if (isset($this->users[$j]) && $this->stats[$j]['hpNow'] >= 1 && $this->stats[$this->uids[$bot]]['hpNow'] >= 1 && !isset($this->ga[$bot][$this->users[$j]['id']]) && !isset($this->ag[$bot][$this->users[$j]['id']]) && $this->users[$j]['id'] != $bot && $this->users[$j]['team'] != $this->users[$this->uids[$bot]]['team']) { + if ($this->users[$j]['timeGo'] < time() && $this->users[$this->uids[$bot]]['timeGo'] < time()) { + $this->botAtack($this->users[$j]['id'], $bot, 1); + mysql_query( + 'UPDATE `stats` SET `timeGo` = "' . $tnbot . '" WHERE `id` = "' . $this->users[$this->uids[$bot]]['id'] . '" LIMIT 1' + ); + } + } elseif (isset($this->users[$i]) && $this->users[$i]['bot'] > 0 && $this->stats[$i]['hpNow'] >= 1 && $this->stats[$this->uids[$bot]]['hpNow'] >= 1 && $this->users[$i]['id'] != $bot && $this->users[$i]['team'] != $this->users[$this->uids[$bot]]['team']) { + if ($this->users[$j]['timeGo'] < time() && $this->users[$this->uids[$bot]]['timeGo'] < time() && $this->botAct($bot)) { + if (!isset($this->ga[$bot][$this->users[$i]['id']]) && $this->users[$this->uids[$bot]]['timeGo'] < time() && !isset($this->ag[$bot][$this->users[$i]['id']])) { + $this->botAtack($this->users[$i]['id'], $bot, 1); + mysql_query( + 'UPDATE `stats` SET `timeGo` = "' . $tnbot . '" WHERE `id` = "' . $this->users[$this->uids[$bot]]['id'] . '" LIMIT 1' + ); + } elseif (!isset($this->ag[$bot][$this->users[$i]['id']]) && isset($this->ga[$bot][$this->users[$i]['id']]) && $this->users[$this->uids[$bot]]['timeGo'] < time()) { + $this->botAtack($bot, $this->users[$i]['id'], 1); mysql_query( 'UPDATE `stats` SET `timeGo` = "' . $tnbot . '" WHERE `id` = "' . $this->users[$this->uids[$bot]]['id'] . '" LIMIT 1' ); } - } elseif (isset($this->users[$i]) && $this->users[$i]['bot'] > 0 && $this->stats[$i]['hpNow'] >= 1 && $this->stats[$this->uids[$bot]]['hpNow'] >= 1 && $this->users[$i]['id'] != $bot && $this->users[$i]['team'] != $this->users[$this->uids[$bot]]['team']) { - if ($this->users[$j]['timeGo'] < time() && $this->users[$this->uids[$bot]]['timeGo'] < time() && $this->botAct($bot)) { - if (!isset($this->ga[$bot][$this->users[$i]['id']]) && $this->users[$this->uids[$bot]]['timeGo'] < time() && !isset($this->ag[$bot][$this->users[$i]['id']])) { - $this->botAtack($this->users[$i]['id'], $bot, 1); - mysql_query( - 'UPDATE `stats` SET `timeGo` = "' . $tnbot . '" WHERE `id` = "' . $this->users[$this->uids[$bot]]['id'] . '" LIMIT 1' - ); - } elseif (!isset($this->ag[$bot][$this->users[$i]['id']]) && isset($this->ga[$bot][$this->users[$i]['id']]) && $this->users[$this->uids[$bot]]['timeGo'] < time()) { - $this->botAtack($bot, $this->users[$i]['id'], 1); + } + } else { + //Удары между ботами + if ($this->users[$j]['timeGo'] < time() && $this->users[$this->uids[$bot]]['timeGo'] < time( + ) && $this->users[$j]['hpNow'] >= 1 && $this->users[$this->uids[$bot]]['hpNow'] >= 1) { + $this->atacks[$this->ga[$bot][$this->users[$j]['id']]]['a1'] = rand( + 1, 5 + ) . '' . rand( + 1, + 5 + ) . rand(1, 5) . rand(1, 5) . rand(1, 5); + $this->atacks[$this->ga[$bot][$this->users[$j]['id']]]['b1'] = rand(1, 5); + $this->atacks[$this->ga[$bot][$this->users[$j]['id']]]['a2'] = rand( + 1, 5 + ) . '' . rand( + 1, + 5 + ) . rand(1, 5) . rand(1, 5) . rand(1, 5); + $this->atacks[$this->ga[$bot][$this->users[$j]['id']]]['b2'] = rand(1, 5); + $this->atacks[$this->ag[$bot][$this->users[$j]['id']]]['a1'] = rand( + 1, 5 + ) . '' . rand( + 1, + 5 + ) . rand(1, 5) . rand(1, 5) . rand(1, 5); + $this->atacks[$this->ag[$bot][$this->users[$j]['id']]]['b1'] = rand(1, 5); + $this->atacks[$this->ag[$bot][$this->users[$j]['id']]]['a2'] = rand( + 1, 5 + ) . '' . rand( + 1, + 5 + ) . rand(1, 5) . rand(1, 5) . rand(1, 5); + $this->atacks[$this->ag[$bot][$this->users[$j]['id']]]['b2'] = rand(1, 5); + if (isset($this->ga[$bot][$this->users[$j]['id']]) && $this->users[$j]['bot'] > 0) { + if ($this->users[$j]['timeGo'] < time() && $this->users[$this->uids[$bot]]['timeGo'] < time()) { + $tnbot = time() + rand(3, 7); + if ($this->info['type'] == 329) { // тестовый бой + $tnbot = time() - 1; + } + $this->startAtack($this->ga[$bot][$this->users[$j]['id']]); + $this->users[$this->uids[$bot]]['timeGo'] = $tnbot; mysql_query( 'UPDATE `stats` SET `timeGo` = "' . $tnbot . '" WHERE `id` = "' . $this->users[$this->uids[$bot]]['id'] . '" LIMIT 1' ); } - } - } else { - //Удары между ботами - if ($this->users[$j]['timeGo'] < time() && $this->users[$this->uids[$bot]]['timeGo'] < time( - ) && $this->users[$j]['hpNow'] >= 1 && $this->users[$this->uids[$bot]]['hpNow'] >= 1) { - $this->atacks[$this->ga[$bot][$this->users[$j]['id']]]['a1'] = rand( - 1, 5 - ) . '' . rand( - 1, - 5 - ) . rand(1, 5) . rand(1, 5) . rand(1, 5); - $this->atacks[$this->ga[$bot][$this->users[$j]['id']]]['b1'] = rand(1, 5); - $this->atacks[$this->ga[$bot][$this->users[$j]['id']]]['a2'] = rand( - 1, 5 - ) . '' . rand( - 1, - 5 - ) . rand(1, 5) . rand(1, 5) . rand(1, 5); - $this->atacks[$this->ga[$bot][$this->users[$j]['id']]]['b2'] = rand(1, 5); - $this->atacks[$this->ag[$bot][$this->users[$j]['id']]]['a1'] = rand( - 1, 5 - ) . '' . rand( - 1, - 5 - ) . rand(1, 5) . rand(1, 5) . rand(1, 5); - $this->atacks[$this->ag[$bot][$this->users[$j]['id']]]['b1'] = rand(1, 5); - $this->atacks[$this->ag[$bot][$this->users[$j]['id']]]['a2'] = rand( - 1, 5 - ) . '' . rand( - 1, - 5 - ) . rand(1, 5) . rand(1, 5) . rand(1, 5); - $this->atacks[$this->ag[$bot][$this->users[$j]['id']]]['b2'] = rand(1, 5); - if (isset($this->ga[$bot][$this->users[$j]['id']]) && $this->users[$j]['bot'] > 0) { - if ($this->users[$j]['timeGo'] < time() && $this->users[$this->uids[$bot]]['timeGo'] < time()) { - $tnbot = time() + rand(3, 7); - if ($this->info['type'] == 329) { // тестовый бой - $tnbot = time() - 1; - } - $this->startAtack($this->ga[$bot][$this->users[$j]['id']]); - $this->users[$this->uids[$bot]]['timeGo'] = $tnbot; - mysql_query( - 'UPDATE `stats` SET `timeGo` = "' . $tnbot . '" WHERE `id` = "' . $this->users[$this->uids[$bot]]['id'] . '" LIMIT 1' - ); - } - } elseif (isset($this->ag[$bot][$this->users[$j]['id']]) && $this->users[$j]['bot'] > 0) { - if ($this->users[$this->uids[$bot]]['timeGo'] < time() && $this->users[$j]['timeGo'] < time()) { - $this->startAtack($this->ag[$bot][$this->users[$j]['id']]); - $tnbot = time() + rand(3, 7); - if ($this->info['type'] == 329) { // тестовый бой - $tnbot = time() - 1; - } - $this->users[$this->uids[$bot]]['timeGo'] = $tnbot; - mysql_query( - 'UPDATE `stats` SET `timeGo` = "' . $tnbot . '" WHERE `id` = "' . $this->users[$this->uids[$bot]]['id'] . '" LIMIT 1' - ); + } elseif (isset($this->ag[$bot][$this->users[$j]['id']]) && $this->users[$j]['bot'] > 0) { + if ($this->users[$this->uids[$bot]]['timeGo'] < time() && $this->users[$j]['timeGo'] < time()) { + $this->startAtack($this->ag[$bot][$this->users[$j]['id']]); + $tnbot = time() + rand(3, 7); + if ($this->info['type'] == 329) { // тестовый бой + $tnbot = time() - 1; } + $this->users[$this->uids[$bot]]['timeGo'] = $tnbot; + mysql_query( + 'UPDATE `stats` SET `timeGo` = "' . $tnbot . '" WHERE `id` = "' . $this->users[$this->uids[$bot]]['id'] . '" LIMIT 1' + ); } } } - } else { } } $j++; @@ -5757,7 +3444,7 @@ class Battle } break; } - return $this->getChanse($rval) ? 1 : 0; + return Helper::getChanse($rval) ? 1 : 0; } //Сохранение данные @@ -6097,9 +3784,7 @@ class Battle } return $at; } - //====================== - //Добавляем в лог public function testRazmenblock1($id, $uid1, $uid2, $atack): bool { @@ -7336,15 +5021,15 @@ class Battle /** * Добавляем опыт \ нанесенный урон. * Кривовсрато, на переделку. - * @param $id - * @param $y - * @param $id1 - * @param $id2 - * @param $mgregen - * @param $nobattle_uron + * @param $id + * @param $y + * @param $id1 + * @param $id2 + * @param bool $mgregen + * @param bool $nobattle_uron * @return void */ - public function takeExp($id, $y, $id1, $id2, $mgregen = false, $nobattle_uron = false) + public function takeExp($id, $y, $id1, $id2, bool $mgregen = false, bool $nobattle_uron = false): void { global $u; if (isset($this->users[$this->uids[$id]])) { @@ -7444,34 +5129,33 @@ class Battle if ($this->stats[$this->uids[$id1]]['notactic'] != 1) { if ($s2['hpAll'] <= 1000) { if ($this->stats[$this->uids[$id2]]['this_animal'] == 0) { - $this->users[$this->uids[$id1]]['tactic6'] += round( - 0.1 * (floor($y) / $s2['hpAll'] * 100), - 10 - ); + $this->users[$this->uids[$id1]]['tactic6'] += + round(0.1 * (floor($y) / $s2['hpAll'] * 100), 10); } else { - $this->users[$this->uids[$id1]]['tactic6'] += round( - 0.1 * (floor($y) / $s2['hpAll'] * 100), - 10 - ) / 3; + $this->users[$this->uids[$id1]]['tactic6'] += + round(0.1 * (floor($y) / $s2['hpAll'] * 100), 10) / 3; } } else { if ($this->stats[$this->uids[$id2]]['this_animal'] == 0) { - $this->users[$this->uids[$id1]]['tactic6'] += round(0.1 * (floor($y) / 1000 * 100), 10); + $this->users[$this->uids[$id1]]['tactic6'] += + round(0.1 * (floor($y) / 1000 * 100), 10); } else { - $this->users[$this->uids[$id1]]['tactic6'] += round(0.1 * (floor($y) / 1000 * 100), 10) / 3; + $this->users[$this->uids[$id1]]['tactic6'] += + round(0.1 * (floor($y) / 1000 * 100), 10) / 3; } } } } Db::sql( - 'update stats set last_hp = ?, tactic6 = ?, battle_yron = ?, battle_exp = ? where id = ?', [ - $this->users[$this->uids[$id1]]['last_hp'], - $this->users[$this->uids[$id1]]['tactic6'], - $this->users[$this->uids[$id1]]['battle_yron'], - $this->users[$this->uids[$id1]]['battle_exp'], - (int)$id1, - ] + 'update stats set last_hp = ?, tactic6 = ?, battle_yron = ?, battle_exp = ? where id = ?', + [ + $this->users[$this->uids[$id1]]['last_hp'], + $this->users[$this->uids[$id1]]['tactic6'], + $this->users[$this->uids[$id1]]['battle_yron'], + $this->users[$this->uids[$id1]]['battle_exp'], + (int)$id1, + ] ); $this->stats[$this->uids[$id1]]['battle_exp'] = $this->users[$this->uids[$id1]]['battle_exp']; @@ -7492,10 +5176,11 @@ class Battle private function clearCache($uid): void { - if ($uid > 0 && !isset($this->uclearc[$uid])) { - $this->uclearc[$uid] = true; - $this->ucleari[] = $uid; + if ($uid <= 0 || isset($this->uclearc[$uid])) { + return; } + $this->uclearc[$uid] = true; + $this->ucleari[] = $uid; } private function addlogRazmen($id, $at): bool @@ -7640,8 +5325,6 @@ class Battle $this->atacks[$id]['uid_' . $u1 . '_t' . $at[$a]['atack'][$j][1]]++; - $this->asr($u1, $u2, $at[$a]['atack'][$j][1]); - if ($at[$a]['atack'][$j][1] == 1) { //u1 ударил обычным ударом u2 $mas['text'] .= $par['zona'] . '{u2} ' . $this->addlt($b, 1, $s2) . $this->addlt($b, 2, $s2) . $this->addlt($a, 3, $s1) . @@ -7827,11 +5510,7 @@ class Battle } else { if ($btlstatus[0] == 0) { //Обычный поединок - $rtngwin = [1, 2, 3, 5, 10, 20, 40, 80, 160]; - if ($this->info['razdel'] == 5) { - //не хаот - $rtnglos = [0, 0, 0, -1, -2, -5, -10, -20, -40]; - } else { + if ($this->info['razdel'] != 5) { //хаот $rtnglos = [0, 0, 0, 0, 0, 0, 0, 0, 0]; } @@ -7908,20 +5587,6 @@ class Battle return true; } - //Смена противника - - private function asr($u1, $u2, $type): void - { - mysql_query( - 'INSERT INTO battle_static ( - `uid1`,`uid2`,`hod`,`type`,`time`,`bid` - ) VALUES ( - "' . $u1 . '","' . $u2 . '","' . $this->hodID . '","' . $type . '","' . time() . '","' . $this->info['id'] . '" - )' - ); - } - - //авто-смена противника //ТУТ баг выбора public function addlt($a, $id, $s, $rnd = null): string { @@ -7934,94 +5599,94 @@ class Battle //Действия бота (атака) - public function spaCheck($u1) + public function spaCheck($u1): void { - if ($this->stats[$this->uids[$u1]]['hpNow'] < 1) { - mysql_query('DELETE FROM `battle_act` WHERE `uid1` = "' . $u1 . '" OR `uid2` = "' . $u1 . '"'); - if ($this->stats[$this->uids[$u1]]['spasenie'] > 0 && $this->users[$this->uids[$u1]]['tactic7'] >= 25) { - //Свиток спасения - if ($this->stats[$this->uids[$u1]]['s7'] > 49 && $this->stats[$this->uids[$u1]]['s7'] < 75) { - //Даем призрачку - mysql_query( - "INSERT INTO `eff_users` - (`id_eff`, `uid`, `name`, `data`, `overType`, `timeUse`, `timeAce`, `user_use`, `delete`, `v1`, `v2`, `img2`, `x`, `hod`, `bj`, `sleeptime`, `no_Ace`, `file_finish`, `tr_life_user`, `deactiveTime`, `deactiveLast`, `mark`, `bs`) VALUES - (22, '" . $u1 . "', 'Призрачная защита', 'add_zmproc=75|add_zaproc=75', 0, 77, 0, '" . $u1 . "', 0, 'priem', 141, 'spirit_block25.gif', 1, 1, '0', 0, 0, '', 0, 0, 0, 0, 0);" - ); - $this->stats[$this->uids[$u1]]['hpNow'] = floor($this->stats[$this->uids[$u1]]['hpAll'] * 0.5); - $this->stats[$this->uids[$u1]]['mpNow'] = floor($this->stats[$this->uids[$u1]]['mpAll'] * 0.5); - } elseif ($this->stats[$this->uids[$u1]]['s7'] > 74 && $this->stats[$this->uids[$u1]]['s7'] < 100) { - //Абсолютная защита - mysql_query( - "INSERT INTO `eff_users` - (`id_eff`, `uid`, `name`, `data`, `overType`, `timeUse`, `timeAce`, `user_use`, `delete`, `v1`, `v2`, `img2`, `x`, `hod`, `bj`, `sleeptime`, `no_Ace`, `file_finish`, `tr_life_user`, `deactiveTime`, `deactiveLast`, `mark`, `bs`) VALUES - (22, '" . $u1 . "', 'Абсолютная защита', 'add_zmproc=100|add_zaproc=100', 0, 77, 0, '" . $u1 . "', 0, 'priem', 358, 'block_absolute.gif', 1, 1, '0', 0, 0, '', 0, 0, 0, 0, 0);" - ); - $this->stats[$this->uids[$u1]]['hpNow'] = floor($this->stats[$this->uids[$u1]]['hpAll'] * 0.75); - $this->stats[$this->uids[$u1]]['mpNow'] = floor($this->stats[$this->uids[$u1]]['mpAll'] * 0.75); - } elseif ($this->stats[$this->uids[$u1]]['s7'] > 99) { - //Абсолютная защита x2 - mysql_query( - "INSERT INTO `eff_users` - (`id_eff`, `uid`, `name`, `data`, `overType`, `timeUse`, `timeAce`, `user_use`, `delete`, `v1`, `v2`, `img2`, `x`, `hod`, `bj`, `sleeptime`, `no_Ace`, `file_finish`, `tr_life_user`, `deactiveTime`, `deactiveLast`, `mark`, `bs`) VALUES - (22, '" . $u1 . "', 'Защита Мироздателя', 'add_zmproc=100|add_zaproc=100', 0, 77, 0, '" . $u1 . "', 0, 'priem', 358, 'wis_white_shield.gif', 1, 2, '0', 0, 0, '', 0, 0, 0, 0, 0);" - ); - $this->stats[$this->uids[$u1]]['hpNow'] = floor($this->stats[$this->uids[$u1]]['hpAll']); - $this->stats[$this->uids[$u1]]['mpNow'] = floor($this->stats[$this->uids[$u1]]['mpAll']); - } - - if ($this->stats[$this->uids[$u1]]['hpNow'] < 1) { - $this->stats[$this->uids[$u1]]['hpNow'] = 1; - } - if ($this->stats[$this->uids[$u1]]['mpNow'] < 1) { - $this->stats[$this->uids[$u1]]['mpNow'] = 1; - } - if ($this->stats[$this->uids[$u1]]['hpNow'] > $this->stats[$this->uids[$u1]]['hpAll']) { - $this->stats[$this->uids[$u1]]['hpNow'] = floor($this->stats[$this->uids[$u1]]['hpAll']); - } - if ($this->stats[$this->uids[$u1]]['mpNow'] > $this->stats[$this->uids[$u1]]['mpAll']) { - $this->stats[$this->uids[$u1]]['mpNow'] = floor($this->stats[$this->uids[$u1]]['mpAll']); - } + if ($this->stats[$this->uids[$u1]]['hpNow'] >= 1) { + return; + } + mysql_query('DELETE FROM `battle_act` WHERE `uid1` = "' . $u1 . '" OR `uid2` = "' . $u1 . '"'); + if ($this->stats[$this->uids[$u1]]['spasenie'] > 0 && $this->users[$this->uids[$u1]]['tactic7'] >= 25) { + //Свиток спасения + if ($this->stats[$this->uids[$u1]]['s7'] > 49 && $this->stats[$this->uids[$u1]]['s7'] < 75) { + //Даем призрачку mysql_query( - 'DELETE FROM `eff_users` WHERE `uid` = "' . $u1 . '" AND `id_eff` = 22 AND `v1` = "priem" AND `v2` = 324' + "INSERT INTO `eff_users` + (`id_eff`, `uid`, `name`, `data`, `overType`, `timeUse`, `timeAce`, `user_use`, `delete`, `v1`, `v2`, `img2`, `x`, `hod`, `bj`, `sleeptime`, `no_Ace`, `file_finish`, `tr_life_user`, `deactiveTime`, `deactiveLast`, `mark`, `bs`) VALUES + (22, '" . $u1 . "', 'Призрачная защита', 'add_zmproc=75|add_zaproc=75', 0, 77, 0, '" . $u1 . "', 0, 'priem', 141, 'spirit_block25.gif', 1, 1, '0', 0, 0, '', 0, 0, 0, 0, 0);" ); + $this->stats[$this->uids[$u1]]['hpNow'] = floor($this->stats[$this->uids[$u1]]['hpAll'] * 0.5); + $this->stats[$this->uids[$u1]]['mpNow'] = floor($this->stats[$this->uids[$u1]]['mpAll'] * 0.5); + } elseif ($this->stats[$this->uids[$u1]]['s7'] > 74 && $this->stats[$this->uids[$u1]]['s7'] < 100) { + //Абсолютная защита mysql_query( - 'UPDATE `stats` SET `hpNow` = "' . $this->stats[$this->uids[$u1]]['hpNow'] . '",`mpNow` = "' . $this->stats[$this->uids[$u1]]['mpNow'] . '", `tactic7` = `tactic7` - 25 WHERE `id` = "' . $u1 . '" LIMIT 1' + "INSERT INTO `eff_users` + (`id_eff`, `uid`, `name`, `data`, `overType`, `timeUse`, `timeAce`, `user_use`, `delete`, `v1`, `v2`, `img2`, `x`, `hod`, `bj`, `sleeptime`, `no_Ace`, `file_finish`, `tr_life_user`, `deactiveTime`, `deactiveLast`, `mark`, `bs`) VALUES + (22, '" . $u1 . "', 'Абсолютная защита', 'add_zmproc=100|add_zaproc=100', 0, 77, 0, '" . $u1 . "', 0, 'priem', 358, 'block_absolute.gif', 1, 1, '0', 0, 0, '', 0, 0, 0, 0, 0);" ); - $mas['text'] = '{tm1} ' . $this->stats[$this->uids[$u1]]['login'] . ' убит...' . $this->stats[$this->uids[$u1]]['login'] . ' был спасен. '; - $this->priemAddLog( - $id, 1, 2, $u->info['id'], $u1, - ' ', - $mas['text'], - ($this->hodID + 0) + $this->stats[$this->uids[$u1]]['hpNow'] = floor($this->stats[$this->uids[$u1]]['hpAll'] * 0.75); + $this->stats[$this->uids[$u1]]['mpNow'] = floor($this->stats[$this->uids[$u1]]['mpAll'] * 0.75); + } elseif ($this->stats[$this->uids[$u1]]['s7'] > 99) { + //Абсолютная защита x2 + mysql_query( + "INSERT INTO `eff_users` + (`id_eff`, `uid`, `name`, `data`, `overType`, `timeUse`, `timeAce`, `user_use`, `delete`, `v1`, `v2`, `img2`, `x`, `hod`, `bj`, `sleeptime`, `no_Ace`, `file_finish`, `tr_life_user`, `deactiveTime`, `deactiveLast`, `mark`, `bs`) VALUES + (22, '" . $u1 . "', 'Защита Мироздателя', 'add_zmproc=100|add_zaproc=100', 0, 77, 0, '" . $u1 . "', 0, 'priem', 358, 'wis_white_shield.gif', 1, 2, '0', 0, 0, '', 0, 0, 0, 0, 0);" ); - } else { - if (isset($this->stats[$this->uids[$u1]]['login'])) { - mysql_query('UPDATE `stats` SET `hpNow` = "0",`mpNow` = "0" WHERE `id` = "' . $u1 . '" LIMIT 1'); - $this->stats[$this->uids[$u1]]['hpNow'] = 0; - $this->users[$this->uids[$u1]]['hpNow'] = 0; - $mas['text'] = '{tm1} ' . $this->stats[$this->uids[$u1]]['login'] . ' погиб.'; - $this->priemAddLog( - $id, 1, 2, $u->info['id'], $u1, - ' ', - $mas['text'], - ($this->hodID + 1) - //Удаляем размен из базы //ТУТ возможен лаг удаления - ); - mysql_query( - 'DELETE FROM `battle_act` WHERE `uid1` = "' . $this->stats[$this->uids[$u1]]['id'] . '" OR `uid2` = "' . $this->stats[$this->uids[$u1]]['id'] . '" OR `uid2` = "-' . $this->stats[$this->uids[$u1]]['id'] . '"' - ); - mysql_query( - 'DELETE FROM `eff_users` WHERE `uid` = "' . $this->stats[$this->uids[$u1]]['id'] . '" AND `v1` = "priem" AND `delete` =0' - ); - } + $this->stats[$this->uids[$u1]]['hpNow'] = floor($this->stats[$this->uids[$u1]]['hpAll']); + $this->stats[$this->uids[$u1]]['mpNow'] = floor($this->stats[$this->uids[$u1]]['mpAll']); } + + if ($this->stats[$this->uids[$u1]]['hpNow'] < 1) { + $this->stats[$this->uids[$u1]]['hpNow'] = 1; + } + if ($this->stats[$this->uids[$u1]]['mpNow'] < 1) { + $this->stats[$this->uids[$u1]]['mpNow'] = 1; + } + if ($this->stats[$this->uids[$u1]]['hpNow'] > $this->stats[$this->uids[$u1]]['hpAll']) { + $this->stats[$this->uids[$u1]]['hpNow'] = floor($this->stats[$this->uids[$u1]]['hpAll']); + } + if ($this->stats[$this->uids[$u1]]['mpNow'] > $this->stats[$this->uids[$u1]]['mpAll']) { + $this->stats[$this->uids[$u1]]['mpNow'] = floor($this->stats[$this->uids[$u1]]['mpAll']); + } + + mysql_query( + 'DELETE FROM `eff_users` WHERE `uid` = "' . $u1 . '" AND `id_eff` = 22 AND `v1` = "priem" AND `v2` = 324' + ); + mysql_query( + 'UPDATE `stats` SET `hpNow` = "' . $this->stats[$this->uids[$u1]]['hpNow'] . '",`mpNow` = "' . $this->stats[$this->uids[$u1]]['mpNow'] . '", `tactic7` = `tactic7` - 25 WHERE `id` = "' . $u1 . '" LIMIT 1' + ); + $mas['text'] = '{tm1} ' . $this->stats[$this->uids[$u1]]['login'] . ' убит...' . $this->stats[$this->uids[$u1]]['login'] . ' был спасен. '; + $this->priemAddLog( + $id, 1, 2, $u->info['id'], $u1, + ' ', + $mas['text'], + ($this->hodID + 0) + ); + } elseif (isset($this->stats[$this->uids[$u1]]['login'])) { + mysql_query('UPDATE `stats` SET `hpNow` = "0",`mpNow` = "0" WHERE `id` = "' . $u1 . '" LIMIT 1'); + $this->stats[$this->uids[$u1]]['hpNow'] = 0; + $this->users[$this->uids[$u1]]['hpNow'] = 0; + $mas['text'] = '{tm1} ' . $this->stats[$this->uids[$u1]]['login'] . ' погиб.'; + $this->priemAddLog( + $id, 1, 2, $u->info['id'], $u1, + ' ', + $mas['text'], + ($this->hodID + 1) + //Удаляем размен из базы //ТУТ возможен лаг удаления + ); + mysql_query( + 'DELETE FROM `battle_act` WHERE `uid1` = "' . $this->stats[$this->uids[$u1]]['id'] . '" OR `uid2` = "' . $this->stats[$this->uids[$u1]]['id'] . '" OR `uid2` = "-' . $this->stats[$this->uids[$u1]]['id'] . '"' + ); + mysql_query( + 'DELETE FROM `eff_users` WHERE `uid` = "' . $this->stats[$this->uids[$u1]]['id'] . '" AND `v1` = "priem" AND `delete` =0' + ); } } //Проверяем удары, приемы, свитки, зверей - public function priemAddLog($id, $a, $b, $u1, $u2, $prm, $text, $hodID, $tm1 = 0, $tm2 = 0) + public function priemAddLog($id, $a, $b, $u1, $u2, $prm, $text, $hodID, $tm1 = 0, $tm2 = 0): void { $time = time(); if ($tm1 == 0) { @@ -8048,7 +5713,6 @@ class Battle $mas = [ 'text' => $text, - 'time' => $time, 'battle' => $this->info['id'], 'id_hod' => $hodID, 'vars' => $vLog, @@ -8059,7 +5723,7 @@ class Battle //Действия бота - private function restZonb($uid1, $uid2) + private function restZonb($uid1, $uid2): void { if ($this->stnZbVs[$uid1] > 0) { $this->stats[$this->uids[$uid1]]['zonb'] = $this->stnZbVs[$uid1]; @@ -8071,29 +5735,9 @@ class Battle //получаем данные о поединке - private function save_stats($uid) + private function save_stats($uid): void { - mysql_query( - 'UPDATE `stats` SET - - `hpNow` = "' . $this->stats[$this->uids[$uid]]['hpNow'] . '", - `mpNow` = "' . $this->stats[$this->uids[$uid]]['mpNow'] . '", - `tactic1` = "' . $this->users[$this->uids[$uid]]['tactic1'] . '", - `tactic2` = "' . $this->users[$this->uids[$uid]]['tactic2'] . '", - `tactic3` = "' . $this->users[$this->uids[$uid]]['tactic3'] . '", - `tactic4` = "' . $this->users[$this->uids[$uid]]['tactic4'] . '", - `tactic5` = "' . $this->users[$this->uids[$uid]]['tactic5'] . '", - `tactic6` = "' . $this->users[$this->uids[$uid]]['tactic6'] . '", - `tactic7` = "' . $this->users[$this->uids[$uid]]['tactic7'] . '", - - `enemy` = "' . $this->users[$this->uids[$uid]]['enemy'] . '", - `battle_yron` = "' . $this->users[$this->uids[$uid]]['battle_yron'] . '", - `last_hp` = "' . $this->users[$this->uids[$uid]]['last_hp'] . '", - `battle_exp` = "' . $this->users[$this->uids[$uid]]['battle_exp'] . '", - `priems_z` = "' . $this->users[$this->uids[$uid]]['priems_z'] . '" - - WHERE `id` = "' . $uid . '" LIMIT 1' - ); + Stats::saveBattleStats($this->stats[$this->uids[$uid]], $uid); } //наносим удар противнику @@ -8217,66 +5861,88 @@ class Battle //выделяем пользователей - private function addNewAtack() + private function addNewAtack(User $u): void { - global $u; if (isset($this->ga[$u->info['id']][$u->info['enemy']])) { return; } + if ($this->stats[$this->uids[$u->info['id']]]['hpNow'] <= 0) { $this->e = 'Для вас поединок закончен, ожидайте пока завершат другие...'; return; } - $us = $this->stats[$this->uids[$u->info['id']]]; - $i = 1; - $no = 0; - while ($i <= $us['zona']) { - if ($this->uAtc['a'][$i] == 0) { - $no = 1; + $us = $this->stats[$this->uids[$u->info['id']]]; + $no = false; + + for ($j = 1; $j <= $us['zona']; $j++) { + if ($this->uAtc['a'][$j] != 0) { + continue; } - $i++; + $no = true; } + if ($this->uAtc['b'] == 0) { - $no = 1; + $no = true; } - if ($no != 0) { + + if ($no) { $this->e = 'Выберите зоны удара и блока'; + return; + } + + //наносим удар + if ($u->info['enemy'] <= 0) { + return; + } + + if (!isset($this->ga[$u->info['enemy']][$u->info['id']])) { + if ( + $this->stats[$this->uids[$u->info['id']]]['hpNow'] < 1 || + $this->stats[$this->uids[$u->info['enemy']]]['hpNow'] < 1 + ) { + return; + } + //наносим новый удар + $a = $this->uAtc['a'][1] . $this->uAtc['a'][2] . $this->uAtc['a'][3] . $this->uAtc['a'][4] . $this->uAtc['a'][5]; + $b = $this->uAtc['b']; + + Db::sql( + 'delete from battle_act where battle = ? and uid1 in (?,?) and uid2 in (?,?)', + [ + $this->info['id'], + $u->info['id'], + $u->info['enemy'], + $u->info['id'], + $u->info['enemy'], + ] + ); + Db::sql( + "insert into battle_act (battle,uid1,uid2,a1,b1,time,a2,b2,invis1,invis2) values (?,?,?,?,?,unix_timestamp(),'',0,0,0)", + [ + $this->info['id'], + $u->info['id'], + $u->info['enemy'], + $a, + $b, + ] + ); + + $this->ga[$u->info['id']][$u->info['enemy']] = Db::lastInsertId(); + } else { - //наносим удар - if ($u->info['enemy'] > 0) { - if (!isset($this->ga[$u->info['enemy']][$u->info['id']])) { - if ($this->stats[$this->uids[$u->info['id']]]['hpNow'] >= 1 && $this->stats[$this->uids[$u->info['enemy']]]['hpNow'] >= 1) { - //наносим новый удар - $a = $this->uAtc['a'][1] . $this->uAtc['a'][2] . $this->uAtc['a'][3] . $this->uAtc['a'][4] . $this->uAtc['a'][5]; - $b = $this->uAtc['b']; - mysql_query( - 'DELETE FROM `battle_act` WHERE `battle` = "' . $this->info['id'] . '" AND ((`uid2` = "' . $u->info['id'] . '" AND `uid1` = "' . $u->info['enemy'] . '") OR (`uid1` = "' . $u->info['id'] . '" AND `uid2` = "' . $u->info['enemy'] . '")) LIMIT 2' - ); - $d = mysql_query( - 'INSERT INTO `battle_act` (`battle`,`time`,`uid1`,`uid2`,`a1`,`b1`) VALUES ("' . $this->info['id'] . '","' . time( - ) . '","' . $u->info['id'] . '","' . $u->info['enemy'] . '","' . $a . '","' . $b . '")' - ); - if (!$d) { - $this->e = 'Не удалось нанести удар по противнику...'; - } else { - $this->ga[$u->info['id']][$u->info['enemy']] = mysql_insert_id(); - } - } - } else { - //отвечаем на удар противника - if ( - $this->stats[$this->uids[$u->info['id']]]['hpNow'] >= 1 && - $this->stats[$this->uids[$u->info['enemy']]]['hpNow'] >= 1 - && isset($this->atacks[$this->ga[$u->info['enemy']][$u->info['id']]]['id']) - ) { - $this->atacks[$this->ga[$u->info['enemy']][$u->info['id']]]['a2'] = $this->uAtc['a'][1] . '' . $this->uAtc['a'][2] . $this->uAtc['a'][3] . $this->uAtc['a'][4] . $this->uAtc['a'][5]; - $this->atacks[$this->ga[$u->info['enemy']][$u->info['id']]]['b2'] = $this->uAtc['b']; - $this->startAtack($this->atacks[$this->ga[$u->info['enemy']][$u->info['id']]]['id']); - } - } + //отвечаем на удар противника + if ( + $this->stats[$this->uids[$u->info['id']]]['hpNow'] >= 1 && + $this->stats[$this->uids[$u->info['enemy']]]['hpNow'] >= 1 + && isset($this->atacks[$this->ga[$u->info['enemy']][$u->info['id']]]['id']) + ) { + $this->atacks[$this->ga[$u->info['enemy']][$u->info['id']]]['a2'] = $this->uAtc['a'][1] . '' . $this->uAtc['a'][2] . $this->uAtc['a'][3] . $this->uAtc['a'][4] . $this->uAtc['a'][5]; + $this->atacks[$this->ga[$u->info['enemy']][$u->info['id']]]['b2'] = $this->uAtc['b']; + $this->startAtack($this->atacks[$this->ga[$u->info['enemy']][$u->info['id']]]['id']); } } + } //Возращаем зоны блока по умолчанию @@ -8289,7 +5955,7 @@ class Battle $r = true; $this->users[$this->uids[$uid]]['online'] = time(); User::setOnline((int)$uid); - } elseif (rand(0, 2) == 1) { + } elseif (mt_rand(0, 2) === 0) { $r = true; } } @@ -8298,11 +5964,11 @@ class Battle //проверка блока (Визуальная) - public function battleInfo($id) + public function battleInfo($id): array { $b = Db::getRow('select * from battle where id = ?', [$id]); if (!isset($b['id'])) { - return false; + return []; } $this->hodID = Db::getValue('select id_hod from battle_logs where battle = ? order by id desc limit 1', [$b['id']]); @@ -8313,314 +5979,174 @@ class Battle //проверка блока - public function addAtack() + public function addAtack(): void { global $js; - if (isset($_POST['atack'], $_POST['block'])) { - $na = ['a' => [1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0]]; - $a = explode('_', $_POST['atack']); - $i = 1; - $na['id'] = time(); - while ($i <= 5) { - if (isset($a[$i - 1])) { - $a[$i - 1] = intval(round($a[$i - 1])); - if ($a[$i - 1] >= 1 && $a[$i - 1] <= 5) { - $na['a'][$i] = $a[$i - 1]; - } else { - $na['a'][$i] = 0; - } - } - $i++; - } - $na['b'] = intval(round($_POST['block'])); - if ($na['b'] < 1 || $na['b'] > 5) { - $na['b'] = 0; - } - - $this->uAtc = $na; - $js .= 'testClearZone();'; - } else { + if (!isset($_POST['atack'], $_POST['block'])) { $this->e = 'Выберите зоны удара и блока'; + return; } + + $na = ['a' => [1 => 0, 2 => 0, 3 => 0, 4 => 0, 5 => 0]]; + $a = explode('_', $_POST['atack']); + $na['id'] = time(); + + for ($i = 1; $i <= 5; $i++) { + if (!isset($a[$i - 1])) { + continue; + } + $a[$i - 1] = intval(round($a[$i - 1])); + if ($a[$i - 1] >= 1 && $a[$i - 1] <= 5) { + $na['a'][$i] = $a[$i - 1]; + } else { + $na['a'][$i] = 0; + } + } + + $na['b'] = intval(round($_POST['block'])); + if ($na['b'] < 1 || $na['b'] > 5) { + $na['b'] = 0; + } + $this->uAtc = $na; + $js .= 'testClearZone();'; } //генерируем команды - public function teamsTake() + public function teamsTake(User $u): void { - global $u; + if ($this->info['id'] < 1) { + return; + } + + $r = ''; $rs = ''; $ts = []; $tsi = 0; - if ($this->info['id'] > 0) { - //данные о игроках в бою - $nxtlg = []; - $t = mysql_query( - 'SELECT `u`.`room`,`u`.`no_ip`,`u`.`twink`,`u`.`stopexp`,`u`.`id`,`u`.`notrhod`,`u`.`login`,`u`.`login2`,`u`.`sex`,`u`.`online`,`u`.`admin`,`u`.`align`,`u`.`align_lvl`,`u`.`align_exp`,`u`.`clan`,`u`.`level`,`u`.`battle`,`u`.`obraz`,`u`.`win`,`u`.`lose`,`u`.`nich`,`u`.`animal`,`st`.`stats`,`st`.`hpNow`,`st`.`mpNow`,`st`.`exp`,`st`.`dnow`,`st`.`team`,`st`.`battle_yron`,`st`.`battle_exp`,`st`.`enemy`,`st`.`battle_text`,`st`.`upLevel`,`st`.`timeGo`,`st`.`timeGoL`,`st`.`bot`,`st`.`lider`,`st`.`btl_cof`,`st`.`tactic1`,`st`.`tactic2`,`st`.`tactic3`,`st`.`tactic4`,`st`.`tactic5`,`st`.`tactic6`,`st`.`tactic7`,`st`.`x`,`st`.`y`,`st`.`battleEnd`,`st`.`priemslot`,`st`.`priems`,`st`.`priems_z`,`st`.`bet`,`st`.`clone`,`st`.`atack`,`st`.`bbexp`,`st`.`res_x`,`st`.`res_y`,`st`.`res_s`,`st`.`id`,`st`.`last_hp`,`st`.`last_pr`,`u`.`sex`,`u`.`money`,`u`.`bot_id`,`u`.`money3`,`u`.`money2` FROM `users` AS `u` LEFT JOIN `stats` AS `st` ON (`u`.`id` = `st`.`id`) WHERE `u`.`battle` = "' . $this->info['id'] . '"' - ); - $i = 0; - $bi = 0; - $up = ''; - if ($this->info['start2'] == 0) { - $tststrt = mysql_fetch_array( - mysql_query( - 'SELECT `id` FROM `battle` WHERE `id` = "' . $this->info['id'] . '" AND `start2` = "0" LIMIT 1' - ) - ); - if (isset($tststrt['id'])) { - mysql_query( - 'UPDATE `battle` SET `start2` = "' . time() . '" WHERE `id` = "' . $this->info['id'] . '" LIMIT 1' - ); - } else { - $this->info['start2'] = time(); - } - } - while ($pl = mysql_fetch_array($t)) { - //записываем данные - if ($pl['login2'] == '') { - $pl['login2'] = $pl['login']; - } - $this->users[$i] = $pl; - $this->uids[$pl['id']] = $i; - if ($this->info['start2'] == 0) { - mysql_query( - 'UPDATE `users` SET `notrhod` = "-1" WHERE `id` = "' . $this->users[$i]['id'] . '" LIMIT 1' - ); - $this->users[$i]['notrhod'] = -1; - } + //данные о игроках в бою + $usersInBattle = Db::getRows( + "select + room,no_ip,twink,stopexp,users.id,notrhod,login, if(login2 != '', login2, login) as login2, sex,online,admin, + align,align_lvl,align_exp,clan,level,battle,obraz,win,lose,nich,animal,stats,hpNow,mpNow,exp,dnow,team, + battle_yron,battle_exp,enemy,battle_text,upLevel,timeGo,timeGoL,bot,lider,btl_cof, + tactic1,tactic2,tactic3,tactic4,tactic5,tactic6,tactic7,x,y,battleEnd,priemslot,priems,priems_z,bet,clone, + atack,bbexp,res_x,res_y,res_s,last_hp,last_pr,sex,money,bot_id,money3,money2 + from users left join stats on users.id = stats.id where battle = ?", [$this->info['id']] + ); - if ($pl['bot'] > 0) { - $this->bots[$bi] = $pl['id']; - $this->iBots[$pl['id']] = $bi; - $bi++; - } - //записываем статы - $this->stats[$i] = $u->getStats($pl['id'], 0, 0, false, $this->cached, true); - //Заносим старт - if ($this->info['start2'] == 0) { - if (!isset($ts[$this->users[$i]['team']])) { - $tsi++; - $ts[$this->users[$i]['team']] = $tsi; - } + $i = 0; + $bi = 0; - if ($this->users[$i]['level'] <= 7) { - $this->users[$i]['tactic7'] = floor(10 / $this->stats[$i]['hpAll'] * $this->stats[$i]['hpNow']); - } elseif ($this->users[$i]['level'] == 8) { - $this->users[$i]['tactic7'] = floor(20 / $this->stats[$i]['hpAll'] * $this->stats[$i]['hpNow']); - } elseif ($this->users[$i]['level'] == 9) { - $this->users[$i]['tactic7'] = floor(30 / $this->stats[$i]['hpAll'] * $this->stats[$i]['hpNow']); - } elseif ($this->users[$i]['level'] >= 10) { - $this->users[$i]['tactic7'] = floor( - (40 + $this->stats[$i]['s7']) / $this->stats[$i]['hpAll'] * $this->stats[$i]['hpNow'] - ); - } - - if ($this->stats[$i]['s7'] > 49) { - mysql_query( - 'UPDATE `eff_users` SET `delete`="' . time() . '" WHERE `uid` = "' . $this->users[$i]['id'] . '" AND `overType` = 101 AND `delete` = 0' - ); - mysql_query( - " - INSERT INTO `eff_users` ( `id_eff`, `uid`, `name`, `data`, `overType`, `timeUse`, `timeAce`, `user_use`, `delete`, `v1`, `v2`, `img2`, `x`, `hod`, `bj`, `sleeptime`, `no_Ace`, `file_finish`, `tr_life_user`, `deactiveTime`, `deactiveLast`, `mark`, `bs`) VALUES - ( 22, '" . $this->stats[$i]['id'] . "', 'Спасение', 'add_spasenie=1', 101, 77, 0, '" . $this->stats[$i]['id'] . "', 0, 'priem', 324, 'preservation.gif', 1, -1, 'спасение', 0, 0, '', 0, 0, 0, 1, 0); - " - ); - } - - // Бафф Зверя animal_bonus - if ($this->users[$i]['animal'] > 0) { - $a = mysql_fetch_array( - mysql_query( - 'SELECT * FROM `users_animal` WHERE `uid` = "' . $this->users[$i]['id'] . '" AND `id` = "' . $this->users[$i]['animal'] . '" AND `pet_in_cage` = "0" AND `delete` = "0" LIMIT 1' - ) - ); - if (isset($a['id'])) { - if ($a['eda'] >= 1) { - $anl = mysql_fetch_array( - mysql_query( - 'SELECT `bonus` FROM `levels_animal` WHERE `type` = "' . $a['type'] . '" AND `level` = "' . $a['level'] . '" LIMIT 1' - ) - ); - $anl = $anl['bonus']; - - $tpa = [ - 1 => 'cat', - 2 => 'owl', - 3 => 'wisp', - 4 => 'demon', - 5 => 'dog', - 6 => 'pig', - 7 => 'dragon', - ]; - $tpa3 = [ - 1 => 'Кошачья Ловкость', - 2 => 'Интуиция Совы', - 3 => 'Сила Стихий', - 4 => 'Демоническая Сила', - 5 => 'Друг', - 6 => 'Полная Броня', - 7 => 'Инферно', - ]; - - mysql_query( - 'UPDATE `eff_users` SET `delete`="' . time() . '" WHERE `uid` = "' . $this->users[$i]['id'] . '" AND `overType` = 100 AND `delete` = 0' - ); - mysql_query( - 'INSERT INTO `eff_users` (`hod`,`v2`,`img2`,`id_eff`,`uid`,`name`,`data`,`overType`,`timeUse`,`v1`,`user_use`) VALUES ("-1","201","summon_pet_' . $tpa[$a['type']] . '.gif",22,"' . $this->users[$i]['id'] . '","' . $tpa3[$a['type']] . ' [' . $a['level'] . ']","' . $anl . '","100","77","priem","' . $this->users[$i]['id'] . '")' - ); - - //добавление духа от дракона - if ($a['type'] == 7) { - if ($a['level'] == 10) { - $this->users[$i]['tactic7'] = floor( - (50 + $this->stats[$i]['s7']) / $this->stats[$i]['hpAll'] * $this->stats[$i]['hpNow'] - ); - } elseif ($a['level'] == 11) { - $this->users[$i]['tactic7'] = floor( - (65 + $this->stats[$i]['s7']) / $this->stats[$i]['hpAll'] * $this->stats[$i]['hpNow'] - ); - } elseif ($a['level'] == 12) { - $this->users[$i]['tactic7'] = floor( - (90 + $this->stats[$i]['s7']) / $this->stats[$i]['hpAll'] * $this->stats[$i]['hpNow'] - ); - } - } - // - $anl = Conversion::dataStringToArray($anl); - - $vLog = 'time1=' . time() . '||s1=' . $this->users[$i]['sex'] . '||t1=' . $this->users[$i]['team'] . '||login1=' . $this->users[$i]['login']; - $vLog .= '||s2=1||t2=' . $this->users[$i]['team'] . '||login2=' . $a['name'] . ' (Зверь ' . $this->users[$i]['login'] . ')'; - - $mas1 = [ - 'time' => time(), - 'battle' => $this->info['id'], - 'id_hod' => 1, - 'vars' => $vLog, - 'zona1' => '', - 'zonb1' => '', - 'zona2' => '', - 'zonb2' => '', - 'type' => '1', - ]; - - $ba = ''; - $i6 = 0; - while ($i6 < count($u->items['add'])) { - if (isset($anl['add_' . $u->items['add'][$i6]])) { - if ($anl['add_' . $u->items['add'][$i6]] > 0) { - if ($u->items['add'][$i6] == 'mib1') { - $ba .= 'Броня головы: +' . $anl['add_' . $u->items['add'][$i6]] . ', '; - } elseif ($u->items['add'][$i6] == 'mib2') { - $ba .= 'Броня корпуса: +' . $anl['add_' . $u->items['add'][$i6]] . ', '; - } elseif ($u->items['add'][$i6] == 'mib3') { - $ba .= 'Броня пояса: +' . $anl['add_' . $u->items['add'][$i6]] . ', '; - } elseif ($u->items['add'][$i6] == 'mib4') { - $ba .= 'Броня ног: +' . $anl['add_' . $u->items['add'][$i6]] . ', '; - } else { - $ba .= $u->is[$u->items['add'][$i6]] . ': +' . $anl['add_' . $u->items['add'][$i6]] . ', '; - } - } - } - $i6++; - } - $ba = trim($ba, ', '); - if ($ba == '') { - $ba = 'Эффект отсутсвует'; - } - - $mas1['text'] = '{tm1} {u2} очнулся от медитации, и призвал заклятье "' . $tpa3[$a['type']] . ' [' . $a['level'] . ']" на {u1}. (' . $ba . ')'; - $nxtlg[] = $mas1; - mysql_query( - 'UPDATE `users_animal` SET `eda` = `eda` - 1 WHERE `id` = "' . $a['id'] . '" LIMIT 1' - ); - Log::addComment($this); - } - } - } - - mysql_query( - 'UPDATE `stats` SET `last_hp` = "0",`tactic1`="0",`tactic2`="0",`tactic3`="0",`tactic4`="0",`tactic5`="0",`tactic6`="0",`tactic7` = "' . ($this->users[$i]['tactic7']) . '" WHERE `id` = "' . $this->users[$i]['id'] . '" LIMIT 1' - ); - $rs[$this->users[$i]['team']] = $rs[$this->users[$i]['team']] . User::getLogin($this->users[$i]['id']) . ', '; - } - $up .= '`uid` = "' . $pl['id'] . '" OR'; - //battle-user (статистика, начальная) - $mybu = mysql_fetch_array( - mysql_query( - 'SELECT `id` FROM `battle_users` WHERE `battle` = "' . $this->info['id'] . '" AND `uid` = "' . mysql_real_escape_string( - $pl['id'] - ) . '" LIMIT 1' - ) - ); - if (!isset($mybu['id'])) { - //Пустое значение статистики для данного персонажа за текущий бой - - $this->addstatuser($pl['id']); - } - $i++; - } - - //Заносим в лог начало поединка - - if ($this->info['start1'] == 0) { - $tststrt = mysql_fetch_array( - mysql_query( - 'SELECT `id` FROM `battle` WHERE `id` = "' . $this->info['id'] . '" AND `start1` = "0" LIMIT 1' - ) - ); - if (isset($tststrt['id'])) { - $upd = mysql_query( - 'UPDATE `battle` SET `start1` = "' . time() . '" WHERE `id` = "' . $this->info['id'] . '" LIMIT 1' - ); - if ($upd) { - $i = 0; - $r = ''; - while ($i <= $tsi) { - if (isset($rs[$i]) && $rs[$i] != '') { - $r .= rtrim($rs[$i], ', ') . ' и '; - } - $i++; - } - $r = rtrim($r, ' и '); - $r = str_replace('"', '\\\\\"', $r); - $this->hodID++; - $vLog = 'time1=' . time() . '||'; - $mass = [ - 'time' => time(), - 'battle' => $this->info['id'], - 'id_hod' => $this->hodID, - 'vars' => $vLog, - 'zona1' => '', - 'zonb1' => '', - 'zona2' => '', - 'zonb2' => '', - 'type' => '1', - ]; - $r = 'Часы показывали ' . date( - 'd.m.Y H:i', - $this->info['time_start'] - ) . ', когда ' . $r . ' бросили вызов друг другу.'; - $ins = mysql_query( - 'INSERT INTO `battle_logs` (`time`,`battle`,`id_hod`,`text`,`vars`,`zona1`,`zonb1`,`zona2`,`zonb2`,`type`) VALUES ("' . $mass['time'] . '","' . $mass['battle'] . '","' . $mass['id_hod'] . '","' . $r . '","' . $mass['vars'] . '","' . $mass['zona1'] . '","' . $mass['zonb1'] . '","' . $mass['zona2'] . '","' . $mass['zonb2'] . '","' . $mass['type'] . '")' - ); - $this->info['start1'] = time(); - } - } - - // - - if (count($nxtlg) > 0) { - $i = 0; - while ($i < count($nxtlg)) { - $this->add_log($nxtlg[$i]); - $i++; - } - } - // + if ($this->info['start2'] == 0) { + if (Db::getValue('select count(id) from battle where id = ? and start2 = 0', [$this->info['id']]) === 1) { + Db::sql('update battle set start2 = unix_timestamp() where id = ?', [$this->info['id']]); + } else { + $this->info['start2'] = time(); } } + + foreach ($usersInBattle as $user) { + //записываем данные + $this->users[$i] = $user; + $this->uids[$user['id']] = $i; + + if ($user['bot'] > 0) { + $this->bots[$bi] = $user['id']; + $this->iBots[$user['id']] = $bi; + $bi++; + } + + //записываем статы + $stats = new Stats($u); + $this->stats[$i] = $stats->getStats(btl_cache: $this->cached); + + //Заносим старт + if ($this->info['start2'] == 0) { + Db::sql('update users set notrhod = default where id = ?', [$this->users[$i]['id']]); + $this->users[$i]['notrhod'] = -1; + + if (!isset($ts[$this->users[$i]['team']])) { + $tsi++; + $ts[$this->users[$i]['team']] = $tsi; + } + + $tactic7LevelModifier = 10; + if ($this->users[$i]['level'] == 8) { + $tactic7LevelModifier = 20; + } elseif ($this->users[$i]['level'] == 9) { + $tactic7LevelModifier = 30; + } elseif ($this->users[$i]['level'] >= 10) { + $tactic7LevelModifier = 40 + $this->stats[$i]['s7']; + } + + $this->users[$i]['tactic7'] = + floor($tactic7LevelModifier / $this->stats[$i]['hpAll'] * $this->stats[$i]['hpNow']); + + if ($this->stats[$i]['s7'] >= 50) { + Effects::addSpasenie($this->users[$i]['id']); + } + + // Бафф Зверя animal_bonus + $this->addAnimalBuff($i, $u); + + Db::sql( + 'update stats set last_hp = 0, tactic1 = 0, tactic2 = 0, tactic3 = 0, tactic4 = 0, tactic5 = 0, tactic6 = 0, tactic7 = ? where id = ?', + [$this->users[$i]['tactic7'], $this->users[$i]['id']] + ); + + $rs[$this->users[$i]['team']] = $rs[$this->users[$i]['team']] . User::getLogin($this->users[$i]['id']) . ', '; + } + + //battle-user (статистика, начальная) + $mybu = Db::getValue('select id from battle_users where battle = ? and uid = ? limit 1', [$this->info['id'], $user['id']]); + + if (!$mybu) { + //Пустое значение статистики для данного персонажа за текущий бой + $this->addstatuser($user['id']); + } + + $i++; + } + + //Заносим в лог начало поединка + + if ($this->info['start1'] != 0) { + return; + } + + if (Db::getValue('select count(id) from battle where id = ? and start1 = 0', [$this->info['id']]) !== 1) { + return; + } + + Db::sql('update battle set start1 = unix_timestamp() where id = ?', [$this->info['id']]); + + for ($j = 0; $j <= $tsi; $j++) { + if (empty($rs[$j])) { + continue; + } + $r .= rtrim($rs[$j], ', ') . ' и '; + } + + $r = rtrim($r, ' и'); + $r = str_replace('"', '\\\\\"', $r); + + $this->hodID++; + + Log::add( + [ + 'text' => 'Часы показывали ' . + date('d.m.Y H:i', $this->info['time_start']) . + ', когда ' . $r . ' бросили вызов друг другу.', + 'battle' => $this->info['id'], + 'id_hod' => $this->hodID, + 'vars' => 'time1=' . time() . '||', + 'type' => '1', + ] + ); + + $this->info['start1'] = time(); } private function addstatuser($uid): void @@ -8761,4 +6287,125 @@ class Battle } return 'genteam("' . $ret . '");'; } + + public function setIBotsValue($key, $value): void + { + $this->iBots[$key] = $value; + } + + /** + * @param int $i + * @param User $u + * @return void + */ + private function addAnimalBuff(int $i, User $u): void + { + if ($this->users[$i]['animal'] <= 0) { + return; + } + + $animal = Db::getRow('select id, eda, type, level, name from users_animal where id = ? and uid = ? and pet_in_cage = 0', [$this->users[$i]['animal'], $this->users[$i]['id']]); + + if (!isset($animal['id']) || $animal['eda'] < 1) { + return; + } + + $animalBonusDataString = + Db::getValue('select bonus from levels_animal where type = ? and level = ?', [$animal['type'], $animal['level']]); + + $tpa = [ + 1 => 'cat', + 2 => 'owl', + 3 => 'wisp', + 4 => 'demon', + 5 => 'dog', + 6 => 'pig', + 7 => 'dragon', + ]; + $tpa3 = [ + 1 => 'Кошачья Ловкость', + 2 => 'Интуиция Совы', + 3 => 'Сила Стихий', + 4 => 'Демоническая Сила', + 5 => 'Друг', + 6 => 'Полная Броня', + 7 => 'Инферно', + ]; + + Effects::removeByOverType($this->users[$i]['id'], 100); + Effects::addCustom( + [ + 'id_eff' => 22, + 'uid' => $this->users[$i]['id'], + 'name' => "{$tpa[$animal['type']]} [{$animal['level']}]", + 'timeUse' => 77, + 'v1' => 'priem', + 'v2' => 201, + 'img2' => "summon_pet_{$tpa[$animal['type']]}.gif", + 'overType' => 100, + 'user_use' => $this->users[$i]['id'], + 'data' => $animalBonusDataString, + ] + ); + + //добавление духа от дракона + if ($animal['type'] == 7) { + $dragonBonus = 0; + if ($animal['level'] == 10) { + $dragonBonus = (50 + $this->stats[$i]['s7']) / $this->stats[$i]['hpAll'] * $this->stats[$i]['hpNow']; + } elseif ($animal['level'] == 11) { + $dragonBonus = (65 + $this->stats[$i]['s7']) / $this->stats[$i]['hpAll'] * $this->stats[$i]['hpNow']; + } elseif ($animal['level'] == 12) { + $dragonBonus = (90 + $this->stats[$i]['s7']) / $this->stats[$i]['hpAll'] * $this->stats[$i]['hpNow']; + } + $this->users[$i]['tactic7'] = $dragonBonus; + } + + $animalBonusData = Conversion::dataStringToArray($animalBonusDataString); + + $bonusString = ''; + + foreach ($u->items['add'] as $itemBonusSysName) { + if ( + !isset($animalBonusData['add_' . $itemBonusSysName]) || + $animalBonusData['add_' . $itemBonusSysName] <= 0 + ) { + continue; + } + + $bonusString .= match ($itemBonusSysName) { + 'mib1' => 'Броня головы: +' . $animalBonusData['add_' . $itemBonusSysName] . ', ', + 'mib2' => 'Броня корпуса: +' . $animalBonusData['add_' . $itemBonusSysName] . ', ', + 'mib3' => 'Броня пояса: +' . $animalBonusData['add_' . $itemBonusSysName] . ', ', + 'mib4' => 'Броня ног: +' . $animalBonusData['add_' . $itemBonusSysName] . ', ', + default => $u->is[$itemBonusSysName] . ': +' . $animalBonusData['add_' . $itemBonusSysName] . ', ', + }; + } + + $bonusString = trim($bonusString, ', '); + if ($bonusString == '') { + $bonusString = 'Эффект отсутсвует'; + } + + Log::add( + [ + 'battle' => $this->info['id'], + 'id_hod' => 1, + 'vars' => + 'time1=' . time() . + '||s1=' . $this->users[$i]['sex'] . + '||t1=' . $this->users[$i]['team'] . + '||login1=' . $this->users[$i]['login'] . + '||s2=1||t2=' . $this->users[$i]['team'] . + '||login2=' . $animal['name'] . ' (Зверь ' . $this->users[$i]['login'] . ')', + 'type' => '1', + 'text' => '{tm1} {u2} очнулся от медитации, и призвал заклятье "' . + $tpa3[$animal['type']] . ' [' . $animal['level'] . ']" на {u1}. (' . $bonusString . ')', + ] + ); + + Db::sql('update users_animal set eda = eda - 1 where id = ?', [$animal['id']]); + Log::addComment($this); + } + } diff --git a/_incl_data/class/Battle/Finish.php b/_incl_data/class/Battle/Finish.php new file mode 100644 index 00000000..5bcc3743 --- /dev/null +++ b/_incl_data/class/Battle/Finish.php @@ -0,0 +1,1916 @@ +battle = $battle; + } + + public function finishBattle(?array $t, ?array $v, ?int $nl): void + { + global $u; + $injuryName = [1 => 'легкую', 2 => 'среднюю', 3 => 'тяжелую', 4 => 'неизлечимую',]; + $dnr = 0; //??? + $chat = new Chat(); + mysql_query('LOCK TABLES users,stats,battle,battle_last,battle_end,chat WRITE'); + + $test = Db::getRow('select id, team_win, testfinish from battle where id = ? and team_win != -1', [$this->battle->info['id']]); + if ($test['testfinish'] == -1) { + sleep(2); + } else { + Db::sql('update battle set testfinish = -1 where id = ?', [$this->battle->info['id']]); + if ($nl != 10 && $this->battle->info['team_win'] == -1) { + $this->battle->info['team_win'] = 0; + if (is_array($v) && is_array($t)) { + foreach ($v as $vs) { + if ($vs < 1 || $t[$vs] <= 0) { + continue; + } + $this->battle->info['team_win'] = $vs; + } + } + } + + + //данные о игроках в бою + $t = Db::getRows( + "select + *, + users.id as id, + users.level as level, + users.align as align, + users.sex as sex, + users.clan as clan, + stats.timeGo as timeGo, + users.name as name, + stats.lider as lider, + if(login2 = '',login,login2) as login2 + from users + left join stats on users.id = stats.id + where battle = ?", [$this->battle->info['id']] + ); + + foreach ($t as $userInBattle) { + $this->battle->users[] = $userInBattle; + end($this->battle->users); + $this->battle->uids[$userInBattle['id']] = key($this->battle->users); + if ($userInBattle['bot'] > 0) { + $this->battle->bots[] = $userInBattle; + end($this->battle->bots); + $this->battle->setIBotsValue($userInBattle['id'], key($this->battle->bots)); + } + $this->battle->stats[key($this->battle->users)] = $u->getStats(uid: $userInBattle['id'], minimal: true); + } + + if ($this->battle->info['time_over'] == 0) { + + + $tststrt = Db::getRow('select * from battle where id = ? and time_over = 0', [$this->battle->info['id']]); + if (isset($tststrt['id'])) { + if ($this->battle->info['inTurnir'] == 0 || $this->battle->info['type'] == 500) { + Db::sql('update battle set time_over = unix_timestamp(), team_win = ? where id = ?', [$this->battle->info['team_win'], $this->battle->info['id']]); + } + //Заносим данные о завершении боя + $queryValues = ''; + $vtvl = ''; + + foreach ($this->battle->users as $user) { + $inner = implode( + "','", + [ + $user['login'], + $user['city'], + $this->battle->info['id'], + $user['id'], + $user['team'], + $user['level'], + $user['align'], + $user['clan'], + $user['exp'], + $user['bot'], + $user['money'], + $user['money2'], + $user['money3'], + ] + ); + $queryValues .= "('$inner',unix_timestamp()),"; + + if ($user['team'] == $this->battle->info['team_win'] && $this->battle->info['team_win'] > 0) { + $vtvl .= '' . $user['login'] . ', '; + } + } + + $this->battle->info['players_c'] = Db::getValue("select count(id) from users where login not like '%(зверь%' and battle = ?", [$this->battle->info['id']]); + Db::sql('update battle set players_c = ? where id = ?', [$this->battle->info['players_c'], $this->battle->info['id']]); + + if (!empty($vtvl)) { + $vtvl = rtrim($vtvl, ', '); + $vtvl = str_replace('"', '\\\\\"', $vtvl); + $logtext = "Бой закончен, победа за $vtvl."; + } else { + $this->battle->info['players_cc'] = $this->battle->info['players_cc2'] = 0; + $logtext = 'Бой закончен, ничья.'; + } + + $this->battle->hodID++; + Log::add( + [ + 'battle' => $this->battle->info['id'], + 'id_hod' => $this->battle->hodID, + 'text' => $logtext, + 'vars' => 'time1=' . time(), + 'type' => 1, + ] + ); + unset($logtext); + $this->saveLogs(); + + if ($this->battle->info['type'] == 99) { + $logarray = [ + 'battle' => $this->battle->info['id'], + 'id_hod' => $this->battle->hodID, + 'text' => 'И победители стали калечить проигравших...', + 'vars' => 'time1=' . time(), + 'type' => '1', + ]; + Log::add($logarray); + + $vtvl = ''; + foreach ($this->battle->users as $userToInjure) { + if ($userToInjure['team'] == $this->battle->info['team_win']) { + continue; + } + $injuryCaster = Db::getRow('select id, v1 from eff_users where id_eff = 4 and uid = ? order by v1 desc limit 1'); + if (!empty($injuryCaster['id']) && $injuryCaster['v1'] >= 3) { + continue; + } + $a = $userToInjure['sex'] == 1 ? 'а' : ''; + $injuryType = $this->battle->info['smert'] == 1 ? 4 : mt_rand(1, 3); + if (!empty($injuryCaster['id'])) { + $injuryType = mt_rand($injuryCaster['v1'] + 1, 3); + } + $vtvl = "{$userToInjure['login']} получил$a повреждение:" . + " $injuryName[$injuryType].
$vtvl"; + $this->battle->addTravm($userToInjure['id'], $injuryType, rand(3, 5)); + } + + $logarray['text'] = $vtvl; + Log::add($logarray); + } + + if (!empty($queryValues)) { + $queryValues = rtrim($queryValues, ','); + Db::sql("insert into battle_last (login,city,battle_id,uid,team,lvl,align,clan,exp,bot,money,money2,money3,time) values $queryValues"); + } + Db::sql( + 'insert into battle_end (battle_id, city, time, team_win) values (?,?,?,?)', + [$this->battle->info['id'], $this->battle->info['city'], $this->battle->info['time_start'], $this->battle->info['team_win']] + ); + } + + $logarray = [ + 'battle' => $this->battle->info['id'], + 'id_hod' => $this->battle->hodID, + 'vars' => 'time1=' . time(), + 'type' => '1', + ]; + + $vtvl = ''; + foreach ($this->battle->users as $userToInjure) { + if ($userToInjure['team'] == $this->battle->info['team_win'] || $this->battle->info['team_win'] == 0) { + continue; + } + $injuryCaster = Db::getRow("select id, v1, data, user_use from eff_users where v1 = 'priem' and v2 = 292 and uid = ? limit 1"); + + if (empty($injuryCaster['id']) || mt_rand(0, 100) >= $injuryCaster['data']) { + continue; + } + + $a = $userToInjure['sex'] == 1 ? 'а' : ''; + $injuryType = mt_rand($injuryCaster['v1'] + 1, 3); + $injuryCasterLogin = $this->battle->users[$this->battle->uids[$injuryCaster['user_use']]]['login']; + + $vtvl = "{$userToInjure['login']} получил$a повреждение" . + " (Искалечить, автор: $injuryCasterLogin):" . + " $injuryName[$injuryType].
$vtvl"; + $this->battle->addTravm($userToInjure['id'], $injuryType, rand(3, 5)); + } + + if (!empty($vtvl)) { + if ($this->battle->info['type'] != 99) { + $logarray['text'] = 'И победители стали калечить проигравших...'; + Log::add($logarray); + } + $logarray['text'] = $vtvl; + Log::add($logarray); + } + + + //Турнир БС + if ($this->battle->info['inTurnir'] > 0 && $this->battle->info['dungeon'] != 15 && $u->info['room'] != 413) { + $bs = mysql_fetch_array( + mysql_query('SELECT * FROM `bs_turnirs` WHERE `id` = "' . $this->battle->info['inTurnir'] . '" LIMIT 1') + ); + $i = 0; + $j = 0; + while ($i < count($this->battle->users)) { + $text = ''; + if ($this->battle->stats[$i]['hpNow'] < 1 && $this->battle->users[$i]['clone'] == 0 && $this->battle->stats[$i]['clone'] == 0) { + //Добавляем в лог БС + if ($this->battle->users[$i]['sex'] == 0) { + $text .= '{u1} повержен и выбывает из турнира'; + } else { + $text .= '{u1} повержена и выбывает из турнира'; + } + //Выкидываем предметы с персонажа + $spik = mysql_query( + 'SELECT `id`,`item_id` FROM `items_users` WHERE `uid` = "' . $this->battle->users[$i]['id'] . '" AND `delete` ="0"' + ); + while ($plik = mysql_fetch_array($spik)) { + + mysql_query( + 'INSERT INTO `dungeon_items` (`dn`,`item_id`,`time`,`x`,`y`) VALUES ( + "' . $this->battle->users[$i]['dnow'] . '","' . $plik['item_id'] . '","' . (time( + ) - 600) . '","' . $this->battle->users[$i]['x'] . '","' . $this->battle->users[$i]['y'] . '" + )' + ); + } + unset($spik, $plik); + // + $usrreal = ''; + $usr_real = mysql_fetch_array( + mysql_query( + 'SELECT `id`,`login`,`align`,`clan`,`battle`,`level` FROM `users` WHERE `login` = "' . $this->battle->users[$i]['login'] . '" AND `inUser` = "' . $this->battle->users[$i]['id'] . '" LIMIT 1' + ) + ); + if (!isset($usr_real['id'])) { + $usr_real = $this->battle->users[$i]; + } + if (isset($usr_real['id'])) { + if ($usr_real['align'] > 0) { + $usrreal .= ''; + } + if ($usr_real['clan'] > 0) { + $usrreal .= ''; + } + $usrreal .= '' . $usr_real['login'] . '[' . $usr_real['level'] . ']'; + } + + $text = str_replace('{u1}', $usrreal, $text); + mysql_query( + 'INSERT INTO `bs_logs` (`type`,`text`,`time`,`id_bs`,`count_bs`,`city`,`m`,`u`) VALUES ( + "1", "' . mysql_real_escape_string($text) . '", "' . time() . '", "' . $bs['id'] . '", "' . $bs['count'] . '", "' . $bs['city'] . '", + "' . round($bs['money'] * 0.85, 2) . '","' . $i . '" + )' + ); + // + //Удаление клона + mysql_query('DELETE FROM `users` WHERE `id` = "' . $this->battle->users[$i]['id'] . '" LIMIT 1'); + mysql_query('DELETE FROM `stats` WHERE `id` = "' . $this->battle->users[$i]['id'] . '" LIMIT 1'); + mysql_query('DELETE FROM `actions` WHERE `uid` = "' . $this->battle->users[$i]['id'] . '"'); + mysql_query('DELETE FROM `items_users` WHERE `uid` = "' . $this->battle->users[$i]['id'] . '"'); + mysql_query('DELETE FROM `eff_users` WHERE `uid` = "' . $this->battle->users[$i]['id'] . '"'); + mysql_query('DELETE FROM `users_delo` WHERE `uid` = "' . $this->battle->users[$i]['id'] . '"'); + //Обновление персонажа + mysql_query( + 'UPDATE `users` SET `inUser` = "0" WHERE `login` = "' . $this->battle->users[$i]['login'] . '" OR `inUser` = "' . $this->battle->users[$i]['id'] . '" LIMIT 1' + ); + //Обновляем заявку + mysql_query( + 'UPDATE `bs_zv` SET `off` = "' . time() . '" WHERE `inBot` = "' . $this->battle->users[$i]['id'] . '" AND `off` = "0" LIMIT 1' + ); + unset($text, $usrreal, $usr_real); + if ($this->battle->users[$i]['pass'] != 'bstowerbot') { + $bs['users']--; + $bs['users_finish']++; + } else { + $bs['arhiv']--; + } + $j++; + } + $i++; + } + if ($j > 0) { + mysql_query( + 'UPDATE `bs_turnirs` SET `arhiv` = "' . $bs['arhiv'] . '",`users` = "' . $bs['users'] . '",`users_finish` = "' . $bs['users_finish'] . '" WHERE `id` = "' . $bs['id'] . '" LIMIT 1' + ); + } + + unset($bs, $j); + } + + //Награда за события + if ($this->battle->info['type'] == 500 && isset($tststrt['id'])) { + //Предметы которые выпадают в центр + + $i = 0; + while ($i < count($this->battle->users)) { + $cmsg = new ChatMessage(); + $cmsg->setType(6); + $cmsg->setIsAlert(true); + if ($this->battle->users[$i]['no_ip'] == 'trupojor') { + $mon = mysql_fetch_array( + mysql_query( + 'SELECT * FROM `aaa_monsters` WHERE `uid` = "' . $this->battle->users[$i]['id'] . '" LIMIT 1' + ) + ); + if (isset($mon['id'])) { + if ($this->battle->info['team_win'] == 0) { + //Ничья + mysql_query( + 'UPDATE `stats` SET `hpNow` = "' . $this->battle->stats[$i]['hpAll'] . '",`mpNow` = "' . $this->battle->stats[$i]['mpAll'] . '" WHERE `id` = "' . $this->battle->users[$i]['id'] . '" LIMIT 1' + ); + $cmsg->setText( + str_replace( + '{b}', + '' . $this->battle->users[$i]['login'] . ' [' . $this->battle->users[$i]['level'] . ']battle->users[$i]['id'] . ' >', + $mon['nich_text'] + ) + ); + $chat->sendMsg($cmsg); + } elseif ($this->battle->info['team_win'] != $this->battle->users[$i]['team']) { + //Выиграли + $j = 0; + $usrwin = ''; + while ($j < count($this->battle->users)) { + if ($this->battle->users[$j]['no_ip'] != 'trupojor' && $this->battle->users[$j]['bot'] == 0 && $this->battle->stats[$j]['hpNow'] > 0) { + $usrwin .= ', '; + if ($this->battle->users[$j]['align'] > 0) { + $usrwin .= 'battle->users[$j]['align'] . '.gif >'; + } + if ($this->battle->users[$j]['clan'] > 0) { + $usrwin .= 'battle->users[$j]['clan'] . '.gif >'; + } + $usrwin .= '' . $this->battle->users[$j]['login'] . ' [' . $this->battle->users[$j]['level'] . ']battle->users[$j]['id'] . ' >'; + } + $j++; + } + if ($usrwin != '') { + $usrwin = ltrim($usrwin, ', '); + } else { + $usrwin = 'Команда героев'; + } + + mysql_query( + 'UPDATE `users` SET `room` = "303" WHERE `id` = "' . $this->battle->users[$i]['id'] . '" LIMIT 1' + ); + + $truptimelast = time() + rand(1800, 3600); + + mysql_query( + 'UPDATE `stats` SET `res_x` = "' . $truptimelast . '" WHERE `id` = "' . $this->battle->users[$i]['id'] . '" LIMIT 1' + ); + $cmsg->setText( + str_replace( + '{b}', + '' . $this->battle->users[$i]['login'] . ' [' . $this->battle->users[$i]['level'] . ']battle->users[$i]['id'] . ' >', + str_replace('{u}', $usrwin, $mon['win_text']) + ) + ); + $chat->sendMsg($cmsg); + unset($usrwin); + } else { + //Проиграли + if ($mon['win_back'] == 1) { + mysql_query( + 'UPDATE `users` SET `room` = "303" WHERE `id` = "' . $this->battle->users[$i]['id'] . '" LIMIT 1' + ); + } + mysql_query( + 'UPDATE `stats` SET `hpNow` = "' . $this->battle->stats[$i]['hpAll'] . '",`mpNow` = "' . $this->battle->stats[$i]['mpAll'] . '" WHERE `id` = "' . $this->battle->users[$i]['id'] . '" LIMIT 1' + ); + $cmsg->setText( + str_replace( + '{b}', + '' . $this->battle->users[$i]['login'] . ' [' . $this->battle->users[$i]['level'] . ']battle->users[$i]['id'] . ' >', + $mon['lose_text'] + ) + ); + $chat->sendMsg($cmsg); + } + } + } + $i++; + } + } + } + + // выкидываем ботов из боя + $i = 0; + $botsi = 0; + if (isset($tststrt['id'])) { + while ($i < count($this->battle->users)) { + //Тут выкидываем юзеров из Призавого хаота + if ($this->battle->info['type'] == 33) { + $plde = mysql_fetch_array( + mysql_query('SELECT * FROM `users` WHERE `id` = "' . $this->battle->users[$i]['id'] . '" LIMIT 1') + ); + if (isset($plde['mail']) && $plde['mail'] == "haot@new-combats.com") { + $pld = mysql_fetch_array( + mysql_query( + 'SELECT * FROM `users` WHERE `inUser` = "' . $this->battle->users[$i]['id'] . '" LIMIT 1' + ) + ); + + if (isset($pld['id'])) { + if ($this->battle->users[$i]['battle_yron'] >= 500) { + mysql_query( + 'UPDATE `users_achiv` SET `pg`= `pg`+1 WHERE `id` = "' . $pld['id'] . '" LIMIT 1' + ); + + if ($this->battle->users[$i]['team'] == $this->battle->info['team_win'] && rand(1, 100) <= 5) { + ItemsModel::addItem(10020, $pld['id'], ''); + $pld['battle_text'] .= ' За Героическое Сражение вы получаете Жетон Успеха. '; + } + } else { + $pld['battle_text'] .= ' Вы ничего не получили. Нужно набить больше 500 урона урона .'; + } + $cmsg = new ChatMessage(); + $cmsg->setRoom($pld['room']); + $cmsg->setTo($pld['login']); + $cmsg->setText($pld['battle_text']); + $cmsg->setType(6); + $chat->sendMsg($cmsg); + + mysql_query( + 'DELETE FROM `stats` WHERE `id` = "' . $this->battle->users[$i]['id'] . '" LIMIT 1' + ); + mysql_query( + 'DELETE FROM `items_users` WHERE `uid` = "' . $this->battle->users[$i]['id'] . '" LIMIT 100' + ); + mysql_query( + 'DELETE FROM `eff_users` WHERE `uid` = "' . $this->battle->users[$i]['id'] . '" LIMIT 100' + ); + mysql_query( + 'UPDATE `users` SET `inUser` = "0" WHERE `inUser` = "' . $this->battle->users[$i]['id'] . '" LIMIT 1' + ); + mysql_query( + 'DELETE FROM `users` WHERE `id` = "' . $this->battle->users[$i]['id'] . '" LIMIT 1' + ); + } + } + + unset ($plde, $pld); + } + + if ($this->battle->users[$i]['bot'] == 1) { + $botsi++; + mysql_query('DELETE FROM `users` WHERE `id` = "' . $this->battle->users[$i]['id'] . '" LIMIT 1'); + mysql_query('DELETE FROM `stats` WHERE `id` = "' . $this->battle->users[$i]['id'] . '" LIMIT 1'); + mysql_query( + 'DELETE FROM `items_users` WHERE `uid` = "' . $this->battle->users[$i]['id'] . '" LIMIT 100' + ); + mysql_query('DELETE FROM `eff_users` WHERE `uid` = "' . $this->battle->users[$i]['id'] . '" LIMIT 100'); + } elseif ($this->battle->users[$i]['bot'] == 2 || $this->battle->users[$i]['bot'] > 0) { + $this->battle->users[$i]['battle'] = 0; + mysql_query( + 'UPDATE `users` SET `battle` = "0" WHERE `id` = "' . $this->battle->users[$i]['id'] . '" LIMIT 1' + ); + mysql_query( + 'UPDATE `stats` SET `zv` = "0",`team` = "0",`exp` = `exp` + `battle_exp`,`battle_exp` = "0",`battle_yron` = "0",`enemy` = "0", `timeGo` = "' . time( + ) . '" WHERE `id` = "' . $this->battle->users[$i]['id'] . '" LIMIT 1' + ); + mysql_query('DELETE FROM `eff_users` WHERE `uid` = "' . $this->battle->users[$i]['id'] . '" LIMIT 100'); + } + if ($this->battle->users[$i]['clone'] > 0 && $this->battle->users[$i]['bot'] > 0 && isset($this->battle->users[$this->battle->uids[$this->battle->users[$i]['clone']]]['id']) && $this->battle->users[$this->battle->uids[$this->battle->users[$i]['clone']]]['team'] != $this->battle->users[$i]['team']) { + //Добавляем что клон побежден + if ($this->battle->users[$this->battle->uids[$this->battle->users[$i]['clone']]]['team'] == $this->battle->info['team_win']) { + $u->addAction(time(), 'win_bot_clone', '', $this->battle->users[$i]['clone']); + } elseif ($this->battle->info['team_win'] == 0) { + $u->addAction(time(), 'nich_bot_clone', '', $this->battle->users[$i]['clone']); + } else { + $u->addAction(time(), 'lose_bot_clone', '', $this->battle->users[$i]['clone']); + } + } elseif ($this->battle->users[$i]['bot'] > 0 && $this->battle->users[$i]['bot_id'] > 0) { + //Добавляем что бота победили + $j = 0; + while ($j < count($this->battle->users)) { + if ($this->battle->users[$j]['bot'] == 0 && $this->battle->users[$j]['team'] != $this->battle->users[$i]['team']) { + if ($this->battle->users[$j]['team'] == $this->battle->info['team_win']) { // if($this->battle->users[$j]['team']==$this->battle->info['team_win']){ + $u->addAction( + time(), 'win_bot_' . $this->battle->users[$i]['bot_id'], '', + $this->battle->users[$j]['id'] + ); + // + mysql_query( + 'UPDATE `dialog_act` SET `now` = `now` + 1 WHERE `uid` = "' . $this->battle->users[$j]['id'] . '" AND + ( `btl_bot` LIKE "' . $this->battle->users[$i]['bot_id'] . '!%" OR `btl_bot` LIKE "%!' . $this->battle->users[$i]['bot_id'] . '!%" ) + AND `val` != 1 + LIMIT 1' + ); + // + } elseif ($this->battle->info['team_win'] == 0) { + $u->addAction( + time(), 'nich_bot_' . $this->battle->users[$i]['bot_id'], '', + $this->battle->users[$j]['id'] + ); + } else { + $u->addAction( + time(), 'lose_bot_' . $this->battle->users[$i]['bot_id'], '', + $this->battle->users[$j]['id'] + ); + } + } + $j++; + } + } + $i++; + } + } + + //Из бота падают предметы + if ($nl != 10 && $this->battle->info['dungeon'] > 0) { + if ($this->battle->info['team_win'] == $u->info['team'] && $this->battle->info['dungeon'] == 102) { + $j1 = mysql_fetch_array( + mysql_query( + 'SELECT * FROM `laba_obj` WHERE `type` = 2 AND `lib` = "' . $this->battle->info['dn_id'] . '" AND `x` = "' . $this->battle->info['x'] . '" AND `y` = "' . $this->battle->info['y'] . '" LIMIT 1' + ) + ); + if (isset($j1['id'])) { + mysql_query('DELETE FROM `laba_obj` WHERE `id` = "' . $j1['id'] . '" LIMIT 1'); + //Выпадает шмотка + mysql_query( + 'INSERT INTO `laba_obj` (`use`,`lib`,`time`,`type`,`x`,`y`,`vars`) VALUES ( + "0","' . $j1['lib'] . '","' . time() . '","6","' . $j1['x'] . '","' . $j1['y'] . '","' . ($botsi) . '" + )' + ); + } + } elseif ($this->battle->info['team_win'] == $u->info['team']) { + //выйграли люди, выкидываем предметы из мобов + $j1 = mysql_query( + 'SELECT * FROM `dungeon_bots` WHERE `dn` = "' . $this->battle->info['dn_id'] . '" AND `for_dn` = "0" AND `x` = "' . $this->battle->info['x'] . '" AND `delete` = "0" AND `y`= "' . $this->battle->info['y'] . '" LIMIT 100' + ); + while ($tbot = mysql_fetch_array($j1)) { + $cmsg = new ChatMessage(); + $cmsg->setDn($this->battle->info['dn_id']); + $cmsg->setRoom($this->battle->users[0]['room']); + $cmsg->setType(6); + $cmsg->setTypeTime(1); + + $tbot2 = mysql_fetch_array( + mysql_query( + 'SELECT * FROM `test_bot` WHERE `id` = "' . $tbot['id_bot'] . '" LIMIT 1' + ) + ); + + $j2 = 0; + while ($j2 < $tbot['colvo']) { + if (isset($tbot['id2'])) { + $itms = explode('|', $tbot2['p_items']); + $tii = 0; + $testdrop = 0; + while ($tii < count($itms) && $testdrop == 0) { + $itmz = explode('=', $itms[$tii]); + if ($itmz[0] > 0) { + if (isset($itmz[2]) && $itmz[2] != '') { // $itmz[2] == quest888 + $questDrop = mysql_fetch_array( + mysql_query( + 'SELECT * FROM `actions` WHERE `vars` LIKE "%' . $itmz[2] . '%" AND `vals` = "go" AND `uid` = "' . $u->info['id'] . '" LIMIT 1' + ) + ); + } + if (!isset($questDrop['id']) && isset($itmz[2]) && $itmz[2] != '') { + $itmz[1] = 0; + } // Если предмет квестовый, а квеста у игрока нет, то предмет выпадет с вероятностью 0 + + + //Добавляем этот предмет в зону Х и У + if ($itmz[1] * 100000 >= rand(1, 10000000)) { + $tou = 0; //какому юзеру предназначено + /* выделяем случайного юзера из команды */ + + $cmsg->setText( + 'У ' . $tbot2['login'] . ' был предмет "' . ItemModel::getNameById($itmz[0]) . '" и кто угодно может поднять его' + ); + $chat->sendMsg($cmsg); + + mysql_query( + 'INSERT INTO `dungeon_items` (`dn`,`user`,`item_id`,`time`,`x`,`y`) VALUES ( + "' . $this->battle->info['dn_id'] . '", + "' . $tou . '", + "' . $itmz[0] . '", + "' . time() . '", + "' . $this->battle->info['x'] . '", + "' . $this->battle->info['y'] . '")' + ); + if (!isset($questDrop['id'])) { + $testdrop = 1; //ТУТ drop-drop //quest + } + } + } + $tii++; + } + } + $j2++; + } + // + //Квест 1-15 сентября, + if ( + date('m') == 9 && + date('d') < 15 && + !Helper::getChanse(99) && + ($this->battle->info['dungeon'] == 12 || $this->battle->info['dungeon'] == 101) + ) { + $tou = 0; //какому юзеру предназначено + /* выделяем случайного юзера из команды */ + $itmz = [ + mt_rand(4745, 4751), + 100, + ]; + + $cmsg->setText( + 'У ' . $tbot2['login'] . ' был предмет "' . ItemModel::getNameById(mt_rand(4745, 4751)) . '" и кто угодно может поднять его' + ); + $chat->sendMsg($cmsg); + + mysql_query( + 'INSERT INTO `dungeon_items` (`dn`,`user`,`item_id`,`time`,`x`,`y`) VALUES ( + "' . $this->battle->info['dn_id'] . '", + "' . $tou . '", + "' . $itmz[0] . '", + "' . time() . '", + "' . $this->battle->info['x'] . '", + "' . $this->battle->info['y'] . '")' + ); + } + // + //Странички саныча, + + if (rand(1, 100) > 99) { + continue; + } + + if ( + $this->battle->info['dungeon'] == 12 || $this->battle->info['dungeon'] == 3 || + $this->battle->info['dungeon'] == 101 || $this->battle->info['dungeon'] == 16 || + $this->battle->info['dungeon'] == 9 || $this->battle->info['dungeon'] == 10 || + $this->battle->info['dungeon'] == 13 || $this->battle->info['dungeon'] == 106 + ) { + $tou = 0; //какому юзеру предназначено + // выделяем случайного юзера из команды + $itmz = mt_rand(3143, 3192); + $cmsg->setText( + 'У ' . $tbot2['login'] . ' был предмет "' . ItemModel::getNameById($itmz) . '" и кто угодно может поднять его' + ); + $chat->sendMsg($cmsg); + + mysql_query( + 'INSERT INTO `dungeon_items` (`dn`,`user`,`item_id`,`time`,`x`,`y`) VALUES ( + "' . $this->battle->info['dn_id'] . '", + "' . $tou . '", + "' . $itmz . '", + "' . time() . '", + "' . $this->battle->info['x'] . '", + "' . $this->battle->info['y'] . '")' + ); + } + } + mysql_query( + 'UPDATE `dungeon_bots` SET `delete` = "' . time( + ) . '" AND `inBattle` = "' . $this->battle->info['id'] . '" WHERE `dn` = "' . $this->battle->info['dn_id'] . '" AND `for_dn` = "0" AND `delete` = "0" ' + ); + } else { + //выкидываем всех игроков в клетку RESTART + $dnr = 1; + if ($this->battle->info['dungeon'] != 102) { + mysql_query( + 'UPDATE `dungeon_bots` SET `inBattle` = "0" WHERE `dn` = "' . $this->battle->info['dn_id'] . '" AND `for_dn` = "0" AND `x` = "' . $this->battle->info['x'] . '" AND `y`= "' . $this->battle->info['y'] . '"' + ); + } + } + } + + $gm = []; + $gms = []; + $bm = []; + $bms = []; + + //Квестовый раздел + //Квестовый раздел + + //завершаем поединок + $i = $this->battle->uids[$u->info['id']]; + + if ($this->battle->info['team_win'] >= 0) { + $cmsg = new ChatMessage(); + $cmsg->setRoom($this->battle->users[$i]['room']); + $cmsg->setType(6); + + if ($this->battle->stats[$i]['pbe'] > 0) { + //Бонус покупателя + $this->expCoef += $this->battle->stats[$i]['pbe']; + } + + if ($this->battle->info['razdel'] == 5 && (Config::get('m') >= 6 && Config::get('m') <= 8 || Config::get('w') == 0 || Config::get('w') == 6)) { + $this->expCoef += 5; + } + + $this->battle->stats[$i]['exp'] += $this->expCoef; + + $this->battle->stats[$i]['exp'] += $this->aBexp * Config::get('exp'); + + if ($this->battle->stats[$i]['os4'] > 0) { + $this->battle->stats[$i]['exp'] += $this->battle->stats[$i]['os4']; + } + + + $act01 = 0; + $this->battle->users[$i]['battle_exp'] = round( + $this->battle->users[$i]['battle_exp'] + ($this->battle->users[$i]['battle_exp'] / 100 * (1 + $this->battle->info['addExp'] + $this->battle->stats[$i]['exp'])) + ); + + if ($this->battle->info['type'] == 564) { + //Бой с копией + $this->battle->users[$i]['battle_exp'] = 0; + } + + if ($this->battle->info['dungeon'] == 104) { + $this->battle->users[$i]['battle_exp'] = ($u->info['level'] * 2) * (count($this->battle->uids) - 1); + } elseif ($this->battle->info['dungeon'] > 0 && $this->battle->users[$i]['dnow'] != 0 && $this->battle->info['dungeon'] != 1 && $this->battle->users[$i]['team'] == $this->battle->info['team_win']) { + $dun_limitForLevel = [ + 4 => 750, + 5 => 1500, + 6 => 3500, + 7 => 8000, + 8 => 25000, + 9 => 50000, + 10 => 75000, + 11 => 100000, + 12 => 100000, + 13 => 100000, + 14 => 100000, + ]; + // Максимум для каждого уровня. + + if ($this->battle->users[$i]['battle_exp'] > 0) { + $dun_exp = []; // Текущий лимит опыта игрока в подземельях. + $rep = mysql_fetch_array( + mysql_query( + 'SELECT `dungeonexp`,`id` FROM `rep` WHERE `id` = "' . $this->battle->users[$i]['id'] . '" LIMIT 1' + ) + ); + $rep = explode(',', $rep['dungeonexp']); + foreach ($rep as $val) { + $val = explode('=', $val); // текущий лимит опыта в подземке + if (isset($val[0]) && isset($val[1]) && $val[0] != '' && $val[1] != 0) { + $dun_exp[(int)$val[0]] = (int)$val[1]; + } + } + unset($rep); + } + + if (!isset($dun_exp[$this->battle->info['dungeon']])) { + $dun_exp[$this->battle->info['dungeon']] = 0; + } + + if (!isset($dun_limitForLevel[(int)$this->battle->users[$i]['level']])) { // Если лимит не задан, опыт не даем. + $this->battle->users[$i]['battle_exp'] = 0; + } elseif ( + isset($dun_exp[$this->battle->info['dungeon']]) && + $dun_exp[$this->battle->info['dungeon']] >= $dun_limitForLevel[(int)$this->battle->users[$i]['level']] + ) { // Если лимит уже достигнут, опыт не даем. + $this->battle->users[$i]['battle_exp'] = 0; + } elseif ( + isset($dun_exp[$this->battle->info['dungeon']]) && + $dun_limitForLevel[(int)$this->battle->users[$i]['level']] > $dun_exp[$this->battle->info['dungeon']] + ) { // Если текущая репутация не достигла лимита. + if (($dun_exp[$this->battle->info['dungeon']] + $this->battle->users[$i]['battle_exp']) > $dun_limitForLevel[(int)$this->battle->users[$i]['level']]) { + // Если опыта набрано достаточно, для достижения лимита. + $this->battle->users[$i]['battle_exp'] = abs( + $this->battle->users[$i]['battle_exp'] - abs( + $dun_limitForLevel[(int)$this->battle->users[$i]['level']] - ($this->battle->users[$i]['battle_exp'] + $dun_exp[$this->battle->info['dungeon']]) + ) + ); + $dun_exp[$this->battle->info['dungeon']] += $this->battle->users[$i]['battle_exp']; + } elseif ($dun_limitForLevel[(int)$this->battle->users[$i]['level']] > ($dun_exp[$this->battle->info['dungeon']] + $this->battle->users[$i]['battle_exp'])) { + // Если опыта недостаточно, для достижения лимита. + $dun_exp[$this->battle->info['dungeon']] += $this->battle->users[$i]['battle_exp']; + } else { + $this->battle->users[$i]['battle_exp'] = 0; + } + } else { // В любой непонятной ситуцаии. + $this->battle->users[$i]['battle_exp'] = 0; + } + + + if ($this->battle->users[$i]['battle_exp'] > 0 && isset($dun_exp[$this->battle->info['dungeon']]) && $dun_exp[$this->battle->info['dungeon']] > 0) { + $dunexp = []; + foreach ($dun_exp as $key => $val) { + $dunexp[$key] = $key . '=' . $val; // текущий лимит опыта в подземке + } + $dun_exp = implode(",", $dunexp); + mysql_query( + 'UPDATE `rep` SET `dungeonexp` = "' . $dun_exp . '" WHERE `id` = "' . $this->battle->users[$i]['id'] . '" LIMIT 1' + ); + unset($dunexp, $dun_exp); + } + unset($dun_limitForLevel); + } + + $sinf = ''; + if (Config::get('exp_mega')) { + $this->battle->users[$i]['battle_exp'] += floor( + $this->battle->users[$i]['battle_exp'] / 100 * Config::get('exp_mega_val')[$this->battle->users[$i]['level']] + ); + } + + if ($this->battle->info['team_win'] == 0 && $this->battle->info['type'] != 564) { + if ($this->battle->users[$i]['level'] <= 1) { + $this->battle->users[$i]['battle_exp'] = floor($this->battle->users[$i]['battle_exp'] * 0.50); + } else { + $this->battle->users[$i]['battle_exp'] = ceil($this->battle->users[$i]['battle_exp'] * 0.10); + } + $this->battle->users[$i]['nich'] += 1; + } elseif ($this->battle->users[$i]['team'] == $this->battle->info['team_win'] && $this->battle->info['type'] != 564) { + $gm[$i] = $this->battle->info['money']; + $gms[$i] = $this->battle->info['money3']; + $this->battle->users[$i]['win'] += 1; + $act01 = 1; + } elseif ($this->battle->info['type'] != 564) { + if ($this->battle->users[$i]['level'] <= 1) { + $this->battle->users[$i]['battle_exp'] = ceil($this->battle->users[$i]['battle_exp'] * 0.33); + } else { + $this->battle->users[$i]['battle_exp'] = ceil($this->battle->users[$i]['battle_exp'] * 0.10); + } + $bm[$i] = $this->battle->info['money']; + $bms[$i] = $this->battle->info['money3']; + $this->battle->users[$i]['lose'] += 1; + $act01 = 2; + } + //Рассчитываем кол-во выигрышных сумм и кто сколько получил (для екр.) + if ($this->battle->info['money3'] > 0 && isset($gms[$i]) && $this->battle->info['type'] != 564) { + $mn = [ + 'l' => 0, //сколько проигравших игроков + 'w' => 0, //сколько выигрывших игроков + 'm' => 0, //сумма выигрыша (общая) + ]; + if ($act01 == 1) { + $mn['l'] = mysql_fetch_array( + mysql_query( + 'SELECT COUNT(`id`) FROM `battle_users` WHERE `battle` = "' . $this->battle->info['id'] . '" AND `team` != "' . $this->battle->users[$i]['team'] . '" LIMIT 1' + ) + ); + $mn['l'] = $mn['l'][0]; + $mn['w'] = mysql_fetch_array( + mysql_query( + 'SELECT COUNT(`id`) FROM `battle_users` WHERE `battle` = "' . $this->battle->info['id'] . '" AND `team` = "' . $this->battle->users[$i]['team'] . '" LIMIT 1' + ) + ); + $mn['w'] = $mn['w'][0]; + $mn['m'] = round(($mn['l'] * $this->battle->info['money3']) / 100 * 87, 2); + $gms[$i] = round(($mn['m'] / $mn['w']), 2); + } + } + //заносим данные в БД + //Поломка предметов + $lom = 0; + if ($act01 == 1) { + //победа + if ($this->battle->users[$i]['dnow'] == 0 && $this->battle->users[$i]['hpNow'] < 1) { + $lom = 0.05; + } + } elseif ($act01 == 2) { + //поражение + $lom = 0.55; + } else { + //ничья + $lom = 0.05; + } + $nlom = [0 => rand(0, 18), 1 => rand(0, 18), 2 => rand(0, 18), 3 => rand(0, 18)]; + if ($this->battle->info['type'] == 564 || $this->battle->stats[$i]['silver']) { + $lom = 0; + } + + mysql_query( + 'UPDATE `items_users` SET `iznosNOW` = `iznosNOW`+' . $lom . ' WHERE `inOdet` < "18" AND `inOdet` > "0" AND `uid` = "' . $this->battle->users[$i]['id'] . '" AND `inOdet`!="0" AND `inOdet`!=' . $nlom[0] . ' AND `inOdet`!=' . $nlom[1] . ' AND `inOdet`!=' . $nlom[2] . ' AND `inOdet`!=' . $nlom[3] . ' LIMIT 18' + ); + + $prc = ''; + if ($this->battle->users[$i]['align'] == 2) { + $this->battle->users[$i]['battle_exp'] = floor($this->battle->users[$i]['battle_exp'] / 2); + } + if ($this->battle->users[$i]['animal'] > 0) { + $ulan = $u->testAction( + '`uid` = "' . $this->battle->users[$i]['id'] . '" AND `vars` = "animal_use' . $this->battle->info['id'] . '" LIMIT 1', + 1 + ); + if (isset($ulan['id']) && $this->battle->users[$i]['team'] == $this->battle->info['team_win'] && $this->battle->users[$i]['level'] > $ulan['vals']) { + $a004 = mysql_fetch_array( + mysql_query( + 'SELECT `max_exp`,`name` FROM `users_animal` WHERE `uid` = "' . $this->battle->users[$i]['id'] . '" AND `id` = "' . $this->battle->users[$i]['animal'] . '" AND `pet_in_cage` = "0" AND `delete` = "0" LIMIT 1' + ) + ); + //33% от опыта переходит зверю, но не более максимума + $aexp = (round($this->battle->users[$i]['battle_exp'] / 100 * 33)); + if ($aexp > $a004['max_exp']) { + $aexp = $a004['max_exp']; + } + unset($ulan); + // + $cmsg->setTo($this->battle->users[$i]['login']); + $cmsg->setText("Ваш питомец «{$a004['name']}» получил опыт: $aexp"); + $chat->sendMsg($cmsg); + // + $upd = mysql_query( + 'UPDATE `users_animal` SET `exp` = `exp` + ' . $aexp . ' WHERE `id` = "' . $this->battle->users[$i]['animal'] . '" AND `level` < ' . $this->battle->users[$i]['level'] . ' LIMIT 1' + ); + if ($upd) { + $this->battle->users[$i]['battle_exp'] = round($this->battle->users[$i]['battle_exp'] / 100 * 67); + $this->battle->info['addExp'] -= 33.333; + } + } + } + + $prsusers = mysql_fetch_array( + mysql_query( + 'SELECT SUM(`price1`) FROM `battle_users` WHERE `battle` = "' . $this->battle->info['id'] . '" LIMIT 1' + ) + ); + + $btlstatus = $this->typeBattle($prsusers[0]); + if ($this->battle->info['smert'] == 1) { + $btlstatus = [150, 150, 'Жесточайшее Сражение', 'Жесточайшее Сражение']; + } + // + if ($this->battle->stats[$i]['clanpos'] > 0 && ($this->battle->stats[$i]['clanpos'] == 1 || $this->battle->stats[$i]['clanpos'] == 2 || $this->battle->stats[$i]['clanpos'] == 3)) { + $this->battle->info['addExp'] += 0; + } + + unset($r1); + //Статусная битва + if ($btlstatus[0] > 0) { + if ($this->battle->info['type'] == 99) { + $this->battle->info['addExp'] += $btlstatus[1]; + } else { + $this->battle->info['addExp'] += $btlstatus[0]; + } + } + + if ($this->battle->users[$i]['align'] == 2 || $this->battle->users[$i]['haos'] > time()) { + $this->battle->stats[$i]['exp'] = -($this->battle->info['addExp'] + 50); + } + if ($this->battle->info['addExp'] + $this->battle->stats[$i]['exp'] != 0) { + $prc = ' (' . (100 + $this->battle->info['addExp'] + $this->battle->stats[$i]['exp']) . '%)'; + } + if ($this->battle->info['money'] > 0) { + if (isset($gm[$i])) { + $prc .= ' Вы выйграли ' . $gm[$i] . ' кр. за этот бой.'; + Delo::add( + 4, + 'System.battle', + $this->battle->users[$i]['id'], + '"System.battle": Персонаж выйграл ' . $gm[$i] . ' кр. (В бою №' . $this->battle->info['id'] . ').', + ); + $this->battle->users[$i]['money'] += $gm[$i]; + } elseif (isset($bm[$i])) { + $prc .= ' Вы заплатили ' . $bm[$i] . ' кр. за этот бой.'; + Delo::add( + 4, + 'System.battle', + $this->battle->users[$i]['id'], + '"System.battle": Персонаж проиграл ' . $gm[$i] . ' кр. (В бою №' . $this->battle->info['id'] . ').', + ); + $this->battle->users[$i]['money'] -= $bm[$i]; + } + } + if (Config::get('money_haot') && $this->battle->users[$i]['exp'] <= 200000000 && $act01 == 1 && $this->battle->info['razdel'] == 5 && $this->battle->users[$i]['level'] >= 8) { + //Сколько нужно опыта набить + $trexp = [ + 8 => 1200, + 9 => 3000, + 10 => 4500, + 11 => 12000, + 12 => 20000, + 13 => 30000, + 14 => 30000, + 15 => 30000, + 16 => 30000, + 17 => 30000, + 18 => 30000, + 19 => 30000, + 20 => 30000, + 21 => 30000, + ]; + $trexp = $trexp[$this->battle->users[$i]['level']]; + + //Сколько екр дается + $admn = [ + 8 => 0.05, //0.05 + 9 => 0.065, //0.065 + 10 => 0.075, //0.075 + 11 => 0.085, //0.085 + 12 => 0.1, //0.1 + 13 => 0.1, + 14 => 0.1, + 15 => 0.1, + 16 => 0.1, + 17 => 0.1, + 18 => 0.1, + 19 => 0.1, + 20 => 0.1, + 21 => 0.1, + ]; + $admn = $admn[$this->battle->users[$i]['level']]; + + if (Config::get('m') >= 6 && Config::get('m') <= 8) { + //Летний период + if (Config::get('w') == 0 || Config::get('w') == 5 || Config::get('w') == 6) { + //Выходные дни + $admn = $admn * 2; + } + } elseif (Config::get('w') == 0 || Config::get('w') == 5 || Config::get('w') == 6) { + //Выходные дни + $admn = $admn * 2; + } + if ($this->battle->users[$i]['battle_exp'] < $trexp) { + $prc .= ', Награда 0 ЕКР за этот бой (Мало опыта набили).'; + } elseif ($admn > 0) { + if ($this->battle->info['type'] != 33) { + $prc .= ', Награда ' . $admn . ' ЕКР за этот бой.'; + } + Delo::add( + 4, + 'System.battle', + $this->battle->users[$i]['id'], + '"System.battle": Персонаж получил ' . $admn . ' ЕКР (В бою №' . $this->battle->info['id'] . ').', + ); + $this->battle->users[$i]['money2'] += $admn; + } + } + if ($this->battle->info['money3'] > 0) { + if (isset($gms[$i])) { + $prc .= ' Вы выйграли ' . $gms[$i] . ' $. за этот бой.'; + Delo::add( + 4, + 'System.battle', + $this->battle->users[$i]['id'], + '"System.battle": Персонаж выйграл ' . $gms[$i] . ' $. (В бою №' . $this->battle->info['id'] . ').', + ); + $this->battle->users[$i]['money3'] += $gms[$i]; + mysql_query( + 'UPDATE `users` SET `money3` = `money3` + "' . $gms[$i] . '" WHERE `id` = "' . $this->battle->users[$i]['id'] . '" LIMIT 1' + ); + } elseif (isset($bms[$i])) { + $prc .= ' Вы заплатили ' . $bms[$i] . ' $. за этот бой.'; + Delo::add( + 4, + 'System.battle', + $this->battle->users[$i]['id'], + '"System.battle": Персонаж проиграл ' . $gms[$i] . ' $. (В бою №' . $this->battle->info['id'] . ').', + ); + $this->battle->users[$i]['money3'] -= $bms[$i]; + mysql_query( + 'UPDATE `users` SET `money3` = `money3` - "' . $bms[$i] . '" WHERE `id` = "' . $this->battle->users[$i]['id'] . '" LIMIT 1' + ); + } + } + + $lime = [ + 8 => 18000, + 9 => 28000, + 10 => 84000, + 11 => 100, + 12 => 100, + 13 => 100, + 14 => 100, + 15 => 100, + 16 => 100, + 17 => 100, + 18 => 100, + 19 => 100, + 20 => 100, + 21 => 100, + ]; + + if ($this->battle->users[$i]['level'] < 8) { + $lime = 5400; + } else { + $lime = $lime[$this->battle->users[$i]['level']]; + } + + if ($this->battle->stats[$i]['silver'] >= 5) { + $lime += round($lime); + } + + if ($this->battle->users[$i]['stopexp'] == 1) { + $lime = 0; + $this->battle->users[$i]['battle_exp'] = 0; + } + + if ($lime < $this->battle->users[$i]['battle_exp'] && Config::get('limitedexp')) { + $this->battle->users[$i]['battle_exp'] = $lime; + } + + unset($lime); + + if ($btlstatus[0] > 0) { + if ($this->battle->info['type'] == 99) { + $prc .= ' (' . $btlstatus[3] . ')'; + } else { + $prc .= ' (' . $btlstatus[2] . ')'; + } + } + + if ($this->battle->info['dungeon'] == 1 && $this->battle->users[$i]['team'] == $this->battle->info['team_win']) { + //канализация лимит + $rep = mysql_fetch_array( + mysql_query( + 'SELECT `dl1`,`id` FROM `rep` WHERE `id` = "' . $this->battle->users[$i]['id'] . '" LIMIT 1' + ) + ); + if ($rep['dl' . $this->battle->info['dungeon']] > 0) { + $this->battle->users[$i]['battle_exp'] += 3 * count($this->battle->users); + if ($rep['dl' . $this->battle->info['dungeon']] > $this->battle->users[$i]['battle_exp']) { + $rep['dl' . $this->battle->info['dungeon']] -= $this->battle->users[$i]['battle_exp']; + } else { + $this->battle->users[$i]['battle_exp'] = $rep['dl' . $this->battle->info['dungeon']]; + $rep['dl' . $this->battle->info['dungeon']] = 0; + } + mysql_query( + 'UPDATE `rep` SET `dl' . $this->battle->info['dungeon'] . '` = "' . $rep['dl' . $this->battle->info['dungeon']] . '" WHERE `id` = "' . $rep['id'] . '" LIMIT 1' + ); + } else { + $this->battle->users[$i]['battle_exp'] = 0; + } + } + + if ($this->battle->users[$i]['battle_exp'] < 1) { + $this->battle->users[$i]['battle_exp'] = 0; + } + + if ( + $this->battle->users[$i]['battle_exp'] < 1 && + $this->battle->users[$i]['twink'] == 0 && + $this->battle->info['money'] == 0 && + $this->battle->info['money3'] == 0 && + $this->battle->info['kingfight'] == 0 && + (!isset($admnb) || $admnb == 0) + ) { + $prc = ''; + } + + if ($this->battle->users[$i]['host_reg'] == 'real_bot_user') { + $this->battle->users[$i]['battle_exp'] = round($this->battle->users[$i]['battle_exp'] / 3); + } + + if ($sinf != '') { + $sinf = ' ( ' . $sinf . ' )'; + } + + //--------------Лимит 8-9-------------- + if ($this->battle->users[$i]['level'] == 8 && $this->battle->users[$i]['battle_exp'] >= 23000) { + $this->battle->users[$i]['battle_exp'] = 23000; + } + if ($this->battle->users[$i]['level'] == 9 && $this->battle->users[$i]['battle_exp'] >= 31000) { + $this->battle->users[$i]['battle_exp'] = 31000; + } + if ($this->battle->users[$i]['level'] == 10 && $this->battle->users[$i]['battle_exp'] >= 52000) { + $this->battle->users[$i]['battle_exp'] = 52000; + } + if ($this->battle->users[$i]['level'] >= 11 && $this->battle->users[$i]['battle_exp'] >= 75000) { + $this->battle->users[$i]['battle_exp'] = 75000; + } + //------------------------------------- + + if ($this->battle->info['type'] != 33) { + $this->battle->users[$i]['battle_text'] = 'Бой закончен. Всего вами нанесено урона: ' . floor( + $this->battle->users[$i]['battle_yron'] + ) . ' HP. Получено опыта: ' . (0 + $this->battle->users[$i]['battle_exp']) . '' . $prc . '.' . $sinf; //stats + } + + //Снижение времени Право на подвиг Титул за победу в хаоте + if ($this->battle->info['dungeon'] == 0 && $this->battle->info['razdel'] == 5 && $this->battle->users[$i]['team'] == $this->battle->info['team_win']) { + //ТУТ2 + StatsModel::addRepexpById($this->battle->users[$i]['id'], 2); //Репутация за поб в хаоте +2 + $check = mysql_fetch_array( + mysql_query( + 'SELECT * FROM `eff_users` WHERE `id_eff` = 478 AND `uid` = "' . $this->battle->users[$i]['id'] . '" AND `delete` = 0 ORDER BY `overType` DESC LIMIT 1;' + ) + ); + if (isset($check['id'])) { + $urcheck = 10000; + if ($this->battle->users[$i]['level'] == 8) { + $urcheck = 3000; + } elseif ($this->battle->users[$i]['level'] == 9) { + $urcheck = 7000; + } elseif ($this->battle->users[$i]['level'] == 10) { + $urcheck = 12000; + } elseif ($this->battle->users[$i]['level'] >= 11) { + $urcheck = 18000; + } + + if ($this->battle->users[$i]['battle_yron'] >= $urcheck) { + mysql_query( + 'UPDATE `eff_users` SET `timeUse` = `timeUse` - 300 WHERE `id_eff`=478 AND `delete` = 0 AND `uid` =' . $this->battle->users[$i]['id'] . ' LIMIT 1' + ); + $this->battle->users[$i]['battle_text'] .= ' За победу в хаоте и нанесение урона в ' . $urcheck . ' и более вы получаете -5 мин. к праву на подвиг!'; + } + } + mysql_query( + 'UPDATE `users_achiv` SET `vx`= `vx`+1 WHERE `id` = "' . $this->battle->users[$i]['id'] . '" LIMIT 1' + ); // + + } + //Награда за клан вар + if ($this->battle->info['dungeon'] == 0 && $this->battle->info['type'] == 250 && $this->battle->users[$i]['team'] == $this->battle->info['team_win']) { + mysql_query( + 'UPDATE `users_achiv` SET `kw`= `kw`+1 WHERE `id` = "' . $this->battle->users[$i]['id'] . '" LIMIT 1' + ); + if (date('w') == 0 || date('w') == 6 || date('w') == 4) { + StatsModel::addRepexpById($this->battle->users[$i]['id'], 25); //Клановые войны(победа) 25 + } + } + //Награда за клан вар + if ( + $this->battle->info['dungeon'] == 0 && + $this->battle->info['type'] == 99 && + $this->battle->users[$i]['team'] == $this->battle->info['team_win'] && + (date('w') == 0 || date('w') == 6 || date('w') == 5) + ) { + StatsModel::addRepexpById($this->battle->users[$i]['id'], 10); //Кровавые войны(победа) 10 + } + + //Новая выдача на трупожора + if ($this->battle->info['dungeon'] == 0 && $this->battle->info['type'] == 500 && $this->battle->users[$i]['team'] == $this->battle->info['team_win'] && $this->battle->users[$i]['no_ip'] != 'trupojor' && $this->battle->users[$i]['bot'] == 0) { + if ($this->battle->users[$i]['level'] > 9) { + $mid = 903093; + } else { + $mid = 89489; + } + $mon = mysql_fetch_array( + mysql_query('SELECT * FROM `aaa_monsters` WHERE `uid` = "' . $mid . '" LIMIT 1') + ); + + if ($this->battle->users[$i]['battle_yron'] >= 1500) { + $ritem = rand(1, 100); + if ($ritem <= 20) { + $mon['win_itm'] = '4459@1'; + } elseif ($ritem <= 40) { + $mon['win_itm'] = '4460@1'; + } elseif ($ritem <= 60) { + $mon['win_itm'] = '4461@1'; + } elseif ($ritem <= 80) { + $mon['win_itm'] = '4462@1'; + } else { + $mon['win_itm'] = '4463@1'; + } + } elseif ($this->battle->users[$i]['battle_yron'] >= 1000) { + $ritem = rand(1, 100); + if ($ritem <= 25) { + $mon['win_itm'] = '4460@1'; + } elseif ($ritem <= 50) { + $mon['win_itm'] = '4461@1'; + } elseif ($ritem <= 75) { + $mon['win_itm'] = '4462@1'; + } else { + $mon['win_itm'] = '4463@1'; + } + } else { + $mon['win_itm'] = '4392@1'; + } + if ($this->battle->users[$i]['battle_yron'] > 0) { + mysql_query( + 'INSERT INTO `eff_users` (`no_Ace`,`id_eff`,`overType`,`uid`,`name`,`data`,`timeUse`) VALUES ("1","478","111","' . $this->battle->users[$i]['id'] . '","Право на подвиг","pravonapodvig=1","' . time( + ) . '")' + ); + } + mysql_query( + 'INSERT INTO `actions`(`uid`, `time`, `city`, `room`, `vars`, `ip`, `vals`, `val`) VALUES ("' . $this->battle->users[$i]['id'] . '","' . time( + ) . '","capitalcity","' . $this->battle->users[$i]['room'] . '","end_trup"," ","","")' + ); + mysql_query( + 'INSERT INTO `eff_users` (`no_Ace`,`id_eff`,`overType`,`uid`,`name`,`data`,`timeUse`) VALUES ("1","479","112","' . $u->info['id'] . '","Защита от нападения","zashitatk=1","' . time( + ) . '")' + ); + $ritem = rand(1, 1000); + if ($ritem == 555) { + $mon['win_itm'] = $mon['win_itm'] . ',5022@1'; + } + // + $this->addGlobalItems( + $mid, + $this->battle->users[$i]['id'], + $mon['win_itm'], + $mon['win_ico'], + 1, + $mon['win_money1'], + $mon['win_money2'] + ); + + } + + if ( + ($this->battle->info['razdel'] == 5 || $this->battle->info['razdel'] == 4) && + (date('d.m') == '31.10' || (date('m') == 11 && date('d') < 7)) + ) { + //Хэллоуин 4504 + $this->battle->users[$i]['battle_text'] .= ' Вы получаете Тыква (x1).'; + ItemsModel::addItem(4504, $this->battle->users[$i]['id'], '|sudba=1'); + } + + + //Добавляем воинственность + if ( + $this->battle->info['dungeon'] == 0 && + $this->battle->info['razdel'] == 5 && + $this->battle->users[$i]['exp'] >= 1500 && + $this->battle->users[$i]['battle_exp'] > 100 * $this->battle->users[$i]['level'] + ) { + $rzbvo = $this->battle->users[$i]['battle_exp'] * 6 / 1000; + + if ($this->battle->users[$i]['level'] == 8 && $rzbvo >= 100) { + $rzbvo = 100; + } + if ($this->battle->users[$i]['level'] == 9 && $rzbvo >= 150) { + $rzbvo = 150; + } + if ($this->battle->users[$i]['level'] == 10 && $rzbvo >= 200) { + $rzbvo = 200; + } + if ($this->battle->users[$i]['level'] == 11 && $rzbvo >= 250) { + $rzbvo = 250; + } + if ($this->battle->users[$i]['level'] == 12 && $rzbvo >= 250) { + $rzbvo = 250; + } + + if ($this->battle->info['type'] != 33) { + $this->battle->users[$i]['battle_text'] .= ' Вы получили ' . $rzbvo . ' воинственности за этот бой.'; + } + mysql_query( + 'UPDATE `rep` SET `rep3` = `rep3` + "' . $rzbvo . '" WHERE `id` = "' . $this->battle->users[$i]['id'] . '" LIMIT 1' + ); + mysql_query( + 'INSERT INTO `actions`(`uid`, `time`, `city`, `room`, `vars`, `ip`, `vals`, `val`) VALUES ("' . $this->battle->users[$i]['id'] . '","' . time( + ) . '","capitalcity","' . $this->battle->users[$i]['room'] . '","end_xaot"," ","","")' + ); + } + + if ($this->battle->stats[$i]['hpNow'] >= 1) { + $this->battle->stats[$i]['test_heal'] = mysql_fetch_array( + mysql_query( + 'SELECT SUM(`yrn`) FROM `battle_stat` WHERE `uid2` = "' . $this->battle->users[$i]['id'] . '" AND `battle` = "' . $this->battle->info['id'] . '" LIMIT 1' + ) + ); + $this->battle->stats[$i]['test_heal'] = $this->battle->stats[$i]['test_heal'][0]; + $this->battle->stats[$i]['test_start'] = mysql_fetch_array( + mysql_query( + 'SELECT `hpStart` FROM `battle_users` WHERE `uid` = "' . $this->battle->users[$i]['id'] . '" AND `battle` = "' . $this->battle->info['id'] . '" LIMIT 1' + ) + ); + $this->battle->stats[$i]['test_start'] = $this->battle->stats[$i]['test_start']['hpStart']; + // + $this->battle->stats[$i]['hpNow'] = ($this->battle->stats[$i]['test_start'] - $this->battle->stats[$i]['test_heal']); + if ($this->battle->stats[$i]['hpNow'] < 1) { + $this->battle->stats[$i]['hpNow'] = 1; + } + } else { + $this->battle->stats[$i]['hpNow'] = 0; + } + + unset($this->battle->stats[$i]['test_heal']); + + $this->battle->users[$i]['last_b'] = $this->battle->info['id']; //stats + $this->battle->users[$i]['last_a'] = $act01; + $this->battle->users[$i]['battle'] = -1; //users + $this->battle->users[$i]['battle_yron'] = 0; //stats + + $this->battle->users[$i]['exp'] += $this->battle->users[$i]['battle_exp']; //users + + //Добавляем клан опыт (Все кроме пещер) + + if ($this->battle->users[$i]['clan'] > 0) { + $cpr = 1; + if ($this->battle->info['typeBattle'] == 9) { + $cpr = 25; + } elseif ($this->battle->info['typeBattle'] == 50) { + $cpr = 65; + } + if ($this->battle->stats[$i]['silver'] >= 5) { + $cpr = floor($cpr / 100 * 150); + } + + Clan::addExp( + round($this->battle->users[$i]['battle_exp'] / 100 * $cpr), + $this->battle->users[$i]['clan'] + ); + } + + $this->battle->users[$i]['battle_exp'] = 0; //stats + + if ($this->battle->users[$i]['team'] == $this->battle->info['team_win']) { + $r = new Reputation($this->battle->users[$i]['id']); + $r->addRep('n_capitalcity', $this->battle->users[$i]['bn_capitalcity']); + $r->addRep('n_demonscity', $this->battle->users[$i]['bn_demonscity']); + $r->addRep('n_suncity', $this->battle->users[$i]['bn_suncity']); + } + + //репутация + $this->battle->users[$i]['bn_demonscity'] = 0; + $this->battle->users[$i]['bn_capitalcity'] = 0; + $this->battle->users[$i]['bn_suncity'] = 0; + + //обновляем данные + Effects::removePriems($this->battle->users[$i]['id']); + + $this->dieInDungeon($dnr, $i, $u, $cmsg, $chat); + + Db::sql('update users set login2 = default where battle = ?', [$this->battle->info['id']]); + Db::sql( + 'update users set login2 = default, money = ?, money2 = ?, win = ?, lose = ?, nich = ?, battle = -1 where id = ?', + [ + $this->battle->users[$i]['money'], + $this->battle->users[$i]['money2'], + $this->battle->users[$i]['win'], + $this->battle->users[$i]['lose'], + $this->battle->users[$i]['nich'], + $this->battle->users[$i]['id'], + ] + ); + + if ($u->info['id'] == $this->battle->users[$i]['id']) { + $u->info['battle_text'] = $this->battle->users[$i]['battle_text']; + } + + Db::sql( + 'update stats set hpNow = ?, mpNow = ?, tactic7 = 10, x = ?, y = ?, exp = ?, battle_exp = ?, battle_text = ?, last_b = ?, regHP = unix_timestamp(), regMP = unix_timestamp() + where id = ?', + [ + $this->battle->stats[$i]['hpNow'], + $this->battle->stats[$i]['mpNow'], + $this->battle->users[$i]['x'], + $this->battle->users[$i]['y'], + $this->battle->users[$i]['exp'], + $this->battle->users[$i]['battle_exp'], + $this->battle->users[$i]['battle_text'], + $this->battle->info['id'], + $this->battle->users[$i]['id'], + ] + ); + + if ($this->battle->info['turnir'] == 0) { + //пишем в чат + $cmsg->setTo($this->battle->users[$i]['login']); + $cmsg->setText($this->battle->users[$i]['battle_text']); + $chat->sendMsg($cmsg); + } else { + Db::sql('update turnirs set winner = ? where id = ?', [$this->battle->info['team_win'], $this->battle->info['turnir']]); + } + //завершаем сам бой + Db::sql('update battle set time_over = unix_timestamp(), team_win = ? where id = ?', [$this->battle->info['team_win'], $this->battle->info['id']]); + + // Жрать хочет + if ($this->battle->users[$i]['animal'] > 0) { + $a = mysql_fetch_array( + mysql_query( + 'SELECT * FROM `users_animal` WHERE `uid` = "' . $this->battle->users[$i]['id'] . '" AND `id` = "' . $this->battle->users[$i]['animal'] . '" AND `pet_in_cage` = "0" AND `delete` = "0" LIMIT 1' + ) + ); + if (isset($a['id']) && $a['eda'] < 1) { + $cmsg = new ChatMessage(); + $cmsg->setRoom($this->battle->users[$i]['room']); + $cmsg->setTo($this->battle->users[$i]['login']); + $cmsg->setText('' . $a['name'] . ' нуждается в еде...'); + $cmsg->setType(6); + $chat->sendMsg($cmsg); + } + } + mysql_query( + 'UPDATE `stats` SET `battle_text` = "",`last_b`="0" WHERE `id` = "' . $this->battle->users[$i]['id'] . '" LIMIT 1' + ); + mysql_query('UPDATE `battle_users` SET `finish` = 1 WHERE `uid` = "' . $this->battle->users[$i]['id'] . '"'); + $this->saveLogs(); + if ($u->info['battle'] != 0 && !isset($u->info['battle_lsto'])) { + echo ''; + } + } + + } + mysql_query('UPDATE `battle` SET `testfinish` = "0" WHERE `id` = "' . $this->battle->info['id'] . '" LIMIT 1'); + mysql_query('UNLOCK TABLES'); + } + + private function addItemToItemsLocal(int $itemId, int $uid, string $data = ''): void + { + Db::sql( + "insert into items_local (room, time, item_id, data, tr_login, colvo) values (?,unix_timestamp(),?,?,?,1)", + [ + $this->battle->users[$this->battle->uids[$uid]]['room'], + $itemId, + $data, + $this->battle->users[$this->battle->uids[$uid]]['login'], + ] + ); + } + + private function addGlobalItems($bid, $uid, $itm, $ico, $exp, $cr, $ecr): void + { + global $u; + $chat = new Chat(); + $cmsg = new ChatMessage(); + $cmsg->setType(6); + $cmsg->setRoom($this->battle->users[$this->battle->uids[$uid]]['room']); + $cmsg->setTo($this->battle->users[$this->battle->uids[$uid]]['login']); + $cmsg->setColor('#cb0000'); + + $this->addGlobalItemsDropsOnMainStreet($bid, $uid); + + if ($exp >= 0) { + //added if, was division by zero. 27.08.22, ins. + $this->battle->users[$this->battle->uids[$uid]]['battle_exp'] += round( + $this->battle->stats[$this->battle->uids[$bid]]['hpAll'] > 0 ? + $exp * $this->battle->users[$this->battle->uids[$uid]]['battle_yron'] / $this->battle->stats[$this->battle->uids[$bid]]['hpAll'] : + $exp * $this->battle->users[$this->battle->uids[$uid]]['battle_yron'] + ); + Db::sql( + 'update stats set battle_exp = ? where id = ?', + [ + $this->battle->users[$this->battle->uids[$uid]]['battle_exp'], + $uid, + ] + ); + } + + if (!empty($cr) && $this->battle->stats[$this->battle->uids[$uid]]['hpNow'] > 0) { + $this->battle->users[$this->battle->uids[$uid]]['money'] += (int)$cr; + $u->addKr((int)$cr, $uid); + $cmsg->setText("Вы получили кредиты: $cr кр."); + $chat->sendMsg($cmsg); + } + + if (!empty($ecr) && $this->battle->stats[$this->battle->uids[$uid]]['hpNow'] > 0) { + $this->battle->users[$this->battle->uids[$uid]]['money2'] += (int)$ecr; + + $u->addEkr((int)$ecr, $uid); + + $cmsg->setText("Вы получили еврокредиты: $ecr екр."); + $chat->sendMsg($cmsg); + Delo::add( + 4, + 'System.battle', + $this->battle->users[$this->battle->uids[$uid]]['id'], + '"System.battle": Персонаж получил ' . $ecr . ' ЕКР (В бою трупожор), сейчас: ' . + $this->battle->users[$this->battle->uids[$uid]]['money2'] . ' ЕКР', + ); + + } + + $this->addGlobalItemsIco($ico, $uid, $cmsg, $chat); + $this->addGlobalItemItm($itm, $uid, $cmsg, $chat); + } + + /** + * Сохраняем лог в архив + * @return void + */ + private function saveLogs(): void + { + Db::sql( + 'insert into battle_logs_save select id, time, battle, id_hod, text, vars, zona1, zonb1, zona2, zonb2, type from battle_logs where battle = ? and id_hod <= ?', + [$this->battle->info['id'], $this->battle->hodID] + ); + Db::sql('delete from battle_logs where battle = ?', [$this->battle->info['id']]); + Db::sql('delete from battle_stat where battle < ?', [$this->battle->info['id'] - 100]); + Db::sql('delete from battle_actions where btl = ?', [$this->battle->info['id']]); + } + + private function typeBattle(int $x): array + { + $r = [0, 0, 'Обычный поединок', 'Кровавый Поединок']; + if ($x >= 50000 && $x < 100000) { + $r = [25, 50, 'Великая Битва', 'Кровавая Битва']; + } elseif ($x < 500000) { + $r = [50, 75, 'Величайшая Битва', 'Кровавая Резня']; + } elseif ($x < 1000000) { + $r = [75, 100, 'Историческая Битва', 'Кровавая Сеча']; + } elseif ($x < 2500000) { + $r = [100, 125, 'Эпохальная Битва', 'Кровавое Побоище']; + } elseif ($x >= 5000000) { + $r = [150, 150, 'Судный День', 'Судный День']; + } + return $r; + } + + private function dieInDungeon(int $dnr, int $i, User $u, ChatMessage $cmsg, Chat $chat): void + { + if ($dnr != 1) { + return; + } + + $vars = $this->battle->users[$i]['room'] == 370 ? 'dielaba' : 'die'; + $dies = Actions::countDungeon( + $this->battle->users[$i]['dnow'], + $this->battle->users[$i]['id'], + $vars + ); + Actions::addDungeon( + $this->battle->users[$i]['dnow'], + $this->battle->users[$i]['id'], + $this->battle->users[$i]['x'], + $this->battle->users[$i]['y'], + $vars + ); + + $la = $this->battle->users[$i]['sex'] == 1 ? 'ла' : ''; + + if ($dies < 2 || $this->battle->info['dungeon'] == 15) { + + $shaibaItemId = Db::getValue('select id from items_users where uid = ? and item_id = 4910 limit 1', [$this->battle->users[$i]['id']]); + + if ($shaibaItemId) { + //выбрасываем шайбу + ItemsModel::delete($shaibaItemId); + Db::sql( + "insert into dungeon_obj (name, dn, x, y, img, action, w, h, os1, os2, os3, date) + values ('Шайба',?,?,?,'shaiba.png','fileact:15/shaiba',120,220,5,8,12,?)", + [ + $this->battle->info['dn_id'], + $this->battle->users[$i]['x'], + $this->battle->users[$i]['y'], + "{use:'takeit',rt1:69,rl1:-47,rt2:74,rl2:126,rt3:76,rl3:140,rt4:80,rl4:150}", + ] + ); + } + + //телепортируем в рестарт (координата 0х0) + $this->battle->users[$i]['x'] = $this->battle->users[$i]['res_x']; + $this->battle->users[$i]['y'] = $this->battle->users[$i]['res_y']; + $this->battle->users[$i]['s'] = $this->battle->users[$i]['res_s']; + + $roomName = Db::getValue('select name from room where id = ?', [(int)$this->battle->users[$i]['room']]); + + $reviveRoomName = $this->battle->users[$i]['room'] == 370 ? 'начале лабиринта' : "комнате «{$roomName}»"; + $rtxt = "{$this->battle->users[$i]['login']} трагически погиб$la и находится в $reviveRoomName"; + + } elseif ($this->battle->info['dungeon'] == 102) { + $nld = ''; + $lab = Db::getRow('select id, users from laba_now where id = ?', [$this->battle->users[$i]['id']]); + + if ($lab['users'] < 2) { + //Удаляем подземелье + Db::sql('delete from laba_now where id = ?', [$lab['id']]); + Db::sql('delete from laba_map where id = ?', [$lab['id']]); + Db::sql('delete from laba_obj where lib = ?', [$lab['id']]); + Db::sql('delete from laba_act where lib = ?', [$lab['id']]); + Db::sql('delete from laba_itm where lib = ?', [$lab['id']]); + } else { + $lab['users']--; + mysql_query( + 'UPDATE `laba_now` SET `users` = "' . $lab['users'] . '" WHERE `id` = "' . $lab['id'] . '" LIMIT 1' + ); + } + mysql_query( + 'UPDATE `stats` SET `dnow` = "0" WHERE `id` = "' . $this->battle->users[$i]['id'] . '" LIMIT 1' + ); + mysql_query( + 'UPDATE `users` SET `room` = "369" WHERE `id` = "' . $this->battle->users[$i]['id'] . '" LIMIT 1' + ); + //удаляем все предметы которые пропадают после выхода из пещеры + mysql_query( + 'UPDATE `items_users` SET `delete` = "' . time( + ) . '" WHERE `uid` = "' . $this->battle->users[$i]['id'] . '" AND `delete` < 1234567890 AND `inShop` = "0" AND (`dn_delete` = "1" OR `data` LIKE "%fromlaba=1%")' + ); + if ($this->battle->users[$i]['login'] != '') { + if ($this->battle->users[$i]['sex'] == 0) { + $rtxt = '' . $this->battle->users[$i]['login'] . ' трагически погиб без права на воскрешение и покидает подземелье' . $nld; + } else { + $rtxt = '' . $this->battle->users[$i]['login'] . ' трагически погибла без права на воскрешение и покидает подземелье' . $nld; + } + } + } else { + $tinf = mysql_fetch_array( + mysql_query( + 'SELECT `uid` FROM `dungeon_now` WHERE `id` = "' . $this->battle->info['dn_id'] . '" LIMIT 1' + ) + ); + $nld = ''; + if ($tinf['uid'] == $this->battle->users[$i]['id']) { + $tinf = mysql_fetch_array( + mysql_query( + 'SELECT `id` FROM `stats` WHERE `dnow` = "' . $this->battle->info['dn_id'] . '" AND `hpNow` >= 1 LIMIT 1' + ) + ); + if (isset($tinf['id'])) { + $tinf = mysql_fetch_array( + mysql_query( + 'SELECT `id`,`login` FROM `users` WHERE `id` = "' . $tinf['id'] . '" LIMIT 1' + ) + ); + $nld .= ', новым лидером становится "' . $tinf['login'] . '"'; + mysql_query( + 'UPDATE `dungeon_now` SET `uid` = "' . $tinf['id'] . '" WHERE `id` = "' . $this->battle->info['dn_id'] . '" LIMIT 1' + ); + } + } + + mysql_query( + 'UPDATE `stats` SET `dnow` = "0" WHERE `id` = "' . $this->battle->users[$i]['id'] . '" LIMIT 1' + ); + mysql_query( + 'UPDATE `users` SET `room` = "321" WHERE `id` = "' . $this->battle->users[$i]['id'] . '" LIMIT 1' + ); + //удаляем все предметы которые пропадают после выхода из пещеры + mysql_query( + 'UPDATE `items_users` SET `delete` = "' . time() . '" WHERE `uid` = "' . $this->battle->users[$i]['id'] . '" AND `dn_delete` = "1" LIMIT 1000' + ); + 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' + ); + + if ($this->battle->users[$i]['sex'] == 0) { + $rtxt = '' . $this->battle->users[$i]['login'] . ' трагически погиб без права на воскрешение и покидает подземелье' . $nld; + } else { + $rtxt = '' . $this->battle->users[$i]['login'] . ' трагически погибла без права на воскрешение и покидает подземелье' . $nld; + } + } + if (!empty($rtxt)) { + $cmsg->setDn($this->battle->info['dn_id']); + $cmsg->setText($rtxt); + $cmsg->setTypeTime(1); + $chat->sendMsg($cmsg); + } + } + + private function addGlobalItemsIco(string $ico, int $uid, ChatMessage $cmsg, Chat $chat): void + { + if (empty($ico)) { + return; + } + /** + ** $exploded[]: + * 0 (тип, 1 - значок, 2 - подвиг)@ + * 1 (время в минутах)@ + * 2 (название картинки)@ + * 3 (название)@ + * 4 (требует остаться в живых 0 или 1, либо игрок умер -1)@ + * 5 (требует набить с ботам урона в % Например 0.001)@ + * 6 (действия например: add_s1=5|add_hpAll=50)@ + * 7 (Требует другой значок, название картинки)@ + * 8 (плюсует значок 0 или 1)@ + * 9 (удаляем прошлый значок 0 or 1) + */ + + $txt = ''; + + foreach (explode('#', $ico) as $icon) { + $exploded = explode('@', $icon); + if (empty($exploded[3])) { + continue; + } + $add = 1; + if ($exploded[4] == 1 && floor($this->battle->stats[$this->battle->uids[$uid]]['hpNow']) < 1) { + $add = 0; + } + if ($add != 1) { + continue; + } + + $ins = false; + if ($exploded[8] == 0) { + $ins = true; + if ($exploded[9] == 1) { + Db::sql('delete from users_ico where uid = ? and img = ?', [$uid, $exploded[2]]); + } + } else { + $oldIcoId = Db::getValue( + 'select id from users_ico where uid = ? and img = ? and (endTime > unix_timestamp() or endTime = 0)', + [$uid, $exploded[2]] + ); + if (!$oldIcoId || $oldIcoId < 1) { + $ins = true; + } else { + $txt .= ", «$exploded[3] (Обновление)»"; + Db::sql( + 'update users_ico set x = x + 1, endTime = unix_timestamp() + ? * 60 where id = ?', + [$exploded[1], $oldIcoId] + ); + } + } + if (!$ins) { + continue; + } + if ($exploded[9] == 1) { + Db::sql('delete from users_ico where uid = ? and img = ?', [$uid, $exploded[2]]); + } + Db::sql( + 'insert into users_ico (uid, time, text, img, endTime, type, bonus) values (?,unix_timestamp(),?,?,unix_timestamp() + ? * 60,?,?)', + [ + $uid, + $exploded[3], + $exploded[2], + $exploded[1], + $exploded[0], + $exploded[6], + ] + ); + $txt .= ", «$exploded[3]»"; + } + + if (!empty($txt)) { + $txt = ltrim($txt, ', '); + $cmsg->setText("Вы совершили подвиг: $txt"); + $chat->sendMsg($cmsg); + } + } + + private function addGlobalItemItm($itm, $uid, ChatMessage $cmsg, Chat $chat): void + { + if (empty($itm)) { + return; + } + /** + ** $exploded[]: + * 0 (id предмета)@ + * 1 (количество предметов)@ + * 2 (data предмета |add_s1=5|add_hpAll=50)@ + */ + + $txt = ''; + + foreach (explode(',', $itm) as $item) { + $exploded = explode('@', $item); + if ($exploded[0] < 1) { + continue; + } + for ($i = 0; $i < $exploded[1]; $i++) { + ItemsModel::addItem($exploded[0], $uid, "|$exploded[2]"); + } + if (empty($this->ainm[$exploded[0]])) { + $this->ainm[$exploded[0]] = + Db::getRow('select id, name from items_main where id = ?', [$exploded[0]]); + } + if (empty($this->ainm[$exploded[0]]['id'])) { + continue; + } + $txt .= ", {$this->ainm[$exploded[0]]['name']}"; + if ($exploded[1] > 1) { + $txt .= ", (x$exploded[1])"; + } + } + + if ($txt != '') { + $txt = ltrim($txt, ', '); + $cmsg->setText("Вы получили предметы: $txt"); + $chat->sendMsg($cmsg); + } + } + + private function addGlobalItemsDropsOnMainStreet(int $bid, int $uid): void + { + //Выпадение дропа на ЦП + $mf = Db::getValue('select floor(count(id) / 20) as c from users where online > unix_timestamp() - 120'); + $mf = mt_rand(1, max($mf, 1)); + if ($bid == 1008) { + //Старый Новый Год + for ($i = 0; $i < $mf; $i++) { + if (mt_rand(0, 1) === 1) { + continue; + } + if (mt_rand(0, 86) <= 71) { + for ($j = 1; $j <= 7; $j++) { + $this->addItemToItemsLocal(1000, $uid, '|nosale=1|srok=259200'); + } + } else { + $customs = [911, 1172, 1173, 1461, 1462, 1463, 2141, 2142, 2143, 2144, 2870, 4037, 4038, 4039, 4040]; + $this->addItemToItemsLocal($customs[array_rand($customs)], $uid, '|nosale=1|srok=259200'); + } + } + } elseif ($bid == 1007) { + //Хэллоуин, Тыквоголовый CAPITAL CITY + for ($i = 0; $i < $mf; $i++) { + if (mt_rand(0, 1) === 1) { + continue; + } + $this->addItemToItemsLocal(4504, $uid); + } + } elseif ($bid == 1006 && mt_rand(1, 10) === 1 || in_array($bid, range(1000, 1004))) { + //Трупожор CAPITAL CITY + $this->addItemToItemsLocal(4451, $uid, 'srok=2592000'); + } + + + } +} \ No newline at end of file diff --git a/_incl_data/class/Battle/Helper.php b/_incl_data/class/Battle/Helper.php new file mode 100644 index 00000000..76f4de60 --- /dev/null +++ b/_incl_data/class/Battle/Helper.php @@ -0,0 +1,11 @@ +item['img']; } + + public static function getNameById(int $id): string + { + $name = Db::getValue('select name from items_main where id = ?', [$id]); + return $name ?: ''; + } } \ No newline at end of file diff --git a/_incl_data/class/Moderation/AdmFactory.php b/_incl_data/class/Moderation/AdmFactory.php index 1b8cb27c..f50e6a97 100644 --- a/_incl_data/class/Moderation/AdmFactory.php +++ b/_incl_data/class/Moderation/AdmFactory.php @@ -25,7 +25,7 @@ class AdmFactory 10, 'moderation.addmoderator', $this->targetUser['id'], - ' .' + 'Назначен на пост модератора.' ); } @@ -36,7 +36,7 @@ class AdmFactory 10, 'moderation.removemoderator', $this->targetUser['id'], - ' .' + 'Уволен с поста модератора.' ); } @@ -48,7 +48,7 @@ class AdmFactory 10, 'moderation.changegender', $this->targetUser['id'], - ' .' + 'Изменен пол персонажа.' ); } @@ -63,7 +63,7 @@ class AdmFactory 10, 'moderation.changelogin', $this->targetUser['id'], - " . $this->targetLogin => " . strip_tags($login) + "Изменен логин персонажа. $this->targetLogin => " . strip_tags($login) ); } @@ -84,7 +84,7 @@ class AdmFactory public function kickfrombattle(): void { if (empty($this->targetUser['battle'])) { - $this->status = ' .'; + $this->status = 'Персонаж не в поединке.'; return; } Db::sql('update users left join stats on users.id = stats.id @@ -94,6 +94,6 @@ class AdmFactory battle_yron = default, battle_exp = default where id = ?', [$this->targetUser['id']]); - // , ? + // В оригинале тут ещё писалась запись в лог боя, но нужна ли она? } } \ No newline at end of file diff --git a/_incl_data/class/Moderation/Announcement.php b/_incl_data/class/Moderation/Announcement.php index 33c2882a..23e6c896 100644 --- a/_incl_data/class/Moderation/Announcement.php +++ b/_incl_data/class/Moderation/Announcement.php @@ -17,13 +17,13 @@ class Announcement { echo << -

+

Мегафон

- + -
+
- + HTML; @@ -41,9 +41,9 @@ HTML; return; } - $sender = empty($_POST['announcementIsSigned']) ? '' : User::getLogin(User::start()->info['id']); + $sender = empty($_POST['announcementIsSigned']) ? 'Администрация' : User::getLogin(User::start()->info['id']); (new Chat())->sendsys("$sender: $strippedMessage"); - echo ' '; + echo 'Сообщение успешно отправлено'; } } \ No newline at end of file diff --git a/_incl_data/class/Moderation/ModFactory.php b/_incl_data/class/Moderation/ModFactory.php index 4c9c40d9..1a798fe3 100644 --- a/_incl_data/class/Moderation/ModFactory.php +++ b/_incl_data/class/Moderation/ModFactory.php @@ -10,7 +10,7 @@ use User; class ModFactory { - private const ERROR_WRONG_DURATION = ' '; + private const ERROR_WRONG_DURATION = 'Неверно указан срок наказания'; public readonly string $status; private DateTime $time; private ChatMessage $msg; @@ -21,12 +21,12 @@ class ModFactory public function __construct( private readonly string $targetLogin, private readonly string $reason, - int $moderatorsRoom // . + int $moderatorsRoom // Комната где сидит модератор. ) { $this->targetUser = User::getInfo($this->targetLogin); if (empty($this->targetUser)) { - $this->status = ' !'; + $this->status = 'Персонаж не найден!'; return; } $this->chat = new Chat(); @@ -46,7 +46,7 @@ class ModFactory } $this->time->modify("+ $minutes minute"); $this->moderation->silence($this->time, $this->reason); - $this->status = " $this->targetLogin {$this->time->format(Moderation::EXPIRATION_DATETIME_FORMAT)}."; + $this->status = "Персонажу $this->targetLogin запрещено общаться в чате до {$this->time->format(Moderation::EXPIRATION_DATETIME_FORMAT)}."; $this->msg->setText("[img[items/silence.gif]] $this->status"); $this->chat->sendMsg($this->msg); } @@ -54,11 +54,11 @@ class ModFactory public function unsilence(): void { if ($this->targetUser['molch1'] < $this->time->getTimestamp()) { - $this->status = ' !'; + $this->status = 'Персонаж не молчит!'; return; } $this->moderation->unsilence(); - $this->status = " $this->targetLogin ."; + $this->status = "С персонажа $this->targetLogin снят запрет на общение в чате."; $this->msg->setText("[img[items/pal_button3.gif]] $this->status"); $this->chat->sendMsg($this->msg); } @@ -71,8 +71,8 @@ class ModFactory } $this->time->modify("+ $days day"); $this->moderation->prison($this->time, $this->reason); - Db::sql('delete from dungeon_zv where uid = ?', [$this->targetUser['id']]); // . - $this->status = " $this->targetLogin {$this->time->format(Moderation::EXPIRATION_DATETIME_FORMAT)}."; + Db::sql('delete from dungeon_zv where uid = ?', [$this->targetUser['id']]); // Удаляем заявки в пещеры. + $this->status = "Персонаж $this->targetLogin был отправлен в тюрьму до {$this->time->format(Moderation::EXPIRATION_DATETIME_FORMAT)}."; $this->msg->setText("[img[items/jail.gif]] $this->status"); $this->chat->sendMsg($this->msg); } @@ -80,7 +80,7 @@ class ModFactory public function unprison(): void { $this->moderation->unprison(); - $this->status = " $this->targetLogin ."; + $this->status = "Персонаж $this->targetLogin был выпущен из тюрьмы."; $this->msg->setText("[img[items/jail_off.gif]] $this->status"); $this->chat->sendMsg($this->msg); } @@ -92,12 +92,12 @@ class ModFactory return; } if ($this->targetUser['info_delete'] === 1 || $this->targetUser['info_delete'] >= $this->time->getTimestamp()) { - $this->status = ' .'; + $this->status = 'Персонаж уже под подозрением.'; return; } $this->time->modify("+ $days day"); $this->moderation->depersonalize($this->time, $this->reason); - $this->status = " $this->targetLogin {$this->time->format(Moderation::EXPIRATION_DATETIME_FORMAT)}"; + $this->status = "Персонаж $this->targetLogin под подозрением до {$this->time->format(Moderation::EXPIRATION_DATETIME_FORMAT)}"; $this->msg->setText("[img[items/cui.gif]] $this->status"); $this->chat->sendMsg($this->msg); } @@ -105,11 +105,11 @@ class ModFactory public function undepersonalize(): void { if ($this->targetUser['info_delete'] <= $this->time->getTimestamp()) { - $this->status = ' .'; + $this->status = 'Персонаж не под подозрением.'; return; } $this->moderation->undepersonalize(); - $this->status = " $this->targetLogin "; + $this->status = "Персонаж $this->targetLogin больше не под подозрением"; $this->msg->setText("[img[items/uncui.gif]] $this->status"); $this->chat->sendMsg($this->msg); } @@ -119,15 +119,15 @@ class ModFactory $this->moderation->ban($this->reason); Db::sql('delete from chat where login = ?', [$this->targetLogin]); Db::sql('insert into ban_email (email, uid, nick_name) values (?,?,?)', [$this->targetUser['mail'], $this->targetUser['id'], $this->targetLogin]); - Db::sql('delete from zayvki where creator = ?', [$this->targetUser['id']]); // . - Db::sql('delete from dungeon_zv where uid = ?', [$this->targetUser['id']]); // . + Db::sql('delete from zayvki where creator = ?', [$this->targetUser['id']]); // Удаляем заявки на бой. + Db::sql('delete from dungeon_zv where uid = ?', [$this->targetUser['id']]); // Удаляем заявки в пещеры. if (!empty($this->targetUser['battle'])) { Db::sql( 'update users left join stats on users.id = stats.id set battle = default, regHP = unix_timestamp(), team = 0, battle_yron = 0, battle_exp = 0 where users.id = ?', [$this->targetUser['id']] ); } - $this->status = " $this->targetLogin "; + $this->status = "Персонаж $this->targetLogin заблокирован"; $this->msg->setText("[img[items/pal_button6.gif]] $this->status"); $this->chat->sendMsg($this->msg); } @@ -135,12 +135,12 @@ class ModFactory public function unban(): void { if (empty($this->targetUser['banned'])) { - $this->status = ' .'; + $this->status = 'Персонаж не в блоке.'; return; } $this->moderation->unban(); Db::sql('delete from ban_email where email = ?', [$this->targetUser['mail']]); - $this->status = " $this->targetLogin "; + $this->status = "Персонаж $this->targetLogin разблокирован"; $this->msg->setText("[img[items/pal_button7.gif]] $this->status"); $this->chat->sendMsg($this->msg); } diff --git a/_incl_data/class/Moderation/UserRegistrationList.php b/_incl_data/class/Moderation/UserRegistrationList.php index 65452cea..235ac0ad 100644 --- a/_incl_data/class/Moderation/UserRegistrationList.php +++ b/_incl_data/class/Moderation/UserRegistrationList.php @@ -7,7 +7,7 @@ use User; class UserRegistrationList { - /** : . + /** Регистрации персонажей: только для администраторов. * @return void */ public static function get(): void @@ -35,14 +35,14 @@ class UserRegistrationList
-

- +

Регистрации персонажей

+ - + -
+
Персонажи зарегистрированные
    time()): ?> - () + (молчит) 0): ?> - ( ) + (в бою) 0): ?> - ( ) + (реферал персонажа ) diff --git a/_incl_data/class/User.php b/_incl_data/class/User.php index 78279a18..c01e8806 100644 --- a/_incl_data/class/User.php +++ b/_incl_data/class/User.php @@ -1174,7 +1174,7 @@ class User public function getStats($uid, $i1 = null, $res = 0, $reimg = false, $btl_cache = false, $minimal = false): array { $result = new Stats($this); - return $result->getStats($uid, $i1, $res, $reimg, $btl_cache); + return $result->getStats($uid, $i1, $reimg, $btl_cache); } public function getUserInfoById($id) diff --git a/_incl_data/class/User/Clan.php b/_incl_data/class/User/Clan.php index f5374ede..640393e9 100644 --- a/_incl_data/class/User/Clan.php +++ b/_incl_data/class/User/Clan.php @@ -31,7 +31,7 @@ class Clan } } - private function join(string $clanname) + private function join(string $clanname): void { Db::sql('update users set clan = (select id from clan where clan.name = ?) where id = ?', [$clanname, $this->userid]); } @@ -46,7 +46,7 @@ class Clan return $this->status; } - public function printClan() + public function printClan(): void { echo 'Склонность' . $this->printLogoImage() . $this->getName(); } @@ -88,4 +88,9 @@ class Clan { return !empty($this->id) && $this->status === 0; } + + public static function addExp(int $value, int $clanid): void + { + Db::sql('update clan set exp = exp + ? where id = ?',[max($value,0), $clanid]); + } } diff --git a/_incl_data/class/User/Effects.php b/_incl_data/class/User/Effects.php index 7f07947f..0c08b3a3 100644 --- a/_incl_data/class/User/Effects.php +++ b/_incl_data/class/User/Effects.php @@ -148,6 +148,11 @@ insert into eff_users Db::sql('delete from eff_users where id in (?) and uid = ?', [implode(',', $ids), $userId]); } + public static function removePriems(int $userid): void + { + Db::sql("delete from eff_users where v1 = 'priem' and uid = ?", [$userid]); + } + public static function hasAttackTimeLimit(int $attackerId): bool { return Db::getValue('select count(*) from eff_users where id_eff = 478 and `delete` = 0 and uid = ?', [$attackerId]) > 0; @@ -166,14 +171,14 @@ insert into eff_users /** * Духовность. Спасение. * Из свитка нападения. - * @param $id + * @param $uid * @return void */ - public static function addSpasenie($id): void + public static function addSpasenie($uid): void { - Db::sql('delete from eff_users where uid = ? and overType = 101'); + self::removeByOverType($uid, 101); Db::sql("insert into eff_users (id_eff, uid, name, data, overType, timeUse, user_use, v1, v2, img2, bj, mark) - values (22,?,'Спасение','add_spasenie=1',101,77,?,'priem',324,'preservation.gif','спасение',1)", [$id, $id]); + values (22,?,'Спасение','add_spasenie=1',101,77,?,'priem',324,'preservation.gif','спасение',1)", [$uid, $uid]); } diff --git a/_incl_data/class/User/Reputation.php b/_incl_data/class/User/Reputation.php index fc68be69..23e671bb 100644 --- a/_incl_data/class/User/Reputation.php +++ b/_incl_data/class/User/Reputation.php @@ -12,21 +12,11 @@ class Reputation public function __construct(int $userid) { $this->uid = $userid; - $this->r = Db::getRow( - 'select *, - (repcapitalcity+repdemonscity+repangelscity+repsuncity+repdreamscity+repabandonedplain+repsandcity+repemeraldscity+repdevilscity) as allrep, - (nu_capitalcity+nu_demonscity+nu_angelscity+nu_suncity+nu_dreamscity+nu_abandonedplain+nu_sandcity+nu_emeraldscity+nu_devilscity) as allnurep - from rep where id = ?', [$this->uid] - ); + $this->r = $this->getr(); if (empty($this->r)) { Db::sql('insert into rep (id) value (?)', [$this->uid]); - $this->r = Db::getRow( - 'select *, - (repcapitalcity+repdemonscity+repangelscity+repsuncity+repdreamscity+repabandonedplain+repsandcity+repemeraldscity+repdevilscity) as allrep, - (nu_capitalcity+nu_demonscity+nu_angelscity+nu_suncity+nu_dreamscity+nu_abandonedplain+nu_sandcity+nu_emeraldscity+nu_devilscity) as allnurep - from rep where id = ?', [$this->uid] - ); + $this->r = $this->getr(); } } @@ -35,7 +25,7 @@ class Reputation return $this->r; } - public function addRep(string $dungeonName, int $value): int + public function addRep(string $dungeonName, int $value): mixed { if (!isset($this->r[$dungeonName]) || $value <= 0) { return 0; @@ -44,4 +34,14 @@ class Reputation Db::sql("update rep set $dungeonName = ? where id = ?", [$value, $this->uid]); return $this->r[$dungeonName]; } + + private function getr() + { + return Db::getRow( + 'select *, + (repcapitalcity+repdemonscity+repangelscity+repsuncity+repdreamscity+repabandonedplain+repsandcity+repemeraldscity+repdevilscity) as allrep, + (nu_capitalcity+nu_demonscity+nu_angelscity+nu_suncity+nu_dreamscity+nu_abandonedplain+nu_sandcity+nu_emeraldscity+nu_devilscity) as allnurep + from rep where id = ?', [$this->uid] + ); + } } \ No newline at end of file diff --git a/_incl_data/class/User/Stats.php b/_incl_data/class/User/Stats.php index ad85d654..561e8e8f 100644 --- a/_incl_data/class/User/Stats.php +++ b/_incl_data/class/User/Stats.php @@ -123,16 +123,13 @@ class Stats ]; } - public function getStats(int|array|null $uid = null, $i1 = 0, $res = 0, $reimg = false, $btl_cache = false): array + public function getStats(int|array|null $uid = null, $i1 = 0, $reimg = false, $btl_cache = false): array { - if (empty($uid) || $uid == $this->u->info['id'] && $res != 1) { - //$u = $this->u->info; - $u = User::getInfo($uid); - } elseif (is_array($uid)) { - $u = $uid; - } else { - $u = User::getInfo($uid); - } + $u = match (true) { + empty($uid) => User::getInfo($this->u->info['id']), + is_array($uid) => $uid, + default => User::getInfo($uid), + }; if (!isset($u['id'])) { return []; @@ -296,11 +293,13 @@ class Stats //Бонусы комплектов if (is_iterable($coms['new'])) { foreach ($coms['new'] as $complect) { - $com = Db::getValue('select data from complects where com = ? and x <= ? order by x desc limit 1', + $com = Db::getValue( + 'select data from complects where com = ? and x <= ? order by x desc limit 1', [ (int)$complect, (int)$coms['com'][$complect], // кол-во предметов данного комплекта - ]); + ] + ); if (!$com) { continue; @@ -513,8 +512,8 @@ class Stats /** Собираем динамически создаваемые параметры. Если ключа нет - создаём. * @param string $key - * @param int $value - * @param array $st + * @param int $value + * @param array $st * @return void */ private function addKeyIfNotExist(string $key, int $value, array &$st): void @@ -530,9 +529,11 @@ class Stats { //Характеристики от предметов //ТУТ tr_lvl // Вся вторая строчка - спасибо Users. - $wearedItems = Db::getRows('select type, data, inOdet, + $wearedItems = Db::getRows( + 'select type, data, inOdet, item_id, inslot, useInBattle, btl_zd, iznosNOW, iznosMAX, magic_inci, name, items_users.id, img, `2h` - from items_users left join items_main on items_main.id = item_id where inOdet != 0 and uid = ?', [$uid]); + from items_users left join items_main on items_main.id = item_id where inOdet != 0 and uid = ?', [$uid] + ); $h = 0; $hnd1 = 0; @@ -1080,7 +1081,7 @@ class Stats private function addIntelligenceBonuses(array &$st): void { -//интелект + //интелект if ($st['s5'] > 24 && $st['s5'] < 50) { $st['m11'] += 10; } @@ -1110,7 +1111,7 @@ class Stats private function addWisdomBonuses(array &$st): void { -//мудрость + //мудрость if ($st['s6'] > 24 && $st['s6'] < 50) { $st['mpall'] += 150; $st['speedmp'] += 100; @@ -1151,7 +1152,8 @@ class Stats private function addDungeonsBonuses(int $id, array &$st): void { - $finishedDungeons = Db::getValue('select + $finishedDungeons = Db::getValue( + 'select if(repcapitalcity > 24999, 1, 0) + if(repdemonscity > 24999, 1, 0) + if(repangelscity > 24999, 1, 0) + @@ -1161,7 +1163,8 @@ class Stats if(repsandcity > 24999, 1, 0) + if(repemeraldscity > 24999, 1, 0) + if(repizlom > 24999, 1, 0) + - 0 as finished from rep where id = ?', [$id]); + 0 as finished from rep where id = ?', [$id] + ); //Бонус за количество полностью вырытых пещер. $st['m10'] += 10 * $finishedDungeons; @@ -1180,10 +1183,12 @@ class Stats return; } - Db::sql("update stats set + Db::sql( + "update stats set tactic1 = tactic2 = tactic3 = tactic4 = tactic5 = tactic6 = tactic7 = 25, priems_z = '0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|' - where id = ?", [$u['id']]); + where id = ?", [$u['id']] + ); } /** Переименовывает элементы массива с несовпадающими с остальным скриптом именами полей. @@ -1199,4 +1204,51 @@ class Stats unset($st['level'], $st['hpnow'], $st['mpnow']); } + public static function saveBattleStats(array $stats, int $id): void + { + if (!isset( + $stats['hpnow'], + $stats['mpNow'], + $stats['tactic1'], + $stats['tactic2'], + $stats['tactic3'], + $stats['tactic4'], + $stats['tactic5'], + $stats['tactic6'], + $stats['tactic7'], + $stats['enemy'], + $stats['battle_yron'], + $stats['battle_exp'], + $stats['last_hp'], + $stats['priems_z'], + ) + ) { + return; + } + + Db::sql( + 'update stats set hpNow = ?,mpNow = ?, + tactic1 = ?,tactic2 = ?,tactic3 = ?,tactic4 = ?,tactic5 = ?,tactic6 = ?,tactic7 = ?, + enemy = ?,battle_yron = ?,last_hp = ?,battle_exp = ?,priems_z = ? + where id = ?', + [ + $stats['hpnow'], + $stats['mpNow'], + $stats['tactic1'], + $stats['tactic2'], + $stats['tactic3'], + $stats['tactic4'], + $stats['tactic5'], + $stats['tactic6'], + $stats['tactic7'], + $stats['enemy'], + $stats['battle_yron'], + $stats['battle_exp'], + $stats['last_hp'], + $stats['priems_z'], + $id, + ] + ); + + } } diff --git a/_incl_data/class/priems/bloodring.php b/_incl_data/class/priems/bloodring.php deleted file mode 100644 index 0ff0cd8a..00000000 --- a/_incl_data/class/priems/bloodring.php +++ /dev/null @@ -1,44 +0,0 @@ -info['battle'] > 0 && $u->info['hpNow'] >= 1) -{ - if($btl->info['team_win'] != -1 ) { - $u->error = 'Использовать кольцо возможно только во время боя'; - }elseif($btl->info['razdel'] != 5) { - $u->error = 'Использование кольца возможно только в хаотичных поединках!'; - }elseif(ceil($u->info['tactic6']) < 15) { - $u->error = 'Не хватает '.(15-ceil($u->info['tactic6'])).' для "Кровавый сбор"'; - }else{ - $bu = mysql_fetch_array(mysql_query('SELECT `id` FROM `eff_users` WHERE `v1` = "priem" AND `v2` = "228" AND `delete` = "0" LIMIT 1')); - if(isset($bu['id'])) { - $u->error = 'Использование кольца возможно 1 раз за бой!'; - }else{ - mysql_query('UPDATE `stats` SET `tactic6` = `tactic6` - 15 WHERE `id` = "'.$u->info['id'].'" LIMIT 1'); - $u->info['tactic6'] -= 15; - \User\ItemsModel::addItem(3134,$u->info['id'],'|sudba='.$u->info['login']); - $ins = mysql_query('INSERT INTO `eff_users` (`hod`,`v2`,`img2`,`id_eff`,`uid`,`name`,`data`,`overType`,`timeUse`,`v1`) VALUES - ("-1",228,"invoke_create_lesserbloodstone.gif",22,"'.$u->info['id'].'","Кровавый Сбор","","30","77","priem")'); - $u->error = 'Вы успешно использовали заклинание "Кровавый сбор"'; - - //Лог боя - $lastHOD = mysql_fetch_array(mysql_query('SELECT * FROM `battle_logs` WHERE `battle` = "'.$u->info['battle'].'" ORDER BY `id_hod` DESC LIMIT 1')); - $id_hod = $lastHOD['id_hod']; - if($lastHOD['type']!=6) { - $id_hod++; - } - $txt = ''.$txt.''; - if($u->info['sex']==1) { - $txt = '{u1} применила заклинание "Кровавый сбор".'; - }else{ - $txt = '{u1} применил заклинание "Кровавый сбор".'; - } - mysql_query('INSERT INTO `battle_logs` (`time`,`battle`,`id_hod`,`text`,`vars`,`zona1`,`zonb1`,`zona2`,`zonb2`,`type`) VALUES ("'.time().'","'.$u->info['battle'].'","'.($id_hod).'","{tm1} '.$txt.'","login1='.$u->info['login'].'||t1='.$u->info['team'].'||time1='.time().'","","","","","6")'); - } - } -} - -?> \ No newline at end of file diff --git a/_incl_data/class/priems/bloodring2.php b/_incl_data/class/priems/bloodring2.php deleted file mode 100644 index 8b94d59f..00000000 --- a/_incl_data/class/priems/bloodring2.php +++ /dev/null @@ -1,63 +0,0 @@ -info['battle'] > 0 && $u->info['hpNow'] >= 1) { - if ($btl->info['team_win'] != -1) { - $u->error = 'Использовать кольцо возможно только во время боя'; - } elseif ($btl->info['razdel'] != 5) { - $u->error = 'Использование кольца возможно только в хаотичных поединках!'; - } elseif (ceil($u->info['tactic6']) < 5) { - $u->error = 'Не хватает ' . (5 - ceil($u->info['tactic6'])) . ' для "Поглотить Кровь"'; - } else { - if ($st['td_cast_data'] != date('d.m.Y')) { - $st['td_cast_data'] = date('d.m.Y'); - $st['td_cast'] = 0; - } - - if ($st['td_cast'] > 5) { - $u->error = 'Использование кольца возможно не более 6 раз в сутки!'; - } else { - $bu = mysql_fetch_array(mysql_query('SELECT * FROM `eff_users` WHERE `v1` = "priem" AND `v2` = "229" AND `delete` = "0" LIMIT 1')); - - $st['td_cast']++; - - $stimp = Helper\Conversion::arrayToDataString($st); - mysql_query('UPDATE `items_users` SET `data` = "' . mysql_real_escape_string($stimp) . '" WHERE `id` = "' . $itm['id'] . '" LIMIT 1'); - - mysql_query('UPDATE `stats` SET `tactic6` = `tactic6` - 5 WHERE `id` = "' . $u->info['id'] . '" LIMIT 1'); - $u->info['tactic6'] -= 5; - - //\User\ItemsModel::addItem(3136,$u->info['id'],'|sudba='.$u->info['login']); - - //Если эффект есть, тогда добавляем к нему +1 каст (Максимум 6) - if (isset($bu['id'])) { - if ($bu['x'] < 6) { - mysql_query('UPDATE `eff_users` SET `x` = `x` + 1 WHERE `id` = "' . $bu['id'] . '" LIMIT 1'); - } - } else { - $ins = mysql_query('INSERT INTO `eff_users` (`file_finish`,`hod`,`v2`,`img2`,`id_eff`,`uid`,`name`,`data`,`overType`,`timeUse`,`v1`) VALUES - ("bloodring2_end","-1",229,"invoke_create_bloodstone.gif",22,"' . $u->info['id'] . '","Поглотить Кровь","","30","77","priem")'); - } - - $u->error = 'Вы успешно использовали заклинание "Поглотить Кровь"
    В случаи победы Вы получите "Кровавый Рубин"'; - - //Лог боя - $lastHOD = mysql_fetch_array(mysql_query('SELECT * FROM `battle_logs` WHERE `battle` = "' . $u->info['battle'] . '" ORDER BY `id_hod` DESC LIMIT 1')); - $id_hod = $lastHOD['id_hod']; - if ($lastHOD['type'] != 6) { - $id_hod++; - } - $txt = '' . $txt . ''; - if ($u->info['sex'] == 1) { - $txt = '{u1} применила заклинание "Поглотить Кровь".'; - } else { - $txt = '{u1} применил заклинание "Поглотить Кровь".'; - } - mysql_query('INSERT INTO `battle_logs` (`time`,`battle`,`id_hod`,`text`,`vars`,`zona1`,`zonb1`,`zona2`,`zonb2`,`type`) VALUES ("' . time() . '","' . $u->info['battle'] . '","' . ($id_hod) . '","{tm1} ' . $txt . '","login1=' . $u->info['login'] . '||t1=' . $u->info['team'] . '||time1=' . time() . '","","","","","6")'); - } - } -} - -?> \ No newline at end of file diff --git a/_incl_data/class/priems/bloodring2_end.php b/_incl_data/class/priems/bloodring2_end.php deleted file mode 100644 index 03883dd7..00000000 --- a/_incl_data/class/priems/bloodring2_end.php +++ /dev/null @@ -1,28 +0,0 @@ -users[$i]['team'] == $this->info['team_win']) { - if ($this->info['razdel'] == 5) { - $i1k = 0; - if ($ple['x'] > 6) { - $ple['x'] = 6; - } - while ($i1k < $ple['x']) { - \User\ItemsModel::addItem(3136, $this->users[$i]['id'], '|sudba=' . $this->users[$i]['login']); - $i1k++; - } - if ($ple['x'] > 1) { - $ple['xz'] = ' (x' . $ple['x'] . ')'; - } else { - $ple['xz'] = ''; - } - - $cmsg = new ChatMessage(); - $cmsg->setCity($this->users[$i]['city']); - $cmsg->setTo($this->users[$i]['login']); - $cmsg->setText("Вы получили предмет "Кровавый Рубин{$ple['xz']}"."); - $cmsg->setType(6); - (new Chat())->sendMsg($cmsg); - } -} diff --git a/jx/battle/refresh.php b/jx/battle/refresh.php index 73036641..dc3c5376 100644 --- a/jx/battle/refresh.php +++ b/jx/battle/refresh.php @@ -97,7 +97,7 @@ if (!isset($btl->info['id'])) { } } else { //получаем массив с игроками в бою - $btl->teamsTake(); + $btl->teamsTake($u); if (isset($_POST['useitem']) && $btl->testUsersLive()) { $magic->useItems((int)$_POST['useitem']); diff --git a/jx/battle/refresh1.php b/jx/battle/refresh1.php index cce2fcda..4ef703a7 100644 --- a/jx/battle/refresh1.php +++ b/jx/battle/refresh1.php @@ -82,7 +82,7 @@ if (!isset($btl->info['id'])) { } } else { //получаем массив с игроками в бою - $btl->teamsTake(); + $btl->teamsTake($u); if (isset($_POST['useitem']) && $btl->testUsersLive() == true) { $magic->useItems((int)$_POST['useitem']); diff --git a/jx/battle/refresh2.php b/jx/battle/refresh2.php index 979452bf..efa5101e 100644 --- a/jx/battle/refresh2.php +++ b/jx/battle/refresh2.php @@ -79,7 +79,7 @@ if (isset($_POST['atack'], $_POST['block']) || (isset($_POST['id']) && $_POST['i } } else { //получаем массив с игроками в бою - $btl->teamsTake(); + $btl->teamsTake($u); if (isset($_POST['useitem']) && $btl->testUsersLive() == true) { $magic->useItems((int)$_POST['useitem']); diff --git a/jx/battle/refresh_bot.php b/jx/battle/refresh_bot.php index 687517bd..fa385cb1 100644 --- a/jx/battle/refresh_bot.php +++ b/jx/battle/refresh_bot.php @@ -115,7 +115,7 @@ if (isset($CRON_CORE) && (isset($_POST['atack'], $_POST['block']) || (isset($_PO } } else { //получаем массив с игроками в бою - $btl->teamsTake(); + $btl->teamsTake($u); if (isset($_POST['useitem'])) { $magic->useItems((int)$_POST['useitem']);