Файл: pesn_voini/peseni_vojni/instalscript/engine/public/adventures/index.php
Строк: 191
<?php
//
//
require_once($_SERVER['DOCUMENT_ROOT']."/instalscript/engine/_inc/sys.php");
//
//
head("Приключение",$uid); # Голова
//
//
$r = rand(1000000,9999999);
//
$energy = number($_GET['energy']);
//
echo logs();
//
//
$fight = fch("SELECT * FROM `adven` WHERE `id_user` = ? LIMIT 1", array($uid)); //проверяем запись в бд
//
if(!$fight){ //нет записи, создаем
qry("INSERT INTO `adven` SET `id_user` = ?", array($uid));
header('location:?r='.$r);
exit();
}
//
//
$boss = fch("SELECT * FROM `adven_boss` WHERE `id` = ? LIMIT 1", array($fight['id_boss'])); //ищем противника
//
$boss2 = fch("SELECT * FROM `adven_boss` WHERE `id` = ? LIMIT 1", array($fight['id_boss']-1)); //ищем противника
//
if(!$boss){ //прошли всех противников, кидаем на последнего
qry("UPDATE `adven` SET `id_boss` = `id_boss` - ? WHERE `id_user` = ? LIMIT 1", array(1,$uid));
header('location:?');
exit();
}
//
//параметры
$pow = rand(2,4);
$pow_mob = rand(2,4);
//
$bot_power = (($fight['power_boss']*15/100)+$pow_mob);
$user_power = (($fight['power']*15/100)+$pow);
//
//
//награда - золото, опыт и серебро
//
//
$sum_gold = $fight['id_boss']*8;
//
$gold2 = $sum_gold*25/100;
//
if(($fight['limit']+$gold2) > $sum_gold){
$gold = ($sum_gold-($fight['limit']));
}else{
$gold = $sum_gold*25/100;
}
//
$nag = rand(4,15);
$nag2 = rand(10,40);
//
$win_exp = ((($fight['id_boss']*50)+$nag)*$user['premium']);
$lose_exp = ((($fight['id_boss']*25)+$nag)*$user['premium']);
//
$win_silver = ((($fight['id_boss']*100)+$nag2)*$user['premium']);
$lose_silver = ((($fight['id_boss']*50)+$nag2)*$user['premium']);
//
//
if($fight['limit'] < $sum_gold){
$info_gold = '<img class = "" src = "/instalscript/images/user/stat/money-gold.gif"> '.$gold.' золота';
}else{
$info_gold = '';
}
//
//
if($fight['hp_boss'] <= 0 && $fight['fight'] != 0){
//
//
if($fight['limit'] < $sum_gold){
qry("UPDATE `users` SET `gold` = `gold` + ? WHERE `id` = ? LIMIT 1", array($gold,$uid));
//
qry("UPDATE `adven` SET `limit` = `limit` + ? WHERE `id_user` = ? LIMIT 1", array($gold,$uid));
}
//
qry("UPDATE `users` SET `silver` = `silver` + ?, `exp` = `exp` + ? WHERE `id` = ? LIMIT 1", array($win_silver,$win_exp,$uid));
//
if($user['start'] == 4){
qry("UPDATE `users` SET `start` = ? WHERE `id` = ? LIMIT 1", array(5,$uid));
}
//
if($fight['reset'] == 0){
qry("UPDATE `adven` SET `fight` = ?, `id_boss` = `id_boss` + ? WHERE `id_user` = ? LIMIT 1", array(0,1,$uid));
}else{
qry("UPDATE `adven` SET `fight` = ?, `reset` = ? WHERE `id_user` = ? LIMIT 1", array(0,0,$uid));
}
qry("DELETE FROM `adven_log` WHERE `tipe` = ? AND `id_user` = ?", array(2,$uid));
qry("DELETE FROM `adven_log` WHERE `tipe` = ? AND `id_user` = ?", array(1,$uid));
//
//
//
msg('<small>Вы выиграли + '.$info_gold.' <img class = "" src = "/instalscript/images/user/stat/money-silver.gif"> '.$win_silver.' серебра, <img class = "" src = "/instalscript/images/user/stat/exp.png" width="14" height="14"> '.$win_exp.' опыта</small>');
//
//
//
//
header('location:?');
exit();
}elseif($fight['hp'] <= 0 && $fight['fight'] != 0){
//
//
if($fight['limit'] < $sum_gold){
qry("UPDATE `users` SET `gold` = `gold` + ? WHERE `id` = ? LIMIT 1", array($gold,$uid));
//
qry("UPDATE `adven` SET `limit` = `limit` + ? WHERE `id_user` = ? LIMIT 1", array($gold,$uid));
}
//
//
qry("UPDATE `users` SET `silver` = `silver` + ?, `exp` = `exp` + ? WHERE `id` = ? LIMIT 1", array($lose_silver,$lose_exp,$uid));
//
//
if($user['start'] == 1){
qry("UPDATE `users` SET `start` = ? WHERE `id` = ? LIMIT 1", array(2,$uid));
}
//
//
qry("UPDATE `adven` SET `fight` = ?, `reset` = ? WHERE `id_user` = ? LIMIT 1", array(0,0,$uid));
qry("DELETE FROM `adven_log` WHERE `tipe` = ? AND `id_user` = ?", array(2,$uid));
qry("DELETE FROM `adven_log` WHERE `tipe` = ? AND `id_user` = ?", array(1,$uid));
//
//
//
err('<small>Вы проиграли + '.$info_gold.' <img class = "" src = "/instalscript/images/user/stat/money-silver.gif"> '.$lose_silver.' серебра, <img class = "" src = "/instalscript/images/user/stat/exp.png" width="14" height="14"> '.$lose_exp.' опыта</small>');
//
//
//
header('location:?');
exit();
}
//
if(isset($_GET['attack']) && $fight['fight'] != 0){
//
qry("UPDATE `adven` SET `hp_boss` = `hp_boss` - ?, `hp` = `hp` - ? WHERE `id_user` = ? LIMIT 1", array($user_power,$bot_power,$uid));
//
qry("INSERT INTO `adven_log` SET
`id_user` = ?,
`tipe` = ?,
`uron` = ?
", array($uid,2,$user_power));
//
qry("INSERT INTO `adven_log` SET
`id_user` = ?,
`tipe` = ?,
`uron` = ?
", array($uid,1,$bot_power));
//
header('location:?');
exit();
}
//
//
if(isset($_GET['list']) && $fight['fight'] == 0){
//
//
//
$count = $BaseConnect->query("SELECT (id) FROM `adven_boss` WHERE `id` >= '1'")->rowCount();
//
$q = $BaseConnect->query("SELECT * FROM `adven_boss` WHERE `id` >= '1' ORDER BY `id` DESC LIMIT $count");
//
//
?><center>Список противников:</center><?
//
//if($count == 0)echo '<center>Нет новых записей</center>';
//
while($post = $q->fetch(PDO::FETCH_ASSOC)){
//
//$bot_power = ($post['power']*15/100);
//
?><div class="message"><div class="ohh"><img class = 'money' src = '/instalscript/images/icons/adven/<? echo $post['id']; ?>.jpg' width="50" height="50"></div>
<img class = '' src = '/instalscript/images/icons/city/arena.png' width="16" height="16"> <b><font color="tomato"><? echo $post['name']; ?></font></b><br><img class = 'money' src = '/instalscript/images/user/stat/power.png'> <? echo $post['power']; ?> <img class = 'money' src = '/instalscript/images/user/stat/block.png'> <? echo $post['block']; ?> <img class = 'money' src = '/instalscript/images/user/stat/hp.png'> <? echo $post['hp']; ?><br><br></div>
<?
}
//
?>
<div class = 'hr'></div>
<div class = 'message'>
<a href = '?'>Вернуться назад</a>
</div>
<?
//
foot($uid);
exit();
}
//
//
if($fight['fight'] != 0){
//
?>
<div class="message"> <div class="ohh"><img class = 'money' src = '/instalscript/images/icons/adven/<? if($fight['reset'] != 0)echo $boss2['id']; else echo $boss['id']; ?>.jpg' width="50" height="50"></div><img class = '' src = '/instalscript/images/icons/city/arena.png' width="16" height="16">
<? if($fight['reset'] != 0)echo $boss2['name']; else echo $boss['name']; ?><br><img class = 'money' src = '/instalscript/images/user/stat/power.png'> <? echo $fight['power_boss']; ?> <img class = 'money' src = '/instalscript/images/user/stat/block.png'> <? echo $fight['block_boss']; ?> <img class = 'money' src = '/instalscript/images/user/stat/hp.png'> <? echo $fight['hp_boss']; ?> <br><br>
</div>
<a class = 'lnk ma cntr' href = '?attack'>Атаковать</a>
<div class="message">
<? echo user_list($uid); ?><br><img class = 'money' src = '/instalscript/images/user/stat/power.png'> <? echo $fight['power']; ?> <img class = 'money' src = '/instalscript/images/user/stat/block.png'> <? echo $fight['block']; ?> <img class = 'money' src = '/instalscript/images/user/stat/hp.png'> <? echo $fight['hp']; ?>
</div>
<?
//
//
require_once($_SERVER['DOCUMENT_ROOT']."/instalscript/engine/public/adventures/log.php");
//
foot($uid);
exit();
//
}else{
//
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:?');
exit();
}
//
//
if($energy == 1)echo '<div class="message cntr">Вы уверены что хотите восстановить энергию за <img class = "money" src = "/instalscript/images/user/stat/money-gold.gif"> 15 золота?<br><a href="?energy=2">Восстановить</a> - <a href="?">Нет, передумал</a></div>';
//
//
if(isset($_GET['fight']) && $fight['fight'] != 1){
//
if($user['energy'] <= 9){
err("<small>Недостаточно энергии - <a href='?energy=1'>[Восстановить]</a></small>");
header('location:?');
exit();
}
//
//
$q_1 = fch("SELECT * FROM `quest_user` WHERE `id_quest` = ? AND `id_user` = ? LIMIT 1", array(6,$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(7,$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(8,$uid));
if($q_3['last'] < time())qry("UPDATE `quest_user` SET `koll` = `koll` + ? WHERE `id` = ? LIMIT 1", array(1,$q_3['id']));
//
//
//
qry("UPDATE `adven` SET
`power` = ?,
`block` = ?,
`hp` = ?,
`power_boss` = ?,
`block_boss` = ?,
`hp_boss` = ?,
`fight` = ?
WHERE `id_user` = ? LIMIT 1",
array($user['power'],
$user['block'],
$user['health'],
$boss['power'],
$boss['block'],
$boss['hp'],
1,
$uid));
//
qry("UPDATE `users` SET `energy` = `energy` - ? WHERE `id` = ? LIMIT 1", array(10,$uid));
//
header("location:?r=".$r);
exit();
}
//
//
//
if($user['start'] == '2')echo '<div class="message cntr">Ты еще слишком слаб, нужно это исправить!<br>Задача: Возвращайтесь в город</div>';
if($user['start'] == '3')echo '<div class="message cntr">Отлично!<br>Теперь загляни в свой рюкзак и надень всё снаряжение!</div>';
if($user['start'] == '4')echo '<div class="message cntr">Когда твоя сила возросла, ты сможешь победить волка!<br>Задача: Сразитесь 1 раз в приключении</div>';
if($user['start'] == '5')echo '<div class="message cntr">В этом мире без ресурсов не выжить, самое время грабежей!<br>Задача: Возвращайтесь в город</div>';
//
?>
<div class="cntr"><img class = '' src = '/instalscript/images/icons/city/arena.png' width="16" height="16"> <b><? echo $boss['name']; ?></b> <img class = '' src = '/instalscript/images/icons/city/arena.png' width="16" height="16"><br><img class = 'money' src = '/instalscript/images/icons/adven/<? echo $boss['id']; ?>.jpg' width="180" height="180"><br><small><img class = 'money' src = '/instalscript/images/user/stat/power.png'> <? echo $boss['power']; ?> <img class = 'money' src = '/instalscript/images/user/stat/block.png'> <? echo $boss['block']; ?> <img class = 'money' src = '/instalscript/images/user/stat/hp.png'> <? echo $boss['hp']; ?></small></div>
<br>
<a class = 'lnk ma cntr' href = '?fight'>Атаковать <img class = 'money' src = '/instalscript/images/user/stat/energy.png' width='14' height='14'>10</a>
<br><div class="hr"></div><div class="message cntr">Получено сегодня: <img class = 'money' src = '/instalscript/images/user/stat/money-gold.gif'> <? echo $fight['limit']; ?> из <? echo $fight['id_boss']*8; ?></div>
<div class="message cntr">Победите <b><? echo $boss['name']; ?></b>, чтобы открыть следующего противника</div><div class="hr"></div>
<?
//
}
//
foot($uid);
?>