<?
$tavf = fch("SELECT * FROM `tavern_fight` WHERE `id_user` = ? LIMIT 1", array($uid)); 
//
//
$power_opp = rand(round($tavf['bot_power']/4), round($tavf['bot_power']/3));
$block_opp = rand(round($tavf['bot_block']/10), round($tavf['bot_block']/8));
//
//
$power = rand(round($tavf['power']/4), round($tavf['power']/3));
$block = rand(round($tavf['block']/10), round($tavf['block']/8));
//
//
$power_opp = $power_opp - $block;
if($power_opp < 0)$power_opp = 0;
$power = $power - $block_opp ;
if($power < 0)$power = 0;
//
//
if(isset($_GET['attack'])){
//
//
if($power >= $tavf['bot_hp']){ //win
//
//
qry("UPDATE `users` SET `exp` = `exp` + ? WHERE `id` = ? LIMIT 1", array(30,$uid)); 
//
//
qry("UPDATE `tavern` SET `id_quest` = ?, `level` = ? WHERE `id_user` = ? LIMIT 1", array(4,5,$uid)); 
//
//
msg2("Вы победили!");
//
//
}
//elseif($power_opp >= $tavf['hp']){ //lose
//
//
//msg2("Вы проиграли, наденьте снаряжение!");
//
//
//}
//
//
qry("UPDATE `tavern_fight` SET `hp` = `hp` - ?, `bot_hp` = `bot_hp` - ? WHERE `id_user` = ? LIMIT 1", array($power_opp,$power,$uid)); 
//
//
header('location:?');
exit();
}
?>
<div class="tophead">
<div class = "ohh">
<img class='imgSkill' src = '/images/tavern/nps2.png' widht='44' height='44'>
</div>
<span class="orange">
Оруженосец
</span>
<br>
<img src="/images/power.png"> <?=$tavf['bot_power'];?> 
<img src="/images/block.png"> <?=$tavf['bot_block'];?> 
<img src="/images/health.png"> <?=$tavf['bot_hp'];?>

<div class="hrs"></div>
   <div class="progress-bar exp">
                                    <div style="width:<? echo ''.round($tavf['bot_hp']/$tavf['bot_power']*100,1).''; ?>%;" class="progress _red"></div>
                                </div>

</div>
<div class="list2 cntr"><div class="hrs"></div><a href="?attack" class=""><img class='imgSkill' src = '/images/attack.png' widht='40' height='40'></a><div class="hrs"></div></div>

<div class="tophead">
<div class = "ohh">
<img class="imgSkill" src="/images/avatar/<?=$user['sex'];?>/<?=$user['avatar'];?>.png" width="40" height="40" alt="*">
</div>
<span class="orange">
<?=$user['login'];?>
</span>
<br>
<img src="/images/power.png"> <?=$tavf['power'];?> 
<img src="/images/block.png"> <?=$tavf['block'];?> 
<img src="/images/health.png"> <?=$tavf['hp'];?>

<div class="hrs"></div>
   <div class="progress-bar exp">
                                    <div style="width:<? echo ''.round($tavf['hp']/$tavf['power']*100,1).''; ?>%;" class="progress _red"></div>
                                </div>

</div>