Вход Регистрация
Файл: 3/coliseum.php
Строк: 126
<?php   
require_once ('./system/func.php'); //тут подключаем шапку 
auth(); // Закроем от не авторизованных
$title 'Колизей';    
require_once (
'./system/header.php');
echo
'<div class="lent mlra w80">
<div class="bl-ttl"><div class="te"><div class="ttl">
        Колизей
        </div></div></div>'
;
 
if(
$user['level'] > 9) {

  
$member $db->query('SELECT * FROM `coliseum_member` WHERE `user` = "'.$user['id'].'" ORDER BY `time` DESC LIMIT 1')->fetch_assoc();
  
$wardark $db->query('SELECT * FROM `coliseum_member` WHERE `id` = "'.$member['object'].'"')->fetch_assoc();
  if(
$member) {

  
$battle $db->query('SELECT * FROM `coliseum` WHERE `id` = "'.$member['battle'].'"');
  
$battle $battle->fetch_assoc();

  }

  
  if(
$member['exit'] == && $battle['start'] == && $battle['end'] == 0) {

  if(
$db->query('SELECT * FROM `coliseum_member` WHERE `battle` = "'.$battle['id'].'" AND `dead` = "0"')->num_rows == 1) {
     
    
$db->query('UPDATE `coliseum` SET `end` = "1" WHERE `id` = "'.$battle['id'].'"');
  
      
header('location: /coliseum/');
  
  exit;
  
  }
  

    if(
$member['dead'] == 1) {
    
?>

<div class='block' align='center'>
<a class='btn' href='/coliseum/?'>Обновить</a>

<br/><br/>
<font color='#999'>Вы были убиты во время сражения, ожидайте окончания боя</font>
</div>

<?

    

    
}
    else
    {
  
  if(
$_GET['exit'] == true) {

    
$log icons_user($user[id]).' <b>'.$user['login'].'</b> покидает бой';    
    
$db->query('INSERT INTO `coliseum_log` (`battle`,
                                               `user`,
                                             `object`,
                                               `text`) VALUES ("'
.$battle['id'].'",
                                                                 "'
.$user['id'].'",
                                                               "'
.$object['id'].'",
                                                                        "'
.$log.'")');

    
$db->query('UPDATE `coliseum_member` SET `dead` = "1" WHERE `battle` = "'.$battle['id'].'" AND `user` = "'.$user['id'].'"');
  
      
header('location: /coliseum/');
  
  exit;
  
  }
  
  if(
$member['object'] == OR $wardark['dead'] == 1) {
  
    
$rand_object $db->query('SELECT * FROM `coliseum_member` WHERE `battle` = "'.$battle['id'].'" AND `dead` = "0" AND `user` != "'.$user['id'].'" ORDER BY RAND() LIMIT 1')->fetch_assoc();

    
$db->query('UPDATE `coliseum_member` SET `object` = "'.$rand_object['id'].'" WHERE `battle` = "'.$battle['id'].'" AND `user` = "'.$user['id'].'"');

  }


if(
$member['object']) {

  if(
$_GET['last'] == true) {
  
    
$rand_object $db->query('SELECT * FROM `coliseum_member` WHERE `battle` = "'.$battle['id'].'" AND `dead` = "0" AND `user` != "'.$user['id'].'" ORDER BY RAND() LIMIT 1')->fetch_assoc();
    
$db->query('UPDATE `coliseum_member` SET `object` = "'.$rand_object['id'].'" WHERE `battle` = "'.$battle['id'].'" AND `user` = "'.$user['id'].'"');
  
header('location: /coliseum/');
  }
    
$member_object $db->query('SELECT * FROM `coliseum_member` WHERE `battle` = "'.$battle['id'].'" AND `id` = "'.$member['object'].'"')->fetch_assoc();

    
$object $db->query('SELECT * FROM `users` WHERE `id` = "'.$member_object['user'].'"')->fetch_assoc();
  
  if(
$_GET['attack'] == true && $member_object['dead'] == 0) {
  
    
$dmg 0;
    
    
$object_dmg 0;
  
 
  
  
      
$dmg +=round(rand(($user['str']/6),($user['str']/4)));

     

$dmg -= round(rand(($object['def']/12),($object['def']/7)));

    if(
$dmg 0) {
    
      
$dmg 0;
    
    }
   
    
$dmg_time time() - $member['time'];
    
    if(
$dmg_time 2) {
    
      
$dmg 0;
    
    }
    
    if(
$dmg_time && $dmg_time 4) {
    
      
$dmg -= round($dmg 2);
    
    }

   
    
    if(
$dmg == 0) {
      
$log 'Вы промахнулись';
    }
    else
    {
      
$log '<font color=green>Вы ударили '.icons_user($object['id']).' <b>'.$object['login'].'</b> на <b>'.$dmg.'</b></font>';    
    }
    
    
$db->query('INSERT INTO `coliseum_log` (`battle`,
                                               `user`,
                                             `object`,
                                               `text`,
                                               `show`) VALUES ("'
.$battle['id'].'",
                                                                 "'
.$user['id'].'",
                                                               "'
.($dmg $object['id']:0).'",
                                                                        "'
.$log.'",
                                                                 "'
.$user['id'].'")');
    
    if(
$dmg 0) {
      
$log icons_user($user['id']).' <b>'.$user['login'].'</b> ударил Вас на <b>'.$dmg.'</b>';    
    
$db->query('INSERT INTO `coliseum_log` (`battle`,
                                               `user`,
                                             `object`,
                                               `text`,
                                               `show`) VALUES ("'
.$battle['id'].'",
                                                               "'
.$object['id'].'",
                                                                 "'
.$user['id'].'",
                                                                        "'
.$log.'",
                                                               "'
.$object['id'].'")');
    }

    if(
$dmg 0) {
    
$log icons_user($user['id']).' <b>'.$user['login'].'</b> ударил  <b> '.icons_user($object['id']).''.$object['login'].'</b> на <b>'.$dmg.'</b>';    
    
$db->query('INSERT INTO `coliseum_log` (`battle`,
                                               `user`,
                                             `object`,
                                               `text`) VALUES ("'
.$battle['id'].'",
                                                                 "'
.$user['id'].'",
                                                               "'
.$object['id'].'",
                                                                        "'
.$log.'")');
    }



    
$db->query('UPDATE `coliseum_member` SET `hp`=`hp`-"'.$dmg.'" WHERE `battle` = "'.$battle['id'].'" AND `user` = "'.$object['id'].'"');
    
$db->query('UPDATE `coliseum_member` SET `time` = "'.time().'" WHERE `battle` = "'.$battle['id'].'" AND `user` = "'.$user['id'].'"');






    if(
$dmg >= $member_object['hp']) {

      
$log 'Вы убили '.icons_user($object['id']).' <b>'.$object['login'].'</b>';        
      
$db->query('INSERT INTO `coliseum_log` (`battle`,
                                                 `user`,
                                               `object`,
                                                 `text`,
                                                 `show`) VALUES ("'
.$battle['id'].'",
                                                                   "'
.$user['id'].'",
                                                                 "'
.$object['id'].'",
                                                                          "'
.$log.'",
                                                                   "'
.$user['id'].'")');

      
$log ''.icons_user($user['id']).' <b>'.$user['login'].'</b> убил Вас';    
      
$db->query('INSERT INTO `coliseum_log` (`battle`,
                                                 `user`,
                                               `object`,
                                                 `text`,
                                                 `show`) VALUES ("'
.$battle['id'].'",
                                                                 "'
.$object['id'].'",
                                                                   "'
.$user['id'].'",
                                                                          "'
.$log.'",
                                                                 "'
.$object['id'].'")');
    
    
      
$log ico('icons','rip.png').' '.icons_user($user['id']).' <b>'.$user['login'].'</b> убил '.icons_user($object['id']).' <b>'.$object['login'].'</b>';    
      
$db->query('INSERT INTO `coliseum_log` (`battle`,
                                                 `user`,
                                               `object`,
                                                 `text`) VALUES ("'
.$battle['id'].'", 
                                                                 "'
.$user['id'].'",
                                                               "'
.$object['id'].'",
                                                                        "'
.$log.'")');


      
$db->query('UPDATE `coliseum_member` SET `dead` = "1" WHERE `battle` = "'.$battle['id'].'" AND `user` = "'.$object['id'].'"');
      
$db->query('UPDATE `coliseum_member` SET `kills` = `kills` + 1 WHERE `battle` = "'.$battle['id'].'" AND `user` = "'.$user['id'].'"');

      
$rand_object $db->query('SELECT * FROM `coliseum_member` WHERE `battle` = "'.$battle['id'].'" AND `dead` = "0" AND `user` != "'.$user['id'].'" ORDER BY RAND() LIMIT 1')->fetch_assoc();

      
$db->query('UPDATE `coliseum_member` SET `object` = "'.$rand_object['id'].'" WHERE `battle` = "'.$battle['id'].'" AND `user` = "'.$user['id'].'"');

    }

  }

?>  
<div class='block'>
<?=icons_user($object['id']);?> <b><?=$object['login']?></b>
                    <img src="/images/icons/str.png" alt="*"/> <?=$object['str']?> <img src="/images/icons/health.png" alt="*"/> <?=$member_object['hp']?> <img src="/images/icons/def.png" alt="*"/> <?=$object['def']?>
                    </div>


<div class='block'>
                        <a href='/coliseum/?attack=true' class='btn'>Атаковать</a> 
                        <a href='/coliseum/?last=true' class='btn'>Сменить</a>
            </div>

<?


  
}else{header ("Location: /coliseum/?last=true");}


  }


  
$count $db->query('SELECT * FROM `coliseum_log` WHERE `battle` = "'.$battle['id'].'"')->num_rows;
if(
$count 0) {

?>

<div class='block2'>Героев в бою: <?=$db->query('SELECT * FROM `coliseum_member` WHERE `battle` = "'.$battle['id'].'"')->num_rows?></div>
<?

$q 
$db->query('SELECT * FROM `coliseum_log` WHERE `battle` = "'.$battle['id'].'" ORDER BY `id` DESC LIMIT 15');

  while(
$row $q->fetch_assoc()) {

    if(
$row['user'] == $user['id'] && $row['show'] == $user['id'] OR $row['object'] == $user['id'] && $row['show'] == $user['id']) {
  
      echo 
'<div class="green-block"><small><font color='#'.($row['object'] == 0 ? '6f6':'f63').''>'.$row['text'].'</font></small></div>';
  
    
}
    elseif(
$row['show'] == 0)
    {
    
    if(
$row['user'] == $user['id']) {
        

    }
    else
    {

    if(
$row['object'] == $user['id']) {
    
    }
    else
    {
    
      echo 
'<div class="green-block">'.$row['text'].'</div>';
  
    }
  
    }
  
    }

  }
  
?>


<?
  
  
}

  if(
$member['dead'] == 0) {

?>


<?

  
}
  
  }
  else
  {

  if(
$member['exit'] == && $battle['start'] == && $battle['end'] == 1) {

$q $db->query('SELECT * FROM `coliseum_member` WHERE `battle` = "'.$battle['id'].'" ORDER BY `kills` DESC  LIMIT '.mysql_result(mysql_query('SELECT COUNT(*) FROM `coliseum_member` WHERE `battle` = "'.$battle['id'].'"'),0).'');

  while(
$row $q->fetch_assoc()) {
  
  
$i++;
  
  if(
$i == 1) {
    
    
$best $db->query('SELECT * FROM `users` WHERE `id` = "'.$row['user'].'"')->fetch_assoc();
  
  }
  
  if(
$row['user'] == $user['id']) {
  
      
$place $i;
  
  }

  }

    
$_s round(rand(1,100) + (100 $place) + (100$member['kills']));

  
$_exp round(rand(1,100) + (100 $place) + (25 $member['kills']));
    
    if(
$clan_memb && $clan_memb['v'] > 0) {
    
      
$_exp += round($_exp/100) * $_clan_memb['v'];
    
    }


  
$db->query('UPDATE `users` SET `silver` =   `silver` + '.$_s.',
                                `exp` = `exp` + '
.$_exp.' WHERE `id` = "'.$user['id'].'"');


      if(
$clan) {
        
       
$db->query('UPDATE `clans`     SET `exp` = `exp` + '.$_exp.' WHERE `id` = "'.$clan['id'].'"');
    
$db->query("UPDATE `users` SET `clan_exp` = '".($user[clan_exp]+$_exp)."' WHERE `id` = '".$myID."' LIMIT 1");

      }
$db->query("DELETE FROM `coliseum_log` WHERE `battle`='".$battle['id']."'");


?>

  <div class='block' align='center'><font color='#90c090'><b>Бой окончен!</b></font><br /><font color='#90b0c0'>Награда за <b><?=$place?></b> место:</font><br/><?=$_s?> серебра  <?=$_exp?> опыта
  
  </div>

  <div class='block' align='center'><b>Лучший: <?=icons_user($best['id']);?> <?=$best['login']?></b>
    <div class='separator'></div>
  <b>Итог боя:</b><br/>

<?

$q 
$db->query('SELECT * FROM `coliseum_member` WHERE `battle` = "'.$battle['id'].'" ORDER BY `kills` DESC LIMIT '.mysql_result(mysql_query('SELECT COUNT(*) FROM `coliseum_member` WHERE `battle` = "'.$battle['id'].'"'),0).'');

  while(
$row $q->fetch_assoc()) {

    
$coliseum_user $db->query('SELECT * FROM `users` WHERE `id` = "'.$row['user'].'"')->fetch_assoc();

  
$_rating $row['kills'];

  
$db->query('UPDATE `users` SET `coliseum_rating` = "'.($coliseum_user['coliseum_rating'] + $_rating).'" WHERE `id` = "'.$coliseum_user['id'].'"');

?>
<?=icons_user
($coliseum_user['id']);?> <a href='/profile/<?=$coliseum_user['id']?>'><?=$coliseum_user['login']?></a> - <?=$_rating?> к рейтингу<br/>

<?

  
}

?>

</div>

<?

    $db
->query('UPDATE `coliseum_member` SET `exit` = "1" WHERE `battle` = "'.$battle['id'].'" AND `user` = "'.$user['id'].'"');
    
  }
  else
  {

?>

 <center><img src='/images/other/wings.png'></center>

<?
  
  
}


if(
$db->query('SELECT * FROM `coliseum` WHERE `start` = "0"')->num_rows == 0) {

  
$db->query('INSERT INTO `coliseum` (`start`,
                                         `end`,
                                        `time`) VALUES ("0",
                                                        "0",
                                        "'
.(time() + 60).'")');

}

  
$battle $db->query('SELECT * FROM `coliseum` WHERE `start` = "0"')->fetch_assoc();

?>



<?

if($db->query('SELECT * FROM `coliseum_member` WHERE `battle` = "'.$battle['id'].'"')->num_rows && $db->query('SELECT * FROM `coliseum_member` WHERE `battle` = "'.$battle['id'].'" AND `user` = "'.$user['id'].'"')->num_rows == 0) {

    if(
$_GET['enter'] == true && $db->query('SELECT * FROM `coliseum_member` WHERE `battle` = "'.$battle['id'].'"')->num_rows 5) {
    
      
$db->query('INSERT INTO `coliseum_member` (`battle`,
                                                    `user`,
                                                    `time`,
                                                    `hp`) VALUES ("'
.$battle['id'].'",
                                                                      "'
.$user['id'].'",
                                                                           "'
.time().'",
                                                                           "'
.($user['max_health']*2).'")');
    
        
header('location: /coliseum/');
    
    exit;
    
   }

?>            
                <div class="block">
                    <img src="/images/icons/coliseum.png" alt="">
                    Ваш рейтинг: <?=$user['coliseum_rating']?><br>
                
            
            
<br><a href='?enter=true' class='btn'>Встать в очередь</a></div>


<?

}
else
{

  if(
$_GET['exit'] == true && $db->query('SELECT * FROM `coliseum_member` WHERE `battle` = "'.$battle['id'].'"')->num_rows 5) {

    
$db->query('DELETE FROM `coliseum_member` WHERE `battle` = "'.$battle['id'].'" AND `user` = "'.$user['id'].'"');
   
        
header('location: /coliseum/');
    
    exit;

  }
  
  if(
$db->query('SELECT * FROM `coliseum_member` WHERE `battle` = "'.$battle['id'].'"')->num_rows 1) {
  
  if(
$battle['time'] > time()) {
  
?>
<div class='block2'>
<font color='#909090'>До начала боя: <?=($battle['time'] - time())?> секунд</font><br/><br/>
</div>
<?
  
  
}
  else
  {

    
$db->query('UPDATE `coliseum` SET `start` = "1" WHERE `id` = "'.$battle['id'].'"');
header('location: /coliseum/');
  
  }
  
  }
  else
  {
  
  if(
$battle['time'] < time()) {
  
    
$db->query('UPDATE `coliseum` SET `time` = "'.(time() + 30).'" WHERE `id` = "'.$battle['id'].'"');
  
  }
  
  }

?>            
            <div class='block'>
                
В очереди: <?=$db->query('SELECT * FROM `coliseum_member` WHERE `battle` = "'.$battle['id'].'"')->num_rows?> из 5

                    <br><a href='?' class='btn'>Обновить</a>

                    <a class='btn' href='/coliseum/?exit=true'>Покинуть очередь</a></div>

                            

<?


}
 }
 else
 {
 
?>

<div class='block'>
Для участия в  Колизее требуется  10 уровень
</div>

<?
 
 
}
echo
'</div>';  
require_once (
'system/footer.php');
?>
Онлайн: 1
Реклама