<?php
define('PROTECTOR', 1);
include('files/path.php');
include($path.'files/db.php');
include($path.'files/auth.php');
include($path.'files/func.php');
$textl='Дуэли';
include($path.'files/core.php');
include($path.'files/head.php');
include($path.'files/zag.php');

if($new_lvl=='yes'){header('Location: arena_dueli.php');exit;}
//********************
$mag = mysql_fetch_array(mysql_query("SELECT * FROM `mag` WHERE `usr` = '$log'"));
                if ($mag['yarost'] > 0) {
                    switch ($mag['yarost']) {
                        case 5:
                            $a_1_bonus  = 45;
                            $a_1_chanse = 8;
                            break;
                        case 10:
                            $a_1_bonus  = 50;
                            $a_1_chanse = 8;
                            break;
                        case 15:
                            $a_1_bonus  = 55;
                            $a_1_chanse = 8;
                            break;
                        case 20:
                            $a_1_bonus  = 60;
                            $a_1_chanse = 8;
                            break;
                        case 25:
                            $a_1_bonus  = 65;
                            $a_1_chanse = 8;
                            break;
                        case 30:
                            $a_1_bonus  = 65;
                            $a_1_chanse = 11;
                            break;
                        case 35:
                            $a_1_bonus  = 70;
                            $a_1_chanse = 11;
                            break;
                        case 40:
                            $a_1_bonus  = 75;
                            $a_1_chanse = 11;
                            break;
                        case 45:
                            $a_1_bonus  = 80;
                            $a_1_chanse = 11;
                            break;
                        case 50:
                            $a_1_bonus  = 85;
                            $a_1_chanse = 11;
                            break;
                        case 55:
                            $a_1_bonus  = 85;
                            $a_1_chanse = 14;
                            break;
                        case 60:
                            $a_1_bonus  = 90;
                            $a_1_chanse = 14;
                            break;
                        case 65:
                            $a_1_bonus  = 95;
                            $a_1_chanse = 14;
                            break;
                        case 70:
                            $a_1_bonus  = 100;
                            $a_1_chanse = 14;
                            break;
                        case 75:
                            $a_1_bonus  = 105;
                            $a_1_chanse = 14;
                            break;
                        case 80:
                            $a_1_bonus  = 105;
                            $a_1_chanse = 17;
                            break;
                        case 85:
                            $a_1_bonus  = 145;
                            $a_1_chanse = 20;
                            break;
                        case 90:
                            $a_1_bonus  = 165;
                            $a_1_chanse = 23;
                            break;
                        case 95:
                            $a_1_bonus  = 165;
                            $a_1_chanse = 23;
                            break;
                        case 100:
                            $a_1_bonus  = 200;
                            $a_1_chanse = 25;
                            break;

                    }
                    if (isset($a_1_chanse) AND mt_rand(0, 100) <= $a_1_chanse) {
                        $a_1 = true;
                    }
                }
                if ($mag['bronya'] > 0) {
                    switch ($mag['bronya']) {
                        case 5:
                            $a_2_bonus  = 45;
                            $a_2_chanse = 8;
                            break;
                        case 10:
                            $a_2_bonus  = 50;
                            $a_2_chanse = 8;
                            break;
                        case 15:
                            $a_2_bonus  = 55;
                            $a_2_chanse = 8;
                            break;
                        case 20:
                            $a_2_bonus  = 60;
                            $a_2_chanse = 8;
                            break;
                        case 25:
                            $a_2_bonus  = 65;
                            $a_2_chanse = 8;
                            break;
                        case 30:
                            $a_2_bonus  = 65;
                            $a_2_chanse = 11;
                            break;
                        case 35:
                            $a_2_bonus  = 70;
                            $a_2_chanse = 11;
                            break;
                        case 40:
                            $a_2_bonus  = 75;
                            $a_2_chanse = 11;
                            break;
                        case 45:
                            $a_2_bonus  = 80;
                            $a_2_chanse = 11;
                            break;
                        case 50:
                            $a_2_bonus  = 85;
                            $a_2_chanse = 11;
                            break;
                        case 55:
                            $a_2_bonus  = 85;
                            $a_2_chanse = 14;
                            break;
                        case 60:
                            $a_2_bonus  = 90;
                            $a_2_chanse = 14;
                            break;
                        case 65:
                            $a_2_bonus  = 95;
                            $a_2_chanse = 14;
                            break;
                        case 70:
                            $a_2_bonus  = 100;
                            $a_2_chanse = 14;
                            break;
                        case 75:
                            $a_2_bonus  = 105;
                            $a_2_chanse = 14;
                            break;
                        case 80:
                            $a_2_bonus  = 105;
                            $a_2_chanse = 17;
                            break;
                        case 85:
                            $a_2_bonus  = 145;
                            $a_2_chanse = 20;
                            break;
                        case 90:
                            $a_2_bonus  = 165;
                            $a_2_chanse = 23;
                            break;
                        case 95:
                            $a_2_bonus  = 165;
                            $a_2_chanse = 23;
                            break;
                         case 100:
                            $a_2_bonus  = 200;
                            $a_2_chanse = 25;
                            break;
                    }
                    if (isset($a_2_chanse) AND mt_rand(0, 100) <= $a_2_chanse) {
                        $a_2 = true;
                    }
                }
                if ($mag['vihr'] > 0) {
                    switch ($mag['vihr']) {
                        case 5:
                            $a_3_bonus       = 5;
                            $a_3_crit_chanse = 5;
                            $a_3_chanse      = 5;
                            break;
                        case 10:
                            $a_3_bonus       = 10;
                            $a_3_crit_chanse = 5;
                            $a_3_chanse      = 5;
                            break;
                        case 15:
                            $a_3_bonus       = 15;
                            $a_3_crit_chanse = 5;
                            $a_3_chanse      = 5;
                            break;
                        case 20:
                            $a_3_bonus       = 20;
                            $a_3_crit_chanse = 5;
                            $a_3_chanse      = 10;
                            break;
                        case 25:
                            $a_3_bonus       = 25;
                            $a_3_crit_chanse = 5;
                            $a_3_chanse      = 10;
                            break;
                        case 30:
                            $a_3_bonus       = 30;
                            $a_3_crit_chanse = 5;
                            $a_3_chanse      = 15;
                            break;
                        case 35:
                            $a_3_bonus       = 35;
                            $a_3_crit_chanse = 5;
                            $a_3_chanse      = 15;
                            break;
                        case 40:
                            $a_3_bonus       = 40;
                            $a_3_crit_chanse = 10;
                            $a_3_chanse      = 20;
                            break;
                        case 45:
                            $a_3_bonus       = 45;
                            $a_3_crit_chanse = 10;
                            $a_3_chanse      = 20;
                            break;
                        case 50:
                            $a_3_bonus       = 50;
                            $a_3_crit_chanse = 10;
                            $a_3_chanse      = 25;
                            break;
                        case 55:
                            $a_3_bonus       = 55;
                            $a_3_crit_chanse = 10;
                            $a_3_chanse      = 25;
                            break;
                        case 60:
                            $a_3_bonus       = 60;
                            $a_3_crit_chanse = 10;
                            $a_3_chanse      = 30;
                            break;
                        case 65:
                            $a_3_bonus       = 65;
                            $a_3_crit_chanse = 10;
                            $a_3_chanse      = 30;
                            break;
                        case 70:
                            $a_3_bonus       = 70;
                            $a_3_crit_chanse = 10;
                            $a_3_chanse      = 35;
                            break;
                        case 75:
                            $a_3_bonus       = 75;
                            $a_3_crit_chanse = 15;
                            $a_3_chanse      = 35;
                            break;
                        case 80:
                            $a_3_bonus       = 80;
                            $a_3_crit_chanse = 15;
                            $a_3_chanse      = 40;
                            break;
                        case 85:
                            $a_3_bonus       = 85;
                            $a_3_crit_chanse = 15;
                            $a_3_chanse      = 40;
                            break;
                        case 90:
                            $a_3_bonus       = 90;
                            $a_3_crit_chanse = 15;
                            $a_3_chanse      = 45;
                            break;
                        case 95:
                            $a_3_bonus       = 95;
                            $a_3_crit_chanse = 15;
                            $a_3_chanse      = 45;
                            break;
                       case 100:
                            $a_3_bonus       = 100;
                            $a_3_crit_chanse = 20;
                            $a_3_chanse      = 50;
                            break;
                    }
                    if (isset($a_3_chanse) AND mt_rand(0, 100) <= $a_3_chanse) {
                        $a_3 = true;
                    }
                }


if($set['razb']==0){
echo'<div class="main"><div class="block_zero center">У Вас нет профессии - Дуэлянт,<br>Вы не можете сражаться на дуэлях!</div></div>';
include($path.'files/down.php');exit;
}
$time=time();
$tim=$time+3600;
switch($_GET['mod']){
default:
$leg=mysql_query("SELECT * FROM `arenalog` WHERE `usr`='$log' LIMIT 1");
$logs1=mysql_num_rows($leg);
if($logs1==0){
mysql_query("INSERT INTO `arenalog` SET `usr` = '$log'");
}
$logs=mysql_fetch_array($leg);

if($set['arenainv']==0){
if($set['artime']==0){
mysql_query("UPDATE `set` SET `arenainv` = '$set[invmax]', `artime` = '$tim'  WHERE `usr` = '$log'");
header('Location: arena_dueli.php');exit;
}
echo'<div class="main"><div class="block_zero center"><span style="color: #9CC;">Одержи 100 побед и получи награду!</div><div class="mini-line"></div><div class="block_zero center">Прогресс: '.$set['arenawins'].' из 100<br>Доступно боёв: '.$set['arenainv'].' из '.$set['invmax'].'</div></div>';
$nachalo=$set['artime']-$time;
echo'<div class="mini-line"></div><div class="block_zero center"><span style="color: #999;">Бои восстановятся через '.Sec2Time($nachalo).'</div></span>';
echo'<div class="separ"></div><div class="block_zero center"><span style="color: #c66;">У Вас нет боёв! Ожидайте восстановления!</span><div class="separ"></div><a class="btn" href="arena_dueli.php?mod=pokup_boi"><span class="end"><span class="label">Восстановить 10 за <img src="image/icon/almaz.png" alt="*"> 100</span></span></a></div>';
}else{
echo'<div class="main"><div class="block_zero center"><span style="color: #9CC;">Одержи 100 побед и получи награду!</div><div class="mini-line"></div><div class="block_zero center">Прогресс: '.$set['arenawins'].' из 100<br>Доступно боёв: '.$set['arenainv'].' из '.$set['invmax'].'</div></div>';
}

if($set['arenawins']>=100){
$kolr=$set['razb']*50;
$kolm=$kolr*10;
$kolexp=1000;
mysql_query("UPDATE `users` SET `almaz`='$udata[almaz]'+'$kolr', `money`='$udata[money]'+'$kolm', `exp`='$udata[exp]'+'$kolexp' WHERE `usr`='$log'");
mysql_query("UPDATE `set` SET `arenawins`='0' WHERE `usr`='$log'");
$time = date("H:i d.m.y");
$text = 'Поздравляем!!!<br>Вы выполнили задание в Дуэлях<br> и получили <img src="image/icon/almaz.png" alt="pic"> '.$kolr.'  <img src="image/icon/money.png" alt="pic"> '.$kolm.'  <img src="image/icon/exp.png" alt="pic"> '.$kolexp.'';
mysql_query("INSERT INTO `msg_r` SET `user_from` = 'Секундант', `user_to` = '$log', `time` = '$time', `read` = 1, `mail_msg` = '$text'");
header ("Location: arena_dueli.php?log=priz");exit;
}

if(isset($_GET['log'])){

if($_GET['log']=="priz"){

echo '<div class="mini-line"></div><div class="block_zero center"><span style="color: #9C9;">Задание выполнено!</span></div>';
}

if($_GET['log']=='hp'){
echo'<div class="main"><div class="block_zero center"><span style="color: #c66;">Для нападения надо минимум <br><img src="image/icon/health.png" alt="*"> 10% жизни и <img src="image/icon/mana.png" alt="*"> 50 маны</span></div><div class="separ"></div><div class="block_zero"><img class="float-left" src="image/nastojka/potion.png" width="40" height="40" style="margin-left:80px;margin-right:10px;" alt="аватар">Настойка бодрости<br>+100% маны и жизни<br><br><div class="block_zero center"><a class="btn" href="arena_dueli.php?mod=pokup_par"><span class="end"><span class="label">Восстановить за <img src="image/icon/almaz.png" alt="*"> 15</span></span></a></div></div></div>';
}
if($_GET['log']=='win'){
echo'<div class="mini-line"></div><div class="block_zero center"><span style="color: #9c9;"><img src="image/icon/2hit.png" alt="*"> Победа! <img src="image/icon/2hit.png" alt="*"></span>';
if ((isset($a_1) AND $a_1 == true) OR (isset($a_2) AND $a_2 == true) OR (isset($a_3) AND $a_3 == true) OR (isset($a_4) AND $a_4 == true)) {
echo'<div class="separ"></div>';
if (isset($a_1) AND $a_1 == true) {
                        if ($mag['yarost'] == 0) {
                            $pic = 0;
                        }
                        if ($mag['yarost'] >= 1) {
                            $pic = 1;
                        }
                        if ($mag['yarost'] >= 20) {
                            $pic = 2;
                        }
                        if ($mag['yarost'] >= 40) {
                            $pic = 3;
                        }
                        if ($mag['yarost'] >= 60) {
                            $pic = 4;
                        }
                        if ($mag['yarost'] >= 80) {
                            $pic = 5;
                        }
                        if ($mag['yarost'] == 100) {
                            $pic = 6;
                        }
                        echo ' <img src=\'/image/umehi/1.' . $pic . '.png\' width=\'25px\' height=\'25px\' alt=\'*\'/> ';
                    }
if (isset($a_2) AND $a_2 == true) {
                        if ($mag['bronya'] == 0) {
                            $pic2 = 0;
                        }
                        if ($mag['bronya'] >= 1) {
                            $pic2 = 1;
                        }
                        if ($mag['bronya'] >= 20) {
                            $pic2 = 2;
                        }
                        if ($mag['bronya'] >= 40) {
                            $pic2 = 3;
                        }
                        if ($mag['bronya'] >= 60) {
                            $pic2 = 4;
                        }
                        if ($mag['bronya'] >= 80) {
                            $pic2 = 5;
                        }
                        if ($mag['bronya'] == 100) {
                            $pic2 = 6;
                        }
                        echo ' <img src=\'/image/umehi/2.' . $pic2 . '.png\' width=\'25px\' height=\'25px\' alt=\'*\'/> ';
                    }
                    if (isset($a_3) AND $a_3 == true) {
                        if ($mag['vihr'] == 0) {
                            $pic3 = 0;
                        }
                        if ($mag['vihr'] >= 1) {
                            $pic3 = 1;
                        }
                        if ($mag['vihr'] >= 20) {
                            $pic3 = 2;
                        }
                        if ($mag['vihr'] >= 40) {
                            $pic3 = 3;
                        }
                        if ($mag['vihr'] >= 60) {
                            $pic3 = 4;
                        }
                        if ($mag['vihr'] >= 80) {
                            $pic3 = 5;
                        }
                        if ($mag['vihr'] == 100) {
                            $pic3 = 6;
                        }
                        echo ' <img src=\'/image/umehi/3.' . $pic3 . '.png\' width=\'25px\' height=\'25px\' alt=\'*\'/> ';
                    }
                    if (isset($a_4) AND $a_4 == true) {
                        if ($mag['stoika'] == 0) {
                            $pic4 = 0;
                        }
                        if ($mag['stoika'] >= 1) {
                            $pic4 = 1;
                        }
                        if ($mag['stoika'] >= 20) {
                            $pic4 = 2;
                        }
                        if ($mag['stoika'] >= 40) {
                            $pic4 = 3;
                        }
                        if ($mag['stoika'] >= 60) {
                            $pic4 = 4;
                        }
                        if ($mag['stoika'] >= 80) {
                            $pic4 = 5;
                        }
                        if ($mag['stoika'] == 100) {
                            $pic4 = 6;
                        }
                        echo ' <img src=\'/image/umehi/4.' . $pic4 . '.png\' width=\'25px\' height=\'25px\' alt=\'*\'/> ';
                    }
}
echo'<div class="separ"></div><img src="image/icon/money.png" alt="*"> '.$logs['money'].' монет <img src="image/icon/exp.png" alt="*"> '.$logs['exp'].' опыта';
}
if($_GET['log']=='los'){
echo'<div class="mini-line"></div><div class="block_zero center"><span style="color: #c66;"><img src="image/icon/2hit.png" alt="*"> Поражение! <img src="image/icon/2hit.png" alt="*"></span><div class="separ"></div><img src="image/icon/money.png" alt="*"> '.$logs['money'].' монет <img src="image/icon/exp.png" alt="*"> '.$logs['exp'].' опыта</div>';
}
if($_GET['log']=='nogold'){
$nogold=5-$udata['almaz'];
echo'<div class="mini-line"></div><div class="block_zero center">Не хватает <img src="image/icon/almaz.png" alt="*"> '.$nogold.' золота<div class="separ"></div><a href=""><span class="btn"><span class="end"><input class="label" type="submit" value="Купить"></span></span></a></div>';
}
if($_GET['log']=='nogold2'){
$nogold=10-$udata['almaz'];
echo'<div class="separ"></div><div class="block_zero center">Не хватает <img src="image/icon/almaz.png" alt="*"> '.$nogold.' золота<div class="separ"></div><a href=""><span class="btn"><span class="end"><input class="label" type="submit" value="Купить"></span></span></a></div>';
}
}
echo'</div><div class="mini-line"></div><div class="main"><div class="block_zero center">';

if(empty($boys2['usr'])){
$log2=rand($udata['lvl']-5,$udata['lvl']+5);
$boy2=mysql_query("SELECT * FROM `users` WHERE `lvl`='$log2' AND `usr`!='$log' ORDER BY RAND() LIMIT 1");
$boys2 = mysql_fetch_array($boy2);
$avto = mysql_num_rows($boy2);
if($avto==0){
$log2=rand($udata['lvl']-5,$udata['lvl']+5);
$boy2=mysql_query("SELECT * FROM `users` WHERE `lvl`='$log2' AND `usr`!='$log' ORDER BY RAND() LIMIT 1");
$boys2 = mysql_fetch_array($boy2);
}
}

//-----
if(empty($boys2['usr'])){
$stat2=false;
echo'Нет подходящего игрока<br>';
echo'<img src="image/avatar/not.png" width="110" height="110" style="margin-left:0px;margin-right:0px;" alt="аватар"><br>';
echo'<img src="image/icon/str.png" alt="*"> нет <img src="image/icon/health.png" alt="*"> нет <img src="image/icon/agi.png" alt="*"> нет <img src="image/icon/def.png" alt="*"> нет<div class="separ"></div>Нельзя атаковать';
}else{
$ref = mysql_fetch_assoc(mysql_query("SELECT `storona` FROM `users` WHERE `usr` = '$boys2[usr]' LIMIT 1"));
if($ref['storona']=='white'){
$p=1;
}else{
$p=0;
}
$laikas = 300;
$dabar = time();
$timeout = $dabar - $laikas;
$asd = mysql_num_rows(mysql_query("SELECT `laikas`, `usr` FROM `online` WHERE `laikas` > '$timeout' AND `usr` = '$boys2[usr]'"));
if($asd==0){
$gde='off';
}else{
$gde='';
}
echo'<img src="image/icon/'.$p.''.$gde.'.png" alt="*"> '.$boys2['usr'].'<br>';
$stat2=$boys2['sila']+$boys2['hp']+$boys2['lovk']+$boys2['prot'];
if($boys2['klas']=="wizard"){$kl="w";}else{$kl="f";}
if($boys2['storona']=="white"){$papka="scw";}else{$papka="scb";}
if($boys2['lvl']<5){$st="a";}
elseif($boys2['lvl']>=5 and $boys2['lvl']<10){$st="b";}
elseif($boys2['lvl']>=10 and $boys2['lvl']<15){$st="c";}
elseif($boys2['lvl']>=15 and $boys2['lvl']<20){$st="d";}
elseif($boys2['lvl']>=20 and $boys2['lvl']<25){$st="e";}
elseif($boys2['lvl']>=25 and $boys2['lvl']<35){$st="f";}
elseif($boys2['lvl']>=35 and $boys2['lvl']<45){$st="g";}
elseif($boys2['lvl']>=45 and $boys2['lvl']<55){$st="h";}
elseif($boys2['lvl']>=55){$st="i";}
$ban = mysql_num_rows(mysql_query("SELECT * FROM `ban` WHERE `usr` = '$boys2[usr]' LIMIT 1"));
$sett = mysql_query("SELECT * FROM `set` WHERE `usr` = '$boys2[usr]' LIMIT 1");
$sett = mysql_fetch_array($sett);
if($ban == 1){
echo'<img src="image/avatar/ban.png" width="110" height="110" style="margin-left:0px;margin-right:0px;" alt="аватар"><br>';
}
elseif(!empty($sett['avatar'])){
echo'<img src="image/avatar/upload/'.$sett['avatar'].'" width="110" height="110" style="margin-left:0px;margin-right:0px;" alt="аватар"><br>';
}
elseif(!empty($boys2['avatar'])){
echo'<img src="image/avatar/nova/'.$papka.'/'.$boys2['avatar'].'" width="110" height="110" style="margin-left:0px;margin-right:0px;" alt="аватар"><br>';
}else{
echo'<img src="image/avatar/'.$boys2['storona'].'/'.$boys2['pol'].''.$kl.''.$st.'.png" width="110" height="110" style="margin-left:0px;margin-right:0px;" alt="аватар"><br>';
}
echo'<img src="image/icon/str.png" alt="*"> '.$boys2['sila'].' <img src="image/icon/health.png" alt="*"> '.$boys2['hp'].' <img src="image/icon/agi.png" alt="*"> '.$boys2['lovk'].' <img src="image/icon/def.png" alt="*"> '.$boys2['prot'].'<div class="separ"></div>
';
echo'<form action="arena_dueli.php?mod=ataka&ataka&user2='.$boys2['usr'].'&stat='.$stat2.'" method="POST"><span class="btn"><span class="end"><input class="label" type="submit" value="Атаковать"></span></span></form>';
}
echo'
</div><div class="mini-line"></div>
<div class="block_zero center">
'.$udata['usr'].'<br>
<img src="image/icon/str.png" alt="*"> 
'.$udata['sila'].' 
<img src="image/icon/health.png" alt="*"> 
'.$udata['hp'].'
<img src="image/icon/agi.png" alt="*"> 
'.$udata['lovk'].' 
<img src="image/icon/def.png" alt="*"> 
'.$udata['prot'].'
</div>
';

echo'<div class="mini-line"></div><div class="block_zero center"><a href="arena_dueli.php?"><span class="btn"><span class="end"><input class="label" type="submit" value="Сменить противника"></span></span></a></div><div class="mini-line"></div>';

if($udata['storona']=='white'){
$pers=1;
}else{
$pers=0;
}

if ($user_id==0){
$gde1='off';
}else{
$gde1='';
}

echo'
<div class="block_zero">
';

if(isset($_GET['log'])){
$ref = mysql_fetch_assoc(mysql_query("SELECT `storona` FROM `users` WHERE `usr` = '$logs[oponent]' LIMIT 1"));
if($ref['storona']=='white'){
$p=1;
}else{
$p=0;
}
$laikas = 300;
$dabar = time();
$timeout = $dabar - $laikas;
$asd = mysql_num_rows(mysql_query("SELECT `laikas`, `usr` FROM `online` WHERE `laikas` > '$timeout' AND `usr` = '$logs[oponent]'"));
if($asd==0){
$gde='off';
}else{
$gde='';
}
if($_GET['log']=='win'){
echo'<img src="image/icon/'.$pers.''.$gde1.'.png" alt="*"> '.$log.'<br><img src="image/icon/hit.png" alt="*"><small> Нанесено урона: '.$logs['myudar'].'</small></div><div class="dot-line"></div><div class="block_zero"><img src="image/icon/'.$p.''.$gde.'.png" alt="*"> '.$logs['oponent'].'<br><img src="image/icon/hit.png" alt="*"><small> Нанесено урона: '.$logs['userudar'].'</small></div><div class="mini-line"></div>';
}
if($_GET['log']=='los'){
echo'<img src="image/icon/'.$pers.''.$gde1.'.png" alt="*"> '.$log.'<br><img src="image/icon/hit.png" alt="*"><small> Нанесено урона: '.$logs['myudar'].'</small></div><div class="dot-line"></div><div class="block_zero"><img src="image/icon/'.$p.''.$gde.'.png" alt="*"> '.$logs['oponent'].'<br><img src="image/icon/hit.png" alt="*"><small> Нанесено урона: '.$logs['userudar'].'</small></div><div class="mini-line"></div>';
}
}

echo'<ul class="hint"><li>Каждый уровень профессии Дуэлянт добавляет 10 боёв</li><li>Чем сильнее противник, тем больше опыта и серебра получишь за победу</li><li>Все бои восстанавливаются через час, после того как были полностью израсходованы</li><li>При наборе 100 побед Вам будут выданы ресурсы</li></ul></div></div></div>';

include($path.'files/down.php');
break;

case 'pokup_boi':
if($udata['almaz']<5){
header ("Location: arena_dueli.php?log=nogold2");exit;
}else{
mysql_query("UPDATE `users` SET `almaz`=`almaz`-'100' WHERE `usr`='$log'");
mysql_query("UPDATE `set` SET `arenainv`=`arenainv`+'10' WHERE `usr`='$log'");
header ("Location: arena_dueli.php");exit;
}
break;

case 'ataka':
if(isset($_GET['ataka'])){
$header=TRUE;

$log2=rand($udata['lvl']-5,$udata['lvl']+5);
$boy2=mysql_query("SELECT * FROM `users` WHERE `lvl`='$log2' AND `usr`!='$log' ORDER BY RAND() LIMIT 1");
$boys2 = mysql_fetch_array($boy2);

$rand=rand(0,100);
$mprand=50;
$hprand=$udata['hpall']/10;
if($set['arenainv']==0){
$ost=$time+300;
mysql_query("UPDATE `arenalog` SET `name`='inv', `log`='$ost' WHERE `usr` = '$log'");
header ("Location: arena_dueli.php?log=inv");exit;
}
if($udata['hp']<$hprand OR $udata['mp']<50){
mysql_query("UPDATE `arenalog` SET `name` = 'hp' WHERE `usr` = '$log'");
header("Location: arena_dueli.php?log=hp");exit;
}else{
if($udata['lvl']>=0 AND $udata['lvl']<=5){
$koef1=rand(2,4);
$koef2=rand(4,8);
$koef3=rand(6,10);
$bon1=rand(1,4)*1.5;
$bon2=rand(2,6)*1.5;
$bon3=rand(6,8)*1.5;
}
if($udata['lvl']>5 and $udata['lvl']<=10){
$koef1=rand(2,4);
$koef2=rand(4,8);
$koef3=rand(6,10);
$bon1=rand(1,4)*1.5;
$bon2=rand(5,15)*1.5;
$bon3=rand(10,20)*1.5;
}
if($udata['lvl']>10 and $udata['lvl']<=20){
$koef1=rand(8,16);
$koef2=rand(10,20);
$koef3=rand(20,30);
$bon1=rand(8,16)*1.6;
$bon2=rand(10,20)*1.6;
$bon3=rand(20,30)*1.6;
}
if($udata['lvl']>20 and $udata['lvl']<=30){
$koef1=rand(14,22);
$koef2=rand(15,25);
$koef3=rand(30,40);
$bon1=rand(14,22)*1.7;
$bon2=rand(15,25)*1.7;
$bon3=rand(30,40)*1.7;
}
if($udata['lvl']>30 and $udata['lvl']<=40){
$koef1=rand(20,28);
$koef2=rand(20,35);
$koef3=rand(40,50);
$bon1=rand(20,28)*1.8;
$bon2=rand(20,35)*1.8;
$bon3=rand(40,50)*1.8;
}
if($udata['lvl']>40 and $udata['lvl']<=50){
$koef1=rand(26,32);
$koef2=rand(30,45);
$koef3=rand(50,60);
$bon1=rand(26,32)*1.9;
$bon2=rand(30,45)*1.9;
$bon3=rand(50,60)*1.9;
}
if($udata['lvl']>50 and $udata['lvl']<=60){
$koef1=rand(30,36);
$koef2=rand(35,55);
$koef3=rand(50,65);
$bon1=rand(30,36)*2;
$bon2=rand(35,55)*2;
$bon3=rand(50,70)*2;
}
if(!empty($_GET['user1'])){
$shans=80;
$var=round($koef1+$set['razb']*1.5);$bon=round($bon1+$set['razb']*3);$user=$_GET['user1'];
}
if(!empty($_GET['user2'])){
$shans=66;
$var=round($koef2+$set['razb']*1.5);$bon=round($bon2+$set['razb']*3);$user=$_GET['user2'];
}
if(!empty($_GET['user3'])){
$shans=40;
$var=round($koef3+$set['razb']*2);
$bon=round($bon3+$set['razb']*3);$user=$_GET['user3'];
}
$stat=$_GET['stat'];
$my=$udata['sila']+$udata['hpall']+$udata['lovk']+$udata['prot'];
if(($my-$stat)>=10){
$shans=80;
}
if($shans>=$rand){
$uron=3+rand(0,$udata['hp']/5);
$uron=round($uron);
$udar=round($uron+$uron/6);
if($set['vip']=='on'){
$var=$var*1.5;
$bon=$bon*1.5;
}

mysql_query("UPDATE `users` SET `money` = '$udata[money]'+'$var', `exp` = '$udata[exp]'+'$bon', `hp` =  '$udata[hp]'-'$uron', `mp` = '$udata[mp]'-'$mprand' WHERE `usr` = '$log'");
mysql_query("UPDATE `set` SET `arenainv` = `arenainv`-1, `arenawins` = `arenawins`+1, `artime`='$tim', `allwins` = `allwins`+1 WHERE `usr` = '$log'");
mysql_query("UPDATE `arenalog` SET `name`='win',`oponent` = '".mysql_real_escape_string($user)."',`money` = '".mysql_real_escape_string($var)."',`exp` = '".mysql_real_escape_string($bon)."',
`myudar` = '$udar', `userudar` = '$uron' WHERE `usr` = '$log'");
$req = mysql_query("SELECT * FROM `clan` where `lider`='$udata[clan]'");
$avto=mysql_num_rows($req);
$clan = mysql_fetch_array($req);
if($avto==1){
$clexp=$bon/10;
}
mysql_query("UPDATE `clan` SET `exp` = `exp`+'$clexp' WHERE `lider` = '$udata[clan]'");
mysql_query("UPDATE `users` SET `clanexp` = `clanexp`+'$clexp' WHERE `usr` = '$log'");
ob_start();
header ("Location: arena_dueli.php?log=win");exit;
}else{
if($set['vip']=='on'){
$var=$var*1.5;
$bon=$bon*1.5;
}else{
$var=1*round($var/4);
$bon=round($bon/2);
}
$uron=1+rand(0,$udata['hp']/5);
$uron=round($uron);
$udar=round($uron-$uron/6);

mysql_query("UPDATE `users` SET `money` = '$udata[money]'+'$var', `exp` = '$udata[exp]'+'$bon', `hp` = '$udata[hp]'-'$uron', `mp` = '$udata[mp]'-'$mprand' WHERE `usr` = '$log'");
mysql_query("UPDATE `set` SET `arenainv` = `arenainv`-1, `arenaloses` = `arenaloses`+1, `artime`='$tim'  WHERE `usr` = '$log'");
mysql_query("UPDATE `arenalog` SET `name` = 'los',`oponent` = '".mysql_real_escape_string($user)."',`money` = '".mysql_real_escape_string($var)."',`exp` = '".mysql_real_escape_string($bon)."',
`myudar` = '$udar', `userudar` = '$uron' WHERE `usr` = '$log'");
$req = mysql_query("SELECT * FROM `clan` where `lider`='$udata[clan]'");
$avto=mysql_num_rows($req);
$clan = mysql_fetch_array($req);
if($avto==1){
$clexp=$bon/10;
}
mysql_query("UPDATE `clan` SET `exp` = `exp`+'$clexp' WHERE `lider` = '$udata[clan]'");
mysql_query("UPDATE `users` SET `clanexp` = `clanexp`+'$clexp' WHERE `usr` = '$log'");
header ("Location: arena_dueli.php?log=los");exit;
}
}
}
break;
//-----
case 'pokup_par':
if($udata['almaz']<5){
header ("Location: arena_dueli.php?log=nogold");exit;
}else{
mysql_query("UPDATE `users` SET `almaz` = '$udata[almaz]'-'15', `hp` = '$udata[hpall]', `mp` = '$udata[mpall]' WHERE `usr` = '$log' LIMIT 1");
header ("Location: arena_dueli.php?");exit;
}
break;
//-----
break;
include($path.'files/down.php');
}
?>