<?php
include 'system/func.php';
$title = 'Арена';
include 'system/header.php';
auth();
if(isset($_GET['attack'])){
$_hp = ceil($user['max_health']*10/100);
if($user['health'] < $_hp){
$_SESSION['msg'] = "Для нападения необходимо минимум ".ico('icons','health.png')." 10% жизни.";
header('Location: ?');
exit();
}else{
mysql_query("update `users` set
`health` = '".($user['health']-15)."'
where (`id` = '".$user['id']."')");
# Статы тени #
$batle_str = ceil($user['str']*99/100);
$batle_def = ceil($user['def']*99/100);
# Урон #
$schet = 0;
$schet_opp = 0;
$_str_opp = rand(round($batle_str/6), round($batle_str/4));
$_def_opp = rand(round($batle_def/12), round($batle_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;
}
$gold = rand(0,2);
$exp = rand(5,20);
$exp_lose = rand(3,15);
$crystals = rand(100,500);
if($schet < $schet_opp){
mysql_query("update `users` set
`gold` = '".($user['gold']+$gold)."', `exp` = '".($user['exp']+$exp)."', `crystals` = '".($user['crystals']+$crystals)."'
where (`id` = '".$user['id']."')");
if($user['id_clan'] > 0){
mysql_query("UPDATE `users` SET `clan_exp` = '".($user['clan_exp'] + $exp)."' WHERE `id` = '".$myID."' LIMIT 1");
mysql_query("UPDATE `clans` SET `exp` = `exp` + '$exp' WHERE `id` = '".$user['id_clan']."' LIMIT 1");
}
$_SESSION['msg'] = "<font color='lime'><b>Победа</b></font><hr>Награда: ".ico('icons','gold.png')." $gold, ".ico('icons','crystal.png')." $crystals и ".ico('icons','exp.png')." $exp опыта!";
}else{
mysql_query("update `users` set
`crystals` = '".($user['crystals']+$crystals)."', `exp` = '".($user['exp']+$exp)."'
where (`id` = '".$user['id']."')");
if($user['id_clan'] > 0){
mysql_query("UPDATE `users` SET `clan_exp` = '".($user['clan_exp'] + $exp_lose)."' WHERE `id` = '".$myID."' LIMIT 1");
mysql_query("UPDATE `clans` SET `exp` = `exp` + '$exp_lose' WHERE `id` = '".$user['id_clan']."' LIMIT 1");
}
$_SESSION['msg'] = "<font color='red'><b>Поражение</b></font><hr>Награда: ".ico('icons','crystal.png')." $crystals и ".ico('icons','exp.png')." $exp_lose опыта!";
}
header("Location: ?");
exit();
}
}
echo "<div class='block center'>";
echo "<font color='tomato'>Противник</font><hr>";
echo "<div class='center'><img src='/manekenImage_$myID.png'></div><hr>";
echo ico('icons','str.png')."".ceil($user['str']*110/100)." ".ico('icons','def.png')."".ceil($user['def']*110/100)." ".ico('icons','health.png')."".ceil($user['max_health']*110/100);
echo "<hr>";
echo "<center><a href='?attack' class='btn2' data-ajax>Атаковать</a></center>";
echo "</ul>";
echo "</div>";
include 'system/footer.php';
?>