Файл: pesn_voini/peseni_vojni/instalscript/engine/public/raid/index.php
Строк: 138
<?php
//
//
require_once($_SERVER['DOCUMENT_ROOT']."/instalscript/engine/_inc/sys.php");
//
//
head("Грабежи",$uid); # Голова
//
//
$r = rand(1000000,9999999);
//
//
echo logs();
//
//
//
//
$fight = fch("SELECT * FROM `raid_fight` WHERE `id_user` = ? LIMIT 1", array($uid));
//
$raid = fch("SELECT * FROM `users` WHERE `save` != ? AND `id` != ? ORDER BY RAND() LIMIT 1", array(0,$uid));
//
$usr = fch("SELECT * FROM `users` WHERE `id` = ? LIMIT 1", array($fight['id_opp']));
//
$search = number($_GET['search']);
$opp = number($_GET['opp']);
$energy = number($_GET['energy']);
//
$opp_item = fch("SELECT * FROM `users` WHERE `id` = ? LIMIT 1", array($opp));
//
if($opp_item['id'] <= 0){
header('location:?search=1&opp='.$raid['id'].'');
exit();
}
//
if($fight != null && $fight['time'] <= time()){
//
qry("DELETE FROM `raid_fight` WHERE `id` = ?", array($fight['id']));
//
header('location: ?r='.$r);
exit();
}
//
//
//
//
//
$rand = rand(1,5);
$exp1 = rand(15,40);
//
$exp = $exp1*$user['premium'];
//
//
//
//Бой
if($fight != null){
//
//
//
//параметры
$pow = rand(2,6);
$pow_mob = rand(2,6);
//
$bot_power = (($fight['bot_power']*15/100)+$pow_mob);
$user_power = (($fight['user_power']*15/100)+$pow);
//
//
//
$win = intval($usr['silver']*10/100);
if($usr['silver'] <= 9)$win = 1;
//
//
//
//
###АТАКА НАЧАЛО
//
if(isset($_GET['attack_opp'])){
//
//
qry("INSERT INTO `raid_log` SET
`id_user` = ?,
`tipe` = ?,
`uron` = ?
", array($uid,1,$bot_power));
//
//
qry("INSERT INTO `raid_log` SET
`id_user` = ?,
`tipe` = ?,
`uron` = ?
", array($uid,2,$user_power));
//
//
qry("UPDATE `raid_fight` SET `user_health` = `user_health` - ?, `bot_health` = `bot_health` - ? WHERE `id` = ? LIMIT 1", array($bot_power,$user_power,$fight['id']));
//
//
if($user['start'] == 5){
qry("UPDATE `users` SET `start` = ? WHERE `id` = ? LIMIT 1", array(6,$uid));
}
//
//
if($user_power >= $fight['bot_health']){
//
qry("UPDATE `users` SET `silver` = `silver` + ?, `exp` = `exp` + ? WHERE `id` = ? LIMIT 1", array($win,$exp,$uid));
//
if($usr['silver'] >= 1){
qry("UPDATE `users` SET `silver` = `silver` - ? WHERE `id` = ? LIMIT 1", array($win,$fight['id_opp']));
}
//
qry("DELETE FROM `raid_fight` WHERE `id` = ?", array($fight['id']));
qry("DELETE FROM `raid_log` WHERE `tipe` = ? AND `id_user` = ?", array(2,$uid));
qry("DELETE FROM `raid_log` WHERE `tipe` = ? AND `id_user` = ?", array(1,$uid));
//
//
//
msg('<small>Вы выиграли + <img class = "" src = "/instalscript/images/user/stat/money-silver.gif"> '.$win.' серебра, <img class = "" src = "/instalscript/images/user/stat/exp.png" width="14" height="14"> '.$exp.' опыта</small>');
//
//
//
}
//
elseif($bot_power >= $fight['user_health']){
//
//
//
qry("UPDATE `users` SET `silver` = `silver` + ? WHERE `id` = ? LIMIT 1", array(1,$uid));
//
//
//
qry("DELETE FROM `raid_fight` WHERE `id` = ?", array($fight['id']));
qry("DELETE FROM `raid_log` WHERE `tipe` = ? AND `id_user` = ?", array(2,$uid));
qry("DELETE FROM `raid_log` WHERE `tipe` = ? AND `id_user` = ?", array(1,$uid));
//
//
//
err('<small>Вы проиграли + <img class = "" src = "/instalscript/images/user/stat/money-silver.gif"> 1 серебра</small>');
//
//
//
}
//
//
//
header("location:?search=1&opp=".$raid['id']."&".$r);
exit();
}
//
//
###АТАКА КОНЕЦ
//
//
//
//
?>
<div class="message">
<? echo user_list($fight['id_opp']); ?><br><img class = 'money' src = '/instalscript/images/user/stat/power.png'> <? echo $fight['bot_power']; ?> <img class = 'money' src = '/instalscript/images/user/stat/block.png'> <? echo $fight['bot_block']; ?> <img class = 'money' src = '/instalscript/images/user/stat/hp.png'> <? echo $fight['bot_health']; ?>
</div>
<a class = 'lnk ma cntr' href = '?search=1&opp=<? echo $fight['id_opp']; ?>&attack_opp'>Атаковать</a>
<div class="message">
<? echo user_list($uid); ?><br><img class = 'money' src = '/instalscript/images/user/stat/power.png'> <? echo $fight['user_power']; ?> <img class = 'money' src = '/instalscript/images/user/stat/block.png'> <? echo $fight['user_block']; ?> <img class = 'money' src = '/instalscript/images/user/stat/hp.png'> <? echo $fight['user_health']; ?>
</div>
<?
//
require_once($_SERVER['DOCUMENT_ROOT']."/instalscript/engine/public/raid/log.php");
//
foot($uid);
exit();
//
//Запись на бой
}
else{
//
//
//Ищем противника
//
//
if(isset($_GET['attack']) && $opp >= 1){
//
//
if($user['energy'] <= 9){
err("Недостаточно энергии - <a href='?search=1&opp=".$opp_item['id']."&energy=1'>[Восстановить]</a>");
header('location:?search=1&opp='.$opp_item['id'].'');
exit();
}
//
$q_1 = fch("SELECT * FROM `quest_user` WHERE `id_quest` = ? AND `id_user` = ? LIMIT 1", array(3,$uid));
if($q_1['last'] < time())qry("UPDATE `quest_user` SET `koll` = `koll` + ? WHERE `id` = ? LIMIT 1", array(1,$q_1['id']));
//
//
$q_2 = fch("SELECT * FROM `quest_user` WHERE `id_quest` = ? AND `id_user` = ? LIMIT 1", array(4,$uid));
if($q_2['last'] < time())qry("UPDATE `quest_user` SET `koll` = `koll` + ? WHERE `id` = ? LIMIT 1", array(1,$q_2['id']));
//
//
$q_3 = fch("SELECT * FROM `quest_user` WHERE `id_quest` = ? AND `id_user` = ? LIMIT 1", array(5,$uid));
if($q_3['last'] < time())qry("UPDATE `quest_user` SET `koll` = `koll` + ? WHERE `id` = ? LIMIT 1", array(1,$q_3['id']));
//
//
qry("INSERT INTO `raid_fight` SET
`id_user` = ?,
`id_opp` = ?,
`user_power` = ?,
`user_block` = ?,
`user_health` = ?,
`bot_power` = ?,
`bot_block` = ?,
`bot_health` = ?,
`time` = ?", array(
$uid,
$opp_item['id'],
$user['power'],
$user['block'],
$user['health'],
$opp_item['power'],
$opp_item['block'],
$opp_item['health'],
time()+3600)); //создаем бой
//
qry("UPDATE `users` SET `energy` = `energy` - ? WHERE `id` = ? LIMIT 1", array(10,$uid));
//
header("location:?".$r);
exit();
}
//
//
if($search <= 0){
header('location:?search=1&opp='.$raid['id'].'');
exit();
}
//
//
if($opp <= 0){
header('location:?search=1&opp='.$raid['id'].'');
exit();
}
//
//
if($search == 1 && $opp_item != 0){
//
if($user['start'] == '5')echo '<div class="message cntr">В этом мире без ресурсов не выжить, самое время грабежей!<br>Задача: Совершите 1 грабеж</div>';
if($user['start'] == '6')echo '<div class="message cntr">На этом ваше обучение закончено!</div>';
//
if($energy == 2 && $user['energy'] < $user['energy_max']){
if($user['gold'] >= 15){
qry("UPDATE `users` SET `gold` = `gold` - ?, `energy` = ? WHERE `id` = ? LIMIT 1", array(15,$user['energy_max'],$uid));
msg("Энергия успешно восстановлена!");
}else{
err("Недостаточно золота - <a href='/paywk/'>[Купить]</a>");
}
header('location:?search=1&opp='.$opp_item['id'].'');
exit();
}
//
//
if($energy == 1)echo '<div class="message cntr">Вы уверены что хотите восстановить энергию за <img class = "money" src = "/instalscript/images/user/stat/money-gold.gif"> 15 золота?<br><a href="?search=1&opp='.$opp_item['id'].'&energy=2">Восстановить</a> - <a href="?search=1&opp='.$opp_item['id'].'">Нет, передумал</a></div>';
//
$param_1 = $opp_item['power']+$opp_item['block']+$opp_item['health'];
$param_2 = $user['power']+$user['block']+$user['health'];
if($param_1 > $param_2){
$param = "<font color='red'>Сильнее</font>";
}
elseif($param_1 < $param_2){
$param = "<font color='lime'>Слабее</font>";
}
elseif($param_1 == $param_2){
$param = "<font color='lime'>Ровны</font>";
}
//
//
//
echo "<center><b>".$opp_item['login']."</b></center>
<table>
";
echo "
<td class = 'rht blck'>
<div class = 'items-list'>
";
for($i = 1;$i < 5;$i++){
$it = fch("SELECT * FROM `inv` WHERE `id_user` = ? AND `type` = ? AND `yes` = ? ", array($opp,$i,"1"));
if($it == false){
$img = "/instalscript/images/items/empty/".$i.".jpg";
}
else{
$img = "/instalscript/images/items/class/icons/".$opp_item['class']."/".$it['set']."/".$it['type'].".jpg";
}
echo "
<div class = 'items-icons'>
<a class = 'items-link' href = '/item/?id=".$opp."&view=".$it['id']."'>
<span class = 'items-icons-view' style = 'background-image:url(".$img.")'></span>
</a>
</div>
<br>
";
}
echo"
</div>
</td>
";
echo "
<td class = 'cntr'>
<img class = '' src = '/instalscript/images/user/race/".($opp_item['side'] == '0' ? "alliance" : "horde")."/".$opp_item['race']."/".$opp_item['sex'].".png' width='180' height='200'>
<div class = 'class ".$opp_item['class']."'></div>
</td>";
echo "
<td class = 'lft blck'>
<div class = 'items-list'>
";
for($i = 5;$i < 9;$i++){
$it = fch("SELECT * FROM `inv` WHERE `id_user` = ? AND `type` = ? AND `yes` = ? ", array($opp,$i,"1"));
if($it == false){
$img = "/instalscript/images/items/empty/".$i.".jpg";
}
else{
$img = "/instalscript/images/items/class/icons/".$opp_item['class']."/".$it['set']."/".$it['type'].".jpg";
}
echo "
<div class = 'items-icons'>
<a class = 'items-link' href = '/item/?id=".$opp."&view=".$it['id']."'>
<span class = 'items-icons-view' style = 'background-image:url(".$img.")'></span>
</a>
</div>
<br>
";
}
echo"
</div>
</td>
";
echo "</table>
<center><img class = 'money' src = '/instalscript/images/user/stat/power.png'> ".$opp_item['power']." <img class = 'money' src = '/instalscript/images/user/stat/block.png'> ".$opp_item['block']." <img class = 'money' src = '/instalscript/images/user/stat/hp.png'> ".$opp_item['health']."<br>Сумма параметров: ".($opp_item['power']+$opp_item['block']+$opp_item['health'])." - ".$param."</center>";
?>
<br>
<a class = 'lnk ma cntr' href = '?search=1&opp=<? echo $opp_item['id']; ?>&attack'>Атаковать <img class = 'money' src = '/instalscript/images/user/stat/energy.png' width='14' height='14'>10</a>
<br>
<center><a class = '' href = '?search=1&opp=<? echo $raid['id']; ?>'><u>Сменить противника</u></a></center><br>
<div class="hr"></div>
<small><div class="message cntr">В случае победы вы заберете <img class = "money" src = "/instalscript/images/user/stat/money-silver.gif"> 10% серебра.</div></small>
<?
//
//
//
foot($uid);
exit();
}
//
//
//
}
//
foot($uid);
?>