<?php
require_once 'core/system.php';

$ids = int($_GET['id']);
if($ids>0){
$mas = ($_SESSION['brut']!=$ids) ? $_SESSION['brut'] = $ids : $_SESSION['brut'];



$ids = int($mas);

}else{ $ids = int($_SESSION['brut']); }

$myq = $dbc->query("SELECT * FROM `my_kvest` WHERE `user` = '".$user['id']."' LIMIT 1")->fetch_assoc();
if ($myq['user']==0){

$dbc->query("INSERT INTO `my_kvest` SET `user` = '".$user['id']."'");}

$quest = $dbc->query("SELECT * FROM `quest` WHERE `id`='".$ids."' LIMIT 1")->fetch_assoc();
head(''.$quest['name'].'');


if($myq['priz']>0){
  ?><center><a href="quest.php?nag"><input class="btn big" type="submit" value="Получить Награду"></a></center><? }
if(isset($_GET['nag'])){


if($myq['priz']<1){ header('location:index.php');exit;}
if($myq['priz']==1){ $dbc->query("update `users` set `gold`=`gold`+5 where `id`='".$user['id']."'");} 


if($myq['priz']==6){ $dbc->query("update `users` set `leg`=`leg`+50 where `id`='".$user['id']."'"); } 

if($myq['priz']==7){ $dbc->query("update `users` set `gold`=`gold`+10 where `id`='".$user['id']."'"); } 


if($myq['priz']==8){ $dbc->query("update `users` set `rub`=`rub`+100 where `id`='".$user['id']."'"); }  

if($myq['priz']==9){ $dbc->query("update `users` set `rub`=`rub`+200 where `id`='".$user['id']."'"); } 

if($myq['priz']==10){ $dbc->query("update `users` set `gold`=`gold`+15 where `id`='".$user['id']."'"); } 

if($myq['priz']==11){ $dbc->query("update `users` set `gold`=`gold`+25 where `id`='".$user['id']."'"); }  
if($myq['priz']==12){ $dbc->query("update `users` set `gold`=`gold`+500 where `id`='".$user['id']."'"); }  

if($myq['priz']==13){ $dbc->query("update `users` set `gold`=`gold`+1000 where `id`='".$user['id']."'"); }  
  

if($myq['priz']==2){ $dbc->query("update `users` set `serebro`=`serebro`+20000 where `id`='".$user['id']."'"); }


if($myq['priz']==3){
$dbc->query("update `dop` set `boi`=`boi`+1 where `user`='".$user['id']."' "); }

if($myq['priz']==4){

$dbc->query("update `dop` set `boi`=`boi`+2 where `user`='".$user['id']."' "); }

if($myq['priz']==5 and $user['spet']==0){




$pet_buy = $dbc->query("SELECT * FROM `pets_tj` WHERE `id` = '1'")->fetch_assoc();  

$dbc->query("INSERT INTO `user_pets` SET 

`id_user` = '$user[id]', 
`id_pets` = '$pet_buy[id]', 
`name` = '$pet_buy[name]',
`str` = '$pet_buy[str]',
`vit` = '$pet_buy[vit]',
`def` = '$pet_buy[def]',
`img` = '$pet_buy[img]',
`level` = '1',
`arena_battle` = '10'");


$dbc->query("UPDATE `users` SET 

`s_pet` =  '1'
 WHERE `id` = '$user[id]'"); 





 }


$dbc->query("update `my_kvest` set `priz`=0 where `user`='".$user['id']."'");
$_SESSION['message']='Награда Получена';
header('location:?');exit;


}









$pss = $myq['q_'.$ids];



$go = $quest['go'];

if(isset($_GET['start'])){   if(!$quest){ header('location: way.php');exit;}


if($pss==1){ header('location:quest.php?id='.$ids.'');exit;}
if($user['level']<$quest['level']){

$_SESSION['message']='ваш уровень слишком мал!';
 header('location:quest.php?id='.$ids.'');exit;}


$dbc->query("UPDATE `users` SET `quest`='".$ids."' WHERE `id`='".$user['id']."'");
$dbc->query("UPDATE `my_kvest` SET `kvest`='".$ids."',`hp`='".$quest['start_hp']."',`max`='".$quest['etap']."',`tip`='".$quest['tip']."',`itog`='".$quest['itog']."',`go`='".$go."',`etap`=1,`sum`=0,`goal`='".$quest['goal']."' WHERE `user`='".$user['id']."'");




header('location:quest_war.php');exit;







}

if(!$quest){
        header("Location: index.php");        exit;}



?><div class="cito-name"><?=$quest['name']?></div><?


?><div class="lblue-panel no-brd-bottom">
<div class="panel-inner-2">
<img alt="" width="32" height="32" class="fleft mt5 mr5" src="img/ivent/nas.png"/>

<span class="font12"> <?=$quest['opis']?></span>


<div style="clear:both;"></div>
</div>
</div><?


$ps = $myq['q_'.$ids];






if($ps==0){


?><a class="gr-btn center" href="quest.php?start"><span class="i12 i12-cross"></span>Начать Бой</a><?



}else{ ?><center> задание уже выполнено </center><? }



?><div class="b-panel-new brown-panel rewards-panel mt2"><span class="iLegendary">Награда:</span></br><?=$quest['nagrada']?>    <img src="/img/res/med.png">3 <img src="img/money/rubin.png">10</div><?








foot();


