Файл: 3/clan_podzemelie.php
Строк: 428
<?
require_once ('system/func.php');
auth();
$clan = mysql_fetch_assoc(mysql_query("SELECT * FROM `clans` WHERE `id` = '$user[id_clan]'"));
$batlle = mysql_fetch_assoc(mysql_query("SELECT * FROM `clan_podzemelie` WHERE `id_clan` = '$clan[id]' ORDER BY `id` DESC LIMIT 1"));
$batlle_user = mysql_fetch_assoc(mysql_query("SELECT * FROM `clan_podzemelie_users` WHERE `id_batlle` = '$batlle[id]'"));
switch($_GET['act']){
case 'reid':
$id = num($_GET['id']);
$reid = mysql_fetch_assoc(mysql_query("SELECT * FROM `clan_podzemelie_reid` WHERE `id` = '$id'"));
if(!$reid or $clan['level'] < $reid['clan_level'] or $batlle['last'] > time()){
header('Location: /clan/podzemelie/');
exit();
}
$title = $reid['name'];
require_once ('system/header.php');
echo "<div class='block center'>";
echo "<span class='money'><b>$reid[name]</b></span>$separ";
$boss = mysql_query("SELECT * FROM `clan_podzemelie_reid_boss` WHERE `id_reid` like '%$reid[id]%' ORDER BY `id` DESC LIMIT 2");
while($boss_ank = mysql_fetch_assoc($boss)){
echo "<img src='/images/clan/boss/$boss_ank[id].png'> ";
}
echo "".$separ."Награда за победу:<br>По ".ico('icons','gold.png')." $reid[gold_user] игрокам и ".ico('icons','gold.png')." $reid[gold_clan] клану!";
echo $separ;
$p1 = mysql_query("SELECT * FROM `users` WHERE `id_clan` = '$clan[id]' AND `fix_url` like '/clan/podzemelie/reid/$reid[id]/%' ORDER BY `clan_rang` DESC, `clan_exp` DESC LIMIT 1");
$p1 = mysql_fetch_assoc($p1);
if($p1['id'] == $myID){
if(isset($_GET['nachat_reid'])){
$boss = mysql_fetch_assoc(mysql_query("SELECT * FROM `clan_podzemelie_reid_boss` WHERE `id_reid` like '%$reid[id]%' ORDER BY `id` ASC LIMIT 1"));
mysql_query("INSERT INTO `clan_podzemelie` SET `id_clan` = '$clan[id]', `id_reid` = '$reid[id]', `last` = '".(time()+10)."', `start` = '1', `id_boss` = '$boss[id]', `boss_health` = '$boss[health]'");
$id_batlle = mysql_insert_id();
$q = mysql_query("SELECT * FROM `users` WHERE `id_clan` = '$clan[id]' AND `fix_url` like '/clan/podzemelie/reid/$reid[id]/%' ORDER BY `clan_rang` DESC, `clan_exp` DESC LIMIT 10");
while($post = mysql_fetch_assoc($q)){
mysql_query("INSERT INTO `clan_podzemelie_users` SET `id_user` = '$post[id]', `id_batlle` = '$id_batlle', `max_health` = '$post[max_health]', `health` = '$post[max_health]'");
}
header('Location: /clan/podzemelie/');
exit();
}
echo "<a href='?nachat_reid' class='btn2'>Начать рейд</a><br>";
}
echo "<a href='?' class='btn2'>Обновить</a>";
echo $separ;
$k_users = mysql_result(mysql_query("SELECT COUNT(*) FROM `users` WHERE `id_clan` = '$clan[id]' AND `fix_url` like '/clan/podzemelie/reid/$reid[id]/%'"),0);
echo "Участники боя $k_users из 10<br>";
$q = mysql_query("SELECT * FROM `users` WHERE `id_clan` = '$clan[id]' AND `fix_url` like '/clan/podzemelie/reid/$reid[id]/%' ORDER BY `clan_rang` DESC, `clan_exp` DESC LIMIT 10");
echo "<table cellpadding='5' cellspacing='0' align='center'>";
while($post = mysql_fetch_assoc($q)){
$i++;
echo "<tr><td class='center' style='border-right: 1px solid #8D673A;' width='50%'>".icons_user($post['id'])." <span class='white'>$post[login]</span></td><td>".ico('icons','sum_stat.png')." ".($i == 1 ? "<span class='money'><b>Старший</b></span>" : "<span class='white'>".($post['str']+$post['def']+$post['max_health'])."</span>")."</td></tr>";
}
echo '</table>';
echo "</div>";
echo "<a href='/clan/podzemelie/' class='link'>".ico('icons','arrow.png')." Вернуться к списку рейдов</a>";
$clan = false;
require_once ('system/footer.php');
break;
default:
$reid = mysql_fetch_assoc(mysql_query("SELECT * FROM `clan_podzemelie_reid` WHERE `id` = '$batlle[id_reid]'"));
$boss = mysql_fetch_assoc(mysql_query("SELECT * FROM `clan_podzemelie_reid_boss` WHERE `id` = '$batlle[id_boss]' AND `id_reid` like '%$reid[id]%'"));
$boss2 = mysql_fetch_assoc(mysql_query("SELECT * FROM `clan_podzemelie_reid_boss` WHERE `id` = '".($batlle['id_boss']+1)."' AND `id_reid` like '%$reid[id]%'"));
$boss0 = mysql_fetch_assoc(mysql_query("SELECT * FROM `clan_podzemelie_reid_boss` WHERE `id` = '".($batlle['id_boss']-1)."' AND `id_reid` like '%$reid[id]%'"));
$batlle_user = mysql_fetch_assoc(mysql_query("SELECT * FROM `clan_podzemelie_users` WHERE `id_user` = '$myID' AND `id_batlle` = '$batlle[id]'"));
if($batlle['start'] == 2 and $batlle['last'] <= time()){
mysql_query("UPDATE `clan_podzemelie` SET `start` = '3' WHERE `id` = '$batlle[id]'");
header('Location: ?');
exit();
}
if(!$batlle_user and ($batlle['start'] == 2 or $batlle['start'] == 1) and $batlle['start'] != 4){
$title = "Клановое подземелье";
require_once ('system/header.php');
echo "<div class='block center'>";
echo "Бой уже начался!".$separ."<a href='?' class='btn2'>Обновить страницу</a>";
echo '</div>';
$clan = false;
require_once ('system/footer.php');
break;
}elseif($batlle_user and $batlle['start'] == 4 and $batlle_user['end'] == 0){
$title = "Клановое подземелье";
require_once ('system/header.php');
echo "<div class='block center'>";
if(!$boss and !$boss2){
echo "<font color='green'><b>Все монстры повержены!</b></font>".$separ."";
$boss = mysql_query("SELECT * FROM `clan_podzemelie_reid_boss` WHERE `id_reid` like '%$reid[id]%' ORDER BY `id` DESC LIMIT 2");
while($boss_ank = mysql_fetch_assoc($boss)){
echo "<img src='/images/clan/boss/$boss_ank[id].png'> ";
}
echo $separ;
echo "Ваша награда: ".ico('icons','gold.png')." $reid[gold_user] золота".$separ."Награда клану: ".ico('icons','gold.png')." $reid[gold_clan] золота";
mysql_query("UPDATE `users` SET `gold` = '".($user['gold']+$reid['gold_user'])."' WHERE `id` = '$myID' LIMIT 1");
}else{
echo "<font color='red'><b>Поражение!</b></font>$separ";
echo "<table cellpadding='5' cellspacing='0' align='center'><tr>";
echo "<td width='20%'>";
if($boss0){
echo "<img src='/images/clan/boss/".$boss0['id'].".png'>";
}
echo '</td>';
echo "<td class='center' width='60%'>";
if($boss){
echo "<a href='?attack'><img src='/images/clan/boss/".$boss['id']."-big.png'></a>";
}
echo '</td>';
echo "<td width='20%'>";
if($boss2){
echo "<img src='/images/clan/boss/".$boss2['id'].".png'>";
}
echo '</td>';
echo '</tr></table>';
echo "$boss[name] ".ico('icons','health.png')." $batlle[boss_health]";
echo "<div class='stat_bar'><div class='progress' style='width: ".round($batlle['boss_health']/$boss['health']*100,1)."%;'></div></div>";
echo "Монстры очень сильные!";
}
echo "</div>";
echo "<div class='block center'>";
echo "Участники боя:<br>";
$q = mysql_query("SELECT * FROM `clan_podzemelie_users` WHERE `id_batlle` = '$batlle[id]' ORDER BY `urons` DESC LIMIT 10");
echo "<table cellpadding='5' cellspacing='0' align='center'>";
while($post = mysql_fetch_assoc($q)){
$i++;
$ank = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '$post[id_user]'"));
echo "<tr><td class='center' style='border-right: 1px solid #8D673A;' width='50%'>".icons_user($ank['id'])." <span class='white'>$ank[login]</span></td><td>".ico('icons','sum_stat.png')." <span class='white'>$post[urons]</span></td></tr>";
}
echo '</table>';
echo '</div>';
echo "<a href='?' class='link'>".ico('icons','arrow.png')." Вернуться к списку рейдов</a>";
mysql_query("UPDATE `clan_podzemelie_users` SET `end` = '1' WHERE `id` = '$batlle_user[id]' LIMIT 1");
$clan = false;
require_once ('system/footer.php');
break;
}elseif($batlle['start'] == 3){
if(!$boss and !$boss2){
mysql_query("UPDATE `clan_podzemelie` SET `start` = '4', `last` = '".(time()+60*60*20)."' WHERE `id` = '$batlle[id]'");
mysql_query("UPDATE `clans` SET `gold` = '".($clan['gold']+$reid['gold_clan'])."' WHERE `id` = '$clan[id]' LIMIT 1");
}else{
mysql_query("UPDATE `clan_podzemelie` SET `start` = '4' WHERE `id` = '$batlle[id]'");
}
header('Location: ?');
exit();
}elseif($batlle['start'] == 2 and $batlle_user){
if($batlle_user['ubit'] == 1){
$title = "Клановое подземелье";
require_once ('system/header.php');
echo "<div class='block center'>";
echo "Вы были убиты во время боя, ожидайте окончания боя".$separ."<a href='?' class='btn2'>Обновить страницу</a>";
echo '</div>';
$clan = false;
require_once ('system/footer.php');
break;
}
if(isset($_GET['exit'])){
mysql_query("UPDATE `clan_podzemelie_users` SET `ubit` = '1' WHERE `id` = '$batlle_user[id]' LIMIT 1");
header("Location: ?");
exit();
}
if(isset($_GET['nastroika']) and $batlle_user['nastroika'] < time()){
mysql_query("UPDATE `clan_podzemelie_users` SET `health` = `max_health`, `nastroika` = '".(time()+90)."' WHERE `id` = '".$batlle_user['id']."' LIMIT 1");
header("Location: ?");
exit();
}
if(isset($_GET['kamen']) and $user['kamen'] >= 1 and $batlle_user['kamen'] < time()){
mysql_query("UPDATE `users` SET `kamen` = `kamen` - '1' WHERE `id` = '".$myID."' LIMIT 1");
mysql_query("UPDATE `clan_podzemelie_users` SET `kamen` = '".(time()+30)."' WHERE `id` = '".$batlle_user['id']."' LIMIT 1");
header('Location: ?');
exit();
}
if(isset($_GET['trava']) and $user['trava'] >= 1 and $batlle_user['trava'] < time()){
mysql_query("UPDATE `users` SET `trava` = `trava` - '1' WHERE `id` = '".$myID."' LIMIT 1");
mysql_query("UPDATE `clan_podzemelie_users` SET `trava` = '".(time()+30)."' WHERE `id` = '".$batlle_user['id']."' LIMIT 1");
header('Location: ?');
exit();
}
if(isset($_GET['attack'])){
if($batlle_user['udar_last'] > time()){
$time = ($batlle_user['udar_last']-time());
switch($time){
case 1:
$_str = ceil($_str*80/100);
break;
case 2:
$_str = ceil($_str*60/100);
break;
case 3:
$_str = ceil($_str*40/100);
break;
case 4:
$_str = ceil($_str*10/100);
break;
}
}
if(mt_rand(0,100) < $user['krit']){
$krit = true;
}
if($krit)$_str *= 2;
$_str_opp = rand(round($boss['str']/6), round($boss['str']/4));
$_def_opp = rand(round($boss['def']/12), round($boss['def']/7));
if($batlle_user['kamen'] > time())$_str += ceil($_str*35/100);
if($batlle_user['trava'] > time())$_def += ceil($_def*35/100);
$_str_opp = $_str_opp - $_def;
if($_str_opp < 0)$_str_opp = 0;
$_str = $_str - $_def_opp;
if($_str < 0)$_str = 0;
mysql_query("INSERT INTO `clan_podzemelie_log` SET `tip` = 'user', `uron_user` = '$_str', `krit` = '".($krit == true ? 1 : 0)."', `id_boss` = '$boss[id]', `id_user` = '$myID', `id_batlle` = '$batlle[id]'");
mysql_query("INSERT INTO `clan_podzemelie_log` SET `tip` = 'boss', `uron_boss` = '$_str_opp', `id_boss` = '$boss[id]', `id_user` = '$myID', `id_batlle` = '$batlle[id]'");
mysql_query("update `clan_podzemelie` set `boss_health` = '".($batlle['boss_health']-$_str)."' where (`id` = '".$batlle['id']."')");
mysql_query("update `clan_podzemelie_users` set `health` = '".($batlle_user['health']-$_str_opp)."', `udar_last` = '".(time()+4)."', `urons` = '".($batlle_user['urons']+$_str)."' where (`id` = '".$batlle_user['id']."')");
if($_str > $batlle['boss_health']){
if($boss2){
mysql_query("update `clan_podzemelie` set `id_boss` = '".$boss2['id']."', `boss_health` = '$boss2[health]' where (`id` = '".$batlle['id']."')");
mysql_query("INSERT INTO `clan_podzemelie_log` SET `tip` = 'user', `boss_ubit` = '1', `id_boss` = '$boss[id]', `id_user` = '$myID', `id_batlle` = '$batlle[id]'");
}else{
mysql_query("UPDATE `clan_podzemelie` SET `start` = '3', `id_boss` = '-1' WHERE `id` = '$batlle[id]'");
}
}
if($_str_opp > $batlle_user['health']){
mysql_query("update `clan_podzemelie_users` set `ubit` = '1' where (`id` = '".$batlle_user['id']."')");
mysql_query("INSERT INTO `clan_podzemelie_log` SET `tip` = 'boss', `user_ubit` = '1', `id_boss` = '$boss[id]', `id_user` = '$myID', `id_batlle` = '$batlle[id]'");
}
header('Location: ?');
exit();
}
$title = "Клановое подземелье";
require_once ('system/head.php');
echo "<div class='linetop'></div><div class='title center'>".img('icons','health.png')." ".n_f($batlle_user['health'],1)."</div><div class='line'></div>";
$progress = round($batlle_user['health']/$batlle_user['max_health']*100,1);
if($progress > 100)$progress = 100;
echo '<div class="exp"><div class="exp_in" style="width: '.$progress.'% "><br></div></div>';
if(isset($_SESSION['msg'])){
echo msg($_SESSION['msg']);
unset($_SESSION['msg']);
}
echo "<div class='block center'>";
echo "$boss[name] ".ico('icons','health.png')." $batlle[boss_health]";
echo "<div class='stat_bar'><div class='progress' style='width: ".round($batlle['boss_health']/$boss['health']*100,1)."%;'></div></div>";
echo "</div>";
echo "<div class='block center'>";
echo "<table cellpadding='5' cellspacing='0' align='center'><tr>";
echo "<td width='20%'>";
if($boss0){
echo "<img src='/images/clan/boss/".$boss0['id'].".png'>";
}
echo '</td>';
echo "<td class='center' width='60%'>";
if($boss){
echo "<a href='?attack'><img src='/images/clan/boss/".$boss['id']."-big.png'></a>";
}
echo '</td>';
echo "<td width='20%'>";
if($boss2){
echo "<img src='/images/clan/boss/".$boss2['id'].".png'>";
}
echo '</td>';
echo '</tr></table>';
echo $separ;
echo "<a href='?attack' class='btn2'>Атаковать</a><div class='md5'></div>";
echo "<a href='?nastroika' class='btn2'>Настройка жизней ".($batlle_user['nastroika'] > time() ? "<span id='time_".($batlle_user['nastroika']-time())."000'>".tl($batlle_user['nastroika']-time())."</span>" : "")."</a><hr>";
echo "<table cellpadding='5' cellspacing='0' align='center'><tr>";
echo "<td class='center' style='border-right: 1px solid #8D673A;'>";
if($user['kamen'] > 0)echo "<a href='?kamen' class='btn2'>".ico('icons','kamen.png')." Камень</a><br>";
else echo "<a href='?kamen' class='btn2'>".ico('icons','kamen.png')." <span class='grey'>Камень</span></a><br>";
if($batlle_user['kamen'] > time()){
echo "<span class='info'><span id='time_".($batlle_user['kamen']-time())."000'>".tl($batlle_user['kamen']-time())."</span></span>";
}else{
echo "<span class='white'>+35% урон</span>";
}
echo "</td>";
echo "<td class='center'>";
if($user['trava'] > 0)echo "<a href='?trava' class='btn2'>".ico('icons','trava.png')." Трава</a><br>";
else echo "<a href='?trava' class='btn2'>".ico('icons','trava.png')." <span class='grey'>Трава</span></a><br>";
if($batlle_user['trava'] > time()){
echo "<span class='info'><span id='time_".($batlle_user['trava']-time())."000'>".tl($batlle_user['trava']-time())."</span></span>";
}else{
echo "<span class='white'>-35% урон</span>";
}
echo "</td>";
echo "</tr></table>";
echo $separ."До конца боя осталось: <span id='time_".($batlle['last']-time())."000'>".tl($batlle['last']-time())."</span>";
echo "</div>";
echo "<div class='block'>";
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `clan_podzemelie_log` WHERE `id_batlle` = '$batlle[id]'"),0);
if($k_post == 0)echo "Логов не найдено...";
$q = mysql_query("SELECT * FROM `clan_podzemelie_log` WHERE `id_batlle` = '$batlle[id]' ORDER BY `id` DESC LIMIT 15");
while($post = mysql_fetch_assoc($q)){
$ank = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '$post[id_user]'"));
$boss = mysql_fetch_assoc(mysql_query("SELECT * FROM `clan_podzemelie_reid_boss` WHERE `id` = '$post[id_boss]'"));
if($post['tip'] == 'user'){
if($ank['id'] == $myID){
if($post['boss_ubit'] == 1){
echo "Вы убили $boss[name]<br>";
}else{
if($post['uron_user'] > 0)echo "Вы атаковали $boss[name] на <b>$post[uron_user]</b> ".($post['krit'] == 1 ? '(Крит)' : '')."<br>";
else echo "<span class='grey'>Промах</span><br>";
}
}else{
if($post['boss_ubit'] == 1){
echo "$ank[login] убили $boss[name]<br>";
}else{
if($post['uron_user'] > 0)echo "$ank[login] атаковал $boss[name] на <b>$post[uron_user]</b> ".($post['krit'] == 1 ? '(Крит)' : '')."<br>";
}
}
}elseif($post['tip'] == 'boss'){
if($ank['id'] == $myID){
if($post['boss_ubit'] == 1){
echo "<font color='red'>$boss[name] убил вас</font><br>";
}else{
if($post['uron_boss'] > 0)echo "<font color='red'>$boss[name] атаковал вас на <b>$post[uron_boss]</b></font><br>";
}
}else{
if($post['boss_ubit'] == 1){
echo "$boss[name] убил $ank[login]<br>";
}else{
if($post['uron_boss'] > 0)echo "$boss[name] атаковал $ank[login] на <b>$post[uron_boss]</b><br>";
}
}
}
}
echo "</div>";
echo "<a href='?exit' class='link center'>".ico('icons','arrow.png')." Покинуть бой</a>";
?>
<script type="text/javascript">
var secS = 'с.';
var secM = 'с.';
var minS = 'м.';
var minM = 'м.';
var hourS = 'ч.';
var hourM = 'ч.';
var dayS = 'д.';
var dayM = 'д.';
var detailOut = false;
var readyLink = '0'+(detailOut?secS:' ' + secM);
</script>
<script src="/ajax/t.js" type="text/javascript"></script>
<?
echo "</body></html>";
break;
}elseif($batlle['start'] == 1){
if($batlle['last'] <= time()){
mysql_query("UPDATE `clan_podzemelie` SET `start` = '2', `last` = '".(time()+60*5)."' WHERE `id` = '$batlle[id]' LIMIT 1");
header('Location: ?');
exit();
}
$title = "Клановое подземелье";
require_once ('system/header.php');
echo "<div class='block center'>";
echo "<span class='money'><b>$reid[name]</b></span>$separ";
$boss = mysql_query("SELECT * FROM `clan_podzemelie_reid_boss` WHERE `id_reid` like '%$reid[id]%' ORDER BY `id` DESC LIMIT 2");
while($boss_ank = mysql_fetch_assoc($boss)){
echo "<img src='/images/clan/boss/$boss_ank[id].png'> ";
}
echo $separ."Бой начнется через <span id='time_".($batlle['last']-time())."000'>".tl($batlle['last']-time())."</span><br><a href='?' class='btn2'>Обновить</a>$separ";
echo "Участники боя:<br>";
$q = mysql_query("SELECT * FROM `clan_podzemelie_users` WHERE `id_batlle` = '$batlle[id]' ORDER BY `id` ASC LIMIT 10");
echo "<table cellpadding='5' cellspacing='0' align='center'>";
while($post = mysql_fetch_assoc($q)){
$i++;
$ank = mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '$post[id_user]'"));
echo "<tr><td class='center' style='border-right: 1px solid #8D673A;' width='50%'>".icons_user($ank['id'])." <span class='white'>$ank[login]</span></td><td>".ico('icons','sum_stat.png')." <span class='white'>".($ank['str']+$ank['def']+$ank['max_health'])."</span></td></tr>";
}
echo '</table>';
echo '</div>';
$clan = false;
require_once ('system/footer.php');
break;
}else{
$title = 'Клановое подземелье';
require_once ('system/header.php');
if($batlle['last'] > time()){
echo "<div class='block center'>";
echo "<font color='green'><b>Все монстры повержены!</b></font>".$separ."";
$boss = mysql_query("SELECT * FROM `clan_podzemelie_reid_boss` WHERE `id_reid` like '%$reid[id]%' ORDER BY `id` DESC LIMIT 2");
while($boss_ank = mysql_fetch_assoc($boss)){
echo "<img src='/images/clan/boss/$boss_ank[id].png'> ";
}
echo $separ;
echo "Следующий рейд можно начать через: <span id='time_".($batlle['last']-time())."000'>".tl($batlle['last']-time())."</span>$separ<a href='?' class='btn2'>Обновить страницу</a></div>";
}
$k_post = mysql_result(mysql_query("SELECT COUNT(*) FROM `clan_podzemelie_reid`"),0);
if($k_post == 0)echo "<div class='block center'>Рейдов нет...</div>";
$q = mysql_query("SELECT * FROM `clan_podzemelie_reid` ORDER BY `id` DESC");
while($post = mysql_fetch_assoc($q)){
echo "<div class='block center'>";
echo "<span class='money'><b>$post[name]</b></span>$separ";
$boss = mysql_query("SELECT * FROM `clan_podzemelie_reid_boss` WHERE `id_reid` like '%$post[id]%' ORDER BY `id` DESC LIMIT 2");
while($boss_ank = mysql_fetch_assoc($boss)){
echo "<img src='/images/clan/boss/$boss_ank[id].png'> ";
}
if($clan['level'] < $post['clan_level']){
echo "$separ<span class='grey'>Необходим ".ico('icons','level.png')." $post[clan_level] уровень клана</span>";
}else{
echo "".$separ."Награда за победу:<br>По ".ico('icons','gold.png')." $post[gold_user] игрокам и ".ico('icons','gold.png')." $post[gold_clan] клану!";
if($batlle['last'] < time())echo "$separ<a href='/clan/podzemelie/reid/$post[id]/' class='btn2'>Присоединиться к рейду</a>";
}
echo "</div>";
}
$clan = false;
require_once ('system/footer.php');
break;
}
}
?>