Вход Регистрация
Файл: pages/combat/duel.php
Строк: 723
<?php
// Physical module map v50.6: public URL stays clean while code lives in /pages.
if (!defined('GAME_ROOT')) define('GAME_ROOT', dirname(__DIR__, 2));
chdir(GAME_ROOT);
if (
PHP_SAPI !== 'cli') { $_SERVER['PHP_SELF']='/duel.php'; $_SERVER['SCRIPT_NAME']='/duel.php'; }

/* Обновление игры под PHP 8.4 / PDO и усиление безопасности: by Метриум (Стэлп) */
    
    
include './system/common.php';
    
 include 
'./system/functions.php';
        
      include 
'./system/user.php';
  include 
'./system/menu.php';
require_once 
'./system/duel_bots.php';
if(!
$user) {

  
header('location: /');
    
exit;

}

    
$title = 'Дуэли';

include 
'./system/h.php';

if(
db_result(db_query('SELECT * FROM `duel` WHERE `user` = "'.$user['id'].'"'),0) == 0) {

  
db_query('INSERT INTO `duel` (`user`) VALUES ("'.$user['id'].'")');

}

    
$duel = db_query('SELECT * FROM `duel` WHERE `user` = "'.$user['id'].'"');
    
$duel = db_fetch_array($duel) ?: [];

    
// PHP 8.4 combat defaults: by Метриум (Стэлп)
    
$a_1 = $a_2 = $a_3 = $a_4 = $a_5 = false;
    
$a_1_bonus = $a_2_bonus = $a_3_bonus = $a_4_bonus = $a_5_bonus = 0;
    
$a_1_chanse = $a_2_chanse = $a_3_chanse = $a_4_chanse = $a_5_chanse = 0;
    
$a_3_crit_chanse = 0;
    
$EnableChanse = false;
    
$turnir = false;
    
$a_f = ['on/off' => 0];
    
$_rating = 0;
    
$text = '';


    
$sack = db_query('SELECT * FROM `sack` WHERE `user` = "'.$user['id'].'"');      
    
$sack = db_fetch_array($sack);

if(!
$sack) {

  
db_query('INSERT INTO `sack` (`user`) VALUES ("'.$user['id'].'")');

}

  if((
$_GET['refresh'] ?? '') == 'true') {
  
    if(
$user['duel_fights'] > 0 OR $user['g'] < 20) {
    
      
header('location: /duel/');
      
     exit;
    
    }
    
    
db_query('UPDATE `users` SET `duel_fights` = "10",
                                              `g` = `g` - 20 WHERE `id` = "'
.$user['id'].'"');
  
    
header('location: /duel/');

  }

?>

<?php

if($user['level'] > 1) {

    if((
$_GET['last'] ?? '') == 'true' && $user['duel_changes'] > 0) {
      
$opponent = duel_select_opponent($user, (int)($duel['opponent'] ?? 0));
      
db_query('UPDATE `users` SET `duel_changes` = GREATEST(`duel_changes` - 1,0) WHERE `id` = "'.(int)$user['id'].'"');
      
duel_store_opponent((int)$user['id'], $opponent);
      
header('location: /duel/'); exit;
    }

    if(empty(
$duel['opponent'])) {
      
$opponent = duel_select_opponent($user);
      
duel_store_opponent((int)$user['id'], $opponent);
      
$duel['opponent']=(int)$opponent['id'];
    } else {
      
$opponent = duel_load_opponent((int)$duel['opponent'], $user);
      if((int)
$opponent['id'] !== (int)$duel['opponent']) { duel_store_opponent((int)$user['id'],$opponent); $duel['opponent']=(int)$opponent['id']; }
    }

  if((
$_GET['attack'] ?? '') == 'true') {

  if(
time() - $duel['time'] < 0) {
  
    
header('location: /duel/');
  
  exit;
  
  }

  
  if(
$user['hp'] > ( ( ($user['vit'] * 2) / 100 ) * 10 )) {
  
  if( 
$user['duel_fights'] > 0) {
  
    
$dmg = 0;
    
$opponent_dmg = 0;
    
$a_1 = $a_2 = $a_3 = $a_4 = $a_5 = false;
    
$EnableChanse = false;
    
$turnir = false;
    
    for(
$round = 1; $round < 6; $round++) {
    
  if(
$user['ability_1'] > 0) {
  switch(
$user['ability_1']) {
    case 
0:
    
$a_1_bonus = 25;
   
$a_1_chanse = 5;
     break;
    case 
1:
    
$a_1_bonus = 25;
   
$a_1_chanse = 5;
     break;
    case 
2:
    
$a_1_bonus = 30;
   
$a_1_chanse = 5;
     break;
    case 
3:
    
$a_1_bonus = 35;
   
$a_1_chanse = 5;
     break;
    case 
4:
    
$a_1_bonus = 40;
   
$a_1_chanse = 5;
     break;
    case 
5:
    
$a_1_bonus = 45;
   
$a_1_chanse = 5;
     break;
    case 
6:
    
$a_1_bonus = 45;
   
$a_1_chanse = 8;
     break;
    case 
7:
    
$a_1_bonus = 50;
   
$a_1_chanse = 8;
     break;
    case 
8:
    
$a_1_bonus = 55;
   
$a_1_chanse = 8;
     break;
    case 
9:
    
$a_1_bonus = 60;
   
$a_1_chanse = 8;
     break;
    case 
10:
    
$a_1_bonus = 65;
   
$a_1_chanse = 8;
     break;
    case 
11:
    
$a_1_bonus = 65;
   
$a_1_chanse = 11;
     break;
    case 
12:
    
$a_1_bonus = 70;
   
$a_1_chanse = 11;
     break;
    case 
13:
    
$a_1_bonus = 75;
   
$a_1_chanse = 11;
     break;
    case 
14:
    
$a_1_bonus = 80;
   
$a_1_chanse = 11;
     break;
    case 
15:
    
$a_1_bonus = 85;
   
$a_1_chanse = 11;
     break;
    case 
16:
    
$a_1_bonus = 85;
   
$a_1_chanse = 14;
     break;
    case 
17:
    
$a_1_bonus = 90;
   
$a_1_chanse = 14;
     break;
    case 
18:
    
$a_1_bonus = 95;
   
$a_1_chanse = 14;
     break;
    case 
19:
    
$a_1_bonus = 100;
   
$a_1_chanse = 14;
     break;
    case 
20:
    
$a_1_bonus = 105;
   
$a_1_chanse = 14;
     break;
    case 
21:
    
$a_1_bonus = 105;
   
$a_1_chanse = 17;
     break;
    case 
22:
    
$a_1_bonus = 145;
   
$a_1_chanse = 20;
     break;
    case 
23:
    
$a_1_bonus = 165;
   
$a_1_chanse = 23;
     break;
    case 
24:
    
$a_1_bonus = 165;
   
$a_1_chanse = 23;
     break;
  }
  
  if(
mt_rand(0, 100) <= $a_1_chanse) {

    
$a_1 = true;

  }
  
  }


  if(
$user['ability_2'] > 0) {
  switch(
$user['ability_2']) {
    case 
0:
    
$a_2_bonus = 25;
   
$a_2_chanse = 5;
     break;
    case 
1:
    
$a_2_bonus = 25;
   
$a_2_chanse = 5;
     break;
    case 
2:
    
$a_2_bonus = 30;
   
$a_2_chanse = 5;
     break;
    case 
3:
    
$a_2_bonus = 35;
   
$a_2_chanse = 5;
     break;
    case 
4:
    
$a_2_bonus = 40;
   
$a_2_chanse = 5;
     break;
    case 
5:
    
$a_2_bonus = 45;
   
$a_2_chanse = 5;
     break;
    case 
6:
    
$a_2_bonus = 45;
   
$a_2_chanse = 8;
     break;
    case 
7:
    
$a_2_bonus = 50;
   
$a_2_chanse = 8;
     break;
    case 
8:
    
$a_2_bonus = 55;
   
$a_2_chanse = 8;
     break;
    case 
9:
    
$a_2_bonus = 60;
   
$a_2_chanse = 8;
     break;
    case 
10:
    
$a_2_bonus = 65;
   
$a_2_chanse = 8;
     break;
    case 
11:
    
$a_2_bonus = 65;
   
$a_2_chanse = 11;
     break;
    case 
12:
    
$a_2_bonus = 70;
   
$a_2_chanse = 11;
     break;
    case 
13:
    
$a_2_bonus = 75;
   
$a_2_chanse = 11;
     break;
    case 
14:
    
$a_2_bonus = 80;
   
$a_2_chanse = 11;
     break;
    case 
15:
    
$a_2_bonus = 85;
   
$a_2_chanse = 11;
     break;
    case 
16:
    
$a_2_bonus = 85;
   
$a_2_chanse = 14;
     break;
    case 
17:
    
$a_2_bonus = 90;
   
$a_2_chanse = 14;
     break;
    case 
18:
    
$a_2_bonus = 95;
   
$a_2_chanse = 14;
     break;
    case 
19:
    
$a_2_bonus = 100;
   
$a_2_chanse = 14;
     break;
    case 
20:
    
$a_2_bonus = 105;
   
$a_2_chanse = 14;
     break;
    case 
21:
    
$a_2_bonus = 105;
   
$a_2_chanse = 17;
     break;
    case 
22:
    
$a_2_bonus = 145;
   
$a_2_chanse = 20;
     break;
    case 
23:
    
$a_2_bonus = 165;
   
$a_2_chanse = 23;
     break;
    case 
24:
    
$a_2_bonus = 165;
   
$a_2_chanse = 23;
     break;
  }

  if(
mt_rand(0, 100) <= $a_2_chanse) {

    
$a_2 = true;

  }
  }

  if(
$user['ability_3'] > 0) {

  switch(
$user['ability_3']) {
    case 
0:
      
$a_3_bonus = 5;
$a_3_crit_chanse = 5;
     
$a_3_chanse = 20;
     break;
    case 
1:
      
$a_3_bonus = 5;
$a_3_crit_chanse = 5;
     
$a_3_chanse = 20;
     break;
    case 
2:
      
$a_3_bonus = 8;
$a_3_crit_chanse = 5;
     
$a_3_chanse = 20;
     break;
    case 
3:
      
$a_3_bonus = 11;
$a_3_crit_chanse = 5;
     
$a_3_chanse = 20;
     break;
    case 
4:
      
$a_3_bonus = 14;
$a_3_crit_chanse = 5;
     
$a_3_chanse = 20;
     break;
    case 
5:
      
$a_3_bonus = 17;
$a_3_crit_chanse = 5;
     
$a_3_chanse = 20;
     break;
    case 
6:
      
$a_3_bonus = 17;
$a_3_crit_chanse = 7;
     
$a_3_chanse = 25;
     break;
    case 
7:
      
$a_3_bonus = 20;
$a_3_crit_chanse = 7;
     
$a_3_chanse = 25;
     break;
    case 
8:
      
$a_3_bonus = 23;
$a_3_crit_chanse = 7;
     
$a_3_chanse = 25;
     break;
    case 
9:
      
$a_3_bonus = 26;
$a_3_crit_chanse = 7;
     
$a_3_chanse = 25;
     break;
    case 
10:
      
$a_3_bonus = 29;
$a_3_crit_chanse = 7;
     
$a_3_chanse = 25;
     break;
    case 
11:
      
$a_3_bonus = 29;
$a_3_crit_chanse = 9;
     
$a_3_chanse = 30;
     break;
    case 
12:
      
$a_3_bonus = 32;
$a_3_crit_chanse = 9;
     
$a_3_chanse = 30;
     break;
    case 
13:
      
$a_3_bonus = 35;
$a_3_crit_chanse = 9;
     
$a_3_chanse = 30;
     break;
    case 
14:
      
$a_3_bonus = 38;
$a_3_crit_chanse = 9;
     
$a_3_chanse = 30;
     break;
    case 
15:
      
$a_3_bonus = 41;
$a_3_crit_chanse = 9;
     
$a_3_chanse = 30;
     break;
    case 
16:
      
$a_3_bonus = 41;
$a_3_crit_chanse = 11;
     
$a_3_chanse = 35;
     break;
    case 
17:
      
$a_3_bonus = 44;
$a_3_crit_chanse = 11;
     
$a_3_chanse = 35;
     break;
    case 
18:
      
$a_3_bonus = 47;
$a_3_crit_chanse = 11;
     
$a_3_chanse = 35;
     break;
    case 
19:
      
$a_3_bonus = 50;
$a_3_crit_chanse = 11;
     
$a_3_chanse = 35;
     break;
    case 
20:
      
$a_3_bonus = 53;
$a_3_crit_chanse = 11;
     
$a_3_chanse = 35;
     break;
   case 
21:
      
$a_3_bonus = 53;
$a_3_crit_chanse = 13;
     
$a_3_chanse = 40;
     break;
    case 
22:
      
$a_3_bonus = 77;
$a_3_crit_chanse = 15;
     
$a_3_chanse = 45;
     break;
    case 
23:
      
$a_3_bonus = 89;
$a_3_crit_chanse = 17;
     
$a_3_chanse = 50;
     break;
    case 
24:
      
$a_3_bonus = 89;
$a_3_crit_chanse = 17;
     
$a_3_chanse = 50;
     break;

  }

  if(
mt_rand(0, 100) <= $a_3_chanse) {

    
$a_3 = true;

  }

  }

  if(
$user['ability_4'] > 0) {

  switch(
$user['ability_4']) {
    case 
0:
      
$a_4_bonus = 20;
     
$a_4_chanse = 5;
     break;
    case 
1:
      
$a_4_bonus = 20;
     
$a_4_chanse = 5;
     break;
    case 
2:
      
$a_4_bonus = 22;
     
$a_4_chanse = 5;
     break;
    case 
3:
      
$a_4_bonus = 24;
     
$a_4_chanse = 5;
     break;
    case 
4:
      
$a_4_bonus = 26;
     
$a_4_chanse = 5;
     break;
    case 
5:
      
$a_4_bonus = 28;
     
$a_4_chanse = 5;
     break;
    case 
6:
      
$a_4_bonus = 28;
     
$a_4_chanse = 10;
     break;
    case 
7:
      
$a_4_bonus = 30;
     
$a_4_chanse = 10;
     break;
    case 
8:
      
$a_4_bonus = 32;
     
$a_4_chanse = 10;
     break;
    case 
9:
      
$a_4_bonus = 34;
     
$a_4_chanse = 10;
     break;
    case 
10:
      
$a_4_bonus = 36;
     
$a_4_chanse = 10;
     break;
    case 
11:
      
$a_4_bonus = 36;
     
$a_4_chanse = 15;
     break;
    case 
12:
      
$a_4_bonus = 38;
     
$a_4_chanse = 15;
     break;
    case 
13:
      
$a_4_bonus = 40;
     
$a_4_chanse = 15;
     break;
    case 
14:
      
$a_4_bonus = 42;
     
$a_4_chanse = 15;
     break;
    case 
15:
      
$a_4_bonus = 44;
     
$a_4_chanse = 15;
     break;
    case 
16:
      
$a_4_bonus = 44;
     
$a_4_chanse = 20;
     break;
    case 
17:
      
$a_4_bonus = 46;
     
$a_4_chanse = 20;
     break;
    case 
18:
      
$a_4_bonus = 48;
     
$a_4_chanse = 20;
     break;
    case 
19:
      
$a_4_bonus = 50;
     
$a_4_chanse = 20;
     break;
    case 
20:
      
$a_4_bonus = 52;
     
$a_4_chanse = 20;
     break;
    case 
21:
      
$a_4_bonus = 52;
     
$a_4_chanse = 25;
     break;
    case 
22:
      
$a_4_bonus = 68;
     
$a_4_chanse = 30;
     break;
    case 
23:
      
$a_4_bonus = 76;
     
$a_4_chanse = 35;
     break;
    case 
24:
      
$a_4_bonus = 76;
     
$a_4_chanse = 35;
     break;
  }

  if(
mt_rand(0, 100) <= $a_4_chanse) {

    
$a_4 = true;

  }
  
  }

      
$dmg +=round(rand((int)floor($user['str']/6), max((int)floor($user['str']/6), (int)floor($user['str']/4))));
    
      if(
$a_1 == true) {
      
        
$dmg += round(($dmg / 100) * $a_1_bonus);
      
      }
    
      
$dmg -= round(rand((int)floor($opponent['def']/12), max((int)floor($opponent['def']/12), (int)floor($opponent['def']/7))));
        
    if(
$dmg < 0) {
    
      
$dmg = 0;
    
    }

    if(
$a_3 == true) {
    
    
$crit = ( (rand(1,2) * ($user['agi'] / 100) + $a_3_crit_chanse ) - (rand(1,2) * ($opponent['agi'] / 100)));
    
    }
    else
    {

    
$crit = ( (rand(1,2) * ($user['agi'] / 100) ) - (rand(1,2) * ($opponent['agi'] / 100)));

    }

    if(
mt_rand(0, 100) <= $crit) {
   
      
$dmg *= 2;
   
      
$dmg += round(($dmg / 100) * $a_3_bonus);
      
    }


    
$dodge = ( (rand(1,2) * ($opponent['agi'] / 100) ) - (rand(1,2) * ($user['agi'] / 100)));

    if(
mt_rand(0, 100) <= $dodge) {
   
      
$dmg = 0;
      
    }



      
$opponent_dmg +=round(rand((int)floor($opponent['str']/6), max((int)floor($opponent['str']/6), (int)floor($opponent['str']/4))));

      if(
$a_2 == true) {
      
        
$dmg -= round(($opponent_dmg / 100) * $a_2_bonus);
      
      }

      
$opponent_dmg -= round(rand((int)floor($user['def']/12), max((int)floor($user['def']/12), (int)floor($user['def']/7))));
    
    if(
$opponent_dmg < 0) {
    
      
$opponent_dmg = 0;
    
    }


    
$opponent_crit = ( (rand(1,2) * ($opponent['agi'] / 100) ) - (rand(1,2) * ($user['agi'] / 100)));

    if(
mt_rand(0, 100) <= $opponent_crit) {
   
      
$opponent_dmg *= 2;
    
    if(
$a_4 == true) {
    
      
$opponent_dmg -= round(($opponent_dmg / 100) * $a_4_bonus);
    
    }
    
    }    
    
    
$opponent_dodge = ( (rand(1,2) * ($user['agi'] / 100) ) - (rand(1,2) * ($opponent['agi'] / 100)));

    if(
mt_rand(0, 100) <= $opponent_dodge) {
   
      
$opponent_dmg = 0;
      
    }

    }
    
    if(
$dmg > $opponent_dmg) {

    
$_hp  = max(0, (int) round($opponent_dmg / 4));

    }
    else
    {

    
$_hp  = max(0, (int) round($opponent_dmg / 2));    
    
    }

    if(
$_hp < 0) { $_hp = 0; }

    if(
$_hp > $user['hp']) {
        
      
$_hp  = $user['hp'];
        
    }


?>

<div class='block center'>

<?php
    
    
    
if($dmg > $opponent_dmg) {

      
$_s =   rand(1,50) * $opponent['level'];
    
$_exp =   rand(1,20) * $opponent['level'];
          

    if(
$clan_memb && $clan_memb['v'] > 0) {
    
      
$_exp += round($_exp/100) * $clan_memb['v'];
    
    }

    
    
$_rating = rand(1,$opponent['level']);
    
   
db_query('UPDATE `users` SET `duel_rating` = `duel_rating` + '.$_rating.' WHERE `id` = "'.$user['id'].'"');

?>

<img src='/images/icon/2hit.png' alt='*'/> <font color='#90c090'><b>Победа!</b></font> <img src='/images/icon/2hit.png' alt='*'/>

<?php

  
   $opponent 
= duel_select_opponent($user, (int)($duel['opponent'] ?? 0));
   
duel_store_opponent((int)$user['id'], $opponent);

    }
    else
    {

      
$_s =   rand(1,25) * $opponent['level'];
    
$_exp =   rand(1,10) * $opponent['level'];
   if((int)(
$a_f['on/off'] ?? 0) > time() && db_result(db_query('SELECT COUNT(*) FROM `tj_users` WHERE `id_user` = "'.$user['id'].'" LIMIT 1'),0) == '1'){



}

    if(
$clan_memb && $clan_memb['v'] > 0) {
    
      
$_exp += round($_exp/100) * $clan_memb['v'];
    
    }
    
    
$_rating = rand(1,($opponent['level'] * 2));

   
db_query('UPDATE `users` SET `duel_rating` = `duel_rating` - '.(($user['duel_rating'] - $_rating < 0) ? $user['duel_rating']:$_rating).' WHERE `id` = "'.$user['id'].'"');

?>

<img src='/images/icon/2hit.png' alt='*'/> <font color='#c06060'><b>Поражение!</b></font> <img src='/images/icon/2hit.png' alt='*'/>

<?php

    
}

    
// Place
    // 3 - Дуэли
    // Type
    // 0 - Провести n-е кол-во боев (неважно победа или поражени)
    // 1 - Только победы
    // Единый прогресс заданий: один бой + победа при фактическом превосходстве по урону. v50.7
    
game_quest_progress_event((int)$user['id'],3,1,$dmg > $opponent_dmg ? 1 : 0);

        if(
$_s < 1) {
          
          
$_s = 1;
          
        }

        if(
$_exp < 1) {
          
          
$_exp = 1;
          
        }


  if(
$clan_memb) {
    
    
$_exp += round($_exp/100) * (int)($clan_memb['bonus'] ?? 0);
    
  }

  if(
$premium) {
  
  
$_exp+= round($_exp/ 100) * 25;
  
  }
if(
$user['vip_time'] >= time()){

  
$_exp+= round($_exp/ 100) * 70;
}
      if(
$clan) {
       
// Клановое задание дуэлей. v50.6
       
if(game_clan_quest_is_week_open()) game_clan_quest_increment((int)$clan['id'],6,(int)$user['id'],1);
       
//конец
       
db_query('UPDATE `clans`     SET `exp` = `exp` + '.$_exp.' WHERE `id` = "'.$clan['id'].'"');
       
db_query('UPDATE `clan_memb` SET `exp` = `exp` + '.$_exp.' WHERE `clan` = "'.$clan['id'].'" AND `user` = "'.$user['id'].'"');

      }

?>

<?php

  
if($a_1 == true OR $a_2 == true OR $a_3 == true OR $a_4 == true OR $a_5 == true) {
  
?>

  <div class='separ'></div>

<?php

  
if($a_1 == true) echo ' <img src='/images/ability/1.'.$user['ability_1_quality'].'.png' width='25px' height='25px' alt='*'/> ';
  if(
$a_2 == true) echo ' <img src='/images/ability/2.'.$user['ability_2_quality'].'.png' width='25px' height='25px' alt='*'/> ';
  if(
$a_3 == true) echo ' <img src='/images/ability/3.'.$user['ability_3_quality'].'.png' width='25px' height='25px' alt='*'/> ';
  if(
$a_4 == true) echo ' <img src='/images/ability/4.'.$user['ability_4_quality'].'.png' width='25px' height='25px' alt='*'/> ';
  if(
$a_5 == true) echo ' <img src='/images/ability/5.'.$user['ability_5_quality'].'.png' width='25px' height='25px' alt='*'/> ';

  }

  
     
// @ var array [ 'CODE' ]  
     
    
if($user['essence'] <= 199 && mt_rand(0,100) <= 5) {
        
        
$EnableChanse = true;
        
        
        
db_query('UPDATE `users` SET `essence` = `essence` + 1 WHERE `id` = "'.$user['id'].'"');
        
    }
    
    
// @ var array [ 'END' ]
    

     // @ var array [ 'CODE' ]  
     
    
if($user['arena'] <= 20099 && mt_rand(0,100) <= 15) {
        
        
$turnir = true;
        
        
        
db_query('UPDATE `users` SET `arena` = `arena` + 1 WHERE `id` = "'.$user['id'].'"');
        
    }
    
    
// @ var array [ 'END' ]
?>

  <div class='separator'></div>
<img src='/images/icon/silver.png' alt="*"/> <?=$_s?> серебра <img src='/images/icon/exp.png' alt='*'/> <?=$_exp?> опыта
<?php 
// @ var array [ 'CODE' ]           
if($EnableChanse == true) {
?>    
<br /> <img src='/images/essence.png' width='14'>  <font color='#90c090'>Атаковав игрока вы поглотили его сущность.</font> <br />

<?php }
// @ var array [ 'CODE' ]           
if($turnir == true) {
?>    


<?php
    
// @ var array [ 'END' ]
}

  if(
$user['duel_trophy'] + 1 == 5) {

      
$res = rand(1,9);
$res_count = rand(1,3);

    
db_query('UPDATE `sack`  SET    `'.$res.'` = `'.$res.'` + '.$res_count.' WHERE `user` = "'.$user['id'].'"');
    
db_query('UPDATE `users` SET `duel_trophy` = "0"                         WHERE   `id` = "'.$user['id'].'"');

    switch(
$res) {
    case 
1:
    
$res_name = 'Алмаз';
     break;
    case 
2:
    
$res_name = 'Корунд';
     break;
    case 
3:
    
$res_name = 'Обсидиан';
     break;
    case 
4:
    
$res_name = 'Графит';
     break;
    case 
5:
    
$res_name = 'Оникс';
     break;
    case 
6:
    
$res_name = 'Амброзия';
     break;
    case 
7:
    
$res_name = 'Мята';
     break;
    case 
8:
    
$res_name = 'Аир';
     break;
    case 
9:
    
$res_name = 'Рябина';
     break;
  }
  
?>

  <div class='separ'></div>
  <font color='#90b0c0'>Награда за 4 поединков:</font><br/>
  <img src='/images/icon/res/<?=$res?>.png' alt='*'/> <?=$res_name?> (<?=$res_count?> <font color='#90b0c0'>шт.</font>)

<?php
  
  
}
  else
  {
  
db_query('UPDATE `users` SET `duel_trophy` = `duel_trophy` + 1 WHERE `id` = "'.$user['id'].'"');
  
  }

?>

</div>

<?php db_query("UPDATE `users` SET `alex_dobl` = `alex_dobl` + '1' WHERE `id` = '".$user['id']."'");

   
db_query('UPDATE `users` SET `exp` = `exp` + '.$_exp.',
                                     `s` =   `s` + '
.$_s.' WHERE `id` = "'.$user['id'].'"');
 

  
   
db_query('UPDATE `duel` SET `time` = "'.(time() + 1).'" WHERE `user` = "'.$user['id'].'"');

   
db_query('UPDATE `users` SET `hp` = `hp` - '.$_hp.',
                     `duel_last_update` = "'
.time().'",
                          `duel_fights` = `duel_fights` - 1 WHERE `id` = "'
.$user['id'].'"');

   if (
function_exists('tutorial_record_action')) tutorial_record_action($user, 'duel');


   
$opponent = duel_select_opponent($user, (int)($duel['opponent'] ?? 0));
   
duel_store_opponent((int)$user['id'], $opponent);

  }
  else
  {

?>

<div class='block center'>
<font color='#c06060'>У вас закончились бесплатные бои!</font><br/>
До восстановления: <?=_time(($user['duel_last_update'] + (60 * 30)) - time())?>

  <div class='separ'></div>
   <a class='btn' href='/duel/?refresh=true'><span class='end'><span class='label'>Купить сейчас 10 боев</span></span></a>
  <br/>
  <br/>
  <font color='#909090'>Цена: <img src='/images/icon/gold.png' alt='*'/> 20 золота</font>

</div>

<?php
  
  
}
  
  }
  else
  {

?>

<div class='mini-line'></div>
<div class='content' align='center'>
<font color='#c06060'>Для нападения надо минимум <img src='/images/icon/health.png' alt='*'/> 10% жизни</font>  
</div>

<?php

  
}

  }
  else
  {

?>

<?php

  
}

/* Старая система обучения удалена; используется system/tutorial.php. by Метриум (Стэлп) */
?>
<div class='main'>
<div class='block' align='center'>
<font color='#90b0c0'>Мой рейтинг: <?=$user['duel_rating']?></font>
<center/>Чем выше рейтинг, тем больше награда<center/>
<?php

if(($_GET['attack'] ?? '') == 'true' && $_rating > 0) {

  if(
$dmg > $opponent_dmg) {

?><font color='#30c030'>(+<?php

  
}
  else
  {

?><font color='#f33'>(-<?php

  
}

?><?=$_rating?>)</font>
<?php

}

?></div>
<?php

  $opponent 
= duel_load_opponent((int)($duel['opponent'] ?? 0), $user);
  
$duelItems = duel_opponent_item_ids($opponent);
  for(
$i=1;$i<=8;$i++){ ${'w_'.$i}=['item'=>(int)$duelItems[$i-1]]; }

?>

<div class='' align='center'>
      
  <img src='/images/icon/race/<?=$opponent['r']?>.png' alt='*'/> <?=$opponent['login']?><br/>
  Рейтинг: <?=$opponent['duel_rating']?><br/>

  <a href='?attack=true'><img src='/manekenImage/<?=$opponent['sex']?>/<?=$w_1['item']?>/<?=$w_2['item']?>/<?=$w_3['item']?>/<?=$w_4['item']?>/<?=$w_5['item']?>/<?=$w_6['item']?>/<?=$w_7['item']?>/<?=$w_8['item']?>/' alt='*'/></a><br/>
  
  <img src='/images/icon/str.png' alt='*'/> <?=$opponent['str']?>
  <img src='/images/icon/vit.png' alt='*'/> <?=$opponent['vit']?>
  <img src='/images/icon/agi.png' alt='*'/>  <?=$opponent['agi']?>
  <img src='/images/icon/def.png' alt='*'/> <?=$opponent['def']?>
    <div class='separ'></div>

   <a class='btn' href='?attack=true'><span class='end'><span class='label'>Атаковать</span></span></a> <br/><br/>
 
    <font color='#90b0c0'>Доступно боёв:</font> <img src='/images/icon/2hit.png' alt='*'/> <b><?=$user['duel_fights']?></b><br/>
    <font color='#90b0c0'>Награда:</font> <?=$user['duel_trophy']?> из 4 боев</font>
 </td>
 </tr></table>
 
</div>

  <div class='separ'></div>
<div class='' align='center'>
  <img src='/images/icon/race/<?=$user['r']?>.png' alt='*'/> <?=$user['login']?><br/>
<img src='/images/icon/str.png' alt='*'/> <?=$user['str']?> <img src='/images/icon/vit.png' alt='*'/> <?=$user['vit']?> <img src='/images/icon/agi.png' alt='*'/> <?=$user['agi']?> <img src='/images/icon/def.png' alt='*'/> <?=$user['def']?>
</div>

<div class='separ'></div>

<div class='' align='center'>
  <a class='btn' href='?last=true'><span class='end'><span class='label'>Другой противник</span></span></a><br/>
  <font color='#909090'>Бесплатная смена противника: <img src='/images/icon/hit.png' alt='*'/> <?=$user['duel_changes']?> раз</font>
</div>
<div class='mini-line'></div></div><div class='main'><ul class='hint '><li>1 бой восстанавливается 2 часа. Бои не накапливаются больше 11.</li><li>После 4 поединков, вы получите по 1 случайному ресурсу за каждые 500 рейтинга</li><li>Награда за 5 боев выдается раз в сутки</li><li>Одна бесплатная смена противника добавляется каждые 2 часа. Бесплатных смен не накапливается больше 5</li></ul></div>
<?php

}
else
{

?>

  <div class='main'>
<div class='block' align='center'>
  <img src='/images/icon/farm.png' alt='*'/> Дуэли доступны с <img src='/images/icon/level.png' alt='*'/> 5 уровня<br/>
</div></div>


<?php

}

include 
'./system/f.php';

?>
Онлайн: 0
Реклама