<?php
define('PROTECTOR', 1);
include('files/path.php');
include($path.'files/db.php');
include($path.'files/auth.php');
include($path.'files/func.php');
$textl='Барыга';
//going();
//ryd();
include($path.'files/core.php');
include($path.'files/head.php');
include($path.'files/zag.php');

echo'<div class="main"><div class="block_zero center"><img src="image/logo/shop.png" alt="logo"><br><div class="block_zero center"><span style="color: #9bc;">Комплекты</span></div></div><div class="dot-line"></div>';

switch($_GET['mod']){

default:

if($mast>=250){
echo'<div class="block_zero"><img class="float-left" src="image/shop/6.png" width="30" height="30" style="margin-left:1px; margin-right:5px;" alt="*"><img src="image/kachestvo/5.png" alt="*"><a href="/weapon.php?mod=prosm&kom=11"><span style="color: #999;"> Божественный</span></a><br><img src="image/icon/skill.png" alt="*"><small> Бицуха: 250</small></div><div class="mini-line"></div>';
}
if($mast>=200){
echo'<div class="block_zero"><img class="float-left" src="image/shop/5.png" width="30" height="30" style="margin-left:1px; margin-right:5px;" alt="*"><img src="image/kachestvo/4.png" alt="*"><a href="/weapon.php?mod=prosm&kom=9"><span style="color: #f96;"> Легендарный</span></a><br><img src="image/icon/skill.png" alt="*"><small> Бицуха: 200</small></div><div class="mini-line"></div>';
}
if($mast>=48){
echo'<div class="block_zero"><img class="float-left" src="image/shop/4.png" width="30" height="30" style="margin-left:1px; margin-right:5px;" alt="*"><img src="image/kachestvo/3.png" alt="*"><a href="/weapon.php?mod=prosm&kom=7"><span style="color: #cc6be2;"> Авторитетный</span></a><br><img src="image/icon/skill.png" alt="*"><small> Бицуха: 48</small></div><div class="mini-line"></div>';
}
if($mast>=24){
echo'<div class="block_zero"><img class="float-left" src="image/shop/3.png" width="30" height="30" style="margin-left:1px; margin-right:5px;" alt="*"><img src="image/kachestvo/2.png" alt="*"><a href="/weapon.php?mod=prosm&kom=5"><span style="color: #4f91ff;"> Блатной</span></a><br><img src="image/icon/skill.png" alt="*"><small> Бицуха: 24</small></div><div class="mini-line"></div>';
}
if($mast>=6){
echo'<div class="block_zero"><img class="float-left" src="image/shop/2.png" width="30" height="30" style="margin-left:1px; margin-right:5px;" alt="*"><img src="image/kachestvo/1.png" alt="*"><a href="/weapon.php?mod=prosm&kom=3"><span style="color: #5cc25c;"> Обычный</span></a><br><img src="image/icon/skill.png" alt="*"><small> Бицуха: 6</small></div><div class="mini-line"></div>';
}
if($mast>=1){
echo'<div class="block_zero"><img class="float-left" src="image/shop/1.png" width="30" height="30" style="margin-left:1px; margin-right:5px;" alt="*"><img src="image/kachestvo/0.png" alt="*"><a href="/weapon.php?mod=prosm&kom=1"><span style="color: #837900;"> Старый</span></a><br><img src="image/icon/skill.png" alt="*"><small> Бицуха: 1</small></div><div class="dot-line"></div>';
}
echo'<div class="block_zero"><img src="image/icon/skill.png" alt="*"> Бицуха: '.$mast.'';
echo'</div><div class="mini-line"></div></div>';
echo'<div class="main"><ul class="hint"><li>Пицуху можно повысить, прокачивая параметры в <img src="image/icon/skill.png" alt="*"><a href="masterstvo.php?"> Качалке</a></li></ul>';
echo'</div></div>';
break;

case 'obychnye':
$req = mysql_query("SELECT * FROM `komplekt` WHERE `lvl` = '1'") OR die(mysql_error());
While($kompl=mysql_fetch_array($req)){
if($mast>=$kompl['lvl']){
echo'<div class="block_zero"><img class="float-left" src="image/shop/1.png" width="30" height="30" style="margin-left:1px; margin-right:5px;" alt="*"><a href="weapon.php?mod=prosm&kom='.$kompl['id'].'"> '.$kompl['name'].'</a><br><img src="image/kachestvo/0.png" alt="*"><small><span style="color: #837900;"> Обычные вещи</span></small></div><div class="dot-line"></div>';
}
}
echo'<div class="dot-line"></div><div class="main"><div class="block_zero"><a href="javascript:history.go(-1)"><span style="color: #999;"><< Назад</span></a></div></div>';
echo'</div>';
break;

case 'redkie':
$req = mysql_query("SELECT * FROM `komplekt` WHERE `lvl` = '6'") OR die(mysql_error());
While($kompl=mysql_fetch_array($req)){
if($mast>=$kompl['lvl']){
echo'<div class="block_zero"><img class="float-left" src="image/shop/2.png" width="30" height="30" style="margin-left:1px; margin-right:5px;" alt="*"><a href="weapon.php?mod=prosm&kom='.$kompl['id'].'"> '.$kompl['name'].'</a><br><img src="image/kachestvo/1.png" alt="*"><small><span style="color: #5cc25c;"> Редкие вещи</span></small></div><div class="dot-line"></div>';
}
}
echo'<div class="dot-line"></div><div class="main"><div class="block_zero"><a href="javascript:history.go(-1)"><span style="color: #999;"><< Назад</span></a></div></div>';
echo'</div>';
break;

case 'epicheskie':
$req = mysql_query("SELECT * FROM `komplekt` WHERE `lvl` = '24'") OR die(mysql_error());
While($kompl=mysql_fetch_array($req)){
if($mast>=$kompl['lvl']){
echo'<div class="block_zero"><img class="float-left" src="image/shop/3.png" width="30" height="30" style="margin-left:1px; margin-right:5px;" alt="*"><a href="weapon.php?mod=prosm&kom='.$kompl['id'].'"> '.$kompl['name'].'</a><br><img src="image/kachestvo/2.png" alt="*"><small><span style="color: #4f91ff;"> Эпические вещи</span></small></div><div class="dot-line"></div>';
}
}
echo'<div class="dot-line"></div><div class="main"><div class="block_zero"><a href="javascript:history.go(-1)"><span style="color: #999;"><< Назад</span></a></div></div>';
echo'</div>';
break;

case 'legendarnye':
$req = mysql_query("SELECT * FROM `komplekt` WHERE `lvl` = '48'") OR die(mysql_error());
While($kompl=mysql_fetch_array($req)){
if($mast>=$kompl['lvl']){
echo'<div class="block_zero"><img class="float-left" src="image/shop/4.png" width="30" height="30" style="margin-left:1px; margin-right:5px;" alt="*"><a href="weapon.php?mod=prosm&kom='.$kompl['id'].'"> '.$kompl['name'].'</a><br><img src="image/kachestvo/3.png" alt="*"><small><span style="color: #cc6be2;"> Легендарные вещи</span></small></div><div class="dot-line"></div>';
}
}
echo'<div class="dot-line"></div><div class="main"><div class="block_zero"><a href="javascript:history.go(-1)"><span style="color: #999;"><< Назад</span></a></div></div>';
echo'</div>';
break;

case 'bozhestvennye':
$req = mysql_query("SELECT * FROM `komplekt` WHERE `lvl` = '200'") OR die(mysql_error());
While($kompl=mysql_fetch_array($req)){
if($mast>=$kompl['lvl']){
echo'<div class="block_zero"><img class="float-left" src="image/shop/5.png" width="30" height="30" style="margin-left:1px; margin-right:5px;" alt="*"><a href="weapon.php?mod=prosm&kom='.$kompl['id'].'"> '.$kompl['name'].'</a><br><img src="image/kachestvo/4.png" alt="*"><small><span style="color: #f96;"> Божественные вещи</span></small></div><div class="dot-line"></div>';
}
}
echo'<div class="dot-line"></div><div class="main"><div class="block_zero"><a href="javascript:history.go(-1)"><span style="color: #999;"><< Назад</span></a></div></div>';
echo'</div>';
break;

case 'titanicheskie':
$req = mysql_query("SELECT * FROM `komplekt` WHERE `lvl` = '250'") OR die(mysql_error());
While($kompl=mysql_fetch_array($req)){
if($mast>=$kompl['lvl']){
echo'<div class="block_zero"><img class="float-left" src="image/shop/6.png" width="30" height="30" style="margin-left:1px; margin-right:5px;" alt="*"><a href="weapon.php?mod=prosm&kom='.$kompl['id'].'"> '.$kompl['name'].'</a><br><img src="image/kachestvo/5.png" alt="*"><small><span style="color: #999;"> Титанические вещи</span></small></div><div class="dot-line"></div>';
}
}
echo'<div class="dot-line"></div><div class="main"><div class="block_zero"><a href="javascript:history.go(-1)"><span style="color: #999;"><< Назад</span></a></div></div>';
echo'</div>';
break;
//********************
case 'prosm':
if(empty($_GET['kom'])){
echo'<div class="main"><div class="block_zero center">Не выбран комплект</div><div class="dot-line"></div><div class="main"><div class="block_zero"><a href="javascript:history.go(-1)"><span style="color: #999;"><< Назад</span></a></div></div></div>';
break;
}else{
$kom = $_GET['kom'];
$id = $_GET['id'];
$req = mysql_query("SELECT * FROM `shops` WHERE `kompl`= '$kom'") or die (mysql_error());
$avto=mysql_num_rows($req);
if($avto==0){
echo'<div class="main"><div class="block_zero center">Нет комплектов</div><div class="dot-line"></div><div class="main"><div class="block_zero"><a href="javascript:history.go(-1)"><span style="color: #999;"><< Назад</span></a></div></div></div>';
break;
}else{
if(isset($_GET['shmot'])){
switch($_GET['act']){

default:
break;

case 'sell':
$ids = $_GET['ids'];
$rep = mysql_query("SELECT * FROM `shops` WHERE `id`='$ids'");
$avtop=mysql_num_rows($rep);
if($avtop==0){
echo'<div class="main"><div class="block_zero center">Ошибка, такой вещи нет!</div></div>';
break;
}

$mags = mysql_fetch_array($rep);
$dm=mysql_query("SELECT * FROM `domination` WHERE `id` = '1'");
$dom = mysql_fetch_assoc($dm);

if($dom['white']>$dom['black']){
$liders='white';
}
elseif($dom['black']>$dom['white']){
$liders='black';
}else{
$liders='not';
}

if($udata['storona']==$liders){
$mags['cena']=round($mags['cena']-(($mags['cena']/100)*25));
}

$nmoney=$udata['almaz']-$mags['cena'];
if($nmoney<0){
echo'<div class="main"><div class="block_zero center">Не хватает рублей!</div></div>';
break;
exit;
}

mysql_query("INSERT INTO
        `weapon` SET
        `usr` = '$log',
        `tip` = '$mags[tip]',
        `kompl` = '$mags[kompl]',
        `proch` = '0',
        `name` = '$mags[name]',
        `cena` = '$mags[cena]',
        `hp` = '$mags[hp]',
        `mp` = '$mags[mp]',
        `krit` = '$mags[krit]',
        `ukrit` = '$mags[ukrit]',
        `sila` = '$mags[sila]',
        `lovk` = '$mags[lovk]',
        `prot` = '$mags[prot]',
        `nlvl` = '$mags[nlvl]',
        `image` = 'not'") OR die (mysql_error());
        mysql_query("UPDATE `users` SET `almaz` = '$nmoney' WHERE `usr` = '$log'");
        $_SESSION['message']="Вещь куплена и помещена в тумбочку!";
header('Location: weapon.php?mod=prosm&kom='.$kom.'');
exit();
break;

case 'ask':
header('Location: weapon.php?mod=prosm&kom='.$kom.'&shmot&act=sell&ids='.$id.'');exit;
break;
}
}

$am=0;
While($mag = mysql_fetch_array($req)){
if($udata['lvl']>$mag['nlvl']){
$font="#AAAAAA";
$pic="downlvl.png";
}
if($udata['lvl']>=$mag['nlvl'] AND $udata['lvl']<=$mag['nlvl']+5){
$font="#71cc71";
$pic="lvl.png";
}
if($udata['lvl']<$mag['nlvl']){
$font="chocolate";
$pic="uplvl.png";
}
$wep = mysql_query("SELECT * FROM `weapon` WHERE `image`= 'yes' AND `usr`='$log' AND `tip`='$mag[tip]'") OR die (mysql_error());
$wep = mysql_fetch_array($wep);
$stat = $wep['hp']+$wep['mp']+$wep['krit']+$wep['ukrit']+$wep['sila']+$wep['lovk']+$wep['prot'];
$statmag = $mag['hp']+$mag['mp']+$mag['krit']+$mag['ukrit']+$mag['sila']+$mag['lovk']+$mag['prot'];
if($stat==$statmag){
$tex='<span style="color: #999;"> + 0</span>';
}
if($statmag-$stat>0){
$sta=$statmag-$stat;
$tex='<span style="color: #9c9;"> +'.$sta.'</span>';
}
if($statmag-$stat<0){
$sta=$statmag-$stat;
$tex='<span style="color: #c66;"> '.$sta.'</span>';
}
$am=$am+$mag['cena'];
switch($mag['tip']){
case 'weapon':
$tip='';
break;
case 'body':
$tip='';
break;
case 'golova':
$tip='';
break;
case 'nogi':
$tip='';
break;
case 'shit':
$tip='';
break;
}
echo'<div class="block_zero">';
echo'<img class="float-left" src="image/weapon/'.$mag['kompl'].'/'.$mag['tip'].'.png" width="50" height="50" style="margin-left:10px; margin-right:10px;" alt="*"><a href="weapon.php?mod=info&id='.$mag['id'].'"><span style="color: #fc6;"> '.$tip.' '.$mag['name'].' </span></a>+0<br>'.$tex.' к параметрам<br>Бонус: 0/10<br><a class="btn" href="weapon.php?mod=prosm&kom='.$kom.'&shmot&act=ask&id='.$mag['id'].'"><span class="end"><span class="label">Купить за <img src="image/icon/almaz.png" alt="*"> '.$mag['cena'].'</span></span></a>';
echo'</div><div class="dot-line"></div>';
}
}
echo'<div class="block_zero center"><a class="btn" href="weapon.php?mod=askall&kom='.$kom.'&am='.$am.'"><span class="end"><span class="label">Купить комплект за <img src="image/icon/almaz.png" alt="*"> '.$am.'</span></span></a>';
echo'</div><div class="dot-line"></div><div class="main"><div class="block_zero"><a href="javascript:history.go(-1)"><span style="color: #999;"><< Назад</span></a></div></div></div>';
}
break;


case 'askall':
if($udata['almaz']<$_GET['am']){
$_SESSION['err']="Не хватает рублей!";
header('Location: weapon.php?');
exit();
}
header('Location: weapon.php?mod=all&kom='.$_GET['kom'].'');exit;
break;

case 'all':
$kom = $_GET['kom'];
$rep = mysql_query("SELECT * FROM `shops` WHERE `kompl`='$kom'");
$avtop=mysql_num_rows($rep);
if($avtop==0){
echo'<div class="main"><div class="block_zero center">Ошибка, такого комплекта нет!</div></div>';
break;
}

$am=0;
While($mags = mysql_fetch_array($rep)){
mysql_query("INSERT INTO
        `weapon` SET
        `usr` = '$log',
        `tip` = '$mags[tip]',
        `kompl` = '$mags[kompl]',
        `proch` = '0',
        `name` = '$mags[name]',
        `cena` = '$mags[cena]',
        `hp` = '$mags[hp]',
        `mp` = '$mags[mp]',
        `krit` = '$mags[krit]',
        `ukrit` = '$mags[ukrit]',
        `sila` = '$mags[sila]',
        `lovk` = '$mags[lovk]',
        `prot` = '$mags[prot]',
        `nlvl` = '$mags[nlvl]',
        `image` = 'not'") OR die (mysql_error());
$am=$am+$mags['cena'];
}
$nmoney=$udata['almaz']-$am;
mysql_query("UPDATE `users` SET `almaz` = '$nmoney' WHERE `usr` = '$log'");
$_SESSION['message']="Комплект куплен и помещён в тумбочку!";
header('Location: weapon.php?mod=prosm&kom='.$kom.'');
exit();
break;

case 'info':
$req = mysql_query("SELECT * FROM `shops` WHERE `id`='$_GET[id]'");
$avto=mysql_num_rows($req);
if($avto==0){
echo'Ошибка!';
include($path.'files/down.php');exit;
}
$mag = mysql_fetch_array($req);

$wep = mysql_query("SELECT * FROM `weapon` WHERE `image`= 'yes' AND `usr`='$log' AND `tip`='$mag[tip]'") OR die (mysql_error());
$wep = mysql_fetch_array($wep);
$stat = $wep['hp']+$wep['mp']+$wep['krit']+$wep['ukrit']+$wep['sila']+$wep['lovk']+$wep['prot'];

$statmag=$mag['hp']+$mag['mp']+$mag['krit']+$mag['ukrit']+$mag['sila']+$mag['lovk']+$mag['prot'];
if($stat==$statmag){
$tex='<span style="color: #999;"> + 0</span>';
}
if($statmag-$stat>0){
$sta=$statmag-$stat;
$tex='<span style="color: #9c9;"> +'.$sta.'</span>';
}
if($statmag-$stat<0){
$sta=$statmag-$stat;
$tex='<span style="color: #c66;"> '.$sta.'</span>';
}
switch($mag['tip']){
case 'weapon':
$tip='';
break;
case 'body':
$tip='';
break;
case 'golova':
$tip='';
break;
case 'nogi':
$tip='';
break;
case 'shit':
$tip='';
break;
}
if($udata['lvl']>$mag['nlvl']){
$font="gray";
$pic="downlvl.png";
}
if($udata['lvl']>=$mag['nlvl'] AND $udata['lvl']<=$mag['nlvl']+5){
$font="#71cc71";
$pic="lvl.png";
}
if($udata['lvl']<$mag['nlvl']){
$font="chocolate";
$pic="uplvl.png";
}

echo'<div class="block_zero"><img class="float-left" src="image/weapon/'.$mag['kompl'].'/'.$mag['tip'].'.png" width="50" height="50" style="margin-left:10px; margin-right:10px;" alt="*"><span style="color: #fc6;"> '.$tip.' '.$mag['name'].' </span>+0<br>'.$tex.' к параметрам<br>Бонус: 0/10<br>';

echo'</div><div class="dot-line"></div><div class="block_zero">';

if(!empty($mag['hp'])){echo"Жизнь: <font color='$font'>$mag[hp]<br/></font>";}
if(!empty($mag['mp'])){echo"Энергия: <font color='$font'>$mag[mp]<br/></font>";}
if(!empty($mag['sila'])){echo"Сила: <font color='$font'>$mag[sila]<br/></font>";}
if(!empty($mag['lovk'])){echo"Ловкость: <font color='$font'>$mag[lovk]<br/></font>";}
if(!empty($mag['prot'])){echo"Физ. защита: <font color='$font'>$mag[prot]<br/></font>";}
if(!empty($mag['krit'])){echo"Крит: <font color='$font'>$mag[krit]%<br/></font>";}
if(!empty($mag['ukrit'])){echo"Крит-урон: <font color='$font'>$mag[ukrit]%<br/></font>";}
echo"Требования:";
if(!empty($mag['nlvl'])){echo" $mag[nlvl] бицухи<br/>";}
echo'</div><div class="dot-line"></div>';

echo'</div><div class="dot-line"></div><div class="main"><div class="block_zero"><a href="javascript:history.go(-1)"><span style="color: #999;"><< Назад</span></a></div></div></div>';

break;
}
include($path.'files/down.php');
?>