Вход Регистрация
Файл: battlesea.php
Строк: 75
<?php
session_start
();
include (
'private/mysql.php');
include (
'tmp/head.php');

$ushq mysql_query("SELECT * FROM `ship` WHERE `user`='$id'");
$ushe mysql_num_rows($ushq);
if(
$ushe=='0'){
    
header('Location: sea.php?sd=sea');
}
$ush mysql_fetch_assoc($ushq);

$q mysql_query("SELECT * FROM `users` WHERE `sea`='1' and `id`!='$uid' LIMIT 20");
$e mysql_num_rows($q);
if(
$e<'4'){
    echo 
"Вражеских кораблей не обнаружено<br>Для битвы в море необходимо чтобы 4 и более игроков были готовы к бою.";
    echo 
"<br><hr>[<a href='?sd=outsea'>К гавани</a>] [<a href='sea.php?sd=sea'>Ожидать</a>]";
    include (
'tmp/foot.php');
    exit;
}

$us mysql_fetch_assoc(mysql_query("SELECT * FROM `users` WHERE `id`='$id'"));

if(
$us['sea']=='0'){
    
header('Location: sea.php?sd=sea');
    exit;
}

$sh mysql_fetch_assoc(mysql_query("SELECT * FROM `ship` WHERE `user`='$uid'"));
$sk mysql_fetch_assoc(mysql_query("SELECT * FROM `ship_k` WHERE `user`='$uid'"));

switch(
$sd){
default:

if(
$ush['hp']<='0'){
    
header("Location: battlesea.php?sd=win&id=$id");
    exit;
}

echo 
"<small><font size=3 color=red><a href='pers.php?id=$id'>$us[login]</a></font><br>
Урон: <font color=red>
$ush[uron]</font><br>
Устойчивость:<font color=red> 
$ush[def]</font><br>
Прочность: <font color=red>
$ush[hpall]</font></small><hr>";


$hps = ($ush['hp']/$ush['hpall'])*100;

echo 
'<span style="float:left">0</span><span style="float:right">'.$ush['hpall'].'</span><br><div style="background:#666666;height:6px;width:100%;padding:0;margin:4px 0;">
<div style="background:brown; height:4px; width:'
.$hps.'%;"></div></div><hr>';

echo 
"<ul class='list_page'><li><div class='linem'></div><a href='?sd=ataka&id=$id'>Атаковать</a></li></ul><div class='linem2'></div>";

break;


case 
'win':

if(
$ush['hp']>'0'){
    
header("Location: battlesea.php?id=$id");
    exit;
}

if(
$ush['level']>='1' and $ush['level']<'3'){$exp1=10;$silver1=8;}
if(
$ush['level']>='3' and $ush['level']<'5'){$exp1=24;$silver1=14;}
if(
$ush['level']>='5' and $ush['level']<'7'){$exp1=40;$silver1=24;}
if(
$ush['level']>='7' and $ush['level']<'9'){$exp1=60;$silver1=40;}
if(
$ush['level']>='9'){$exp1=100;$silver1=70;}

$exp2 round(($exp1/100)*$sk['exp']);
$silver2 round(($silver1/100)*$sk['silver']);

if(
$game['winopp']==$user['storona']){$oppexp=($exp2/100)*15;$oppsilver=($silver2/100)*15;}else{$oppsilver=0;$oppexp=0;}


$exp round($exp1+$exp2+$oppexp);
$silver round($silver1+$silver2+$oppsilver);

$q mysql_query("SELECT * FROM `baff` WHERE `user`='$uid' and `time`>'".time()."'");
$e mysql_num_rows($q);
if(
$e>='1'){
    
    
$w mysql_fetch_assoc($q);
    
    if(
$w['exp']>='1'){
        
$exp = ($exp/100)*$w['exp'];
    }
    if(
$w['silver']>='1'){
        
$silver = ($silver/100)*$w['silver'];
    }
    
}

mysql_query("UPDATE `users` SET `win`=`win`+'1',`exp`=`exp`+'$exp',`silver`=`silver`+'$silver',`sea_medal`=`sea_medal`+'1' WHERE `id`='$uid'");

mysql_query("UPDATE `users` SET `lose`=`lose`+'1' WHERE `id`='$id'");

mysql_query("UPDATE `ship` SET `hp`=`hpall` WHERE `user`='$uid'");

$_SESSION['sea']="<font color=lightgreen>Вы победили <b>$us[login]</b></font><br>Награда: $silver <img src='img/silver.png'>, $exp <img src='img/exp.png'>, +1 <img src='img/sea_medal.png'>";


header('Location: sea.php?sd=sea');
exit;

break;


case 
'ataka':

$sdef round(($sh['uron']/100)*$ush['def']);

if(
$game['winopp']==$user['storona']){$oppbonus=($sh['uron']/100)*25;}else{$oppbonus=0;}

$uron round(($sh['uron']+$oppbonus)-$sdef);

mysql_query("UPDATE `ship` SET `hp`=`hp`-'$uron' WHERE `user`='$id'");

if(
$ush['hp']<=$uron or $ush['hp']<='0'){
    
    
header("Location: battlesea.php?sd=win&id=$id");
    exit;
    
}


echo 
$uron;

header("Location: battlesea.php?id=$id");
exit;

break;


}
include (
'tmp/foot.php');
?>
Онлайн: 0
Реклама