<? 
include './system/common.php';  
include './system/functions.php';
include './system/user.php';
    
if(!$user) {
header('location: /');
exit;}
    
$title = 'Тренировка';
include './system/h.php';  
$id = htmlspecialchars($_GET['id']); //Оприделяем какой параметр   
	
	
    function cost($i) {

	switch($i) {
case 0:
$cost = 200;
break;
        
case 1:
$cost = 400;
break;
        
case 2:
$cost = 600;
break;
          
case 3:
$cost = 800;
break;

case 4:
$cost = 1000;
break;   
           
case 5:
$cost = 1;
break;        

case 6:
$cost = 1600;
break;   

case 7:
$cost = 3200;
break;

case 8:
$cost = 4800;
break;   
           
case 9:
$cost = 6400;
break;   

case 10:
$cost = 8000;
break;   

case 11:
$cost = 10;
break;   

case 12:
$cost = 2400;
break;   

case 13:
$cost = 4800;
break;   

case 14:
$cost = 7200;
break;   

case 15:
$cost = 9600;
break;   

case 16:
$cost = 12000;
break;   

case 17:
$cost = 20;
break;   

case 18:
$cost = 3200;
break;   

case 19:
$cost = 7200;
break;   

case 20:
$cost = 10800;
break;   

case 21:
$cost = 14400;
break;   

case 22:
$cost = 18000;
break;   

case 23:
$cost = 40;
break;   

case 24:
$cost = 3600;
break;   

case 25:
$cost = 7200;
break;   

case 26:
$cost = 10800;
break;   

case 27:
$cost = 14400;
break;   

case 28:
$cost = 18000;
break;   

case 29:
$cost = 80;
break;   

case 30:
$cost = 4800;
break;   

case 31:
$cost = 9600;
break;   

case 32:
$cost = 14400;
break;   

case 33:
$cost = 19200;
break;   

case 34:
$cost = 24000;
break;   

case 35:
$cost = 160;
break;   

case 36:
$cost = 5600;
break;   

case 37:
$cost = 11200;
break;   

case 38:
$cost = 16800;
break;   

case 39:
$cost = 22400;
break;   

case 40:
$cost = 28000;
break;   

case 41:
$cost = 320;
break;   

case 42:
$cost = 6400;
break;   

case 43:
$cost = 12800;
break;   

case 44:
$cost = 19200;
break;   

case 45:
$cost = 25600;
break;   

case 46:
$cost = 32000;
break;   

case 47:
$cost = 640;
break;   

case 48:
$cost = 7200;
break;   

case 49:
$cost = 14400;
break;   

case 50:
$cost = 21600;
break;   

case 51:
$cost = 28800;
break;   

case 52:
$cost = 36000;
break;   

case 53:
$cost = 1280;
break;   

case 54:
$cost = 5000;
break;   

case 55:
$cost = 16000;
break;   

case 56:
$cost = 24000;
break;   

case 57:
$cost = 32000;
break;   

case 58:
$cost = 40000;
break;   

case 59:
$cost = 2560;
break;   
}
        
return $cost;
    
}

    function value($i) {
        
       switch($i) {
case 0:
$value = 's';
break;
        
case 1:
$value = 's';
break;
        
case 2:
$value = 's';
break;
          
case 3:
$value = 's';
break;

case 4:
$value = 's';
break;        

case 5:
$value = 'g';
break;        

case 6:
$value = 's';
break;        

case 7:
$value = 's';
break;        

case 8:
$value = 's';
break;        

case 9:
$value = 's';
break;        

case 10:
$value = 's';
break;        

case 11:
$value = 'g';
break;        

case 12:
$value = 's';
break;        

case 13:
$value = 's';
break;        

case 14:
$value = 's';
break;        

case 15:
$value = 's';
break;        

case 16:
$value = 's';
break;        

case 17:
$value = 'g';
break;        

case 18:
$value = 's';
break;        
        
case 19:
$value = 's';
break;        

case 20:
$value = 's';
break;        
          
case 21:
$value = 's';
break;        
          
case 22:
$value = 's';
break;     
              
case 23:
$value = 'g';
break;        

case 24:
$value = 's';
break;     

case 25:
$value = 's';
break;     

case 26:
$value = 's';
break;     

case 27:
$value = 's';
break;     

case 28:
$value = 's';
break;     

case 29:
$value = 'g';
break;     

case 30:
$value = 's';
break;     

case 31:
$value = 's';
break;     

case 32:
$value = 's';
break;     

case 33:
$value = 's';
break;     

case 34:
$value = 's';
break;     

case 35:
$value = 'g';
break;     

case 36:
$value = 's';
break;     

case 37:
$value = 's';
break;     

case 38:
$value = 's';
break;     

case 39:
$value = 's';
break;     

case 40:
$value = 's';
break;     

case 41:
$value = 'g';
break;     

case 42:
$value = 's';
break;     

case 43:
$value = 's';
break;     

case 44:
$value = 's';
break;     

case 45:
$value = 's';
break;     

case 46:
$value = 's';
break;     

case 47:
$value = 'g';
break;     

case 48:
$value = 's';
break;     

case 49:
$value = 's';
break;     

case 50:
$value = 's';
break;     

case 51:
$value = 's';
break;     

case 52:
$value = 's';
break;     

case 53:
$value = 'g';
break;     

case 54:
$value = 's';
break;     

case 55:
$value = 's';
break;     

case 56:
$value = 's';
break;     

case 57:
$value = 's';
break;     

case 58:
$value = 's';
break;     

case 59:
$value = 'g';
break;     

}
return $value;
 }

 
 
 
 
if($id) {

if($user['_'.$id.''] < 60) {

    if(value($user['_'.$id.'']) == 's') {
if($user['s'] < cost($user['_'.$id.''])) {
header("Location:/train/");
$_SESSION[''.$id.''] = mes('Недостаточно ресурсов!');
exit;           
}else{
mysql_query('UPDATE `users` SET `'.$id.'` =   `'.$id.'` + 3,
                                         `_'.$id.'` =  `_'.$id.'` + 1,
                                        `skill` = `skill` + 1 WHERE `id` = "'.$user['id'].'"');
mysql_query('UPDATE `users` SET `s` = `s` - '.cost($user['_'.$id.'']).' WHERE `id` = "'.$user['id'].'"');
}

}else
    if(value($user['_'.$id.''] == 'g')) {
      
      if($user['g'] < cost($user['_'.$id.''])) {
header("Location:/train/");
$_SESSION[''.$id.''] = mes('Недостаточно ресурсов!');
exit; 
}else{
mysql_query('UPDATE `users` SET `'.$id.'` =   `'.$id.'` + 3,
                                         `_'.$id.'` =  `_'.$id.'` + 1,
                                        `skill` = `skill` + 1 WHERE `id` = "'.$user['id'].'"');
mysql_query('UPDATE `users` SET `g` = `g` - '.cost($user['_'.$id.'']).' WHERE `id` = "'.$user['id'].'"');
  }    
}
}   


// Задания
$task_id=5;// Подними параметры героя 3 раза
$req = mysql_query('select * from `task_user` WHERE (`user`="'.$user['id'].'") AND (`task`="'.$task_id.'") AND (`complete`="0")');
    if (mysql_num_rows ($req) != 0) {
while ($t = mysql_fetch_array ($req)) {
$task = mysql_fetch_array(mysql_query ('SELECT * FROM `task` WHERE (`id`="'.$task_id.'")'));
if ($t['how'] < $task['how']){                            
mysql_query ('UPDATE `task_user` SET `how`=`how`+1 WHERE (`user`="'.$user['id'].'") AND (`task`="'.$task_id.'")');
}}}
/////////////////////////////////////////////////

$_SESSION[''.$id.''] = mes('Успешно улучшено!');
header('location: /train/');
exit;
}	








echo'<div class="title">'.$title.'</div>';

echo' '.$_SESSION['str'].' ';
    $_SESSION['str']=NULL; //Удаляем сесию
echo'<div class="empty_block">
<table> <tbody><tr>
  <table> <tbody><tr>
<td width="14%">
<img src="/images/ico/png/strength.png">
</td><td> 
Сила +'.($user['_str']*3).' <br>
Увеличивает наносимый врагам урон <br>
Уровень: '.$user['_str'].' из 60
</td></tr>
</tbody></table>';

  if($user['_str'] < 60) {
echo'<div class="link_center"><a href="/train/str"><img src="/images/ico/png/'.(value($user['_str']) == 'g' ? 'gold':'silver').'.png" alt="*" width="18"/> '.cost($user['_str']).'</a></div>';
}
echo'</div>
<div class="line"></div>';




echo' '.$_SESSION['vit'].' ';
    $_SESSION['vit']=NULL; //Удаляем сесию
echo'<div class="empty_block">
<table> <tbody><tr>
<td width="14%">
<img src="/images/ico/png/health.png">
</td><td> 
Здоровье  +'.($user['_vit']*3).' <br>
Увеличивает запас здоровья <br>
Уровень: '.$user['_vit'].' из 60
</td></tr>
</tbody></table>';
  if($user['_vit'] < 60) {
echo'<div class="link_center"><a href="/train/vit"><img src="/images/ico/png/'.(value($user['_vit']) == 'g' ? 'gold':'silver').'.png" alt="*" width="18"/> '.cost($user['_vit']).'</a></div>';
}
echo'</div>
<div class="line"></div>';




echo' '.$_SESSION['def'].' ';
    $_SESSION['def']=NULL; //Удаляем сесию
echo'<div class="empty_block">
<table> <tbody><tr>
<td width="14%">
<img src="/images/ico/png/defense.png">
</td><td> 
Броня  +'.($user['_def']*3).' <br>
Поглощает урон врага <br>
Уровень: '.$user['_def'].' из 60
</td></tr>
</tbody></table>';
  if($user['_def'] < 60) {
echo'<div class="link_center"><a href="/train/def"><img src="/images/ico/png/'.(value($user['_def']) == 'g' ? 'gold':'silver').'.png" alt="*" width="18"/> '.cost($user['_def']).'</a></div>';
}
echo'</div>
 <div class="line"></div>';





  
include './system/f.php';

?>