Вход Регистрация
Файл: duel_batle.php
Строк: 240
<?php
require_once ('system/func.php');
auth(); // Закроем от гостей
$duel mysql_fetch_array(mysql_query('SELECT * FROM `duel` WHERE `id_user` = "'.$myID.'"'));
if(
$duel['start'] != 1){
header('Location: /duel/');
exit();
}
$quest mysql_fetch_assoc(mysql_query("SELECT * FROM `quest` WHERE `id` = '5'"));
$q mysql_fetch_assoc(mysql_query("SELECT * FROM `quest_user` WHERE `id_quest` = '$quest[id]' AND `id_user` = '$myID'"));
$_opponent mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` != '$myID' AND `str`+`def`+`max_health` >= '".ceil($user['str']+$user['def']+$user['max_health']*35/100)."' AND `str`+`def`+`max_health` <= '".ceil($user['str']+$user['def']+$user['max_health']*115/100)."' ORDER BY RAND() LIMIT 1"));
if(!
$_opponent)$_opponent mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` != '$myID' AND `str`+`def`+`max_health` >= '".ceil($user['str']+$user['def']+$user['max_health']*25/100)."' AND `str`+`def`+`max_health` <= '".ceil($user['str']+$user['def']+$user['max_health']*140/100)."' ORDER BY RAND() LIMIT 1"));
$opponent mysql_fetch_array(mysql_query('SELECT * FROM `users` WHERE `id` = "'.$duel['opponent'].'"'));
$l_ch mysql_query("SELECT * FROM `l_ch` WHERE `id_1` = '".$myID."' AND `id_2` = '$opponent[id]' OR `id_1` = '".$opponent['id']."' AND `id_2` = '$myID' ORDER BY `id` LIMIT 1");
$l_ch mysql_fetch_array($l_ch);
if(!
$l_ch){
mysql_query("INSERT INTO `l_ch` SET `id_1` = '$myID', `id_2` = '$opponent[id]', `schet_1` = '0', `schet_2` = '0'");
}
$user['health'] = $duel['user_health'];
if(
$user['health'] < 0)$user['health'] = 0;
if(isset(
$_GET['end'])){
if(
$l_ch['id_1'] == $myID){
mysql_query("update `l_ch` set `schet_2` = '".($l_ch['schet_2']+1)."' where (`id` = '".$l_ch['id']."')");
}else{
mysql_query("update `l_ch` set `schet_1` = '".($l_ch['schet_1']+1)."' where (`id` = '".$l_ch['id']."')");
}
mysql_query("update `duel` set `start` = '0', `opponent` = '$_opponent[id]' where (`id` = '".$duel['id']."')");
mysql_query("DELETE FROM `duel_log` WHERE `id_batle` = '".$duel['id']."'");
$_SESSION['porazenie'] = "<b><font color='red'>Поражение</font></b>";
header('Location: /duel/');
exit();
}
if(isset(
$_GET['kamen']) and $user['kamen'] >= and $duel['kamen'] < time()){
mysql_query("UPDATE `users` SET `kamen` = `kamen` - '1' WHERE `id` = '".$myID."' LIMIT 1");
mysql_query("UPDATE `duel` SET `kamen` = '".(time()+30)."' WHERE `id` = '".$duel['id']."' LIMIT 1");
header('Location: ?attack');
exit();
}
if(isset(
$_GET['trava']) and $user['trava'] >= and $duel['trava'] < time()){
mysql_query("UPDATE `users` SET `trava` = `trava` - '1' WHERE `id` = '".$myID."' LIMIT 1");
mysql_query("UPDATE `duel` SET `trava` = '".(time()+30)."' WHERE `id` = '".$duel['id']."' LIMIT 1");
header('Location: ?attack');
exit();

}

if(isset(
$_GET['attack'])){
if(
$duel['udar_last'] > time()){
/*
$time = ($duel['udar_last']-time());

switch($time){
case 1:
$_str = ceil($_str*80/100);
break;
case 2:
$_str = ceil($_str*60/100);
break;
case 3:
$_str = ceil($_str*40/100);
break;
case 4:
$_str = ceil($_str*10/100);
break;

}
*/
}
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;
if(
$duel[kamen] > time())$_str += ceil($_str*35/100);
if(
$duel[trava] > time())$_str_opp -= ceil($_str_opp*35/100);
$_str_opp $_str_opp $_def;
if(
$_str_opp 0)$_str_opp 0;
$_str $_str $_def_opp;
if(
$_str 0)$_str 0;
if(
$_str $duel['opp_health']){
$exp exp_koll(rand($opponent['level']*5,$opponent['level']*10));
if(
$effect_2['on'] == 1)$exp $exp+ceil($exp*25/100);
$crystals rand($opponent['level']*10,$opponent['level']*15);
$win '<font color="green">Победа</font>';
if(
$l_ch['id_1'] == $myID){
mysql_query("update `l_ch` set `schet_1` = '".($l_ch['schet_1']+1)."' where (`id` = '".$l_ch['id']."')");
}else{
mysql_query("update `l_ch` set `schet_2` = '".($l_ch['schet_2']+1)."' where (`id` = '".$l_ch['id']."')");
}
if(
$q['last'] < time())mysql_query("update `quest_user` set `koll` = `koll`+'1' where (`id` = '".$q['id']."')");
mysql_query("update `duel` set `start` = '0', `opponent` = '$_opponent[id]' where (`id` = '".$duel['id']."')");
mysql_query("update `users` set `exp` = '".($user['exp']+$exp)."', `crystals` = '".($user['crystals']+$crystals)."' where (`id` = '".$myID."')");
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");
}
mysql_query("DELETE FROM `duel_log` WHERE `id_batle` = '".$duel[id]."'");
$_SESSION['pobeda'] = "<b>$win</b><hr>Награда: ".ico('icons','exp.png').$exp опыта и ".ico('icons','crystal.png').$crystals кристаллов";
header('Location: /duel/');
exit();
}elseif(
$_str_opp $user['health']){
$exp exp_koll(rand($opponent['level']*2,$opponent['level']*4));
if(
$effect_2[on] == 1)$exp $exp+ceil($exp*25/100);
$crystals rand($opponent['level']*5,$opponent['level']*7);
$win '<font color="red">Поражение</font>';
if(
$l_ch['id_1'] == $myID){
mysql_query("update `l_ch` set `schet_2` = '".($l_ch['schet_2']+1)."' where (`id` = '".$l_ch['id']."')");
}else{
mysql_query("update `l_ch` set `schet_1` = '".($l_ch['schet_1']+1)."' where (`id` = '".$l_ch['id']."')");
}
mysql_query("update `duel` set `start` = '0', `opponent` = '$_opponent[id]' where (`id` = '".$duel['id']."')");
mysql_query("update `users` set `exp` = '".($user['exp']+$exp)."', `crystals` = '".($user['crystals']+$crystals)."' where (`id` = '".$myID."')");
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");
}
mysql_query("DELETE FROM `duel_log` WHERE `id_batle` = '".$duel['id']."'");
$_SESSION['porazenie'] = "<b>$win</b><hr>Награда: ".ico('icons','exp.png').$exp опыта и ".ico('icons','crystal.png').$crystals кристаллов";
header('Location: /duel/');
exit();
}
mysql_query("INSERT INTO `duel_log` SET `uron` = '$_str', `krit` = '".($krit == true '0')."', `tip` = 'user', `id_batle` = '$duel[id]'");
mysql_query("INSERT INTO `duel_log` SET `uron` = '$_str_opp', `krit` = '".($krit_opp == true '0')."', `tip` = 'opp', `id_batle` = '$duel[id]'");
mysql_query("update `duel` set `opp_health` = '".($duel['opp_health']-$_str)."', `user_health` = '".($duel['user_health']-$_str_opp)."', `udar_last` = '".(time()+4)."' where (`id` = '".$duel['id']."')");
header('Location: /duel/batle/');
exit();
}
$title 'Дуэль с '.$opponent['login'];
require_once (
'system/head.php');
echo 
"<div class='linetop'></div><div class='title center'>".img('icons','health.png')." ".n_f($user['health'],1)."</div><div class='line'></div>";
$progress round($user['health']/$user['max_health']*100,1);
if(
$progress 100)$progress 100;
echo 
'<div class="exp"><div class="exp_in" style="width: '.$progress.'% "><br></div></div>';
echo 
"<div class='block center'>";
echo 
icons_user($opponent[id]).$opponent[login] ".ico('icons','health.png').$duel[opp_health]<br>";
echo 
"<div class='stat_bar'><div class='progress' style='width: ".round($duel['opp_health']/$opponent['max_health']*100,1)."%;'></div></div>";
echo 
"<a href='?attack' class='btn2'>Атаковать</a><hr>";
echo 
"<table cellpadding='5' cellspacing='0' align='center'><tr>";
echo 
"<td class='center' style='border-right: 1px solid #8D673A;'>";
if(
$user['kamen'] > 0)echo "<a href='?kamen' class='btn2'>".ico('icons','kamen.png')." Камень</a><br>";
else echo 
"<a href='?kamen' class='btn2'>".ico('icons','kamen.png')." <span class='grey'>Камень</span></a><br>";
if(
$duel['kamen'] > time()){
echo 
"<span class='info'><span id='time_".($duel['kamen']-time())."000'>".tl($duel['kamen']-time())."</span></span>";
}else{
echo 
"<span class='white'>+35% урон</span>";
}
echo 
"</td>";
echo 
"<td class='center'>";
if(
$user['trava'] > 0)echo "<a href='?trava' class='btn2'>".ico('icons','trava.png')." Трава</a><br>";
else echo 
"<a href='?trava' class='btn2'>".ico('icons','trava.png')." <span class='grey'>Трава</span></a><br>";
if(
$duel['trava'] > time()){
echo 
"<span class='info'><span id='time_".($duel['trava']-time())."000'>".tl($duel['trava']-time())."</span></span>";
}else{
echo 
"<span class='white'>-35% урон</span>";
}
echo 
"</td>";
echo 
"</tr></table>";
echo 
"</div>";
echo 
"<div class='block'>";
$k_post mysql_result(mysql_query("SELECT COUNT(*) FROM `duel_log` WHERE `id_batle` = '$duel[id]'"),0);
if(
$k_post == 0)echo "Логов не найдено...";
$q mysql_query("SELECT * FROM `duel_log` WHERE `id_batle` = '$duel[id]' ORDER BY `id` DESC LIMIT 15");
while(
$post mysql_fetch_assoc($q)){
if(
$post['tip'] == 'user'){
if(
$post['uron'] > 0)echo "Вы атаковали ".icons_user($opponent['id']).$opponent[login] на <b>$post[uron]</b> ".($post['krit'] == '(Крит)' '')."<br>";
else echo 
"Вы промахнулись<br>";
}else{
if(
$post['uron'] > 0)echo icons_user($opponent[id])." <font color='red'>$opponent[login] атаковал".($opponent['sex'] == 'w' 'а' '')." Вас на <b>$post[uron]</b> ".($post['krit'] == '(Крит)' '')."</font><br>";
else echo 
icons_user($opponent['id'])." <font color='red'>$opponent[login] промахнул".($opponent['sex'] == 'w' 'ась' 'ся')."</font><br>";
}
}
echo 
"</div>";
echo 
"<a href='?end' class='link center'>".ico('icons','arrow.png')." Покинуть бой</a>";
?>
<script type="text/javascript">
        var secS = 'с.';
        var secM = 'с.';
        var minS = 'м.';
        var minM = 'м.';
        var hourS = 'ч.';
        var hourM = 'ч.';
        var dayS = 'д.';
        var dayM = 'д.';
        var detailOut = false;
        var readyLink = '0'+(detailOut?secS:' ' + secM);
</script>
<script src="/ajax/t.js" type="text/javascript"></script>
<?
echo "</body></html>";
?>
Онлайн: 0
Реклама