Файл: 3/arena.php
Строк: 411
<?php
require_once ('system/func.php');
$title = 'Арена';
require_once ('system/header.php');
auth(); // Закроем от гостей
if(isset($_SESSION['relict'])){
echo msg($_SESSION['relict']);
unset($_SESSION['relict']);
}
$accz=$db->query("SELECT * FROM `zadanuya` WHERE `account`=".$user['id']." LIMIT 1")->fetch_assoc();
$batle = $db->query("SELECT * FROM `arena` WHERE `id_user` = '".$myID."' ORDER BY `id` LIMIT 1");
$batle = $batle->fetch_assoc();
if(!$batle){
$db->query("INSERT INTO `arena` SET `id_user` = '$user[id]', `last` = '".time()."'");
header('Location: /arena');
exit();
}
if(isset($_GET['max_energy']) == true and $batle['last'] <= time()){
$id = num($_GET['max_energy']);
$_hp = ceil(($user['max_health']+$user['health'])*10/100);
if($user['energy'] < 10 or $user['gold'] < 1 or $user['health'] < $_hp){
$_SESSION['msg'] = "Для нападения необходимо минимум ".ico('icons','health.png')." 10% жизни, ".ico('icons','energy.png')." 10 энергии и ".ico('icons','gold.png')." 1 золота!<br><a href='/rinok?koldun&url=/arena' class='btn2' data-ajax>Восстановить ".ico('icons','gold.png')." 15</a>";
header('Location: /arena?'.$random.'');
exit();
}else{
$koll = num($user['energy']/10);
$exp = 0;
$silver = 0;
$win = 0;
$los = 0;
for($kolls = 1; $kolls <= $koll; $kolls++) {
$opponent = $db->query("SELECT * FROM `users` WHERE `id` = '".$id."'")->fetch_assoc();
$_str = 0;
$_str_opp = 0;
for($round = 1; $round < num($user[energy]/10); $round++) {
## Это раз ##
$_str_1 = rand(round($user['str']/6), round($user['str']/4));
$_str_opp_1 = rand(round($opponent['str']/6), round($opponent['str']/4));
$_str_opp_1 -= rand(round($user['def']/12), round($user['def']/7));
$_str_1 -= rand(round($opponent['def']/12), round($opponent['def']/7));
if($_str_opp_1 < 0)$_str_opp_1 = 0;
if($_str_1 < 0)$_str_1 = 0;
## Это 2 ##
$_str += $_str_1;
$_str_opp += $_str_opp_1;
}
if($_str_1 > $_str_opp_1){
$exp = num((rand(1,3)*($user[level]))*$round);
$silver = num((rand(2,4)*$user[level])*$round);
if($user[vip]==1){$silver=ceil($silver*1.5);}
$win = 1;
}else{
$exp = 1;
$silver = 1;
$los = 1;
}
}
if($effect_2['on'] == 1)$exp = $exp+ceil($exp*25/100);
$exp = exp_koll($exp);
$db->query("update `users` set
`exp` = '".($user['exp']+$exp)."',
`silver` = '".($user['silver']+$silver)."',
`health` = '".($user['health']-$_str_opp)."',
`energy` = '".($user['energy']-$koll*10)."',
`gold` = '".($user['gold']-1)."'
where (`id` = '".$user['id']."')");
if($user[id_clan] > 0){
$db->query("UPDATE `users` SET `clan_exp` = '".($user[clan_exp]+ceil($exp*15/100))."' WHERE `id` = '".$myID."' LIMIT 1");
$db->query("UPDATE `clans` SET `exp` = `exp` + '".ceil($exp*15/100)."' WHERE `id` = '".$user[id_clan]."' LIMIT 1");
}
$db->query("update `arena` set `last` = '".(time()+2)."' where (`id` = '".$batle['id']."')");
if($accz[zadanie]==1){
if($accz[zadanue1]<100)
{
$db->query("UPDATE `zadanuya` SET `zadanue1`=`zadanue1`+".$round." WHERE `account`=".$myID."");
}
}
$_SESSION['msg'] = ico('icons','sum_stat.png')." <b class='info'>Проведено $round боев</b> ".ico('icons','sum_stat.png')."<br>
<font color='green'>Побед: <b>$win</b></font> | <font color='red'>Поражений: <b>$los</b></font><br>
Награда: ".ico('icons','exp.png')." ".n_f($exp)." опыта и ".ico('icons','silver.png')." ".n_f($silver)." серебра<br>
<div class='example3' style='text-align:center'><img src='images/other/koldun.png' class='example_beauty' style='width:100%;border-radius:8px'> <br/>
Здравствуй <b>$myLogin</b> я могу восстановить тебе ".ico('icons','health.png')." 100% жизни и ".ico('icons','energy.png')." энергии.
<a href='/rinok?koldun&url=/arena?max_energy=$opponent[id]' </a></div>";
$nik='<span style="text-shadow: 1px 0 10px #'.$opponent[gradient2].';">'.gradient(''.$opponent[login].'',''.$opponent[gradient1].'', ''.$opponent[gradient2].'').'</span>';
$nik1='<span style="text-shadow: 1px 0 10px #'.$user[gradient2].';">'.gradient(''.$user[login].'',''.$user[gradient1].'', ''.$user[gradient2].'').'</span>';
$_SESSION['itog'] = icons_user($myID)." <a>$nik1</a> нанес $_str урона<br>".icons_user($opponent[id])." <a>$nik</a> нанес $_str_opp урона";
unset($_SESSION['itog']);
header('Location: /arena?'.$random.'');
exit();
}
}
if(isset($_GET['attack']) == true and $batle['last'] <= time()){
$id = num($_GET['attack']);
$_hp = ceil(($user['max_health']+$user['health'])*10/100);
if($user['energy'] < 10 or $user['health'] < $_hp){
$_SESSION['msg'] = "Для нападения необходимо минимум ".ico('icons','health.png')." 10% жизни и ".ico('icons','energy.png')." 10 энергии!<br><a href='/rinok?koldun&url=/arena' class='btn2' data-ajax>Восстановить ".ico('icons','gold.png')." 15</a>";
header('Location: /arena');
exit();
}else{
$db->query("update `users` set `energy` = '".($user['energy']-10)."' where (`id` = '".$user['id']."')");
$db->query("update `arena` set `last` = '".(time()+2)."' where (`id` = '".$batle['id']."')");
$trn = $db->query("SELECT * FROM `trenirovka` WHERE `user` = '".$user["id"]."' LIMIT 1");
$tren = $trn->fetch_assoc();
if($tren['shag'] == 2){
if($tren['arena'] < 10){
$db->query("UPDATE `trenirovka` SET `arena`=`arena`+'1' WHERE `user`=".$myID."");
}}
if($accz[zadanie]==1){
if($accz[zadanue1]<100)
{
$db->query("UPDATE `zadanuya` SET `zadanue1`=`zadanue1`+'1' WHERE `account`=".$myID."");
}
}
$opponent = $db->query("SELECT * FROM `users` WHERE `id` = '".$id."'")->fetch_assoc();
$schet = 0;
$schet_opp = 0;
$_str_opp = rand(round($opponent['str']/6), round($opponent['str']/4));
$_def_opp = rand(round($opponent['def']/12), round($opponent['def']/7));
$_str_opp = $_str_opp - $_def;
if($_str_opp < 0)$_str_opp = 0;
$_str = $_str - $_def_opp;
if($_str < 0)$_str = 0;
if($_str > $_str_opp){
$schet = $schet + 1;
}elseif($_str_opp > $_str){
$schet_opp = $schet_opp + 1;
}else{
$schet = $schet + 1;
$schet_opp = $schet_opp + 1;
}
if($schet >= $schet_opp){
$exp = exp_koll(num(rand(1,3)*$opponent[level]));
if($effect_2['on'] == 1)$exp = $exp+ceil($exp*25/100);
$silver = num(rand(3,5)*$opponent[level]);
if($user[vip]==1){$silver=ceil($silver*1.5);}
$db->query("update `users` set `exp` = '".($user['exp']+$exp)."', `silver` = '".($user['silver']+$silver)."', `health` = '".($user['health']-$_str_opp)."' where (`id` = '".$user['id']."')");
$sob=$db->query("SELECT * FROM `sobytia_log` WHERE `id_user`=".$myID." LIMIT 1")->fetch_assoc();
if($sob['g_arena']==1 and $sob['arena']<10 and $sob['k_arena']>0)
{
$db->query("UPDATE `sobytia_log` SET `arena`=`arena`+'1' WHERE `id_user`=".$myID."");
}
if($user[id_clan] > 0){
$db->query("UPDATE `users` SET `clan_exp` = '".($user[clan_exp]+ceil($exp*15/100))."' WHERE `id` = '".$myID."' LIMIT 1");
$db->query("UPDATE `clans` SET `exp` = `exp` + '".ceil($exp*15/100)."' WHERE `id` = '".$user[id_clan]."' LIMIT 1");
}
require_once('relict456fgtQ4.php');
$_SESSION['msg'] = "<font color='green'><b>Победа</b></font><br><a href='/arena/$opponent[id]/' </a><br>Награда: ".ico('icons','exp.png')." $exp опыта и ".ico('icons','silver.png')." $silver серебра<br><a href='/arena?max_energy=$opponent[id]/' 1</a>";
$nik='<span style="text-shadow: 1px 0 10px #'.$opponent[gradient2].';">'.gradient(''.$opponent[login].'',''.$opponent[gradient1].'', ''.$opponent[gradient2].'').'</span>';
$nik1='<span style="text-shadow: 1px 0 10px #'.$user[gradient2].';">'.gradient(''.$user[login].'',''.$user[gradient1].'', ''.$user[gradient2].'').'</span>';
$_SESSION['itog'] = icons_user($myID)." <a>$nik1</a> нанес $_str урона<br>".icons_user($opponent[id])." <a>$nik</a> нанес $_str_opp урона";
header('Location: /arena?'.$random.'');
exit();
}else{
$exp = exp_koll(1);
if($effect_2['on'] == 1)$exp = $exp+ceil($exp*25/100);
$db->query("update `users` set `exp` = '".($user['exp']+$exp)."', `silver` = '".($user['silver']+1)."', `health` = '".($user['health']-$_str_opp)."' where (`id` = '".$user['id']."')");
if($user[id_clan] > 0){
$db->query("UPDATE `users` SET `clan_exp` = '".($user[clan_exp]+ceil($exp*15/100))."' WHERE `id` = '".$myID."' LIMIT 1");
$db->query("UPDATE `clans` SET `exp` = `exp` + '".ceil($exp*15/100)."' WHERE `id` = '".$user[id_clan]."' LIMIT 1");
}
$_SESSION['msg'] = "<font color='red'><b>Поражение</b></font><br><a href='/arena/$opponent[id]/'</a><br>Награда: ".ico('icons','exp.png')." $exp опыта и ".ico('icons','silver.png')." 1 серебра<br><a href='/arena?max_energy=$opponent[id]' 1</a>";
$nik='<span style="text-shadow: 1px 0 10px #'.$opponent[gradient2].';">'.gradient(''.$opponent[login].'',''.$opponent[gradient1].'', ''.$opponent[gradient2].'').'</span>';
$nik1='<span style="text-shadow: 1px 0 10px #'.$user[gradient2].';">'.gradient(''.$user[login].'',''.$user[gradient1].'', ''.$user[gradient2].'').'</span>';
$_SESSION['itog'] = icons_user($myID)." <a>$nik1</a> нанес $_str урона<br>".icons_user($opponent[id])." <a>$nik</a> нанес $_str_opp урона";
header('Location: /arena?'.$random.'');
exit();
}
}
}
$opponent = $db->query("SELECT * FROM `users` WHERE `side` != '$user[side]' AND `id`>'3' AND `str`+`def`+`max_health` >= '".ceil($user[str]+$user[def]+$user[max_health]*40/100)."' AND `str`+`def`+`max_health` <= '".ceil($user[str]+$user[def]+$user[max_health]*70/100)."' ORDER BY RAND() LIMIT 1");
$opponent = $opponent->fetch_assoc();
if(!$opponent){
$opponent = $db->query("SELECT * FROM `users` WHERE `side` != '$user[side]' AND `id`>'3' AND `str`+`def`+`max_health` <= '".($user[str]+$user[def]+$user[max_health])."' ORDER BY RAND() LIMIT 1");
$opponent = $opponent->fetch_assoc();
}
if($opponent == 0){
echo "<div class='block'>Нет доступных противников</div></div>";
require_once ('system/footer.php');
exit();
}
// exit('12345');
echo "<div class='block'>";
$nik='<span style="text-shadow: 1px 0 10px #'.$opponent[gradient2].';">'.gradient(''.$opponent[login].'',''.$opponent[gradient1].'', ''.$opponent[gradient2].'').'</span>';
echo "<div class='oh'><a href='/arena/$opponent[id]/' data-ajax><img src='/images/avatars/".(!empty($opponent['avatar'])?$opponent['avatar']:'noavatar.png')."' width='110px' style='margin-right:3px;margin-top:-2px;'/></a></div>".icons_user($opponent[id])." <a>$nik</a><br><br>";
echo ico('icons','str.png')." Атака: ".$opponent['str']."<br>".ico('icons','def.png')." Защита: ".$opponent['def']."<br> ".ico('icons','health.png')." Жизнь: ".$opponent['max_health']*'2'."<br><br>";
echo "<a href='/arena/$opponent[id]/' class='btn2' data-ajax>Атаковать</a>";
echo "<div style='clear:both;'></div>";
echo "<br><a href='/arena?$random' class='link center' data-ajax>Другой противник</a>";
echo "</div>";
if(isset($_SESSION['itog'])){
echo "<div class='block'>$_SESSION[itog]</div>";
unset($_SESSION['itog']);
}
$nik1='<span style="text-shadow: 1px 0 10px #'.$user[gradient2].';">'.gradient(''.$user[login].'',''.$user[gradient1].'', ''.$user[gradient2].'').'</span>';
echo "<div class='block'>".icons_user($myID)." $nik1:<br>".ico('icons','str.png')." $user[str] ".ico('icons','def.png')." $user[def] ".ico('icons','health.png')." $user[health]</div></div>";
require_once ('system/footer.php');
?>