Файл: 3/dragon.php
Строк: 225
<?php
require_once ('system/func.php');
$title = 'Дракон';
require_once ('system/header.php');
auth(); // Закроем от гостей
?>
<style>
.enemy-hp2 {
position: relative;
overflow: hidden;
margin-left: 3px;
margin-top: 5px;
height: 4px;
background: none repeat scroll 0% 0% #2B2B2B;
border: 2px solid #000;
}
.enemy-hp-remain2 {
float: left;
height: 4px;
}
.hp-green {
background: none repeat scroll 0% 0% #0D6822 !important;
}
</style>
<?
$df1= round(rand($user['def']/15,$user['def']/17));
$drag_def = round(rand($df1,$df2));
$my_atk = round(rand($user['str']/6,$user['str']/4)-$drag_def);
if ($my_atk<1)
{
$my_atk = $user['level']+rand($user['level'],$user['level']/2);
}
$dragon = mysql_fetch_assoc(mysql_query("SELECT * FROM `dragon` ORDER BY `id` LIMIT 1"));
if($dragon['health']==0){
echo '<div class="main"><div class="block_zero center"><center><img src="/images/icon/arena.png">
<font color="green">Легон повержен! Теперь Ждите 24часов покаместь он воскреснит</font></div></div></center>';
require_once ('system/footer.php');
exit;
}
if($my_atk >$dragon['health'] && $dragon['health']>0)
{
mysql_query("UPDATE `dragon` SET `health`=0 WHERE `id`='".$dragon['id']."'")or die (mysql_error());
echo '<div class="content"><img src="images/dragon/1.png">
Король повержен! Теперь ждите 5часов покаместь он воскреснит</div>';
require_once ('system/footer.php');
$total = mysql_result(mysql_query("SELECT COUNT(*) FROM `dragon_log`"),0);
if($total>0){
$q_nagr = mysql_query("SELECT * FROM `dragon_log` GROUP BY `user_id` ORDER BY RAND()");
/*3 лучших */
$top_q = mysql_query("SELECT SUM( uron ) , `user_id` FROM `dragon_log` GROUP BY `user_id` ORDER BY SUM( uron ) DESC LIMIT 3");
$topes_us = 'Лучшие в бою с Король:<br> ';
while($top= mysql_fetch_assoc($top_q)){
$max_uron = mysql_result(mysql_query("SELECT SUM( uron ) FROM `dragon_log` WHERE `user_id`='".$top['user_id']."'"),0);
$moneyReward = $max_uron/20;
mysql_query("UPDATE `users` SET `g`=`g`+".$moneyReward." WHERE `id`='".$top['user_id']."'");
mysql_query("UPDATE `users` SET `exp`=`exp`+".$dragon['exp'].", `g`=`g`+".$moneyReward*rand(2,3)." WHERE `id`='".$top['user_id']."'");
$name_top = mysql_fetch_assoc(mysql_query("SELECT `login` FROM `users` WHERE `id`='".$top['user_id']."' LIMIT 1"));
$topes_us.= '<span class="login">'.$name_top['login'].'</span>('.$max_uron.'- <img src="images/icon/gold.png"> '.$dragon['g'].')<br>';
$dragon['g']=$dragon['g']-4;
$dragon['exp']= round($dragon['exp']/2);
}
mysql_query("INSERT INTO `chat` SET
`user_id`='1',
`text`='".$topes_us."',
`time`='".time()."'");
while($nagr = mysql_fetch_assoc($q_nagr)){
mysql_query("INSERT INTO `journal` SET
`user_id`='".$nagr['user_id']."', `text`='За победу Легеона Вы получаете <img src="images/icon/gold.png"> ".$dragon['g']."',
`time`='".time()."'");
//Награда
//mysql_query("UPDATE `users` SET `g`=`g`+".$dragon['g'].",`journal`=`journal`+1 WHERE `id`='".$nagr['user_id']."'");
$dragon['g']= round($dragon['g']/2);
mysql_query("DELETE FROM `dragon_log` WHERE `user_id`='".$nagr['user_id']."'");
}
mysql_query("TRUNCATE TABLE `dragon_log`");
}
include './system/f.php';
exit;
}
$dragon['health'] = $dragon['health']-$my_atk;
$dragon_sl = array('ткнул в глаз','нанес урон','порезал','ударил','царапнул');
shuffle($dragon_sl);
$rand_m = rand(1,15);
if($user['mana']<15 ){
?>
<div class ='content'/>
<center>
<h2 class ='dred'/> Вы устали!</h2>
</center>
Восстановите ману!
</div>
<?
include './system/f.php';
exit;
}
/**
* Атака написанная не таким ГК
* @author vk.com/elfi68
*/
if (isset($_GET['attack']))
{
mysql_query("INSERT INTO `dragon_log` SET
`user_id`='".$user['id']."',
`text`='".$dragon_sl[0]." <b>Король</b> на <b>".$my_atk."</b>',
`time`='".time()."',
`uron`='".$my_atk."'");
mysql_query("UPDATE `dragon` SET `health`=`health`-".$my_atk." WHERE `id`='".$dragon['id']."'");
mysql_query("UPDATE `users` SET `mana`=`mana`-".$rand_m.",`mana_resp`='".time()."' WHERE `id`='".$user['id']."'");
$all_uron = mysql_result(mysql_query("SELECT SUM( uron )FROM `dragon_log` WHERE `user_id`='".$user['id']."'"),0);
$perc_health_dragon = round($dragon['health']/$dragon['max_health']*100,2);
header("Location:?");
exit;
}
$dragon_progress = round(100/($dragon['max_health']/$dragon['health']));
echo '
<div class="content">
<center><img src="http://m.vten.ru/animations/dungeons/uroboros/back.jpg" width = "auto"><br>
</div>
<div class="line"></div>
<div class="content">
Я легеон вы всё думаете меня убить?
</div>
<div class="line"></div>
<div class="content">
<div class="enemy-hp2">
<div class="enemy-hp-remain2 hp-green" style="width:'.$dragon_progress.'%"></div>
</div>
<center>Здоровье:
<font color="green">
'.$dragon['health'].'
</font>
/
<font color="green">
'.$dragon['max_health'].'
</font>
</div>
<div class="line"></div>
<div class="list">
<li><a href="?attack" style ="display:block;">
<img src="http://m.vten.ru/images/icons/sword1.png"/>
Бить Короля Титанов!
</a>
</li>
</span>
</span>
';
$dragon_log_q = mysql_query("SELECT * FROM `dragon_log` ORDER BY `time` DESC LIMIT 5");
echo '</div>';
$self = '/dragon';
$inFight = mysql_num_rows(mysql_query("SELECT `id`,`self` FROM `users`
WHERE `self`='".($self)."' and
`online`>'".(time()-300)."'"));
?>
<div class ='line'/></div>
<div class ='content'/>
<center/>
В бою <?=$inFight;?> титанов, против Легеона
</center>
</div>
<?
echo '
<div class ="line"/></div>
<div class="content"><center>Журнал боя
</center>
</div>
<div class ="line"/></div>';
while($dragon_log = mysql_fetch_array($dragon_log_q))
{
$row = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id`='".$dragon_log['user_id']."'"));
//echo '<a href="user.php?ank='.$ank['id'].'">'.$ank['login'].'</a> '.$aluko_log['text'].'<br>';
?>
<div class ='content'/>
<span class ='float:left;'/>
<img src='/images/icon/race/<?=$row['r'].($row['online'] > (time() - 300) ? '':'-off')?>.png' alt='*'/>
<a href='/user/<?=$row['id']?>/'>
<?=$row['login']?>
</a>
</span>
|
<?=$dragon_log['text'];?>
</div>
<div class ='line'/></div>
<?
}
/**
* Вывод лидеров в бою!
*
*@author vk.com/elfi68
*/
$queryLiders = mysql_query("SELECT SUM( uron ) , `user_id` FROM `dragon_log`
GROUP BY `user_id`
ORDER BY SUM( uron ) DESC LIMIT 3");
?>
<div class ='content'/>
<center>
Топ 3 бойцов:
</center>
</div>
<div class ='line'/>
</div>
<?
$alPos = 0;
while ($liders = mysql_fetch_array($queryLiders))
{
$alPos++;
$row = mysql_fetch_array(mysql_query("SELECT * FROM `users`
WHERE `id`='".$liders['user_id']."'"));
$damageUs = mysql_result(mysql_query("SELECT SUM( uron ) , `user_id`
FROM `dragon_log`
WHERE `user_id`='".$liders['user_id']."'"),0);
?>
<div class ='content'/>
<span class ='float:left;'/>
<?=$alPos;?>.<img src='/images/icon/race/<?=$row['r'].($row['online'] > (time() - 300) ? '':'-off')?>.png' alt='*'/>
<a href='/user/<?=$row['id']?>/'>
<?=$row['login'];?>
</a>
</span>
<span class ='float:right;'/>
<?=$damageUs;?>
</span>
</div>
<div class ='dl'/></div>
<?
}
require_once ('system/footer.php');
?>