'групповые', 5 => 'хаотичные']; private array $z2n = [4 => 'группового', 5 => 'хаотичного']; private bool $backTest = false; // Для проверок хаотических поединков. private static bool $bcktst; private User $u; private ?int $zv_see = null; public string $test_s = ''; public string $error = ''; /** * Заявки на бой. */ public function __construct() { $this->u = User::start(); unset($_POST['kingfight'], $_POST['nobot'], $_POST['mut_clever']); $this->u->info['no_zv_key'] = true; if (!empty($_GET['del_z_time'])) { $zay = Db::getValue( 'select count(*) from zayvki where id = ? and creator = ? and start = 0 and cancel = 0 and btl_id = 0 and priz = 0', [$this->u->info['zv'], $this->u->info['id']] ); if ($zay) { $colls = Db::getValue('select count(*) from stats where zv = ?', [$this->u->info['zv']]); if ($colls === 1) { Db::sql('update stats set zv = 0 where id = ?', [$this->u->info['id']]); Db::sql('delete from zayvki where id = ?', [$this->u->info['zv']]); } } } $this->test(); //проверяем заявки } private function add_effn($uid, $id) { $eff = Db::getRow('select mname, mdata, oneType, id2 from eff_main where id2 = ?', [$id]); if (!$eff['id2']) { return; } Db::sql( 'insert into eff_users (overType, id_eff, uid, name, timeUse, data) values (?,?,?,?,unix_timestamp(),?)', [$eff['oneType'], $eff['id2'], $uid, $eff['mname'], $eff['mdata']] ); // Db::sql(' // insert into eff_users (overType, id_eff, uid, name, timeUse, data) // select oneType, id2, ?, mname, unix_timestamp(), mdata from eff_main // where id2 = ?', // [$uid, $id]); } private function testTravm() { $tr = Db::getValue( 'select v1 from eff_users where id_eff = 4 and `delete` = 0 and uid = ? order by v1 desc limit 1', [$this->u->info['id']] ); return $tr ? $tr - 1 : 0; } private function testTurnir() { $chat = new Chat(); //Проверяем турниры в этом городе $trn = Db::getRows('select * from turnirs where status != -1'); $stmt = Db::prepare('update turnirs set chat = ? where id = ?'); foreach ($trn as $pl) { //Начало турнира if ($pl['status'] == 0 && $pl['time'] > time()) { if (floor(($pl['time'] - time()) / 60) <= 2 && $pl['chat'] > 0) { $stmt->execute([0, $pl['id']]); } elseif (floor(($pl['time'] - time()) / 60) <= 5 && $pl['chat'] > 1) { //Осталось 5 мин. $chat->sendsys('Турниры: До начала турнира осталось 5 минут.'); $stmt->execute([1, $pl['id']]); } elseif (floor(($pl['time'] - time()) / 60) <= 10 && $pl['chat'] > 2) { //Осталось 10 мин. $chat->sendsys('Турниры: До начала турнира осталось 10 минут.'); $stmt->execute([2, $pl['id']]); } elseif (floor(($pl['time'] - time()) / 60) <= 15 && $pl['chat'] > 3) { //Осталось 15 мин. $chat->sendsys('Турниры: До начала турнира осталось 15 минут.'); $stmt->execute([3, $pl['id']]); } } if ($pl['status'] != 0 || $pl['time'] >= time()) { continue; } if ($pl['users_in'] > 1) { //Начало турнира Db::sql( 'update turnirs set time = unix_timestamp() + ?, status = 1 where id = ?', [$pl['time3'], $pl['id']] ); $usp = mysql_query( 'SELECT * FROM `users` WHERE `inTurnirnew` = "' . $pl['id'] . '" LIMIT ' . $pl['users_in'] ); while ($ur = mysql_fetch_array($usp)) { mysql_query( 'INSERT INTO `users` (`login`,`room`,`name`,`sex`,`level`,`inTurnirnew`,`bithday`) VALUES ("' . $ur['login'] . '","318","' . $ur['name'] . '","' . $ur['sex'] . '","' . $t['level'] . '","' . $pl['id'] . '","01.01.2001")' ); $uri = mysql_insert_id(); mysql_query( 'INSERT INTO `users_turnirs` (`uid`,`bot`,`turnir`) VALUES ("' . $ur['id'] . '","' . $uri . '","' . $pl['id'] . '")' ); $zid = 0; $x1 = 0; $y1 = 0; mysql_query( 'INSERT INTO `stats` (`upLevel`,`dnow`,`id`,`stats`,`exp`,`ability`,`skills`,`x`,`y`) VALUES ("98","' . $zid . '","' . $uri . '","s1=3|s2=3|s3=3|s4=3|s5=0|s6=0|rinv=40|m9=5|m6=10","0","0","0",' . $x1 . ',' . $y1 . ')' ); mysql_query( 'UPDATE `users` SET `inUser` = "' . $uri . '" WHERE `id` = "' . $ur['id'] . '" LIMIT 1' ); //Добавляем эффекты скорость регена и запрет передвижения } } else { //Отмена турнира mysql_query( 'UPDATE `turnirs` SET `time` = "' . (time( ) + $pl['time2']) . '",`users_in` = "0" WHERE `id` = "' . $pl['id'] . '" LIMIT 1' ); mysql_query('UPDATE `users` SET `inTurnirnew` = "0" WHERE `inTurnirnew` = "' . $pl['id'] . '"'); } } } private function testGroupAndChaotic() { //Проверяем хаотичные и групповые бои в этом городе $sp = mysql_query( 'SELECT * FROM `zayvki` AS `z` WHERE `z`.`btl_id` = "0" AND `z`.`cancel` = "0" AND `z`.`start` = "0" AND (`z`.`razdel` = 4 OR `z`.`razdel` = 5) ORDER BY `z`.`id` DESC LIMIT 22' ); while ($pl = mysql_fetch_array($sp)) { $uz = mysql_query( 'SELECT `u`.`sex`,`u`.`id`,`u`.`login`,`u`.`align`,`u`.`clan`,`u`.`admin`,`u`.`city`,`u`.`room`,`u`.`online`,`u`.`level`,`u`.`battle`,`u`.`money`,`st`.* FROM `stats` AS `st` LEFT JOIN `users` AS `u` ON (`st`.`id` = `u`.`id`) WHERE `st`.`zv`="' . $pl['id'] . '"' ); $tm1 = []; $tm2 = []; $i = []; $toChat = ''; $toChat2 = ''; $toWhere = ''; while ($t = mysql_fetch_array($uz)) { if (!isset(${'tm' . $t['team']})) { ${'tm' . $t['team']} = []; } if (!isset($i[$t['team']])) { $i[$t['team']] = 0; } ${'tm' . $t['team']}[$i[$t['team']]] = $t; $toChat .= '' . $t['login'] . ','; $toWhere .= 'OR `id` = "' . $t['id'] . '" '; if ($pl['razdel'] == 5 && $pl['time_start'] - 180 < time() - $pl['time'] && $pl['send'] == 0) { $toChat2 .= '' . $this->u->microLogin2($t) . ', '; } $i[$t['team']]++; } if ($pl['razdel'] == 5) { $col_p = mysql_fetch_array( mysql_query('SELECT COUNT(*) FROM `stats` WHERE `zv` = "' . $pl['id'] . '"') ); $cols = $col_p[0]; if ($cols >= $pl['maxplayers']) { $pl['time_start'] = time() - $pl['time'] - 1; } } if ($pl['time_start'] < time( ) - $pl['time'] || ($pl['razdel'] == 4 && $i[1] >= $pl['tm1max'] && $i[2] >= $pl['tm2max'])) { $toChat = rtrim($toChat, ','); $toWhere = ltrim($toWhere, 'OR '); if ($pl['razdel'] == 4) { //группы $this->testGroup($i, $pl, $toChat, $toWhere); } elseif ($pl['razdel'] == 5) { //fixme ёбаный костыль! $this->testCronChaotic($pl, $toChat, $toWhere); return; //хаоты // $i = mysql_fetch_array( mysql_query('SELECT COUNT(*) FROM `stats` WHERE `zv` = "' . $pl['id'] . '" LIMIT 1') ); if ($i[0] < 4 && ($i[0] < 2 || $pl['fastfight'] == 0)) { //группа не набрана $this->cancelGroup($pl, $toChat, ' Беда!'); } else { //Начинаем поединок $this->startBattle($pl['id'], $toChat . '|-|' . $toWhere); } } } } } /** Проверяем заявки * @return void */ private function test() { if ($this->u->info['zv'] > 0) { $z = Db::getRow('select * from zayvki where id = ?', [$this->u->info['zv']]); if ($z['id'] && ($z['cancel'] || $z['btl_id'] || $z['time'] < time() - 3600) || !$z['id']) { $this->u->info['zv'] = 0; Db::sql('update stats set zv = 0 where id = ?', [$this->u->info['id']]); } } $this->testTurnir(); $this->testGroupAndChaotic(); } private function testCronTurnir() { //Проверяем турниры в этом городе $sp = mysql_query('SELECT * FROM `turnirs` WHERE `status` != "-1"'); while ($pl = mysql_fetch_array($sp)) { //Начало турнира if ($pl['status'] != 0 || $pl['time'] >= time()) { continue; } if ($pl['users_in'] > 1) { //Начало турнира mysql_query( 'UPDATE `turnirs` SET `time` = "' . (time( ) + $pl['time3']) . '",`status` = "1" WHERE `id` = "' . $pl['id'] . '" LIMIT 1' ); $usp = mysql_query( 'SELECT * FROM `users` WHERE `inTurnirnew` = "' . $pl['id'] . '" LIMIT ' . $pl['users_in'] ); while ($ur = mysql_fetch_array($usp)) { mysql_query( 'INSERT INTO `users` (`login`,`room`,`name`,`sex`,`level`,`inTurnirnew`,`bithday`) VALUES ("' . $ur['login'] . '","318","' . $ur['name'] . '","' . $ur['sex'] . '","' . $t['level'] . '","' . $pl['id'] . '","01.01.2001")' ); $uri = mysql_insert_id(); mysql_query( 'INSERT INTO `users_turnirs` (`uid`,`bot`,`turnir`) VALUES ("' . $ur['id'] . '","' . $uri . '","' . $pl['id'] . '")' ); $zid = 0; $x1 = 0; $y1 = 0; mysql_query( 'INSERT INTO `stats` (`upLevel`,`dnow`,`id`,`stats`,`exp`,`ability`,`skills`,`x`,`y`) VALUES ("98","' . $zid . '","' . $uri . '","s1=3|s2=3|s3=3|s4=3|s5=0|s6=0|rinv=40|m9=5|m6=10","0","0","0",' . $x1 . ',' . $y1 . ')' ); mysql_query( 'UPDATE `users` SET `inUser` = "' . $uri . '" WHERE `id` = "' . $ur['id'] . '" LIMIT 1' ); //Добавляем эффекты скорость регена и запрет передвижения } } else { //Отмена турнира mysql_query( 'UPDATE `turnirs` SET `time` = "' . (time( ) + $pl['time2']) . '",`users_in` = "0" WHERE `id` = "' . $pl['id'] . '" LIMIT 1' ); mysql_query('UPDATE `users` SET `inTurnirnew` = "0" WHERE `inTurnirnew` = "' . $pl['id'] . '"'); } } } private function testGroup($groups, $zayavka, $toChat, $toWhere) { if ($zayavka['razdel'] != 4) { return; } if ( empty($groups[1]) || empty($groups[2]) || ( empty($groups[3]) && $zayavka['teams'] == 3 ) ) { //группа не набрана $this->cancelGroup($zayavka, $toChat); } else { //Начинаем поединок $this->startBattle($zayavka['id'], $toChat . '|-|' . $toWhere); } } private function testCronChaotic($zayavka, $toChat, $toWhere) { $chat = new Chat(); $levelToExp = [ 0 => 0, 1 => 110, 2 => 420, 3 => 1300, 4 => 2500, 5 => 5000, 6 => 12500, 7 => 30000, 8 => 300000, 9 => 3000000, 10 => 10000000, 11 => 52000000, 12 => 63000000, 13 => 182000000, 14 => 212000000, 15 => 352000000, 16 => 504000000, 17 => 1187000000, 18 => 2455000000, 19 => 4387000000, 20 => 6355000000, 21 => 15500000000, 22 => 755500000000, ]; $botUsers = []; define('FAST_FIGHT_REQUIRED_FIGHTERS_COUNT', 2); define('FIGHT_REQUIRED_FIGHTERS_COUNT', 6); $requiredFightersToStartBattle = FIGHT_REQUIRED_FIGHTERS_COUNT; if ($zayavka['fastfight'] > 0) { $requiredFightersToStartBattle = FAST_FIGHT_REQUIRED_FIGHTERS_COUNT; } $pendingFightersCount = Db::getValue('select count(*) from stats where zv = ?', [$zayavka['id']]); if ($pendingFightersCount < $requiredFightersToStartBattle) { //группа не набрана //Добавляем недостающих игроков if (!$zayavka['nobot']) { // Если нет запрета на ботов. $getRealPlayersQuery = 'select * from stats left join users on stats.id = users.id where exp >= ? and exp < ? and bot = 0 order by btl_cof desc limit 50'; $getBotsQuery = 'select * from stats left join users on stats.id = users.id where bot = 2 and exp >= ? and exp < ?'; $botUsers = Db::getRows( $getBotsQuery, [$levelToExp[$zayavka['min_lvl_1']], $levelToExp[$zayavka['max_lvl_1'] + 1]] ); } if (empty($botUsers)) { $text = ' Не удалось начать поединок по причине: Группа не набрана. (' . $zayavka['id'] . ': 0 ' . $levelToExp[$zayavka['min_lvl_1']] . '-' . $levelToExp[$zayavka['max_lvl_1'] + 1] . ')'; $chat->sendsys($text, 'Merlin'); $this->cancelGroup($zayavka, $toChat, ' Боты проспали.'); } else { $pendingBotsCount = 0; for ($i = 0; $i < $requiredFightersToStartBattle - $pendingFightersCount; $i++) { shuffle($botUsers); $botInfo = array_shift($botUsers); $botData = [ 'id' => $botInfo['id'], 'login' => $botInfo['login'], 'level' => $botInfo['level'], 'city' => $botInfo['city'], 'cityreg' => $botInfo['city'], 'name' => $botInfo['login'], 'sex' => $botInfo['sex'], 'hobby' => '', 'time_reg' => time(), 'obraz' => $botInfo['obraz'], 'stats' => $botInfo['stats'], 'upLevel' => $botInfo['upLevel'], 'priems' => $botInfo['priems'], 'loclon' => true, ]; $bot = $this->u->addNewbot(1, null, $botData, null, true); if ($bot) { Db::sql( 'update stats set btl_cof = ?, zv = ?, hpNow = 1000000, mpNow = 1000000 where id = ?', [$botInfo['btl_cof'], $zayavka['id'], $bot] ); Db::sql('update users set room = 303, battle = 0 where id = ?', [$bot]); $pendingBotsCount++; } } unset($botUsers, $botInfo, $botData, $bot); if ($pendingBotsCount + $pendingFightersCount >= $requiredFightersToStartBattle) { $this->backTest = true; self::$bcktst = true; } } } else { //Начинаем поединок $this->startBattle($zayavka['id'], $toChat . '|-|' . $toWhere); } } /** Проверяем хаотичные и групповые бои в этом городе * @return void * @throws Exception */ private function testCronGroupAndChaotic() { define('GROUP_BATLE', 4); define('CHAOTIC_BATTLE', 5); $zv1k = Db::getRows( 'select * from zayvki where btl_id = 0 and cancel = 0 and start = 0 and razdel in (4, 5) order by id desc limit 1000' ); foreach ($zv1k as $zv) { $tm1 = []; $tm2 = []; $i = []; $toChat = $toWhere = ''; $users = Db::getRows( 'select * from stats left join users on stats.id = users.id where zv = ?', [$zv['id']] ); foreach ($users as $user) { !empty(${'tm' . $user['team']}) ?: ${'tm' . $user['team']} = []; !empty($i[$user['team']]) ?: $i[$user['team']] = 0; ${'tm' . $user['team']}[$i[$user['team']]] = $user; $toChat .= $user['login'] . ','; $toWhere .= 'OR id = ' . $user['id'] . ' '; $i[$user['team']]++; } if ($zv['time_start'] > time( ) - $zv['time'] && ($zv['razdel'] != 4 || $i[1] < $zv['tm1max'] || $i[2] < $zv['tm2max'])) { continue; } $toChat = rtrim($toChat, ','); $toWhere = ltrim($toWhere, 'OR '); trigger_error('test'); if ($zv['razdel'] == GROUP_BATLE) { $this->testGroup($i, $zv, $toChat, $toWhere); } else { $this->testCronChaotic($zv, $toChat, $toWhere); } } } public function testCronZv() { $this->testCronTurnir(); $this->testCronGroupAndChaotic(); if ($this->backTest || self::$bcktst) { self::$bcktst = false; $this->testCronZv(); } } public function userInfo() { $r = ''; $dp = ''; $ph = $this->u->stats['hpNow'] / $this->u->stats['hpAll'] * 100; if ($this->u->stats['mpAll'] > 0) { $pm = $this->u->stats['mpNow'] / $this->u->stats['mpAll'] * 100; } else { $dp = 'margin-top:13px;'; } $r .= '
| ' . $this->u->microLogin($this->u->info['id'], 1) . ' |
' . floor(
$this->u->stats['hpNow']
) . '/' . $this->u->stats['hpAll'] . '
' . floor(
$this->u->stats['mpNow']
) . '/' . $this->u->stats['mpAll'] . '
|
| ';
if ($this->u->info['team'] == 1) {
$uz = mysql_fetch_array(
mysql_query(
'SELECT `u`.`sex`,`u`.`id`,`u`.`login`,`u`.`align`,`u`.`clan`,`u`.`admin`,`u`.`city`,`u`.`room`,`u`.`online`,`u`.`level`,`u`.`battle`,`u`.`money`,`st`.* FROM `stats` AS `st` LEFT JOIN `users` AS `u` ON (`st`.`id` = `u`.`id`) WHERE `st`.`zv`="' . $zi['id'] . '" AND `st`.`team`="2" LIMIT 1'
)
);
if (!isset($uz['id'])) {
//если никто не принял
echo ' Вы уже подали заявку на бой ';
} else {
//если кто-то принял
$sa = '';
if ($uz['sex'] == 2) {
$sa = 'а';
}
echo 'Вашу заявку принял' . $sa . ' ' . $ca . ' ' . $this->u->microLogin(
$uz['id'], 1
) . ' Хотите подтвердить бой? ';
}
} else {
$uz = mysql_fetch_array(
mysql_query(
'SELECT `u`.`id`,`u`.`login`,`u`.`align`,`u`.`clan`,`u`.`admin`,`u`.`city`,`u`.`room`,`u`.`online`,`u`.`level`,`u`.`battle`,`u`.`money`,`st`.* FROM `stats` AS `st` LEFT JOIN `users` AS `u` ON (`st`.`id` = `u`.`id`) WHERE `st`.`zv`="' . $zi['id'] . '" AND `st`.`team`="1" LIMIT 1'
)
);
if (isset($uz['id'])) {
echo 'Ожидаем подтверждения боя от ' . $this->u->microLogin(
$uz['id'], 1
) . ' ';
}
}
echo ' |
';
echo '▶▶';
}
echo '| « Предыдущий день | Записи о завершенных боях за ' . date('d.m.Y', $dt) . ' |
Следующий день » |
';
}
$tm2 .= '' . $tms[$g][$h]['login'] . ' [' . $tms[$g][$h]['lvl'] . ']
, ';
}
$h++;
}
$tm2 = rtrim($tm2, ', ');
$btlg = mysql_fetch_array(
mysql_query(
'SELECT `id`,`team_win` FROM `battle` WHERE `id` = "' . $pl['battle_id'] . '" LIMIT 1'
)
);
if (isset($btlg['id']) && $g == $btlg['team_win']) {
$tm2 .= '
';
}
if ($pl['kingfight'] == 1) {
$n1tv .= '
';
}
if ($pl['travmaChance'] == 100) {
$n1tv .= '
';
}
if ($pl['noatack'] == 1) {
$n1tv .= '
';
}
if ($pl['nobot'] == 1) {
$n1tv .= '
';
}
if ($pl['fastfight'] == 1) {
$n1tv .= '
';
}
if ($pl['noeff'] == 1) {
$n1tv .= '
';
} else {
$del_q = '';
}
$lvldt = '';
if ($pl['min_lvl_1'] != $pl['max_lvl_2']) {
$lvldt .= '' . $pl['min_lvl_1'] . '-' . $pl['max_lvl_2'] . ' ур. ';
} else {
$lvldt .= '' . $pl['min_lvl_1'] . ' ур. ';
}
$lvldt .= (0 + $cols) . '/' . $pl['maxplayers'] . '';
$zvb .= $rad . '' . date(
'H:i', $pl['time']
) . ' (' . $lvldt . ') тип боя:
' . $ttl1 . ': ' . $tm1;
$tm2 = '
' . $ttl2 . ': ' . $tm2;
$tm3 = '
' . $ttl3 . ': ' . $tm3;
}
//
$rad = '';
if (!isset($zi['id']) && $this->u->room['zvsee'] == 0) {
$rad = ' ';
}
if ($pl['comment'] != '') {
$dl = '';
if (($moder['boi'] == 1 || $this->u->info['admin'] > 0) && $pl['dcom'] == 0) {
$dl .= ' (удалить комментарий)';
if (isset($_GET['delcom']) && $_GET['delcom'] == $pl['id'] && $this->u->newAct(
$_GET['key']
) == true) {
mysql_query(
'UPDATE `zayvki` SET `dcom` = "' . $this->u->info['id'] . '" WHERE `id` = "' . $pl['id'] . '" LIMIT 1'
);
$pl['dcom'] = $this->u->info['id'];
}
}
if ($pl['dcom'] > 0) {
$dl = 'Комментарий удален модератором';
}
if ($pl['dcom'] > 0) {
if ($moder['boi'] == 1 || $this->u->info['admin'] > 0) {
$pl['comment'] = '[ Текст комментария : ' . $pl['comment'] . '] ';
} else {
$pl['comment'] = '';
}
}
$zv_comm = '' . $pl['comment'] . '' . $dl . '';
} else {
$zv_comm = '';
}
if ($pl['teams'] == 3) {
$zv_comm .= ' (Турнир трех склонностей)';
}
$zvb .= $rad . '' . date('H:i', $pl['time']) . ' ';
$zvb .= '(' . (0 + $tmc[1]) . '/' . $pl['tm1max'] . ')';
$zvb .= ' ' . $tm1;
$zvb .= ' (';
if ($pl['min_lvl_1'] == $pl['max_lvl_1']) {
$zvb .= $pl['min_lvl_1'];
} else {
$zvb .= $pl['min_lvl_1'] . '-' . $pl['max_lvl_1'];
}
$zvb .= ' ур.)';
$zvb .= ' против ';
$zvb .= '(' . (0 + $tmc[2]) . '/' . $pl['tm2max'] . ')';
$zvb .= ' ' . $tm2;
$zvb .= ' (';
if ($pl['min_lvl_2'] == $pl['max_lvl_2']) {
$zvb .= $pl['min_lvl_2'];
} else {
$zvb .= $pl['min_lvl_2'] . '-' . $pl['max_lvl_2'];
}
$zvb .= ' ур.)';
$zvb .= ' тип боя:
( таймаут ' . round(
$pl['timeout'] / 60
) . ' мин.' . $dp1 . ' ' . $mon . ')' . $mbcom . '
';
}
}
if ($uz1['align'] != 0) {
$ca = '
' . $ca;
}
$this->error = 'Ожидаем подтверждения боя от ' . $ca . ' ' . $uz1['login'] . ' [' . $uz1['level'] . ']
';
$sa = '';
if ($this->u->info['sex'] == 2) {
$sa = 'а';
}
$cmsg = new ChatMessage();
$cmsg->setText(
' [login:' . $this->u->info['login'] . '] принял' . $sa . ' вашу заявку на бой.[reflesh_main_zv_priem:' . $this->u->info['id'] . ']'
);
$cmsg->setCity($uz1['city']);
$cmsg->setTo($uz1['login']);
$cmsg->setType(6);
(new Chat())->sendMsg($cmsg);
$zi = $z;
$this->u->info['zv'] = $z['id'];
$this->u->info['team'] = 2;
} else {
$this->error = 'Невозможно принять заявку.';
}
} else {
$this->error = 'Заявку уже кто-то принял до вас.';
}
} else {
$this->error = 'Заявка на бой заблокирована.';
}
} elseif ($z['razdel'] == 4 && $this->u->info['level'] > 1) {
$tm = 0;
//групповые
if (isset($_GET['tm1'])) {
$tm = 1;
} elseif (isset($_GET['tm2'])) {
$tm = 2;
} else {
$this->error = 'Что-то здесь не так';
}
if ($tm != 0) {
$t1 = $tm;
$t2 = 1;
$tmmax = 0;
if ($tm == 1) {
$t2 = 2;
}
$cl111 = mysql_query(
'SELECT `u`.`clan`,`st`.`team`,`st`.`id`,`st`.`zv` FROM `stats` AS `st` LEFT JOIN `users` AS `u` ON (`st`.`id` = `u`.`id`) WHERE `st`.`zv` = "' . $z['id'] . '" LIMIT 200'
);
$cln = 0;
while ($pc111 = mysql_fetch_array($cl111)) {
if ($pc111['clan'] == $this->u->info['clan'] && $this->u->info['clan'] != 0 && $pc111['team'] == $t2) {
$cln++;
}
if ($pc111['team'] == $t1) {
$tmmax++;
}
}
if ($cln > 0) {
$this->error = 'Вы не можете сражаться против сокланов';
} elseif ($z['bot2'] == 1 && $t1 == 2) {
$this->error = 'Вы не можете сражаться на стороне ботов';
} elseif ($z['money3'] > 0 && $z['money3'] > $this->u->info['money3']) {
$this->error = 'У Вас недостаточно денег, чтобы принять эту заявку';
} elseif (($z['money'] > 0 || $z['money3'] > 0) && $this->u->info['level'] < 4) {
$this->error = 'Бои на деньги проводятся с 4-го уровня';
} elseif ($z['tm' . $t1 . 'max'] > $tmmax) {
if ($z['min_lvl_' . $t1] > $this->u->info['level'] || $z['max_lvl_' . $t1] < $this->u->info['level']) {
$this->error = 'Вы не подходите по уровню, за эту команду могут зайти персонажи ' . $z['min_lvl_' . $t1] . ' - ' . $z['max_lvl_' . $t1] . ' уровня';
} elseif ($this->u->stats['hpNow'] < ceil($this->u->stats['hpMax'] / 100 * 30)) {
$this->error = 'Вы слишком ослаблены, восстановитесь';
} else {
$upd = mysql_query(
'UPDATE `stats` SET `zv` = "' . $z['id'] . '",`team` = "' . mysql_real_escape_string(
(int)$t1
) . '" WHERE `id` = "' . $this->u->info['id'] . '" LIMIT 1'
);
if (!$upd) {
$this->error = 'Ошибка приема заявки...';
} else {
$this->error = 'Вы приняли групповой бой...';
$zi = $z;
$this->u->info['zv'] = $z['id'];
$this->u->info['team'] = mysql_real_escape_string((int)$t1);
}
}
} else {
$this->error = 'Группа уже набрана (' . ($z['tm' . $t1 . 'max'] - $tmmax) . ')';
}
}
} elseif ($z['razdel'] == 5 && $this->u->info['level'] > 1) {
//хаотичные
$col_p = mysql_fetch_array(
mysql_query('SELECT COUNT(*) FROM `stats` WHERE `zv` = "' . $z['id'] . '"')
);
$cols = $col_p[0];
if ($cols >= $z['maxplayers']) {
$this->error = 'Достигнут максимальный предел участников в этой заявке!';
} elseif ($this->testTravm() == 1 && $z['k'] != 1) {
$this->error = 'Вы травмированы. С такими увечьями доступны кулачные бои.';
} elseif ($this->testTravm() == 2) {
$this->error = 'Вы травмированы. С такими увечьями невозможно сражаться.';
} elseif (!$this->u->info['no_zv_key'] && (!isset($_SESSION['code2']) || $_SESSION['code2'] < 1 || ($_POST['code21'] != $_SESSION['code2'] && $_POST['code22'] != $_SESSION['code2']))) {
$this->error = 'Неправильный код подтверждения';
} elseif ($z['min_lvl_1'] > $this->u->info['level'] || $z['max_lvl_1'] < $this->u->info['level']) {
$this->error = 'Вы не подходите по уровню, за эту команду могут зайти персонажи ' . $z['min_lvl_1'] . ' - ' . $z['max_lvl_1'] . ' уровня';
} elseif ($this->u->stats['hpNow'] < ceil($this->u->stats['hpMax'] / 100 * 30)) {
$this->error = 'Вы слишком ослаблены, восстановитесь';
} elseif ($z['money'] > 0 && $this->u->info['level'] < 4) {
$this->error = 'Бои на деньги проводятся с 4-го уровня';
} else {
$t1 = 0;
if ($z['type'] == 33) {
//============================================================================================= Призовые
Db::sql(
'insert into users (name, align, `real`, login, host_reg, pass, ip, ipreg, city, cityreg, room, timereg, mail, bithday, sex, fnq, battle, molch2, level)
values (?,?,1,?,0,?,?,?,?,?,422,unix_timestamp(),?,?,?,0,0,unix_timestamp() + 86400,8)',
[
$this->u->info['name'],
$this->u->info['align'],
$this->u->info['login'],
$this->u->info['pass'],
IP,
IP,
'capitalcity',
'capitalcity',
'haot@new-combats.com',
'01.01.1980',
$this->u->info['sex'],
]
);
$uidb = Db::lastInsertId();
Db::sql('update users set inUser = ? where id = ?', [$uidb, $this->u->info['id']]);
//тут классы
$sellclass = rand(1, 6);
$stmt1 = Db::prepare('update items_users set inOdet = ? where id = ?');
$stmt2 = Db::prepare(
'update items_users set `1price` = (select price_1 from items_shop where sid = 1 and items_shop.item_id = ?) where id = ?'
);
$stmt3 = Db::prepare(
'insert into stats (id, stats, ability, skills, exp, priems) values (?,?,-75,-9,100000,?)'
);
if ($sellclass == 1) {
//уворот класс 1
$this->add_effn($uidb, 8); // ловка
$this->add_effn($uidb, 20); // сокрушение
$items = [
1 => 525,
2 => 539,
3 => 523,
14 => 523,
4 => 290,
5 => 541,
7 => 633,
8 => 647,
9 => 680,
10 => 685,
11 => 685,
12 => 685,
13 => 1151,
16 => 707,
17 => 712,
];
foreach ($items as $slot => $itemId) {
$re = $this->u->addItem($itemId, $uidb);
$stmt1->execute([$slot, $re]);
$stmt2->execute([$itemId, $re]);
}
$stmt3->execute(
[
$uidb,
's1=21|s2=31|s3=16|s4=30|rinv=40|m9=5|m6=10|s7=0|a1=10|a2=0|a3=0|a4=0|a5=0|mg1=0|mg2=0|mg3=0|mg4=0|mg5=0|mg6=0|mg7=0|s5=0|s6=0',
'193|8|217|221|6|213|14|220|141|232|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',
]
);
//уворот класс закончен
} elseif ($sellclass == 2) {
//крит класс 2
$this->add_effn($uidb, 7); // инта
$this->add_effn($uidb, 20); // сокрушение
$items = [
1 => 527,
2 => 537,
3 => 567,
14 => 723,
4 => 291,
5 => 544,
7 => 626,
8 => 651,
9 => 683,
10 => 686,
11 => 686,
12 => 686,
13 => 706,
16 => 708,
17 => 717,
];
foreach ($items as $slot => $itemId) {
$re = $this->u->addItem($itemId, $uidb);
$stmt1->execute([$slot, $re]);
$stmt2->execute([$itemId, $re]);
}
$stmt3->execute(
[
$uidb,
's1=24|s2=20|s3=24|s4=30|rinv=40|m9=5|m6=10|s7=0|a1=0|a2=0|a3=0|a4=9|a5=0|mg1=0|mg2=0|mg3=0|mg4=0|mg5=0|mg6=0|mg7=0|s5=0|s6=0|a6=0|s8=0|s9=0|s10=0|s11=0|s12=0|s13=0|s14=0|s15=0',
'193|204|221|138|9|188|240|215|147|232|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',
]
);
} elseif ($sellclass == 3) {
//танк класс 3
$this->add_effn($uidb, 1); // сила
$this->add_effn($uidb, 20); // сокрушение
$items = [
1 => 533,
2 => 536,
3 => 558,
14 => 722,
4 => 291,
5 => 545,
7 => 628,
8 => 654,
9 => 684,
10 => 689,
11 => 689,
12 => 689,
13 => 700,
16 => 710,
17 => 718,
];
foreach ($items as $slot => $itemId) {
$re = $this->u->addItem($itemId, $uidb);
$stmt1->execute([$slot, $re]);
$stmt2->execute([$itemId, $re]);
}
$stmt3->execute(
[
$uidb,
's1=42|s2=3|s3=3|s4=50|rinv=40|m9=5|m6=10|s7=0|a1=0|a2=0|a3=9|a4=0|a5=0|mg1=0|mg2=0|mg3=0|mg4=0|mg5=0|mg6=0|mg7=0|s5=0|s6=0|a6=0|s8=0|s9=0|s10=0|s11=0|s12=0|s13=0|s14=0|s15=0',
'11|204|233|226|45|14|139|221|6|232|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',
]
);
} elseif ($sellclass == 4) {
//топор класс 4
$this->add_effn($uidb, 1); // сила
$this->add_effn($uidb, 20); // сокрушение
$items = [
1 => 528,
2 => 538,
3 => 552,
14 => 552,
4 => 291,
5 => 543,
7 => 627,
8 => 653,
9 => 681,
10 => 687,
11 => 687,
12 => 687,
13 => 320,
16 => 709,
17 => 716,
];
foreach ($items as $slot => $itemId) {
$re = $this->u->addItem($itemId, $uidb);
$stmt1->execute([$slot, $re]);
$stmt2->execute([$itemId, $re]);
}
$stmt3->execute(
[
$uidb,
's1=43|s2=15|s3=15|s4=25|rinv=40|m9=5|m6=10|s7=0|a1=0|a2=10|a3=0|a4=0|a5=0|mg1=0|mg2=0|mg3=0|mg4=0|mg5=0|mg6=0|mg7=0|s5=0|s6=0',
'193|139|49|14|6|217|221|204|147|45|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',
]
);
} elseif ($sellclass == 5) {
//м земля класс 5
//кастим эфекты
$this->add_effn($uidb, 9); // интелект
$this->add_effn($uidb, 32); // Холодный разум
$this->add_effn($uidb, 54); // Маг уселок земля
$this->add_effn($uidb, 439); // Маг уселок
$items = [
1 => 531,
2 => 534,
3 => 1026,
4 => 291,
5 => 548,
7 => 629,
8 => 657,
9 => 674,
10 => 692,
11 => 692,
12 => 692,
13 => 699,
16 => 711,
17 => 714,
];
foreach ($items as $slot => $itemId) {
$re = $this->u->addItem($itemId, $uidb);
$stmt1->execute([$slot, $re]);
$stmt2->execute([$itemId, $re]);
}
$stmt3->execute(
[
$uidb,
's1=14|s2=3|s3=3|s4=25|rinv=40|m9=5|m6=10|s7=0|a1=0|a2=0|a3=0|a4=0|a5=3|mg1=0|mg2=0|mg3=0|mg4=6|mg5=0|mg6=0|mg7=0|s5=13|s6=40|a6=0|s8=0|s9=0|s10=0|s11=0|s12=0|s13=0|s14=0|s15=0',
'208|117|170|44|113|128|122|249|246|147|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',
]
);
} elseif ($sellclass == 6) {
//м воздух 6
//кастим эфекты
$this->add_effn($uidb, 9); // интелект
$this->add_effn($uidb, 32); // Холодный разум
$this->add_effn($uidb, 53); // Маг уселок воздух
$this->add_effn($uidb, 439); // Маг уселок
$items = [
1 => 531,
2 => 534,
3 => 1026,
4 => 291,
5 => 548,
7 => 629,
8 => 658,
9 => 675,
10 => 693,
11 => 693,
12 => 693,
13 => 699,
16 => 711,
17 => 714,
];
foreach ($items as $slot => $itemId) {
$re = $this->u->addItem($itemId, $uidb);
$stmt1->execute([$slot, $re]);
$stmt2->execute([$itemId, $re]);
}
$stmt3->execute(
[
$uidb,
's1=14|s2=3|s3=3|s4=25|rinv=40|m9=5|m6=10|s7=0|a1=0|a2=0|a3=0|a4=0|a5=3|mg1=0|mg2=6|mg3=0|mg4=0|mg5=0|mg6=0|mg7=0|s5=13|s6=40|a6=0|s8=0|s9=0|s10=0|s11=0|s12=0|s13=0|s14=0|s15=0',
'208|93|98|260|39|263|257|104|30|147|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',
]
);
}
// классы кончились
//кастим эфекты
$this->add_effn($uidb, 37);//нектар
$this->add_effn($uidb, 38);//нектар отрицания
$this->add_effn($uidb, 283);//Бутерброд -Завтрак Рыцаря- толстый
$this->add_effn($uidb, 25);//Защита от оружия
$this->add_effn($uidb, 296);//Жажда Жизни +6
Db::sql('update users set money = -3000, money2 = 0 where id = ?', [$uidb]);
//Корекция хп в призовых
Db::sql('update stats set hpNow = hpAll, mpNow = mpAll where id = ?', [$uidb]);
$this->u->info['id'] = $uidb;
//=============================================================================================
$this->error = 'Вы вселены в клона 8го левела'; //ТУТ вселяем в клона призовые хаоты
echo '';
}
$this->u->info['login2'] = '';
$blnc = $this->u->stats['reting'];
$z['tm' . $t1] += $blnc;
$upd = Db::run(
'update stats set zv = ?, team = ? where id = ?',
[$z['id'], $t1, $this->u->info['id']]
);
if ($upd) {
Db::sql(
'update users set login2 = ? where id = ?',
[$this->u->info['login2'], $this->u->info['id']]
);
Db::sql(
'update zayvki set tm1 = ?, tm2 = ? where id = ?',
[$z['tm1'], $z['tm2'], $z['id']]
);
$zi = $z;
$this->u->info['zv'] = $z['id'];
$this->u->info['team'] = $t1;
$this->error = 'Вы приняли хаотичный бой...';
} else {
$this->error = 'Ошибка приема заявки...';
}
}
}
} else {
$this->error = 'Заявка на бой не найдена.';
}
}
}
}
}