Файл: core/league.php
Строк: 189
<?
require_once 'core/system.php';
echo only_reg();
if(!$user) {
header('location: /');
exit;
}
$league = array( '', 'новичков', 'опытных', 'претендентов', 'мастеров', 'титанов', 'избранных' );
$header = 'Лига ' . $league[$user['league']];
require_once 'core/head.php';
echo '<div class='title'><span style='float: right;'>' . $user['league_place'] . ' место</span>Лига ' . $league[$user['league']] . '</div>
<div class='line'></div>';
if ( isset($_GET['attack']) && ereg('^[0-9]', $_GET['attack']) ) {
if ( $user['league_place'] == 1 ) {
$query = mysql_query( ' SELECT * FROM `user` WHERE `league` = '' . $user['league'] . '' AND `league_place` > '' . $user['league_place'] . '' ORDER BY `league_place` DESC LIMIT 3 ' );
} else {
$query = mysql_query( ' SELECT * FROM `user` WHERE `league` = '' . $user['league'] . '' AND `league_place` < '' . $user['league_place'] . '' ORDER BY `league_place` DESC LIMIT 3 ' );
}
if ( mysql_num_rows( $query ) != 0 ) {
$rows = array();
while ( $row = mysql_fetch_array( $query ) )
{
$rows[] = $row['league_place'];
}
if ( !in_array( $_GET['attack'], $rows ) )
{
header( 'location: /league.php');
exit;
}
}
else
{
header( 'location: /league.php' );
exit;
}
$query = mysql_query( 'SELECT * FROM `user` WHERE `league` = '' . $user['league'] . '' AND `league_place` = '' . $_GET['attack'] . '' AND `league_place` != '' . $user['league_place'] . '' ' );
if ( mysql_num_rows( $query ) == 0 OR $user['league_fights'] == 0 )
{
header( 'location: /league.php' );
exit;
}
$opponent = mysql_fetch_array( $query );
if ( $user['mana'] < 50 OR $user['health'] < ( ( ($user['lovk'] * 2) / 100 ) * 10 ) )
{
}
else
{
$dmg = 0;
$opponent_dmg = 0;
for ( $i = 1; $i < 6; $i++ )
{
$dmg += ceil( rand( ( $user['sila'] / 6 ), ( $user['sila'] / 4 ) ) );
$crit = ( ( rand( 1, 2 ) * ( $user['zashit'] / 100 ) ) - ( rand( 1, 2 ) * ( $opponent['zashit'] / 100 ) ) );
if ( mt_rand( 0, 100 ) <= $crit )
{
$dmg *= 2;
}
$dodge = ( ( rand( 1, 2 ) * ( $opponent['lovk'] / 100 ) ) - ( rand( 1 ,2 ) * ( $user['lovk'] / 100 ) ) );
if ( mt_rand( 0, 100 ) <= $dodge )
{
$dmg = 0;
}
$dmg -= ceil( rand( ( $opponent['zashit'] / 12 ), ( $opponent['zashit'] / 7 ) ) );
$opponent_dmg += ceil( rand( ( $opponent['sila'] / 6 ), ( $opponent['sila'] / 4 ) ) );
if($opponent_dmg < 0) {
$opponent_dmg = 0;
}
$opponent_crit = ( ( rand( 1, 2 ) * ( $opponent['lovk'] / 100 ) ) - ( rand( 1, 2 ) * ( $user['lovk'] / 100 ) ) );
if ( mt_rand( 0, 100 ) <= $opponent_crit )
{
$opponent_dmg *= 2;
}
$opponent_dodge = ( ( rand( 1, 2 ) * ( $user['lovk'] / 100 ) ) - ( rand( 1, 2 ) * ( $opponent['lovk'] / 100 ) ) );
if ( mt_rand( 0, 100 ) <= $opponent_dodge )
{
$opponent_dmg = 0;
}
$opponent_dmg -= ceil( rand( ( $user['zashit'] / 12 ), ( $user['zashit'] / 7 ) ) );
}
if ( $dmg > $opponent_dmg )
{
$_hp = ceil( $opponent_dmg / 4 );
}
else
{
$_hp = ceil( $opponent_dmg / 2 );
}
mysql_query( ' UPDATE `user` SET `health` = `health` - ' . $_hp . ',
`mana` = `mana` - 50 WHERE `id` = '' . $user['id'] . '' ' );
echo '<div class='block'>';
if ( $dmg > $opponent_dmg )
{
if ( $opponent['league_place'] < $user['league_place'] )
{
mysql_query( ' UPDATE `user` SET `league_place` = '' . $user['league_place'] . '' WHERE `id` = '' . $opponent['id'] . '' ' );
mysql_query( ' UPDATE `user` SET `league_place` = '' . $opponent['league_place'] . '' WHERE `id` = '' . $user['id'] . '' ' );
}
$_silver = rand( 1, 100 ) + ( ( rand( 1, 100 ) * $opponent['level'] ) + ( rand( 0, ( 1000 - $user['league_place'] ) ) ) );
$_exp = ( rand( 1, 10 ) * $opponent['level'] ) * rand( 1, ( ( 1000 - $user['league_place'] ) / 100 ) );
echo '<h2 class='dgreen' style='font-weight:bold;'><img src='/images/icon/2hit.png' alt=''/> Победа! <img src='/images/icon/2hit.png' alt=''/></h2>';
}
else
{
$_silver = rand( 1,100 ) + ( ( rand( 1, 100 ) * $opponent['level'] ) );
$_exp = 1;
echo '<h2 class='dred' style='font-weight:bold;'><img src='/images/icon/2hit.png' alt=''/> Поражение! <img src='/images/icon/2hit.png' alt=''/></h2>';
}
if ( $premium )
{
$_exp += ceil( ( $_exp / 100 ) * 25 );
}
echo ' <div class='player'></div>
<img src='/images/icon/silver.png' alt=''/> $_silver серебра <img src='/images/icon/exp.png' alt=''/> $_exp опыта
</div>
</div>
<div class='line'></div>';
mysql_query( ' UPDATE `user` SET `exp` = `exp` + ' . $_exp . ',
`silver` = `silver` + ' . $_silver . ',
`league_fights` = `league_fights` - 1 WHERE `id` = '' . $user['id'] . '' ' );
}
}
else
{
echo '<div class='player' align='center'>
Чем выше место в лиге, тем больше награда!
</div>';
}
if ( $user['league_place'] < 4 )
{
echo '<div class='block'>
<img src='/images//' . $user['league_place'] . '.png' width='50' height='50' style='float:left; margin-right:3px; margin-top:3px;' alt=''/> <span class='yellow'>Поздравляем!</span>
<br/>';
if ( $user['league_place'] == 1 ) echo 'Вы лучший в лиге!';
elseif ( $user['league_place'] == 2 ) echo 'Вы второй в лиге!';
elseif ( $user['league_place'] == 3 ) echo 'Вы третий в лиге!';
echo '<div style='clear: both;'></div>
</div>';
}
echo '<div class='line'></div>
<div class='content'>
<img src='/images/icon/2hit.png' alt=''/> Осталось боев: <b>' . $user['league_fights'] . '</b>
</div>';
if ( $user['league_place'] == 1 )
{
$query = mysql_query( ' SELECT * FROM `user` WHERE `league` = '' . $user['league'] . '' AND `league_place` > '' . $user['league_place'] . '' ORDER BY `league_place` DESC LIMIT 3 ' );
}
else
{
$query = mysql_query( ' SELECT * FROM `user` WHERE `league` = '' . $user['league'] . '' AND `league_place` < '' . $user['league_place'] . '' ORDER BY `league_place` DESC LIMIT 3 ' );
}
if ( mysql_num_rows( $query ) > 0 )
{
$rows = array();
while ( $row = mysql_fetch_array( $query ) )
{
$rows[] = $row['id'];
}
$rows = array_reverse( $rows );
for ( $i = 0; $i < 3; $i++ )
{
$query = mysql_query( ' SELECT * FROM `user` WHERE `id` = '' . $rows[$i] . '' ' );
$opponent = mysql_fetch_array( $query );
echo '<div class='player'>
<span style='float: left;'>
<a href='/league.php?attack=' . $opponent['league_place'] . ''><img src='/manekenimage.php?,' . $opponent['sex'] . ',' . $w_1 . ',' . $w_2 . ',' . $w_3 . ',' . $w_4 . ',' . $w_5 . ',' . $w_6 . ',' . $w_7 . ',' . $w_8 . '' width='120' height='160' style='margin-right:10px; margin-top:3px;' alt=''></a>
</span>
<img src='/images/icon/user.png' alt=''> <b>' . $opponent['league_place'] . '.</b> ' . $opponent['nick'] . '
<br/>
<br/>
<img src='/images/icon/str.png' alt=''> Сила: ' . $opponent['sila'] . '
<br/>
<img src='/images/icon/vit.png' alt=''> Здоровье: ' . $opponent['max_health'] . '
<br/>
<img src='/images/icon/agi.png' alt=''> Ловкость: ' . $opponent['lovk'] . '
<br/>
<img src='/images/icon/def.png' alt=''> Защита: ' . $opponent['zashit'] . '
<br/>
<br/>
<a class='btn' href='/league.php?attack=' . $opponent['league_place'] . ''><span class='end'><span class='label'>Атакoвать</span></span></a>
<div style='clear:both;'></div>
</div>';
if ( $i < 2 ) echo '<div class='line'></div>';
}
}
else
{
}
echo '<div class='line'></div>
<div class='content'>
Ваши параметры:
<br/>
<img src='/images/icon/str.png' alt=''/> ' . $user['sila'] . ' <img src='/images/icon/vit.png' alt=''/> ' . $user['max_health'] . ' <img src='/images/icon/agi.png' alt=''/> ' . $user['lovk'] . ' <img src='/images/icon/def.png' alt=''/> ' . $user['zashit'] . '
</div>
<div class='line'></div>
<div class='list'>
<a href='/arena.php'><img src='/images/icon/arrow.png' alt=''/> Арена</a>
</div>';
require_once 'core/foot.php';
?>