Вход Регистрация
Файл: wenr.online/app/clan/battle.php
Строк: 149
<?php
ini_set
('display_errors'1);
ini_set('display_startup_errors'1);
error_reporting(E_ALL);
if (!
$user->isAuth() or $user->get()->clan == 0) {
    
redirect('/');
    exit;
}

function 
count_clan($clan){
        global 
$db;
    return 
$db->query('select user_id from users where clan = '.$clan)->rowCount();
    }
            
            
$clan $db->prepare('select * from clan where id = ?');
            
$clan -> execute([$user->get()->clan]);
            
$clan $clan -> fetch(PDO :: FETCH_OBJ);
            
            
            
            
    
$clanwar $db->prepare('select * from clanwar where clan1 = ? and win = ? or clan2 = ? and win = ?');
    
$clanwar ->execute([$clan->id,0,$clan->id,0]);
    
$clanwar $clanwar -> fetch(PDO :: FETCH_OBJ);
    
            if(!isset(
$clanwar->id)){
                
redirect('/clan');
                exit;
            }
            
            
$clan_id $clanwar->clan1;
            
            if(
$clan_id == $clan->id$clan_id $clanwar->clan2;
            
            
            
$clantwo $db->prepare('select * from clan where id = ?');
            
$clantwo -> execute([$clan_id]);
            
$clantwo $clantwo -> fetch(PDO :: FETCH_OBJ);
            
        
            
          
          
            if(
$clanwar->war == 1){
                
                
                
$us $db->prepare('select * from users where clan = ? order by rand() limit 1');
                
$us -> execute([$clantwo->id]);
                
$us $us -> fetch(PDO :: FETCH_OBJ);
            
            
            
              if(isset(
$_GET['attack'])){
        
        if(
$user->get()->hp 2){
            
Notif :: error('Слишком мало здоровья для нападения','/clan/battle');
            exit;
        }
        
        
        
$user_id Clean :: int($_GET['attack']);
        if(
$user->get($user_id)->clan != $clantwo -> id){
            
redirect('/clan/battle');
            exit;
        }
        
        
        
        
        
$magic $db->prepare('select * from `bag` where `id` = ? and `user` = ?');
        
$magic -> execute([Clean :: int($_GET['rolls']),$user->get()->user_id]);
        
$magic $magic -> fetch(PDO :: FETCH_OBJ);
        
                
$dop_uron 0;
                
        
$fight_skill $user->get()->one_handed+$user->get()->two_handed+$user->get()->bow+$user->get()->crossbow;
                
        if(
$figth_skill 50)    $dop_uron .= rand(1,$fight_skill);
        
$dop_uron .= rand(0,clan_info($user->get()->clan)->attack*2);
        
        
$dop_uron2 0;
                
        
$fight_skill2 $user->get($user_id)->one_handed+$user->get($user_id)->two_handed+$user->get($user_id)->bow+$user->get($user_id)->crossbow;
                
        if(
$figth_skill2 50)    $dop_uron2 .= rand(1,$fight_skill);
        
$dop_uron2 .= rand(0,clan_info($user->get($user_id)->clan)->lucky*2);
        
        
                
        if(
$magic->mana $user->get()->mana and isset($magic->id)){
            
Notif :: error('Нехватает маны для использования свитка','/clan/battle');
            exit;
        }
        
        if(isset(
$magic->force)) $dop_uron .= $magic->force;
        
        
        
$uron = ['user' => $user->get()->force+$user->get()->dex+$dop_uron
                 
'mob'  =>  $user->get($user_id)->force+$user->get($user_id)->dex+$dop_uron2];
       
       if(
$uron['mob'] >= $uron['user']){
           
           
$sql $db->prepare('update clan set uron = ? where id = ?');
           
$sql -> execute([$clantwo->uron+$uron['mob'],$clantwo->id]);
           
           
$sql $db->prepare('update clan set uron = ? where id = ?');
           
$sql -> execute([$clan->uron+$uron['user'],$clan->id]);
           
           
           
$up $db->prepare('update users set hp = ? where user_id = ?');
           
$up -> execute([$user->get()->hp-$uron['mob'],$user->get()->user_id]);
           
           
$db->query('update users set hp = 0 where hp < 0 and user_id = '.$user->get()->user_id);
           
           
Notif :: message('Вы проиграли бой с '.$user->get($user_id)->nick.' Ваш урон: '.$uron['user'].', урон противника: '.$uron['mob'],'/clan/battle');
           exit;
           
       }
       else {
           
           
$sql $db->prepare('update clan set uron = ? where id = ?');
           
$sql -> execute([$clantwo->uron+$uron['mob'],$clantwo->id]);
           
           
$sql $db->prepare('update clan set uron = ? where id = ?');
           
$sql -> execute([$clan->uron+$uron['user'],$clan->id]);
           
           
$up $db->prepare('update users set hp = ?, `exp` = ? where user_id = ?');
           
$up -> execute([$user->get()->hp-$uron['mob'],$user->get()->exp+rand(1,$user->get()->lvl),$user->get()->user_id]);
           
           
$db->query('update users set hp = 0 where hp < 0 and user_id = '.$user->get()->user_id);
           
           
Notif :: message('Вы выиграли бой с '.$user->get($user_id)->nick.' Ваш урон: '.$uron['user'].', урон противника: '.$uron['mob'],'/clan/battle');
           exit;
           
           
       }
       
      
    }
            
            
            
            
            echo 
$template->render('clan.battle', ['clan'=>$clan,'clantwo'=>$clantwo,'clanwar'=>$clanwar,'us'=>$us]);
            
            }
            
            
            if(
$clanwar->war == 0){
            
            echo 
$template->render('clan.battle_info', ['clan'=>$clan,'clantwo'=>$clantwo,'clanwar'=>$clanwar]);
            
            }
Онлайн: 1
Реклама