<?
//
//
//рандом вещь
$item = DB::$dbs->queryFetch('SELECT * FROM `items` WHERE `set` > ? AND `set` < ? ORDER BY RAND() LIMIT 1', [0,4]);
//
//
//сколько вещей в сумке
$count_bag = DB::$dbs->query("SELECT (id) FROM `inv` WHERE `yes` = '0' AND `id_user` = '".$user['id']."'")->rowCount(); 
//
//
if($user['start'] == 1)$rand_it = rand(4,5); //проходит обучение
elseif($user['level'] <= 17)$rand_it = rand(2,5); //слабым игрокам и новичкам вещи будут падать чаще
elseif($user['level'] >= 18)$rand_it = rand(2,8); //более сильным игрокам вещи будут падать реже
//
//
$it = '';
//
//
if($item && $rand_it == 5 && $count_bag <= 29){
//
//
DB::$dbs->query("INSERT INTO `inv` SET `id_user` = ?, `set` = ?, `power` = ?, `def` = ?, `hp` = ?, `smitch` = ?, `max_smitch` = ?, `yes` = ?, `type` = ?, `name` = ?, `level` = ?", array($user['id'],$item['set'],$item['power'],$item['def'],$item['hp'],0,$item['max_smitch'],0,$item['type'],$item['name'],$item['level']));
//
//
$medal2 = DB::$dbs->queryFetch("SELECT * FROM `medal_user` WHERE `id_task` = ? AND `id_user` = ? LIMIT 1", array(12,$user['id']));
if($medal2['check'] == 0)DB::$dbs->query("UPDATE `medal_user` SET `coll` = `coll` + ? WHERE `id` = ? LIMIT 1", array(1,$medal2['id']));
//
//
$medal3 = DB::$dbs->queryFetch("SELECT * FROM `medal_user` WHERE `id_task` = ? AND `id_user` = ? LIMIT 1", array(13,$user['id']));
if($medal3['check'] == 0)DB::$dbs->query("UPDATE `medal_user` SET `coll` = `coll` + ? WHERE `id` = ? LIMIT 1", array(1,$medal3['id']));
//
//
$medal4 = DB::$dbs->queryFetch("SELECT * FROM `medal_user` WHERE `id_task` = ? AND `id_user` = ? LIMIT 1", array(14,$user['id']));
if($medal4['check'] == 0)DB::$dbs->query("UPDATE `medal_user` SET `coll` = `coll` + ? WHERE `id` = ? LIMIT 1", array(1,$medal4['id']));
//
//
$medal5 = DB::$dbs->queryFetch("SELECT * FROM `medal_user` WHERE `id_task` = ? AND `id_user` = ? LIMIT 1", array(15,$user['id']));
if($medal5['check'] == 0)DB::$dbs->query("UPDATE `medal_user` SET `coll` = `coll` + ? WHERE `id` = ? LIMIT 1", array(1,$medal5['id']));
//
//
$medal6 = DB::$dbs->queryFetch("SELECT * FROM `medal_user` WHERE `id_task` = ? AND `id_user` = ? LIMIT 1", array(16,$user['id']));
if($medal6['check'] == 0)DB::$dbs->query("UPDATE `medal_user` SET `coll` = `coll` + ? WHERE `id` = ? LIMIT 1", array(1,$medal6['id']));
//
//
$medal7 = DB::$dbs->queryFetch("SELECT * FROM `medal_user` WHERE `id_task` = ? AND `id_user` = ? LIMIT 1", array(17,$user['id']));
if($medal7['check'] == 0)DB::$dbs->query("UPDATE `medal_user` SET `coll` = `coll` + ? WHERE `id` = ? LIMIT 1", array(1,$medal7['id']));
//
//
$medal8 = DB::$dbs->queryFetch("SELECT * FROM `medal_user` WHERE `id_task` = ? AND `id_user` = ? LIMIT 1", array(18,$user['id']));
if($medal8['check'] == 0)DB::$dbs->query("UPDATE `medal_user` SET `coll` = `coll` + ? WHERE `id` = ? LIMIT 1", array(1,$medal8['id']));
//
//
$medal9 = DB::$dbs->queryFetch("SELECT * FROM `medal_user` WHERE `id_task` = ? AND `id_user` = ? LIMIT 1", array(19,$user['id']));
if($medal9['check'] == 0)DB::$dbs->query("UPDATE `medal_user` SET `coll` = `coll` + ? WHERE `id` = ? LIMIT 1", array(1,$medal9['id']));
//
//
$medal10 = DB::$dbs->queryFetch("SELECT * FROM `medal_user` WHERE `id_task` = ? AND `id_user` = ? LIMIT 1", array(20,$user['id']));
if($medal10['check'] == 0)DB::$dbs->query("UPDATE `medal_user` SET `coll` = `coll` + ? WHERE `id` = ? LIMIT 1", array(1,$medal10['id']));
//
//
$medal11 = DB::$dbs->queryFetch("SELECT * FROM `medal_user` WHERE `id_task` = ? AND `id_user` = ? LIMIT 1", array(21,$user['id']));
if($medal11['check'] == 0)DB::$dbs->query("UPDATE `medal_user` SET `coll` = `coll` + ? WHERE `id` = ? LIMIT 1", array(1,$medal11['id']));

//
//
$it = '<div class="stats2"></div><a href="/bag/"><font color="'.$color[$item['set']].'">'.$item['name'].'</font></a>';
//
//
}
//
//
?>