Файл: arena.php
Строк: 314
<?
define('PROTECTOR', 1);
if(isset($_GET[ataka])){
$header=TRUE;
}else{
$textl='Арена';
}
$head = 'arena';//фикс. места
@include('files/db.php');
@include('files/auth.php');
@include('files/func.php');
@include('files/core.php');
@include('files/head.php');
@include('files/zag.php');
$time=time();
switch($_GET[mod]){
default:
$per=$op-$ol;
if($per==0){$per=1;}
$exp=round((($udata[exp]-$ol)/($per))*100);
////////////////Первый лог арены////
$leg=mysql_query("SELECT * FROM `arenalog` WHERE `usr`='$log' LIMIT 1");
$logs=mysql_num_rows($leg);
if($logs==0){
mysql_query("INSERT INTO `arenalog` SET `usr` = '$log'");
}
echo"Доступные противники</div><div class='menu'>";
echo'<div style="background:#666666;height:1px;width:100%;padding:0;margin:6px 0;">
<div style="background:#FFDF8C; height:1px; width:'.$exp.'%;"></div>
</div>';
if(!isset($_GET['log'])){
echo"</div><div class="log"><font color='#66FF66'>Ваш уровень разбойника <b>$set[razb]</b></br></font>";
if(!isset($_GET['ataka'])){echo"<font color='#66FF66'>Чем сильнее противник, тем больше опыта и монет получишь за победу!</font></div>";}
}else{
$leg=mysql_query("SELECT * FROM `arenalog` WHERE `usr`='$log' LIMIT 1");
$logs=mysql_fetch_array($leg);
if($_GET[log]=="inv"){
echo"<div class="log"><font color='#FF6633'>У вас больше нет доступных боёв! До следующего боя
$logs[log] минут</div></div></font>";
}
if($_GET[log]=="hp"){
echo"<div class="log"><font color='#FF6633'>У вас не хватает здоровья или энергии!</div></div></font>";}
if($_GET[log]=="win"){
echo"<div class="log"><font color='#66FF66'>Вы победили!</br></font>Вы нанесли урона: $logs[myudar]</br>
$logs[oponent] нанес урона: $logs[userudar]</br>Вы отобрали $logs[money] монет и получили $logs[exp] опыта!
</div></div>";}
if($_GET[log]=="los"){
echo"<div class="log"><font color='#FF6633'>Поражение!</br></font>Вы нанесли урона: $logs[myudar]</br>
$logs[oponent] нанес урона: $logs[userudar]</br>У вас отобрали $logs[money] монет, но вы получили $logs[exp] опыта.
</div></div>";}
}
echo"</div>";
if(empty($boys1[usr])){$log1=rand($udata[lvl]-3,$udata[lvl]-1);
$boy1=mysql_query("SELECT * FROM `users` WHERE `lvl`='$log1' ORDER BY RAND() LIMIT 1");
$boys1 = mysql_fetch_array($boy1);
$avto = mysql_num_rows($boy1);if($avto==0){$log1=rand($udata[lvl]-3,$udata[lvl]-1);
$boy1=mysql_query("SELECT * FROM `users` WHERE `lvl`='$log1' ORDER BY RAND() LIMIT 1");
$boys1 = mysql_fetch_array($boy1);}
}
if(empty($boys2[usr])){$log2=rand($udata[lvl],$udata[lvl]+1);
$boy2=mysql_query("SELECT * FROM `users` WHERE `lvl`='$log2' and `usr`!='$log' ORDER BY RAND() LIMIT 1");
$boys2 = mysql_fetch_array($boy2);
$avto = mysql_num_rows($boy2);if($avto==0){$log2=rand($udata[lvl]-3,$udata[lvl]-1);
$boy2=mysql_query("SELECT * FROM `users` WHERE `lvl`='$log2' ORDER BY RAND() LIMIT 1");
$boys2 = mysql_fetch_array($boy2);}
}
if(empty($boys3[usr])){$log3=rand($udata[lvl]+2,$udata[lvl]+3);
$boy3=mysql_query("SELECT * FROM `users` WHERE `lvl`='$log3' ORDER BY RAND() LIMIT 1");
$boys3 = mysql_fetch_array($boy3);
$avto = mysql_num_rows($boy3);if($avto==0){$log3=rand($udata[lvl]-3,$udata[lvl]-1);
$boy3=mysql_query("SELECT * FROM `users` WHERE `lvl`='$log3' ORDER BY RAND() LIMIT 1");
$boys3 = mysql_fetch_array($boy3);}
}
echo"</div><div class='menu'>";
if(empty($boys1[usr])){echo"<b>Нет подходящего игрока</b></br>";}else{
$stat1=$boys1[sila]+$boys1[hp]+$boys1[lovk]+$boys1[prot];
echo"<b>$boys1[usr]</b></br>";}
echo"<img class='float-left' src='pic/avatar/human/C.jpg' width='50' height='80' style='margin-right:6px;'/>
<img src='pic/main/redup.png' alt='*'/>Уровень: $boys1[lvl]</br>
<img src='pic/main/red_warrior.png' alt='*'/>Сила: $boys1[sila]</br>
<img src='pic/main/red_healer.png' alt='*'/>Здоровье: $boys1[hp]</br><img src='pic/main/exp.png' alt='*'/>Ловкость: $boys1[lovk]</br><img src='pic/main/def.png' alt='*'/>
Защита: $boys1[prot]</br>
<form action="arena.php?mod=ataka&ataka&user1=$boys1[usr]&stat=$stat1" method="post">
<input class="button" type="submit" value="Атаковать!" /></form>
</div><div class='menu'>";
if(empty($boys2[usr])){echo"<b>Нет подходящего игрока</b></br>";}else{
$stat2=$boys2[sila]+$boys2[hp]+$boys2[lovk]+$boys2[prot];
echo"<b>$boys2[usr]</b></br>";}
echo"<img class='float-left' src='pic/avatar/human/B.jpg' width='50' height='80' style='margin-right:6px;'/>
<img src='pic/main/redup.png' alt='*'/>Уровень: $boys2[lvl]</br>
<img src='pic/main/red_warrior.png' alt='*'/>Сила: $boys2[sila]</br>
<img src='pic/main/red_healer.png' alt='*'/>Здоровье: $boys2[hp]</br><img src='pic/main/exp.png' alt='*'/>Ловкость: $boys2[lovk]</br><img src='pic/main/def.png' alt='*'/>
Защита: $boys2[prot]</br>
<form action="arena.php?mod=ataka&ataka&user2=$boys2[usr]&stat=$stat2" method="post">
<input class="button" type="submit" value="Атаковать!" /></form>
</div><div class='menu'>";
if(empty($boys3[usr])){echo"<b>Нет подходящего игрока</b></br>";}else{
$stat3=$boys3[sila]+$boys3[hp]+$boys3[lovk]+$boys3[prot];
echo"<b>$boys3[usr]</b></br>";}
echo"<img class='float-left' src='pic/avatar/human/A.jpg' width='50' height='80' style='margin-right:6px;'/>
<img src='pic/main/redup.png' alt='*'/>Уровень: $boys3[lvl]</br><img src='pic/main/red_warrior.png' alt='*'/>Сила: $boys3[sila]</br>
<img src='pic/main/red_healer.png' alt='*'/>Здоровье: $boys3[hp]</br><img src='pic/main/exp.png' alt='*'/>Ловкость: $boys3[lovk]</br><img src='pic/main/def.png' alt='*'/>
Защита: $boys3[prot]</br>
<form action="arena.php?mod=ataka&ataka&user3=$boys3[usr]&stat=$stat3" method="post">
<input class="button" type="submit" value="Атаковать!" /></form>
</div><div class='menu'>
";
echo"<img src='pic/main/hero.png' alt='*'/> $log <img src='pic/main/redup.png' alt='*'/> $udata[lvl] <img src='pic/main/red_warrior.png' alt='*'/> $udata[sila]
<img src='pic/main/red_healer.png' alt='*'/> $udata[hpall] <img src='pic/main/exp.png' alt='*'/> $udata[lovk] <img src='pic/main/def.png' alt='*'/>
$udata[prot]</br> $div";
$el = mysql_query("SELECT * FROM `res` WHERE `usr` = '$log' and `tip`='elexir' and `kol`>'0' ORDER by `cena` DESC LIMIT 4");
$avt=mysql_num_rows($el);
if($avt>=1){
While($elm = mysql_fetch_array($el)){
echo"$elm[name] ($elm[kol] шт.) [<a href="elexirs.php?id=$elm[id]">исп.</a>]<br/>";
}}
echo"</div><div class='menu'><a href="arena.php?">Другие противники</a>";
@include('files/down.php');
case 'ataka':
if(isset($_GET['ataka'])){
$header=TRUE;
$log1=rand($udata[lvl]-3,$udata[lvl]-1);
$log2=rand($udata[lvl],$udata[lvl]+1);
$log3=rand($udata[lvl]+2,$udata[lvl]+4);
$boy1=mysql_query("SELECT * FROM `users` WHERE `lvl`='$log1' ORDER BY RAND() LIMIT 1");
$boys1 = mysql_fetch_array($boy1);
$boy2=mysql_query("SELECT * FROM `users` WHERE `lvl`='$log2' and `usr`!='$log' ORDER BY RAND() LIMIT 1");
$boys2 = mysql_fetch_array($boy2);
$boy3=mysql_query("SELECT * FROM `users` WHERE `lvl`='$log3' ORDER BY RAND() LIMIT 1");
$boys3 = mysql_fetch_array($boy3);
$rand=rand(0,100);
$mprand=rand(3,6);
if($set[arenainv]==0){
$ost=5-round(($time-$set[artime])/60);
mysql_query("UPDATE `arenalog` SET `name`='inv', `log`='$ost' WHERE `usr` = '$log'");
header ("Location: arena.php?log=inv");exit; //в бой
}elseif($udata[hp]<=0 OR $udata[mp]<=0){
mysql_query("UPDATE `arenalog` SET `name`='hp' WHERE `usr` = '$log'");
header ("Location: arena.php?log=hp");exit; //в бой
}
ELSE{
if($udata[lvl]>=0 and $udata[lvl]<=5){$koef1=rand(2,4);$koef2=rand(4,8);$koef3=rand(6,10);$bon1=rand(1,4)*1.5;$bon2=rand(2,6)*1.5;$bon3=rand(6,8)*1.5;}
if($udata[lvl]>5 and $udata[lvl]<=10){$koef1=rand(2,4);$koef2=rand(4,8);$koef3=rand(6,10);$bon1=rand(1,4)*1.5;$bon2=rand(5,15)*1.5;$bon3=rand(10,20)*1.5;}
if($udata[lvl]>10 and $udata[lvl]<=20){$koef1=rand(8,16);$koef2=rand(10,20);$koef3=rand(20,30);$bon1=rand(8,16)*1.6;$bon2=rand(10,20)*1.6;$bon3=rand(20,30)*1.6;}
if($udata[lvl]>20 and $udata[lvl]<=30){$koef1=rand(14,22);$koef2=rand(15,25);$koef3=rand(30,40);$bon1=rand(14,22)*1.7;$bon2=rand(15,25)*1.7;$bon3=rand(30,40)*1.7;}
if($udata[lvl]>30 and $udata[lvl]<=40){$koef1=rand(20,28);$koef2=rand(20,35);$koef3=rand(40,50);$bon1=rand(20,28)*1.8;$bon2=rand(20,35)*1.8;$bon3=rand(40,50)*1.8;}
if($udata[lvl]>40 and $udata[lvl]<=50){$koef1=rand(26,32);$koef2=rand(30,45);$koef3=rand(50,60);$bon1=rand(26,32)*1.9;$bon2=rand(30,45)*1.9;$bon3=rand(50,60)*1.9;}
if($udata[lvl]>50 and $udata[lvl]<=60){$koef1=rand(30,36);$koef2=rand(35,55);$koef3=rand(50,65);$bon1=rand(30,36)*2;$bon2=rand(35,55)*2;$bon3=rand(50,70)*2;}
if(!empty($_GET[user1])){$shans=80;$var=round($koef1+$set[razb]*1.5);$bon=round($bon1+$set[razb]*3);$user=$_GET[user1];}
if(!empty($_GET[user2])){$shans=66;$var=round($koef2+$set[razb]*1.5);$bon=round($bon2+$set[razb]*3);$user=$_GET[user2];}
if(!empty($_GET[user3])){$shans=40;$var=round($koef3+$set[razb]*2);$bon=round($bon3+$set[razb]*3);$user=$_GET[user3];}
$stat=$_GET[stat];
$my=$udata[sila]+$udata[hpall]+$udata[lovk]+$udata[prot];
if(($my-$stat)>=10){$shans=80;}
if($shans>=$rand){
$inv=$set[arenainv]-1;
$win=$udata[arenawins]+1;
$los=$udata[arenaloses];
$uron=3+rand(0,$udata[hp]/5);
$uron=round($uron);
$udar=round($uron+$uron/6);
mysql_query("UPDATE `users` SET `money` = '$udata[money]'+'$var', `exp`='$udata[exp]'+'$bon', `hp`= '$udata[hp]'-'$uron'
, `mp`='$udata[mp]'-'$mprand', `arenawins`='$win',`arenaloses`='$los' WHERE `usr` = '$log'");
/////////////zd2
if($kv[zd2]=="used" AND $kv[zd2_p]<"3"){
$zd2=$kv[zd2_p]+1;
mysql_query("UPDATE `kves` SET `zd2_p`='$zd2' WHERE `us_id`='$udata[id]' ");}
////////////
mysql_query("UPDATE `set` SET `arenainv`='$inv', `artime`='$time' WHERE `usr` = '$log'")or die(mysql_error());
mysql_query("UPDATE `arenalog` SET `name`='win',`oponent`='".mysql_real_escape_string($user)."',`money`='$var',`exp`='$bon',`myudar`='$udar',`userudar`='$uron' WHERE `usr` = '$log'");
ob_start();
$header=TRUE;
header ("Location: arena.php?log=win");exit; //в бой
}
else{
$inv=$set[arenainv]-1;
$win=$udata[arenawins];
$los=$udata[arenaloses]+1;
$var=1*round($var/4);
$bon=round($bon/2);
$uron=1+rand(0,$udata[hp]/5);
$uron=round($uron);
$udar=round($uron-$uron/6);
mysql_query("UPDATE `users` SET `money` = '$udata[money]'-'$var', `exp`='$udata[exp]'+'$bon', `hp`= '$udata[hp]'-'$uron'
, `mp`='$udata[mp]'-'$mprand', `arenawins`='$win',`arenaloses`='$los' WHERE `usr` = '$log'");
mysql_query("UPDATE `set` SET `arenainv`='$inv', `artime`='$time' WHERE `usr` = '$log'");
mysql_query("UPDATE `arenalog` SET `name`='los',`oponent`='".mysql_real_escape_string($user)."',`money`='$var',`exp`='$bon',
`myudar`='$udar',`userudar`='$uron' WHERE `usr` = '$log'");
header ("Location: arena.php?log=los");exit; //в бой
}
}
}
break;
break;
@include('files/down.php');
}
?>