Вход Регистрация
Файл: arena.php
Строк: 332
<?php
require_once ('system/func.php');
$title 'Арена';
require_once (
'system/header.php');
auth(); // Закроем от гостей
$quest_1 mysql_fetch_assoc(mysql_query("SELECT * FROM `quest` WHERE `id` = '1'"));
$q_1 mysql_fetch_assoc(mysql_query("SELECT * FROM `quest_user` WHERE `id_quest` = '$quest_1[id]' AND `id_user` = '$myID'"));
$quest_2 mysql_fetch_assoc(mysql_query("SELECT * FROM `quest` WHERE `id` = '2'"));
$q_2 mysql_fetch_assoc(mysql_query("SELECT * FROM `quest_user` WHERE `id_quest` = '$quest_2[id]' AND `id_user` = '$myID'"));
$batle mysql_query("SELECT * FROM `arena` WHERE `id_user` = '".$myID."' ORDER BY `id` LIMIT 1");
$batle mysql_fetch_array($batle);
if(!
$batle){
mysql_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() and $user['level'] >= 7){
$_hp ceil($user['max_health']*10/100);
if(
$user['gold'] < 1){
$_SESSION['msg'] = 'Для нападения необходимо '.ico('icons','gold.png').' 1 золота';
header("Location: ?");
exit();
}
if(
$user['energy'] < 30 or $user['health'] < $_hp){
$_SESSION['msg'] = "Для нападения необходимо минимум ".ico('icons','health.png')." 10% жизни и ".ico('icons','energy.png')." 30 энергии<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']/30);
$exp 0;
$crystals 0;
$win 0;
$los 0;
for(
$kolls 0$kolls <= $koll$kolls++) {
$opponent mysql_query("SELECT * FROM `users` WHERE `side` != '$user[side]'  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]*110/100)."' ORDER BY RAND() LIMIT 1");
$opponent mysql_fetch_array($opponent);
if(!
$opponent){
$opponent mysql_query("SELECT * FROM `users` WHERE `side` != '$user[side]'  AND `str`+`def`+`max_health` >= '".ceil($user[str]+$user[def]+$user[max_health]*20/100)."' AND `str`+`def`+`max_health` <= '".ceil($user[str]+$user[def]+$user[max_health]*110/100)."' ORDER BY RAND() LIMIT 1");
$opponent mysql_fetch_array($opponent);
}
if(!
$opponent){
$opponent mysql_query("SELECT * FROM `users` WHERE `side` != '$user[side]'  AND `str`+`def`+`max_health` <= '".($user[str]+$user[def]+$user[max_health])."' ORDER BY RAND() LIMIT 1");
$opponent mysql_fetch_array($opponent);
}
$_str 0;
$_str_opp 0;
for(
$round 1$round 6$round++){
$_str += rand(round($user['str']/6), round($user['str']/4));

$_str -= rand(round($opponent['def']/12), round($opponent['def']/7));

$_str_opp += rand(round($opponent['str']/6), round($opponent['str']/4));

$_str_opp -= rand(round($user['def']/12), round($user['def']/7));

if(
$_str_opp 0)$_str_opp 0;
if(
$_str 0)$_str 0;

if(
mt_rand(0,100) < $user['krit']){
$krit true;
}

if(
$krit)$_str *= 2;

$_str_opp += $_str_opp_1;

if(
mt_rand(0,100) < $opponent['krit']){
$krit_opp true;
}

if(
$krit_opp)$_str_opp *= 2;
}
if(
$_str $_str_opp){
$exp += num(rand(8,12)*$user[level]);
$crystals += num(rand(300,500)*$opponent[level]);
$win += 1;
}elseif(
$_str_opp $_str){
$exp += 1;
$crystals += 1;
$los += 1;
}
}
if(
$effect_2['on'] == 1)$exp $exp+ceil($exp*25/100);
$exp exp_koll($exp);
mysql_query("update `users` set 
`exp` = '"
.($user['exp']+$exp)."', 
`crystals` = '"
.($user['crystals']+$crystals)."', 
`health` = '"
.($user['health']-$_str_opp)."', 
`energy` = '"
.($user['energy']-$koll*30)."', 
`gold` = '"
.($user['gold']-1)."'
where (`id` = '"
.$user['id']."')");
if(
$user[id_clan] > 0){
mysql_query("UPDATE `users` SET `clan_exp` = '".($user['clan_exp']+clan_exp_koll($exp))."', `clan_exp_24` = '".($user['clan_exp_24']+clan_exp_koll($exp))."' WHERE `id` = '".$myID."' LIMIT 1");
mysql_query("UPDATE `clans` SET `exp` = `exp` + '".clan_exp_koll($exp)."' WHERE `id` = '".$user['id_clan']."' LIMIT 1");
}


if(
$q_1['last'] < time())mysql_query("update `quest_user` set `koll` = `koll`+'$kolls' where (`id` = '".$q_1['id']."')");
if(
$q_2['last'] < time())mysql_query("update `quest_user` set `koll` = `koll`+'$win' where (`id` = '".$q_2['id']."')");
mysql_query("update `arena` set `last` = '".(time()+1)."' where (`id` = '".$batle['id']."')");
require_once (
'modules/arena_item_rand_full.php');
$_SESSION['msg'] = ico('icons','sum_stat.png')." <b class='info'>Проведено $kolls боев</b> ".ico('icons','sum_stat.png')."<hr>
<font color='green'>Побед: <b>
$win</b></font> | <font color='red'>Поражений: <b>$los</b></font><hr>
Награда: "
.ico('icons','exp.png')." ".n_f($exp)." опыта и ".ico('icons','crystal.png')." ".n_f($crystals)." кристаллов
"
.($item_rand == "<hr>Новые вещи в твоей сумке:<br><img src='/images/items/$item[tip]/$item[item].png' width='50px'> <img src='/images/items/$item2[tip]/$item2[item].png' width='50px'> " "")."".($inv+>= 21 "<br>Вы не смогли поднять вещи, ваша сумка переполнена!" "")."";
header('Location: /arena?'.$random.'');
exit();
}
}
if(isset(
$_GET['attack']) == true and $batle['last'] <= time()){
$id num($_GET['attack']);
$_hp ceil($user['max_health']*10/100);
if(
$user['energy'] < 30 or $user['health'] < $_hp){
$_SESSION['msg'] = "Для нападения необходимо минимум ".ico('icons','health.png')." 10% жизни и ".ico('icons','energy.png')." 30 энергии!<br><a href='/rinok?koldun&url=/arena' class='btn2' data-ajax>Восстановить ".ico('icons','gold.png')." 15</a>";
header('Location: /arena');
exit();
}else{
mysql_query("update `users` set `energy` = '".($user['energy']-30)."' where (`id` = '".$user['id']."')");
mysql_query("update `arena` set `last` = '".(time()+1)."' where (`id` = '".$batle['id']."')");
if(
$q_1['last'] < time())mysql_query("update `quest_user` set `koll` = `koll`+'1' where (`id` = '".$q_1['id']."')");
$opponent mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id` = '".$id."'"));
$schet 0;
$schet_opp 0;
if(
mt_rand(0,100) < $user['krit']){
$krit true;
}
if(
$krit)$_str *= 2;
$_str_opp rand(round($opponent['str']/6), round($opponent['str']/4));
$_def_opp rand(round($opponent['def']/12), round($opponent['def']/7));
if(
mt_rand(0,100) < $opponent['krit']){
$krit_opp true;
}
if(
$krit_opp)$_str_opp *= 2;
$_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(8,12)*$user[level]));
if(
$effect_2['on'] == 1)$exp $exp+ceil($exp*25/100);
$crystals num(rand(300,500)*$opponent[level]);
mysql_query("update `users` set `exp` = '".($user['exp']+$exp)."', `crystals` = '".($user['crystals']+$crystals)."', `health` = '".($user['health']-$_str_opp)."' where (`id` = '".$user['id']."')");
if(
$user[id_clan] > 0){
mysql_query("UPDATE `users` SET `clan_exp` = '".($user['clan_exp']+clan_exp_koll($exp))."', `clan_exp_24` = '".($user['clan_exp_24']+clan_exp_koll($exp))."' WHERE `id` = '".$myID."' LIMIT 1");
mysql_query("UPDATE `clans` SET `exp` = `exp` + '".clan_exp_koll($exp)."' WHERE `id` = '".$user['id_clan']."' LIMIT 1");
}
if(
$q_2['last'] < time())mysql_query("update `quest_user` set `koll` = `koll`+'1' where (`id` = '".$q_2['id']."')");
require_once (
'modules/arena_item_rand.php');
$_SESSION['pobeda'] = "<font color='green'><b>Победа</b></font><hr><a href='/arena/$opponent[id]/' class='btn2' data-ajax>Сразиться</a><hr>Награда: ".ico('icons','exp.png').$exp опыта и ".ico('icons','crystal.png').$crystals кристаллов".($user['level'] >="<hr><a href='/arena?max_energy=$opponent[id]/' class='btn2' data-ajax>Максимум энергии ".ico('icons','gold.png')." 1</a><br>" "")."
"
.($item_rand == 10 "Новая вещь в твоей сумке:<br><img src='/images/items/$item[tip]/$item[item].png'> $item[name]"")."".($inv+== 21 "<br>Вы не смогли поднять вещь, ваша сумка переполнена!" "")."";
$_SESSION['itog'] = icons_user($myID)." <a>$user[login]</a> нанес $_str ".($krit == true "(Крит)" "")." урона<br>".icons_user($opponent[id])." <a>$opponent[login]</a> нанес $_str_opp ".($krit_opp == true "(Крит)" "")." урона";
header('Location: /arena?'.$random.'');
exit();
}else{
$exp exp_koll (rand(1,8));
if(
$effect_2['on'] == 1)$exp $exp+ceil($exp*25/100);
mysql_query("update `users` set `exp` = '".($user['exp']+$exp)."', `crystals` = '".($user['crystals']+300)."', `health` = '".($user['health']-$_str_opp)."' where (`id` = '".$user['id']."')");
if(
$user[id_clan] > 0){
mysql_query("UPDATE `users` SET `clan_exp` = '".($user['clan_exp']+clan_exp_koll($exp))."', `clan_exp_24` = '".($user['clan_exp_24']+clan_exp_koll($exp))."' WHERE `id` = '".$myID."' LIMIT 1");
mysql_query("UPDATE `clans` SET `exp` = `exp` + '".clan_exp_koll($exp)."' WHERE `id` = '".$user['id_clan']."' LIMIT 1");
}

$_SESSION['porazenie'] = "<font color='red'><b>Поражение</b></font><hr><a href='/arena/$opponent[id]/' class='btn2'>Сразиться</a><hr>Награда: ".ico('icons','exp.png').$exp опыта и ".ico('icons','crystal.png')." 300 кристаллов".($user['level'] >="<hr><a href='/arena?max_energy=$opponent[id]/' class='btn2' data-ajax>Максимум энергии ".ico('icons','gold.png')." 1</a><br>" "")."";
$_SESSION['itog'] = icons_user($myID)." <a>$user[login]</a> нанес $_str ".($krit == true "(Крит)" "")." урона<br>".icons_user($opponent[id])." <a>$opponent[login]</a> нанес $_str_opp ".($krit_opp == true "(Крит)" "")." урона";
header('Location: /arena?'.$random.'');
exit();
}
}
}
$opponent mysql_query("SELECT * FROM `users` WHERE `side` != '$user[side]'  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]*110/100)."' ORDER BY RAND() LIMIT 1");
$opponent mysql_fetch_array($opponent);
if(!
$opponent){
$opponent mysql_query("SELECT * FROM `users` WHERE `side` != '$user[side]'  AND `str`+`def`+`max_health` >= '".ceil($user[str]+$user[def]+$user[max_health]*20/100)."' AND `str`+`def`+`max_health` <= '".ceil($user[str]+$user[def]+$user[max_health]*110/100)."' ORDER BY RAND() LIMIT 1");
$opponent mysql_fetch_array($opponent);
}
if(!
$opponent){
$opponent mysql_query("SELECT * FROM `users` WHERE `side` != '$user[side]'  AND `str`+`def`+`max_health` <= '".($user[str]+$user[def]+$user[max_health])."' ORDER BY RAND() LIMIT 1");
$opponent mysql_fetch_array($opponent);
}
echo 
"<div class='block'>";
echo 
"<div class='oh'><a href='/arena/$opponent[id]/' data-ajax><img src='/manekenImage_$opponent[id].png' width='150px' style='margin-right:3px;margin-top:-2px;'></a></div>".icons_user($opponent[id])." <a>$opponent[login]</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]<br><br>";
echo 
"<a href='/arena/$opponent[id]/' class='btn' data-ajax>Атаковать</a>";
echo 
"<div style='clear:both;'></div>";


echo 
"<center><a href='/arena?$random' class='btn'>Другой противник</center></a>";
echo 
"</div>";
if(isset(
$_SESSION['itog'])){
echo 
"<div class='block'>$_SESSION[itog]</div>";
unset(
$_SESSION['itog']);
}
echo 
"<div class='block'>".icons_user($myID).$user[login]:<br>".ico('icons','str.png').$user[str] ".ico('icons','def.png').$user[def] ".ico('icons','health.png').$user[max_health]</div>";
require_once (
'system/footer.php');
?>
Онлайн: 0
Реклама