game/_incl_data/class/Location/DeathTower.php

173 lines
8.2 KiB
PHP
Raw Blame History

<?php
namespace Location;
use Chat;
use ChatMessage;
use Delo;
use User;
class DeathTower
{
public static function finish($id, $bu, $di)
{
$user = User::start();
if ($bu) {
/* <20> <20><><EFBFBD><EFBFBD> <20><><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
$i = 0;
while ($i < count($bu[$i])) {
if ($bu[$i]['lose'] > 0 || $bu[$i]['nich']) {
mysql_query(
'UPDATE `users` SET `lose` = "' . $bu[$i]['lose'] . '", `nick` = "' . $bu[$i]['nich'] . '" WHERE `id` = "' . $bu[$i]['id'] . '" LIMIT 1'
);
mysql_query(
'UPDATE `bs_turnirs` SET `users_finish` = `users_finish` + 1 WHERE `id` = "' . $id['id'] . '" LIMIT 1'
);
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD> */
if ($bu['inBot'] == 0) {
$pls1 = mysql_fetch_array(
mysql_query(
'SELECT `id`, `bsid`, `money`, `finish`, `time`, `inBot`, `uid` FROM `bs_zv` WHERE `bsid` = "' . $id['id'] . '" AND `finish` = 0 AND `time` = "' . $id['time_start'] . '" AND `inBot` = "' . $bu[$i]['id'] . '" LIMIT 1'
)
);
if (isset($pls1['id'])) {
mysql_query('DELETE FROM `users` WHERE `id` = "' . $bu[$i]['id'] . '" LIMIT 1');
mysql_query('DELETE FROM `stats` WHERE `id` = "' . $bu[$i]['id'] . '" LIMIT 1');
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> <20><><EFBFBD><EFBFBD><EFBFBD>
$spi = mysql_query(
'SELECT `id`,`item_id` FROM `items_users` WHERE `uid` = "' . $bu[$i]['id'] . '" LIMIT 500'
);
$ins = '';
while ($pli = mysql_fetch_array($spi)) {
$ins .= '("' . $di['dn_id'] . '","' . $pli['item_id'] . '","' . time(
) . '","' . $di['x'] . '","' . $di['y'] . '"),';
}
$ins = rtrim($ins, ',');
mysql_query(
'INSERT INTO `dungeon_items` (`dn`,`item_id`,`time`,`x`,`y`) VALUES ' . $ins . ''
);
mysql_query('DELETE FROM `items_users` WHERE `uid` = "' . $pls1['inBot'] . '" LIMIT 1');
mysql_query('DELETE FROM `eff_users` WHERE `uid` = "' . $pls1['inBot'] . '" LIMIT 1');
mysql_query(
'UPDATE `bs_zv` SET `finish` = "' . time(
) . '" WHERE `id` = "' . $pls1['id'] . '" LIMIT 1'
);
mysql_query('UPDATE `users` SET `inUser` = 0 WHERE `id` = "' . $pls1['uid'] . '" LIMIT 1');
}
}
$id['users_finish']++;
}
$i++;
}
}
if ($id['users'] - $id['users_finish'] >= 2) {
return;
}
$win = [];
$sp = mysql_query(
'SELECT `id`,`bsid`,`money`,`finish`,`time`,`inBot`,`uid` FROM `bs_zv` WHERE `bsid` = "' . $id['id'] . '" AND `finish` = "0" AND `time` = "' . $id['time_start'] . '" ORDER BY `money` DESC LIMIT 100'
);
while ($pl = mysql_fetch_array($sp)) {
$ur = mysql_fetch_array(
mysql_query(
'SELECT `id`,`login`,`room`,`name`,`sex`,`inUser`,`twink`,`lose`,`nich`,`win` FROM `users` WHERE `id` = "' . $pl['uid'] . '" LIMIT 1'
)
);
$ub = mysql_fetch_array(
mysql_query(
'SELECT `id`,`login`,`room`,`name`,`sex`,`inUser`,`twink`,`lose`,`nich`,`win` FROM `users` WHERE `id` = "' . $ur['inUser'] . '" LIMIT 1'
)
);
if (isset($ur['id']) && isset($ub['id']) && $ub['lose'] <= 0 && $ub['nich'] <= 0) {
$win = $ub;
$winr = $ur;
}
}
$chat = new Chat();
$cmsg = new ChatMessage();
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><> */
if (isset($win['id']) && $win['lose'] == 0 && $win['nich'] == 0 && $win['id'] > 0) {
//<2F><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
$bsep = 0;
if ($winr['level'] < 6) {
$bsep = 2500;
} elseif ($winr['level'] < 7) {
$bsep = 5000;
} elseif ($winr['level'] < 8) {
$bsep = 15000;
} elseif ($winr['level'] < 9) {
$bsep = 25000;
} else {
$bsep = 50000;
}
/* <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD> */
$mn = (round($id['money'] / 100 * 85));
mysql_query(
'UPDATE `users` SET `money` = `money` + "' . $mn . '" WHERE `id` = "' . $winr['id'] . '" LIMIT 1'
);
mysql_query(
'UPDATE `stats` SET `exp` = `exp` + "' . $bsep . '" WHERE `id` = "' . $winr['id'] . '" LIMIT 1'
);
/* <20><><EFBFBD> */
$cmsg->setTo($winr['login']);
$cmsg->setText(
"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>! <20><> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> &quot;<3B><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>&quot;! <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>: $bsep, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: $mn <20><>."
);
$cmsg->setType(6);
$chat->sendMsg($cmsg);
$cmsg->setTo('');
$cmsg->setIsAlert(true);
$cmsg->setText(
"<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> &quot;<3B><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>&quot;, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <strong>{$winr['login']}</strong>! <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>!"
);
$cmsg->setType(5);
$chat->sendMsg($cmsg);
Delo::add(
1,
'WinTournament.' . $user->info['city'],
$uid,
'&quot;<span style="color: #C65F00; ">WinTournament.' . $user->info['city'] . '</span>&quot; (<28><><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>): <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> &quot;<strong>' . $mn . '</strong> <20><>.&quot;',
);
} else {
/* <20><><EFBFBD> */
$cmsg->setIsAlert(true);
$cmsg->setType(5);
$cmsg->setText('<27><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>: <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>.');
}
$sp = mysql_query(
'SELECT `id`,`bsid`,`money`,`finish`,`time`,`inBot`,`uid` FROM `bs_zv` WHERE `bsid` = "' . $id['id'] . '" AND `time` = "' . $id['time_start'] . '" ORDER BY `money` DESC LIMIT 100'
);
while ($pl = mysql_fetch_array($sp)) {
$ur = mysql_fetch_array(
mysql_query(
'SELECT `id`,`login`,`room`,`name`,`sex`,`inUser`,`lose`,`nich`,`win` FROM `users` WHERE `id` = "' . $pl['uid'] . '" LIMIT 1'
)
);
$ub = mysql_fetch_array(
mysql_query(
'SELECT `id`,`login`,`room`,`name`,`sex`,`inUser`,`lose`,`nich`,`win` FROM `users` WHERE `id` = "' . $ur['inUser'] . '" LIMIT 1'
)
);
if (isset($ub['id'])) {
//del
mysql_query('DELETE FROM `users` WHERE `id` = "' . $ub['id'] . '" LIMIT 1');
mysql_query('DELETE FROM `stats` WHERE `id` = "' . $ub['id'] . '" LIMIT 1');
mysql_query('DELETE FROM `items_users` WHERE `uid` = "' . $ub['id'] . '" LIMIT 500');
mysql_query('DELETE FROM `eff_users` WHERE `uid` = "' . $ub['id'] . '" LIMIT 500');
//upd
mysql_query(
'UPDATE `bs_zv` SET `finish` = "' . time() . '" WHERE `id` = "' . $pl['id'] . '" LIMIT 1'
);
mysql_query('UPDATE `users` SET `inUser` = 0 WHERE `id` = "' . $pl['uid'] . '" LIMIT 1');
}
}
}
}