@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
trait CaveBots
|
||||
{
|
||||
public static $bots = [
|
||||
1 => 10025,
|
||||
2 => 10026,
|
||||
3 => 10027,
|
||||
4 => 10028,
|
||||
5 => 10031,
|
||||
6 => 10032,
|
||||
7 => 10033,
|
||||
8 => 10034];
|
||||
public static $botnames = [
|
||||
1 => "Паук",
|
||||
2 => "Тарантул",
|
||||
3 => "Гигантская крыса",
|
||||
4 => "Покровитель нечести",
|
||||
5 => "Нечто",
|
||||
6 => "Обезумевший крыс",
|
||||
7 => "Призрак короля крыс ",
|
||||
8 => "Обезумевший палач"];
|
||||
}
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
trait CaveItems
|
||||
{
|
||||
static function getCaveItems($room)
|
||||
{
|
||||
if ($room == 621) {
|
||||
$caveitems[1] = [['id' => 1126, 'from' => 'shop', 'foronetrip' => 0, 'chance' => 50, 'podzem' => 1]];
|
||||
$caveitems[2] = [['id' => 1125, 'from' => 'shop', 'foronetrip' => 0, 'chance' => 40, 'podzem' => 1]];
|
||||
$caveitems[3] = [['id' => 1127, 'from' => 'shop', 'foronetrip' => 0, 'chance' => 15, 'podzem' => 1]];
|
||||
$caveitems[4] = [['id' => 1128, 'from' => 'shop', 'foronetrip' => 0, 'chance' => 5, 'podzem' => 1]];
|
||||
$caveitems[5] = [['id' => 1126, 'from' => 'shop', 'foronetrip' => 0, 'chance' => 60, 'podzem' => 1]];
|
||||
$caveitems[6] = [['id' => 1130, 'from' => 'shop', 'foronetrip' => 0, 'chance' => 7], 'podzem' => 1];
|
||||
$caveitems[7] = [['id' => 1129, 'from' => 'shop', 'foronetrip' => 0, 'chance' => 10, 'podzem' => 1]];
|
||||
$caveitems[8] = [['id' => 1131, 'from' => 'shop', 'foronetrip' => 0, 'chance' => 5, 'podzem' => 1]];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
if (in_array($user->getRoom(), CAVE_ROOMS)) {
|
||||
$cavedata = CAVE_DATA ?? [];
|
||||
$floor = mysql_fetch_row(mysql_query("SELECT `floor` FROM `caveparties` WHERE `user` = '$user[id]' LIMIT 1"));
|
||||
if (!isset($cavedata[$user->getRoom()]['x' . $floor])) {
|
||||
$floor = 1;
|
||||
}
|
||||
}
|
||||
|
||||
$lomka1 = $lomka;
|
||||
|
||||
foreach ($lomka1 as $k => $v) {
|
||||
if ($v < _BOTSEPARATOR_) {
|
||||
if (in_array($user->getRoom(), CAVE_ROOMS)) {
|
||||
mysql_query("UPDATE `caveparties` SET `floor` = $floor, `x` = '" . $cavedata[$user->getRoom()]['x' . $floor] . "', `y` = '" . $cavedata[$user->getRoom()]['y' . $floor] . "', `dir` = '" . $cavedata[$user->getRoom()]['dir' . $floor] . "', `loses` = (`loses`+1) WHERE `user` = '$v' LIMIT 1");
|
||||
}
|
||||
if ($user['laba'] > 0) {
|
||||
mysql_query('UPDATE `users` SET `x` = `xf`, `y` = `yr` WHERE `id` = "' . $v . '" LIMIT 1');
|
||||
exit('Suka');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
function getchance($p)
|
||||
{
|
||||
if (mt_rand(1, 100) <= $p) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
function cavesys($text)
|
||||
{
|
||||
global $user;
|
||||
if ($fp = @fopen("tmp/chat.txt", "a")) {
|
||||
flock($fp, LOCK_EX);
|
||||
fputs($fp, ":[" . time() . "]:[!cavesys!!]:[$text]:[$user[caveleader]]\r\n");
|
||||
fflush($fp);
|
||||
flock($fp, LOCK_UN);
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
|
||||
if (in_array($user->getRoom(), CAVE_ROOMS)) {
|
||||
include("CaveItems.php");
|
||||
mysql_query('LOCK TABLES `cavebots` WRITE, `caveitems` WRITE, `shop` WRITE, `caveparties` WRITE');
|
||||
$location = mysql_fetch_array(mysql_query("SELECT `x`, `y`, `dir`, `floor` FROM `caveparties` WHERE `user` = '$user[id]' LIMIT 1"));
|
||||
|
||||
if ($location['dir'] == 0) {
|
||||
$y = $location['y'] * 2;
|
||||
$x = ($location['x'] - 1) * 2;
|
||||
}
|
||||
|
||||
if ($location['dir'] == 1) {
|
||||
$y = ($location['y'] - 1) * 2;
|
||||
$x = $location['x'] * 2;
|
||||
}
|
||||
|
||||
if ($location['dir'] == 2) {
|
||||
$y = $location['y'] * 2;
|
||||
$x = ($location['x'] + 1) * 2;
|
||||
}
|
||||
|
||||
if ($location['dir'] == 3) {
|
||||
$y = ($location['y'] + 1) * 2;
|
||||
$x = $location['x'] * 2;
|
||||
}
|
||||
|
||||
$floor = $location['floor'];
|
||||
|
||||
$r = mysql_query("SELECT `bot`, `x`, `y`, `cnt` FROM `cavebots` WHERE `battle` = '" . $this->battle_data["id"] . "'");
|
||||
$i = 0;
|
||||
$cnt = 0;
|
||||
while ($rec = mysql_fetch_assoc($r)) {
|
||||
$bot = $rec['bot'];
|
||||
$cnt = $rec['cnt'];
|
||||
if (@$caveitems[$bot]) {
|
||||
if ($user->getRoom() == 621) {
|
||||
$i = mt_rand(0, (count($caveitems[$bot]) - 1));
|
||||
$item = $caveitems[$bot][$i];
|
||||
if (getchance($item['chance'])) {
|
||||
$it = mysql_fetch_array(mysql_query("SELECT `id`, `name`, `img` FROM `$item[from]` WHERE `id` = $item[id] LIMIT 1"));
|
||||
$podz = 1;
|
||||
mysql_query('INSERT INTO `caveitems` SET `podzem` = "' . $item['podzem'] . '", `leader` = "' . $user['caveleader'] . '", `x` = "' . $rec['x'] . '", `y` = "' . $rec['y'] . '", `floor` = "' . $floor . '", `name` = "' . $it['name'] . '", `img` = "' . $it['img'] . '", `item` = "' . $item['id'] . '"' . ($item['foronetrip'] ? ", `foronetrip` = 1" : ""));
|
||||
cavesys("У <b>" . $cavebots[$bot] . "</b> был предмет <b>$it[name]</b> и кто угодно может подобрать его.");
|
||||
$this->AddToLog('<span class=date>' . date("H:i") . "</span> У <b>" . $cavebots[$bot] . "</b> был предмет <b>$it[name]</b>.<BR>");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($user['caveleader'] > 0) {
|
||||
$bots = [1 => 10025, 2 => 10026, 3 => 10027, 4 => 10028, 5 => 10031, 6 => 10032, 7 => 10033, 8 => 10034];
|
||||
$tp = 1;
|
||||
while ($tp <= $cnt) {
|
||||
addActions(time(), 'win_bot_' . $bots[$bot], 0, $user['id']);
|
||||
$tp++;
|
||||
}
|
||||
}
|
||||
|
||||
mysql_query("DELETE FROM `cavebots` WHERE `battle` = '" . $this->battle_data["id"] . "'");
|
||||
mysql_query('UNLOCK TABLES');
|
||||
}
|
||||
@@ -0,0 +1,553 @@
|
||||
<?php
|
||||
|
||||
use Battles\GameLogs;
|
||||
use Battles\Nick;
|
||||
use Battles\User;
|
||||
|
||||
class Tournament
|
||||
{
|
||||
public $MaxUserLevel = 9;
|
||||
private $awards = [1 => [1 => 10, 20, 30, 40, 50, 60, 70, 80],
|
||||
2 => [1 => 8, 15, 20, 30, 35, 45, 50, 60],
|
||||
3 => [1 => 5, 10, 15, 20, 25, 30, 35, 40]];
|
||||
|
||||
function AddUserInTournament(int $id)
|
||||
{
|
||||
global $user;
|
||||
$chek = mysql_fetch_row(mysql_query("select id from turnament where id=" . $id . " and old=0"));
|
||||
if ($chek[0] == '') {
|
||||
exit("Жаль, очень жаль....");
|
||||
}
|
||||
|
||||
if (mysql_query("insert into turnamuser (idturnam,iduser,level) values(" . $id . "," . $user['id'] . "," . $user['level'] . ")")) {
|
||||
mysql_query("update turnament set kolvo=kolvo+1 where id=" . $id);
|
||||
echo "Регистрация пройдена!";
|
||||
} else {
|
||||
exit("Вы уже зарегистрированы.");
|
||||
}
|
||||
}
|
||||
|
||||
function DellUserInTournament(int $id)
|
||||
{
|
||||
global $user;
|
||||
mysql_query("delete from turnamuser where idturnam=" . $id . " and iduser=" . $user['id']);
|
||||
mysql_query("update turnament set kolvo=kolvo-1 where id=" . $id);
|
||||
echo "Заявка отозвана<br>";
|
||||
}
|
||||
|
||||
function fract($num = 0)
|
||||
{
|
||||
if (!is_float($num)) {
|
||||
return false;
|
||||
}
|
||||
$out = explode('.', $num);
|
||||
return $out[1];
|
||||
}
|
||||
|
||||
function PrepearTournir()
|
||||
{//запускается за час до начала турнира
|
||||
|
||||
for ($i = 1; $i < $this->MaxUserLevel; $i++) {
|
||||
$uch = mysql_query("select id,iduser from turnamuser where loose=0 and idturnam=(select id from turnament where old=0 and level=" . $i . ") order by id desc");
|
||||
$kol = mysql_num_rows($uch);
|
||||
$cop = $kol;
|
||||
if ($kol > 7) {
|
||||
while (true) {
|
||||
$stepen = log($cop) / log(2);
|
||||
if (!$this->fract($stepen)) { //==false - дробная часть отсутствует
|
||||
for ($j = 1; $j <= ($kol - $cop); $j++) {
|
||||
$res = mysql_fetch_row($uch);
|
||||
mysql_query("delete from turnamuser where id=" . $res[0]);
|
||||
addchp('<font color=red>Внимание!</font> На этой неделе Вам не нашлелся противник в турнире.<BR>', '{[]}' . Nick::id($res[1])->short() . '{[]}');
|
||||
}
|
||||
mysql_query("update turnament set kolvo=kolvo-" . ($kol - $cop) . " where old=0 and level=" . $i);
|
||||
break;
|
||||
}
|
||||
$cop--;
|
||||
}
|
||||
$CountUser = [];
|
||||
while ($res = mysql_fetch_row($uch)) {
|
||||
$CountUser[] = $res[1];
|
||||
}
|
||||
shuffle($CountUser);
|
||||
|
||||
for ($ii = 0; $ii < count($CountUser); $ii++) {
|
||||
$user1 = $CountUser[$ii];
|
||||
$user2 = $CountUser[++$ii];
|
||||
mysql_query("insert into turnirbattle(userid,userid1,level,idtur) values(" . $user1 . "," . $user2 . "," . $i . ",(select id from turnament where old=0 and level=" . $i . "))");
|
||||
addchp('<font color=red>Внимание!</font> Подготовтесь к турниру.<BR>', '{[]}' . Nick::id($user1)->short() . '{[]}');
|
||||
addchp('<font color=red>Внимание!</font> Подготовтесь к турниру.<BR>', '{[]}' . Nick::id($user2)->short() . '{[]}');
|
||||
}
|
||||
} else {
|
||||
//Если команда не набралась удалить из таблицы и поставить турниру статус 2
|
||||
while ($res = mysql_fetch_row($uch)) {
|
||||
mysql_query("delete from turnamuser where id=" . $res['0']);
|
||||
addchp('<font color=red>Внимание!</font>На этой неделе команда для турнира не набралась.<BR>', '{[]}' . Nick::id($res[1])->short() . '{[]}');
|
||||
}
|
||||
mysql_query("delete from turnament where old=0 and level=" . $i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// созает поединок между 2 юзерами
|
||||
function MakeBattle($user1, $user2)
|
||||
{
|
||||
$res = mysql_fetch_array(mysql_query("select * from turnirbattle where userid=" . $user1 . " or userid1=" . $user1 . " limit 1"));
|
||||
if ($res['userid1'] == $user1 && $res['badmaxweap1'] != 0) {
|
||||
if ((time() - $res['badmaxweap1']) > 120) {
|
||||
mysql_query("update turnamuser set loose=2, place=" . time() . " where iduser=" . $user1 . " and idturnam=" . $res['idtur']);
|
||||
mysql_query("delete from turnirbattle where userid1=" . $user1);
|
||||
addchp('<font color=red>Внимание!</font>Вы выбыли из турнира<BR>', '{[]}' . Nick::id($user1)->short() . '{[]}');
|
||||
addchp('<font color=red>Внимание!</font>Ваш противник отказался от боя. Техническая победа.<BR>', '{[]}' . Nick::id($user2)->short() . '{[]}');
|
||||
}
|
||||
} elseif ($res['userid'] == $user2 && $res['badmaxweap'] != 0) {
|
||||
if ((time() - $res['badmaxweap']) > 120) {
|
||||
mysql_query("update turnamuser set loose=2, place=" . time() . " where iduser=" . $user2 . " and idturnam=" . $res['idtur']);
|
||||
mysql_query("delete from turnirbattle where userid=" . $user2);
|
||||
addchp('<font color=red>Внимание!</font>Вы выбыли из турнира<BR>', '{[]}' . Nick::id($user2)->short() . '{[]}');
|
||||
addchp('<font color=red>Внимание!</font>Ваш противник отказался от боя. Техническая победа.<BR>', '{[]}' . Nick::id($user1)->short() . '{[]}');
|
||||
}
|
||||
} elseif ($res['userid'] == $user1 && $res['badmaxweap'] != 0) {
|
||||
if ((time() - $res['badmaxweap']) > 120) {
|
||||
mysql_query("update turnamuser set loose=2, place=" . time() . " where iduser=" . $user1 . " and idturnam=" . $res['idtur']);
|
||||
mysql_query("delete from turnirbattle where userid=" . $user1);
|
||||
addchp('<font color=red>Внимание!</font>Вы выбыли из турнира<BR>', '{[]}' . Nick::id($user1)->short() . '{[]}');
|
||||
addchp('<font color=red>Внимание!</font>Ваш противник отказался от боя. Техническая победа.<BR>', '{[]}' . Nick::id($user2)->short() . '{[]}');
|
||||
}
|
||||
} elseif ($res['userid1'] == $user2 && $res['badmaxweap1'] != 0) {
|
||||
if ((time() - $res['badmaxweap1']) > 120) {
|
||||
mysql_query("update turnamuser set loose=2, place=" . time() . " where iduser=" . $user2 . " and idturnam=" . $res['idtur']);
|
||||
mysql_query("delete from turnirbattle where userid1=" . $user2);
|
||||
addchp('<font color=red>Внимание!</font>Вы выбыли из турнира<BR>', '{[]}' . Nick::id($user2)->short() . '{[]}');
|
||||
addchp('<font color=red>Внимание!</font>Ваш противник отказался от боя. Техническая победа.<BR>', '{[]}' . Nick::id($user1)->short() . '{[]}');
|
||||
}
|
||||
} else {
|
||||
//Если на человеке лишняя одежда написать чтобы снял поставить время ожидания 2 минуты
|
||||
$Shmotuser = mysql_fetch_array(mysql_query("select * from users where id=" . $user1));
|
||||
$Shmotuser1 = mysql_fetch_array(mysql_query("select * from users where id=" . $user2));
|
||||
$PriceWeap = mysql_fetch_row(mysql_query("select cost from inventory where id=" . $Shmotuser['weap'] . " limit 1")) ?? [];
|
||||
$PriceWeap1 = mysql_fetch_row(mysql_query("select cost from inventory where id=" . $Shmotuser1['weap'] . " limit 1")) ?? [];
|
||||
|
||||
if ($PriceWeap[0] > 16 || $Shmotuser['sergi'] != 0 || $Shmotuser['kulon'] != 0 || $Shmotuser['perchi'] != 0 || $Shmotuser['bron'] != 0 || $Shmotuser['r1'] != 0 || $Shmotuser['r2'] != 0 || $Shmotuser['r3'] != 0 || $Shmotuser['helm'] != 0 || $Shmotuser['shit'] != 0 || $Shmotuser['boots'] != 0 || $Shmotuser['stats'] != 0 || $Shmotuser['m1'] != 0 || $Shmotuser['m2'] != 0 || $Shmotuser['m3'] != 0 || $Shmotuser['m4'] != 0 || $Shmotuser['m5'] != 0 || $Shmotuser['m6'] != 0 || $Shmotuser['m7'] != 0 || $Shmotuser['m8'] != 0 || $Shmotuser['m9'] != 0 || $Shmotuser['m10'] != 0) {
|
||||
if ($res['userid'] == $user1) {
|
||||
mysql_query("update turnirbattle set badmaxweap=" . time() . " , checkuser=0 where userid=" . $user1);
|
||||
}
|
||||
if ($res['userid1'] == $user1) {
|
||||
mysql_query("update turnirbattle set badmaxweap1=" . time() . " , checkuser2=0 where userid1=" . $user1);
|
||||
}
|
||||
addchp('<font color=red>Внимание!</font>Оставьте оружие только до 16экр или оставьте только оружие.<BR>', '{[]}' . Nick::id($user1)->short() . '{[]}');
|
||||
} elseif ($PriceWeap1[0] > 16 || $Shmotuser1['sergi'] != 0 || $Shmotuser1['kulon'] != 0 || $Shmotuser1['perchi'] != 0 || $Shmotuser1['bron'] != 0 || $Shmotuser1['r1'] != 0 || $Shmotuser1['r2'] != 0 || $Shmotuser1['r3'] != 0 || $Shmotuser1['helm'] != 0 || $Shmotuser1['shit'] != 0 || $Shmotuser1['boots'] != 0 || $Shmotuser1['stats'] != 0 || $Shmotuser1['m1'] != 0 || $Shmotuser1['m2'] != 0 || $Shmotuser1['m3'] != 0 || $Shmotuser1['m4'] != 0 || $Shmotuser1['m5'] != 0 || $Shmotuser1['m6'] != 0 || $Shmotuser1['m7'] != 0 || $Shmotuser1['m8'] != 0 || $Shmotuser1['m9'] != 0 || $Shmotuser1['m10'] != 0) {
|
||||
if ($res['userid'] == $user2) {
|
||||
mysql_query("update turnirbattle set badmaxweap=" . time() . " , checkuser=0 where userid=" . $user2);
|
||||
}
|
||||
if ($res['userid1'] == $user2) {
|
||||
mysql_query("update turnirbattle set badmaxweap1=" . time() . " , checkuser2=0 where userid1=" . $user2);
|
||||
}
|
||||
addchp('<font color=red>Внимание!</font>Оставьте оружие только до 16экр или оставьте только оружие.<BR>', '{[]}' . Nick::id($user2)->short() . '{[]}');
|
||||
} else {
|
||||
// генерим массив с командами
|
||||
$teams = [];
|
||||
$teams[$user1][$user2] = [0, 0, time()];
|
||||
$teams[$user2][$user1] = [0, 0, time()];
|
||||
//Востанавливаем HP
|
||||
mysql_query("update users set hp=maxhp where id=" . $user1 . " or id=" . $user2);
|
||||
// создаем битву
|
||||
mysql_query("INSERT INTO `battle`(
|
||||
`id`,`coment`,`teams`,`timeout`,`type`,`status`,`t1`,`t2`,`to1`,`to2`,`blood`)
|
||||
VALUES(
|
||||
NULL,'','" . serialize($teams) . "','3','1','0','" . $user1 . "','" . $user2 . "','" . time() . "','" . time() . "','0')");
|
||||
// айди боя
|
||||
$id = mysql_insert_id();
|
||||
// кидаем в бой
|
||||
mysql_query("UPDATE `users` SET `battle` = {$id} WHERE `id` = " . $user1 . " OR `id` = " . $user2);
|
||||
// создаем лог
|
||||
$rr = "<b>" . Nick::id(User::getInstance()->getId())->full(1) . "</b> и <b>" . Nick::id($jert['id'])->full(1) . "</b>";
|
||||
addch("<a href=logs.php?log=" . $id . " target=_blank>Бой</a> между <B><b>" . Nick::id(User::getInstance()->getId())->short() . "</b> и <b>" . Nick::id($jert['id'])->short() . "</b> начался. ", User::getInstance()->getRoom());
|
||||
GameLogs::addBattleLog($id, "Часы показывали <span class=date>" . date("Y.m.d H.i") . "</span>, когда " . $rr . " решили выяснить кто из них сильнее. <i>(турнир)</i><BR>");
|
||||
return $id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// функция проверки статуса боя
|
||||
function CheckBattle($id)
|
||||
{
|
||||
// если по айдишнику возвращается
|
||||
// 1 - победил USER1
|
||||
// 2 - победил USER2
|
||||
// 3 - бои идет
|
||||
$res = mysql_fetch_array(mysql_query("SELECT `win` FROM `battle` WHERE `id` = " . (int)$id . " LIMIT 1;"));
|
||||
return $res['win'];
|
||||
}
|
||||
|
||||
function UpdateTournir()
|
||||
{
|
||||
for ($i = 1; $i < $this->MaxUserLevel; $i++) {
|
||||
$sql = mysql_query("select * from turnirbattle where level=" . $i);
|
||||
|
||||
if (mysql_numrows($sql) == 0) {
|
||||
$this->NextTournir($i);
|
||||
$this->StartTournir($i);
|
||||
} else {
|
||||
echo "Для " . $i . " уровня игроков следующий этап турнира начнется после завершения следующих боёв: <br>";
|
||||
}
|
||||
|
||||
while ($res = mysql_fetch_array($sql)) {
|
||||
$win = $this->CheckBattle($res['battleid']);
|
||||
if ($win == 1) {
|
||||
mysql_query("update turnamuser set place=" . time() . ", loose=loose+1 where iduser=" . $res['userid1']);
|
||||
mysql_query("update turnamuser set place=0 where iduser=" . $res['userid']);
|
||||
mysql_query("delete from turnirbattle where id=" . $res['id']);
|
||||
}
|
||||
if ($win == 2) {
|
||||
mysql_query("update turnamuser set place=" . time() . ", loose=loose+1 where iduser=" . $res['userid']);
|
||||
mysql_query("update turnamuser set place=0 where iduser=" . $res['userid1']);
|
||||
mysql_query("delete from turnirbattle where id=" . $res['id']);
|
||||
}
|
||||
if ($win == 3) {
|
||||
echo Nick::id($res['userid'])->full(1) . " против " . Nick::id($res['useridl'])->full(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function NextTournir($level)
|
||||
{
|
||||
$CheckFinal = [];
|
||||
for ($i = 0; $i <= 1; $i++) {
|
||||
$sql = mysql_query("select iduser from turnamuser where level=" . $level . " and loose=" . $i . " and idturnam=(select id from turnament where old=0 and level=" . $level . ")");
|
||||
|
||||
$ArrayUsers = [];
|
||||
while ($res = mysql_fetch_row($sql)) {
|
||||
$ArrayUsers[] = $res[0];
|
||||
}
|
||||
shuffle($CountUser);
|
||||
|
||||
if (count($ArrayUsers) == 1) {
|
||||
$CheckFinal[] = $ArrayUsers[0];
|
||||
}
|
||||
if (count($ArrayUsers) == 1 && $i == 0) {
|
||||
addchp('<font color=red>Внимание!</font> Вы вышли в финал. Дождитесь второго финалиста.<BR>', '{[]}' . Nick::id($ArrayUsers[0])->short() . '{[]}');
|
||||
}
|
||||
|
||||
if ($this->fract(count($ArrayUsers) / 2)) {
|
||||
$countUs = count($ArrayUsers) - 1;
|
||||
} else {
|
||||
$countUs = count($ArrayUsers);
|
||||
}
|
||||
|
||||
for ($ii = 0; $ii < $countUs; $ii++) {
|
||||
$user1 = $ArrayUsers[$ii];
|
||||
$user2 = $ArrayUsers[++$ii];
|
||||
//Востанавливаем HP
|
||||
mysql_query("update users set hp=maxhp where id=" . $user1 . " or id=" . $user2);
|
||||
mysql_query("insert into turnirbattle(userid,userid1,level,idtur) values(" . $user1 . "," . $user2 . "," . $level . ",(select id from turnament where old=0 and level=" . $level . "))");
|
||||
addchp('<font color=red>Внимание!</font> Подготовтесь к следующему туру.<BR>', '{[]}' . Nick::id($user1)->short() . '{[]}');
|
||||
addchp('<font color=red>Внимание!</font> Подготовтесь к следующему туру.<BR>', '{[]}' . Nick::id($user2)->short() . '{[]}');
|
||||
}
|
||||
}
|
||||
if (count($CheckFinal) == 2) {
|
||||
$this->TournirFinal($level, $CheckFinal);
|
||||
}
|
||||
if (count($CheckFinal) == 1) {
|
||||
$this->CreateHTML($level);
|
||||
//поставить турниру статус 2. создать HTML для подгрузки результатов
|
||||
//Если команда не набралась - удалить турнир. - эо при старте в 4 часа.
|
||||
$this->ShowTournirFinaliats($level);
|
||||
}
|
||||
}
|
||||
|
||||
function CreateHTML($level)
|
||||
{
|
||||
$dir = "logtur/" . $level;
|
||||
if (!file_exists($dir)) {
|
||||
mkdir($dir);
|
||||
}
|
||||
$tur = mysql_fetch_array(mysql_query("select * from turnament where old=0 and level=" . $level . " limit 1"));
|
||||
$f = fopen($dir . "/" . $tur['datetime'] . ".html", 'w+');
|
||||
fwrite($f, '<html><head><TITLE></TITLE><META content="text/html; charset=utf-8" http-equiv=Content-type></head>');
|
||||
fwrite($f, '<bpdy><table><tr><td>Игрок</td><td>Место</td></tr>');
|
||||
mysql_query("update turnamuser set place=" . (time() + 1000) . " where place=0 and idturnam=" . $tur['id'] . " and level=" . $level);
|
||||
$sql = mysql_query("select tur.*, us.login from turnamuser as tur left join users as us on us.id=tur.iduser where tur.idturnam=" . $tur['id'] . " order by tur.place desc");
|
||||
$i = 1;
|
||||
|
||||
while ($res = mysql_fetch_array($sql)) {
|
||||
if ($i == 1 || $i == 2 || $i == 3) {
|
||||
mysql_query("INSERT INTO `delo`(`id` , `author` ,`pers`, `text`, `type`, `date`) VALUES ('','0','" . $res['iduser'] . "','Выиграл в турнире " . $this->awards[$i][$level] . " кр.','1','" . time() . "');");
|
||||
addchp('<font color=red>Внимание!</font> За ' . $i . ' место в турнире, Вы получили ' . $this->awards[$i][$level] . ' кр.<BR>', '{[]}' . Nick::id($res['iduser'])->short() . '{[]}');
|
||||
}
|
||||
fwrite($f, '<tr><td>' . $res['login'] . '</td><td>' . $i++ . '</td></tr>');
|
||||
|
||||
}
|
||||
fwrite($f, '</table></body></html>');
|
||||
fclose($f);
|
||||
mysql_query("update turnament set old=2, path='/" . $dir . "/" . $tur['datetime'] . ".html' where old=0 and level=" . $level);
|
||||
|
||||
if (mysql_numrows(mysql_query("select id from turnament where old=0")) == 0) {
|
||||
$this->CreateTournament("Еженедельные турниры");
|
||||
}
|
||||
}
|
||||
|
||||
function ShowTournirFinaliats()
|
||||
{
|
||||
$sql = mysql_query("select datetime,level,path from turnament where old=2 group by level order by datetime");
|
||||
$level = 0;
|
||||
|
||||
echo "Результаты прошедших турниров.<br><table border='0' style='background-color:#E0E0E0;'><tr><td>Уровень</td><td>Дата</td></tr>";
|
||||
while ($res = mysql_fetch_array($sql)) {
|
||||
if ($level != $res['level']) {
|
||||
echo "<tr><td>" . $res['level'] . "</td>";
|
||||
}
|
||||
echo "<td><a href='http://capitalcity.oldbk.com" . $res['path'] . "'>" . date("d.m.Y H:i", $res['datetime']) . "</a></td>";
|
||||
if ($level != $res['level']) {
|
||||
echo "</tr>";
|
||||
$level = $res['level'];
|
||||
}
|
||||
}
|
||||
echo "</table>";
|
||||
}
|
||||
|
||||
function TournirFinal($level, $masFinals)
|
||||
{
|
||||
mysql_query("update turnamuser set place=0 where (iduser=" . $masFinals[0] . " or iduser=" . $masFinals[1] . ") and idturnam=(select id from turnament where old=0 and level=" . $level . ")");
|
||||
mysql_query("insert into turnirbattle(userid,userid1,level,idtur) values(" . $masFinals[0] . "," . $masFinals[1] . "," . $level . ",(select id from turnament where old=0 and level=" . $level . "))");
|
||||
addchp('<font color=red>Внимание!</font> Подготовтесь к финалу.<BR>', '{[]}' . Nick::id($masFinals[0])->short() . '{[]}');
|
||||
addchp('<font color=red>Внимание!</font> Подготовтесь к финалу.<BR>', '{[]}' . Nick::id($masFinals[1])->short() . '{[]}');
|
||||
}
|
||||
|
||||
function expectationenemy()
|
||||
{
|
||||
global $user;
|
||||
$res = mysql_fetch_array(mysql_query("select * from turnirbattle where userid=" . $user['id'] . " or userid1=" . $user['id'] . " limit 1"));
|
||||
if ($res['id'] != '') {
|
||||
if ($res['userid'] == $user['id'] && $res['checkuser'] == 0 && $res['badmaxweap'] == 0) {
|
||||
mysql_query("update turnirbattle set checkuser=1 where userid=" . $user['id']);
|
||||
if ($res['checkuser2'] == 1) {
|
||||
$battle = $this->MakeBattle($res['userid'], $res['userid1']);
|
||||
mysql_query("update turnirbattle set battleid=" . $battle . " where id=" . $res['id']);
|
||||
}
|
||||
} elseif ($res['badmaxweap'] != 0) {
|
||||
if ((time() - $res['badmaxweap']) > 120) {
|
||||
mysql_query("update turnamuser set loose=2, place=" . time() . " where iduser=" . $res['userid'] . " and idturnam=" . $res['idtur']);
|
||||
mysql_query("delete from turnirbattle where userid=" . $res['userid']);
|
||||
addchp('<font color=red>Внимание!</font>Вы выбыли из турнира<BR>', '{[]}' . Nick::id($res['userid'])->short() . '{[]}');
|
||||
addchp('<font color=red>Внимание!</font>Ваш противник отказался от боя. Техническая победа.<BR>', '{[]}' . Nick::id($res['userid1'])->short() . '{[]}');
|
||||
}
|
||||
}
|
||||
if ($res['userid1'] == $user['id'] && $res['checkuser2'] == 0 && $res['badmaxweap1'] == 0) {
|
||||
mysql_query("update turnirbattle set checkuser2=1 where userid1=" . $user['id']);
|
||||
if ($res['checkuser'] == 1) {
|
||||
$battle = $this->MakeBattle($res['userid'], $res['userid1']);
|
||||
mysql_query("update turnirbattle set battleid=" . $battle . " where id=" . $res['id']);
|
||||
}
|
||||
} elseif ($res['badmaxweap1'] != 0) {
|
||||
if ((time() - $res['badmaxweap1']) > 120) {
|
||||
mysql_query("update turnamuser set loose=2, place=" . time() . " where iduser=" . $res['userid'] . " and idturnam=" . $res['idtur1']);
|
||||
mysql_query("delete from turnirbattle where userid1=" . $res['userid1']);
|
||||
addchp('<font color=red>Внимание!</font>Вы выбыли из турнира<BR>', '{[]}' . Nick::id($res['userid1'])->short() . '{[]}');
|
||||
addchp('<font color=red>Внимание!</font>Ваш противник отказался от боя. Техническая победа.<BR>', '{[]}' . Nick::id($res['userid'])->short() . '{[]}');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function StartTournir($level = null)
|
||||
{//Запускается в 17-00-10 каждую пятницу
|
||||
//Разослать всем кнопочки на вход в турнир
|
||||
global $user;
|
||||
$res = mysql_fetch_array(mysql_query("select * from turnirbattle where userid=" . $user['id'] . " or userid1=" . $user['id'] . " limit 1"));
|
||||
$PriceWeap = mysql_fetch_row(mysql_query("select cost from inventory where id=" . $user['weap'] . " limit 1")) ?? [];
|
||||
|
||||
if ($PriceWeap[0] > 16 || $user['sergi'] != 0 || $user['kulon'] != 0 || $user['perchi'] != 0 || $user['bron'] != 0 || $user['r1'] != 0 || $user['r2'] != 0 || $user['r3'] != 0 || $user['helm'] != 0 || $user['shit'] != 0 || $user['boots'] != 0 || $user['stats'] != 0 || $user['m1'] != 0 || $user['m2'] != 0 || $user['m3'] != 0 || $user['m4'] != 0 || $user['m5'] != 0 || $user['m6'] != 0 || $user['m7'] != 0 || $user['m8'] != 0 || $user['m9'] != 0 || $user['m10'] != 0) {
|
||||
if ($res['userid'] == $user['id'] && $res['badmaxweap'] == 0) {
|
||||
mysql_query("update turnirbattle set badmaxweap=" . time() . " , checkuser=0 where userid=" . $user['id']);
|
||||
}
|
||||
if ($res['userid1'] == $user['id'] && $res['badmaxweap1'] == 0) {
|
||||
mysql_query("update turnirbattle set badmaxweap1=" . time() . " , checkuser2=0 where userid1=" . $user['id']);
|
||||
}
|
||||
addchp('<font color=red>Внимание!</font>Оставьте оружие только до 16экр или оставьте только оружие.<BR>', '{[]}' . Nick::id($user['id'])->short() . '{[]}');
|
||||
} else {
|
||||
if ($res['userid'] == $user['id']) {
|
||||
mysql_query("update turnirbattle set badmaxweap=0 where userid=" . $user['id']);
|
||||
}
|
||||
if ($res['userid1'] == $user['id']) {
|
||||
mysql_query("update turnirbattle set badmaxweap1=0 where userid1=" . $user['id']);
|
||||
}
|
||||
}
|
||||
|
||||
$sql = mysql_query("select * from turnirbattle where badmaxweap1<>0 or badmaxweap<>0");
|
||||
while ($res = mysql_fetch_array($sql)) {
|
||||
if ($res['badmaxweap1'] != 0 && (time() - $res['badmaxweap1']) > 120) {
|
||||
mysql_query("update turnamuser set loose=2, place=" . time() . " where iduser=" . $res['userid1'] . " and idturnam=" . $res['idtur']);
|
||||
mysql_query("delete from turnirbattle where userid1=" . $res['userid1']);
|
||||
addchp('<font color=red>Внимание!</font>Вы выбыли из турнира<BR>', '{[]}' . Nick::id($res['userid1'])->short() . '{[]}');
|
||||
addchp('<font color=red>Внимание!</font>Ваш противник отказался от боя. Техническая победа.<BR>', '{[]}' . Nick::id($res['userid'])->short() . '{[]}');
|
||||
}
|
||||
if ($res['badmaxweap'] != 0 && (time() - $res['badmaxweap']) > 120) {
|
||||
mysql_query("update turnamuser set loose=2, place=" . time() . " where iduser=" . $res['userid'] . " and idturnam=" . $res['idtur']);
|
||||
mysql_query("delete from turnirbattle where userid=" . $res['userid']);
|
||||
addchp('<font color=red>Внимание!</font>Вы выбыли из турнира<BR>', '{[]}' . Nick::id($res['userid'])->short() . '{[]}');
|
||||
addchp('<font color=red>Внимание!</font>Ваш противник отказался от боя. Техническая победа.<BR>', '{[]}' . Nick::id($res['userid1'])->short() . '{[]}');
|
||||
}
|
||||
}
|
||||
|
||||
if ($level != '') {
|
||||
$level = ' and level=' . $level;
|
||||
}
|
||||
$sql = mysql_query("SELECT * FROM turnirbattle WHERE (userid=" . $user['id'] . " or userid1=" . $user['id'] . ") " . $level);
|
||||
while ($res = mysql_fetch_array($sql)) {
|
||||
$looseL1 = mysql_fetch_row(mysql_query("select loose from turnamuser where iduser=" . $res['userid1'] . " and idturnam=" . $res['idtur']));
|
||||
$looseL = mysql_fetch_row(mysql_query("select loose from turnamuser where iduser=" . $res['userid'] . " and idturnam=" . $res['idtur']));
|
||||
if ($res['userid'] == $user['id']) {
|
||||
if ($res['checkuser'] == 0) {
|
||||
if ($res['badmaxweap'] != 0) {
|
||||
if ((time() - $res['badmaxweap']) > 120) {
|
||||
mysql_query("update turnamuser set loose=2, place=" . time() . " where iduser=" . $res['userid'] . " and idturnam=" . $res['idtur']);
|
||||
mysql_query("delete from turnirbattle where userid=" . $res['userid']);
|
||||
addchp('<font color=red>Внимание!</font>Вы выбыли из турнира<BR>', '{[]}' . Nick::id($res['userid'])->short() . '{[]}');
|
||||
addchp('<font color=red>Внимание!</font>Ваш противник отказался от боя. Техническая победа.<BR>', '{[]}' . Nick::id($res['userid1'])->short() . '{[]}');
|
||||
} else {
|
||||
echo "<form method='post'><input type='submit' name='expenemy' value='Я готов'> противник " . Nick::id($res['useridl'])->full(1) . "(поражений-" . $looseL1[0] . ")</form>";
|
||||
}
|
||||
} else {
|
||||
echo "<form method='post'><input type='submit' name='expenemy' value='Я готов'> противник " . Nick::id($res['useridl'])->full(1) . "(поражений-" . $looseL1[0] . ")</form>";
|
||||
}
|
||||
} else {
|
||||
echo "Ожидаем противника";
|
||||
}
|
||||
}
|
||||
|
||||
if ($res['userid1'] == $user['id']) {
|
||||
if ($res['checkuser2'] == 0) {
|
||||
if ($res['badmaxweap1'] != 0) {
|
||||
if ((time() - $res['badmaxweap1']) > 120) {
|
||||
mysql_query("update turnamuser set loose=2, place=" . time() . " where iduser=" . $res['userid1'] . " and idturnam=" . $res['idtur']);
|
||||
mysql_query("delete from turnirbattle where userid1=" . $res['userid1']);
|
||||
addchp('<font color=red>Внимание!</font>Вы выбыли из турнира<BR>', '{[]}' . Nick::id($res['userid1'])->short() . '{[]}');
|
||||
addchp('<font color=red>Внимание!</font>Ваш противник отказался от боя. Техническая победа.<BR>', '{[]}' . Nick::id($res['userid'])->short() . '{[]}');
|
||||
} else {
|
||||
echo "<form method='post'><input type='submit' name='expenemy' value='Я готов'>противник " . Nick::id($res['userid'])->full(1) . "(поражений-" . $looseL[0] . ")</form>";
|
||||
}
|
||||
} else {
|
||||
echo "<form method='post'><input type='submit' name='expenemy' value='Я готов'>противник " . Nick::id($res['userid'])->full(1) . "(поражений-" . $looseL[0] . ")</form>";
|
||||
}
|
||||
} else {
|
||||
echo "Ожидаем противника";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function CreateTournament($title)
|
||||
{
|
||||
//Вычисляем следующую пятницу
|
||||
$dateTime = '';
|
||||
if (date("w", mktime(0, 0, 0, date('n'), date('j'), date('Y'))) == 5 && date("H") > 17) {
|
||||
$nextDay = date('j') + 1;
|
||||
$DayofMonth = date('j');
|
||||
if ($nextDay > date('t')) {
|
||||
$nextDay = 1;
|
||||
$DayofMonth = date("t", mktime(0, 0, 0, date('n') + 1, 1, date('Y')));//даже если date('n')+1 = 13 mktime переведет на 01.01.следующий год
|
||||
}
|
||||
} else {
|
||||
$nextDay = date('j');
|
||||
$DayofMonth = date('t');
|
||||
}
|
||||
|
||||
for ($j = $nextDay; $j <= $DayofMonth; $j++) {
|
||||
//узнаем день недели
|
||||
$DayofWeek = date("w", mktime(0, 0, 0, date('n'), $j, date('Y')));
|
||||
if ($DayofWeek == 5) {
|
||||
$dateTime = mktime(17, 0, 0, date('n'), $j, date('Y'));
|
||||
break;
|
||||
}
|
||||
}
|
||||
//если пятниц в этом месяце не осталось
|
||||
if ($dateTime == '') {
|
||||
if (date("n") + 1 == 13) {
|
||||
$Month = 1;
|
||||
$Year = date("Y") + 1;
|
||||
} else {
|
||||
$Month = date('n') + 1;
|
||||
$Year = date("Y");
|
||||
}
|
||||
|
||||
for ($j = 1; $j <= date('t', mktime(0, 0, 0, $Month, 1, $Year)); $j++) {
|
||||
//узнаем день недели
|
||||
$DayofWeek = date("w", mktime(0, 0, 0, $Month, $j, $Year));
|
||||
if ($DayofWeek == 5) {
|
||||
$dateTime = mktime(17, 0, 0, $Month, $j, $Year);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Создаем турниры.
|
||||
for ($i = 1; $i < $this->MaxUserLevel; $i++)
|
||||
if (!mysql_query("insert into turnament(title,level,datetime) values ('" . $title . "'," . $i . ",'" . $dateTime . "')")) {
|
||||
$f = fopen('/tmp/memcache/logtur/error.log', 'w');
|
||||
fwrite($f, "insert into turnament(title,level,datetime) values ('" . $title . "'," . $i . ",'" . $dateTime . "')\n");
|
||||
fclose($f);
|
||||
}
|
||||
}
|
||||
|
||||
function showAllTurnament()
|
||||
{
|
||||
global $user;
|
||||
$sql = mysql_query("select * from turnament where old=0");
|
||||
$dateD = mysql_fetch_row(mysql_query("select datetime from turnament where old=0 limit 1"));
|
||||
if (mysql_num_rows($sql) < 1) {
|
||||
echo "На данный момент новых чемпионатов нет";
|
||||
}
|
||||
if ($user['level'] > 0 && mktime() < $dateD[0]) {
|
||||
echo "<form method='post'>";
|
||||
}
|
||||
echo "<table border=1 style='font-weight:bold;'>
|
||||
<tr>
|
||||
<td>Название турнира</td>
|
||||
<td>Время проведения</td>
|
||||
<td>Кол-во учасников</td>
|
||||
<td>Уровень</td>";
|
||||
if ($user['level'] > 0 && mktime() < $dateD[0]) {
|
||||
echo "<td>Регистрация</td>";
|
||||
}
|
||||
echo "</tr>";
|
||||
while ($res = mysql_fetch_array($sql)) {
|
||||
if ($user['level'] == $res['level']) {
|
||||
$dellzay = mysql_fetch_row(mysql_query("select id from turnamuser where iduser=" . $user['id'] . " and idturnam=" . $res['id']));
|
||||
}
|
||||
echo "<tr>
|
||||
<td>
|
||||
" . $res['title'] . "
|
||||
</td>
|
||||
<td>
|
||||
" . date("d.m.Y H:i", $res['datetime']) . "
|
||||
</td>
|
||||
<td>
|
||||
" . $res['kolvo'] . "
|
||||
</td>
|
||||
<td>
|
||||
" . $res['level'] . "
|
||||
</td>";
|
||||
if ($user['level'] == $res['level'] && mktime() < $dateD[0]) {
|
||||
if ($dellzay[0] == '') {
|
||||
echo "<td>
|
||||
<input type='submit' name='addzayvka' value='Зарегистрироваться'>
|
||||
<input type='hidden' name='idtur' value='" . $res['id'] . "'>
|
||||
</td>";
|
||||
}
|
||||
else {
|
||||
echo "<td>
|
||||
<input type='submit' name='dellzayvka' value='Отказаться'>
|
||||
<input type='hidden' name='idtur' value='" . $res['id'] . "'>
|
||||
</td>";
|
||||
}
|
||||
}
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
if ($user['level'] > 0 && mktime() < $dateD[0]) {
|
||||
echo "</form>";
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,592 @@
|
||||
<?php
|
||||
|
||||
use Battles\User;
|
||||
|
||||
class Quests
|
||||
{
|
||||
public $free_x = 28, $data = [], $error = '';
|
||||
|
||||
public function testGood($pl, $uid)
|
||||
{
|
||||
if (!is_array($pl)) $pl = db::c()->query('SELECT * FROM `quests` WHERE `id` = ?i', $pl)->fetch_assoc();
|
||||
|
||||
$r = 1;
|
||||
|
||||
$qlst = db::c()->query('SELECT `vals` FROM `actions` WHERE `uid` = ?i AND `vars` = "?s"', $uid, 'start_quest' . $pl['id'])->fetch_assoc();
|
||||
if (db::c()->getAffectedRows() AND !in_array($qlst['vals'], ['win', 'end', 'vals'])) $r = 2;
|
||||
|
||||
unset($qlst, $qlst2);
|
||||
|
||||
$d = $this->expl($pl['tr_date']);
|
||||
|
||||
if (isset($d['tr_endq'])) {
|
||||
$i = 0;
|
||||
$e = explode(',', $d['tr_endq']);
|
||||
while ($i < count($e)) {
|
||||
$qlst = mysql_fetch_array(mysql_query('SELECT `id`, `vals` FROM `actions` WHERE `uid` = "' . $uid . '" AND `vars` = "start_quest' . $e[$i] . '" AND `vals` = "win" LIMIT 1'));
|
||||
if (!isset($qlst['id'])) {
|
||||
$r = 3;
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
unset($qn, $qlst, $qlst2);
|
||||
}
|
||||
|
||||
if (isset($d['tr_zdr'])) {
|
||||
$qlst = mysql_fetch_array(mysql_query('SELECT * FROM `actions` WHERE `uid` = "' . $uid . '" AND `vars` = "start_quest' . $pl['id'] . '" AND `vals` != "go" ORDER BY `time` DESC LIMIT 1'));
|
||||
if ($qlst['time'] + ($d['tr_zdr'] * 60 * 60) - time() > 0) {
|
||||
$r = 4;
|
||||
}
|
||||
unset($qlst);
|
||||
}
|
||||
|
||||
if (isset($d['tr_tm1'])) {
|
||||
$d['tr_tm1'] = str_replace('d', date('d'), $d['tr_tm1']);
|
||||
$d['tr_tm1'] = str_replace('m', date('m'), $d['tr_tm1']);
|
||||
$d['tr_tm1'] = str_replace('y', date('y'), $d['tr_tm1']);
|
||||
$d['tr_tm2'] = str_replace('d', date('d'), $d['tr_tm2']);
|
||||
$d['tr_tm2'] = str_replace('m', date('m'), $d['tr_tm2']);
|
||||
$d['tr_tm2'] = str_replace('y', date('y'), $d['tr_tm2']);
|
||||
}
|
||||
|
||||
if (isset($d['tr_raz'])) {
|
||||
$qlst = $this->testAction('SELECT `id` FROM `actions` WHERE `uid` = "' . $uid . '" AND `vars` = "start_quest' . $pl['id'] . '" LIMIT ' . $d['tr_raz'], 2);
|
||||
if ($d['tr_raz'] > 0 && $d['tr_raz'] - $qlst[0] <= 0) {
|
||||
$r = 5;
|
||||
}
|
||||
unset($qlst);
|
||||
}
|
||||
|
||||
if (isset($d['tr_raz2'])) {
|
||||
$qlst = $this->testAction('SELECT `id` FROM `actions` WHERE `uid` = "' . $uid . '" AND `vars` = "start_quest' . $pl['id'] . '" AND `vals` != "go" AND `vals` != "win" LIMIT ' . $d['tr_raz2'], 2);
|
||||
if ($d['tr_raz2'] - $qlst[0] <= 0) {
|
||||
$r = 6;
|
||||
}
|
||||
unset($qlst);
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
public function __clone()
|
||||
{
|
||||
trigger_error('Дублирование не допускается.', E_USER_ERROR);
|
||||
}
|
||||
|
||||
public function startq($id, $uid)
|
||||
{
|
||||
$pl = db::c()->query('SELECT `id`,`name`,`time` FROM `quests` WHERE `delete` = 0 AND `id` = ?i', $id)->fetch_assoc();
|
||||
if (db::c()->getAffectedRows()) {
|
||||
$tms = (time() + 60 * 60 * $pl['time']);
|
||||
db::c()->query('INSERT INTO `actions` (`uid`, `time`, `city`, `room`, `vars`, `ip`, `vals`, `val`) VALUES (?i,?i,"?s",?i,"?s","?s","?s","?s")',
|
||||
$uid, time(), 'capitalcity', 0, 'start_quest' . $id, $_SERVER['REMOTE_ADDR'], 'go', $tms);
|
||||
return 'Вы успешно получили задание "' . $pl['name'] . '"';
|
||||
} else {
|
||||
return 'Не удалось получить данное задание ...';
|
||||
}
|
||||
}
|
||||
|
||||
public function list_quest($pl, $u)
|
||||
{
|
||||
$r = '';
|
||||
$t = '';
|
||||
$nagr = '';
|
||||
$tr = '';
|
||||
$za = '';
|
||||
|
||||
$qlst = db::c()->query('SELECT `vals`, `time` FROM `actions` WHERE `uid` = ?i AND `vars` = "?s" ORDER BY `time` DESC', $u, 'start_quest' . $pl['id'])->fetch_assoc();
|
||||
$ds = $this->expl($pl['win_date']);
|
||||
if (isset($ds['add_cr'])) $nagr .= "Деньги: {$ds['add_cr']} кр. ";
|
||||
if (isset($ds['add_point'])) $nagr .= "Репутация: {$ds['add_point']} ед. ";
|
||||
if (isset($ds['add_exp'])) $nagr .= "Опыт: {$ds['add_exp']} ед. ";
|
||||
|
||||
$d = $this->expl($pl['act_date']);
|
||||
|
||||
if (isset($d['heal'])) $tr .= "<small>Вылечить <b>{$d['heal']}</b> игроков от травм.</small><br>";
|
||||
if (isset($d['tr_win_haot'])) $tr .= "<small>Выиграть <b>{$d['tr_win_haot']}</b> хаотических поединков.</small><br>";
|
||||
if (isset($d['kill_clone'])) $tr .= "<small>Выиграть <b>{$d['kill_clone']}</b> поединков против своего клона.</small><br>";
|
||||
if (isset($d['tr_win'])) $tr .= "<small>Выйграть <b>{$d['tr_win']}</b> физических поединков против игроков.</small><br>";
|
||||
|
||||
if (isset($d['kill_bot'])) {
|
||||
$x = '';
|
||||
$ex = explode(',', $d['kill_bot']);
|
||||
$i = 0;
|
||||
while ($i < count($ex)) {
|
||||
$ex2 = explode('=', $ex[$i]);
|
||||
$bot2 = db::c()->query('SELECT `login` FROM `users` WHERE `id` = ?i', $ex2[0])->fetch_assoc();
|
||||
if (db::c()->getAffectedRows()) $x .= " • <b>{$bot2['login']}</b> {$ex2[1]}<br>";
|
||||
$i++;
|
||||
}
|
||||
if (!empty($x)) {
|
||||
$x = trim($x, ', ');
|
||||
$tr .= "<small>Убить ботов: <br>{$x}</small>";
|
||||
}
|
||||
}
|
||||
if (!empty($tr)) $ts = 'Требования :<br />' . $tr;
|
||||
|
||||
if ($qlst['time'] + ($pl['heal'] * 60 * 60) - time() > 0) {
|
||||
$tms = $this->timeOut($qlst['time'] + ($pl['heal'] * 60 * 60) - time());
|
||||
$za = "<b style='color: Red;'>Задержка еще: {$tms}</b><br />";
|
||||
}
|
||||
|
||||
$d = $this->expl($pl['tr_date']);
|
||||
$r .= <<<TASK
|
||||
<div class="taskContainer" style="background: #dff0ff;border: 1px dashed black;margin: 5px auto;padding-bottom: 5px;width: 50%;">
|
||||
<h3>{$pl['name']}</h3><button disabled>Недоступно</button>
|
||||
<div><!--<a class="action-start" href="?quid={$pl['id']}">Я берусь за задание!</a>--></div>
|
||||
<div style="font-style: italic;">{$pl['info']}</div>
|
||||
<div>
|
||||
Награда: <b>{$nagr}</b><br>
|
||||
Время на выполнение: <b>{$pl['time']}</b> ч.<br>
|
||||
{$ts}{$za}<br>
|
||||
Задание для [{$pl['min_lvl']}-{$pl['max_lvl']}] уровней, с задержкой {$pl['heal']} ч.
|
||||
</div>
|
||||
</div>
|
||||
TASK;
|
||||
return $r;
|
||||
}
|
||||
|
||||
public function info($pl, $uid)
|
||||
{
|
||||
$r = '';
|
||||
$t = '';
|
||||
$qst = mysql_fetch_array(mysql_query('SELECT * FROM `actions` WHERE `uid` = "' . $uid . '" AND `vars` = "start_quest' . $pl['id'] . '" AND `vals` = "go" LIMIT 1'));
|
||||
$d = $this->expl($pl['tr_date']);
|
||||
|
||||
if (isset($d['tr_endq'])) {
|
||||
$t .= 'Завершить квесты : ';
|
||||
$i = 0;
|
||||
$e = explode(',', $d['tr_endq']);
|
||||
while ($i <= count($e)) {
|
||||
if ($e[$i] > 0) {
|
||||
$qn = mysql_fetch_array(mysql_query('SELECT `name` FROM `quests` WHERE `id` = "' . $e[$i] . '" LIMIT 1'));
|
||||
if (isset($qn['name'])) {
|
||||
$t .= '"' . $qn['name'] . '", ';
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$t = trim($t, ', ');
|
||||
$t .= '<br />';
|
||||
unset($qn);
|
||||
}
|
||||
|
||||
if (isset($d['tr_botitm'])) {
|
||||
$t .= 'Из ботов выпадают предметы :<ul>';
|
||||
$e = explode('|', $d['tr_botitm']);
|
||||
$i = 0;
|
||||
while ($i < count($e)) {
|
||||
$j = 0;
|
||||
$e2 = explode('-', $e[$i]);
|
||||
|
||||
if ($e2[0] > 0) {
|
||||
$qn = mysql_fetch_array(mysql_query('SELECT `login` FROM `users` WHERE `id` = "' . $e2[0] . '" LIMIT 1'));
|
||||
$t .= ' • Из "' . $qn['login'] . '" выпадает: ';
|
||||
} else {
|
||||
$t .= ' • Из любых ботов выпадает: ';
|
||||
}
|
||||
|
||||
$j = 0;
|
||||
$e3 = explode(',', $e2[1]);
|
||||
while ($j < count($e3)) {
|
||||
$e4 = explode('=', $e3[$j]);
|
||||
$qi = mysql_fetch_array(mysql_query('SELECT `id`, `name`, `img` FROM `shop` WHERE `id` = "' . $e4[0] . '" LIMIT 1'));
|
||||
$t .= '<img src="/i/sh/' . $qi['img'] . '" style="max-height: 12px;"> ' . $qi['name'] . ', ';
|
||||
$j++;
|
||||
}
|
||||
$t = trim($t, ', ');
|
||||
$i++;
|
||||
}
|
||||
$t .= '<br />';
|
||||
unset($qn, $qi, $e2, $e3, $e4);
|
||||
}
|
||||
|
||||
if (isset($d['tr_winitm'])) {
|
||||
$t .= 'После победы выпадают предметы :<br />';
|
||||
$e = explode('|', $d['tr_winitm']);
|
||||
$i = 0;
|
||||
while ($i < count($e)) {
|
||||
$j = 0;
|
||||
$e2 = explode('-', $e[$i]);
|
||||
$t .= ' • ';
|
||||
|
||||
if ($e2[0] > 0) {
|
||||
$t .= 'Из людей выпадает : ';
|
||||
} else {
|
||||
$t .= 'Из ботов выпадает : ';
|
||||
}
|
||||
|
||||
$j = 0;
|
||||
$e3 = explode(',', $e2[1]);
|
||||
while ($j < count($e3)) {
|
||||
$e4 = explode('=', $e3[$j]);
|
||||
$qi = mysql_fetch_array(mysql_query('SELECT `id`, `name`, `img` FROM `shop` WHERE `id` = "' . $e4[0] . '" LIMIT 1'));
|
||||
$t .= '<img src="/i/sh/' . $qi['img'] . '" style="max-height: 12px;"> ' . $qi['name'] . ', ';
|
||||
$j++;
|
||||
}
|
||||
$t = trim($t, ', ');
|
||||
$t .= '<br />';
|
||||
$i++;
|
||||
}
|
||||
unset($qn, $qi, $e2, $e3, $e4);
|
||||
}
|
||||
|
||||
if (isset($d['tr_zdr'])) {
|
||||
$qlst = mysql_fetch_array(mysql_query('SELECT * FROM `actions` WHERE `uid` = "' . $uid . '" AND `vars` = "start_quest' . $pl['id'] . '" AND `vals` != "go" LIMIT 1'));
|
||||
$t .= 'Задержка между выполнением задания : ' . $this->timeOut($d['tr_zdr'] * 60 * 60);
|
||||
if ($qlst['time'] + ($d['tr_zdr'] * 60 * 60) - time() > 0) {
|
||||
$t .= '<small>(Осталось : ' . $this->timeOut($qlst['time'] + ($d['tr_zdr'] * 60 * 60) - time()) . ' ч.)</small>';
|
||||
}
|
||||
$t .= '<br />';
|
||||
unset($qlst);
|
||||
}
|
||||
|
||||
if (isset($d['tr_tm1'])) {
|
||||
$d['tr_tm1'] = str_replace('d', date('d'), $d['tr_tm1']);
|
||||
$d['tr_tm1'] = str_replace('m', date('m'), $d['tr_tm1']);
|
||||
$d['tr_tm1'] = str_replace('y', date('y'), $d['tr_tm1']);
|
||||
$d['tr_tm2'] = str_replace('d', date('d'), $d['tr_tm2']);
|
||||
$d['tr_tm2'] = str_replace('m', date('m'), $d['tr_tm2']);
|
||||
$d['tr_tm2'] = str_replace('y', date('y'), $d['tr_tm2']);
|
||||
$t .= 'Период квеста : ' . $d['tr_tm1'] . ' - ' . $d['tr_tm2'] . '<br />';
|
||||
}
|
||||
|
||||
if (isset($d['tr_raz'])) {
|
||||
if ($d['tr_raz'] == -1) {
|
||||
$t .= 'Сколько еще раз можно выполнить задание: <b><small>бесконечно</small></b><br>';
|
||||
} else {
|
||||
$qlst = $this->testAction('SELECT `id` FROM `actions` WHERE `uid` = "' . $uid . '" AND `vars` = "start_quest' . $pl['id'] . '" LIMIT ' . $d['tr_raz'], 2);
|
||||
$t .= 'Сколько раз можно выполнить задание: ' . ($d['tr_raz'] - $qlst[0]) . '<br />';
|
||||
}
|
||||
unset($qlst);
|
||||
}
|
||||
|
||||
if (isset($d['tr_raz2'])) {
|
||||
$qlst = $this->testAction('SELECT `id` FROM `actions` WHERE `uid` = "' . $uid . '" AND `vars` = "start_quest' . $pl['id'] . '" AND `vals` != "go" AND `vals` != "win" LIMIT ' . $d['tr_raz2'], 2);
|
||||
$t .= 'Осталось попыток выполнить задание : ' . ($d['tr_raz2'] - $qlst[0]) . '<br />';
|
||||
unset($qlst);
|
||||
}
|
||||
|
||||
$d = $this->expl($pl['act_date']);
|
||||
|
||||
if (isset($d['kill_bot'])) {
|
||||
$x = '';
|
||||
$ex = explode(',', $d['kill_bot']);
|
||||
$i = 0;
|
||||
if (isset($d['all_kill']) && $d['all_kill'] > 0) {
|
||||
while ($i < count($ex)) {
|
||||
$x2 = 0;
|
||||
$ex2 = explode('=', $ex[$i]);
|
||||
if (isset($qst['id'])) {
|
||||
$x2 = $this->testAction('`uid` = "' . $uid . '" AND `time` > ' . $qst['time'] . ' AND `vars` = "win_bot_' . $ex2[0] . '" LIMIT ' . $ex2[1], 2);
|
||||
$x2 = (0 + $x2[0]);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
|
||||
$bot2 = mysql_fetch_array(mysql_query('SELECT * FROM `users` WHERE `id` = "' . $ex2[0] . '" LIMIT 1'));
|
||||
//$bot2['id'] = $bot2['id']; ?!?!?!?!?!?!?!
|
||||
if (isset($bot2['id'])) {
|
||||
$x .= ' • <b>' . $bot2['login'] . '</b> [' . $x2 . '/' . $d['all_kill'] . ']<br />';
|
||||
} else {
|
||||
$x .= ' • <b>' . $pl['name'] . '</b> [' . $x2 . '/' . $d['all_kill'] . ']<br />';
|
||||
}
|
||||
} else {
|
||||
while ($i < count($ex)) {
|
||||
$x2 = 0;
|
||||
$ex2 = explode('=', $ex[$i]);
|
||||
$bot2 = mysql_fetch_array(mysql_query('SELECT * FROM `users` WHERE `id` = "' . $ex2[0] . '" LIMIT 1'));
|
||||
if (isset($bot2['id'])) {
|
||||
if (isset($qst['id'])) {
|
||||
$x2 = $this->testAction('`uid` = "' . $uid . '" AND `time` > ' . $qst['time'] . ' AND `vars` = "win_bot_' . $ex2[0] . '" LIMIT ' . $ex2[1], 2);
|
||||
$x2 = (0 + $x2[0]);
|
||||
}
|
||||
$x .= ' • <b>' . $bot2['login'] . '</b> [' . $x2 . '/' . $ex2[1] . ']<br />';
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
if ($x != '') {
|
||||
$x = trim($x, ', ');
|
||||
$t .= 'Убить ботов: <br />' . $x . '';
|
||||
}
|
||||
unset($x, $ex, $x2, $bot2, $ex2);
|
||||
}
|
||||
|
||||
if (isset($d['tr_win_haot'])) {
|
||||
$x = $this->testAction('`uid` = "' . $uid . '" AND `time` > "' . $qst['time'] . '" AND `vars` = "win_haot" LIMIT 1', 2);
|
||||
$x = (0 + $x[0]);
|
||||
$t .= 'Победить в хаотических поединках : [' . $x . '/' . $d['tr_win_haot'] . ']<br />';
|
||||
unset($x);
|
||||
}
|
||||
|
||||
if (isset($d['kill_clone'])) {
|
||||
$x = $this->testAction('`uid` = "' . $uid . '" AND `time` > "' . $qst['time'] . '" AND `vars` = "kill_clone" LIMIT 1', 2);
|
||||
$x = (0 + $x[0]);
|
||||
$t .= 'Победите в : [' . $x . '/' . $d['kill_clone'] . '] физических боях с клоном.<br />';
|
||||
unset($x);
|
||||
}
|
||||
|
||||
if (isset($d['tr_win'])) {
|
||||
$x = $this->testAction('`uid` = "' . $uid . '" AND `time` > "' . $qst['time'] . '" AND `vars` = "win_fiz" LIMIT 1', 2);
|
||||
$x = (0 + $x[0]);
|
||||
$t .= 'Победите в : [' . $x . '/' . $d['tr_win'] . '] физических против игроков.<br />';
|
||||
unset($x);
|
||||
}
|
||||
|
||||
if (isset($d['heal'])) {
|
||||
$x = $this->testAction('`uid` = "' . $uid . '" AND `time` > "' . $qst['time'] . '" AND `vars` LIKE "heal%" AND `vars` != "heal_' . $uid . '" LIMIT 1', 2);
|
||||
$x = (0 + $x[0]);
|
||||
$t .= 'Вылечите : [' . $x . '/' . $d['heal'] . '] игроков от травм.<br />';
|
||||
unset($x);
|
||||
}
|
||||
|
||||
if (isset($d['tk_itm'])) {
|
||||
$ex = explode(',', $d['tk_itm']);
|
||||
$i = 0;
|
||||
$x = '';
|
||||
while ($i < count($ex)) {
|
||||
$ex2 = explode('=', $ex[$i]);
|
||||
$x2 = mysql_fetch_array(mysql_query('SELECT `koll` FROM `inventory` WHERE `prototype` = "' . mysql_real_escape_string($ex2[0]) . '" AND `owner` = "' . $uid . '" LIMIT 1'));
|
||||
$bot2 = mysql_fetch_array(mysql_query('SELECT `id`, `name`, `img` FROM `shop` WHERE `id` = "' . mysql_real_escape_string($ex2[0]) . '" LIMIT 1'));
|
||||
$x .= ' • <b>' . $bot2['name'] . '</b> [' . $x2[0] . '/' . $ex2[1] . ']<br />';
|
||||
$i++;
|
||||
}
|
||||
|
||||
if ($x != '') {
|
||||
$x = trim($x, ', ');
|
||||
$t .= 'Собрать ресурсы : <br />' . $x . '';
|
||||
}
|
||||
}
|
||||
|
||||
if ($t != '') {
|
||||
$r .= '<b>Условия задания :</b><br />' . $t . '<br />';
|
||||
$t = '';
|
||||
}
|
||||
|
||||
$ds = $this->expl($pl['win_date']);
|
||||
if (isset($ds['add_cr'])) {
|
||||
$t .= 'Деньги : ' . $ds['add_cr'] . ' кр.<br />';
|
||||
}
|
||||
|
||||
if (isset($ds['add_point'])) {
|
||||
$t .= 'Репутация : ' . $ds['add_point'] . ' ед.<br />';
|
||||
}
|
||||
|
||||
if (isset($ds['add_exp'])) {
|
||||
$t .= 'Опыт : ' . $ds['add_exp'] . ' ед.<br />';
|
||||
}
|
||||
|
||||
if ($t != '') {
|
||||
$r = '<b>Награда:</b><br />' . $t . '<br />' . $r;
|
||||
$t = '';
|
||||
}
|
||||
|
||||
if ($t != '') {
|
||||
$r = '<br /><b>Действия задания :</b><br />' . $t . '<br />' . $r;
|
||||
$t = '';
|
||||
}
|
||||
|
||||
if ($r == '') {
|
||||
$r = 'Дополнительная информация по заданию отсутствует';
|
||||
}
|
||||
return $r;
|
||||
}
|
||||
|
||||
public function endq($id, $tp, $user):void
|
||||
{
|
||||
$pl = mysql_fetch_array(mysql_query('SELECT * FROM `quests` WHERE `delete` = "0" AND `min_lvl` <= "' . $user['level'] . '" AND `max_lvl` >= "' . $user['level'] . '" AND `id` = "' . mysql_real_escape_string($id) . '" LIMIT 1'));
|
||||
$qlst = mysql_fetch_array(mysql_query('SELECT `id` FROM `actions` WHERE `uid` = "' . $user['id'] . '" AND `vars` = "start_quest' . $pl['id'] . '" AND `vals` = "go" LIMIT 1'));
|
||||
if (isset($qlst['id'])) {
|
||||
if ($tp == 'end') {
|
||||
mysql_query('UPDATE `actions` SET `vals` = "end" WHERE `id` = "' . $qlst['id'] . '" LIMIT 1');
|
||||
$this->error = 'Вы успешно отказались от задания "' . $pl['name'] . '"';
|
||||
} elseif ($tp == 'win') {
|
||||
mysql_query('UPDATE `actions` SET `vals` = "win" WHERE `id` = "' . $qlst['id'] . '" LIMIT 1');
|
||||
}
|
||||
} else {
|
||||
$this->error = 'Не удалось отказаться от задания ...';
|
||||
}
|
||||
}
|
||||
|
||||
public function testAction($filter, $tp)
|
||||
{
|
||||
if ($tp == 1) {
|
||||
$ins = mysql_fetch_array(mysql_query('SELECT `id`, `uid`, `time`, `city`, `room`, `vars`, `ip`, `vals`, `val` FROM `actions` WHERE ' . $filter . ''));
|
||||
} elseif ($tp == 2) {
|
||||
$ins = mysql_fetch_array(mysql_query('SELECT COUNT(`id`) FROM `actions` WHERE ' . $filter . ''));
|
||||
}
|
||||
return $ins;
|
||||
}
|
||||
|
||||
public function timeOut($ttm): string
|
||||
{
|
||||
$out = '';
|
||||
$time_still = $ttm;
|
||||
$tmp = floor($time_still / 2592000);
|
||||
$id = 0;
|
||||
if ($tmp > 0) {
|
||||
$id++;
|
||||
if ($id < 3) {
|
||||
$out .= $tmp . " мес. ";
|
||||
}
|
||||
$time_still = $time_still - $tmp * 2592000;
|
||||
}
|
||||
$tmp = floor($time_still / 86400);
|
||||
if ($tmp > 0) {
|
||||
$id++;
|
||||
if ($id < 3) {
|
||||
$out .= $tmp . " дн. ";
|
||||
}
|
||||
$time_still = $time_still - $tmp * 86400;
|
||||
}
|
||||
$tmp = floor($time_still / 3600);
|
||||
if ($tmp > 0) {
|
||||
$id++;
|
||||
if ($id < 3) {
|
||||
$out .= $tmp . " ч. ";
|
||||
}
|
||||
$time_still = $time_still - $tmp * 3600;
|
||||
}
|
||||
$tmp = floor($time_still / 60);
|
||||
if ($tmp > 0) {
|
||||
$id++;
|
||||
if ($id < 3) {
|
||||
$out .= $tmp . " мин. ";
|
||||
}
|
||||
}
|
||||
if ($out == '') {
|
||||
if ($time_still < 0) {
|
||||
$time_still = 0;
|
||||
}
|
||||
$out = $time_still . ' сек.';
|
||||
}
|
||||
return $out;
|
||||
}
|
||||
|
||||
|
||||
public function expl($d)
|
||||
{
|
||||
$i = 0;
|
||||
$e = explode(':|:', $d);
|
||||
while ($i < count($e)) {
|
||||
$t = explode(':=:', $e[$i]);
|
||||
if (isset($t[0])) {
|
||||
$dr[$t[0]] = $t[1];
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
unset($i, $e, $t);
|
||||
return $dr;
|
||||
}
|
||||
|
||||
public function winqst($id, $user)
|
||||
{
|
||||
$bad = 0;
|
||||
$qlst = mysql_fetch_array(mysql_query('SELECT * FROM `actions` WHERE `uid` = "' . $user['id'] . '" AND `vars` = "start_quest' . $id . '" AND `vals` = "go" LIMIT 1'));
|
||||
$qu = mysql_fetch_array(mysql_query('SELECT * FROM `quests` WHERE `id` = "' . $id . '" LIMIT 1'));
|
||||
if (isset($qlst['id'])) {
|
||||
$d = $this->expl($qu['act_date']);
|
||||
|
||||
if (isset($d['heal'])) {
|
||||
$x = $this->testAction('`uid` = "' . $user['id'] . '" AND `time` > "' . $qlst['time'] . '" AND `vars` LIKE "heal%" AND `vars` != "heal_' . $user['id'] . '" LIMIT 1', 2);
|
||||
$x = ($x[0] + 0);
|
||||
if ($x < $d['heal']) {
|
||||
$bad = 1;
|
||||
}
|
||||
unset($x);
|
||||
}
|
||||
|
||||
if (isset($d['tr_win'])) {
|
||||
$x = $this->testAction('`uid` = "' . $user['id'] . '" AND `time` > "' . $qlst['time'] . '" AND `vars` = "win_fiz" LIMIT 1', 2);
|
||||
$x = (0 + $x[0]);
|
||||
if ($x < $d['tr_win']) {
|
||||
$bad = 1;
|
||||
}
|
||||
unset($x);
|
||||
}
|
||||
|
||||
if (isset($d['kill_clone'])) {
|
||||
$x = $this->testAction('`uid` = "' . $user['id'] . '" AND `time` > "' . $qlst['time'] . '" AND `vars` = "kill_clone" LIMIT 1', 2);
|
||||
$x = (0 + $x[0]);
|
||||
if ($x < $d['kill_clone']) {
|
||||
$bad = 1;
|
||||
}
|
||||
unset($x);
|
||||
}
|
||||
|
||||
if (isset($d['tr_win_haot'])) {
|
||||
$x = $this->testAction('`uid` = "' . $user['id'] . '" AND `time` > "' . $qlst['time'] . '" AND `vars` = "win_haot" LIMIT 1', 2);
|
||||
$x = (0 + $x[0]);
|
||||
if ($x < $d['tr_win_haot']) {
|
||||
$bad = 1;
|
||||
}
|
||||
unset($x);
|
||||
}
|
||||
|
||||
if (isset($d['kill_bot'])) {
|
||||
$ex = explode(',', $d['kill_bot']);
|
||||
$i = 0;
|
||||
while ($i < count($ex)) {
|
||||
$x = 0;
|
||||
$ex2 = explode('=', $ex[$i]);
|
||||
$bot2 = mysql_fetch_array(mysql_query('SELECT `id`, `login` FROM `users` WHERE `id` = "' . $ex2[0] . '" LIMIT 1'));
|
||||
if (isset($bot2['id'])) {
|
||||
if (isset($qlst['id'])) {
|
||||
$x = $this->testAction('`uid` = "' . $user['id'] . '" AND `time` > "' . $qlst['time'] . '" AND `vars` = "win_bot_' . $ex2[0] . '"', 2);
|
||||
$x = ($x[0] + 0);
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
if ($x < $ex2[1]) {
|
||||
$bad = 1;
|
||||
}
|
||||
unset($x);
|
||||
}
|
||||
|
||||
if ($bad == 0) {
|
||||
$nagr = $this->expl($qu['win_date']);
|
||||
mysql_query('UPDATE `actions` SET `vals` = "win" WHERE `uid` = "' . $user['id'] . '" AND `vars` = "start_quest' . $id . '" LIMIT 1');
|
||||
if (isset($nagr['add_cr'])) {
|
||||
$user['money'] += $nagr['add_cr'];
|
||||
$c .= $nagr['add_cr'] . ' кр. ';
|
||||
}
|
||||
if (isset($nagr['add_point'])) {
|
||||
$user['doblest'] += $nagr['add_point'];
|
||||
if (isset($nagr['add_cr'])) {
|
||||
$c .= 'и ' . $nagr['add_point'] . ' репутации ';
|
||||
} else {
|
||||
$c .= $nagr['add_point'] . ' репутации ';
|
||||
}
|
||||
}
|
||||
if (isset($nagr['add_exp'])) {
|
||||
$user['exp'] += $nagr['add_exp'];
|
||||
if (isset($nagr['add_cr']) || isset($nagr['add_point'])) {
|
||||
$c .= 'и ' . $nagr['add_exp'] . ' опыта';
|
||||
} else {
|
||||
$c .= $nagr['add_exp'] . ' опыта';
|
||||
}
|
||||
}
|
||||
mysql_query('UPDATE `users` SET `money` = "' . $user['money'] . '", `exp` = "' . $user['exp'] . '", `doblest` = "' . $user['doblest'] . '" WHERE `id` = "' . $user['id'] . '" LIMIT 1');
|
||||
$this->error = 'Вы успешно сдали задание!';
|
||||
$text = '<font style="color: Red;">Внимание!</font> За успешно выполненное задание Вы получили : ' . $c;
|
||||
$this->msg($text, '{[]}' . $user['login'] . '{[]}', User::getInstance()->getRoom());
|
||||
} else {
|
||||
$this->error = 'Не все условия задания были выполнены ...';
|
||||
}
|
||||
} else {
|
||||
$this->error = 'Квест не найден ...';
|
||||
}
|
||||
}
|
||||
|
||||
public function msg($text, $who, $room)
|
||||
{
|
||||
$fp = fopen("/tmp/chat.txt", "a");
|
||||
flock($fp, LOCK_EX);
|
||||
fputs($fp, ":[" . time() . "]:[{$who}]:[" . ($text) . "]:[" . $room . "]\r\n");
|
||||
fflush($fp);
|
||||
flock($fp, LOCK_UN);
|
||||
fclose($fp);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user