<?
include './system/common.php'; 
include './system/functions.php'; 
include './system/user.php'; 
if($user) { header('location: /'); exit; } 
$title = 'Зарождение'; 
include './system/h.php'; 

$ref = _string(_num($_GET['ref'])); 
$_SESSION['ref']=$ref;
if ($_SESSION['start']==0 or (!isset($_SESSION['start'])))  {
if ($_SESSION['compl']==0 or (!isset($_SESSION['compl'])))  {
$_SESSION['compl']=1;}
if(isset($_GET['sex'])){
$sex=$_GET['sex'];
$_SESSION['sex']=$sex;
header('Location: start');exit;
}
if (isset($_GET['c_sm'])) {
$complect=rand(1,3);
$_SESSION['compl']=$complect;
if($complect==$_GET['c_sm'] and $complect==1){$_SESSION['compl']=3;}
elseif($complect==$_GET['c_sm'] and $complect==2){$_SESSION['compl']=1;}
elseif($complect==$_GET['c_sm'] and $complect==3){$_SESSION['compl']=2;}

header('Location: start');exit;
}
if (isset($_GET['v_sn'])) {
$_SESSION['start']=1;
header('Location: start');exit;
}
$complect=$_SESSION['compl'];
if($complect==1){$w_1['item']=9;$w_2['item']=10;$w_3['item']=11;$w_4['item']=12;$w_5['item']=13;$w_6['item']=14;$w_7['item']=15;$w_8['item']=16;}
elseif($complect==2){$w_1['item']=25;$w_2['item']=26;$w_3['item']=27;$w_4['item']=28;$w_5['item']=29;$w_6['item']=30;$w_7['item']=31;$w_8['item']=32;}
elseif($complect==3){$w_1['item']=17;$w_2['item']=18;$w_3['item']=19;$w_4['item']=20;$w_5['item']=21;$w_6['item']=22;$w_7['item']=23;$w_8['item']=24;}
if($_SESSION['sex']==f){$isex=1;}else{$isex=0;}
?><div class='center'><div class='main' style='word-wrap:break-word;'><span style='text-shadow:none;'></span><div class='head' onclick='location.href="/"'>Зарождение</div><div class='line'></div>



<div class='center'><div class='block_zero'><span class='blue'>Выбери себе снаряжение для битвы!</span></div><div class='mini-line'></div>


<div class='block_zero' style='word-wrap:break-word;'>
<img src='/manekenImage/
<?=$isex?>/
<?=$w_1['item']?>/
<?=$w_2['item']?>/
<?=$w_3['item']?>/
<?=$w_4['item']?>/
<?=$w_5['item']?>/
<?=$w_6['item']?>/
<?=$w_7['item']?>/
<?=$w_8['item']?>/
' width='120' height='160' style='margin-right:10px;margin-top:3px;' alt='*'/></div>
</div><div class='block_zero'>





<?
if($_SESSION['sex']==f){?><span class='blue'>Пол:</span> <a href='/start.php?sex=m'>мужской</a> / <span class='bold'>женский</span><? }
else{?><span class='blue'>Пол:</span> <span class='bold'>мужской</span> / <a href='/start.php?sex=f'>женский</a><? }
?>
<div class='block_zero'>
<div class='mini-line'></div>

</div><a class='btn' href='/start.php?c_sm=<?php echo$complect?>'>
<span class='end'><span class='label'>Выбрать другое снаряжение</span></span></a>
<div class='block_zero'>
<div class='dot-line'></div>
</div><span class='dgreen bold'>+992</span> к параметрам<div class='mb10'></div>
<a class='btn' href='/start.php?v_sn'><span class='end'><span class='label'>
<span class='dgreen'>Взять это снаряжение</span></span></span></a></div></div><br/>
<div class='center'></span><div class='mb10'></div><a class='grey' href='/?exit'>Выход</a><div class='mb10'></div>
<?}
if ($_SESSION['start']==1)  {
if (isset($_GET['at'])) {
$_SESSION['start']=2;
header('Location: start');exit;
}
?><div class='main' style='word-wrap:break-word;'><span style='text-shadow:none;'></span><div class='head' onclick='location.href="/"'><div class='center'>Зарождение</div>
</div><div class='line'></div>
<div class='center'>На своём пути вы встретили врага<div class='medium'><span class='blue'>— Стой, дальше дороги нет, держи меч и готовься к битве.</span><br/></br></div></div>
<div class='line'></div><div class='block_zero'><div class='float-left'>
<img src='/manekenImage/0/49/50/51/52/53/54/55/56/' width='120' height='160' style='margin-right:10px;margin-top:3px;' alt=''/></div>
<img src='/images/icon/race/1.png' alt=''/> Враг<br/><br/>
<img src='/images/icon/str.png' alt='str'/> Сила: 190<br/>
<img src='/images/icon/vit.png' alt='vit'/> Жизни: 198<br/>
<img src='/images/icon/agi.png' alt='agi'/> Удача: 198<br/>
<img src='/images/icon/def.png' alt='def'/> Броня: 190<br/><br/>
<form action='/start.php?at' method='post'><div>
<input class='button1' type='submit' value='Атаковать'></div>
</form><div style='clear:both;'></div></div></div><br/><? }
if ($_SESSION['start']==2)  {
if (isset($_GET['prd'])) {
$_SESSION['start']=3;
header('Location: start');exit;
}
?><div class='main' style='word-wrap:break-word;'><span style='text-shadow:none;'></span><div class='head' onclick='location.href="/"'><div class='center'>Зарождение</div>
</div><div class='line'></div>
<div class='center'><div class='block_light'><h2 class='dgreen' style='font-weight:bold;'><img src='/images/icon/2hit.png' alt=''/> Победа! <img src='/images/icon/2hit.png' alt=''/></h2> <div class='separ'></div><span class='blue'>Награда:</span> <img src='/images/icon/silver.png' alt=''/> 500 серебра</div></div><div class='line'></div>
<div class='float-left'><img src='/manekenImage/0/49/50/51/52/53/54/55/56/' width='120' height='160' style='margin-right:10px;margin-top:3px;' alt=''/></div>
<img src='/images/icon/race/1.png' alt=''/> Враг<br/><br/>
<img src='/images/icon/str.png' alt='str'/> Сила: 190<br/>
<img src='/images/icon/vit.png' alt='vit'/> Жизни: 198<br/>
<img src='/images/icon/agi.png' alt='agi'/> Удача: 198<br/>
<img src='/images/icon/def.png' alt='def'/> Броня: 190<br/>
<div style='clear:both;'></div>
<div class='line'></div>
<center><span class='blue'>Неплохо! Но ещё есть куда стремиться!<br/>Удачи тебе!</span><div class='dot-line'></div><a class='btn' href='/start.php?prd'><span class='end'><span class='label'>Продолжить путь</span></span></a></div><br/></center><? }
if ($_SESSION['start']==3)  {
$ref=$_SESSION['ref'];
$password = rand(111,999); 

  if(mysql_query('INSERT INTO `users` (`login`, 
`password`) VALUEs ("Боец", 
                                               "'.$password.'")')) { 


     
    $id = mysql_insert_id(); 

if($ref) { 

  $ref_user = mysql_query('SELECT * FROM `users` WHERE `id` = "'.$ref.'"'); 
  $ref_user = mysql_fetch_array($ref_user); 

  if($ref_user) { 
   
    mysql_query('INSERT INTO `ref` (`user`, 
                                      `ho`) VALUEs ("'.$ref_user['id'].'", 
                                                                "'.$id.'")'); 
   
  } 

} 
   
  $user = mysql_query('SELECT * FROM `users` WHERE `id` = "'.$id.'"'); 
  $user = mysql_fetch_array($user); 

$com=$_SESSION['compl'];
if($com==1){$com=1;}
elseif($com==2){$com=20;}
elseif($com==3){$com=21;}
if($_SESSION['sex']==m){$isex=0;}else{$isex=1;}
   for($w = 1; $w < 9; $w++) {
    if($com==1){$com=1;}
elseif($com==2){$com=20;}
elseif($com==3){$com=21;}
   
$buy_complect =$com;


    
    $complect = mysql_query('SELECT * FROM `complects` WHERE `id` = "'.$buy_complect.'"');
    $complect = mysql_fetch_array($complect);
    
    switch($complect['quality']) {
      case 1:
      $complect_quality_skill =   1;
       break;
      case 2:
      $complect_quality_skill =  10;
       break;
      case 3:
      $complect_quality_skill =  24;
       break;
      case 4:
      $complect_quality_skill =  48;
       break;
      case 5:
      $complect_quality_skill = 200;
       break;
      case 6:
      $complect_quality_skill = 250;
       break;
	
	}
    

    
    for($w = 1; $w < 9; $w++) {
      $shop = mysql_query('SELECT * FROM `shop` WHERE `id` = "'.$complect['w_'.$w].'"');
      $shop = mysql_fetch_array($shop);
    }
    



    for($w = 1; $w < 9; $w++) {
    
      $shop = mysql_query('SELECT * FROM `shop` WHERE `id` = "'.$complect['w_'.$w].'"');
      $shop = mysql_fetch_array($shop);
    
    
      mysql_query('INSERT INTO `inv` (`user`,
                                      `item`,
                                     `bonus`,
                                      `_str`,
                                      `_vit`,
                                      `_agi`,
                                      `_def`) VALUES ("'.$user['id'].'",
                                                      "'.$shop['id'].'",
                                                   "'.$shop['bonus'].'",
                                                    "'.$shop['_str'].'",
                                                    "'.$shop['_vit'].'",
                                                    "'.$shop['_agi'].'",
                                                    "'.$shop['_def'].'")');
    
        
    }
$_g = 50; 
$_s = 10000; 
if($_SESSION['sex']==f){$isex=1;}else{$isex=0;}
     mysql_query('UPDATE `users` SET `hp` = "'.($user['vit'] * 2).'", `sex` = "'.$isex.'",`mp` = "'.$user['mana'].'" WHERE `id` = "'.$id.'"');

     mysql_query('UPDATE `users` SET `g`  ="'.$_g.'", 
                                     `s`  ="'.$_s.'" WHERE `id` = "'.$id.'"'); 




            setCookie('id', $user['id'], time() + 86400, '/'); 
setCookie('password', $password, time() + 86400, '/'); 
     
     
 $_SESSION = array();

      header('location: /'); 
  } 
}
}
if(isset($_GET['zan'])){
    
 $_SESSION = array();

      header('location: /'); 
}
include './system/f.php'; 
?>