Файл: duel.php
Строк: 155
<?
require_once 'core/system.php';
echo only_reg();
$header = 'Дуэли';
require_once 'core/head.php';
//Параметры Противника
$sila = rand(1,$user[sila]*2);
$health = rand(1,$user[health]*2);
$lovk = rand(1,$user[lovk]*2);
$zashit = rand(1,$user[zashit]*2);
$avatar = rand(1,5);
$silver = rand(1,100);
$rating = rand(1,100);
$rating2 = 1;
$exp = rand($user[level],$user[level]*2);
$health2 = rand(1,$user[lvl]+5);
//Идем дальше
switch($act) {
case 'attack':
if($user['health'] < 20){
$_SESSION['light'] = "<span class='dred'>Для нападения нужно <img src='/images/icon/health.png' alt=''/> 20 Здоровья</span><br/>Здоровье восстанавливается со временем или за золото<br><div class='separ'></div><a class='btn' href='/moduls/ckoldun.php?act=ok'><span class='end'><span class='label'>Восстановить <img src='/images/icon/health.png' alt=''/> 100% здоровья</span></span></a><br><span class='grey'>Цена: <img src='/images/icon/gold.png' alt=''/> 125 золота</span>";
header('Location: ?');
exit();
}
if($user['mana'] < 50){
$_SESSION['light'] = "<span class='dred'>Для нападения нужно <img src='/images/icon/mana.png' alt=''/> 50 маны</span><br/>Мана восстанавливается со временем или за золото<br><div class='separ'></div><a class='btn' href='/moduls/ckoldun.php?act=ok'><span class='end'><span class='label'>Восстановить <img src='/images/icon/mana.png' alt=''/> 50% маны</span></span></a><br><span class='grey'>Цена: <img src='/images/icon/gold.png' alt=''/> 25 золота</span>";
header('Location: ?');
exit();
}else{
$pets_param = $user[silapets] + $user[vinoslpets] + $user[healthpets];
$user_param = $user[sila] + $user[max_health] + $user[lovk] + $user[zashit] + $pets_param;
$param = $sila + $health + $lovk + $zashit;
require_once H.'core/head.php';
if($param > $user_param){
mysql_query("update `user` set `health` = '".($user['health']-$health2)."',`mana`='".($user['mana']-50)."' where (`id` = '".$user['id']."')");
if($user[duel_rating] > 1){
mysql_query("update `user` set `duel_rating` = '".($user['duel_rating']-$rating)."', `arenaweek` = '".($user['arenaweek']-$rating)."' where (`id` = '".$user['id']."')");
}
header('Location: ?');
$_SESSION['light'] = "<h2 class='dred' style='font-weight:bold;'><img src='/images/icon/2hit.png' alt=''/> Поражение <img src='/images/icon/2hit.png' alt=''/></h2><div class='separ'></div><img src='/images/icon/2hit.png' alt=''/> $param VS $user_param (<span class='dgreen'>+$pets_param</span>)<img src='/images/icon/2hit.png' alt=''/><div class='separ'></div><span class='dred'>Рейтинг - $rating</span>";
exit();
}else{
if($user['bonus_elik'] > time()) {
$exp = $exp * 2;
}
if($user['clan_id'] != 0) {
mysql_query("INSERT INTO `jr_clan` SET `user_id` = '".$user['id']."', `clan_id` = '".$user['clan_id']."', `exp` = '$exp'");
mysql_query("UPDATE `clans` SET `exp` = `exp` + $exp WHERE `id` = '".$user['clan_id']."'");
}
mysql_query("update `user` set `exp` = '".($user['exp']+$exp)."',`silver` = '".($user['silver']+$silver)."',`health` = '".($user['health']-$health2)."',`mana`='".($user['mana']-50)."',`duel_rating`='".($user['duel_rating']+$rating)."', `arenaweek` = '".($user['arenaweek']+$rating)."' where (`id` = '".$user['id']."')");
header("Location: ?");
$_SESSION['light'] = "<h2 class='dgreen' style='font-weight:bold;'><img src='/images/icon/2hit.png' alt=''/> Победа <img src='/images/icon/2hit.png' alt=''/></h2><div class='separ'></div><img src='/images/icon/silver.png' alt=''/> ".$silver." серебра <img src='/images/icon/exp.png' alt='exp'/> ".$exp." опыта<div class='separ'></div><img src='/images/icon/2hit.png' alt=''/> $param VS $user_param (<span class='dgreen'>+$pets_param</span>)<img src='/images/icon/2hit.png' alt=''/><div class='separ'></div><span class='dgreen'>Рейтинг + $rating</span>";
exit();
}
}
break;
case 'nagrada':
if($user[duel_mission] == 0){
if($user[duel_rating] < 1000){
$_SESSION['err'] = "Нужно 1000 рейтинга!";
header('Location: ?');
exit();
}else{
mysql_query("UPDATE `user` SET `gold` = '".($user['gold']+100)."', `duel_mission` = 1 WHERE `id` = '$user[id]' LIMIT 1");
mysql_query("UPDATE `user` SET `duel_rating` = '".($user['duel_rating']-1000)."' WHERE `id` = '$user[id]' LIMIT 1");
$_SESSION['message'] = "Награда получена!";
header('Location: ?');
exit();
}
}else{
$_SESSION['err'] = "Вы уже получали награду!";
header('Location: ?');
exit();
}
break;
default;
echo "<div class='player center'>";
echo "<img src='/style/duel/$avatar.png' width='120' height='160'>";
echo "</div>";
echo "<div class='player center'>";
echo "<a href='?act=attack'><img src='/images/icon/atk.png'></a>";
echo "</div>";
if($user[duel_mission] == 0){
echo "<div class='dot-line'></div>";
echo "<div class='block_zero'>";
echo "<b class='dgreen'>Лучший боец:</b><br/><span class='medium'>Набери 1000 рейтинга и получи 100 золота!<br/><span class='blue'>Прогресс:</span> $user[duel_rating] из 1000";
echo "<div class='stat_bar' style='margin:2px 0px 2px'>";
echo "<div class='progress' style='width:".round(100/(1000/($user[duel_rating]+1)))."%'></div>";
echo "</div>";
echo "<a class='btn' href='?act=nagrada'><span class='end'><span class='label'>Получить награду</span></span></a>";
echo "</div>";
}
echo "<div class='mini-line'></div>";
echo "<ul class='hint'><li>Параметры врага видны только после атаки!</li></ul>";
}
echo'<div class="player menuList">
<li>
<a href="/toparena.php">Топ недели</a></li></div>';
require_once 'core/foot.php';
?>