Файл: public_html/modules/arena.php
Строк: 104
<?php
$root = $_SERVER['DOCUMENT_ROOT'];
include_once ($root.'/core/base.php');
falseauth();
$header = "Арена";
include_once ($root.'/core/head.php');
if(isset($_GET['attack']))
{
$attack = fl($_GET['attack']);
if($attack == $u['id']) redirect('/arena');
if($u['energy'] < 5) redirect('/arena', 'Вы устали');
$opponentParams = get_health($attack)+get_power($attack)+get_block($attack);
$myParams = get_power($u['id'])+get_health($u['id'])+get_block($u['id']);
if($opponentParams > $myParams)
{
$exp = rand(1,5);
$silver = rand(2,10);
$result = 'Поражение! Награда: '.$exp.' опыта и '.$silver.' серебра!';
}
elseif($opponentParams == $myParams)
{
$rand = rand(1,2);
if($rand == 1)
{
$exp = rand(1,5);
$silver = rand(2,10);
$result = 'Поражение! Награда: '.$exp.' опыта и '.$silver.' серебра!';
}
else
{
$exp = rand(50,250);
$silver = rand(100,500);
$result = 'Победа! Награда: '.$exp.' опыта и '.$silver.' серебра!';
}
}
else
{
$exp = rand(50,250);
$silver = rand(100,500);
$result = 'Победа! Награда: '.$exp.' опыта и '.$silver.' серебра!';
}
$db->query("UPDATE `users` SET `energy` = `energy` - '5' WHERE `id` = '".$u['id']."'");
updateUserStats($u['id'],$exp,$silver,0);
redirect('/arena', $result);
}
$in = "IN(".($u['level']-2).",".($u['level']-1).",".$u['level'].",".($u['level']+1).",".($u['level']+2).")";
$rand_opponent = $db->query("SELECT * FROM `users` WHERE `level` ".$in." AND `id` != '".$u['id']."' ORDER BY RAND()")->fetch_object();
$ifNotEnergy = '<div class="notice_container"><div class = "gborder notice_alert alert-success"> Восстановление вашей усталости происходит каждую минуту (+1)</div></div>';
$expProgressArena = round(($u['energy']*100)/100);
if($expProgressArena > 100) $expProgressArena = 100;
echo ''.($u['energy'] < 100 ? $ifNotEnergy : '').'
<div class = "b">';
echo'
<center>Усталось '.($u['energy']).'/100</center></br>
<div style="height: 8px; border: 1px solid #000; position:relative; border-radius: 4px">
<div style="height: 8px; background: #00A4D9; width:'.$expProgressArena.'%; position: absolute; left: 0px; top: 0px; border-radius: 2px; border-bottom-right-radius: 1px;border-top-right-radius: 1px;">
</div>
</div>
';
echo '
<div class = "title">
<center><big>'.who($rand_opponent->id).'</big></div></center>
';
?>
<center><table class="dummy">
<tr>
<td class="1"><div class="slot">
<? echo"".getWearedItem($rand_opponent->id,'head')." ";?> </td>
<td colspan="2" rowspan="4">
<div class="pic_shd">
<?
echo' '.getAvatar($rand_opponent->id).'';
?>
</div></td>
<td class="1"><div class="slot">
<? echo"".getWearedItem($rand_opponent->id,'weapon')." ";?>
</td></td>
</tr><tr>
<td class="1"><div class="slot">
<? echo"".getWearedItem($rand_opponent->id,'body')." ";?>
</td>
</td>
<td class="1"><div class="slot">
<? echo"".getWearedItem($rand_opponent->id,'boots')." ";?>
</td>
</td>
</tr><tr>
<td class="1"><div class="slot">
<img src="/1-1-1.png" width="40" height="37" alt=""/> </td>
<td class="1"><div class="slot">
<img src="/1-2-0.png" width="40" height="37" alt=""/> </td>
</tr><tr>
<td class="1"><div class="slot">
<img src="/1-3-0.png" width="40" height="37" alt=""/> </td>
<td class="1"><div class="slot">
<img src="/1-4-1.png" width="40" height="37" alt=""/> </td>
</tr>
</table>
<?
echo'
<img src="/images/str.png" width="30px"> '.get_power($rand_opponent->id).'
<img src="/images/def.png" width="30px"> '.get_block($rand_opponent->id).'
<img src="/images/health.png" width="30px"> '.get_health($rand_opponent->id).'
';
?>
</br></br>
<?
echo '
<a href="?attack='.$rand_opponent->id.'"> <input type="submit" value="Бой"> </a>
<a href="?"> <input type="submit" value="Другой"> </a>
</center>
</div>
<div class="notice_container"><div class = "gborder notice_alert alert-success">
Здесь вы можете сразиться с любым воином, которого Вы встретите.</div></div>';
include_once ($root.'/core/foot.php');