View file release_fix#2/mods/game/battle.php

File size: 6.78Kb
<?php
session_start();
$mod_title="игра-сражение с $_GET[name]";
$mod_status="on";
if($mod_status=="on")
{
function mod_body($auth,$adminauth)
{
$level="";
$guildc="";
$arenac="";
if($auth=="ok")
{
$mcl="";
$mh="";
$ms="";
$mm="";
$mmx="";
$mz="";
$query = "SELECT * FROM users WHERE login='$_COOKIE[login]'";
$cat = mysql_query ($query);
if(!$cat) exit (mysql_error());
while(list($id,$login,$pass,$mail,$reg,$class,$m,$h,$z,$s,$mon,$gold,$pms,$lvl,$ava,$ban,$online) = mysql_fetch_row($cat))
{
$mcl=$class;
$level=$lvl;
$mh=$h;
$ms=$s;
$mm=$m;
$mz=$z;
$mmx=$m;
}
$query = "SELECT * FROM count";
$cat = mysql_query ($query);
if(!$cat) exit (mysql_error());
while(list($id,$guild,$arena) = mysql_fetch_row($cat))
{
$guildc=$guild;
$arenac=$arena;
}
echo "
<img src='img/bo.png'> <a href='?do=game/char'>персонаж($level)</a>|<img src='img/bs.png'> <a href='?do=game/history'>история</a><br>
<br>
";
$_pg="0";
$ag="-10";
$_pg2="10";
if(!empty($_GET['_pg']))
{
$ag=$_GET['_pg']-"10";
$_pg=$_GET['_pg'];
$_pg2=$_GET['_pg']+"10";
}
$mob_name="";
$mob_s;
$mob_m;
$mob_h;
$query = "SELECT * FROM mobs WHERE name='$_GET[name]'";
$cat = mysql_query ($query);
if(!$cat) exit (mysql_error());
while(list($id,$name,$inst,$lvl,$s,$m,$h,$expp,$expm,$mp,$mm,$drop) = mysql_fetch_row($cat))
{
$mob_name=$name;
$mob_s=$s;
$mob_m=$m;
$mob_h=$h;
}
if($mob_name=="")
{
echo "<span style='color:red'>моб $_GET[name] несушествует</span><br>";
}
else
{
$nowhtest="";
$query = "SELECT * FROM battle WHERE login='$_COOKIE[login]'";
$cat = mysql_query ($query);
if(!$cat) exit (mysql_error());
while(list($login,$nowh,$name,$s,$m,$h) = mysql_fetch_row($cat))
{
$nowhtest=$nowh;
}

$mh1="";
$mobx_h="";
$xname="";
$mobx_s="";
$mobx_m="";
$query = "SELECT * FROM battle WHERE login='$_COOKIE[login]'";
$cat = mysql_query ($query);
if(!$cat) exit (mysql_error());
while(list($login,$nowh,$name,$s,$m,$h) = mysql_fetch_row($cat))
{
$mh1=$nowh;
$mobx_h=$h;
$xname=$name;
$mobx_s=$s;
$mobx_m=$m;
}
$mh1="";
$mobx_h="";
$namex="";
$query = "SELECT * FROM battle WHERE login='$_COOKIE[login]'";
$cat = mysql_query ($query);
if(!$cat) exit (mysql_error());
while(list($login,$nowh,$name,$s,$m,$h) = mysql_fetch_row($cat))
{
$mh1=$nowh;
$mobx_h=$h;
$namex=$name;
}
$mattack=rand(0,1);
$ztype="";
$mhx="$mobx_h";
if($_GET['dox']=="attack")
{
$mhx=$mobx_h-$ms;
$query="UPDATE battle SET h='$mhx' WHERE login='".$_COOKIE[login]."'";
$result=mysql_query($query)
or die("<span style='color:red'>ошибка обновления battle.log!</span><br>");
$str="<img src=img/bb.png> вы нанесли удар -$ms HP<br>";
$query = "INSERT INTO battlelog (login,text) VALUES ('$_COOKIE[login]','$str')";
$result = mysql_query ($query)
or die ("<span style='color:red'>ошибка лога!</span>");
}
else if($_GET['dox']=="magic")
{
$mhx=$mobx_h-$mmx;
$query="UPDATE battle SET h='$mhx' WHERE login='".$_COOKIE[login]."'";
$result=mysql_query($query)
or die("<span style='color:red'>ошибка обновления battle.log!</span><br>");
$str="<img src=img/bb.png> вы нанесли магический удар -$mmx HP<br>";
$query = "INSERT INTO battlelog (login,text) VALUES ('$_COOKIE[login]','$str')";
$result = mysql_query ($query)
or die ("<span style='color:red'>ошибка лога!</span>");
}
else if($_GET['dox']=="shield")
{
$ztype="true";
$str="<img src=img/bz.png> вы защитились!<br>";
$query = "INSERT INTO battlelog (login,text) VALUES ('$_COOKIE[login]','$str')";
$result = mysql_query ($query)
or die ("<span style='color:red'>ошибка лога!</span>");
}
sleep(0.8);
if(!empty($_GET['dox']))
{
$str="";
if($mattack=="0")
{
$mh1=$mh1-$mobx_s;
$str="&nbsp;&nbsp;&nbsp;<img src=img/bb.png> $namex ударил вас -$mobx_s HP<br>";
}
else
{
$mh1=$mh1-$mobx_m;
$str="&nbsp;&nbsp;&nbsp;<img src=img/bb.png> $namex ударил вас магией -$mobx_m HP<br>";
}
if($ztype=="true")
{
$mh1=$mh1+$mz;
}
$query = "INSERT INTO battlelog (login,text) VALUES ('$_COOKIE[login]','$str')";
$result = mysql_query ($query)
or die ("<span style='color:red'>ошибка лога!</span>");
$query="UPDATE battle SET nowh='$mh1' WHERE login='".$_COOKIE[login]."'";
$result=mysql_query($query)
or die("<span style='color:red'>ошибка обновления battle.log!</span><br>");
}
if($nowhtest=="")
{
}
else
{
if($mh1<"0")
{
echo "<html>
<head>
<meta http-equiv='Refresh' content='0;URL=index.php?do=game/lost'>
</head>
</html>";
}
else if($mhx<"0")
{
echo "<html>
<head>
<meta http-equiv='Refresh' content='0;URL=index.php?do=game/win'>
</head>
</html>";
}
else if($mhx=="0")
{
echo "<html>
<head>
<meta http-equiv='Refresh' content='0;URL=index.php?do=game/win'>
</head>
</html>";
}
}
if($nowhtest=="")
{
$query = "INSERT INTO battle (login,nowh,name,s,m,h) VALUES ('$_COOKIE[login]','$mh','$_GET[name]','$mob_s','$mob_m','$mob_h')";
$result = mysql_query ($query)
or die ("<span style='color:red'>ошибка сражения!</span>");
echo "
битва, $_GET[name]!<br>
жизни:$mob_h<br>
<img src='img/bb.png'> <a href='?do=game/battle&name=$_GET[name]&dox=attack'>ударить</a>|<img src='img/bb.png'> <a href='?do=game/battle&name=$_GET[name]&dox=magic'>магия</a><br>
<img src='img/bz.png'> <a href='?do=game/battle&name=$_GET[name]&dox=shield'>защита</a><br>
ваши жизни:$mh<br>
";
}
else
{
$mh1="";
$mobx_h="";
$xname="";
$mobx_s="";
$mobx_m="";
$query = "SELECT * FROM battle WHERE login='$_COOKIE[login]'";
$cat = mysql_query ($query);
if(!$cat) exit (mysql_error());
while(list($login,$nowh,$name,$s,$m,$h) = mysql_fetch_row($cat))
{
$mh1=$nowh;
$mobx_h=$h;
$xname=$name;
$mobx_s=$s;
$mobx_m=$m;
}
echo "
битва, $xname!<br>
жизни:$mobx_h<br>
<img src='img/bb.png'> <a href='?do=game/battle&name=$_GET[name]&dox=attack'>ударить</a>|<img src='img/bb.png'> <a href='?do=game/battle&name=$_GET[name]&dox=magic'>магия</a><br>
<img src='img/bz.png'> <a href='?do=game/battle&name=$_GET[name]&dox=shield'>защита</a><br>
ваши жизни:$mh1<br>
";
}
$query = "SELECT * FROM battlelog WHERE login='$_COOKIE[login]' ORDER BY id DESC LIMIT $_pg,$_pg2";
$cat = mysql_query ($query);
if(!$cat) exit (mysql_error());
while(list($id,$login,$text) = mysql_fetch_row($cat))
{
echo "$text";
}
echo "<br><a href='?do=game/battle&_pg=$ag&name=$_GET[name]'><<<назад</a>|<a href='?do=game/battle&_pg=$_pg2&name=$_GET[name]'>далее>>></a><br>";
}
include "data/buttons.auth.php";
}
else
{
echo "
Ошибка авторизации!<br>
";
}
}
}
else
{
function mod_body($auth,$adminauth)
{
echo "мод выключен администратором!<br>";
}
}
?>