<?php

require_once 'core/system.php';








head('get');



reg();

$aluko = $dbc->query("SELECT `id` FROM `monster` WHERE `user`='".$user['id']."' LIMIT 1")->fetch_assoc();






if($aluko){ header('location:battle.php');exit; } 

if($user['level']<15){ $store = 1; $limit = 10; }elseif($user['level']>=15){ $store = 2; $limit= 20; }
if($user['level']>=25){ $store = 3; $limit = 30; }
if($user['level']>=45){ $store = 4; $limit = 40; }
if($user['level']>=55){ $store = 5; $limit = 50; }
if($user['level']>=65){ $store = 6; $limit = 60; }
if($user['level']>=75){ $store = 7; $limit = 70; }
if($user['level']>=85){ $store = 8; $limit = 80; }
if($user['level']>=95){ $store = 9; $limit = 100; }

if(!empty($_GET['id'])){

    $pet_id = int($_GET['id']);
$pet = $dbc->query("SELECT * FROM `monster` WHERE `id`='".$pet_id."' LIMIT 1")->fetch_assoc();

if(!$pet){
        header("Location: fost.php");
        exit;        }


$time = $pet['time'] - time();

 if($pet['store']!=$store){       header("Location: fost.php");exit; }

 if(Sec2Time($time)>0){       header("Location: fost.php");exit; }

 if($pet['health']<=0){       header("Location: fost.php");exit; }
    $until = 120 + TIME;
$dbc->query("update `monster` set `time` = ".$until." where id = '".$pet_id."'");


$dbc->query("update `monster` set `user` = '".$user['id']."',`login`='".$user['login']."' where id = '".$pet_id."'");


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




}
