diff --git a/_incl_data/class/Core/ComparsionHelper.php b/_incl_data/class/Core/ComparsionHelper.php
new file mode 100644
index 00000000..433ac15f
--- /dev/null
+++ b/_incl_data/class/Core/ComparsionHelper.php
@@ -0,0 +1,17 @@
+ $maximum) {
+ $value = $maximum;
+ }
+ return $value;
+ }
+}
\ No newline at end of file
diff --git a/_incl_data/class/FightRequest.php b/_incl_data/class/FightRequest.php
index e773f2a8..ab2a3b80 100644
--- a/_incl_data/class/FightRequest.php
+++ b/_incl_data/class/FightRequest.php
@@ -1,20 +1,27 @@
'групповые', 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 const BATTLE_RAZDEL_GROUP = 4;
+ public const BATTLE_RAZDEL_CHAOTIC = 5;
+ public const BATTLE_RAZDEL_CURRENT = 6;
+ public const BATTLE_RAZDEL_ENDED = 7;
+ public const BATTLE_RAZDEL_TOURNAMENTS = 10;
+ private const BATTLE_TYPE_MELEE = 1;
+ private const BATTLE_TYPE_NO_EKR_ITEMS = 51;
+ private const CHAOTIC_TYPE_PRIZED = 33;
/**
* Заявки на бой.
@@ -31,34 +38,32 @@ class FightRequest
[$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) {
+ $cols = $this->countUsersAll($this->u->info['zv']);
+ if ($cols === 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)
+ /** Считаем количество людей в конкретной заявке.
+ * @param int $frId id заявки
+ * @return int
+ */
+ private function countUsersAll(int $frId): int
{
- $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]);
+ return Db::getValue('select count(*) from stats where zv = ?', [$frId]);
+ }
+ /** Считаем количество людей в конкретной заявке во второй команде.
+ * @param int $frId id заявки
+ * @return int
+ */
+ private function countUsersInTeam2(int $frId): int
+ {
+ return Db::getValue('select count(*) from stats where zv = ? and team = 2', [$frId]);
}
private function testTravm()
@@ -70,139 +75,49 @@ class FightRequest
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'
+ //Проверяем хаотичные и групповые бои [в этом городе ?]
+ $sp = 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 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'] . '"'
+ foreach ($sp as $pl) {
+ $uz = Db::getRow(
+ 'select users.id, * from users left join stats on users.id = stats.id where 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;
- }
+ foreach ($uz as $t) {
+ ${'tm' . $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 ($pl['razdel'] == self::BATTLE_RAZDEL_CHAOTIC) {
+ $cols = $this->countUsersAll($pl['id']);
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);
- }
- }
+ if (
+ $pl['time_start'] >= time() - $pl['time'] &&
+ ($pl['razdel'] != self::BATTLE_RAZDEL_GROUP || $i[1] < $pl['tm1max'] || $i[2] < $pl['tm2max'])
+ ) {
+ continue;
+ }
+
+ $toChat = rtrim($toChat, ',');
+ $toWhere = ltrim($toWhere, 'OR ');
+ if ($pl['razdel'] == self::BATTLE_RAZDEL_GROUP) {
+ $this->testGroup($i, $pl, $toChat, $toWhere);
+ } else {
+ $this->testCronChaotic($pl, $toChat, $toWhere);
}
}
}
@@ -213,66 +128,18 @@ class FightRequest
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']) {
+ $z = Db::getValue(
+ 'select count(*) from zayvki where id = ? and (cancel > 0 or btl_id >0 or time < unix_timestamp() - 3600)',
+ [$this->u->info['zv']]
+ );
+ if ($z > 0) {
$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) {
@@ -331,16 +198,16 @@ class FightRequest
$requiredFightersToStartBattle = FAST_FIGHT_REQUIRED_FIGHTERS_COUNT;
}
- $pendingFightersCount = Db::getValue('select count(*) from stats where zv = ?', [$zayavka['id']]);
-
+ $pendingFightersCount = $this->countUsersAll($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';
+ //$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]]
+ $getBotsQuery,
+ [$levelToExp[$zayavka['min_lvl_1']], $levelToExp[$zayavka['max_lvl_1'] + 1]]
);
}
@@ -370,14 +237,15 @@ class FightRequest
'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++;
+ if (!$bot) {
+ continue;
}
+ 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);
@@ -392,41 +260,37 @@ class FightRequest
}
}
- /** Проверяем хаотичные и групповые бои в этом городе
- * @return void
- * @throws Exception
- */
- private function testCronGroupAndChaotic()
+ /** Проверяем хаотичные и групповые бои [в этом городе ?] */
+ private function testCronGroupAndChaotic(): void
{
- 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'
+ 'select * from zayvki where btl_id = 0 and cancel = 0 and start = 0 and razdel in (4, 5) order by id desc'
);
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']]
+ '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']] ??= 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'])) {
+ if (
+ $zv['time_start'] > time() - $zv['time'] &&
+ ($zv['razdel'] != self::BATTLE_RAZDEL_GROUP || $i[1] < $zv['tm1max'] || $i[2] < $zv['tm2max'])
+ ) {
continue;
}
$toChat = rtrim($toChat, ',');
$toWhere = ltrim($toWhere, 'OR ');
- trigger_error('test');
- if ($zv['razdel'] == GROUP_BATLE) {
+
+ if ($zv['razdel'] == self::BATTLE_RAZDEL_GROUP) {
$this->testGroup($i, $zv, $toChat, $toWhere);
} else {
$this->testCronChaotic($zv, $toChat, $toWhere);
@@ -436,7 +300,6 @@ class FightRequest
public function testCronZv()
{
- $this->testCronTurnir();
$this->testCronGroupAndChaotic();
if ($this->backTest || self::$bcktst) {
@@ -446,171 +309,120 @@ class FightRequest
}
- public function userInfo()
+ private function cancelGroup($zv, $uids, $debug = null)
{
- $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'] . '
-
-
-
-';
-
- if ($this->u->stats['mpAll'] > 0) {
- $r .= '
' . floor(
- $this->u->stats['mpNow']
- ) . '/' . $this->u->stats['mpAll'] . '
-
-
-
';
- }
- $r .= '
';
- unset($stt, $ph, $pm);
- return $r;
- }
-
- public function cancelGroup($zv, $uids, $debug = null)
- {
- if ($zv['priz'] > 0) {
- $sp = mysql_query('SELECT `id` FROM `stats` WHERE `zv` = "' . $zv['id'] . '"');
- }
- $upd = mysql_query('UPDATE `stats` SET `zv` = "0" WHERE `zv` = "' . $zv['id'] . '"');
- if (!$upd) {
- return;
- }
- $upd = mysql_query('UPDATE `zayvki` SET `cancel` = "' . time() . '" WHERE `id` = "' . $zv['id'] . '"');
- if (!$upd || $uids == '') {
+ Db::sql('update stats set zv = default where zv = ?', [$zv['id']]);
+ Db::sql('update zayvki set cancel = unix_timestamp() where id = ?', [$zv['id']]);
+ if (empty($uids)) {
return;
}
+ $text = ' Не удалось начать поединок по причине: Группа не набрана!';
if ($zv['priz'] > 0) {
- while ($pl = mysql_fetch_array($sp)) {
- //Выдаем по 1 жетону
- if ($zv['type'] == 33) //ТУТ група не набранна удаляем персонажа и выдаем жетон
- {
- $pld = mysql_fetch_array(
- mysql_query('SELECT `id` FROM `users` WHERE `inUser` = "' . $pl['id'] . '"')
- );
- if (isset($pld['id'])) {
- mysql_query('UPDATE `users` SET `inUser` = "0" WHERE `id` = "' . $pld['id'] . '" LIMIT 1');
- $this->u->addItem(4754, $pld['id'], '');
- $uids = $pld['id'];
- mysql_query('DELETE FROM `users` WHERE `id` = "' . $pl['id'] . '" LIMIT 1');
- mysql_query('DELETE FROM `stats` WHERE `id` = "' . $pl['id'] . '" LIMIT 1');
- mysql_query('DELETE FROM `items_users` WHERE `uid` = "' . $pl['id'] . '" LIMIT 100');
- mysql_query('DELETE FROM `eff_users` WHERE `uid` = "' . $pl['id'] . '" LIMIT 100');
- }
- } else {
- $this->u->addItem(4754, $pl['id'], '');
- }
+ $pg = $this->cancelPrizedChaotic($zv);
+ if (!empty($pg[0])) {
+ $uids = $pg[0];
}
- $text = ' Не удалось начать поединок по причине: Группа не набрана. Вы получаете Призовой Жетон (х1)';
- } else {
- $text = ' Не удалось начать поединок по причине: Группа не набрана!';
+ $text .= $pg[1];
}
$chat = new Chat();
$chat->sendsys($text . $debug, $uids);
}
- public function add()
+ private function cancelPrizedChaotic(array $zv): array
{
- if (!isset($_GET['r']) || $this->u->info['inTurnirnew'] != 0) {
- return;
- }
- $r = round(intval($_GET['r']));
- if (!in_array($r, [1, 4, 5, 8, 10])) {
- return;
- }
- $az = 1;
- if ($r == 1 && $this->u->info['level'] > 0) {
- $az = 0;
- $this->error = 'Вы уже выросли из ползунков ;)';
- }
- if (($r == 4 || $r == 5) && $this->u->info['level'] < 2) {
- $az = 0;
- $this->error = 'В ' . $this->z1n[$r] . ' бои только со второго уровня.';
+ $stmt = Db::getRows('select id from stats where zv = ?', [$zv['id']]);
+ foreach ($stmt as $user) {
+ if ($zv['type'] === self::CHAOTIC_TYPE_PRIZED) {
+ $stmt2 = Db::getValue('select id from users where inUser = ?', [$user['id']]);
+ if (!empty($stmt2)) {
+ Db::sql('update users set inUser = 0 where id = ?', [$stmt2]);
+ Db::sql('delete from users where id = ?', [$user['id']]);
+ Db::sql('delete from stats where id = ?', [$user['id']]);
+ Db::sql('delete from items_users where uid = ?', [$user['id']]);
+ Db::sql('delete from eff_users where uid = ?', [$user['id']]);
+ $this->u->addItem(4754, $user['id']);
+ }
+ } else {
+ $this->u->addItem(4754, $user['id']);
+ }
}
+ return [
+ $stmt2 ?? 0,
+ ' Вы получаете Призовой Жетон (х1)',
+ ];
+ }
- if ($this->testTravm() == 1 && $_POST['k'] != 1) {
+ private function addGroupRequest()
+ {
+
+ }
+
+ public function addGroupOrChaoticRequest(int $r)
+ {
+ if (!in_array($r, [self::BATTLE_RAZDEL_GROUP, self::BATTLE_RAZDEL_CHAOTIC])) {
+ return;
+ }
+ $k = (int)$_POST['k'];
+ $az = 1;
+
+ if ($this->testTravm() == 1 && $k !== 1) {
$this->error = 'Вы травмированы. С такими увечьями доступны кулачные бои.';
$az = 0;
} elseif ($this->testTravm() == 2) {
$this->error = 'Вы травмированы. С такими увечьями невозможно сражаться.';
$az = 0;
- } elseif ($this->u->info['hpNow'] < $this->u->stats['hpAll'] / 100 * 30) {
+ } elseif ($this->u->isWeakened()) {
$this->error = 'Вы еще слишком ослаблены чтобы начать новый бой';
$az = 0;
}
if ($this->u->info['zv'] > 0) {
+ $this->error = 'Вы уже находитесь в заявке.';
$az = 0;
- $this->error = 'Вы уже находите в заявке.';
}
- if ($az != 1) {
+ if ($az === 0) {
return;
}
+ $timeout = (int)$_POST['timeout'];
+
$nz = [];
$nz['travmaChance'] = 0;
$nz['time_start'] = 0;
- $nz['min_lvl_1'] = 0;
- $nz['min_lvl_2'] = 0;
- $nz['max_lvl_1'] = 21;
- $nz['max_lvl_2'] = 21;
$nz['tm1max'] = 0;
$nz['tm2max'] = 0;
$nz['invise'] = 0;
- $nz['money'] = 0;
- $nz['comment'] = '';
$nz['tm1'] = 0;
$nz['tm2'] = 0;
$nz['otmorozok'] = 0;
$nz['fastfight'] = 0;
$nz['noinc'] = 0;
-
-
- $nz['city'] = $this->u->info['city'];
- $nz['creator'] = $this->u->info['id'];
$nz['type'] = 0;
- if ($_POST['k'] == 1) {
+
+ if ($k === 1) {
$nz['type'] = 1;
}
- if ($_POST['k'] == 2) {
+ if ($k === 2) {
$nz['type'] = 6;
$nz['travmaChance'] = 100;
}
- $_POST['timeout'] = round(intval(mysql_real_escape_string($_POST['timeout'])));
- if ($_POST['timeout'] == 1 || $_POST['timeout'] == 2 || $_POST['timeout'] == 3 || $_POST['timeout'] == 4 || $_POST['timeout'] == 5) {
- $nz['timeout'] = $_POST['timeout'] * 60;
- } else {
- $nz['timeout'] = 3 * 60;
+
+ if (!in_array($timeout, [1, 2, 3, 4, 5])) {
+ $timeout = 3;
}
+ $nz['timeout'] = $timeout * 60;
$nz['razdel'] = $r;
+ $nz['comment'] = substr($_POST['cmt'], 0, 40);
+ $nz['comment'] = str_replace('"', '"', $nz['comment']);
+
$gad = 1;
- if ($r == 5 && $this->u->info['level'] > 1) {
+ if ($r == self::BATTLE_RAZDEL_CHAOTIC) {
//хаотичный бой
if ($_POST['startime2']) {
$nz['time_start'] = (int)$_POST['startime2'];
- $nz['comment'] = substr($_POST['cmt'], 0, 40);
- $nz['comment'] = str_replace('"', '"', $nz['comment']);
- $nz['comment'] = htmlspecialchars($nz['comment'], null);
+
if (!in_array($nz['time_start'], [60, 180, 300])) {
$nz['time_start'] = 600;
}
@@ -655,42 +467,24 @@ class FightRequest
$nz['kingfight'] = 0;
}
- $nz['timeout'] = (int)$_POST['timeout'];
- if ($nz['timeout'] != 1 && $nz['timeout'] != 2 && $nz['timeout'] != 3 && $nz['timeout'] != 4 && $nz['timeout'] != 5) {
- $nz['timeout'] = 3;
- }
+ //Генерируем уровни
+ $levels = FRHelper::getChaoticTeammatesLevel($_POST['levellogin1'], $this->u->info['level']);
+ $nz['min_lvl_1'] = $levels->min;
+ $nz['max_lvl_1'] = $levels->max;
+ $nz['min_lvl_2'] = $levels->min;
+ $nz['max_lvl_2'] = $levels->max;
- //Генерируем уровни союзника
- $lvl = (int)$_POST['levellogin1'];
- if ($lvl == 0) {
- $nz['min_lvl_1'] = 2;
- $nz['max_lvl_1'] = 21;
- } elseif ($lvl == 3) {
- $nz['min_lvl_1'] = $this->u->info['level'];
- $nz['max_lvl_1'] = $this->u->info['level'];
- $nz['min_lvl_2'] = $nz['min_lvl_1'];
- $nz['max_lvl_2'] = $nz['min_lvl_2'];
- } elseif ($lvl == 6) {
- $nz['min_lvl_1'] = $this->u->info['level'] - 1;
- $nz['max_lvl_2'] = $this->u->info['level'] + 1;
- } else {
- $nz['min_lvl_1'] = 2;
- $nz['max_lvl_1'] = 2;
- }
-
- if ((int)$_POST['k'] == 1) {
- //кулачный бой
- $nz['type'] = 1;
- }
- if ((int)$_POST['k'] == 2) {
- //кровавый бой
- $nz['type'] = 6;
- $nz['travmaChance'] = 1;
- }
- $nz['timeout'] = $nz['timeout'] * 60;
$nz['tm1'] = $this->u->stats['reting'];
- if (!$this->u->info['no_zv_key'] && ($_POST['code21'] == 0 || $_POST['code21'] != $_SESSION['code2'] || $_SESSION['code2'] == 0 || !isset($_SESSION['code2']))) {
+ if (
+ !$this->u->info['no_zv_key'] &&
+ (
+ $_POST['code21'] == 0 ||
+ $_POST['code21'] != $_SESSION['code2'] ||
+ $_SESSION['code2'] == 0 ||
+ !isset($_SESSION['code2'])
+ )
+ ) {
$this->error = 'Неправильный код подтверждения';
$gad = 0;
}
@@ -698,127 +492,27 @@ class FightRequest
$gad = 0;
$this->error = 'Что-то не так... ';
}
- } elseif ($r == 4 && $this->u->info['level'] > 1) {
+ } elseif ($r == self::BATTLE_RAZDEL_GROUP) {
//групповой бой
//здесь заносим и проверяем данные на гурпповой бой
if ($_POST['startime']) {
$nz['time_start'] = (int)$_POST['startime'];
- $nz['comment'] = substr($_POST['cmt'], 0, 40);
- $nz['comment'] = str_replace('"', '"', $nz['comment']);
- if ($nz['time_start'] != 300 && $nz['time_start'] != 600 && $nz['time_start'] != 900 && $nz['time_start'] != 1200 && $nz['time_start'] != 1800) {
+ if (!in_array($nz['time_start'], [300, 600, 900, 1200, 1800])) {
$nz['time_start'] = 600;
}
- $nz['timeout'] = (int)$_POST['timeout'];
- if ($nz['timeout'] != 1 && $nz['timeout'] != 2 && $nz['timeout'] != 3 && $nz['timeout'] != 4 && $nz['timeout'] != 5) {
- $nz['timeout'] = 3;
- }
-
- $nz['timeout'] = $nz['timeout'] * 60;
-
- $nz['tm1max'] = (int)$_POST['nlogin1'];
- if ($nz['tm1max'] < 1 || $nz['tm1max'] > 99) {
- $this->error .= 'Неверное кол-во союзников ';
- $gad = 0;
- }
-
- $nz['tm2max'] = (int)$_POST['nlogin2'];
- if ($nz['tm2max'] < 1 || $nz['tm2max'] > 99) {
- $this->error .= 'Неверное кол-во противников ';
- $gad = 0;
- }
-
- if ($this->testTravm() == 1 && $_POST['k'] != 1) {
- $this->error = 'Вы травмированы. С такими увечьями доступны кулачные бои.';
- $gad = 0;
- } elseif ($this->testTravm() == 2) {
- $this->error = 'Вы травмированы. С такими увечьями невозможно сражаться.';
- $gad = 0;
- } elseif ($nz['tm1max'] + $nz['tm2max'] < 3) {
- $this->error .= 'Заявки 1 на 1 подаются в разделе физические или договорные бои ';
- $gad = 0;
- }
+ $nz['tm1max'] = ComparsionHelper::minimax((int)$_POST['nlogin1'], 1, 99);
+ $nz['tm2max'] = ComparsionHelper::minimax((int)$_POST['nlogin2'], 1, 99);
//Генерируем уровни союзника
- $lvl = (int)$_POST['levellogin1'];
- if ($lvl == 0) {
- $nz['min_lvl_1'] = 2;
- $nz['max_lvl_1'] = 21;
- } elseif ($lvl == 1) {
- $nz['min_lvl_1'] = 2;
- $nz['max_lvl_1'] = $this->u->info['level'];
- } elseif ($lvl == 2) {
- $nz['min_lvl_1'] = 2;
- $nz['max_lvl_1'] = $this->u->info['level'] - 1;
- } elseif ($lvl == 3) {
- $nz['min_lvl_1'] = $this->u->info['level'];
- $nz['max_lvl_1'] = $this->u->info['level'];
- } elseif ($lvl == 4) {
- $nz['min_lvl_1'] = $this->u->info['level'];
- $nz['max_lvl_1'] = $this->u->info['level'] + 1;
- } elseif ($lvl == 5) {
- $nz['min_lvl_1'] = $this->u->info['level'] - 1;
- $nz['max_lvl_1'] = $this->u->info['level'];
- } elseif ($lvl == 6) {
- $nz['min_lvl_1'] = $this->u->info['level'] - 1;
- $nz['max_lvl_1'] = $this->u->info['level'] + 1;
- $nz['min_lvl_1'] = 99;
- } else {
- $this->error = 'Что-то не так... ';
- $gad = 0;
- }
+ $levels = FRHelper::getTeammatesLevel($_POST['levellogin1'], $this->u->info['level']);
+ $nz['min_lvl_1'] = $levels->min;
+ $nz['max_lvl_1'] = $levels->max;
//Генерируем уровни противника
- $lvl = (int)$_POST['levellogin2'];
- if ($lvl == 0) {
- $nz['min_lvl_2'] = 2;
- $nz['max_lvl_2'] = 21;
- } elseif ($lvl == 1) {
- $nz['min_lvl_2'] = 2;
- $nz['max_lvl_2'] = $this->u->info['level'];
- } elseif ($lvl == 2) {
- $nz['min_lvl_2'] = 2;
- $nz['max_lvl_2'] = $this->u->info['level'] - 1;
- } elseif ($lvl == 3) {
- $nz['min_lvl_2'] = $this->u->info['level'];
- $nz['max_lvl_2'] = $this->u->info['level'];
- } elseif ($lvl == 4) {
- $nz['min_lvl_2'] = $this->u->info['level'];
- $nz['max_lvl_2'] = $this->u->info['level'] + 1;
- } elseif ($lvl == 5) {
- $nz['min_lvl_2'] = $this->u->info['level'] - 1;
- $nz['max_lvl_2'] = $this->u->info['level'];
- } elseif ($lvl == 6) {
- $nz['min_lvl_2'] = $this->u->info['level'] - 1;
- $nz['max_lvl_2'] = $this->u->info['level'] + 1;
- $nz['min_lvl_2'] = 99;
- } else {
- $this->error = 'Что-то не так... ';
- $gad = 0;
- }
-
- if ($nz['min_lvl_1'] < 2) {
- $nz['min_lvl_1'] = 2;
- }
- if ($nz['max_lvl_1'] > 21) {
- $nz['max_lvl_1'] = 21;
- }
- if ($nz['min_lvl_2'] < 2) {
- $nz['min_lvl_2'] = 2;
- }
- if ($nz['max_lvl_2'] > 21) {
- $nz['max_lvl_2'] = 21;
- }
-
- if ((int)$_POST['k'] == 1) {
- //кулачный бой
- $nz['type'] = 1;
- }
- if ((int)$_POST['k'] == 2) {
- //кровавый бой
- $nz['type'] = 6;
- $nz['travmaChance'] = 100;
- }
+ $levels = FRHelper::getTeammatesLevel($_POST['levellogin2'], $this->u->info['level']);
+ $nz['min_lvl_2'] = $levels->min;
+ $nz['max_lvl_2'] = $levels->max;
} else {
$gad = 0;
@@ -827,7 +521,7 @@ class FightRequest
}
$bt2 = (int)$_POST['bots2'];
- if ($bt2 != 0 && $r == 4 && $this->u->info['level'] > 1) {
+ if ($bt2 != 0 && $r == self::BATTLE_RAZDEL_GROUP) {
$bt2 = 1;
$nz['min_lvl_2'] = $this->u->info['level'];
$nz['max_lvl_2'] = $this->u->info['level'];
@@ -838,74 +532,13 @@ class FightRequest
}
if ($gad == 1) {
- if (!isset($nz['withUser'])) {
- $nz['withUser'] = '';
- }
- $nz['time_create_zv'] = time();
- if ($nz['razdel'] == 4 || $nz['razdel'] == 5) {
- //Округляем время для кроны
- $nz['time_create_zv'] = strtotime(
- date('d.m.Y H:i', $nz['time_create_zv']) . ':00', $nz['time_create_zv']
- );
- } elseif ($nz['razdel'] == 3) {
- $nz['noinc'] = 1;
- }
- $nz['teams'] = 2;
- $nz['align1'] = 0;
- $nz['align2'] = 0;
- $nz['align3'] = 0;
- if (isset($_POST['3align'])) {
- $nz['teams'] = 3;
- $nz['min_lvl_1'] = 2;
- $nz['min_lvl_2'] = 2;
- $nz['max_lvl_1'] = 21;
- $nz['max_lvl_2'] = 21;
- //
- if (floor($this->u->info['align']) == 3) {
- $nz['align1'] = 3;
- $nz['align2'] = 1;
- $nz['align3'] = 7;
- } elseif (floor($this->u->info['align']) == 7) {
- $nz['align1'] = 7;
- $nz['align2'] = 1;
- $nz['align3'] = 3;
- } else {
- $nz['align1'] = 1;
- $nz['align2'] = 3;
- $nz['align3'] = 7;
- }
- //
- }
- //
- if ($nz['razdel'] == 2 && isset($_POST['commentfiz'])) {
- $nz['comment'] = htmlspecialchars($_POST['commentfiz'], null);
- }
- //
- if ($nz['razdel'] == 5) {
- $nz['maxplayers'] = [
- 6 => 6,
- 8 => 8,
- 10 => 10,
- 12 => 12,
- 14 => 14,
- 16 => 16,
- 18 => 18,
- 20 => 20,
- 40 => 40,
- ];
- if (isset($nz['players'][$_POST['players']])) {
- $nz['maxplayers'];
- } else {
- $nz['maxplayers'] = $nz['maxplayers'][$_POST['players']];
- }
+ if ($nz['razdel'] == self::BATTLE_RAZDEL_CHAOTIC) {
+ $nz['maxplayers'] = (int)$_POST['players'];
}
+
$dbvalues = [
$nz['maxplayers'],
$nz['otmorozok'],
- $nz['align1'],
- $nz['align2'],
- $nz['align3'],
- $nz['teams'],
$nz['smert'],
$nz['noart'],
$nz['noeff'],
@@ -916,9 +549,9 @@ class FightRequest
$nz['fastfight'],
$nz['noinc'],
$bt2,
- $nz['time_create_zv'],
- $nz['city'],
- $nz['creator'],
+ strtotime(date('d.m.Y H:i:00')),
+ $this->u->info['city'],
+ $this->u->info['id'],
$nz['type'],
$nz['time_start'],
$nz['timeout'],
@@ -932,15 +565,13 @@ class FightRequest
$nz['invise'],
$nz['razdel'],
$nz['comment'],
- $nz['money'],
- $nz['withUser'],
$nz['tm1'],
$nz['tm2'],
];
- $dbquery = 'insert into zayvki (`maxplayers`,`otmorozok`,`align1`,`align2`,`align3`,`teams`,`smert`,`noart`,`noeff`,`noatack`,`arand`,`kingfight`,`nobot`,`fastfight`,`noinc`,`bot2`,`time`,`city`,`creator`,`type`,`time_start`,`timeout`,`min_lvl_1`,`min_lvl_2`,`max_lvl_1`,`max_lvl_2`,`tm1max`,`tm2max`,`travmaChance`,`invise`,`razdel`,`comment`,`money`,`withUser`,`tm1`,`tm2`) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)';
- $ins = Db::run($dbquery, $dbvalues);
+ $dbquery = 'insert into zayvki (`maxplayers`,`otmorozok`,`smert`,`noart`,`noeff`,`noatack`,`arand`,`kingfight`,`nobot`,`fastfight`,`noinc`,`bot2`,`time`,`city`,`creator`,`type`,`time_start`,`timeout`,`min_lvl_1`,`min_lvl_2`,`max_lvl_1`,`max_lvl_2`,`tm1max`,`tm2max`,`travmaChance`,`invise`,`razdel`,`comment`,`tm1`,`tm2`) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)';
+ Db::run($dbquery, $dbvalues);
$zid = Db::lastInsertId();
- if ($ins) {
+ if ($zid) {
Db::sql('update stats set zv = ?, team = 1 where id = ?', [$zid, $this->u->info['id']]);
$this->u->info['zv'] = $zid;
$this->error = 'Заявка на бой подана';
@@ -950,79 +581,6 @@ class FightRequest
}
}
- //тренеровочный бой
- public function addBot()
- {
- global $c;
-
- if (($this->u->info['level'] <= $c['bot_level'] || $this->u->info['admin'] > 0) && $this->u->info['exp'] != 12499) {
- $bot = $this->u->addNewbot($id['id'], null, $this->u->info['id'], null, true);
- } else {
- $bot = false;
- }
- if (!$bot) {
- $this->error = 'Бои с монстрами, нежитью, клонами и прочими вурдалаками проводятся только для персонажей младше 8 уровня... Со стороны посматривает Общий Враг, ему явно что-то не понравилось... ';
- } elseif ($this->u->info['hpNow'] < $this->u->stats['hpAll'] / 100 * 30 && ($r == 1)) {
- $this->error = 'Вы еще слишком ослаблены чтобы начать новый бой';
- $az = 0;
- } elseif ($this->u->info['align'] == 2) {
- $this->error = 'Хаосники не могут сражаться здесь';
- $az = 0;
- } elseif (!$bot) {
- echo 'Cannot start battle (no prototype "ND0Clone") ';
- } else {
- //создаем поединок с ботом
- $expB = 0;
- $btl = ['smert' => 0, 'noart' => 0, 'noeff' => 0, 'otmorozok' => 0, 'noatack' => 0, 'priz' => 0, 'arand' => 0, 'kingfight' => 0, 'nobot' => 0, 'fastfight' => 0, 'players' => '', 'timeout' => 60, 'type' => 0, 'invis' => 0, 'noinc' => 0, 'travmChance' => 0, 'typeBattle' => 0, 'addExp' => $expB, 'money' => 0, 'money3' => 0];
- $ins = mysql_query(
- 'INSERT INTO `battle` (`otmorozok`,`smert`,`noart`,`noeff`,`noatack`,`arand`,`kingfight`,`nobot`,`fastfight`,`clone`,`city`,`time_start`,`players`,`timeout`,`type`,`invis`,`noinc`,`travmChance`,`typeBattle`,`addExp`,`money`,`priz`) VALUES (
- "' . $btl['otmorozok'] . '",
- "' . $btl['smert'] . '",
- "' . $btl['noart'] . '",
- "' . $btl['noeff'] . '",
- "' . $btl['noatack'] . '",
- "' . $btl['arand'] . '",
- "' . $btl['kingfight'] . '",
- "' . $btl['nobot'] . '",
- "' . $btl['fastfight'] . '",
- "1",
- "' . $this->u->info['city'] . '",
- "' . time() . '",
- "' . $btl['players'] . '",
- "' . $btl['timeout'] . '",
- "' . $btl['type'] . '",
- "' . $btl['invis'] . '",
- "' . $btl['noinc'] . '",
- "' . $btl['travmChance'] . '",
- "' . $btl['typeBattle'] . '",
- "' . $btl['addExp'] . '",
- "' . $btl['money'] . '",
- "' . $btl['priz'] . '")'
- );
- if ($ins) {
- $btl_id = mysql_insert_id();
- //обновляем данные о поединке
- $this->u->info['enNow'] -= $trEn;
- $upd2 = mysql_query(
- 'UPDATE `users` SET `battle`="' . $btl_id . '" WHERE `id` = "' . $this->u->info['id'] . '" OR `id` = "' . $bot . '" LIMIT 2'
- );
- mysql_query(
- 'UPDATE `stats` SET `team`="1",`enNow` = "' . $this->u->info['enNow'] . '" WHERE `id` = "' . $this->u->info['id'] . '" LIMIT 1'
- );
- mysql_query(
- 'UPDATE `stats` SET `hpNow` = "' . $this->u->stats['hpAll'] . '",`team`="2" WHERE `id` = "' . $bot . '" LIMIT 1'
- );
- //обновляем заявку, что бой начался
- $this->u->info['battle'] = $btl_id;
- //Отправляем сообщение в чат всем бойцам
- $this->sendSysChatSound();
- die('');
- } else {
- $this->error = 'Cannot start battle (no prototype "ABD0Clone")';
- }
- }
- }
-
/**
* Звуковой пинг в чат?
* @return void
@@ -1047,2164 +605,1045 @@ class FightRequest
(new Chat())->sendMsg($cmsg);
}
- //тренеровочный бой
- public function addBotClone($uid)
- {
- if ($this->u->info['online'] > 0) {
- $bot = $this->u->addNewbot($id['id'], null, $uid, null, false);
- } else {
- $bot = false;
- }
- if (!$bot) {
- $this->error = 'Не получилось начать поединок';
- } elseif ($this->u->info['hpNow'] < $this->u->stats['hpAll'] / 100 * 30 && ($r >= 1 || $r <= 3)) {
- $this->error = 'Вы еще слишком ослаблены чтобы начать новый бой';
- $az = 0;
- } elseif ($this->u->info['align'] == 2) {
- $this->error = 'Хаосники не могут сражаться здесь';
- $az = 0;
- } elseif (!$bot) {
- echo 'Cannot start battle (no prototype "ND0Clone") ';
- } else {
- //создаем поединок с ботом
- $expB = 0;
- $btl = ['priz' => 0, 'smert' => 0, 'noart' => 0, 'noeff' => 0, 'noatack' => 0, 'arand' => 0, 'kingfight' => 0, 'nobot' => 0, 'fastfight' => 0, 'players' => '', 'timeout' => 60, 'type' => 0, 'invis' => 0, 'noinc' => 0, 'travmChance' => 0, 'typeBattle' => 0, 'addExp' => $expB, 'money' => 0, 'money3' => 0];
- $ins = mysql_query(
- 'INSERT INTO `battle` (`otmorozok`,`priz`,`smert`,`noart`,`noeff`,`noatack`,`arand`,`kingfight`,`nobot`,`fastfight`,`clone`,`city`,`time_start`,`players`,`timeout`,`type`,`invis`,`noinc`,`travmChance`,`typeBattle`,`addExp`,`money`) VALUES (
- "' . $btl['otmorozok'] . '",
- "' . $btl['priz'] . '",
- "' . $btl['smert'] . '",
- "' . $btl['noart'] . '",
- "' . $btl['noeff'] . '",
- "' . $btl['noatack'] . '",
- "' . $btl['arand'] . '",
- "' . $btl['kingfight'] . '",
- "' . $btl['nobot'] . '",
- "' . $btl['fastfight'] . '",
- "1",
- "' . $this->u->info['city'] . '",
- "' . time() . '",
- "' . $btl['players'] . '",
- "' . $btl['timeout'] . '",
- "564",
- "' . $btl['invis'] . '",
- "' . $btl['noinc'] . '",
- "' . $btl['travmChance'] . '",
- "' . $btl['typeBattle'] . '",
- "' . $btl['addExp'] . '",
- "' . $btl['money'] . '")'
- );
- if ($ins) {
- $btl_id = mysql_insert_id();
- //обновляем данные о поединке
- $this->u->info['enNow'] -= $trEn;
- $upd2 = mysql_query(
- 'UPDATE `users` SET `battle`="' . $btl_id . '" WHERE `id` = "' . $this->u->info['id'] . '" OR `id` = "' . $bot . '" LIMIT 2'
- );
- mysql_query(
- 'UPDATE `stats` SET `team`="1",`enNow` = "' . $this->u->info['enNow'] . '" WHERE `id` = "' . $this->u->info['id'] . '" LIMIT 1'
- );
- mysql_query('UPDATE `stats` SET `team`="2" WHERE `id` = "' . $bot . '" LIMIT 1');
-
- //обновляем заявку, что бой начался
- $this->u->info['battle'] = $btl_id;
- //Отправляем сообщение в чат всем бойцам
- $this->sendSysChatSound();
- die('');
- } else {
- $this->error = 'Cannot start battle (no prototype "ABD0Clone")';
- }
- }
- }
-
public function startBattle($id, $vars = null)
{
- $z = mysql_fetch_array(
- mysql_query(
- 'SELECT * FROM `zayvki` WHERE `id`="' . $id . '" AND `start` = "0" AND `cancel` = "0" AND (`time` > "' . (time(
- ) - 60 * 60 * 2) . '" OR `razdel` > 3) LIMIT 1'
- )
+ // что это?
+ $z = Db::getRow(
+ 'select * from zayvki where id = ? and start = 0 and cancel = 0 and (time > unix_timestamp() - 60*60*2 or razdel > 3)',
+ [$id]
);
- if ($z['type'] == 33) {
- sleep(5);
+ if (!isset($z['id'])) {
+ return;
}
- mysql_query('START TRANSACTION');
- mysql_query(
- "LOCK TABLES
- `aaa_monsters` WRITE,
- `actions` WRITE,
- `bank` WRITE,
-
- `battle` WRITE,
- `battle_act` WRITE,
- `battle_actions` WRITE,
- `battle_cache` WRITE,
- `battle_end` WRITE,
- `battle_last` WRITE,
- `battle_logs` WRITE,
- `battle_logs_save` WRITE,
- `battle_stat` WRITE,
- `battle_users` WRITE,
-
- `bs_actions` WRITE,
- `bs_items` WRITE,
- `bs_items_use` WRITE,
- `bs_logs` WRITE,
- `bs_map` WRITE,
- `bs_statistic` WRITE,
- `bs_trap` WRITE,
- `bs_turnirs` WRITE,
- `bs_zv` WRITE,
-
- `clan` WRITE,
- `clan_wars` WRITE,
-
- `dungeon_actions` WRITE,
- `dungeon_bots` WRITE,
- `dungeon_items` WRITE,
- `dungeon_map` WRITE,
- `dungeon_now` WRITE,
- `dungeon_zv` WRITE,
-
- `eff_main` WRITE,
- `eff_users` WRITE,
-
- `items_img` WRITE,
- `items_local` WRITE,
- `items_main` WRITE,
- `items_main_data` WRITE,
- `items_users` WRITE,
-
- `izlom` WRITE,
- `izlom_rating` WRITE,
-
- `laba_act` WRITE,
- `laba_itm` WRITE,
- `laba_map` WRITE,
- `laba_now` WRITE,
- `laba_obj` WRITE,
-
- `levels` WRITE,
- `levels_animal` WRITE,
-
- `online` WRITE,
-
- `priems` WRITE,
-
- `quests` WRITE,
- `reimage` WRITE,
-
- `reg` WRITE,
-
- `stats` WRITE,
- `test_bot` WRITE,
- `turnirs` WRITE,
- `users` WRITE,
- `users_animal` WRITE,
- `user_ico` WRITE,
- `users_twink` WRITE,
- `zayvki` WRITE;"
- );
- $z = mysql_fetch_array(
- mysql_query(
- 'SELECT * FROM `zayvki` WHERE `id`="' . $id . '" AND `start` = "0" AND `cancel` = "0" AND (`time` > "' . (time(
- ) - 60 * 60 * 2) . '" OR `razdel` > 3) LIMIT 1'
- )
- );
- if (isset($z['id'])) {
- $vars = explode('|-|', $vars);
- if ($z['razdel'] >= 4 && $z['razdel'] <= 5) {
- //начало группового или хаотичного боя
- $btl_id = 0;
- //$txtz = '';
- if ($z['razdel'] == 5) {
- $sp = mysql_query(
- 'SELECT `s`.`id`,`s`.`team`,`s`.`upLevel`,`s`.`btl_cof`,`s`.`exp` FROM `stats` AS `s` LEFT JOIN `users` AS `u` ON `u`.`id` = `s`.`id` WHERE `s`.`zv` = "' . $z['id'] . '" ORDER BY `s`.`btl_cof` DESC LIMIT 200'
- );
- $tsr = rand(0, 100);
- if ($tsr >= 70 && $z['type'] != 33) {
- $ii = -1;
- while ($pl = mysql_fetch_array($sp)) {
- $ii++;
- $pld[$ii] = $pl;
- }
- $yy = $ii;
- $jj = $ii;//счетчик c конца
- $ii = 0;
- $teamA = 0;
- $teamAbtlconf = 0;
- $teamB = 0;
- $teamBbtlconf = 0;
- while ($yy > -1) {
- if ($ii == 0 || $teamAbtlconf <= $teamBbtlconf) {
- if (isset ($pld[$ii])) {
- $teamnew = 1;
- $teamAbtlconf = $teamAbtlconf + $pld[$ii]['btl_cof'];
- $teamA++;
- $idi = $ii;
- mysql_query(
- 'UPDATE `stats` SET `team` = "' . $teamnew . '" WHERE `id` = "' . $pld[$idi]['id'] . '" LIMIT 1'
- );
- }
- $ii++;
- } elseif (($teamB - $teamA) <= 0) {
- if (isset ($pld[$ii])) {
- $teamnew = 2;
- $teamBbtlconf = $teamBbtlconf + $pld[$ii]['btl_cof'];
- $teamB++;
- $idi = $ii;
- mysql_query(
- 'UPDATE `stats` SET `team` = "' . $teamnew . '" WHERE `id` = "' . $pld[$idi]['id'] . '" LIMIT 1'
- );
- }
- $ii++;
- } else {
- if (isset ($pld[$ii])) {
- $teamnew = 1;
- $teamAbtlconf = $teamAbtlconf + $pld[$jj]['btl_cof'];
- $teamA++;
- $idi = $jj;
- mysql_query(
- 'UPDATE `stats` SET `team` = "' . $teamnew . '" WHERE `id` = "' . $pld[$idi]['id'] . '" LIMIT 1'
- );
- }
- $jj--;
- }
- $yy--;
- }
- } else {
- $balansteamA = 0;
- $balansteamB = 0;
- while ($pl = mysql_fetch_array($sp)) {
- $teamnew = rand(1, 2);
- if ($balansteamA != $balansteamB) {
- if ($balansteamA > $balansteamB) {
- $teamnew = 2;
- } else {
- $teamnew = 1;
- }
- }
- mysql_query(
- 'UPDATE `stats` SET `team` = "' . $teamnew . '" WHERE `id` = "' . $pl['id'] . '" LIMIT 1'
- );
- if ($teamnew == 1) {
- $balansteamA += 1;
- } else {
- $balansteamB += 1;
- }
- }
- }
- unset($sp, $pl);
- }
- $btl = [
- 'otmorozok' => $z['otmorozok'],
- 'priz' => $z['priz'], 'smert' => $z['smert'], 'noart' => $z['noart'], 'noeff' => $z['noeff'], 'noatack' => $z['noatack'], 'arand' => $z['arand'], 'kingfight' => $z['kingfight'],
- 'players' => '', 'timeout' => $z['timeout'], 'type' => $z['type'], 'travmChance' => $z['travmChance'], 'invis' => $z['invise'], 'noinc' => 0, 'typeBattle' => 0, 'addExp' => $z['exp'], 'money' => 0, 'money3' => 0];
- //ТУТ старт боя
- $ins = mysql_query(
- 'INSERT INTO `battle` (`otmorozok`,`priz`,`smert`,`noart`,`noeff`,`noatack`,`arand`,`kingfight`,`nobot`,`fastfight`,`razdel`,`city`,`time_start`,`players`,`timeout`,`type`,`invis`,`noinc`,`travmChance`,`typeBattle`,`addExp`,`money`) VALUES (
- "' . $z['otmorozok'] . '",
- "' . $z['priz'] . '",
- "' . $z['smert'] . '",
- "' . $z['noart'] . '",
- "' . $z['noeff'] . '",
- "' . $z['noatack'] . '",
- "' . $z['arand'] . '",
- "' . $z['kingfight'] . '",
- "' . $z['nobot'] . '",
- "' . $z['fastfight'] . '",
- "' . $z['razdel'] . '",
- "' . $z['city'] . '",
- "' . time() . '",
- "' . mysql_real_escape_string($btl['players']) . '",
- "' . mysql_real_escape_string($btl['timeout']) . '",
- "' . mysql_real_escape_string($btl['type']) . '",
- "' . mysql_real_escape_string($btl['invis']) . '",
- "' . mysql_real_escape_string($btl['noinc']) . '",
- "' . mysql_real_escape_string($z['travmChance']) . '",
- "' . mysql_real_escape_string($btl['typeBattle']) . '",
- "' . mysql_real_escape_string($btl['addExp']) . '",
- "' . mysql_real_escape_string($btl['money']) . '")'
+
+ $vars = explode('|-|', $vars);
+ if ($z['razdel'] == self::BATTLE_RAZDEL_GROUP || $z['razdel'] == self::BATTLE_RAZDEL_CHAOTIC) {
+ if ($z['razdel'] == self::BATTLE_RAZDEL_CHAOTIC) {
+ $sp = Db::getRows(
+ 'select id, team, upLevel, btl_cof, exp from stats where zv = ? order by btl_cof desc', [$z['id']]
);
- $btl_id = mysql_insert_id();
- if ($btl_id > 0) {
- //Если бой кулачный, то снимаем вещи
- if ($z['type'] == 1) {
- $sp = mysql_query('SELECT `id` FROM `stats` WHERE `zv` = "' . $z['id'] . '"');
- while ($pl = mysql_fetch_array($sp)) {
- mysql_query(
- 'UPDATE `items_users` SET `inOdet`="0" WHERE `uid` = "' . $pl['id'] . '" AND `inOdet`!=0'
- );
- }
- } elseif ($z['type'] == 51) { //Поединок без ЕКР вещей
- $sp = mysql_query('SELECT `id` FROM `stats` WHERE `zv` = "' . $z['id'] . '"');
- while ($pl = mysql_fetch_array($sp)) {
- mysql_query(
- 'UPDATE `items_users` SET `inOdet`="0" WHERE `uid` = "' . $pl['id'] . '" AND `2price` > 0'
- );
- }
- }
+ // Разбивка на команды раньше зависела от равной суммы btl_cof в командах, но как это должно было
+ // работать никто не знал. Теперь просто пул игроков мешается и бьётся пополам. Ins.
- //обновляем данные о поединке
- $upd1 = mysql_query('UPDATE `stats` SET `zv`="0" WHERE `zv` = "' . $z['id'] . '"');
- $upd2 = mysql_query('UPDATE `users` SET `battle`="' . $btl_id . '" WHERE ' . $vars[1] . '');
-
- //обновляем заявку, что бой начался
- $upd = mysql_query(
- 'UPDATE `zayvki` SET `start` = "' . time(
- ) . '",`btl_id` = "' . $btl_id . '" WHERE `id` = "' . $z['id'] . '" LIMIT 1'
- );
- $this->u->info['battle'] = $btl_id;
- //Отправляем сообщение в чат всем бойцам
- $this->sendSysChatSound($vars[0], -1);
+ $pld2 = [];
+ $team1IdsArr = [];
+ $team2IdsArr = [];
+ foreach ($sp as $pl) {
+ $pld2[] = $pl;
}
- } elseif ($z['razdel'] >= 1 && $z['razdel'] <= 3) {
- //начало PvP
- if ($this->u->info['team'] == 1 && $this->u->info['zv'] == $z['id']) {
- $zu = mysql_fetch_array(
- mysql_query('SELECT * FROM `stats` WHERE `zv`="' . $z['id'] . '" AND `team` = "2" LIMIT 1')
+ shuffle($pld2);
+ $pieces = array_chunk($pld2, ceil(count($pld2) / 2));
+ foreach ($pieces[0] as $team1) {
+ $team1IdsArr[] = $team1['id'];
+ }
+ foreach ($pieces[1] as $team2) {
+ $team2IdsArr[] = $team2['id'];
+ }
+ $team1Ids = implode($team1IdsArr);
+ $team2Ids = implode($team2IdsArr);
+ Db::sql('update stats set team = 1 where id in (?)', [$team1Ids]);
+ Db::sql('update stats set team = 2 where id in (?)', [$team2Ids]);
+ }
+ $args = [
+ $z['otmorozok'],
+ $z['priz'],
+ $z['smert'],
+ $z['noart'],
+ $z['noeff'],
+ $z['noatack'],
+ $z['arand'],
+ $z['kingfight'],
+ $z['nobot'],
+ $z['fastfight'],
+ $z['razdel'],
+ $z['city'],
+ $z['timeout'],
+ $z['type'],
+ $z['invise'],
+ $z['travmChance'],
+ $z['exp'],
+ ];
+ $q = 'insert into battle (
+ otmorozok,
+ priz,
+ smert,
+ noart,
+ noeff,
+ noatack,
+ arand,
+ kingfight,
+ nobot,
+ fastfight,
+ razdel,
+ city,
+ time_start,
+ timeout,
+ type,
+ invis,
+ travmChance,
+ addExp
+ ) values (?,?,?,?,?,?,?,?,?,?,?,?,unix_timestamp(),?,?,?,?,?)';
+ //ТУТ старт боя
+ Db::sql($q, $args);
+ unset($q, $args);
+ $btl_id = Db::lastInsertId();
+ if ($btl_id) {
+ if ($z['type'] == self::BATTLE_TYPE_MELEE) {
+ Db::sql(
+ 'update items_users set inOdet = 0 where uid in (select id from stats where zv = ?)', [$z['id']]
);
- if (isset($zu['id'])) {
- $uz = mysql_fetch_array(
- mysql_query('SELECT `login`,`money` FROM `users` WHERE `id`="' . $zu['id'] . '" LIMIT 1')
- );
- if ($zu['clone'] > 0) {
- //обновляем клона
- $bot = $this->u->addNewbot(1, null, $zu['clone'], null, true);
- if ($bot > 0) {
- mysql_query('DELETE FROM `users` WHERE `id` = "' . $zu['id'] . '" LIMIT 1');
- mysql_query('DELETE FROM `stats` WHERE `id` = "' . $zu['id'] . '" LIMIT 1');
- mysql_query('DELETE FROM `items_users` WHERE `uid` = "' . $zu['id'] . '" LIMIT 100');
- mysql_query('DELETE FROM `eff_users` WHERE `uid` = "' . $zu['id'] . '" LIMIT 100');
+ } elseif ($z['type'] == self::BATTLE_TYPE_NO_EKR_ITEMS) {
+ Db::sql(
+ 'update items_users set inOdet = 0 where uid in (select id from stats where zv = ?) and 2price > 0',
+ [$z['id']]
+ );
+ }
+ //обновляем данные о поединке
+ Db::sql('update stats set zv = 0 where zv = ?', [$z['id']]);
+ $q = 'update users set battle = ' . $btl_id . ' where ' . $vars[1];
+ Db::sql($q);
+ unset($q);
- mysql_query(
- 'UPDATE `stats` SET `zv` = "' . $z['id'] . '",`team` = 2 WHERE `id` = "' . $bot . '" LIMIT 1'
- );
-
- $zu = mysql_fetch_array(
- mysql_query(
- 'SELECT * FROM `stats` WHERE `zv`="' . $z['id'] . '" AND `team` = "2" LIMIT 1'
- )
- );
- $uz = mysql_fetch_array(
- mysql_query(
- 'SELECT `login`,`money` FROM `users` WHERE `id`="' . $zu['id'] . '" LIMIT 1'
- )
- );
- }
- }
-
- //создаем поединок
- $btl_id = 0;
- if ($uz['money'] < $z['money'] || $this->u->info['money'] < $z['money']) {
- $z['money'] = 0;
- }
- $btl = ['otmorozok' => $z['otmorozok'], 'players' => '', 'timeout' => $z['timeout'], 'type' => $z['type'], 'travmChance' => $z['travmChance'], 'invis' => 0, 'noinc' => 0, 'typeBattle' => 0, 'addExp' => 0, 'money' => round(
- $z['money'], 2
- ), 'money3' => 0];
- $ins = mysql_query(
- 'INSERT INTO `battle` (`otmorozok`,`smert`,`noart`,`noeff`,`noatack`,`arand`,`kingfight`,`nobot`,`fastfight`,`city`,`time_start`,`players`,`timeout`,`type`,`invis`,`noinc`,`travmChance`,`typeBattle`,`addExp`,`money`) VALUES (
- "' . mysql_real_escape_string($btl['otmorozok']) . '",
- "' . mysql_real_escape_string($btl['smert']) . '",
- "' . mysql_real_escape_string($btl['noart']) . '",
- "' . mysql_real_escape_string($btl['noeff']) . '",
- "' . mysql_real_escape_string($btl['noatack']) . '",
- "' . mysql_real_escape_string($btl['arand']) . '",
- "' . mysql_real_escape_string($btl['kingfight']) . '",
- "' . mysql_real_escape_string($btl['nobot']) . '",
- "' . mysql_real_escape_string($btl['fastfight']) . '",
- "' . $this->u->info['city'] . '",
- "' . time() . '",
- "' . mysql_real_escape_string($btl['players']) . '",
- "' . mysql_real_escape_string($btl['timeout']) . '",
- "' . mysql_real_escape_string($btl['type']) . '",
- "' . mysql_real_escape_string($btl['invis']) . '",
- "' . mysql_real_escape_string($btl['noinc']) . '",
- "' . mysql_real_escape_string($btl['travmChance']) . '",
- "' . mysql_real_escape_string($btl['typeBattle']) . '",
- "' . mysql_real_escape_string($btl['addExp']) . '",
- "' . mysql_real_escape_string($btl['money']) . '")'
- );
- $btl_id = mysql_insert_id();
- if ($ins) {
- //обновляем данные о поединке
- $upd1 = mysql_query('UPDATE `stats` SET `zv`="0" WHERE `zv` = "' . $z['id'] . '" LIMIT 2');
- $upd2 = mysql_query(
- 'UPDATE `users` SET `battle`="' . $btl_id . '" WHERE `id` = "' . $this->u->info['id'] . '" OR `id` = "' . $zu['id'] . '" LIMIT 2'
- );
-
- //Если бой кулачный, то снимаем вещи
- if ($z['type'] == 1) {
- mysql_query(
- 'UPDATE `items_users` SET `inOdet`="0" WHERE `uid` = "' . $this->u->info['id'] . '" AND `inOdet`!=0'
- );
- mysql_query(
- 'UPDATE `items_users` SET `inOdet`="0" WHERE `uid` = "' . $zu['id'] . '" AND `inOdet`!=0'
- );
- }
-
- //обновляем заявку, что бой начался
- $upd = mysql_query(
- 'UPDATE `zayvki` SET `start` = "' . time(
- ) . '",`btl_id` = "' . $btl_id . '" WHERE `id` = "' . $z['id'] . '" LIMIT 1'
- );
-
- $this->u->info['battle'] = $btl_id;
-
- //Отправляем сообщение в чат всем бойцам
- $this->sendSysChatSound($uz['login']);
- die('');
- } else {
- $this->error = 'Ошибка создания битвы.';
- }
- } else {
- $this->error = 'Вы не можете начать поединок, вашу заявку никто не принял.';
- }
+ //обновляем заявку, что бой начался
+ Db::sql('update zayvki set start = unix_timestamp(), btl_id = ? where id = ?', [$btl_id, $z['id']]);
+ $this->u->info['battle'] = $btl_id;
+ //Отправляем сообщение в чат всем бойцам
+ $this->sendSysChatSound($vars[0], -1);
+ }
+ } elseif ($z['razdel'] >= 1 && $z['razdel'] <= 3) {
+ //начало PvP
+ if ($this->u->info['team'] != 1 || $this->u->info['zv'] != $z['id']) {
+ $this->error = 'Вы не можете начать поединок.';
+ } else {
+ $enemyId = Db::getValue('select id from stats where zv = ? and team = 2 limit 1', [$z['id']]);
+ if (!$enemyId) {
+ $this->error = 'Вы не можете начать поединок, вашу заявку никто не принял.';
} else {
- $this->error = 'Вы не можете начать поединок.';
+ $enemy = Db::getRow('select login, money from users where id = ?', [$enemyId]);
+ //создаем поединок
+ if (
+ $enemy['money'] < $z['money'] ||
+ $this->u->info['money'] < $z['money']
+ ) {
+ $z['money'] = 0.00;
+ }
+
+ $args = [
+ $z['otmorozok'],
+ $z['smert'],
+ $z['noart'],
+ $z['noeff'],
+ $z['noatack'],
+ $z['arand'],
+ $z['kingfight'],
+ $z['nobot'],
+ $z['fastfight'],
+ $this->u->info['city'],
+ $z['timeout'],
+ $z['type'],
+ $z['travmChance'],
+ $z['money'],
+ ];
+ $q = 'insert into battle (
+ otmorozok,
+ smert,
+ noart,
+ noeff,
+ noatack,
+ arand,
+ kingfight,
+ nobot,
+ fastfight,
+ city,
+ time_start,
+ timeout,
+ type,
+ travmChance,
+ money
+ ) values (?,?,?,?,?,?,?,?,?,?,unix_timestamp(),?,?,?,?)';
+ Db::sql($q, $args);
+ $btl_id = Db::lastInsertId();
+ unset($q, $args);
+ if (!$btl_id) {
+ $this->error = 'Ошибка создания битвы.';
+ } else {
+ //обновляем данные о поединке
+ Db::sql('update stats set zv = 0 where zv = ?', [$z['id']]);
+ Db::sql(
+ 'update users set battle = ? where id = ? or id = ?',
+ [$btl_id, $this->u->info['id'], $enemyId]
+ );
+
+ //Если бой кулачный, то снимаем вещи
+ if ($z['type'] == self::BATTLE_TYPE_MELEE) {
+ Db::sql(
+ 'update items_users set inOdet = 0 where uid in (?,?) ',
+ [$this->u->info['id'], $enemyId]
+ );
+ }
+
+ //обновляем заявку, что бой начался
+ Db::sql(
+ 'update zayvki set start = unix_timestamp(), btl_id = ? where id = ?', [$btl_id, $z['id']]
+ );
+ $this->u->info['battle'] = $btl_id;
+
+ //Отправляем сообщение в чат всем бойцам
+ $this->sendSysChatSound($enemy['login']);
+ die('');
+ }
}
}
}
- mysql_query('UNLOCK TABLES');
- mysql_query('COMMIT');
}
- public function cancelzv()
+ public function getCurrentStatus(array $zi, int $r)
{
- global $zi;
- if (isset($_GET['cancelzv'], $zi['id']) && $zi['razdel'] >= 1 && $zi['razdel'] <= 3) {
- $enemy = mysql_fetch_array(
- mysql_query(
- 'SELECT `u`.*,`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 (
+ !$this->u->info['zv'] || $this->u->info['battle'] > 0 ||
+ !in_array($r, [self::BATTLE_RAZDEL_GROUP, self::BATTLE_RAZDEL_CHAOTIC, self::BATTLE_RAZDEL_TOURNAMENTS])
+ ) {
+ return;
+ }
+ $battleType = [
+ self::BATTLE_RAZDEL_GROUP => 'группового',
+ self::BATTLE_RAZDEL_CHAOTIC => 'хаотичного',
+ ];
+ $tm_start = floor(($zi['time'] + $zi['time_start'] - time()) / 6) / 10;
+ $tm_start = $this->rzv($tm_start);
+ echo 'Ожидаем начала ' . $battleType[$zi['razdel']] . ' боя ';
+ echo ' Ваш бой начнется через ' . $tm_start . ' мин.';
+ }
+
+ public function getEndedBattlesList(string $slogin, int $dt)
+ {
+ $code = PassGen::intCode();
+ $btl = '';
+ $see = '';
+ $usr = Db::getRow('select id, login, level, city from users where login = ? limit 1', [$slogin]);
+
+ if (isset($usr['id'])) {
+ $tms = $dt;
+ $tmf = $dt + 86400;
+ $sp = Db::getRows(
+ 'select * from battle_last where time >= ? and time < ? and uid = ? order by id desc ',
+ [$tms, $tmf, $usr['id']]
);
- if (isset($enemy['id'])) {
- $chat = new Chat();
- $cmsg = new ChatMessage();
- $cmsg->setType(6);
- if ($this->u->info['team'] == 1) {
- //выкидываем из заявки + пишем сообщение в чат
- $upd = mysql_query(
- 'UPDATE `stats` SET `zv` = "0",`team`="0" WHERE `id` = "' . $enemy['id'] . '" LIMIT 1'
- );
- if ($upd) {
- mysql_query('UPDATE `users` SET `otk` = (`otk` + 1) WHERE `id` = "' . $zi['id'] . '" LIMIT 1');
- $this->error = 'Вы отказали ' . $enemy['login'] . ' в поединке';
- //отправляем сообщение в чат
- $sa = '';
- if ($this->u->info['sex'] == 2) {
- $sa = 'а';
+ $jk = 0;
+ $btl_lst = [];
+ foreach ($sp as $pl) {
+ $b = Db::getRow('select * from battle_end where battle_id = ? limit 1', [$pl['battle_id']]);
+ $tm = '';
+ if (isset($b['id'])) {
+ $tms = [];
+ $ts = [];
+ $spi = Db::getRows('select * from battle_last where battle_id = ?', [$pl['battle_id']]);
+ foreach ($spi as $pli) {
+ if (!isset($tms[$pli['team']])) {
+ $ts[] = $pli['team'];
}
-
- $cmsg->setText(' [login:' . $this->u->info['login'] . '] отказал' . $sa . ' вам в поединке.');
- $cmsg->setCity($enemy['city']);
- $cmsg->setTo($enemy['login']);
- $chat->sendMsg($cmsg);
+ $tms[$pli['team']][count($tms[$pli['team']])] = $pli;
}
- } elseif ($this->u->info['id'] == $enemy['id'] && $zi['start'] == 0) {
- //выкидываем из заявки + пишем сообщение в чат
- $upd = mysql_query(
- 'UPDATE `stats` SET `zv` = "0",`team`="0" WHERE `id` = "' . $enemy['id'] . '" LIMIT 1'
- );
- if ($upd) {
- $uz = mysql_fetch_array(
- mysql_query(
- 'SELECT `u`.`sex`,`u`.`login`,`u`.`city`,`u`.`room`,`u`.`id`,`st`.`zv`,`st`.`team` 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'])) {
- $this->error = 'Вы отозвали свой запрос на бой.';
- //отправляем сообщение в чат
- $sa = '';
- if ($this->u->info['sex'] == 2) {
- $sa = 'а';
- }
-
- $cmsg->setText(
- ' [login:' . $this->u->info['login'] . '] отозвал' . $sa . ' свой запрос на бой.'
- );
- $cmsg->setCity($uz['city']);
- $cmsg->setTo($uz['login']);
- $chat->sendMsg($cmsg);
- }
- $this->u->info['zv'] = 0;
- $this->u->info['team'] = 0;
- }
- }
- if ($enemy['bot'] == 1) {
- //удаляем бота , предметы и эффекты
- mysql_query('DELETE FROM `users` WHERE `id` = "' . $enemy['id'] . '" LIMIT 1');
- mysql_query('DELETE FROM `stats` WHERE `id` = "' . $enemy['id'] . '" LIMIT 1');
- mysql_query('DELETE FROM `items_users` WHERE `uid` = "' . $enemy['id'] . '" LIMIT 100');
- mysql_query('DELETE FROM `eff_users` WHERE `uid` = "' . $enemy['id'] . '" LIMIT 100');
- }
- } else {
- if ($this->u->info['team'] == 1) {
- //удаляем заявку на бой
- $upd = mysql_query(
- 'UPDATE `zayvki` SET `cancel` = "' . time() . '" WHERE `id` = "' . $zi['id'] . '" LIMIT 1'
- );
- if ($upd) {
- mysql_query(
- 'UPDATE `stats` SET `zv` = "0" WHERE `id` = "' . $this->u->info['id'] . '" LIMIT 1'
- );
- $this->error = 'Вы отозвали свою заявку';
- $zi = false;
- $this->u->info['zv'] = 0;
- }
- }
- }
- }
- }
-
- public function see()
- {
- global $c, $code, $zi;
- if (isset($_GET['r']) && ((!isset($_GET['new_group']) && !isset($_POST['groupClick'])) || isset($zi['id']))) {
- $r = round(intval($_GET['r']));
- if (in_array($r, [1, 4, 5, 8, 10])) {
- $this->zv_see = 1;
- if ($this->u->room['FR'] == 0 && $this->u->room['zvsee'] == 0) {
- echo 'Подать заявку можно только в комнатах бойцовского клуба ';
- $this->zv_see = 0;
- } elseif ($r == 1 && $this->u->info['level'] > 0) {
- echo 'Вы уже выросли из ползунков ;) ';
- $this->zv_see = 0;
- } elseif ($r > 1 && $r < 6 && $this->u->info['level'] < 1) {
- echo 'Вы еще не выросли из ползунков ;) ';
- $this->zv_see = 0;
- } elseif ($r > 3 && $r < 6 && $this->u->info['level'] < 2) {
- echo 'В ' . $this->z1n[$r] . ' бои только со второго уровня. ';
- $this->zv_see = 0;
- } elseif ($r == 8 && $this->u->info['level'] < 1) {
- echo 'Принимать участие в турнире только с первого уровня. ';
- $this->zv_see = 0;
- } elseif ($r == 10) {
- if (\Insallah\Tournament::IS_ENABLED) {
- /** Турниры by Insallah*/
- # Защита от F5
- if (!isset($_SESSION['bypass'])) {
- $_SESSION['bypass'] = mt_rand();
- }
- if ($_SERVER['REQUEST_METHOD'] === 'POST' && $_POST['key'] == $_SESSION['bypass']) {
- unset($_SESSION['bypass']);
- if (array_key_exists('tournament_start', $_POST)) {
- (new \Insallah\Tournament())->join($this->u->info['id']);
- }
- }
- ##
- # Формируем список идущих турниров.
- $tournamentsList = Db::getRows('select * from tournaments');
- $tournaments = '';
- foreach ($tournamentsList as $tournament) {
- $time = $tournament['start_time'] === -1 ? 'Турнир уже начался!' : date(
- 'G:i', $tournament['start_time']
- );
- $tournament_members_id = \Insallah\TournamentModel::getFreeFighters($tournament['tid']);
- $members = [];
- foreach ($tournament_members_id as $member) {
- $members[] = \Insallah\TournamentModel::uidToLogin($member);
- }
- $tournaments .= sprintf(
- "Турнир для %d уровней. Время подачи заявки: %s Участники: %s ",
- $tournament['tid'], $time, implode(', ', $members)
- );
- }
- $tournaments .= ' ';
- ?>
-
-
Внимание!
-
- В случае создания либо присоединения к Турниру, покинуть его -
- невозможно !
-
- u->info['id'])): ?>
- Стоимость предметов, одетых на вас не должна
- превышать = \Insallah\Tournament::ekrOverpriceFormula(
- $this->u->info['level']
- ) ?> еврокредитов.
-
-
- u->info['exp'] < \Insallah\Tournament::MIN_EXP): ?>
- У вас должно быть не менее = \Insallah\Tournament::MIN_EXP ?> опыта.
-
- Турнир начнётся, когда в заявке
- наберётся = \Insallah\Tournament::START_TOURNAMENT ?> человек.
-
- Игроки занявшие 1, 2 и 3 места получат 25, 15, 5 Реликвий
- Ангела, а так же задержки на участие в турнире 12 часов, 6 и 3 часа соответственно!
-
-
-
-
-
- Активные турниры.
- = $tournaments ?>
-
-
- u->info['id']
- ) || !\Insallah\TournamentModel::isStarted($this->u->info['level'])): ?>
-
-
- Вы учавствуете.
-
-
-
- В данный момент турниры не проводятся!
-
- u->info['zv'] > 0 && $this->u->info['battle'] == 0 && $r != 8) {
- if ($zi['razdel'] == 1 || $zi['razdel'] == 2 || $zi['razdel'] == 3) {
- echo '
-
-
- ';
-
- 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 '
';
- } else {
- $tm_start = floor(($zi['time'] + $zi['time_start'] - time()) / 6) / 10;
- $tm_start = $this->rzv($tm_start);
- echo 'Ожидаем начала ' . $this->z2n[$zi['razdel']] . ' боя ';
- echo ' Ваш бой начнется через ' . $tm_start . ' мин.';
- }
- } elseif ($r == 8) {
- //Турниры
-
- $ttur = [
- 0 => 'Выжить любой ценой!',
- 1 => 'Каждый сам за себя!',
- 2 => 'Захват ключа!',
- ];
-
- if (isset($_POST['trn1']) && $this->u->room['zvsee'] == 0) {
- if ($this->u->info['inTurnirnew'] == 0) {
- $totr = mysql_fetch_array(
- mysql_query(
- 'SELECT * FROM `turnirs` WHERE `id` = "' . mysql_real_escape_string(
- $_POST['trn1']
- ) . '" AND `status` = "0" LIMIT 1'
- )
- );
- if (isset($totr['id'])) {
- mysql_query(
- 'UPDATE `users` SET `inTurnirnew` = "' . $totr['id'] . '" WHERE `id` = "' . $this->u->info['id'] . '" LIMIT 1'
- );
- mysql_query(
- 'UPDATE `turnirs` SET `users_in` = `users_in` + 1 WHERE `id` = "' . $totr['id'] . '" LIMIT 1'
- );
- $this->u->info['inTurnirnew'] = $totr['id'];
- $this->error = 'Вы записались на участие в турнире.';
- } else {
- $this->error = 'Заявка на турнир не найдена.';
- }
- } else {
- $this->error = 'Вы уже находитесь в заявке на турнир.';
- }
- } elseif (isset($_GET['cancel13']) && $this->u->room['zvsee'] == 0) {
- if ($this->u->info['inTurnirnew'] > 0) {
- $totr = mysql_fetch_array(
- mysql_query(
- 'SELECT * FROM `turnirs` WHERE `id` = "' . mysql_real_escape_string(
- $this->u->info['inTurnirnew']
- ) . '" AND `status` = "0" LIMIT 1'
- )
- );
- if (isset($totr['id'])) {
- mysql_query(
- 'UPDATE `users` SET `inTurnirnew` = "0" WHERE `id` = "' . $this->u->info['id'] . '" LIMIT 1'
- );
- mysql_query('UPDATE `turnirs` SET `users_in` = `users_in` - 1 LIMIT 1');
- $this->u->info['inTurnirnew'] = 0;
- $this->error = 'Вы отказались от заявки на турнир.';
- } else {
- $this->error = 'Нельзя отказаться от заявки находясь в турнире.';
- }
- } else {
- $this->error = 'Вы не принимаете участия ни в одном из турниров.';
- }
- }
-
- $dv = '';
- $trse = '';
-
- if ($this->u->info['inTurnirnew'] > 0) {
- $pl = mysql_fetch_array(
- mysql_query(
- 'SELECT * FROM `turnirs` WHERE `id` = "' . $this->u->info['inTurnirnew'] . '" LIMIT 1'
- )
- );
- if (!isset($pl['id'])) {
- mysql_query(
- 'UPDATE `users` SET `inTurnirnew` = "0" WHERE `id` = "' . $pl['id'] . '" LIMIT 1'
- );
- echo 'Что-то не так... Обновите страницу.';
- } else {
- $dv = 'Участники турнира [' . $pl['users_in'] . '] : ';
- $spu = mysql_query(
- 'SELECT `u`.`id`,`u`.`align`,`u`.`login`,`u`.`clan`,`u`.`level`,`u`.`city`,`u`.`online`,`u`.`sex`,`u`.`cityreg`,`u`.`palpro`,`u`.`invis` FROM `users` AS `u` WHERE `u`.`inTurnirnew` = "' . $pl['id'] . '" LIMIT ' . $pl['users_in']
- );
- $i = 1;
- while ($plu = mysql_fetch_array($spu)) {
- $dv .= '' . $i . '. ' . $this->u->microLogin(
- $plu, 2
- ) . '
';
- $i++;
- }
- echo '
-
- ';
- }
- } else {
- $tlvl = 4;
- $i = 4;
- $trnmz = [4 => 'Физический', 5 => 'Магический', 6 => 'Физ.\Маг.'];
- while ($i <= 6) {
- if ($_GET['tlvl'] == $i) {
- $trse .= '' . $trnmz[$i] . ' ';
- $tlvl = $i;
- } else {
- $trse .= '' . $trnmz[$i] . ' ';
- }
- $i++;
- }
- $prb = ' ';
- echo '';
- $sp = mysql_query('SELECT * FROM `turnirs` WHERE `status` = "0" AND `level` = "' . $tlvl . '"');
- $j = 0;
- while ($pl = mysql_fetch_array($sp)) {
- $j++;
- $dinf = 'Начало через ' . $this->u->timeOut($pl['time'] - time()) . '';
- $dv .= '';
- if ($this->u->room['zvsee'] == 0) {
- $dv .= ' ';
- }
- $dv .= ' Физический турнир. Участников турнира: ' . $pl['users_in'] . ' чел. | ' . $dinf . '
';
- }
- if ($dv == '') {
- $dv = 'Список турниров для данного типа пуст...';
- }
- echo '
-
- ';
- }
- } elseif ($r == 1) {
- //новички, физические и договорные удаляются. Инс. 29.05.22
- $zi = [
- 1 => 'Если вы не достигли первого уровня, то для вас это единственный способ для проведения битв.',
- ];
- $dv = '';
- if ($this->u->room['zvsee'] == 0) {
- if ($this->u->info['level'] <= $c['bot_level'] || $this->u->info['admin'] > 0) {
- $dv = 'Тренировочные бои доступны до ' . ($c['bot_level'] + 1) . '-го уровня. ';
- } else {
- if ($this->u->info['level'] < 9) {
- $tstw = ' для 8 левелов недоступны';
- } else {
- $tstw = '';
- }
- $dv .= '
-
-
- Комментарий к бою ' . $tstw . '
-
-
-
-
';
- }
- if ($this->u->info['admin'] > 0) {
- if (isset($_GET['adminbotatack'])) {
- $bot_atack = mysql_fetch_array(
- mysql_query(
- 'SELECT * FROM `test_bot` WHERE `id` = "' . mysql_real_escape_string(
- $_GET['adminbotatack']
- ) . '" LIMIT 1'
- )
- );
- if (isset($bot_atack['id'])) {
- $logins_bot = [];
- $k = $this->u->addNewbot($bot_atack['id'], null, null, $logins_bot);
- if (isset($k['id'])) {
- $expB = 0;
- $btl = [
- 'players' => '',
- 'timeout' => 180,
- 'type' => 0,
- 'invis' => 0,
- 'noinc' => 0,
- 'travmChance' => 0,
- 'typeBattle' => 0,
- 'addExp' => $expB,
- 'money' => 0,
- ];
-
- $ins = mysql_query(
- 'INSERT INTO `battle` (`dungeon`,`dn_id`,`x`,`y`,`city`,`time_start`,`players`,`timeout`,`type`,`invis`,`noinc`,`travmChance`,`typeBattle`,`addExp`,`money`) VALUES (
- "0",
- "0",
- "0",
- "0",
- "' . $this->u->info['city'] . '",
- "' . time() . '",
- "' . $btl['players'] . '",
- "' . $btl['timeout'] . '",
- "' . $btl['type'] . '",
- "' . $btl['invis'] . '",
- "' . $btl['noinc'] . '",
- "' . $btl['travmChance'] . '",
- "' . $btl['typeBattle'] . '",
- "' . $btl['addExp'] . '",
- "' . $btl['money'] . '")'
- );
- $btl_id = mysql_insert_id();
- mysql_query(
- 'UPDATE `users` SET `battle` = "' . $btl_id . '" WHERE `id` = "' . $k['id'] . '" OR `id` = "' . $this->u->info['id'] . '" LIMIT 2'
- );
- mysql_query(
- 'UPDATE `stats` SET `team` = "2" WHERE `id` = "' . $k['id'] . '" LIMIT 1'
- );
- mysql_query(
- 'UPDATE `stats` SET `team` = "1" WHERE `id` = "' . $this->u->info['id'] . '" LIMIT 1'
- );
- die('');
- }
- }
- }
-
- $dv .= '';
- }
-
- echo '
- ';
- }
- } elseif ($r == 4) {
- if ($this->u->room['zvsee'] == 0) { //групповые ?>
-
-
- Подать заявку на групповой бой
-
-
- u->room['zvsee'] == 0) {
- echo '
- ';
- }
- }
- } elseif ($r == 6) {
- ?>
- Записи текущих боев на = date('d.m.Y'); ?>
- 0 order by time_start) order by battle desc';
- $currentBattles = Db::getRows($query);
-
- if (empty($currentBattles)) {
- echo 'К сожалению сейчас боев нет...
';
- } else {
- // Надеялся на вывод вида:
- // [battle -> [team -> [uid, uid, uid], team -> [uid, uid, uid],]],
- // [battle -> [team -> [uid, uid, uid], team -> [uid, uid, uid],]],
- // но глубоко наломался, где-то перемудрил с ArraySorter::groupBy()
- // и на выходе там сортировка, но с сохранением всех вложенностей,
- // что усложнило последющий вывод. Но вышло как вышло. Ins.
- $currentBattlesArray = ArraySorter::groupBy($currentBattles, 'battle');
- echo '';
- foreach ($currentBattlesArray as $battleId => $cb) {
- $players = '';
- $typeBattle = 0;
- $timeStart = 0;
- $teams = ArraySorter::groupBy($cb, 'team');
- foreach ($teams as $teamId => $team) {
- foreach ($team as $key => $player) {
- $players .= $this->u->microLogin($player['id']);
- if ($key !== array_key_last($team)) {
- $players .= ', ';
- } else {
- $typeBattle = $player['typeBattle'];
- $timeStart = $player['time_start'];
- }
- }
- if ($teamId === array_key_first($teams)) {
- $players .= ' против ';
- }
- }
- echo '' . date('d.m.y H:i', $timeStart) . ' ';
- echo " $players ";
- echo ' ';
- echo '▶▶ ';
- }
- echo ' ';
- }
- ///new
-
-
- } elseif ($r == 7) {
- //завершенные
- $btl = '';
- $dt = time();
- if (isset($_GET['logs2'])) {
- $dt = round((int)$_GET['logs2']);
- }
- $dt = strtotime(date('d F Y', $dt) . ' 00:00:00');
- $slogin = $this->u->info['login'];
- if (isset($_GET['filter'])) {
- $slogin = $_GET['filter'];
- }
- if (isset($_POST['filter'])) {
- $slogin = $_POST['filter'];
- }
- $slogin = str_replace('"', '', $slogin);
- $slogin = str_replace("'", '', $slogin);
- $slogin = str_replace('\\', '', $slogin);
- $see = '';
- $usr = mysql_fetch_array(
- mysql_query(
- 'SELECT `id`,`login`,`level`,`city` FROM `users` WHERE `login` = "' . mysql_real_escape_string(
- $slogin
- ) . '" LIMIT 1'
- )
- );
- if (isset($usr['id'])) {
- $tms = $dt;
- $tmf = $dt + 86400;
- $sp = mysql_query(
- 'SELECT * FROM `battle_last` WHERE `time` >= ' . $tms . ' AND `time` < ' . $tmf . ' AND `uid` = "' . $usr['id'] . '" ORDER BY `id` DESC'
- );
- $j = 1;
- $jk = 0;
- $btl_lst = [];
- while ($pl = mysql_fetch_array($sp)) {
- $b = mysql_fetch_array(
- mysql_query(
- 'SELECT * FROM `battle_end` WHERE `battle_id` = "' . $pl['battle_id'] . '" LIMIT 1'
- )
- );
- $tm = '';
- if (isset($b['id'])) {
- $tms = [];
- $ts = [];
- $spi = mysql_query(
- 'SELECT * FROM `battle_last` WHERE `battle_id` = "' . $pl['battle_id'] . '"'
- );
- while ($pli = mysql_fetch_array($spi)) {
- if (!isset($tms[$pli['team']])) {
- $ts[count($ts)] = $pli['team'];
- }
- $tms[$pli['team']][count($tms[$pli['team']])] = $pli;
- }
- $k = 0;
- while ($k < count($ts)) {
- $g = $ts[$k];
- $h = 0;
- $tm2 = '';
- while ($h < count($tms[$g])) {
- if ($tms[$g][$h]['uid'] > 0) {
- if ($tms[$g][$h]['align'] > 0) {
- $tm2 .= ' ';
- }
- $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 .= ' ';
- }
- $tm .= $tm2;
- if ($k + 1 < count($ts) && $tm2 != '' && $ts[$k + 1] > 0) {
- $tm .= ' против ';
- }
- $k++;
- }
- }
- if (!isset($btl_lst[$b['id']])) {
- $btl_lst[$b['id']] = true;
- if ($tm == '') {
- $tm = 'Данные поединка потеряны';
- }
- $jk++;
- $btl .= $jk . '. ' . date(
- 'd.m.y H:i', $pl['time']
- ) . ' ' . $tm . ' »» ';
- }
- $j++;
- }
- }
- if ($btl == '') {
- $see .= 'В этот день не было боев, или же, летописец опять потерял свитки... ';
- } else {
- $see .= $btl;
- }
- echo $see;
- } else {
- if ((!isset($_GET['new_group']) && !isset($_POST['groupClick'])) || isset($zi['id'])) {
- echo 'Выберите раздел ';
- }
- }
- } else {
- if ((!isset($_GET['new_group']) && !isset($_POST['groupClick'])) || isset($zi['id'])) {
- echo 'Выберите раздел ';
- }
- }
- }
-
- public function rzv($v)
- {
- $v = explode('.', $v);
- if (!isset($v[1])) {
- $v = $v[0] . '.0';
- } else {
- $v = $v[0] . '.' . $v[1];
- }
- return $v;
- }
-
- public function testzvu($id, $tm, $bt = 0)
- {
- $query = "select id from stats where zv = $id and team = $tm";
- if ($bt) {
- $query .= " and bot = 2";
- }
- return mysql_num_rows(mysql_query($query));
- }
-
- public function seeZv()
- {
- global $code, $zi;
- if (isset($_GET['r']) && $this->zv_see == 1) {
- $r = round(intval($_GET['r']));
- if ($r >= 1 && $r <= 5) {
- //Список заявок
- $i = 0;
- $cl = mysql_query(
- 'SELECT * FROM `zayvki` WHERE `razdel` = "' . mysql_real_escape_string(
- $r
- ) . '" AND `start` = "0" AND `cancel` = "0" AND `time` > "' . (time(
- ) - 60 * 60 * 2) . '" /*AND `city` = "' . $this->u->info['city'] . '"*/ ORDER BY `id` DESC'
- );
- $zvb = '';
-
- while ($pl = mysql_fetch_array($cl)) {
- if ($pl['razdel'] == 5) {
- if ($pl['min_lvl_1'] < 2) {
- $pl['min_lvl_1'] = 2;
- }
- if ($pl['max_lvl_1'] > 21) {
- $pl['max_lvl_1'] = 21;
- }
- $tm = '';
- $tmStart = floor(($pl['time'] + $pl['time_start'] - time()) / 6) / 10;
- if ((($pl['time'] + $pl['time_start']) / 10) != (int)(($pl['time'] + $pl['time_start']) / 10)) {
- $pl['time'] = ceil($pl['time'] / 60) * 60;
- mysql_query(
- 'UPDATE `zayvki` SET `time` = "' . $pl['time'] . '" WHERE `id` = "' . $pl['id'] . '" LIMIT 1'
- );
- }
- $tmStart = $this->rzv($tmStart);
- $users = mysql_query(
- 'SELECT `u`.`id`,`u`.`login`,`u`.`level`,`u`.`align`,`u`.`clan`,`u`.`admin`,`st`.`team` FROM `users` AS `u` LEFT JOIN `stats` AS `st` ON `u`.`id` = `st`.`id` WHERE `st`.`zv` = "' . $pl['id'] . '"'
- );
- $col_p = mysql_fetch_array(
- mysql_query('SELECT COUNT(*) FROM `stats` WHERE `zv` = "' . $pl['id'] . '"')
- );
- $cols = $col_p[0];
- while ($s = mysql_fetch_array($users)) {
- $tm .= $this->u->microLogin($s['id'], 1) . ', ';
- }
- $rad = '';
- $tm = rtrim($tm, ', ');
- if (!isset($zi['id']) && $this->u->room['zvsee'] == 0 && $this->u->info['inTurnirnew'] == 0) {
- $rad = ' ';
- }
- $n1tv = '';
- $unvs = '';
- if ($pl['invise'] == 1) {
- //невидимый бой
- $tm = 'невидимый ';
- $unvs = 0;
-
- $usrszv = '';
- //if( $this->u->info['admin'] > 0 ) {
- $spzm = mysql_query(
- 'SELECT `id`,`team` FROM `stats` WHERE `zv` = "' . $pl['id'] . '" AND `id` != "' . $pl['creator'] . '"'
- );
- while ($plzm = mysql_fetch_array($spzm)) {
- if ($this->u->info['admin'] > 0 || ($this->u->info['align'] > 1 && $this->u->info['align'] < 2) || ($this->u->info['align'] > 3 && $this->u->info['align'] < 4)) {
- $usrszv .= ',' . $this->u->microLogin($plzm['id'], 1) . '';
- }
- $unvs++;
- }
- //}
- $tm = '' . $this->u->microLogin(
- $pl['creator'], 1
- ) . ' ' . $usrszv . ' - ' . $tm;
-
- $unvs = ' Участников: ' . (1 + $unvs) . ' чел. ';
- $n1tv = ' ';
- }
- 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 .= ' ';
- }
- if ($pl['arand'] == 1) {
- $n1tv .= ' ';
- }
- if ($pl['noart'] == 1) {
- $n1tv .= ' ';
- }
- if ($pl['otmorozok'] == 1) {
- $n1tv .= ' ';
- }
- 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['priz'] == 1) {
- $imn = '';
- if ($pl['min_lvl_1'] == 10) {
- $imn .= ' им. Jora Kardan';
- }
- $zv_comm = ' (Героическое Сражение' . $imn . ') ';
- }
- if ($r == 5 && ($pl['creator'] == $this->u->info['id']) && $cols < 2 && $pl['priz'] == 0) {
- $del_q = ' ';
- } 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 . ') тип боя: ' . $n1tv . ' (таймаут ' . ($pl['timeout'] / 60) . ' мин. ) ' . $zv_comm . ' (' . $unvs . 'Бой начнется через ' . $tmStart . ' мин.) ' . $mon . ' Участники: ' . $tm . ' ' . $del_q . ' ';
- } elseif ($pl['razdel'] == 4) {
- if ($pl['min_lvl_1'] < 2) {
- $pl['min_lvl_1'] = 2;
- }
- if ($pl['max_lvl_1'] > 21) {
- $pl['max_lvl_1'] = 21;
- }
- if ($pl['min_lvl_2'] < 2) {
- $pl['min_lvl_2'] = 2;
- }
- if ($pl['max_lvl_2'] > 21) {
- $pl['max_lvl_2'] = 21;
- }
- //Заявки группового боя
- $tm1 = '';
+ $k = 0;
+ while ($k < count($ts)) {
+ $g = $ts[$k];
+ $h = 0;
$tm2 = '';
- $tmStart = floor(($pl['time'] + $pl['time_start'] - time()) / 6) / 10;
- $tmStart = $this->rzv($tmStart);
-
- //Персонаж в заявке, подключаем ему противника
- //Ищем апонента для групповых
- $xx2 = $this->testzvu($pl['id'], 2, 0);
- if ($pl['bot2'] > 0 && $xx2 < $pl['tm2max']) {
- //Добавляем ботов за вторую команду
- $spb = mysql_query(
- 'SELECT `u`.*,`st`.* FROM `users` AS `u` LEFT JOIN `stats` AS `st` ON `u`.`id` = `st`.`id` WHERE `st`.`bot` = 3 AND `u`.`level` = "' . $pl['min_lvl_2'] . '" AND `u`.`battle` = 0 AND `st`.`zv` = 0 LIMIT 100'
- );
- $logins_bot = [];
- while ($plb = mysql_fetch_array($spb)) {
- if ($xx2 < $pl['tm2max'] && rand(0, 10000) < 5000 && rand(0, 10000) > 5000) {
- $bt = $this->u->addNewbot(0, '', $plb['id']);
- $logins_bot = $bt['logins_bot'];
- if ($bt > 0) {
- mysql_query(
- 'UPDATE `stats` SET `zv` = "' . $pl['id'] . '",`team` = "2" WHERE `id` = "' . $bt . '" LIMIT 1'
- );
- $xx2++;
- }
+ while ($h < count($tms[$g])) {
+ if ($tms[$g][$h]['uid'] > 0) {
+ if ($tms[$g][$h]['align'] > 0) {
+ $tm2 .= ' ';
}
+ $tm2 .= '' . $tms[$g][$h]['login'] . ' [' . $tms[$g][$h]['lvl'] . ']
+
+ , ';
}
- unset($plb, $spb, $logins_bot, $bt);
+ $h++;
}
- unset($xx2);
-
- //генерируем команды
- $users = mysql_query(
- 'SELECT `u`.`id`,`u`.`login`,`u`.`level`,`u`.`align`,`u`.`clan`,`u`.`admin`,`st`.`team` FROM `users` AS `u` LEFT JOIN `stats` AS `st` ON `u`.`id` = `st`.`id` WHERE `st`.`zv` = "' . $pl['id'] . '"'
- );
- $tmc = [];
- while ($s = mysql_fetch_array($users)) {
- ${'tm' . $s['team']} .= $this->u->microLogin($s['id'], 1) . ', ';
- $tmc[$s['team']]++;
+ $tm2 = rtrim($tm2, ', ');
+ $btlg = Db::getValue('select id, team_win from battle where id = ?', [$pl['battle_id']]);
+ if (isset($btlg['id']) && $g == $btlg['team_win']) {
+ $tm2 .= ' ';
}
-
- if ($tm1 == '') {
- $tm2 = 'группа пока не набрана ';
- } else {
- $tm1 = rtrim($tm1, ', ');
- }
-
- if ($tm2 == '') {
- $tm2 = 'группа пока не набрана ';
- } else {
- $tm2 = rtrim($tm2, ', ');
- }
- //
- if ($pl['teams'] == 3) {
- if ($tm3 == '') {
- $tm2 = 'группа пока не набрана ';
- } else {
- $tm3 = rtrim($tm3, ', ');
- }
-
- $ttl1 = '';
- $ttl2 = '';
- $ttl3 = '';
-
- if ($pl['align1'] == 3) {
- $ttl1 = 'Тьма';
- } elseif ($pl['align1'] == 7) {
- $ttl1 = 'Нейтралы';
- } else {
- $ttl1 = 'Свет';
- }
- if ($pl['align2'] == 3) {
- $ttl2 = 'Тьма';
- } elseif ($pl['align2'] == 7) {
- $ttl2 = 'Нейтралы';
- } else {
- $ttl2 = 'Свет';
- }
- if ($pl['align3'] == 3) {
- $ttl3 = 'Тьма';
- } elseif ($pl['align3'] == 7) {
- $ttl3 = 'Нейтралы';
- } else {
- $ttl3 = 'Свет';
- }
-
- $tm1 = ' ' . $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 .= ' тип боя: (таймаут: ' . ($pl['timeout'] / 60) . ' мин. ) ';
- $zvb .= ' ' . $zv_comm . ' ';
- $zvb .= ' (Бой начнется через ' . $tmStart . ' ) ' . $mon . ' ';
- } elseif ($pl['razdel'] >= 1 && $pl['razdel'] <= 3) {
- $uz = mysql_fetch_array(
- mysql_query(
- 'SELECT `u`.`banned`,`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'] . '" AND `st`.`team`="1" LIMIT 1'
- )
- );
- if (isset($uz['id'])) {
- $uze = mysql_fetch_array(
- mysql_query(
- 'SELECT `u`.*,`st`.* FROM `stats` AS `st` LEFT JOIN `users` AS `u` ON (`st`.`id` = `u`.`id`) WHERE `st`.`zv`="' . $pl['id'] . '" AND `st`.`team` = "2" LIMIT 1'
- )
- );
- $d1 = '';
- if ($uz['id'] == $this->u->info['id'] || $uze['id'] == $this->u->info['id'] || $this->u->info['level'] <= Config::get(
- 'bot_level'
- )) {
- $d1 = 'disabled="disabled"';
- }
- if (!isset($uze['id']) || $this->u->info['zv'] == $pl['id']) {
- $enm = '';
- if (isset($uze['id'])) {
- $enm = ' против ' . $this->u->microLogin($uze['id'], 1) . '';
- }
- if ($uz['banned'] > 0) {
- $pl['id'] = 0;
- $d1 = 'disabled="disabled"';
- $zvb .= '';
- }
- $dp1 = '';
- if ($pl['money'] > 0) {
- $dp1 = ' Бой на деньги, ставка: ' . $this->u->round2($pl['money']) . ' кр. ';
- }
- if ($this->u->room['zvsee'] == 0) {
- $zvb .= ' ';
- }
- $mbcom = '';
- if ($pl['comment'] != '') {
- $mbcom = ' ' . $pl['comment'] . ' ';
- }
- $zvb .= '' . date(
- 'H:i', $pl['time']
- ) . ' ' . $this->u->microLogin(
- $uz['id'], 1
- ) . ' ' . $enm . ' тип боя: ( таймаут ' . round(
- $pl['timeout'] / 60
- ) . ' мин. ' . $dp1 . ' ' . $mon . ')' . $mbcom . ' ';
- if ($uz['banned'] > 0) {
- $zvb .= ' ';
- }
- }
+ $tm .= $tm2;
+ if ($k + 1 < count($ts) && $tm2 != '' && $ts[$k + 1] > 0) {
+ $tm .= ' против ';
}
+ $k++;
}
- $i++;
}
- if ($i == 0) {
- //заявок нет
- if ($this->u->room['zvsee'] > 0) {
- echo 'В данном разделе нет ни одной заявки
';
+ if (!isset($btl_lst[$b['id']])) {
+ $btl_lst[$b['id']] = true;
+ if ($tm == '') {
+ $tm = 'Данные поединка потеряны';
}
+ $jk++;
+ $btl .= $jk . '. ' . date(
+ 'd.m.y H:i', $pl['time']
+ ) . ' ' . $tm . ' »» ';
+ }
+ }
+ }
+ $see .= empty($btl) ? 'В этот день не было боев, или же, летописец опять потерял свитки...
' : $btl;
+ echo $see;
+ }
+
+ public function getCurrentBattlesList(): void
+ {
+ $code = PassGen::intCode();
+ $query = 'select
+ login,
+ users.id,
+ team,
+ battle,
+ time_start,
+ typeBattle from users
+ left join stats on users.id = stats.id
+ left join battle on users.battle = battle.id
+ where
+ battle in (select id from battle
+ where type != 329 and
+ team_win = -1 and
+ time_over = 0 and
+ start1 > 0
+ order by time_start)
+ order by battle desc';
+ $currentBattles = Db::getRows($query);
+
+ if (empty($currentBattles)) {
+ echo 'К сожалению сейчас боев нет...
';
+ } else {
+ // Надеялся на вывод вида:
+ // [battle -> [team -> [uid, uid, uid], team -> [uid, uid, uid],]],
+ // [battle -> [team -> [uid, uid, uid], team -> [uid, uid, uid],]],
+ // но глубоко наломался, где-то перемудрил с ArraySorter::groupBy()
+ // и на выходе там сортировка, но с сохранением всех вложенностей,
+ // что усложнило последющий вывод. Но вышло как вышло. Ins.
+ $currentBattlesArray = ArraySorter::groupBy($currentBattles, 'battle');
+ echo '';
+ foreach ($currentBattlesArray as $battleId => $cb) {
+ $players = '';
+ $typeBattle = 0;
+ $timeStart = 0;
+ $teams = ArraySorter::groupBy($cb, 'team');
+ foreach ($teams as $teamId => $team) {
+ foreach ($team as $key => $player) {
+ $players .= $this->u->microLogin($player['id']);
+ if ($key !== array_key_last($team)) {
+ $players .= ', ';
+ } else {
+ $typeBattle = $player['typeBattle'];
+ $timeStart = $player['time_start'];
+ }
+ }
+ if ($teamId !== array_key_first($teams)) {
+ continue;
+ }
+ $players .= ' против ';
+ }
+ echo '' . date('d.m.y H:i', $timeStart) . ' ';
+ echo " $players ";
+ echo ' ';
+ echo '▶▶ ';
+ }
+ echo ' ';
+ }
+ }
+
+ public function getTournaments(): object
+ {
+ /** Турниры by Insallah*/
+ # Защита от F5
+ if (!isset($_SESSION['bypass'])) {
+ $_SESSION['bypass'] = mt_rand();
+ }
+ if ($_SERVER['REQUEST_METHOD'] === 'POST' && $_POST['key'] == $_SESSION['bypass']) {
+ unset($_SESSION['bypass']);
+ if (array_key_exists('tournament_start', $_POST)) {
+ (new Tournament())->join($this->u->info['id']);
+ }
+ }
+
+ # Формируем список идущих турниров.
+ $tournamentsList = Db::getRows('select * from tournaments');
+ $tournaments = '';
+ foreach ($tournamentsList as $tournament) {
+ $time = $tournament['start_time'] === -1 ? 'Турнир уже начался!' : date(
+ 'G:i', $tournament['start_time']
+ );
+ $tournament_members_id = TournamentModel::getFreeFighters($tournament['tid']);
+ $members = [];
+ foreach ($tournament_members_id as $member) {
+ $members[] = TournamentModel::uidToLogin($member);
+ }
+ $tournaments .= sprintf(
+ "Турнир для %d уровней. Время подачи заявки: %s Участники: %s ",
+ $tournament['tid'], $time, implode(', ', $members)
+ );
+ }
+ $tournaments .= ' ';
+
+ return (object)[
+ 'hasTournaments' => !empty($tournamentsList),
+ 'listTournaments' => $tournaments,
+ ];
+ /** Конец турниров от Insallah. */
+ }
+
+ /** Дописывает значение после точки, если такового нет. 1 -> 1.0, 1.1 -> 1.1
+ * @param string $str
+ * @return string
+ */
+ public function rzv(string $str): string
+ {
+ $symbols = explode('.', $str);
+ return isset($symbols[1]) ? $symbols[0] . '.' . $symbols[1] : $symbols[0] . '.0';
+ }
+
+ public function seeZv(array $zi, int $r)
+ {
+ $code = PassGen::intCode();
+ if (!$r) {
+ return;
+ }
+ if (!in_array($r, [self::BATTLE_RAZDEL_GROUP, self::BATTLE_RAZDEL_CHAOTIC])) {
+ return;
+ }//Список заявок
+ $i = 0;
+ $fightrequests = Db::getRows(
+ 'select * from zayvki where razdel = ? and start = 0 and cancel = 0 and time > unix_timestamp() - ? order by id desc',
+ [$r, 2 * 60 * 60]
+ );
+ $zvb = '';
+ foreach ($fightrequests as $pl) {
+ $tmStart = floor(($pl['time'] + $pl['time_start'] - time()) / 6) / 10;
+ $tmStart = $this->rzv($tmStart);
+
+ if (!empty($pl['comment'])) {
+ $dl = '';
+ if ($this->u->isModerator() && $pl['dcom'] == 0) {
+ $dl .= ' (удалить комментарий )';
+ $pl['dcom'] = $this->deleteComment($pl['id']);
+ }
+ if ($pl['dcom'] > 0) {
+ $dl = ' Комментарий удален модератором ';
+ if (!$this->u->isModerator()) {
+ $pl['comment'] = '';
+ }
+ }
+ $zv_comm = ' ' . $pl['comment'] . $dl . ' ';
+ } else {
+ $zv_comm = '';
+ }
+
+ $rad = '';
+
+ if ($pl['razdel'] == self::BATTLE_RAZDEL_CHAOTIC) {
+ $tm = '';
+
+ $uids = Db::getColumn('select id from stats where zv = ?', [$pl['id']]);
+ $cols = count($uids);
+ foreach ($uids as $uid) {
+ $tm .= $this->u->microLogin($uid) . ', ';
+ }
+
+ $tm = rtrim($tm, ', ');
+ if (!isset($zi['id']) && $this->u->room['zvsee'] == 0) {
+ $rad = ' ';
+ }
+ $n1tv = '';
+ $unvs = '';
+ if ($pl['invise'] == 1) {
+ $userslist = $this->u->isModerator() ? $tm : '';
+ $tm = '' . $this->u->microLogin($pl['creator']) . ' ' .
+ $userslist . ' - невидимый ';
+ $unvs = ' Участников: ' . $cols . ' чел. ';
+ $n1tv .= ' ';
+ }
+ 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 .= ' ';
+ }
+ if ($pl['arand'] == 1) {
+ $n1tv .= ' ';
+ }
+ if ($pl['noart'] == 1) {
+ $n1tv .= ' ';
+ }
+ if ($pl['otmorozok'] == 1) {
+ $n1tv .= ' ';
+ }
+
+ if ($pl['priz'] == 1) {
+ $zv_comm = ' (Героическое Сражение) ';
+ }
+ if ($r == 5 && ($pl['creator'] == $this->u->info['id']) && $cols < 2 && $pl['priz'] == 0) {
+ $del_q = '
+ ';
} else {
- if (!isset($zi['id']) && $this->u->room['zvsee'] == 0) {
- if ($_GET['r'] == 5) {
- if (!$this->u->info['no_zv_key']) {
- echo '';
- } else {
- echo '
';
+ $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 .= $cols . '/' . $pl['maxplayers'];
+ $zvb .= $rad . '' . date('H:i', $pl['time']) . '
+ (' . $lvldt . ')
+ тип боя:
+ ' . $n1tv . ' (таймаут ' . ($pl['timeout'] / 60) . ' мин. ) ' . $zv_comm . '
+ (' . $unvs . 'Бой начнется через ' . $tmStart . ' мин.)
+ Участники: ' . $tm . ' ' . $del_q . ' ';
+
+ } elseif ($pl['razdel'] == self::BATTLE_RAZDEL_GROUP) {
+ if ($pl['min_lvl_2'] < 2) {
+ $pl['min_lvl_2'] = 2;
+ }
+ if ($pl['max_lvl_2'] > 21) {
+ $pl['max_lvl_2'] = 21;
+ }
+
+ if ($pl['teams'] == 2) {
+ //Персонаж в заявке, подключаем ему противника
+ //Ищем бота для групповых
+ $xx2 = $this->countUsersInTeam2($pl['id']);
+ if ($pl['bot2'] > 0 && $xx2 < $pl['tm2max']) {
+ //Добавляем ботов за вторую команду
+ $spb = Db::getColumn(
+ 'select users.id from users left join stats on users.id = stats.id where bot = 3 and level = ? and battle = 0 and zv = 0'
+ );
+ foreach ($spb as $botId) {
+ if ($xx2 >= $pl['tm2max'] || rand(0, 10000) >= 5000 || rand(0, 10000) <= 5000) {
+ continue;
}
- } else {
- if ($zvb != '' && $this->u->info['level'] > Config::get('bot_level')) {
- echo '
';
- } else {
- echo '' . $zvb . '
';
+ $bt = $this->u->addNewbot(0, '', $botId);
+ if ($bt == 0) {
+ continue;
}
+ Db::sql('update stats set zv = ?, team = 2 where id = ?', [$pl['id'], $bt]);
+ $xx2++;
}
- } else {
- echo $zvb;
+ }
+ unset($xx2);
+ }
+
+ //генерируем команды
+ $teams = [];
+ $cols = [];
+ $tmc = [];
+ $users = Db::getRows('select team, id from stats where zv = ?', [$pl['id']]);
+ foreach ($users as $user) {
+ ${'tm' . $user['team']} .= $this->u->microLogin($user['id']) . ', ';
+ $tmc[$user['team']]++;
+ $teams[$user['team']][] = $this->u->microLogin($user['id']);
+ }
+
+ foreach ($teams as $id => $members) {
+ $cols[$id] = count($members);
+ $teams[$id] = !empty($cols[$id]) ? implode(', ', $members) : 'группа пока не набрана';
+ }
+
+ if (!isset($zi['id']) && $this->u->room['zvsee'] == 0) {
+ $rad = ' ';
+ }
+
+ $zvb .= $rad . '' . date('H:i', $pl['time']) . ' ';
+
+ foreach ($teams as $id => $memberList) {
+ $zvb .= '(' . $cols[$id] . '/' . $pl['tm' . $id . 'max'] . ' ) ';
+ $zvb .= $memberList;
+ $zvb .= ' (';
+ $zvb .= $pl['min_lvl_' . $id] == $pl['max_lvl_' . $id] ?
+ $pl['min_lvl_' . $id] : $pl['min_lvl_' . $id] . '-' . $pl['max_lvl_' . $id];
+ $zvb .= ' ур.) ';
+ if ($id !== array_key_last($teams)) {
+ $zvb .= ' против ';
}
}
+
+ $zvb .= ' тип боя: (таймаут: ' . ($pl['timeout'] / 60) . ' мин. ) ';
+ $zvb .= ' ' . $zv_comm . ' ';
+ $zvb .= ' (Бой начнется через ' . $tmStart . ' ) ';
+ }
+ $i++;
+ }
+ if ($i == 0) {
+ //заявок нет
+ if ($this->u->room['zvsee'] > 0) {
+ echo 'В данном разделе нет ни одной заявки
';
+ }
+ } else {
+ if (!isset($zi['id']) && $this->u->room['zvsee'] == 0) {
+
+ $html = <<
+
+
+ HTML;
+
+ if ($r === self::BATTLE_RAZDEL_CHAOTIC) {
+ if (!$this->u->info['no_zv_key']): ?>
+
+ u->info['level'] <= Config::get('bot_level')) {
+ echo '' . $zvb . '
';
+ } else {
+ echo $html;
+ }
+ }
+ } else {
+ echo $zvb;
}
}
}
- public function go($id)
+ private function deleteComment($uid): int
+ {
+ if (
+ !isset($_GET['delcom']) ||
+ $_GET['delcom'] != $uid ||
+ !$this->u->newAct($_GET['key'])
+ ) {
+ return 0;
+ }
+ Db::sql('update zayvki set dcom = ? where id = ?', [$this->u->info['id'], $uid]);
+ return $this->u->info['id'];
+ }
+
+ /** Принять групповую заявку.
+ * @param array $z заявка
+ * @return void
+ */
+ private function joinGroup(array $z)
+ {
+ $tm = 0;
+ if (isset($_GET['tm1'])) {
+ $tm = 1;
+ } elseif (isset($_GET['tm2'])) {
+ $tm = 2;
+ } else {
+ $this->error = 'Что-то здесь не так';
+ }
+ if ($tm == 0) {
+ return;
+ }
+ $t1 = $tm;
+ $t2 = 1;
+ $tmmax = 0;
+ $cln = 0;
+ if ($tm == 1) {
+ $t2 = 2;
+ }
+ $clanTeamsCheck = Db::getRows(
+ 'select clan, team from users left join stats on users.id = stats.id where zv = ?', [$z['id']]
+ );
+ foreach ($clanTeamsCheck as $ctc) {
+ if ($ctc['team'] == $t1) {
+ $tmmax++;
+ }
+ if (
+ !empty($this->u->info['clan']) &&
+ $this->u->info['clan'] == $ctc['clan'] &&
+ $ctc['team'] == $t2
+ ) {
+ $cln++;
+ }
+ }
+
+ $error = null;
+ if ($cln > 0) {
+ $error = 'Вы не можете сражаться против сокланов';
+ } elseif ($z['bot2'] == 1 && $t1 == 2) {
+ $error = 'Вы не можете сражаться на стороне ботов';
+ } elseif ($z['tm' . $t1 . 'max'] <= $tmmax) {
+ $error = 'Группа уже набрана (' . ($z['tm' . $t1 . 'max'] - $tmmax) . ')';
+ } elseif (
+ $z['min_lvl_' . $t1] > $this->u->info['level'] ||
+ $z['max_lvl_' . $t1] < $this->u->info['level']
+ ) {
+ $error = 'Вы не подходите по уровню, за эту команду могут зайти персонажи ' .
+ $z['min_lvl_' . $t1] . ' - ' . $z['max_lvl_' . $t1] . ' уровня';
+ } elseif ($this->u->isWeakened()) {
+ $error = 'Вы слишком ослаблены, восстановитесь';
+ }
+
+ if ($error) {
+ $this->error = $error;
+ return;
+ }
+ Db::sql('update stats set zv = ?, team = ? where id = ?', [$z['id'], $t1, $this->u->info['id']]);
+ $this->error = 'Вы приняли групповой бой...';
+ $this->u->info['zv'] = $z['id'];
+ $this->u->info['team'] = $t1;
+ }
+
+ /** Присоединиться к хаотической заявке.
+ * @param array $z заявка
+ * @return void
+ */
+ private function joinChaotic(array $z)
+ {
+ $error = null;
+ $cols = $this->countUsersAll($z['id']);
+ if ($cols >= $z['maxplayers']) {
+ $error = 'Достигнут максимальный предел участников в этой заявке!';
+ } elseif ($this->testTravm() == 1 && $z['k'] != 1) {
+ $error = 'Вы травмированы. С такими увечьями доступны кулачные бои.';
+ } elseif ($this->testTravm() == 2) {
+ $error = 'Вы травмированы. С такими увечьями невозможно сражаться.';
+ } elseif (
+ !$this->u->info['no_zv_key'] &&
+ (
+ !isset($_SESSION['code2']) ||
+ $_SESSION['code2'] < 1 ||
+ (
+ $_POST['code21'] != $_SESSION['code2'] &&
+ $_POST['code22'] != $_SESSION['code2']
+ )
+ )
+ ) {
+ $error = 'Неправильный код подтверждения';
+ } elseif (
+ $z['min_lvl_1'] > $this->u->info['level'] ||
+ $z['max_lvl_1'] < $this->u->info['level']
+ ) {
+ $error = 'Вы не подходите по уровню, за эту команду могут зайти персонажи ' .
+ $z['min_lvl_1'] . ' - ' . $z['max_lvl_1'] . ' уровня';
+ } elseif ($this->u->isWeakened()) {
+ $error = 'Вы слишком ослаблены, восстановитесь';
+ }
+
+ if ($error) {
+ $this->error = $error;
+ return;
+ }
+ $t1 = 0;
+ if ($z['type'] == self::CHAOTIC_TYPE_PRIZED) {
+ $this->joinPrizedChaotic();
+ }
+
+ $this->u->info['login2'] = '';
+ $blnc = $this->u->stats['reting'];
+ $z['tm' . $t1] += $blnc;
+
+ Db::run('update stats set zv = ?, team = ? where id = ?', [$z['id'], $t1, $this->u->info['id']]);
+ 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']]);
+ $this->u->info['zv'] = $z['id'];
+ $this->u->info['team'] = $t1;
+ $this->error = 'Вы приняли хаотичный бой...';
+
+ }
+
+ private function joinPrizedChaotic()
+ {
+ //============================================================================================= Призовые
+ Db::sql(
+ 'insert into users (
+ name,
+ align,
+ `real`,
+ login,
+ host_reg,
+ pass,
+ ip,
+ ipreg,
+ room,
+ timereg,
+ mail,
+ sex,
+ fnq,
+ molch2,
+ level
+ ) values (?,?,1,?,0,?,?,?,422,unix_timestamp(),?,?,0,unix_timestamp() + 86400,8)',
+ [
+ $this->u->info['name'],
+ $this->u->info['align'],
+ $this->u->info['login'],
+ $this->u->info['pass'],
+ IP,
+ IP,
+ 'haot@new-combats.com',
+ $this->u->info['sex'],
+ ]
+ );
+
+ $uidb = Db::lastInsertId();
+ Db::sql('update users set inUser = ? where id = ?', [$uidb, $this->u->info['id']]);
+ /** Классы:
+ * 1 - Уворот
+ * 2 - Крит
+ * 3 - Танк
+ * 4 - Топор
+ * 5 - Маг земли
+ * 6 - Маг воздуха
+ */
+ $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,?)'
+ );
+
+ $classItems = [
+ 1 => [
+ 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,
+ ],
+ 2 => [
+ 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,
+ ],
+ 3 => [
+ 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,
+ ],
+ 4 => [
+ 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,
+ ],
+ 5 => [
+ 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,
+ ],
+ 6 => [
+ 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,
+ ],
+ ];
+
+ $classStats = [
+ 1 => [
+ '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',
+ ],
+ 2 => [
+ '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',
+ ],
+ 3 => [
+ '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',
+ ],
+ 4 => [
+ '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',
+ ],
+ 5 => [
+ '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',
+ ],
+ 6 => [
+ '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',
+ ],
+ ];
+
+ /** @var array $classEffects
+ * Эффекты:
+ * 1 - Сила;
+ * 7 - Интуиция;
+ * 8 - Ловкость;
+ * 9 - Интеллект;
+ * 20 - Сокрушение;
+ * 25 - Защита от оружия;
+ * 32 - Холодный разум;
+ * 37 - Нектар;
+ * 38 - Нектар отрицания;
+ * 53 - Магическое усиление воздуха;
+ * 54 - Магическое усиление земли;
+ * 283 - Бутерброд -Завтрак Рыцаря- толстый;
+ * 296 - Жажда Жизни +6;
+ * 439 - Магическое усиление общее;
+ */
+ $classEffects = [
+ 1 => [8, 20, 25, 37, 38, 283, 296,],
+ 2 => [7, 20, 25, 37, 38, 283, 296,],
+ 3 => [1, 20, 25, 37, 38, 283, 296,],
+ 4 => [1, 20, 25, 37, 38, 283, 296,],
+ 5 => [9, 32, 54, 439, 25, 37, 38, 283, 296,],
+ 6 => [9, 32, 53, 439, 25, 37, 38, 283, 296,],
+ ];
+
+ foreach ($classEffects[$sellclass] as $classEffect) {
+ UserEffects::addById($uidb, $classEffect);
+ }
+ $items = $classItems[$sellclass];
+
+ foreach ($items as $slot => $itemId) {
+ $re = $this->u->addItem($itemId, $uidb);
+ $stmt1->execute([$slot, $re]);
+ $stmt2->execute([$itemId, $re]);
+ }
+ $stmt3->execute([$uidb, $classStats[$sellclass][0], $classStats[$sellclass][1]]);
+
+ 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 ''; - и где, блять, брать $btl_id ???
+ echo '';
+ }
+
+ public function go(int $id)
{
global $zi;
- $filter = new Filter();
+ if (empty($id) || !empty($this->u->info['battle'])) {
+ return;
+ }
if (isset($zi['id'])) {
$this->error = 'Вы не можете принять бой. Сначала отзовите свою заявку.';
- } else {
- if ($this->u->info['battle'] == 0 && $this->u->info['inTurnirnew'] == 0) {
- $z = mysql_fetch_array(
- mysql_query(
- 'SELECT * FROM `zayvki` WHERE `id`="' . mysql_real_escape_string(
- intval($id)
- ) . '" /*AND `city` = "' . $this->u->info['city'] . '"*/ AND `start` = "0" AND `cancel` = "0" AND `time` > "' . (time(
- ) - 60 * 60 * 2) . '" LIMIT 1'
- )
- );
- if (isset($z['id'])) {
- if ($z['razdel'] >= 1 && $z['razdel'] <= 3) {
- //новички, физы, договорные
- $uz1 = 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`="' . $z['id'] . '" AND `st`.`team`="1" LIMIT 1'
- )
- );
- if (isset($uz1['id'])) {
- $uz2 = 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`="' . $z['id'] . '" AND `st`.`team`="2" LIMIT 1'
- )
- );
- if ($this->testTravm() == 1 && $z['type'] != 1) {
- $this->error = 'Вы травмированы. С такими увечьями доступны кулачные бои.';
- $az = 0;
- } elseif ($this->testTravm() == 2) {
- $this->error = 'Вы травмированы. С такими увечьями невозможно сражаться.';
- $az = 0;
- } elseif ($this->u->info['hpNow'] < $this->u->stats['hpAll'] / 100 * 30 && ($z['razdel'] >= 1 || $z['razdel'] <= 3)) {
- $this->error = 'Вы еще слишком ослаблены чтобы начать новый бой';
- $az = 0;
- } elseif ($uz1['clan'] == $this->u->info['clan'] && $this->u->info['clan'] != 0 && $this->u->info['admin'] == 0 && true == false) {
- $this->error = 'Вы не можете сражаться против сокланов';
- } elseif ($z['withUser'] != '' && $filter->mystr($this->u->info['login']) != $filter->mystr(
- $z['withUser']
- ) && $z['razdel'] == 3) {
- $this->error = 'Вы не можете принять эту заявку';
- } elseif ($z['money'] > 0 && $z['money'] > $this->u->info['money']) {
- $this->error = 'У Вас недостаточно денег, чтобы принять эту заявку';
- } elseif ($this->u->stats['hpNow'] < ceil($this->u->stats['hpMax'] / 100 * 30)) {
- $this->error = 'Вы слишком ослаблены, восстановитесь';
- } elseif (!isset($uz2['id'])) {
- $upd = mysql_query(
- 'UPDATE `stats` SET `zv` = "' . $z['id'] . '",`team` = "2" WHERE `id` = "' . $this->u->info['id'] . '" LIMIT 1'
- );
- if ($upd) {
- $ca = '';
- if ($uz1['clan'] != 0) {
- $pc = mysql_fetch_array(
- mysql_query(
- 'SELECT * FROM `clan` WHERE `id`="' . $uz1['clan'] . '" LIMIT 1'
- )
- );
- if (isset($pc['id'])) {
- $pc['img'] = $pc['name_mini'] . '.gif';
- $ca = ' ';
- }
- }
- if ($uz1['align'] != 0) {
- $ca = ' ' . $ca;
- }
- $this->error = 'Ожидаем подтверждения боя от ' . $ca . ' ' . $uz1['login'] . ' [' . $uz1['level'] . '] ';
- $sa = '';
- if ($this->u->info['sex'] == 2) {
- $sa = 'а';
- }
+ return;
+ }
- $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 = 'Заявка на бой не найдена.';
- }
- }
+ $z = Db::getRow(
+ 'select * from zayvki where id = ? and start = 0 and cancel = 0 and time > unix_timestamp() - 60*60*2',
+ [$id]
+ );
+ if (!isset($z['id'])) {
+ $this->error = 'Заявка на бой не найдена.';
+ return;
+ }
+ if ($z['razdel'] == self::BATTLE_RAZDEL_GROUP) {
+ $this->joinGroup($z);
+ } elseif ($z['razdel'] == self::BATTLE_RAZDEL_CHAOTIC) {
+ $this->joinChaotic($z);
}
}
}
diff --git a/_incl_data/class/FightRequest/FRHelper.php b/_incl_data/class/FightRequest/FRHelper.php
new file mode 100644
index 00000000..49da9956
--- /dev/null
+++ b/_incl_data/class/FightRequest/FRHelper.php
@@ -0,0 +1,61 @@
+ $min,
+ 'max'=> $max,
+ ];
+ }
+
+ /** .
+ * @param int $type .
+ * @param int $userLevel .
+ * @return object
+ */
+ public static function getChaoticTeammatesLevel(int $type, int $userLevel): object
+ {
+ if (!in_array($type, [3, 6])) {
+ $type = 0;
+ }
+ return self::getTeammatesLevel($type, $userLevel);
+ }
+}
+
diff --git a/_incl_data/class/Insallah/Tournament/Tournament.php b/_incl_data/class/Tournament/Tournament.php
similarity index 95%
rename from _incl_data/class/Insallah/Tournament/Tournament.php
rename to _incl_data/class/Tournament/Tournament.php
index c05e13ef..9a684e77 100644
--- a/_incl_data/class/Insallah/Tournament/Tournament.php
+++ b/_incl_data/class/Tournament/Tournament.php
@@ -1,12 +1,14 @@
1) {
diff --git a/_incl_data/class/Insallah/Tournament/TournamentModel.php b/_incl_data/class/Tournament/TournamentModel.php
similarity index 74%
rename from _incl_data/class/Insallah/Tournament/TournamentModel.php
rename to _incl_data/class/Tournament/TournamentModel.php
index 4000c881..82819399 100644
--- a/_incl_data/class/Insallah/Tournament/TournamentModel.php
+++ b/_incl_data/class/Tournament/TournamentModel.php
@@ -1,6 +1,10 @@
0 and uid = ?', [$uid]);
+ $wearedItemsEkrPrice = Db::getValue('select sum(2price) from items_users where inOdet > 0 and uid = ?', [$uid]);
return $wearedItemsEkrPrice > Tournament::ekrOverpriceFormula($level);
}
@@ -43,9 +45,8 @@ class TournamentModel
*/
public static function isEnoughExperience(int $uid): bool
{
- $db = new Db();
- return $db::getValue('select exp from stats where id = ?', [$uid]) >= Tournament::MIN_EXP;
- }
+ return Db::getValue('select exp from stats where id = ?', [$uid]) >= Tournament::MIN_EXP;
+ }
/**
* @param int $uid
@@ -54,8 +55,7 @@ class TournamentModel
*/
public static function isRestrictedToJoin(int $uid): bool
{
- $db = new Db();
- return $db::getValue('select count(*) from eff_users where uid = ? and id_eff = 486 and `delete` = 0', [$uid]);
+ return Db::getValue('select count(*) from eff_users where uid = ? and id_eff = 486 and `delete` = 0', [$uid]);
}
/**
@@ -65,8 +65,7 @@ class TournamentModel
*/
public static function isStarted(int $tid): bool
{
- $db = new Db();
- return $db::getValue('select count(*) from tournaments where start_time = -1 and tid = ?', [$tid]);
+ return Db::getValue('select count(*) from tournaments where start_time = -1 and tid = ?', [$tid]);
}
/**
@@ -78,8 +77,7 @@ class TournamentModel
*/
public static function getWaitingMembersQuantity(int $tid): int
{
- $db = new Db();
- return $db::getValue('select count(*) from tournaments_users where tid = ?', [$tid]);
+ return Db::getValue('select count(*) from tournaments_users where tid = ?', [$tid]);
}
/**
@@ -91,8 +89,7 @@ class TournamentModel
*/
public static function createTournament(int $tid): void
{
- $db = new Db();
- $db::sql('insert into tournaments (tid) values (?)', [$tid]);
+ Db::sql('insert into tournaments (tid) values (?)', [$tid]);
}
/**
@@ -107,8 +104,7 @@ class TournamentModel
{
/** Кастомные комнаты 25008 - 25012. */
$roomId = 25000 + $tid;
- $db = new Db();
- $db::sql('insert into tournaments_users (tid, uid) values (?, ?)', [$tid, $uid]);
+ Db::sql('insert into tournaments_users (tid, uid) values (?, ?)', [$tid, $uid]);
self::teleport($uid, $roomId);
}
@@ -121,8 +117,7 @@ class TournamentModel
*/
public static function startTournament(int $tid): void
{
- $db = new Db();
- $db::sql('update tournaments set start_time = -1 where tid = ?', [$tid]);
+ Db::sql('update tournaments set start_time = -1 where tid = ?', [$tid]);
}
/**
@@ -134,9 +129,8 @@ class TournamentModel
*/
public static function destroyTournament(int $tid): void
{
- $db = new Db();
//Убедиться что в базе настроен foreign_keys и последует автоочистка tournaments_users !!!
- $db::sql('delete from tournaments where tid = ?', [$tid]);
+ Db::sql('delete from tournaments where tid = ?', [$tid]);
}
/**
@@ -148,9 +142,8 @@ class TournamentModel
*/
public static function getFightersTeams(array $fightersList): array
{
- $db = new Db();
$query = sprintf("select id from users where battle = 0 and id in (%s)", implode(', ', $fightersList));
- return array_chunk($db::getColumn($query), 2);
+ return array_chunk(Db::getColumn($query), 2);
}
/**
@@ -162,8 +155,9 @@ class TournamentModel
*/
public static function getFreeFighters(int $tid): array
{
- $db = new Db();
- return $db::getColumn('select uid from tournaments_users where tid = ? and death_time = 0 order by uid', [$tid]);
+ return Db::getColumn(
+ 'select uid from tournaments_users where tid = ? and death_time = 0 order by uid', [$tid]
+ );
}
/**
@@ -175,12 +169,13 @@ class TournamentModel
*/
public static function getWinners(int $tid): array
{
- $db = new Db();
- $winners = $db::getColumn('select uid from tournaments_users where tid = ? order by death_time desc limit 3', [$tid]);
+ $winners = Db::getColumn(
+ 'select uid from tournaments_users where tid = ? order by death_time desc limit 3', [$tid]
+ );
return [
1 => $winners[0],
2 => $winners[1],
- 3 => $winners[2]
+ 3 => $winners[2],
];
}
@@ -210,8 +205,8 @@ class TournamentModel
inner join battle_users bu on b.team_win != bu.team and b.id = bu.battle
inner join tournaments_users tu on bu.uid = tu.uid
where typeBattle = 25000 and death_time = 0 order by b.time_start desc limit 1';
- $db = new Db;
- $row = $db::getRow($query);
+
+ $row = Db::getRow($query);
return $row['uid'] ?? 0;
}
@@ -228,8 +223,9 @@ class TournamentModel
return;
}
//$winner_timer_add = $winner? 500 : 0; # Последный ДОЛЖЕН быть последним.
- $db = new Db();
- $db::sql('update tournaments_users set death_time = unix_timestamp() + 500 where death_time = 0 and uid = ?', [$uid]);
+ Db::sql(
+ 'update tournaments_users set death_time = unix_timestamp() + 500 where death_time = 0 and uid = ?', [$uid]
+ );
self::teleport($uid, 9);
//fixme: Классы не подключаются друг к другу. Нужно менять архитектуру игры. :(
Db::sql("update users_achiv set trn = trn + 1 where id = ?", [$uid]);
@@ -245,8 +241,7 @@ class TournamentModel
*/
public static function getTournamentIdByUserId(int $uid)
{
- $db = new Db();
- return $db::getValue('select tid from tournaments_users where uid = ?', [$uid]);
+ return Db::getValue('select tid from tournaments_users where uid = ?', [$uid]);
}
/**
@@ -262,18 +257,19 @@ class TournamentModel
*/
public static function startBattle(int $uid1, int $uid2): void
{
- $db = new Db();
$check = Db::getValue('select count(*) from users where id in (?, ?) and battle = 0', [$uid1, $uid2]);
if ($check !== 2) {
return;
}
- $db::exec('insert into battle (city, time_start, timeout, type, invis, noinc, travmChance, typeBattle)
- values (\'capitalcity\', unix_timestamp(), 60, 0, 1, 1, 0, 25000)');
- $bid = $db::lastInsertId(); // ВАЖНО!
- $db::sql('update stats set team = 1, hpNow = hpAll, mpNow = mpAll where id = ?', [$uid1]);
- $db::sql('update stats set team = 2, hpNow = hpAll, mpNow = mpAll where id = ?', [$uid2]);
- $db::sql('update users set battle = ? where id in (?, ?)', [$bid, $uid1, $uid2]);
+ Db::exec(
+ 'insert into battle (city, time_start, timeout, type, invis, noinc, travmChance, typeBattle)
+ values (\'capitalcity\', unix_timestamp(), 60, 0, 1, 1, 0, 25000)'
+ );
+ $bid = Db::lastInsertId(); // ВАЖНО!
+ Db::sql('update stats set team = 1, hpNow = hpAll, mpNow = mpAll where id = ?', [$uid1]);
+ Db::sql('update stats set team = 2, hpNow = hpAll, mpNow = mpAll where id = ?', [$uid2]);
+ Db::sql('update users set battle = ? where id in (?, ?)', [$bid, $uid1, $uid2]);
}
/**
@@ -285,8 +281,7 @@ class TournamentModel
*/
public static function uidToLogin(int $uid)
{
- $db = new Db();
- return $db::getValue('select login from users where id = ?', [$uid]);
+ return Db::getValue('select login from users where id = ?', [$uid]);
}
/**
@@ -299,8 +294,7 @@ class TournamentModel
*/
private static function teleport(int $uid, int $roomId): void
{
- $db = new Db();
- $db::sql('update users set room = ? where id = ?', [$roomId, $uid]);
+ Db::sql('update users set room = ? where id = ?', [$roomId, $uid]);
}
/**
@@ -315,12 +309,12 @@ class TournamentModel
if (empty($message)) {
return;
}
- $cmsg = new \ChatMessage();
+ $cmsg = new ChatMessage();
$cmsg->setDa(1);
$cmsg->setType(6);
$cmsg->setText($message);
$cmsg->setColor('forestgreen');
- (new \Chat())->sendMsg($cmsg);
+ (new Chat())->sendMsg($cmsg);
}
/**
@@ -337,10 +331,9 @@ class TournamentModel
values (4754, :uid, :data, 1, unix_timestamp(), unix_timestamp())';
$args = [
'uid' => $uid,
- 'data' => 'nosale=1|musor=1|sudba=' . self::uidToLogin($uid) . '|lvl=8|tr_s1=0|tr_s2=0|tr_s3=0|tr_s4=0'
+ 'data' => 'nosale=1|musor=1|sudba=' . self::uidToLogin($uid) . '|lvl=8|tr_s1=0|tr_s2=0|tr_s3=0|tr_s4=0',
];
- $db = new Db();
- $stmt = $db::prepare($query);
+ $stmt = Db::prepare($query);
for ($i = 0; $i < $quantity; $i++) {
$stmt->execute($args);
}
@@ -354,9 +347,8 @@ class TournamentModel
*/
public static function giveDelay(int $uid, int $unixtime): void
{
- $db = new Db();
$query = 'insert into eff_users (id_eff, uid, name, timeUse) VALUES (?,?,?,?)';
$args = [486, $uid, 'Призёр городского турнира!', $unixtime];
- $db::sql($query, $args);
+ Db::sql($query, $args);
}
}
diff --git a/_incl_data/class/Tournir.php b/_incl_data/class/Tournir.php
deleted file mode 100644
index b545fa3f..00000000
--- a/_incl_data/class/Tournir.php
+++ /dev/null
@@ -1,559 +0,0 @@
- 'Выжить любой ценой', 1 => 'Каждый сам за себя', 2 => 'Захват ключа',];
-
- public function __construct()
- {
- $this->u = User::start();
- $this->start();
- $this->locationSee();
- }
-
- private function start()
- {
- $this->info = Db::getRow('select * from turnirs where id = ?', [$this->u->info['inTurnirnew']]);
- $this->user = Db::getRow(
- 'select * from users_turnirs where turnir = ? and bot = ?',
- [$this->u->info['inTurnirnew'], $this->u->info['id']]
- );
- }
-
- private function startTurnir()
- {
- $row = Db::getValue('select count(*) from users where win = 0 and lose = 0 and nich = 0');
- if (!$row || $this->info['status'] == 3) {
- if ($this->info['status'] == 3) {
- $this->finishTurnir();
- }
- } else {
- Db::sql('update turnirs set status = 3 where id = ?', [$this->info['id']]);
- //Создание поединка
- Db::sql(
- 'insert into battle (city, time_start, timeout, type, turnir) values (?,unix_timestamp(),60,1,?)',
- [$this->u->info['city'], $this->info['id']]
- );
- $uri = Db::lastInsertId();
- //Закидываем персонажей в поединок
- Db::sql('update users set battle = ? where inUser = 0 and inTurnirnew = ?', [$uri, $this->info['id']]);
- //Обозначаем завершение турнира при выходе
- die('Перейтиде в раздел "поединки"...');
- }
- }
-
- private function finishTurnir()
- {
- $chat = new Chat();
- $cmsg = new ChatMessage();
- $cmsg->setType(6);
-
- $this->info = mysql_fetch_array(
- mysql_query('SELECT * FROM `turnirs` WHERE `id` = ' . $this->u->info['inTurnirnew'])
- );
- if ($this->info['status'] != 3) {
- return;
- }
- $win = '';
- $lose = '';
- $sp = mysql_query(
- 'SELECT * FROM `users_turnirs` WHERE `turnir` = "' . $this->info['id'] . '" ORDER BY `points` DESC'
- );
- while ($pl = mysql_fetch_array($sp)) {
- mysql_query('DELETE FROM `users_turnirs` WHERE `turnir` = "' . $this->info['id'] . '"');
- $inf = mysql_fetch_array(mysql_query('SELECT * FROM `users` WHERE `id` = "' . $pl['uid'] . '" LIMIT 1'));
- $bot = mysql_fetch_array(mysql_query('SELECT * FROM `users` WHERE `id` = "' . $pl['bot'] . '" LIMIT 1'));
- if (isset($inf['id'], $bot['id'])) {
- //выдаем призы и т.д
- mysql_query('DELETE FROM `users` WHERE `id` = "' . $bot['id'] . '" LIMIT 1');
- mysql_query('DELETE FROM `stats` WHERE `id` = "' . $bot['id'] . '" LIMIT 1');
- mysql_query('DELETE FROM `items_users` WHERE `uid` = "' . $bot['id'] . '" LIMIT 1000');
- mysql_query('DELETE FROM `eff_users` WHERE `uid` = "' . $bot['id'] . '" LIMIT 1000');
- }
-
- if ($pl['team'] == $this->info['winner'] && $this->info['winner'] != 0) {
- $inf['add_expp'] = [0, 1, 5, 10, 15, 25, 35, 70, 100, 150, 200, 300, 500, 700, 1000];
-
- //получаем опыт (с 0 по 12 лвл)
- $inf['add_expn'] = [10, 30, 55, 62, 92, 180, 350, 1350, 4500, 7000, 21000, 30000, 35000];
- $inf['add_expn'] = $inf['add_expn'][$inf['level']];
-
- mysql_query(
- 'UPDATE `users` SET `win` = `win` + 1,`win_t` = `win_t` + 1 WHERE `id` = "' . $inf['id'] . '" LIMIT 1'
- );
- mysql_query(
- 'UPDATE `stats` SET `exp` = `exp` + ' . $inf['add_expn'] . ' WHERE `id` = "' . $inf['id'] . '" LIMIT 1'
- );
- $win .= '' . $inf['login'] . ' , ';
-
- $cmsg->setRoom($inf['room']);
- $cmsg->setTo($inf['login']);
- $cmsg->setText("Турнир завершен. Вы являетесь победителем турнира, получено опыта: {$inf['add_expn']} .");
- $chat->sendMsg($cmsg);
-
- } elseif ($pl['team'] != $this->info['winner'] && $this->info['winner'] != 0) {
- mysql_query(
- 'UPDATE `users` SET `lose` = `lose` + 1,`lose_t` = `lose_t` + 1 WHERE `id` = "' . $inf['id'] . '" LIMIT 1'
- );
-
- $lose .= '' . $inf['login'] . ' , ';
- } else {
- mysql_query('UPDATE `users` SET `nich` = `nich` + 1 WHERE `id` = "' . $inf['id'] . '" LIMIT 1');
- }
- mysql_query('DELETE FROM `users_turnirs` WHERE `uid` = "' . $inf['id'] . '" LIMIT 1');
- }
- mysql_query(
- 'UPDATE `users` SET `inUser` = 0,`inTurnirnew` = 0 WHERE `inTurnirnew` = "' . $this->info['id'] . '" LIMIT ' . $this->info['users_in']
- );
- mysql_query(
- 'UPDATE `turnirs` SET `chat` = 4 , `winner` = -1,`users_in` = 0,`status` = 0,`winner` = -1,`step` = 0,`time` = "' . (time(
- ) + $this->info['time2']) . '",`count` = `count` + 1 WHERE `id` = ' . $this->info['id'] . ' LIMIT 1'
- );
-
- if ($win != '') {
- $win = rtrim($win, ', ');
- $lose = rtrim($lose, ', ');
- $win = 'Победители турнира: ' . $win . '. Проигравшая сторона: ' . $lose . '. Следующий турнир начнется через ' . $this->u->timeOut(
- $this->info['time2']
- ) . ' (' . date('d.m.Y H:i', (time() + $this->info['time2'])) . ').';
- } else {
- $win = 'Победители турнира отсутствует. Следующий турнир начнется через ' . $this->u->timeOut(
- $this->info['time2']
- ) . ' (' . date('d.m.Y H:i', (time() + $this->info['time2'])) . ').';
- }
-
- $cmsg->setText('Турнир завершен. ' . $win);
- $chat->sendMsg($cmsg);
- }
-
- private function locationSee()
- {
- $r = '';
- $tm1 = '';
- $tm2 = '';
- $noitm = [869 => 1, 1246 => 1, 155 => 1, 1245 => 1, 678 => 1];
-
- //получение комплекта
- if ($this->info['step'] != 3 && $this->info['step'] != 0 && isset($_GET['gocomplect']) && $this->user['points'] < 2) {
- $aso = explode(',', $this->user['items']);
- $ast = explode('-', $_GET['gocomplect']);
- $asg = [];
- $asj = [];
- $asgp = [];
-
- $i = 0;
- while ($i < count($aso)) {
- if ($aso[$i] > 0) {
- $asg[$aso[$i]] = true;
- }
- $i++;
- }
-
- $i = 0;
- $j = 0;
- $noitm = 0;
- $addi = 1;
- while ($i < count($ast)) {
- if ($ast[$i] > 0) {
- if (!$asg[$ast[$i]]) {
- $noitm++;
- }
- $itm = mysql_fetch_array(
- mysql_query(
- 'SELECT `id`,`inSlot`,`price1` FROM `items_main` WHERE `id` = "' . mysql_real_escape_string(
- $ast[$i]
- ) . '" LIMIT 1'
- )
- );
- if (isset($itm['id'])) {
- $itm2 = mysql_fetch_array(
- mysql_query(
- 'SELECT `iid`,`price_1` FROM `items_shop` WHERE `item_id` = "' . mysql_real_escape_string(
- $ast[$i]
- ) . '" AND `kolvo` > 0 LIMIT 1'
- )
- );
- if ($itm2['price_1'] > $itm['price1']) {
- $itm['price1'] = $itm2['price_1'];
- }
- if ($itm['inSlot'] == 3 || $itm['inSlot'] == 10) {
- $asg[$itm['inSlot']][count($asg[$itm['inSlot']])] = $itm['id'];
- $asgp[$itm['inSlot']][count($asgp[$itm['inSlot']])] = $itm['price1'];
- } else {
- $asg[$itm['inSlot']] = $itm['id'];
- $asp[$itm['inSlot']] = $itm['price1'];
- }
- $j++;
- }
- }
- $i++;
- }
-
- if ($noitm > 0) {
- echo 'Использование багов карается законом!';
- $addi = 0;
- } elseif (count($asg[3]) > 2) {
- echo 'Вы выбрали слишком много предметов, выберите только два оружия и один щит';
- $addi = 0;
- } elseif (count($asg[10]) > 3) {
- echo 'Вы выбрали слишком много предметов, выберите только три кольца';
- $addi = 0;
- } elseif ($j > 16) {
- echo 'Вы выбрали слишком много предметов';
- $addi = 0;
- } elseif ($j < 1) {
- echo 'Выберите хотя бы один предмет';
- $addi = 0;
- }
-
- if ($addi == 1) {
- $i = 0;
- while ($i <= 17) {
- if ($i == 10) {
- if ($asg[$i][0] > 0) {
- $this->u->addItem($asg[$i][0], $this->u->info['id']);
- $this->user['points'] += 1 + round($asgp[$i][0]);
- }
- if ($asg[$i][1] > 0) {
- $this->u->addItem($asg[$i][1], $this->u->info['id']);
- $this->user['points'] += 1 + round($asgp[$i][1]);
- }
- if ($asg[$i][2] > 0) {
- $this->u->addItem($asg[$i][2], $this->u->info['id']);
- $this->user['points'] += 1 + round($asgp[$i][2]);
- }
- } elseif ($i == 3) {
- if ($asg[$i][0] > 0) {
- $this->u->addItem($asg[$i][0], $this->u->info['id']);
- $this->user['points'] += 1 + round($asgp[$i][0]);
- }
- if ($asg[$i][1] > 0) {
- $this->u->addItem($asg[$i][1], $this->u->info['id']);
- $this->user['points'] += 1 + round($asgp[$i][1]);
- }
- } elseif ($asg[$i] > 0) {
- $this->u->addItem($asg[$i], $this->u->info['id']);
- $this->user['points'] += 1 + round($asgp[$i]);
- }
- $i++;
- }
-
- mysql_query(
- 'UPDATE `users_turnirs` SET `points` = "' . $this->user['points'] . '",`items` = "0" WHERE `bot` = "' . $this->u->info['id'] . '" LIMIT 1'
- );
- mysql_query(
- 'UPDATE `stats` SET `ability` = "100",`skills` = "10" WHERE `id` = "' . $this->u->info['id'] . '" LIMIT 1'
- );
- mysql_query('UPDATE `users` SET `level` = "12" WHERE `id` = "' . $this->u->info['id'] . '" LIMIT 1');
- mysql_query('UPDATE `turnirs` SET `step` = "0" WHERE `id` = "' . $this->info['id'] . '" LIMIT 1');
-
- $this->info['step'] = 0;
- $this->info['items'] = '0';
- }
- }
-
- if ($this->info['step'] == 3) {
- $this->finishTurnir();
- } elseif ($this->info['step'] == 0) {
- //распределяем команды
- $po = [0, 0];
- $sp = mysql_query(
- 'SELECT * FROM `users_turnirs` WHERE `turnir` = "' . $this->info['id'] . '" AND `points` > 3 ORDER BY `points` DESC LIMIT ' . $this->info['users_in']
- );
- $tmr = rand(1, 2);
- if ($tmr == 1) {
- $tmr = [2, 1];
- } else {
- $tmr = [1, 2];
- }
- while ($pl = mysql_fetch_array($sp)) {
- $inf = mysql_fetch_array(
- mysql_query('SELECT * FROM `users` WHERE `id` = "' . $pl['uid'] . '" LIMIT 1')
- );
- $bot = mysql_fetch_array(
- mysql_query('SELECT * FROM `users` WHERE `id` = "' . $pl['bot'] . '" LIMIT 1')
- );
- if (isset($inf['id'], $bot['id'])) {
- if ($po[1] == $po[2]) {
- $tm = rand(1, 2);
- } elseif ($po[1] > $po[2]) {
- $tm = 2;
- } else {
- $tm = 1;
- }
- //$tm = $tmr[$tm];
- $bot['team'] = $tm;
- $po[$bot['team']] += $pl['points'];
- mysql_query(
- 'UPDATE `stats` SET `team` = "' . $bot['team'] . '" WHERE `id` = "' . $bot['id'] . '" LIMIT 1'
- );
- mysql_query(
- 'UPDATE `users_turnirs` SET `team` = "' . $bot['team'] . '" WHERE `id` = "' . $pl['id'] . '" LIMIT 1'
- );
- }
- }
- mysql_query('UPDATE `turnirs` SET `step` = "1" WHERE `id` = "' . $this->info['id'] . '" LIMIT 1');
- }
-
- $sp = mysql_query(
- 'SELECT * FROM `users_turnirs` WHERE `turnir` = "' . $this->info['id'] . '" LIMIT ' . $this->info['users_in']
- );
- $po = [0, 0];
- while ($pl = mysql_fetch_array($sp)) {
- $inf = mysql_fetch_array(mysql_query('SELECT * FROM `users` WHERE `id` = "' . $pl['uid'] . '" LIMIT 1'));
- $bot = mysql_fetch_array(
- mysql_query(
- 'SELECT `u`.*,`st`.* FROM `users` AS `u` LEFT JOIN `stats` AS `st` ON `u`.`id` = `st`.`id` WHERE `u`.`id` = "' . $pl['bot'] . '" LIMIT 1'
- )
- );
- if (isset($inf['id'], $bot['id'])) {
- $po[$bot['team']] += $pl['points'];
- //${'tm'.$bot['team']} .= ''.$bot['login'].' ['.$bot['level'].'] ';
- ${'tm' . $bot['team']} .= $this->u->microLogin($bot, 2) . ' ';
- }
- }
- $r .= '';
- $r .= '«' . $this->name[$this->info['type']] . '» Начало турнира через ' . $this->u->timeOut(
- $this->info['time'] - time()
- ) . '! ';
-
- if (isset($_GET['hpregenNowTurnir']) && ($this->u->stats['hpNow'] < $this->u->stats['hpAll'] || $this->u->stats['mpNow'] < $this->u->stats['mpAll'])) {
- mysql_query(
- 'UPDATE `stats` SET `hpNow` = "' . $this->u->stats['hpAll'] . '",`mpNow` = "' . $this->u->stats['mpAll'] . '" WHERE `id` = "' . $this->u->info['id'] . '" LIMIT 1'
- );
- }
-
- if ($this->user['points'] < 3) {
- //Еще не получили обмундирование
- if ($this->user['points'] < 2) {
- $r .= ' ';
- } else {
- $r .= ' ';
- }
- } else {
- $r .= 'Вы участвуете в турнире! ';
- $r .= ' ';
- }
-
- $r .= '
';
- if ($this->user['points'] < 3 && $this->user['items'] != '0') {
- $r .= '
';
- if ($this->user['items'] == '') {
- //Выдаем предметы для выбора
- $ai = '';
-
- $sp = mysql_query(
- 'SELECT `a`.*,`b`.* FROM `items_shop` AS `a` LEFT JOIN `items_main` AS `b` ON (`a`.`item_id` = `b`.`id`) WHERE `a`.`sid` = 1 AND
- (`a`.`r` != 5 AND `a`.`r` != 9 AND `a`.`r` <= 18 AND `a`.`kolvo` > 0 AND `cantBuy` = 0 AND `a`.`level` < 9 AND `b`.`level` < 9) AND
- `b`.`class` != 6'
- );
- while ($pl = mysql_fetch_array($sp)) {
- if (!isset($noitm[$pl['item_id']])) {
- $aso[$pl['inslot']][count($aso[$pl['inslot']])] = $pl;
- }
- }
-
- $j = 1;
- $com = [];
- while ($j <= 5) {
- $i = 0;
- while ($i <= 17) {
- if ($i == 3) {
- //
- $com[$i] = $aso[$i][rand(0, count($aso[$i]) - 1)];
- } elseif ($i == 14) {
- //правая рука
- $com[$i] = $aso[$i][rand(0, count($aso[$i]) - 1)];
- } else {
- //обмундирование
- $com[$i] = $aso[$i][rand(0, count($aso[$i]) - 1)];
- if ($i == 10) {
- $ai .= $com[$i]['id'] . ',';
- $com[$i] = $aso[$i][rand(0, count($aso[$i]) - 1)];
- $ai .= $com[$i]['id'] . ',';
- }
- }
- if ($com[$i]['id'] > 0 && $i != 10) {
- $ai .= $com[$i]['id'] . ',';
- }
- $i++;
- }
- $j++;
- }
- unset($com);
-
- $ai .= '0';
- $this->user['items'] = $ai;
- mysql_query(
- 'UPDATE `users_turnirs` SET `items` = "' . $ai . '" WHERE `id` = "' . $this->user['id'] . '" LIMIT 1'
- );
- }
-
- //Выводим предметы чтобы надеть их
- $ai = explode(',', $this->user['items']);
- $i = 0;
- $ia = [];
- while ($i < count($ai)) {
- if ($ai[$i] > 0) {
- $pli = mysql_fetch_array(
- mysql_query(
- 'SELECT `id`,`inSlot`,`name`,`type`,`img`,`level` FROM `items_main` WHERE `id` = "' . $ai[$i] . '" LIMIT 1'
- )
- );
- $ia[$pli['inSlot']][count($ia[$pli['inSlot']])] = $pli;
- unset($pli);
- }
- $i++;
- }
- unset($ai);
-
- $r .= 'Выберите предметы для турнира: ';
- ?>
-
-
- 0) {
- $j = 0;
- while ($j < count($ia[$i])) {
- $r .= ' ';
- $j++;
- }
- $r .= ' ';
- }
- $i++;
- }
- }
- $r .= '
';
- $r .= '
-
- Команда 1
- Команда 2
-
-
- ' . rtrim($tm1, ', ') . '
- ' . rtrim($tm2, ', ') . '
-
-
';
-
- if (($this->info['time'] - time() < 0) && $this->info['step'] == 1) {
- //начинаем турнир
- $this->startTurnir();
- }
- echo $r;
- }
-}
diff --git a/_incl_data/class/User.php b/_incl_data/class/User.php
index f8e91a15..6e4a06e4 100644
--- a/_incl_data/class/User.php
+++ b/_incl_data/class/User.php
@@ -2599,7 +2599,7 @@ FROM `items_users` AS `iu` LEFT JOIN `items_main` AS `im` ON (`im`.`id` = `iu`.`
public function addNewbot($id, $botDate, $clon, $logins_bot = null, $luser = null, $round = null)
{
if ($clon != null) {
- $r = false;
+ $r = 0;
if (!is_array($clon)) {
$clon = $this->getUserInfoById((int)$clon);
}
@@ -11887,4 +11887,22 @@ LIMIT 1'
Db::sql('update users set online = unix_timestamp() where id = ?', [$uid]);
}
+ public function isModerator(): bool
+ {
+ return $this->isAdmin() || $this->info['align'] > 3 && $this->info['align'] < 4;
+ }
+
+ public function isAdmin(): bool
+ {
+ return $this->info['admin'] > 0;
+ }
+
+ /** Игрок имеет меньше 30% хп.
+ * @return bool
+ */
+ public function isWeakened(): bool
+ {
+ return $this->stats['hpNow'] < ceil($this->stats['hpMax'] / 100 * 30);
+ }
+
}
diff --git a/_incl_data/class/UserEffects.php b/_incl_data/class/UserEffects.php
new file mode 100644
index 00000000..994258f6
--- /dev/null
+++ b/_incl_data/class/UserEffects.php
@@ -0,0 +1,25 @@
+stats['hpNow']);
+ $hpAll = $u->stats['hpAll'];
+ $mpNow = floor($u->stats['mpNow']);
+ $mpAll = $u->stats['mpAll'];
+
+ //floor(120 / 100 * ($hpNow / $hpAll * 100)); // ??????
+ $ph = ($hpAll > 0 && $hpNow > 0) ? floor(120 / $hpNow / $hpAll) : 0;
+ $pm = ($mpAll > 0 && $mpNow > 0) ? floor(120 / $mpNow / $mpAll) : 0;
+
+ return (object)[
+ 'uid' => $u->info['id'],
+ 'login' => $u->microLogin($u->info['id']),
+ 'hpbarwidth' => $ph,
+ 'mpbarwidth' => $pm,
+ 'hpbartext' => ' ' . $hpNow . '/' . $hpAll,
+ 'mpbartext' => ' ' . $mpNow . '/' . $mpAll,
+ 'divstyle' => $pm === 0 ? ' margin-top:13px;' : '',
+ 'hasmana' => $mpAll > 0,
+ ];
+ }
}
\ No newline at end of file
diff --git a/ajax.php b/ajax.php
deleted file mode 100644
index fa89eb6c..00000000
--- a/ajax.php
+++ /dev/null
@@ -1,20 +0,0 @@
-'.$_GET['test'].' '.$_POST['test_post'].'';
- die();
-}
-echo 'Тест 1 ';
-?>
-
-
-Тест 2
-
-
-
-Протестировать запрос
\ No newline at end of file
diff --git a/css/stylesMobile.js b/css/stylesMobile.js
deleted file mode 100644
index aa4ec841..00000000
--- a/css/stylesMobile.js
+++ /dev/null
@@ -1,69 +0,0 @@
-
-// if (document.documentElement.clientWidth >= 414 && document.documentElement.clientWidth <= 736 ) {
-// console.log(document.documentElement.clientWidth)
-// console.log(document.documentElement.clientHeight)
-// // var $reline2 = document.getElementById("reline2")
-// var $chatMobile = document.getElementsByClassName("allChat")
-// var $arrayChatWindow = Array.from($chatMobile)
-
-// var $onlineList = document.getElementById("online_list")
-// var $online = document.getElementById("online")
-
-// var $chatList = document.getElementById("chat_list")
-// var $chat_menus = document.getElementById("chat_menus")
-// // var $cb1 = document.getElementById("cb1")
-// // var $cb2 = document.getElementById("cb2")
-
-// var $globalMain = document.getElementById("globalMain")
-
-
-
-// for (let key of $arrayChatWindow) {
-// key.hidden = true
-// }
-// // $reline2.hidden = true
-
-// // Кнопка показа чата
-// var $buttonChat = document.createElement("button")
-// $buttonChat.id = "buttonHiddenChat"
-// $buttonChat.textContent = "Показать чат"
-// // $buttonChat.style.width = "100%"
-// // $buttonChat.style.fontSize = "17pt"
-// // $buttonChat.style.position = "fixed"
-// $buttonChat.style.top = `${document.documentElement.clientHeight - 33}px`
-// document.body.append($buttonChat)
-
-// document.body.addEventListener("click", function (event) {
-// if (event.target == $buttonChat) {
-
-// if ($buttonChat.textContent == "Показать чат") {
-// $buttonChat.textContent = "Скрыть чат"
-
-// // for (let key of $arrayChatWindow) {
-// // key.hidden = false
-// // }
-
-// $arrayChatWindow[0].hidden = false
-
-// $onlineList.hidden = true
-// $online.hidden = true
-// // $chat_menus.display = "none"
-// // $chatList.style.width = "410px"
-
-// // var $p = document.createElement("p")
-// // $p.textContent = "Онлайн"
-
-// // document.getElementById("chat_menus").prepend(`Онлайн `)
-
-// return
-// }
-
-// $buttonChat.textContent = "Показать чат"
-// $arrayChatWindow[0].hidden = true
-
-// // for (let key of $arrayChatWindow) {
-// // key.hidden = true
-// // }
-// }
-// })
-// }
diff --git a/modules_data/__turnir.php b/modules_data/__turnir.php
deleted file mode 100644
index 649de50c..00000000
--- a/modules_data/__turnir.php
+++ /dev/null
@@ -1,278 +0,0 @@
- 'Выжить любой ценой',
- 1 => 'Каждый сам за себя',
- 2 => 'Захват ключа',
- ];
-
- public function start()
- {
- global $c, $u;
- $this->info = mysql_fetch_array(
- mysql_query('SELECT * FROM `turnirs` WHERE `id` = "' . $u->info['inTurnir'] . '" LIMIT 1')
- );
- $this->user = mysql_fetch_array(
- mysql_query(
- 'SELECT * FROM `users_turnirs` WHERE `turnir` = "' . $u->info['inTurnir'] . '" AND `bot` = "' . $u->info['id'] . '" LIMIT 1'
- )
- );
- }
-
- public function startTurnir()
- {
- global $c, $u;
- $row = mysql_fetch_array(
- mysql_query('SELECT COUNT(*) FROM `users` WHERE `win` = "0" AND `lose` = "0" AND `nich` = "0"')
- );
- if ($row[0] > 0 && $this->info['status'] != 3) {
- //Создание поединка
- mysql_query(
- 'INSERT INTO `battle` (`city`,`time_start`,`timeout`,`type`,`turnir`) VALUES ("' . $u->info['city'] . '","' . time(
- ) . '","60","1","' . $this->info['id'] . '")'
- );
- $uri = mysql_insert_id();
- //Закидываем персонажей в поединок
- mysql_query(
- 'UPDATE `users` SET `battle` = "' . $uri . '" WHERE `inUser` = "0" AND `inTurnir` = "' . $this->info['id'] . '"'
- );
- //Обозначаем завершение турнира при выходе
- mysql_query('UPDATE `turnirs` SET `status` = "3" WHERE `id` = "' . $this->info['id'] . '" LIMIT 1');
- die('Перейтиде в раздел "поединки"...');
- } else {
- if ($this->info['status'] == 3) {
- $this->finishTurnir();
- }
- }
- }
-
- public function finishTurnir()
- {
- global $c, $u;
- $this->info = mysql_fetch_array(
- mysql_query('SELECT * FROM `turnirs` WHERE `id` = "' . $u->info['inTurnir'] . '" LIMIT 1')
- );
- //mysql_query('UPDATE `users` SET `inUser` = 0, `inTurnir` = 0 WHERE `inTurnir` = '.$this->info['id'].' AND `inUser` > 0 LIMIT '.$this->info['users_in']);
- if ($this->info['status'] == 3) {
- $win = '';
-
- $sp = mysql_query(
- 'SELECT * FROM `users_turnirs` WHERE `turnir` = "' . $this->info['id'] . '" ORDER BY `points` DESC LIMIT ' . $this->info['users_in']
- );
- while ($pl = mysql_fetch_array($sp)) {
- $inf = mysql_fetch_array(
- mysql_query('SELECT * FROM `users` WHERE `id` = "' . $pl['uid'] . '" LIMIT 1')
- );
- $bot = mysql_fetch_array(
- mysql_query('SELECT * FROM `users` WHERE `id` = "' . $pl['bot'] . '" LIMIT 1')
- );
- if (isset($inf['id'], $bot['id'])) {
- //выдаем призы и т.д
- mysql_query('DELETE FROM `users` WHERE `id` = "' . $bot['id'] . '" LIMIT 1');
- mysql_query('DELETE FROM `stats` WHERE `id` = "' . $bot['id'] . '" LIMIT 1');
- mysql_query('DELETE FROM `items_users` WHERE `uid` = "' . $bot['id'] . '" LIMIT 1000');
- mysql_query('DELETE FROM `eff_users` WHERE `uid` = "' . $bot['id'] . '" LIMIT 1000');
- }
-
- if ($bot['win'] > 0 && $bot['lose'] < 1) {
- $win .= '' . $inf['login'] . ' , ';
- }
- }
- mysql_query(
- 'UPDATE `users` SET `inUser` = "0",`inTurnir` = "0" WHERE `inTurnir` = "' . $this->info['id'] . '" LIMIT ' . $this->info['users_in']
- );
- mysql_query(
- 'UPDATE `turnirs` SET `users_in` = 0,`status` = 0,`winner` = -1,`step` = 0,`time` = "' . (time(
- ) + $this->info['time2']) . '",`count` = `count` + 1 WHERE `id` = ' . $this->info['id'] . ' LIMIT 1'
- );
-
- if ($win != '') {
- $win = rtrim($win, ', ');
- $win = 'Победители турнира: ' . $win . '. Следующий турнир начнется через ' . $u->timeOut(
- $this->info['time2']
- ) . ' (' . date('d.m.Y H:i', (time() + $this->info['time2'])) . ').';
- } else {
- $win = 'Победители турнира отсутствует. Следующий турнир начнется через ' . $u->timeOut(
- $this->info['time2']
- ) . ' (' . date('d.m.Y H:i', (time() + $this->info['time2'])) . ').';
- }
- $r = 'Турнир «' . $this->name[$this->info['type']] . ' [' . $this->info['level'] . '] №' . $this->info['count'] . '» завершился! ' . $win;
- mysql_query(
- 'DELETE FROM `users_turnirs` WHERE `turnir` = "' . $this->info['id'] . '" LIMIT ' . $this->info['users_in']
- );
-
- $cmsg = new ChatMessage();
- $cmsg->setType(6);
- $cmsg->setText($r);
- (new Chat())->sendMsg($cmsg);
- }
- }
-
- public function locationSee()
- {
- global $c, $u;
-
- $r = '';
-
- $tm1 = '';
-
- $tm2 = '';
-
- if ($this->info['step'] != 3 && $this->info['step'] != 0) {
- //получение комплекта
- if (isset($_GET['gocomplect']) && $this->user['points'] < 2) {
-
- $aso = [];
- $noitm = [
- 869 => 1,
- ];
- $sp = mysql_query(
- 'SELECT `id`,`price1`,`inslot`,`price2` FROM `items_main` WHERE `inslot` > 0 AND `inslot` <= 26 AND `inslot` != 25 AND `inslot` != 24 AND `inslot` != 23 AND `inslot` != 16 AND `inslot` != 17 AND `inslot` != 2 AND `price2` = 0'
- );
- while ($pl = mysql_fetch_array($sp)) {
- if (!isset($noitm[$pl['id']])) {
- $aso[$pl['inslot']][count($aso[$pl['inslot']])] = $pl;
- }
- }
-
- $i = 0;
- $com = [];
- while ($i <= 17) {
- if ($i == 16) {
- //левая рука
-
- } elseif ($i == 17) {
- //правая рука
-
- } else {
- //обмундирование
- $com[$i] = $aso[$i][rand(0, count($aso[$i]))];
- }
- if ($com[$i]['id'] > 0) {
- $u->addItem($com[$i]['id'], $u->info['id']);
- $this->user['points'] += $com[$i]['price1'];
- }
- echo ',' . $com[$i];
- $i++;
- }
- mysql_query(
- 'UPDATE `users_turnirs` SET `points` = "' . $this->user['points'] . '" WHERE `bot` = "' . $u->info['id'] . '" LIMIT 1'
- );
- $this->info['step'] == 0;
- }
- }
-
- if ($this->info['step'] == 3) {
- $this->finishTurnir();
- } elseif ($this->info['step'] == 0) {
- //распределяем команды
- $po = [0, 0];
- $sp = mysql_query(
- 'SELECT * FROM `users_turnirs` WHERE `turnir` = "' . $this->info['id'] . '" ORDER BY `points` DESC LIMIT ' . $this->info['users_in']
- );
- $tmr = rand(1, 2);
- if ($tmr == 1) {
- $tmr = [2, 1];
- } else {
- $tmr = [1, 2];
- }
- while ($pl = mysql_fetch_array($sp)) {
- $inf = mysql_fetch_array(
- mysql_query('SELECT * FROM `users` WHERE `id` = "' . $pl['uid'] . '" LIMIT 1')
- );
- $bot = mysql_fetch_array(
- mysql_query('SELECT * FROM `users` WHERE `id` = "' . $pl['bot'] . '" LIMIT 1')
- );
- if (isset($inf['id'], $bot['id'])) {
- if ($po[1] == $po[2]) {
- $tm = rand(1, 2);
- } elseif ($po[1] > $po[2]) {
- $tm = 2;
- } else {
- $tm = 1;
- }
- //$tm = $tmr[$tm];
- $bot['team'] = $tm;
- $po[$bot['team']] += $pl['points'];
- mysql_query(
- 'UPDATE `stats` SET `team` = "' . $bot['team'] . '" WHERE `id` = "' . $bot['id'] . '" LIMIT 1'
- );
- mysql_query(
- 'UPDATE `users_turnirs` SET `team` = "' . $bot['team'] . '" WHERE `id` = "' . $pl['id'] . '" LIMIT 1'
- );
- }
- }
- mysql_query(
- 'UPDATE `turnirs` SET `step` = "1",`time` = "' . (time(
- ) + $this->info['time3']) . '" WHERE `id` = "' . $this->info['id'] . '" LIMIT 1'
- );
- }
-
- $sp = mysql_query(
- 'SELECT * FROM `users_turnirs` WHERE `turnir` = "' . $this->info['id'] . '" LIMIT ' . $this->info['users_in']
- );
- $po = [0, 0];
- while ($pl = mysql_fetch_array($sp)) {
- $inf = mysql_fetch_array(mysql_query('SELECT * FROM `users` WHERE `id` = "' . $pl['uid'] . '" LIMIT 1'));
- $bot = mysql_fetch_array(
- mysql_query(
- 'SELECT `u`.*,`st`.* FROM `users` AS `u` LEFT JOIN `stats` AS `st` ON `u`.`id` = `st`.`id` WHERE `u`.`id` = "' . $pl['bot'] . '" LIMIT 1'
- )
- );
- if (isset($inf['id'], $bot['id'])) {
- $po[$bot['team']] += $pl['points'];
- ${'tm' . $bot['team']} .= '' . $bot['login'] . ' [' . $bot['level'] . '], ';
- }
- }
- $r .= '';
- $r .= '«' . $this->name[$this->info['type']] . '» Начало турнира через ' . $u->timeOut(
- $this->info['time'] - time()
- ) . '! ';
-
- if ($this->user['points'] < 3) {
- //Еще не получили обмундирование
- if ($this->user['points'] < 2) {
- $r .= ' ';
- } else {
- $r .= ' ';
- }
- } else {
- $r .= 'Вы участвуете в турнире! ';
- }
- $r .= '
';
- $r .= 'Команда №1 : ' . rtrim($tm1, ', ');
- $r .= 'Команда №2 : ' . rtrim($tm2, ', ');
-
- if (($this->info['time'] - time() < 0) && $this->info['step'] == 1) {
- //начинаем турнир
- $this->startTurnir();
- }
-
- echo $r;
- }
-
-}
-
-$tur = new turnir;
-$tur->start();
diff --git a/modules_data/_newanimal.bac.php b/modules_data/_newanimal.bac.php
deleted file mode 100644
index 9e2ebace..00000000
--- a/modules_data/_newanimal.bac.php
+++ /dev/null
@@ -1,443 +0,0 @@
-
- var elem = document.getElementById('se-pre-con');
- elem.parentNode.removeChild(elem);
-
- ";
-if(!defined('GAME')) {
- die();
-}
-
-$slot = mysql_fetch_array(mysql_query('SELECT * FROM `users_animal_slot` WHERE `uid` = "'.$u->info['id'].'" LIMIT 1'));
-if(!isset($slot['id'])) {
- if( mysql_query('INSERT INTO `users_animal_slot` ( `uid`,`slots`,`ekr` ) VALUES ( "'.$u->info['id'].'","2","0" )') ) {
- $slot = mysql_fetch_array(mysql_query('SELECT * FROM `users_animal_slot` WHERE `uid` = "'.$u->info['id'].'" LIMIT 1'));
- }else{
- $u->error = 'Ошибка в работе базы данных...';
- }
-}
-
-$slot['price_next'] = 5;
-
-$petox = mysql_fetch_array(mysql_query('SELECT * FROM `obraz_pet` WHERE `uid` = "'.$u->info['id'].'" LIMIT 1'));
-$petox = $petox[0];
-
-$an_eda = array(
- 0.05,
- 0.07,
- 0.10,
- 0.15,
- 0.20,
- 0.30,
- 0.40,
- 0.50,
- 0.60,
- 0.70,
- 0.80,
- 1.00,
- 1.50,
- 2.00,
- 2.50,
- 3.00,
- 3.50,
- 4.00,
- 4.50,
- 5.00,
- 5.50,
- 7.00
-);
-
-function en_ru($txt) {
- $g = false;
- $en = preg_match("/^(([0-9a-zA-Z _-])+)$/i", $txt);
- $ru = preg_match("/^(([0-9а-яА-Я _-])+)$/i", $txt);
- if(($ru && $en) || (!$ru && !$en)) {
- $g = true;
- }
- return $g;
-}
-//
-function testBad($txt) {
- $white = '-_ 0123456789qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNMЁЙЦУКЕНГШЩЗХЪФЫВАПРОЛДЖЭЯЧСМИТЬБЮёйцукенгшщзхъфывапролджэячсмитьбю';
- $r = false;
- $i = 0;
- while( $i != -1 ) {
- if( isset($txt[$i]) ) {
- $g = false;
- $j = 0;
- while( $j != -1 ) {
- if(isset($white[$j])) {
- if( $white[$j] == $txt[$i] ) {
- $g = true;
- }
- }else{
- $j = -2;
- }
- $j++;
- }
- if( $g == false ) {
- $r = true;
- }
- }else{
- $i = -2;
- }
- $i++;
- }
- return $r;
-}
-
-function is_login_an($login) {
- $r = true;
- //
- $login = htmlspecialchars($login,NULL);
- //
- $bad = array(
- 'Мусорщик' => 1,
- 'Мироздатель' => 1
- );
- //
- //$login_db = mysql_fetch_array(mysql_query('SELECT `id` FROM `users` WHERE `login` = "'.mysql_real_escape_string($login).'" LIMIT 1'));
- //$login_an_db = mysql_fetch_array(mysql_query('SELECT `id` FROM `users_animal` WHERE `name` = "'.mysql_real_escape_string($login).'" LIMIT 1'));
- if( isset($login_db['id']) || isset($login_an_db['id']) || isset($bad[$login]) ) {
- $r = false;
- }else{
- $true = true;
- //
- /*
- Логин может содержать от 2 до 16 символов, и состоять только из букв русского ИЛИ английского алфавита, цифр, символов '_', '-' и пробела.
- Логин не может начинаться или заканчиваться символами '_', '-' или пробелом.
- */
- //
- $login = str_replace(' ',' ',$login);
- $login = str_replace('%',' ',$login);
- $login = str_replace(' ',' ',$login);
- //
- if( strlen($login) > 16 ) {
- $true = false;
- }elseif( strlen($login) < 2 ) {
- $true = false;
- }elseif( strripos($login,' ') == true ) {
- $true = false;
- }elseif( substr($login,1) == ' ' || substr($login,-1) == ' ' ) {
- $true = false;
- }elseif( substr($login,1) == '-' || substr($login,-1) == '-' ) {
- $true = false;
- }elseif( substr($login,1) == '_' || substr($login,-1) == '_' ) {
- $true = false;
- }elseif( testBad($login) == true ) {
- $true = false;
- }elseif( en_ru(str_replace('ё','е',str_replace('Ё','Е',$login))) == true ) {
- $true = false;
- }
- //
- if( $true == false ) {
- $r = false;
- }else{
- $r = true;
- }
- }
- return $r;
-}
-
-if(isset($_GET['buy_slot'])) {
- if($u->info['money2'] < $slot['price_nex']) {
- $u->error = 'Недостаточно денег';
- }elseif($u->info['money2'] < 5 ) {
- $u->error = 'Недостаточно екр!';
- }elseif( isset($slot['id']) && $slot['slots'] < 7 ) {
- $slot['slots']++;
- $u->info['money2'] -= 5;
- mysql_query('UPDATE `users_animal_slot` SET `slots` = "'.$slot['slots'].'" WHERE `id` = "'.$slot['id'].'" LIMIT 1');
- mysql_query('UPDATE `users` SET `money2` = "'.$u->info['money2'].'" WHERE `id` = "'.$u->info['id'].'" LIMIT 1');
- $u->error = 'Куплен слот для зверя.';
- }else{
- $u->error = 'Нельзя купить больше слотов';
- }
-}elseif(isset($_GET['pet'])) {
- $_GET['pet'] = round((int)$_GET['pet']);
- $_GET['petname'] = htmlspecialchars($_GET['petname'],NULL);
- $ax = mysql_fetch_array(mysql_query('SELECT COUNT(*) FROM `users_animal` WHERE `uid` = "'.$u->info['id'].'" AND `delete` = 0 LIMIT 1'));
- $ax = $ax[0];
- if( $_GET['pet'] < 1 || $_GET['pet'] > 7 ) {
- $u->error = 'Нельзя привзвать такого зверя';
- }elseif( $ax >= $slot['slots'] ) {
- $u->error = 'Нет свободных слотов для зверя';
- }elseif( $u->info['money'] < 50 ) {
- $u->error = 'Недостаточно денег';
- }elseif(is_login_an($_GET['petname']) == false) {
- $u->error = 'Неверная кличка зверя, выберите другую';
- }else{
- $u->error = 'Зверь пришел к Вам!';
- $u->info['money'] -= 50;
- mysql_query('UPDATE `users` SET `money` = "'.$u->info['money'].'" WHERE `id` = "'.$u->info['id'].'" LIMIT 1');
- //
- $anm['type'] = $_GET['pet'];
- //
- if($anm['type']==1)
- {
- $anm['name'] = 'Кот';
- $anm['sex'] = 0;
- $anm['obraz'] = array(1=>'20864.gif',2=>'21301.gif',3=>'21139.gif',4=>'20427.gif');
- $anm['stats'] = 's1=2|s2=5|s3=2|s4=5|rinv=40|m9=5|m6=10';
- }elseif($anm['type']==2)
- {
- $anm['name'] = 'Сова';
- $anm['sex'] = 1;
- $anm['obraz'] = array(1=>'21415.gif',2=>'21722.gif',3=>'21550.gif');
- $anm['stats'] = 's1=2|s2=2|s3=5|s4=5|rinv=40|m9=5|m6=10';
- }elseif($anm['type']==3)
- {
- $anm['name'] = 'Светляк';
- $anm['sex'] = 0;
- $anm['obraz'] = array(1=>'22277.gif',2=>'22265.gif',3=>'22333.gif',4=>'22298.gif');
- $anm['stats'] = 's1=3|s2=10|s3=3|s4=4|rinv=40|m9=5|m6=10';
- }elseif($anm['type']==4)
- {
- $anm['name'] = 'Чертяка';
- $anm['sex'] = 0;
- $anm['obraz'] = array(1=>'22177.gif',2=>'21976.gif',3=>'21877.gif');
- $anm['stats'] = 's1=25|s2=3|s3=3|s4=25|rinv=40|m9=5|m6=10';
- }elseif($anm['type']==5)
- {
- $anm['name'] = 'Пес';
- $anm['sex'] = 0;
- $anm['obraz'] = array(1=>'22352.gif',2=>'23024.gif',3=>'22900.gif',4=>'22501.gif',5=>'22700.gif');
- $anm['stats'] = 's1=5|s2=3|s3=3|s4=5|rinv=40|m9=5|m6=10';
- }elseif($anm['type']==6)
- {
- $anm['name'] = 'Свин';
- $anm['sex'] = 0;
- $anm['obraz'] = array(1=>'24000.gif',2=>'25000.gif',3=>'27000.gif',4=>'28000.gif');
- $anm['stats'] = 's1=5|s2=3|s3=3|s4=5|rinv=40|m9=5|m6=10';
- }elseif($anm['type']==7)
- {
- $anm['name'] = 'Дракон';
- $anm['sex'] = 0;
- $anm['obraz'] = array(1=>'21338_pgtpdbx.gif');
- $anm['stats'] = 's1=5|s2=3|s3=3|s4=5|rinv=40|m9=5|m6=10';
- }
- //
- $anm['name'] = $_GET['petname'];
- //
- $anm['obraz'] = $anm['obraz'][rand(1,count($anm['obraz']))];
- $anm['obraz'] = str_replace('.gif','',$anm['obraz']);
- $anm['obraz'] = str_replace('.jpg','',$anm['obraz']);
- $anm['obraz'] = str_replace('.png','',$anm['obraz']);
- $ins = mysql_query('INSERT INTO `users_animal` (`type`,`name`,`uid`,`obraz`,`stats`,`sex`,`eda`) VALUES ("'.$anm['type'].'","'.$anm['name'].'","'.$u->info['id'].'","'.$anm['obraz'].'","'.$anm['stats'].'","'.$anm['sex'].'","0")');
- if($ins)
- {
- $u->addDelo(1,$u->info['id'],'"System.inventory ": Персонаж призвал зверя "'.$_GET['petname'].'" ('.$_GET['pet'].') - 50 кр.',time(),$u->info['city'],'System.inventory',0,0);
- }else{
- $u->error = 'Не удалось призвать зверя, что-то здесь не так ...';
- }
- //
- }
- //
-}elseif(isset($_GET['eda'])) {
- $anm = mysql_fetch_array(mysql_query('SELECT * FROM `users_animal` WHERE `id` = "'.mysql_real_escape_string($_GET['eda']).'" AND `uid` = "'.$u->info['id'].'" AND `delete` = 0 LIMIT 1'));
- $x = round((int)$_GET['vvv']);
- if($x > 100 - $anm['eda']) { $x = 100 - $anm['eda']; }
- if($x < 1) { $x = 1; }
- if($x > 100) { $x = 100; }
- if(!isset($anm['id'])) {
- $u->error = 'Зверь не найден.';
- }elseif( $anm['eda'] >= 100 ) {
- $u->error = 'Зверь сыт и не нуждается в еде.';
- }elseif($an_eda[$anm['level']]*$_GET['vvv'] > $u->info['money']) {
- $u->error = 'Недостаточно денег.';
- }else{
- $u->error = 'Покормили зверя "'.$anm['name'].'" на '.$x.' ед. за '.($x*$an_eda[$anm['level']]).' кр.';
- $u->info['money'] -= ($x*$an_eda[$anm['level']]);
- $anm['eda'] += $x;
- mysql_query('UPDATE `users` SET `money` = "'.$u->info['money'].'" WHERE `id` = "'.$u->info['id'].'" LIMIT 1');
- mysql_query('UPDATE `users_animal` SET `eda` = "'.$anm['eda'].'" WHERE `id` = "'.$anm['id'].'" LIMIT 1');
- }
-}elseif(isset($_GET['pet_del'])) {
- if(mysql_query('UPDATE `users_animal` SET `delete` = "'.time().'" WHERE `id` = "'.mysql_real_escape_string($_GET['pet_del']).'" AND `delete` = 0 AND `uid` = "'.$u->info['id'].'" LIMIT 1')) {
- $u->error = 'Зверь был выгнан.';
- }else{
- $u->error = 'Зверь не найден.';
- }
-}elseif(isset($_GET['rename'])) {
- $anm = mysql_fetch_array(mysql_query('SELECT * FROM `users_animal` WHERE `id` = "'.mysql_real_escape_string($_GET['rename']).'" AND `uid` = "'.$u->info['id'].'" AND `delete` = 0 LIMIT 1'));
- $_GET['vvv'] = htmlspecialchars($_GET['vvv'],NULL);
- if(!isset($anm['id'])) {
- $u->error = 'Зверь не найден.';
- }elseif(30 > $u->info['money']) {
- $u->error = 'Недостаточно денег.';
- }else{
- $u->info['money'] -= 30;
- $anm['name'] = $_GET['vvv'];
- $u->error = 'Кличка зверя изменена на "'.$anm['name'].'" за 30 кр.';
- mysql_query('UPDATE `users` SET `money` = "'.$u->info['money'].'" WHERE `id` = "'.$u->info['id'].'" LIMIT 1');
- mysql_query('UPDATE `users_animal` SET `name` = "'.$anm['name'].'" WHERE `id` = "'.$anm['id'].'" LIMIT 1');
- }
-}elseif(isset($_GET['shadow']) && $petox > 0) {
- if(isset($_GET['rechange'])) {
- $u->error = 'Образ питомца снят.';
- mysql_query('UPDATE `obraz_pet` SET `use` = 0 WHERE `uid` = "'.$u->info['id'].'"');
- }elseif(isset($_GET['change'])) {
- $u->error = 'Образ питомца установлен.';
- mysql_query('UPDATE `obraz_pet` SET `use` = 0 WHERE `uid` = "'.$u->info['id'].'"');
- mysql_query('UPDATE `obraz_pet` SET `use` = 1 WHERE `uid` = "'.$u->info['id'].'" AND `id` = "'.mysql_real_escape_string($_GET['change']).'" LIMIT 1');
- }
-}
-?>
-
-Ваши деньги: =$u->info['money']?> кр.
-
- 0 ) {
- echo 'Образ ';
- }else{
- echo 'Образ ';
- }
- ?>
- Обновить
- Вернуться
-
- Обновить
- Вернуться
-
-
-error != '' ) {
- echo ''.$u->error.'
';
-}
-?>
-
-
diff --git a/modules_data/_ref_OLD.php b/modules_data/_ref_OLD.php
deleted file mode 100644
index 3e86aba0..00000000
--- a/modules_data/_ref_OLD.php
+++ /dev/null
@@ -1,171 +0,0 @@
-info['id'].'" AND `mail` != "No E-Mail" LIMIT 1000'));
-$rfs['count'] = 0+$rfs['count'][0];
-$rfs['c'] = 1;
-$rfs['data'] = explode('|',$u->info['ref_data']);
-if(isset($_POST['r_bank']) || isset($_POST['r_type']))
-{
- $bnk = mysql_fetch_array(mysql_query('SELECT * FROM `bank` WHERE `id` = "'.mysql_real_escape_string($_POST['r_bank']).'" AND `uid` = "'.$u->info['id'].'" AND `block` = "0" LIMIT 1'));
- if(!isset($bnk['id']))
- {
-
- }else{
- if($_POST['r_type']==1){ $_POST['r_type'] = 1; }else{ $_POST['r_type'] = 2; }
- $u->info['ref_data'] = $bnk['id'].'|'.$_POST['r_type'];
- $rfs['data'] = explode('|',$u->info['ref_data']);
- mysql_query('UPDATE `stats` SET `ref_data` = "'.mysql_real_escape_string($u->info['ref_data']).'" WHERE `id` = "'.$u->info['id'].'" LIMIT 1');
- }
-}
-$rfs['see'] = '';
-$sp = mysql_query('SELECT `s`.`active`,`u`.`online`,`u`.`id`,`u`.`level` FROM `users` AS `u` LEFT JOIN `stats` AS `s` ON `u`.`id` = `s`.`id` WHERE `u`.`host_reg` = "'.$u->info['id'].'" AND `u`.`mail` != "No E-Mail" ORDER BY `u`.`level` DESC LIMIT '.$rfs['count']);
-while($pl = mysql_fetch_array($sp))
-{
- $rfs['c2'] = ' '.$rfs['c'].'. '.$u->microLogin($pl['id'],1).'';
- if($pl['active']!='')
- {
- $rfs['c2'] = ''.$rfs['c2'].' не активирован ';
- }elseif($pl['level']>5)
- {
- $rfs['c2'] = ''.$rfs['c2'].' ';
- }
- if($pl['online'] >time()-520) {
- $rfs['c2'] .= ' ONLINE ';
- }
- $rfs['see'] .= $rfs['c2'].' ';
- $rfs['c']++;
-}
-if($rfs['see']=='')
-{
- $rfs['see'] = 'К сожалению у Вас нет рефералов ';
-}
-?>
-
diff --git a/modules_data/_zv.php b/modules_data/_zv.php
index f7f2680d..3b3ab88c 100644
--- a/modules_data/_zv.php
+++ b/modules_data/_zv.php
@@ -2,38 +2,56 @@
use Core\Config;
use Core\Db;
-
-require_once dirname(__DIR__) . DIRECTORY_SEPARATOR . '_incl_data/autoload.php';
+use Tournament\Tournament;
+use Tournament\TournamentModel;
if (!defined('GAME')) {
die();
}
-
-if (isset($_GET['r'])) {
- $_GET['r'] = (int)$_GET['r'];
-} else {
- $_GET['r'] = null;
-}
-
-if ($_GET['r'] == 3 || $_GET['r'] == 8 || !isset($_GET['r'])) {
- $_GET['r'] = 2;
-}
-
/** @var User $u */
if ($u->info['inTurnir'] > 0 && $u->info['inUser'] == 0 && $u->info['room'] == 318) {
die('');
}
$zv = new FightRequest();
+
+// Турниры по умолчанию.
+// 4-group,5-chaos,6-current,7-ended,10-tournament
+$r = (int)$_GET['r'] ??= FightRequest::BATTLE_RAZDEL_TOURNAMENTS;
+
+
$js_5356 = sprintf(
"top.lafstReg[%d] = 0; top.startHpRegen(\"main\",%d,%d,%d,%d,%d,%d,%d,%d,%d,1);",
- $u->info['id'], $u->info['id'], 0 + $u->stats['hpNow'], 0 + $u->stats['hpAll'],
- 0 + $u->stats['mpNow'], 0 + $u->stats['mpAll'], time() - $u->info['regHP'], time() - $u->info['regMP'],
- 0 + $u->rgd[0], 0 + $u->rgd[1]
+ $u->info['id'],
+ $u->info['id'],
+ $u->stats['hpNow'],
+ $u->stats['hpAll'],
+ $u->stats['mpNow'],
+ $u->stats['mpAll'],
+ time() - $u->info['regHP'],
+ time() - $u->info['regMP'],
+ $u->rgd[0],
+ $u->rgd[1]
);
$code ??= PassGen::intCode();
+$userinfo = UserStats::getLoginHpManaBars($u);
+$slogin = null;
+$dt = null;
+$dateformatter = null;
+if ($r === FightRequest::BATTLE_RAZDEL_ENDED) {
+ $dateformatter = new IntlDateFormatter(
+ 'ru_RU',
+ IntlDateFormatter::LONG,
+ IntlDateFormatter::NONE
+ );
+ $dt = $_GET['logs2'] ??= time();
+ $slogin = $_GET['filter'] ?? $_POST['filter'] ?? $u->info['login'];
+ $slogin = str_replace('"', '', $slogin);
+ $slogin = str_replace("'", '', $slogin);
+ $slogin = str_replace('\\', '', $slogin);
+}
?>
info['battle'] == 0) {
- if (isset($_POST['add_new_zv'])) {
- $zv->add();
- } elseif (isset($_GET['bot']) && ($u->info['level'] <= 7 || $u->info['admin'] > 0)) {
- $zv->addBot();
- } elseif (isset($_GET['bot_clone'])) {
- $zvclone = Db::getValue(
- 'select id from users where admin = 0 and `real` = 1 and login = ?',
- [$_GET['bot_clone']]
- );
- $zv->addBotClone($zvclone['id']);
- } elseif (isset($_GET['add_group'])) {
- $zv->add();
- } elseif (isset($_GET['start_haot'])) {
- $zv->add();
- }
+ if (
+ $u->info['battle'] == 0 &&
+ (isset($_GET['add_group']) || isset($_GET['start_haot']))
+ ) {
+ $zv->addGroupOrChaoticRequest($r);
}
if ($u->info['zv'] != 0) {
- $zi = Db::getRow('select id, razdel from zayvki where id = ? and start = 0 and cancel = 0 and time > unix_timestamp() - 60 * 60 * 2 or razdel > 3', [$u->info['zv']]);
+ //fixme результаты этого запроса используются в методах класса FightRequest как global $zi.
+ $zi = Db::getRow(
+ 'select * from zayvki where id = ? and start = 0 and cancel = 0 and time > unix_timestamp() - 60 * 60 * 2 or razdel > 3',
+ [$u->info['zv']]
+ );
if (!isset($zi['id'])) {
- $zi = false;
+ $zi = [];
$u->info['zv'] = 0;
Db::sql('update stats set zv = 0 where id = ?', [$u->info['id']]);
}
@@ -138,7 +223,10 @@ $code ??= PassGen::intCode();
if ($u->info['battle'] == 0) {
if (isset($_POST['groupClick']) && !isset($zi['id'])) {
- $zg = Db::getRow('select * from zayvki where id = ? and start = 0 and cancel = 0 and time > unix_timestamp() - 60 * 60 * 2 and btl_id = 0 and razdel = 4', [(int)$_POST['groupClick']]);
+ $zg = Db::getRow(
+ 'select * from zayvki where id = ? and start = 0 and cancel = 0 and time > unix_timestamp() - 60 * 60 * 2 and btl_id = 0 and razdel = 4',
+ [(int)$_POST['groupClick']]
+ );
if (!isset($zg['id'])) {
echo '
Заявка на групповой бой не найдена.
';
} else {
@@ -147,9 +235,14 @@ $code ??= PassGen::intCode();
$tm1 = '';
$tm2 = '';
$tm3 = '';
- $users = Db::getRow('select users.id, login, level, align, clan, admin, team from users left join stats on users.id = stats.id where zv = ?', [$zg['id']]);
+ $users = Db::getRow(
+ 'select users.id, login, level, align, clan, admin, team from users left join stats on users.id = stats.id where zv = ?',
+ [$zg['id']]
+ );
foreach ($users as $user) {
- ${'tm' . $user['team']} .= '
' . $user['login'] . ' [' . $user['level'] . ']
';
+ ${'tm' . $user['team']} .= '
' . $user['login'] . ' [' . $user['level'] . ']
';
}
if (empty($tm1)) {
$tm1 = 'группа пока не набрана';
@@ -187,10 +280,10 @@ $code ??= PassGen::intCode();
Бой начнется через = $tm_start; ?> мин.
-
+ onclick="location.href='main.php?zayvka&r== $r; ?>&rnd== $code; ?>';">
@@ -233,12 +326,12 @@ $code ??= PassGen::intCode();
cancelzv();
} elseif (isset($_GET['startBattle']) && isset($zi['id']) && ($zi['razdel'] >= 1 && $zi['razdel'] <= 3)) {
$zv->startBattle($zi['id']);
}
}
-if (isset($_POST['btl_go'])) {
- $zv->go($_POST['btl_go']);
-} elseif (isset($_GET['btl_go'])) {
- $zv->go($_GET['btl_go']);
-}
+$btl_go = (int)$_POST['btl_go'] ?? (int)$_GET['btl_go'] ?? 0;
+$zv->go($btl_go);
if ($zv->error) {
echo '' . $zv->error . ' ';
}
-if ($zv->test_s) {
- echo '' . $zv->test_s . ' ';
-}
?>
- see(); ?>
+
+ room['zvsee'] == 0): ?>
+
+
+ Подать заявку на групповой бой
+
+
+ room['zvsee'] == 0): ?>
+
+
+
+
+
+ Записи текущих боев на = date('d.m.Y'); ?>
+ getCurrentBattlesList(); ?>
+
+
+ getEndedBattlesList($slogin, $dt); ?>
+
+
+
+
Внимание!
+
+ В случае создания либо присоединения к Турниру, покинуть его -
+ невозможно !
+
+ info['id'])): ?>
+ Стоимость предметов, одетых на вас не должна
+ превышать = Tournament::ekrOverpriceFormula($u->info['level']) ?> еврокредитов.
+
+
+ info['exp'] < Tournament::MIN_EXP): ?>
+ У вас должно быть не менее = Tournament::MIN_EXP ?> опыта.
+
+ Турнир начнётся, когда в заявке
+ наберётся = Tournament::START_TOURNAMENT ?> человек.
+
+ Игроки занявшие 1, 2 и 3 места получат 25, 15, 5 Реликвий
+ Ангела, а так же задержки на участие в турнире 12 часов, 6 и 3 часа соответственно!
+
+
+
+ getTournaments(); ?>
+ hasTournaments): ?>
+
+ Активные турниры.
+ = $trn->listTournaments ?>
+
+
+ u->info['id']
+ ) || !TournamentModel::isStarted($this->u->info['level'])): ?>
+
+
+ Вы учавствуете.
+
+
+ В данный момент турниры не проводятся!
+
+
+ nan
+
+ getCurrentStatus($zi, $r); ?>
+
- seeZv(); ?>
+ seeZv($zi, $r); ?>
-
-
+
+
= Config::get('counters') ?>
diff --git a/modules_data/_zv2.php b/modules_data/_zv2.php
deleted file mode 100644
index 9861e68a..00000000
--- a/modules_data/_zv2.php
+++ /dev/null
@@ -1,64 +0,0 @@
-
- var elem = document.getElementById('se-pre-con');
- elem.parentNode.removeChild(elem);
-
- ";
-if(!defined('GAME'))
-{
- die();
-}
-
-if(isset($_GET['r']))
-{
- $_GET['r'] = (int)$_GET['r'];
-}else{
- $_GET['r'] = NULL;
-}
-
-$u->info['referals'] = mysql_fetch_array(mysql_query('SELECT COUNT(`id`) FROM `register_code` WHERE `uid` = "'.$u->info['id'].'" AND `time_finish` > 0 AND `end` = 0 LIMIT 1000'));
-$u->info['referals'] = $u->info['referals'][0];
-
-$zv = new FightRequest();
-
-?>
-
-
-
-
-
- = $zv->see(); ?>
-
-
- seeZv(); ?>
-
-
-
-
-
diff --git a/modules_data/location/turnir.php b/modules_data/location/turnir.php
deleted file mode 100644
index 80da5e6b..00000000
--- a/modules_data/location/turnir.php
+++ /dev/null
@@ -1,10 +0,0 @@
-room['file'] != 'turnir') {
- return;
-}
-$tur = new Tournir();