Файл: arena.php
Строк: 263
<?
require_once 'core/system.php';
echo only_reg();
$header = 'Арена';
require_once 'core/head.php';
?>
<?
$kount = mysql_result(mysql_query("SELECT COUNT(*) FROM `user`"),0);
$health = rand(1,$user[level]);
if($_GET['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=''/> 25 золота</span>";
header('Location: ?');
exit();
}
if($user['mana'] < 20)
{
$_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=''/> 100% маны</span></span></a><br><span class='grey'>Цена: <img src='/images/icon/gold.png' alt=''/> 25 золота</span>";
header('Location: ?');
exit();
}else{
$ank = mysql_fetch_array(mysql_query("select * from `user` where (`id` = '".abs(intval($_GET['attack']))."')"));
if($ank['bonus_sila'] > time()) {
$ank['sila'] += 300;
$ank['max_health'] += 300;
$ank['lovk'] += 300;
$ank['zashit'] += 300;
$ank['mana'] += 300;
}
$pets_param2 = $user[silapets] + $user[vinoslpets] + $user[healthpets];
$pets_param3 = $ank[silapets] + $ank[vinoslpets] + $ank[healthpets];
$ank_param = $ank[sila] + $ank[max_health] + $ank[lovk] + $ank[zashit] + $pets_param3;
$user_param = $user[sila] + $user[max_health] + $user[lovk] + $user[zashit] + $pets_param2;
if($ank_param > $user_param){
mysql_query("update `user` set `health` = '".($user['health']-20)."',`exp` = '".($user['exp']+1)."',`silver`='".($user['silver']+10)."',`arena_pobed`='".($user['arena_pobed']+ 0)."',`mana`='".($user['mana']-20)."' where (`id` = '".$user['id']."')");
mysql_query("UPDATE `user` SET `liga` = '".($user['liga']-1)."' WHERE `id` = '$user[id]' LIMIT 1");
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><a class='btn' href='/arena.php?attack=$_GET[attack]'><span class='end'><span class='label'>Новый бой</span></span></a><div class='separ'></div><img src='/images/icon/silver.png' alt=''/> 10 серебра <img src='/images/icon/exp.png' alt='exp'/> 1 опыта<br>";
exit();
}else{
if($user[level] <= 5){
$mini = 30;
$maxi = 90;
$max = 9;
$min = 2;
}
if($user[level] >= 6){
$mini = 50;
$maxi = 150;
$max = 21;
$min = 9;
}
if($user[level] >= 10){
$mini = 70;
$maxi = 210;
$max = 36;
$min = 15;
}
if($user[level] >= 15){
$mini = 110;
$maxi = 350;
$max = rand(50,70);
$min = 30;
}
if($user[level] >= 20){
$mini = 170;
$maxi = 420;
$max = rand(65,99);
$min = rand(40,70);
}
if($user[level] >= 25){
$mini = 200;
$maxi = 510;
$max = rand(70,150);
$min = rand(57,88);
}
if($user[level] >= 30){
$mini = 230;
$maxi = 580;
$max = rand(85,170);
$min = rand(63,92);
}
if($user[prava] == 3){
$mini = $mini * 4;
$maxi = $maxi * 6;
$max = $max * 8;
$min = $min * 10;
}
$silver = rand($mini,$maxi);
$exp = rand($min,$max);
$arena_pobed = 1;
if($user['bonus_elik'] > time()) {
$exp = $exp * 4;
}
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, `quest` = `quest` + 1 WHERE `id` = '".$user['clan_id']."'");
}
mysql_query("update `user` set `health` = '".($user['health']-5)."',`exp` = '".($user['exp']+$exp)."',`silver`='".($user['silver']+$silver)."',`arena_pobed`='".($user['arena_pobed']+$arena_pobed)."',`mana`='".($user['mana']-20)."' where (`id` = '".$user['id']."')");
mysql_query("UPDATE `user` SET `liga` = '".($user['liga']+1)."' WHERE `id` = '$user[id]' LIMIT 1");
// Place
// 1 - Арена
// Type
// 0 - Провести n-е кол-во боев (неважно победа или поражени)
// 1 - Только победы
$q = mysql_query ('select * from `user_q` WHERE (`user`="' . $user['id'] . '") AND (`complete`="0")');
if (mysql_num_rows ($q) != 0) {
while ($user_q = mysql_fetch_array ($q)) {
//
$q_ = mysql_query ('SELECT * FROM `quest` WHERE (`id`="' . $user_q['q'] . '")');
$quest = mysql_fetch_array ($q_);
if ($user_q['c'] < $quest['c']) {
if ($quest['place']=='1') {
if ($quest['type']=='0') {
mysql_query ('UPDATE `user_q` SET `c`=`c`+1 WHERE (`user`="' . $user['id'] . '") AND (`q`="' . $quest['id'] . '")');
}
if ($quest['type']=='1') {
if($dmg > $opponent_dmg) {
mysql_query ('UPDATE `user_q` SET `c`=`c`+1 WHERE (`user`="' . $user['id'] . '") AND (`q`="' . $quest['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><a class='btn' href='?attack=$_GET[attack]'><span class='end'><span class='label'>Новый бой</span></span></a><div class='separ'></div><img src='/images/icon/silver.png' alt=''/> ".$silver." серебра <img src='/images/icon/exp.png' alt='exp'/> ".(int)$exp." опыта<br>";
exit();
}
}
}
echo "<div class='player center blue'>Побеждай врагов и становись сильнее!</div>
<div class='mini-line'></div>";
echo "<div class='player'>
<h2>Доступный противник</h2>
</div>";
if($kount < 2)echo "<div class='dot-line'></div><div class='player grey'>Нет противников!</div>";
$opponents = mysql_query("SELECT * FROM `user` WHERE `id` != '".$user['id']."' AND `level` <= '".$user['level']."' ORDER BY RAND() DESC LIMIT 3");
while($opponent = mysql_fetch_array($opponents))
{
$pets_param1 = $user[silapets] + $user[vinoslpets] + $user[healthpets];
$pets_param = $opponent[silapets] + $opponent[vinoslpets] + $opponent[healthpets];
$opponent_param = $opponent[sila] + $opponent[max_health] + $opponent[lovk] + $opponent[zashit] + $pets_param;
$user_param = $user[sila] + $user[max_health] + $user[lovk] + $user[zashit] + $pets_param1;
echo "<div class='block_zero'><div class='float-left'>
<img src='/style/avatar/".($opponent['pol'] == 0 ? "zj" : "m")."/$opponent[avatar].png' width='120' height='160' style='margin-right:10px;float:left;' alt=''/></a></div>
<img src='/images/icon/user.png' alt=''/> $opponent[nick]
<br><br>
<img src='/images/icon/str.png' alt='str'/> Сила: $opponent[sila] </span>
<br>
<img src='/images/icon/vit.png' alt='vit'/> Здоровье: $opponent[max_health] </span>
<br>
<img src='/images/icon/agi.png' alt='agi'/> Ловкость: $opponent[lovk] </span>
<br>
<img src='/images/icon/def.png' alt='def'/> Защита: $opponent[zashit] </span>
<br>
<img src='/images/icon/2hit.png'> $opponent_param VS $user_param </span>
<br>
<br>
<a class='btn' href='/arena.php?attack=$opponent[id]'><span class='end'><span class='label'>Атакoвать</span></span></a>
<br>
<div style='clear:both;'></div>
</div>";
}
echo "<div class='dot-line'></div>
<div class='player center'>
<a class='btn' href='/arena.php'><span class='end'><span class='label'>Другие противники</span></span></a>
</div>";
echo "<div class='mini-line'></div><div class='player'><img src='/images/icon/skill.png'> Ваш рейтинг: <b>$user[liga]</b></div>";
echo "<div class='mini-line'></div>
<div class='player'>
Ваши параметры:
<br>
<img src='/images/icon/str.png' alt='str'/> $user[sila] <img src='/images/icon/vit.png' alt='vit'/> $user[max_health] <img src='/images/icon/agi.png' alt='agi'/> $user[lovk] <img src='/images/icon/def.png' alt='def'/> $user[zashit]
</div>
<div class='mini-line'></div>";
if($user['petschek'] == 1){
echo "<div class='player'>Ваш питомец:</br><img src='/pets/$user[pets]'height='35'> <img src='/images/icon/pit.png'><span class='orange'> $user[petsname]</span><span class='green'>: $pets_param1</span></div></div>";
echo "<div class='mini-line'></div>";
}
echo "<div class='player'><ul class='hint'><li>Чем больше уровень противника, тем больше опыта получишь за победу!</li></ul></div>";
require_once 'core/foot.php';
?>