File size: 15.58Kb
<?
require_once '../core/system.php';
$header = 'Нежданные гости';
require_once '../core/head.php';
$timer=$_SERVER['REQUEST_TIME']+300;
$rel = mysql_query("SELECT * FROM `battle` WHERE `usr`='".$user['nick']."'");
$avto = mysql_num_rows($rel);
if($avto==1){
$t=$_SERVER['REQUEST_TIME']+3600;
$nextudar=rand(3,12);
$nextud=$_SERVER['REQUEST_TIME']+$nextudar;
mysql_query("INSERT INTO `battle` SET `usr`='".$user['nick']."', `name`='Посланник Тьмы', `status`='', `hpmax`='60', `hp`='60', `sila`='5', `prot`='10', `time`='$t', `nextud`='$nextud'");
mysql_query("INSERT INTO `battle` SET `usr`='".$user['nick']."', `name`='Посланник Тьмы', `status`='', `hpmax`='60', `hp`='60', `sila`='5', `prot`='10', `time`='$t', `nextud`='$nextud'");
mysql_query("UPDATE `user` SET `battle`='1' WHERE `id`='".$user['id']."'");
header ("Location: ?");exit;
}
if($user['save']==1){
header('Location: /');
exit();
}
if(empty($user['id'])){ header('Location: /');}
$_GET['mod'] = htmlspecialchars($_GET['mod']);
switch($_GET['mod']){
default:
$rep = mysql_query("SELECT * FROM `battle` WHERE `usr`='".$user['nick']."' and `hp`>0");
$mob = mysql_fetch_array($rep);
$kols = mysql_result(mysql_query("SELECT COUNT(*) FROM `battle` WHERE `usr`='".$user['nick']."' and `status`=''"),0);
if($kols==0){
$_SESSION['light'] = '<font color="#FE642E"><img src="/images/main/capture.png"> Бой завершен!</font>
<div class="empty"></div>
<font color="#81F781">Чтобы продолжить приключения, необходимо сохранить персонажа!</font>';
header ("Location: /user/save");
exit;
}
if(isset($_GET['udar'])){
$ureq = mysql_query("SELECT * FROM `battle` WHERE `usr`='".$user['nick']."' and `id`='$id'");
$mobc = mysql_fetch_array($ureq);
if(empty($id)){
$_SESSION['err']="Не выбран противник";
header ("Location: ?");
exit;
}
$req = mysql_query("SELECT * FROM `umen` WHERE `usr` = '".$user['id']."' and `img`='whack'");
$umen = mysql_fetch_array($req);
$summastat = $mobc['hpmax']+$mobc['sila']+$mobc['prot'];
$p=$mobc['prot']/$summastat;
$y=1-$p;
$u=rand($user['sila']-$user['sila']/8,$user['sila']);
$udar=$u*$y;
if(isset($_GET['whack'])){$udar=$udar*$umen['sila'];}else{$udar=$u*$y;}
$udar=round($udar,0);
$uron=$mobc['hp']-$udar;
if($udar>$user['max_uron']){mysql_query("UPDATE `user` SET `max_uron` = '$udar' WHERE `id`='".$user['id']."' LIMIT 1");}
$ttur=rand(1,4);
if($ttur==1){$ttur='ударили'; }
if($ttur==2){$ttur='поразили';}
if($ttur==3){$ttur='сразили';}
if($ttur==4){$ttur='зацепили';}
$sms="$ttur $mobc[name]";
if($uron<=0){
$ttud=rand(1,5);
if($ttud==1){$ttud='убили';}
if($ttud==2){$ttud='уничтожили';}
if($ttud==3){$ttud='разгромили';}
if($ttud==4){$ttud='сокрушили';}
if($ttud==5){$ttud='победили';}
mysql_query("UPDATE `battle` SET `status` = 'off', `hp` = '0' WHERE `usr`='".$user['nick']."' and `id`='$id'");
mysql_query("UPDATE `user` SET `mob`='0', `gold` = '$user[gold]'+10, `wins`=`wins`+'1' WHERE `id`='".$user['id']."'");
$_SESSION['light']="Вы <img src='/images/icon/dead.png'>".$ttud." Посланник Тьмы <img src='/images/icon/stat/hp.png'><font color='#F5E17E'>-".$udar."</font>";
}else{
if(isset($_GET['whack'])){
$whack = mysql_num_rows(mysql_query("SELECT * FROM `task` WHERE `usr`='".$user['id']."' and `status`='2' and `task`='1'"));
if($whack>0){mysql_query("UPDATE `task` SET `min` = `min`+'1' WHERE `usr`='".$user['id']."' and `status`='2' and `task`='1'");}
$vrem = $_SERVER['REQUEST_TIME']+$umen['time'];
mysql_query("UPDATE `umen` SET `timer` = '$vrem' WHERE `usr`='".$user['id']."' and `img`='whack'");
$_SESSION['light']="Вы использовали <img src='/images/umen/whack.png' height='16px' width='16px'> <font color='#FFBF00'>Сильный Удар</font> против Посланник Тьмы <img src='/images/icon/stat/hp.png'><font color='#F5E17E'>-".$udar."</font>";
} else {
$_SESSION['light']="Вы <img src='/images/icon/fight.png'>".$sms." <img src='/images/icon/stat/hp.png'><font color='#F5E17E'>-".$udar."</font>";
}
mysql_query("UPDATE `battle` SET `hp` = '$uron' WHERE `usr`='".$user['nick']."' and `id`='$id'");}
if($setgame['exp']==1)$udar=$udar*2;
mysql_query("UPDATE `user` SET `exp` = '$user[exp]'+$udar, `mob`='$id' WHERE `nick`='".$user['nick']."'");
header ("Location: ?");
exit;
}
if($user['health']<=0){
echo"</div><div class='but-list'>
<a href=\"?\"> <img src='/images/icon/reload.png'> Обновить </a></font>
<a href=\"/\"> <img src='/images/icon/error.png'> Покинуть бой </a></div></div>";
} else {
$ureq = mysql_query("SELECT * FROM `battle` WHERE `usr`='".$user['nick']."' and `hp`>0'");
$umob = mysql_fetch_array($ureq);
echo'<div class="foot"><table width="100%">
<tbody>
<td style="text-align: center" width="30%">
<img src="/images/monsters/envoy.png">
</td>
<td class="foot center"> '.$mob['name'].'<div class="empty2"></div>';
$kol70=60*0.70;
$kol30=60*0.30;
if($mob['hp']>=$kol70){$health="green";}
if($mob['hp']>=$kol30 and $mob['hp']<$kol70){$health="orange";}
if($mob['hp']<$kol30){$health="red";}
echo"<div class='hp'>
<div class='$health' style='width:".floor(100/(60/$mob['hp']))."%'></div>
</div>";
echo'<div class="empty2"></div><div class="empty2"></div><font color="#CDC9C9"> ('.$mob['hp'].'/60)</font></td>
</tbody></table></div>';
echo"<div class='foot'><table width='100%' border='0' cellpadding='0' cellspacing='0' style='padding-top: 5px;'>
<tbody>";
$randomob = mysql_fetch_array(mysql_query("SELECT * FROM `battle` WHERE `usr`='".$user['nick']."' and `status`='' ORDER BY RAND() LIMIT 1"),0);
if($kols==0){echo'<td width="45%"><a class="fight center" href="?"> Обновить </a></div></td>';}
if($kols==1){echo' <td width="45%"><a class="fight center" href="?udar&id='.$mob['id'].'"> Атаковать </a></div></td>';}
if($kols>1){
if($user['mob']>0 and $randomob['hp']>0){echo' <td width="45%"><a class="fight center" href="?udar&id='.$mob['id'].'"> Атаковать </a></div></td>';}
echo' <td width="45%"><a class="fight center" href="?udar&id='.$randomob['id'].'"> Бить любого </a></div></td>';}
echo"</tbody></table><table width='100%' border='0' cellpadding='0' cellspacing='0' style='padding-top: 5px;'>
<tbody>";
$req = mysql_query("SELECT * FROM `umen` WHERE `usr` = '".$user['id']."' and `img`='whack'");
$umen = mysql_fetch_array($req);
$avto = mysql_num_rows($req);
if($avto==0){echo"<td width='30%'><div class='big-but'><div class='imgwrap'><img src='/images/umen/whack_grey.png' height='20' width='20'></div><div class='empty'></div>Недоступно</td></div>"; }
if($avto>0){
if($umen['timer']<="".$_SERVER['REQUEST_TIME'].""){echo"<td width='30%'><a class='big-but' href=\"?udar&whack&id=$mob[id]\"><div class='imgwrap'><img src='/images/umen/whack.png' height='35' width='35'></div> <div class='empty'></div> </a></td></div>";
}else{
$recharge=$umen['timer']-$_SERVER['REQUEST_TIME'];
echo"<td width='30%'><div class='big-but'><div class='imgwrap'><img src='/images/umen/whack_grey.png' height='20' width='20'></div><div class='empty'></div>";
$hours = floor($recharge / 3600);
if($hours > 0 && $hours<10)
{$h='0'.$hours.'';}
if($hours >= 10){$h=''.$hours.'';}
if($hours == 0){$h='00';}
$minutes = floor($recharge / 60) % 60;
if($minutes > 0 && $minutes<10)
{$m='0'.$minutes.'';}
if($minutes >= 10){$m=''.$minutes.'';}
if($minutes == 0){$m='00';}
$seconds = $recharge - $minutes*60 - $hours*3600;
if($seconds > 0 && $seconds<10)
{$s='0'.$seconds.'';}
if($seconds >=10){$s=''.$seconds.'';}
if($seconds == 0){$s='00';}
if($h==0){echo"$m:$s</td></div>";}
if($h>0){echo"$h:$m:$s</td></div>";}
}}
$req = mysql_query("SELECT * FROM `umen` WHERE `usr` = '".$user['id']."' and `img`='healing'");
$umen = mysql_fetch_array($req);
$avto = mysql_num_rows($req);
if($avto==0){echo"<td width='30%'><div class='big-but'><div class='imgwrap'><img src='/images/umen/healing_grey.png' height='20' width='20'></div><div class='empty'></div>Недоступно</td></div>"; }
if($avto>0){
if($umen['timer']<"".$_SERVER['REQUEST_TIME'].""){echo"<td width='30%'><a class='big-but' href=\"?healing\"><div class='imgwrap'><img src='/images/umen/healing.png' height='35' width='35'></div><div class='empty'></div></a></td></div>";
}else{$recharge=$umen['timer']-$_SERVER['REQUEST_TIME'];
echo"<td width='30%'><div class='big-but'><div class='imgwrap'><img src='/images/umen/healing_grey.png' height='20' width='20'></div><div class='empty'></div>";
$hours = floor($recharge / 3600);
if($hours > 0 && $hours<10)
{$h='0'.$hours.'';}
if($hours >= 10){$h=''.$hours.'';}
if($hours == 0){$h='00';}
$minutes = floor($recharge / 60) % 60;
if($minutes > 0 && $minutes<10)
{$m='0'.$minutes.'';}
if($minutes >= 10){$m=''.$minutes.'';}
if($minutes == 0){$m='00';}
$seconds = $recharge - $minutes*60 - $hours*3600;
if($seconds > 0 && $seconds<10)
{$s='0'.$seconds.'';}
if($seconds >=10){$s=''.$seconds.'';}
if($seconds == 0){$s='00';}
if($h==0){echo"$m:$s</td></div>";}
if($h>0){echo"$h:$m:$s</td></div>";}
}}
$req = mysql_query("SELECT * FROM `umen` WHERE `usr` = '".$user['id']."' and `img`='gift_of_the_Gods'");
$umen = mysql_fetch_array($req);
$avto = mysql_num_rows($req);
if($avto==0){echo"<td width='30%'><div class='big-but'><div class='imgwrap'><img src='/images/umen/gift_of_the_Gods_grey.png' height='20' width='20'></div><div class='empty'></div>Недоступно</td></div>"; }
if($avto>0){
if($umen['timer']<"".$_SERVER['REQUEST_TIME'].""){echo"<td width='30%'><a class='big-but' href=\"?gift_of_the_Gods\"><div class='imgwrap'><img src='/images/umen/gift_of_the_Gods.png' height='35' width='35'></div><div class='empty'></div></a></td></div>";
}else{$recharge=$umen['timer']-$_SERVER['REQUEST_TIME'];
echo"<td width='30%'><div class='big-but'><div class='imgwrap'><img src='/images/umen/gift_of_the_Gods_grey.png' height='20' width='20'></div><div class='empty'></div>";
$hours = floor($recharge / 3600);
if($hours > 0 && $hours<10)
{$h='0'.$hours.'';}
if($hours >= 10){$h=''.$hours.'';}
if($hours == 0){$h='00';}
$minutes = floor($recharge / 60) % 60;
if($minutes > 0 && $minutes<10)
{$m='0'.$minutes.'';}
if($minutes >= 10){$m=''.$minutes.'';}
if($minutes == 0){$m='00';}
$seconds = $recharge - $minutes*60 - $hours*3600;
if($seconds > 0 && $seconds<10)
{$s='0'.$seconds.'';}
if($seconds >=10){$s=''.$seconds.'';}
if($seconds == 0){$s='00';}
if($h==0){echo"$m:$s</td></div>";}
if($h>0){echo"$h:$m:$s</td></div>";}
}}
echo"</td></tbody></table></div>";
}
$requ = mysql_query("SELECT * FROM `battle` WHERE `usr`='".$user['nick']."' and `status`='' ");
$avto = mysql_num_rows($requ);
if($avto>0){
echo"<hr><div class='foot foot'><div class='center'>Противники</br><div class='empty2'></div></div>";
$req = mysql_query("SELECT DISTINCT `name` FROM `battle` WHERE `usr`='".$user['nick']."' and `status`='' ");
while($mob = mysql_fetch_array($req)){
$randomobu = mysql_fetch_array(mysql_query("SELECT * FROM `battle` WHERE `usr`='".$user['nick']."' and `name`='$mob[name]' and `status`='' ORDER BY RAND() LIMIT 1"),0);
if($randomobu['hp']>=$kol70){$health="green";$hp="<font color='green'>$randomobu[hp]</font>";}
if($randomobu['hp']>=$kol30 and $randomobu['hp']<$kol70){$health="orange";$hp="<font color='orange'>$randomobu[hp]</font>";}
if($randomobu['hp']<$kol30){$health="red";$hp="<font color='red'>$randomobu[hp]</font>";}
$koll = mysql_result(mysql_query("SELECT COUNT(*) FROM `battle` WHERE `name`='$mob[name]' and `usr`='".$user['nick']."' and `status`=''"),0);
if($koll>1){
echo"<a class='fight' href='?udar&id=$randomobu[id]'>$mob[name] <font color='#CDC9C9'>($koll)</font></a>";}else{
echo"<a class='fight' href='?udar&id=$randomobu[id]'>$mob[name] ($hp)</a>";}
}echo"</div>";}
$req = mysql_query("SELECT * FROM `duellog` WHERE `opon` = '".$user['nick']."' or `usr` = '".$user['nick']."' and `timer`>='".$_SERVER['REQUEST_TIME']."' ORDER BY `id` DESC LIMIT 9");
$avto = mysql_num_rows($req);
if($avto>=1){
echo"<hr><div class='foot foot'><div class='center'>Журнал боя</br><div class='empty2'></div></div>";
While($ilok = mysql_fetch_array($req)){
$timeudar=$_SERVER['REQUEST_TIME']-$ilok['timer']+300;
if($timeudar<60){
$timeudar="$timeudar сек.";
}else{
$timeudar=round($timeudar/60);
$timeudar="$timeudar мин.";
}
$fed = mysql_query("SELECT * FROM `user` WHERE `id` = '$ilok[kogo]'");
$us = mysql_fetch_array($fed);
if($user['plem']=='ogn'){$plem='0';}
if($user['plem']=='mol'){$plem='1';}
if($us['plem']=='ogn'){$plem2='0';}
if($us['plem']=='mol'){$plem2='1';}
if($ilok['slip']==1){echo'<font color="grey"> '.$ilok['text'].'</font> <span class="mit">'.$timeudar.'</span> <div class="empty"></div>';}
if($ilok['slip']==2){echo'<font color="#AAAAAA"> <img src=/images/icon/race/'.$plem.'.png><a href="/user/'.$user['id'].'/"><font color="'.$user['font'].'">'.$user['nick'].'</font></a><font color="grey"> '.$ilok['text'].'</font> на игрока <font color="#AAAAAA"> <img src=/images/icon/race/'.$plem2.'.png><a href="/user/'.$us['id'].'/"><font color="'.$us['font'].'">'.$us['nick'].'</font></a> <font color="8CF956">+'.$ilok['uron'].'</font> здоровья <span class="mit">'.$timeudar.'</span> <div class="empty"></div>';}
if($ilok['slip']==3){echo'<font color="#AAAAAA"> <img src=/images/icon/race/'.$plem.'.png><a href="/user/'.$user['id'].'/"><font color="'.$user['font'].'">'.$user['nick'].'</font></a><font color="grey"> '.$ilok['text'].'</font> <font color="8CF956">+'.$ilok['uron'].'</font> к <img src="/images/icon/stat/hp.png"><img src="/images/icon/stat/sila.png"><img src="/images/icon/stat/prot.png"> <span class="mit">'.$timeudar.'</span> <div class="empty"></div>';}
if($ilok['slip']==0){
if($ilok['kogo']>0){
if($user['plem']=='ogn'){$plem='0';}
if($user['plem']=='mol'){$plem='1';}
if($ilok['dead']==1){echo '<img src="/images/icon/dead.png" height="16" width="16">
<font color="#AAAAAA"> '.$ilok['text'].' <img src=/images/icon/race/'.$plem.'.png><a href="/user/'.$user['id'].'/"><font color="'.$user['font'].'">'.$user['nick'].'</font></a></font><span class="mit">'.$timeudar.'</span> <div class="empty"></div>';}else{
echo'<font color="#AAAAAA"> '.$ilok['text'].' <img src=/images/icon/race/'.$plem.'.png><a href="/user/'.$user['id'].'/"><font color="'.$user['font'].'">'.$user['nick'].'</font></a> на <font color="F5E17E">'.$ilok['uron'].'</font> урона</font><span class="mit">'.$timeudar.'</span> <div class="empty"></div>';}}
if($ilok['kogo']==0){
if($ilok['dead']==1){echo '<img src="/images/icon/dead.png" height="16" width="16">
<font color="#AAAAAA"> <img src=/images/icon/race/'.$plem.'.png><a href="/user/'.$user['id'].'/"><font color="'.$user['font'].'">'.$user['nick'].'</font></a>'.$ilok['text'].' </font><span class="mit">'.$timeudar.'</span> <div class="empty"></div>';}else{
echo'<font color="#AAAAAA"> <img src=/images/icon/race/'.$plem.'.png><a href="/user/'.$user['id'].'/"><font color="'.$user['font'].'">'.$user['nick'].'</font></a>'.$ilok['text'].' на <font color="F5E17E">'.$ilok['uron'].'</font> урона</font></font><span class="mit">'.$timeudar.'</span> <div class="empty"></div>';}}}}}
echo"</div>";
break;
case 'win':
$umen="<img src='/images/umen/whack.png' height='16' width='16'>Сильный Удар";
echo"<center><img width='100%' src='/images/win.jpg'/></center><div class='mini-line'></div>
<div class='player'><div class='empty'></div><center><span class='blue'>Ваша награда:</span> <img src='/images/icon/silver.png' alt=''/>10</br> <span class='blue'>Получено умение:</span> $umen</center><div class='empty'></div></div> <div class='mini-line'></div>";
echo"
</div> <center><div class='foot'><a class='inpc-ar' href=\"/user/save\">Сохранить персонажа</a></center></div>";
break;
}
require_once '../core/foot.php';
?>