Файл: battle_ships.php
Строк: 532
<?
define('PROTECTOR', 1);
include('files/db.php');
include($path.'files/auth.php');
if ($user_id==0){
header('location: index.php');exit;
}
$textl='Битва';
include($path.'files/core.php');
$lv=time();
$last=date('d.m.Y - H:i:s');
mysql_query("UPDATE `users` SET
`lv`='".$lv."',
`last`='".$last."',
`mesto`='".$textl."'
WHERE `id`='".$udata['id']."'");
$npdz=mysql_num_rows(mysql_query("SELECT * FROM `battle_ships` WHERE `usr`='".$udata['id']."'"));
if($npdz==0)
{
header('location: port.php');exit;
}
$bt=mysql_fetch_array(mysql_query("SELECT * FROM `battle_ships` WHERE `usr`='".$udata['id']."'"));
$kr=mysql_fetch_array(mysql_query("SELECT * FROM `users_ships` WHERE `usr`='".$udata['id']."'"));
if(isset($_GET['arm']))
{
if($bt['arm']<$kr['arm'] and $bt['kom']>1)
{
$arm=$bt['arm']+500;
$kom=$bt['kom']-1;
if($arm>$kr['arm']){$arm=$kr['arm'];}
mysql_query("UPDATE `battle_ships` SET `arm`='".$arm."', `kom`='".$kom."' WHERE `id`='".$bt['id']."'");
}
header('location: ?');exit;
}
if(isset($_GET['oryd']))
{
if($bt['oryd']<$kr['oryd'] and $bt['kom']>1)
{
$oryd=$bt['oryd']+1;
$kom=$bt['kom']-1;
mysql_query("UPDATE `battle_ships` SET `oryd`='".$oryd."', `kom`='".$kom."' WHERE `id`='".$bt['id']."'");
}
header('location: ?');exit;
}
if(isset($_GET['parys']))
{
if($bt['parys']<$kr['parys'] and $bt['kom']>1)
{
$parys=$bt['parys']+1;
$kom=$bt['kom']-1;
mysql_query("UPDATE `battle_ships` SET `parys`='".$parys."', `kom`='".$kom."' WHERE `id`='".$bt['id']."'");
}
header('location: ?');exit;
}
if(isset($_GET['pl']))
{
if($bt['battle']==0 and $bt['yzel']<$bt['yzel_max'] and $bt['parys']>0)
{
$yzel=$bt['yzel']+1;
mysql_query("UPDATE `battle_ships` SET `yzel`='".$yzel."', `battle`='1' WHERE `id`='".$bt['id']."'");
mysql_query("DELETE FROM `users_ships_item` WHERE `usr`='".$udata['id']."' and `mesto`='0'");
if($udata['more_story']<=23)
{
$hp_m=150;
$hp_mx=320;
$sila_m=20;
$sila_mx=50;
$hp_b_m=1250;
$hp_b_mx=1500;
$sila_b_m=80;
$sila_b_mx=150;
}
if($udata['more_story']>=24 and $udata['more_story']<=46)
{
$hp_m=400;
$hp_mx=600;
$sila_m=60;
$sila_mx=80;
$hp_b_m=2000;
$hp_b_mx=3500;
$sila_b_m=160;
$sila_b_mx=200;
}
if($udata['more_story']>=47 and $udata['more_story']<=69)
{
$hp_m=700;
$hp_mx=1000;
$sila_m=90;
$sila_mx=120;
$hp_b_m=4000;
$hp_b_mx=5500;
$sila_b_m=210;
$sila_b_mx=300;
}
if($udata['more_story']>=70 and $udata['more_story']<=92)
{
$hp_m=1050;
$hp_mx=1500;
$sila_m=130;
$sila_mx=150;
$hp_b_m=5600;
$hp_b_mx=7000;
$sila_b_m=310;
$sila_b_mx=400;
}
if($bt['yzel_max']==10)
{
if($yzel!=$bt['yzel_max'])
{
$name='Морской Житель';
$img='53';
$hp1=rand($hp_m,$hp_mx);$sila1=rand($sila_m,$sila_mx);$tim1=time()+rand(3,7);
$hp2=rand($hp_m,$hp_mx);$sila2=rand($sila_m,$sila_mx);$tim2=time()+rand(3,7);
$hp3=rand($hp_m,$hp_mx);$sila3=rand($sila_m,$sila_mx);$tim3=time()+rand(3,7);
mysql_query("INSERT INTO `battle_ships_mob` SET
`id`='',
`usr`='".$udata['id']."',
`name`='".$name."',
`hp`='".$hp1."',
`sila`='".$sila1."',
`time`='".$tim1."',
`img`='".$img."'
");
mysql_query("INSERT INTO `battle_ships_mob` SET
`id`='',
`usr`='".$udata['id']."',
`name`='".$name."',
`hp`='".$hp2."',
`sila`='".$sila2."',
`time`='".$tim2."',
`img`='".$img."'
");
mysql_query("INSERT INTO `battle_ships_mob` SET
`id`='',
`usr`='".$udata['id']."',
`name`='".$name."',
`hp`='".$hp3."',
`sila`='".$sila3."',
`time`='".$tim3."',
`img`='".$img."'
");
}
else
{
$name='Пиратский Капитан';
$img='62';
$hp1=rand($hp_b_m,$hp_b_mx);$sila1=rand($sila_b_m,$sila_b_mx);$tim1=time()+rand(3,7);
mysql_query("INSERT INTO `battle_ships_mob` SET
`id`='',
`usr`='".$udata['id']."',
`name`='".$name."',
`hp`='".$hp1."',
`sila`='".$sila1."',
`time`='".$tim1."',
`img`='".$img."'
");
}
}
elseif($bt['yzel_max']==20)
{
if($yzel==20 or $yzel==13 or $yzel==6)
{
$name='Пиратский Капитан';
$img='62';
$hp1=rand($hp_b_m,$hp_b_mx);$sila1=rand($sila_b_m,$sila_b_mx);$tim1=time()+rand(3,7);
mysql_query("INSERT INTO `battle_ships_mob` SET
`id`='',
`usr`='".$udata['id']."',
`name`='".$name."',
`hp`='".$hp1."',
`sila`='".$sila1."',
`time`='".$tim1."',
`img`='".$img."'
");
}
else
{
$name='Морской Житель';
$img='53';
$hp1=rand($hp_m,$hp_mx);$sila1=rand($sila_m,$sila_mx);$tim1=time()+rand(3,7);
$hp2=rand($hp_m,$hp_mx);$sila2=rand($sila_m,$sila_mx);$tim2=time()+rand(3,7);
$hp3=rand($hp_m,$hp_mx);$sila3=rand($sila_m,$sila_mx);$tim3=time()+rand(3,7);
mysql_query("INSERT INTO `battle_ships_mob` SET
`id`='',
`usr`='".$udata['id']."',
`name`='".$name."',
`hp`='".$hp1."',
`sila`='".$sila1."',
`time`='".$tim1."',
`img`='".$img."'
");
mysql_query("INSERT INTO `battle_ships_mob` SET
`id`='',
`usr`='".$udata['id']."',
`name`='".$name."',
`hp`='".$hp2."',
`sila`='".$sila2."',
`time`='".$tim2."',
`img`='".$img."'
");
mysql_query("INSERT INTO `battle_ships_mob` SET
`id`='',
`usr`='".$udata['id']."',
`name`='".$name."',
`hp`='".$hp3."',
`sila`='".$sila3."',
`time`='".$tim3."',
`img`='".$img."'
");
}
}
elseif($bt['yzel_max']==50)
{
if($yzel==20 or $yzel==10 or $yzel==30 or $yzel==40 or $yzel==50)
{
$name='Пиратский Капитан';
$img='62';
$hp1=rand($hp_b_m,$hp_b_mx);$sila1=rand($sila_b_m,$sila_b_mx);$tim1=time()+rand(3,7);
mysql_query("INSERT INTO `battle_ships_mob` SET
`id`='',
`usr`='".$udata['id']."',
`name`='".$name."',
`hp`='".$hp1."',
`sila`='".$sila1."',
`time`='".$tim1."',
`img`='".$img."'
");
}
else
{
$name='Морской Житель';
$img='53';
$hp1=rand($hp_m,$hp_mx);$sila1=rand($sila_m,$sila_mx);$tim1=time()+rand(3,7);
$hp2=rand($hp_m,$hp_mx);$sila2=rand($sila_m,$sila_mx);$tim2=time()+rand(3,7);
$hp3=rand($hp_m,$hp_mx);$sila3=rand($sila_m,$sila_mx);$tim3=time()+rand(3,7);
mysql_query("INSERT INTO `battle_ships_mob` SET
`id`='',
`usr`='".$udata['id']."',
`name`='".$name."',
`hp`='".$hp1."',
`sila`='".$sila1."',
`time`='".$tim1."',
`img`='".$img."'
");
mysql_query("INSERT INTO `battle_ships_mob` SET
`id`='',
`usr`='".$udata['id']."',
`name`='".$name."',
`hp`='".$hp2."',
`sila`='".$sila2."',
`time`='".$tim2."',
`img`='".$img."'
");
mysql_query("INSERT INTO `battle_ships_mob` SET
`id`='',
`usr`='".$udata['id']."',
`name`='".$name."',
`hp`='".$hp3."',
`sila`='".$sila3."',
`time`='".$tim3."',
`img`='".$img."'
");
}
}
}
header('location: ?');exit;
}
$grn=mysql_num_rows(mysql_query("SELECT * FROM `battle_ships_mob` WHERE `usr`='".$udata['id']."'"));
if($grn==0 and $bt['battle']!=0)
{
mysql_query("UPDATE `battle_ships` SET `battle`='0' WHERE `usr`='".$udata['id']."'");
$klad=rand(1,100);
if($klad<=$bt['klad'])
{
$item=rand(1,4);
if($item==1){$imgk=17;$namek='Золотой Слиток';$kolk=rand(1,2);}
elseif($item==2){$imgk=16;$namek='Ром';$kolk=rand(1,2);}
elseif($item==3){$imgk=14;$namek='Порох';$kolk=rand(1,2);}
elseif($item==4){$imgk=15;$namek='Шоколад';$kolk=rand(1,2);}
mysql_query("INSERT INTO `users_ships_item` SET
`id`='',
`usr`='".$udata['id']."',
`name`='<font color=#ff0000>".$namek."</font>',
`kol`='".$kolk."',
`img`='".$imgk."',
`mesto`='0'
");
}
$it1=rand(1,12);
$kol1=rand(1,3);
if($it1==1){$img=1;$name='Кофе';}
elseif($it1==2){$img=2;$name='Доски';}
elseif($it1==3){$img=3;$name='Фрукты';}
elseif($it1==4){$img=4;$name='Сталь';}
elseif($it1==5){$img=5;$name='Припасы';}
elseif($it1==6){$img=6;$name='Бревна';}
elseif($it1==7){$img=7;$name='Красное дерево';}
elseif($it1==8){$img=8;$name='Специи';}
elseif($it1==9){$img=9;$name='Шелк';}
elseif($it1==10){$img=10;$name='Ткань';}
elseif($it1==11){$img=11;$name='Сахар';}
elseif($it1==12){$img=12;$name='Уголь';}
mysql_query("INSERT INTO `users_ships_item` SET
`id`='',
`usr`='".$udata['id']."',
`name`='".$name."',
`kol`='".$kol1."',
`img`='".$img."',
`mesto`='0'
");
header('location: ?');exit;
}
if(isset($_GET['ataka']))
{
if($bt['battle']==1 and $bt['time']<time())
{
$sila=$bt['sila'];
$gr=mysql_query("SELECT * FROM `battle_ships_mob` WHERE `usr`='".$udata['id']."'");
$num=mysql_num_rows($gr);
if($num>0)
{
$mob=mysql_fetch_array($gr);
$hp=$mob['hp']-$sila;
mysql_query("INSERT INTO `log_ships` SET
`id`='',
`usr`='".$udata['id']."',
`text`='<img src=img/ships/ataka/a1.png width=18px> <font color=#00cc00>Вы атаковали из пушки <font color=#ff9900>".$mob['name']."</font>. Урон - </font><font color=#ff000>".$sila."</font>'
");
if($hp<=0)
{
mysql_query("INSERT INTO `log_ships` SET
`id`='',
`usr`='".$udata['id']."',
`text`='<img src=img/ships/ataka/a1.png width=18px> <font color=#ffff00><font color=#ff9900>".$mob['name']."</font> побежден.</font>'
");
mysql_query("DELETE FROM `battle_ships_mob` WHERE `id`='".$mob['id']."'");
}
else
{
mysql_query("UPDATE `battle_ships_mob` SET `hp`='".$hp."' WHERE `id`='".$mob['id']."'");
}
$tim=time()+10;
$ti1=mysql_query("SELECT * FROM `titul` WHERE `usr`='".$udata['id']."' and `status`='1' and `img`='303'");$t1=mysql_num_rows($ti1);
$ti2=mysql_query("SELECT * FROM `titul` WHERE `usr`='".$udata['id']."' and `status`='1' and `img`='302'");$t2=mysql_num_rows($ti2);
$ti3=mysql_query("SELECT * FROM `titul` WHERE `usr`='".$udata['id']."' and `status`='1' and `img`='301'");$t3=mysql_num_rows($ti3);
$ti4=mysql_query("SELECT * FROM `titul` WHERE `usr`='".$udata['id']."' and `status`='1' and `img`='300'");$t4=mysql_num_rows($ti4);
if($t1!=0){$tim=$tim-2;}
if($t2!=0){$tim=$tim-3;}
if($t3!=0){$tim=$tim-4;}
if($t4!=0){$tim=$tim-5;}
mysql_query("UPDATE `battle_ships` SET `time`='".$tim."' WHERE `usr`='".$udata['id']."'");
}
}
header('location: ?');exit;
}
if(isset($_GET['ataka2']))
{
if($bt['battle']==1 and $bt['time_m']<time())
{
$sila=$bt['sila']+$bt['oryd']*100;
$gr=mysql_query("SELECT * FROM `battle_ships_mob` WHERE `usr`='".$udata['id']."'");
$num=mysql_num_rows($gr);
if($num>0)
{
$mob=mysql_fetch_array($gr);
$hp=$mob['hp']-$sila;
mysql_query("INSERT INTO `log_ships` SET
`id`='',
`usr`='".$udata['id']."',
`text`='<img src=img/ships/ataka/a2.png width=18px> <font color=#00cc00>Вы атаковали из мортиры <font color=#ff9900>".$mob['name']."</font>. Урон - </font><font color=#ff000>".$sila."</font>'
");
if($hp<=0)
{
mysql_query("INSERT INTO `log_ships` SET
`id`='',
`usr`='".$udata['id']."',
`text`='<img src=img/ships/ataka/a2.png width=18px> <font color=#ffff00><font color=#ff9900>".$mob['name']."</font> побежден.</font>'
");
mysql_query("DELETE FROM `battle_ships_mob` WHERE `id`='".$mob['id']."'");
}
else
{
mysql_query("UPDATE `battle_ships_mob` SET `hp`='".$hp."' WHERE `id`='".$mob['id']."'");
}
$tim=time()+45;
$ti1=mysql_query("SELECT * FROM `titul` WHERE `usr`='".$udata['id']."' and `status`='1' and `img`='303'");$t1=mysql_num_rows($ti1);
$ti2=mysql_query("SELECT * FROM `titul` WHERE `usr`='".$udata['id']."' and `status`='1' and `img`='302'");$t2=mysql_num_rows($ti2);
$ti3=mysql_query("SELECT * FROM `titul` WHERE `usr`='".$udata['id']."' and `status`='1' and `img`='301'");$t3=mysql_num_rows($ti3);
$ti4=mysql_query("SELECT * FROM `titul` WHERE `usr`='".$udata['id']."' and `status`='1' and `img`='300'");$t4=mysql_num_rows($ti4);
if($t1!=0){$tim=$tim-2;}
if($t2!=0){$tim=$tim-3;}
if($t3!=0){$tim=$tim-4;}
if($t4!=0){$tim=$tim-5;}
mysql_query("UPDATE `battle_ships` SET `time_m`='".$tim."' WHERE `usr`='".$udata['id']."'");
}
}
header('location: ?');exit;
}
if(isset($_GET['ataka3']))
{
if($bt['battle']==1 and $bt['time_k']<time())
{
$sila=$bt['oryd']*100;
$gr=mysql_query("SELECT * FROM `battle_ships_mob` WHERE `usr`='".$udata['id']."'");
$num=mysql_num_rows($gr);
if($num>0)
{
$sila=floor($sila/$num);
while($mob=mysql_fetch_array($gr))
{
$hp=$mob['hp']-$sila;
mysql_query("INSERT INTO `log_ships` SET
`id`='',
`usr`='".$udata['id']."',
`text`='<img src=img/ships/ataka/a2.png width=18px> <font color=#00cc00>Вы атаковали из кулеврины <font color=#ff9900>".$mob['name']."</font>. Урон - </font><font color=#ff000>".$sila."</font>'
");
if($hp<=0)
{
mysql_query("INSERT INTO `log_ships` SET
`id`='',
`usr`='".$udata['id']."',
`text`='<img src=img/ships/ataka/a2.png width=18px> <font color=#ffff00><font color=#ff9900>".$mob['name']."</font> побежден.</font>'
");
mysql_query("DELETE FROM `battle_ships_mob` WHERE `id`='".$mob['id']."'");
}
else
{
mysql_query("UPDATE `battle_ships_mob` SET `hp`='".$hp."' WHERE `id`='".$mob['id']."'");
}
}
$tim=time()+25;
$ti1=mysql_query("SELECT * FROM `titul` WHERE `usr`='".$udata['id']."' and `status`='1' and `img`='303'");$t1=mysql_num_rows($ti1);
$ti2=mysql_query("SELECT * FROM `titul` WHERE `usr`='".$udata['id']."' and `status`='1' and `img`='302'");$t2=mysql_num_rows($ti2);
$ti3=mysql_query("SELECT * FROM `titul` WHERE `usr`='".$udata['id']."' and `status`='1' and `img`='301'");$t3=mysql_num_rows($ti3);
$ti4=mysql_query("SELECT * FROM `titul` WHERE `usr`='".$udata['id']."' and `status`='1' and `img`='300'");$t4=mysql_num_rows($ti4);
if($t1!=0){$tim=$tim-2;}
if($t2!=0){$tim=$tim-3;}
if($t3!=0){$tim=$tim-4;}
if($t4!=0){$tim=$tim-5;}
mysql_query("UPDATE `battle_ships` SET `time_k`='".$tim."' WHERE `usr`='".$udata['id']."'");
}
}
header('location: ?');exit;
}
if(isset($_GET['vz']))
{
$id=mysql_real_escape_string($_GET['vz']);
$item=mysql_query("SELECT * FROM `users_ships_item` WHERE `usr`='".$udata['id']."' and `mesto`='0' and `id`='".$id."'");
$item_tr=mysql_result(mysql_query("SELECT SUM(kol) FROM `users_ships_item` WHERE `usr`='".$udata['id']."' and `mesto`='1'"),0);
if($item_tr==''){$item_tr=0;}
$nit=mysql_num_rows($item);
if($nit!=0)
{
$it=mysql_fetch_array($item);
$ti1=mysql_query("SELECT * FROM `titul` WHERE `usr`='".$udata['id']."' and `status`='1' and `img`='303'");$t1=mysql_num_rows($ti1);
$ti2=mysql_query("SELECT * FROM `titul` WHERE `usr`='".$udata['id']."' and `status`='1' and `img`='302'");$t2=mysql_num_rows($ti2);
$ti3=mysql_query("SELECT * FROM `titul` WHERE `usr`='".$udata['id']."' and `status`='1' and `img`='301'");$t3=mysql_num_rows($ti3);
$ti4=mysql_query("SELECT * FROM `titul` WHERE `usr`='".$udata['id']."' and `status`='1' and `img`='300'");$t4=mysql_num_rows($ti4);
if($t1!=0){$kr['trym']=$kr['trym']+5;}
if($t2!=0){$kr['trym']=$kr['trym']+7;}
if($t3!=0){$kr['trym']=$kr['trym']+10;}
if($t4!=0){$kr['trym']=$kr['trym']+15;}
if($kr['trym']>$item_tr)
{
$itn=mysql_num_rows(mysql_query("SELECT * FROM `users_ships_item` WHERE `usr`='".$udata['id']."' and `mesto`='1' and `name`='".$it['name']."'"));
mysql_query("INSERT INTO `log_ships` SET
`id`='',
`usr`='".$udata['id']."',
`text`='<img src=img/ships/item/".htmlspecialchars($it['img']).".png width=18px> <font color=#00ff99>".$it['name']." помещен в трюм</font>'
");
if($itn==0)
{
$kt=$item_tr+$it['kol'];
if($kt<$kr['trym'])
{
mysql_query("UPDATE `users_ships_item` SET `mesto`='1' WHERE `id`='".$it['id']."'");
}
else
{
$kol=$kr['trym']-$item_tr;
mysql_query("UPDATE `users_ships_item` SET `mesto`='1', `kol`='".$kol."' WHERE `id`='".$it['id']."'");
}
}
else
{
$itz=mysql_fetch_array(mysql_query("SELECT * FROM `users_ships_item` WHERE `usr`='".$udata['id']."' and `mesto`='1' and `name`='".$it['name']."'"));
$kol=$itz['kol']+$it['kol'];
if($kol>$kr['trym']){$kol=$kr['trym'];}
mysql_query("UPDATE `users_ships_item` SET `kol`='".$kol."' WHERE `id`='".$itz['id']."'");
mysql_query("DELETE FROM `users_ships_item` WHERE `id`='".$it['id']."'");
}
}
}
header('location: ?');exit;
}
if($bt['battle']==1)
{
$mobas=mysql_query("SELECT * FROM `battle_ships_mob` WHERE `usr`='".$udata['id']."' and `time`<'".time()."'");
while($mb=mysql_fetch_array($mobas))
{
$ydar=$mb['sila'];
$arm=$bt['arm']-$ydar;
mysql_query("INSERT INTO `log_ships` SET
`id`='',
`usr`='".$udata['id']."',
`text`='<img src=img/ships/ataka/a1.png width=18px> <font color=#ff0000><font color=#ff9900>".$mb['name']."</font> повредил корабль - </font><font color=#ff000>".$ydar."</font>'
");
if($arm<=0)
{
mysql_query("INSERT INTO `log_ships` SET
`id`='',
`usr`='".$udata['id']."',
`text`='<img src=img/ships/ataka/a1.png width=18px> <font color=#ff0000><font color=#ff9900>".$mb['name']."</font> уничтожил ваш корабль.</font>'
");
mysql_query("UPDATE `battle_ships` SET `arm`='0', `battle`='2' WHERE `id`='".$bt['id']."'");
}
else
{
mysql_query("UPDATE `battle_ships` SET `arm`='".$arm."' WHERE `id`='".$bt['id']."'");
$do=rand(1,100);
if($do<=$bt['oryd_pr'] and $bt['oryd']>0)
{
$opr=$bt['oryd']-1;
mysql_query("UPDATE `battle_ships` SET `oryd`='".$opr."' WHERE `id`='".$bt['id']."'");
mysql_query("INSERT INTO `log_ships` SET
`id`='',
`usr`='".$udata['id']."',
`text`='<img src=img/ships/ataka/a1.png width=18px> <font color=#ff0000><font color=#ff9900>".$mb['name']."</font> сломал орудие.</font>'
");
}
$dp=rand(1,100);
if($dp<=$bt['parys_pr'] and $bt['parys']>0)
{
$prr=$bt['parys']-1;
mysql_query("UPDATE `battle_ships` SET `parys`='".$prr."' WHERE `id`='".$bt['id']."'");
mysql_query("INSERT INTO `log_ships` SET
`id`='',
`usr`='".$udata['id']."',
`text`='<img src=img/ships/ataka/a1.png width=18px> <font color=#ff0000><font color=#ff9900>".$mb['name']."</font> порвал парус.</font>'
");
}
$tim=time()+rand(10,14);
mysql_query("UPDATE `battle_ships_mob` SET `time`='".$tim."' WHERE `id`='".$mb['id']."'");
}
header('location: ?');exit;
}
}
if(isset($_GET['finish']))
{
if($bt['yzel']==$bt['yzel_max'])
{
$activ=mysql_query("SELECT * FROM `users_activ` WHERE `usr`='".$udata['id']."'");
$act=mysql_fetch_array($activ);
if($act['act_8']<1)
{
$kol=$act['act_8']+1;
mysql_query("UPDATE `users_activ` SET `act_8`='".$kol."' WHERE `usr`='".$udata['id']."'");
}
if($udata['more_story']==0){$udata['more_story']=1;}
$s=$udata['more_story']+1;
if($s==24 or $s==47 or $s==70 or $s==93){$time=time()+12*60*60;}else{$time=0;}
if($s==93){$s=1;}else{$s=$s;}
mysql_query("UPDATE `users` SET `more_story`='".$s."', `more_err`='".$time."' WHERE `id`='".$udata['id']."'");
mysql_query("DELETE FROM `battle_ships` WHERE `usr`='".$udata['id']."'");
mysql_query("DELETE FROM `log_ships` WHERE `usr`='".$udata['id']."'");
mysql_query("DELETE FROM `users_ships_item` WHERE `mesto`='0' and `usr`='".$udata['id']."'");
mysql_query("DELETE FROM `battle_ships_mob` WHERE `usr`='".$udata['id']."'");
}
header('location: port.php');exit;
}
if(isset($_GET['leave']))
{
$time=time()+900;
mysql_query("UPDATE `users` SET `more_err`='".$time."' WHERE `id`='".$udata['id']."'");
mysql_query("DELETE FROM `battle_ships` WHERE `usr`='".$udata['id']."'");
mysql_query("DELETE FROM `log_ships` WHERE `usr`='".$udata['id']."'");
mysql_query("DELETE FROM `users_ships_item` WHERE `mesto`='0' and `usr`='".$udata['id']."'");
mysql_query("DELETE FROM `battle_ships_mob` WHERE `usr`='".$udata['id']."'");
header('location: port.php');exit;
}
include($path.'files/head.php');
$pr=$bt['yzel_max']/100;
$pr=floor($bt['yzel']/$pr);
echo '
<div class="head brs bls v8 bts bbs p"><font color=#00ccff><img src=img/main/b49.png> Статус: '.$pr.'%</font>';
$q = mysql_query("SELECT COUNT(*) FROM `msg_kont` WHERE `usr1` = '".$udata['id']."' AND `read` = '1';");
$new_mail = mysql_result($q, 0);
if($new_mail > 0)
{
echo"
<a href="mail.php"><img src=img/main/e1.png></a>";
}
if($udata['clan']!=0)
{
$fridaa=mysql_query("SELECT * FROM `sectors` WHERE `clan`='".$udata['clan']."' and `att_clan`!='0'");
$fra=mysql_num_rows($fridaa);
if($fra!=0)
{
echo'<a href=clan.php?gi=ter><img src=img/main/st.png></a>';
}
}
echo'</font> </div>';
$giza=mysql_fetch_array(mysql_query("SELECT * FROM `clan` WHERE `id`='".$udata['clan']."'"));
if($giza['gorn_time']>time() and $udata['gorn']==1)
{
echo '<div class="v6 rr rt rl p">'.$giza['gorn'].'<br>
<img src=img/main/e55.png><a href=clan.php?gorn_def>Закрыть</a>
</div>';
}
echo '<div class="line m bbs bts brs bls b p v12">Бой</div><div class="bat bts brs bls bbs p t2">';
if($bt['battle']==0)
{
echo '<table width=100%>
<tr>
<td width=35%>
<img src=img/ships/'.htmlspecialchars($kr['img']).'.png width=100%>
</td>
<td>
<img src=img/main/e30.png> Прочность: <font color=#00ff99>'.$bt['arm'].'/'.$kr['arm'].'</font>'; if($bt['arm']<$kr['arm'] and $bt['kom']>1){echo ' <a href=?arm><font color=#ff0000>+</font></a>';} echo'<br>
<img src=img/main/e30.png> Команда: <font color=#00ff99>'.$bt['kom'].'/'.$kr['kom'].'</font><br>
<img src=img/main/e30.png> Пушки: <font color=#00ff99>'.$bt['oryd'].'/'.$kr['oryd'].'</font>'; if($bt['oryd']<$kr['oryd'] and $bt['kom']>1){echo ' <a href=?oryd><font color=#ff0000>+</font></a>';} echo'<br>
<img src=img/main/e30.png> Паруса: <font color=#00ff99>'.$bt['parys'].'/'.$kr['parys'].'</font>'; if($bt['parys']<$kr['parys'] and $bt['kom']>1){echo ' <a href=?parys><font color=#ff0000>+</font></a>';} echo'<br>
</td>
</tr>
</table>';
$item=mysql_query("SELECT * FROM `users_ships_item` WHERE `usr`='".$udata['id']."' and `mesto`='0'");
$item_tr=mysql_result(mysql_query("SELECT SUM(kol) FROM `users_ships_item` WHERE `usr`='".$udata['id']."' and `mesto`='1'"),0);
if($item_tr==''){$item_tr=0;}
$nit=mysql_num_rows($item);
if($nit!=0)
{
echo '<div class="head p">
<center><i><font color=#ff9900>После боя вы замечаете несколько хороших вещей</font></i></center>
<img src=img/main/e28.png> Трюм: <font color=#00ff99>'.$item_tr.'/'.$kr['trym'].'</font>
';
while($it=mysql_fetch_array($item))
{
echo '<table>
<tr>
<td><img src=img/ships/item/'.htmlspecialchars($it['img']).'.png></td>
<td>
<img src=img/main/e30.png> '.$it['name'].'<br>
<img src=img/main/e30.png> Кол-во: <font color=#ffffff>'.$it['kol'].'</font><br>
<img src=img/main/e28.png> <a href=?vz='.$it['id'].'>Взять</a>
</td>
</tr>
</table>';
}
echo'</div>';
}
if($bt['yzel']<$bt['yzel_max'])
{
echo '<a href=?pl><div style="position: relative;
font-weight: bold;
color: #ffff00;
text-decoration: none;
text-shadow: 0 -1px 1px #cc5500;
user-select: none;
padding: 3px 0 3px 3px;
outline: none;
border-radius: 1px;
background: #348533;
background-size: 100% 100%, auto;
background-position: 50% 50%;
box-shadow: inset #34f533 0 -1px 1px, inset 0 1px 1px #34f533, #34f533 0 0 0 1px, #000 0 10px 15px -10px;
margin-left: 5px;
margin-right: 5px;
margin-top: 4px;"><center>Плыть дальше</center></div></a>';
}
else
{
echo '<a href=?finish><div style="position: relative;
font-weight: bold;
color: #00ffff;
text-decoration: none;
text-shadow: 0 -1px 1px #cc5500;
user-select: none;
padding: 3px 0 3px 3px;
outline: none;
border-radius: 1px;
background: #348533;
background-size: 100% 100%, auto;
background-position: 50% 50%;
box-shadow: inset #34f533 0 -1px 1px, inset 0 1px 1px #34f533, #34f533 0 0 0 1px, #000 0 10px 15px -10px;
margin-left: 5px;
margin-right: 5px;
margin-top: 4px;"><center>Причалить</center></div></a>';
}
echo '<a href=?leave><div style="position: relative;
font-weight: bold;
color: #ff9900;
text-decoration: none;
text-shadow: 0 -1px 1px #cc5500;
user-select: none;
padding: 3px 0 3px 3px;
outline: none;
border-radius: 1px;
background: #742324;
background-size: 100% 100%, auto;
background-position: 50% 50%;
box-shadow: inset #c62324 0 -1px 1px, inset 0 1px 1px #c62324, #c62324 0 0 0 1px, #000 0 10px 15px -10px;
margin-left: 5px;
margin-right: 5px;
margin-top: 4px;"><center>Отступление</center></div></a>';
}
elseif($bt['battle']==1)
{
echo '<table width=100%>
<tr>
<td width=35%>
<img src=img/ships/'.htmlspecialchars($kr['img']).'.png width=100%>
</td>
<td>
<img src=img/main/e30.png> Прочность: <font color=#00ff99>'.$bt['arm'].'/'.$kr['arm'].'</font>'; if($bt['arm']<$kr['arm'] and $bt['kom']>1){echo ' <a href=?arm><font color=#ff0000>+</font></a>';} echo'<br>
<img src=img/main/e30.png> Команда: <font color=#00ff99>'.$bt['kom'].'/'.$kr['kom'].'</font><br>
<img src=img/main/e30.png> Пушки: <font color=#00ff99>'.$bt['oryd'].'/'.$kr['oryd'].'</font>'; if($bt['oryd']<$kr['oryd'] and $bt['kom']>1){echo ' <a href=?oryd><font color=#ff0000>+</font></a>';} echo'<br>
<img src=img/main/e30.png> Паруса: <font color=#00ff99>'.$bt['parys'].'/'.$kr['parys'].'</font>'; if($bt['parys']<$kr['parys'] and $bt['kom']>1){echo ' <a href=?parys><font color=#ff0000>+</font></a>';} echo'<br>
</td>
</tr>
</table>';
echo '<a href=?leave><div style="position: relative;
font-weight: bold;
color: #ff9900;
text-decoration: none;
text-shadow: 0 -1px 1px #cc5500;
user-select: none;
padding: 3px 0 3px 3px;
outline: none;
border-radius: 1px;
background: #742324;
background-size: 100% 100%, auto;
background-position: 50% 50%;
box-shadow: inset #c62324 0 -1px 1px, inset 0 1px 1px #c62324, #c62324 0 0 0 1px, #000 0 10px 15px -10px;
margin-left: 5px;
margin-right: 5px;
margin-top: 4px;"><center>Отступление</center></div></a>';
echo '</div></div><div class=v8><div class="line m bbs bts brs bls b p v12">Атака</div><div class="bat bts brs bls bbs p t2">';
echo '<center><table>
<td>';
if($bt['time']>time())
{echo '<div style="opacity: 0.2;" class="p">';}
else
{
echo '<div class="p">';
}
echo '<a href=?ataka><img src=img/ships/ataka/a1.png alt="пушка"></a></div>';
echo '</td>
<td>';
if($bt['time_m']>time())
{echo '<div style="opacity: 0.2;" class="p">';}
else
{
echo '<div class="p">';
}
echo '<a href=?ataka2><img src=img/ships/ataka/a2.png alt="мортира"></a></div>';
echo '</td>
<td>';
if($bt['time_k']>time())
{echo '<div style="opacity: 0.2;" class="p">';}
else
{
echo '<div class="p">';
}
echo '<a href=?ataka3><img src=img/ships/ataka/a3.png alt="кулеврина"></a></div>';
echo '</td>
</table></center>';
echo '</div></div><div class=v8><div class="line m bbs bts brs bls b p v12">Ваши противники:</div><div class="bat bts brs bls bbs p t2">';
$gr=mysql_query("SELECT * FROM `battle_ships_mob` WHERE `usr`='".$udata['id']."'");
while($mn=mysql_fetch_array($gr))
{
echo '<font color=#ff9900>'.$mn['name'].'</font> <img src=img/main/p6.png>'.$mn['hp'].', ';
}
}
elseif($bt['battle']==2)
{
echo '<center><font color=#ff2222>Ваш корабль потоплен.</font></center>';
echo '<a href=?leave><div style="position: relative;
font-weight: bold;
color: #ff9900;
text-decoration: none;
text-shadow: 0 -1px 1px #cc5500;
user-select: none;
padding: 3px 0 3px 3px;
outline: none;
border-radius: 1px;
background: #742324;
background-size: 100% 100%, auto;
background-position: 50% 50%;
box-shadow: inset #c62324 0 -1px 1px, inset 0 1px 1px #c62324, #c62324 0 0 0 1px, #000 0 10px 15px -10px;
margin-left: 5px;
margin-right: 5px;
margin-top: 4px;"><center>Отступление</center></div></a>';
}
$mobs=mysql_query("SELECT * FROM `log_ships` WHERE `usr`='".$udata['id']."' ORDER BY `id` DESC LIMIT 10");
$rows=mysql_num_rows($mobs);
if($rows==0)
{
}
else
{
echo '</div><div class=v8><div class="line m bbs bts brs bls b p v12">Лог боя:</div><div class="bat bts brs bls bbs p t2">';
while($log=mysql_fetch_array($mobs))
{
echo $log['text'].'<br>';
}
}
echo '</div></div>';
include('files/dwn.php');
?>