Вход Регистрация
Файл: weatut.ru/duel_batle.php
Строк: 235
<?php
require_once ('system/func.php');
$duel mysql_fetch_array(mysql_query('SELECT * FROM `duel` WHERE `id_user` = "'.$myID.'"'));
if(
$duel[start] != 1){
header('Location: /duel/');
exit();
}
$_opponent mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `side` != '$user[side]' AND `str`+`def`+`max_health` >= '".ceil($user[str]+$user[def]+$user[max_health]*40/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(
$duel[opp_health] <= and $user[health] <= 0){
$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]+ceil($exp*15/100))."' WHERE `id` = '".$myID."' LIMIT 1");
mysql_query("UPDATE `clans` SET `exp` = `exp` + '".ceil($exp*15/100)."' WHERE `id` = '".$user[id_clan]."' LIMIT 1");
}
mysql_query("DELETE FROM `duel_log` WHERE `id_batle` = '".$duel[id]."'");
$_SESSION[msg] = "<b>$win</b><hr>Награда: ".ico('icons','exp.png').$exp опыта и ".ico('icons','crystal.png').$crystals кристаллов";
header('Location: /duel/');
exit();
}elseif(
$user[health] > and $duel[opp_health] <= 0){
$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']."')");
}
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]+ceil($exp*15/100))."' WHERE `id` = '".$myID."' LIMIT 1");
mysql_query("UPDATE `clans` SET `exp` = `exp` + '".ceil($exp*15/100)."' WHERE `id` = '".$user[id_clan]."' LIMIT 1");
}
mysql_query("DELETE FROM `duel_log` WHERE `id_batle` = '".$duel[id]."'");
$_SESSION[msg] = "<b>$win</b><hr>Награда: ".ico('icons','exp.png').$exp опыта и ".ico('icons','crystal.png').$crystals кристаллов";
header('Location: /duel/');
exit();
}elseif(
$duel[opp_health] > and $user[health] == 0){
$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]+ceil($exp*15/100))."' WHERE `id` = '".$myID."' LIMIT 1");
mysql_query("UPDATE `clans` SET `exp` = `exp` + '".ceil($exp*15/100)."' WHERE `id` = '".$user[id_clan]."' LIMIT 1");
}
mysql_query("DELETE FROM `duel_log` WHERE `id_batle` = '".$duel[id]."'");
$_SESSION[msg] = "<b>$win</b><hr>Награда: ".ico('icons','exp.png').$exp опыта и ".ico('icons','crystal.png').$crystals кристаллов";
header('Location: /duel/');
exit();
}
$title 'Дуэль';
require_once (
'system/head.php');
auth(); // Закроем от гостей
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>';
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]) and $user[health] > and $duel[opp_health] > 0) {
$_str_opp rand(round($opponent['str']/6), round($opponent['str']/4));
$_def_opp rand(round($opponent['def']/12), round($opponent['def']/7));
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;
mysql_query("INSERT INTO `duel_log` SET `uron_user` = '$_str', `tip` = 'user', `id_batle` = '$duel[id]'");
mysql_query("INSERT INTO `duel_log` SET `uron_opp` = '$_str_opp', `tip` = 'opp', `id_batle` = '$duel[id]'");
mysql_query("update `duel` set `opp_health` = '".($duel[opp_health]-$_str)."', `user_health` = '".($duel[user_health]-$_str_opp)."' where (`id` = '".$duel['id']."')");
header('Location: /duel/batle/');
exit();
}
echo 
"<div class='block center'>";
echo 
icons_user($opponent[id])." <font color='$opponent[color]'>$opponent[login]</font> ".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'>".tl($duel[kamen]-time())."</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'>".tl($duel[trava]-time())."</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'){
echo 
"Вы атаковали ".icons_user($opponent['id'])." <font color='$opponent[color]'>$opponent[login]</font> на <b>$post[uron_user]</b><br>";
}else{
echo 
icons_user($opponent[id])." <font color='red'><font color='$opponent[color]'>$opponent[login]</font> атаковал".($opponent['sex'] == 'w' 'а' '')." Вас на <b>$post[uron_opp]</b></font><br>";
}
}
echo 
"</div>";
echo 
"<a href='/duel/' class='link center'>".ico('icons','arrow.png')." Покинуть бой</a>";
echo 
"</body></html>";
require_once (
'system/footer.php');
?>
Онлайн: 2
Реклама