Merge
This commit is contained in:
+69
-55
@@ -247,7 +247,7 @@ class Battle
|
||||
|
||||
/**
|
||||
* @param int|null $experience
|
||||
* @param bool $hardcore поединок с гарантированной травмой
|
||||
* @param bool $hardcore поединок с гарантированной травмой
|
||||
* @return array|int[]
|
||||
*/
|
||||
public static function getType(?int $experience, bool $hardcore = false): array
|
||||
@@ -365,10 +365,10 @@ class Battle
|
||||
|
||||
Db::sql(
|
||||
'update stats set last_hp = ?, tactic7 = ? where id = ?', [
|
||||
$this->users[$this->uids[$uid]]['last_hp'],
|
||||
$this->users[$this->uids[$uid]]['tactic7'],
|
||||
$uid,
|
||||
]
|
||||
$this->users[$this->uids[$uid]]['last_hp'],
|
||||
$this->users[$this->uids[$uid]]['tactic7'],
|
||||
$uid,
|
||||
]
|
||||
);
|
||||
|
||||
return (int)$hp;
|
||||
@@ -1139,9 +1139,9 @@ JS;
|
||||
|
||||
/**
|
||||
* @param array $botLogins
|
||||
* @param int $counter
|
||||
* @param int $obr
|
||||
* @param int $unique для совместимости с непонятным вызовом User->addAction
|
||||
* @param int $counter
|
||||
* @param int $obr
|
||||
* @param int $unique для совместимости с непонятным вызовом User->addAction
|
||||
* при вызове уникального монстра.
|
||||
* @return void
|
||||
*/
|
||||
@@ -1231,14 +1231,14 @@ JS;
|
||||
/** Осторожно! Подключаются файлы!!!
|
||||
* Трогать очень осторожно. Этот шайтан как-то проверяет приёмы на враге
|
||||
* и рассчитывает урон учитывая и эти приёмы тоже.
|
||||
* @param int $uid1
|
||||
* @param int $uid2
|
||||
* @param int $priem
|
||||
* @param int $uid1
|
||||
* @param int $uid2
|
||||
* @param int $priem
|
||||
* @param $yron
|
||||
* @param int $profil
|
||||
* @param int $profil
|
||||
* @param bool $stabil
|
||||
* @param bool $test
|
||||
* @param int $inlog
|
||||
* @param int $inlog
|
||||
* @return float|int|mixed
|
||||
*/
|
||||
public function testYronPriem(
|
||||
@@ -1250,7 +1250,8 @@ JS;
|
||||
bool $stabil,
|
||||
bool $test = false,
|
||||
int $inlog = 0
|
||||
): mixed {
|
||||
): mixed
|
||||
{
|
||||
|
||||
/**
|
||||
* profil = {
|
||||
@@ -1524,7 +1525,12 @@ JS;
|
||||
$jstext = json_encode($log['text']);
|
||||
$jsvars = json_encode($log['vars']);
|
||||
|
||||
$js = "add_log({$log['id']},0,$jstext,{$log['id_hod']},$jsvars);" . $js;
|
||||
//old
|
||||
//$js = "add_log({$log['id']},0,$jstext,{$log['id_hod']},0,0,$jsvars)" . $js;
|
||||
//home
|
||||
//$js = "add_log({$log['id']},0,$jstext,{$log['id_hod']},$jsvars);" . $js;
|
||||
//work
|
||||
$js = "add_log({$log['id']},$jstext,{$log['id_hod']},$jsvars);" . $js;
|
||||
}
|
||||
|
||||
Db::sql('update stats set alog = ? where id = ?', [$u->info['alog'], $u->info['id']]);
|
||||
@@ -1589,8 +1595,15 @@ JS;
|
||||
$jstext = json_encode($log['text']);
|
||||
$jsvars = json_encode($log['vars']);
|
||||
|
||||
//$js = "add_mlog({$log['id']},0,$jstext,{$log['id_hod']},$jsvars);" . $js;
|
||||
$js = "add_mlog({$log['id']},0,'{$log['text']}',{$log['id_hod']},'{$log['vars']}');" . $js;
|
||||
$js = "add_mlog({$log['id']},0,$jstext,{$log['id_hod']},0,0,$jsvars)" . $js;
|
||||
|
||||
//old
|
||||
//$js = "add_mlog({$log['id']},0,$jstext,{$log['id_hod']},0,0,$jsvars)" . $js;
|
||||
//home
|
||||
////$js = "add_mlog({$log['id']},0,$jstext,{$log['id_hod']},$jsvars);" . $js;
|
||||
//$js = "add_mlog({$log['id']},0,'{$log['text']}',{$log['id_hod']},'{$log['vars']}');" . $js;
|
||||
//work
|
||||
$js = "add_mlog({$log['id']},$jstext,{$log['id_hod']},$jsvars)" . $js;
|
||||
}
|
||||
|
||||
Db::sql('update stats set mlog = ? where id = ?', [$u->info['mlog'], $u->info['id']]);
|
||||
@@ -1920,17 +1933,6 @@ JS;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Массово встречается в подключаемых файлах приёмов.
|
||||
* @param array $arr
|
||||
* @return void
|
||||
* @deprecated
|
||||
*/
|
||||
public function add_log(array $arr): void
|
||||
{
|
||||
Log::add($arr);
|
||||
}
|
||||
|
||||
private function botAtack($uid, $pl, $tp): void
|
||||
{
|
||||
$testAttack = Db::getValue('select count(id) from battle_act where battle = ? and uid1 in (?,?) and uid2 in(?,?) and uid1 != uid2', [$this->i->id, $pl, $uid, $pl, $uid]) === 0;
|
||||
@@ -1963,8 +1965,6 @@ JS;
|
||||
}
|
||||
}
|
||||
|
||||
//Используем приемы
|
||||
|
||||
public function startAtack($id): void
|
||||
{
|
||||
global $u, $priem;
|
||||
@@ -2413,12 +2413,14 @@ JS;
|
||||
Db::sql('delete from battle_act where id = ?', [$id]);
|
||||
}
|
||||
|
||||
//Используем приемы
|
||||
|
||||
/** Осторожно! Подключаются файлы!!!
|
||||
* @param array $pl
|
||||
* @param array $pl
|
||||
* @param $u1
|
||||
* @param int $t
|
||||
* @param int $t
|
||||
* @param int|array $u2
|
||||
* @param string $rznm
|
||||
* @param string $rznm
|
||||
* @return void
|
||||
*/
|
||||
public function delPriem(
|
||||
@@ -2427,7 +2429,8 @@ JS;
|
||||
int $t = 1,
|
||||
int|array $u2 = 0,
|
||||
string $rznm = 'Очиститься Кровью'
|
||||
): void {
|
||||
): void
|
||||
{
|
||||
global $u, $priem;
|
||||
if (!isset($pl['priem']['id']) || isset($this->del_val['eff'][$pl['priem']['id']])) {
|
||||
return;
|
||||
@@ -2484,8 +2487,6 @@ JS;
|
||||
$this->stats[$this->uids[$pl['uid']]] = $u->getStats($pl['uid'], 0, 0, false, false, true);
|
||||
}
|
||||
|
||||
//Повторная проверка приемов
|
||||
|
||||
/**
|
||||
* Расчет количества блоков и противников?
|
||||
* @param $uid
|
||||
@@ -2564,7 +2565,7 @@ JS;
|
||||
}
|
||||
}
|
||||
|
||||
//Проверка действия приема
|
||||
//Повторная проверка приемов
|
||||
|
||||
/**
|
||||
* Магия предметов?
|
||||
@@ -2597,7 +2598,7 @@ JS;
|
||||
}
|
||||
}
|
||||
|
||||
//Проверка урона приемов
|
||||
//Проверка действия приема
|
||||
|
||||
private function newRazmen($id): array
|
||||
{
|
||||
@@ -2618,6 +2619,8 @@ JS;
|
||||
return $at;
|
||||
}
|
||||
|
||||
//Проверка урона приемов
|
||||
|
||||
private function usersTestAtack($id, $uid1, $uid2): array
|
||||
{
|
||||
$r = [];
|
||||
@@ -2681,8 +2684,6 @@ JS;
|
||||
return $r;
|
||||
}
|
||||
|
||||
//Наносим удар между игроками
|
||||
|
||||
public function priemsRazmen(array|int $id, array|string $at): void
|
||||
{
|
||||
if ($at == 'fast') {
|
||||
@@ -2734,6 +2735,8 @@ JS;
|
||||
}
|
||||
}
|
||||
|
||||
//Наносим удар между игроками
|
||||
|
||||
/** Осторожно! Подключаются файлы!!!
|
||||
* @param $id
|
||||
* @param $at
|
||||
@@ -2955,10 +2958,6 @@ JS;
|
||||
return $at;
|
||||
}
|
||||
|
||||
|
||||
//Расчет типа удара от оружия
|
||||
//Расчет урона от оружия
|
||||
|
||||
public function testPogB($uid, $yr, $pliid, $test = 0)
|
||||
{
|
||||
$checktuman = Db::getValue('select count(id) from eff_users where uid = ? and v2 in (273,286,287,288)', [$uid]) == 0; //проверка на туманный образ
|
||||
@@ -3059,6 +3058,8 @@ JS;
|
||||
return $yr2;
|
||||
}
|
||||
|
||||
|
||||
//Расчет типа удара от оружия
|
||||
//Расчет урона от оружия
|
||||
|
||||
/**
|
||||
@@ -3226,8 +3227,7 @@ JS;
|
||||
return $at;
|
||||
}
|
||||
|
||||
|
||||
//Расчет защиты
|
||||
//Расчет урона от оружия
|
||||
|
||||
public function yhod_user($uid1, $uid2, $type)
|
||||
{
|
||||
@@ -3288,7 +3288,8 @@ JS;
|
||||
return $r;
|
||||
}
|
||||
|
||||
//Расчет защиты (магия)
|
||||
|
||||
//Расчет защиты
|
||||
|
||||
/**
|
||||
* Добавляем опыт \ нанесенный урон.
|
||||
@@ -3447,6 +3448,8 @@ JS;
|
||||
}
|
||||
}
|
||||
|
||||
//Расчет защиты (магия)
|
||||
|
||||
private function clearCache($uid): void
|
||||
{
|
||||
if ($uid <= 0 || isset($this->uclearc[$uid])) {
|
||||
@@ -3871,7 +3874,6 @@ JS;
|
||||
return '{' . $a . 'x' . $id . 'x' . $rnd . '}';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Свиток спасения.
|
||||
*
|
||||
@@ -3998,7 +4000,8 @@ JS;
|
||||
$hodID,
|
||||
$tm1 = 0,
|
||||
$tm2 = 0
|
||||
): void {
|
||||
): void
|
||||
{
|
||||
$time = time();
|
||||
if ($tm1 == 0) {
|
||||
$tm1 = isset($this->atacks[$id]) ? $this->atacks[$id]['time'] : $time;
|
||||
@@ -4032,8 +4035,6 @@ JS;
|
||||
Log::add($mas);
|
||||
}
|
||||
|
||||
//Расчет МФ
|
||||
|
||||
/**
|
||||
* Возращаем зоны блока?
|
||||
* @param $uid1
|
||||
@@ -4050,6 +4051,8 @@ JS;
|
||||
}
|
||||
}
|
||||
|
||||
//Расчет МФ
|
||||
|
||||
private function saveStats($uid): void
|
||||
{
|
||||
Stats::saveBattleStats($this->stats[$this->uids[$uid]], $uid);
|
||||
@@ -4120,8 +4123,6 @@ JS;
|
||||
return $result ?: [];
|
||||
}
|
||||
|
||||
//Действия бота (атака)
|
||||
|
||||
/**
|
||||
* Смерть от пропуска ходов. Включается в конфиге.
|
||||
* @param int $id
|
||||
@@ -4154,7 +4155,7 @@ JS;
|
||||
}
|
||||
}
|
||||
|
||||
//Проверяем удары, приемы, свитки, зверей
|
||||
//Действия бота (атака)
|
||||
|
||||
private function addNewAtack(User $u): void
|
||||
{
|
||||
@@ -4240,7 +4241,7 @@ JS;
|
||||
|
||||
}
|
||||
|
||||
//Действия бота
|
||||
//Проверяем удары, приемы, свитки, зверей
|
||||
|
||||
private function botAct($uid): bool
|
||||
{
|
||||
@@ -4257,6 +4258,19 @@ JS;
|
||||
return $r;
|
||||
}
|
||||
|
||||
//Действия бота
|
||||
|
||||
/**
|
||||
* Массово встречается в подключаемых файлах приёмов.
|
||||
* @param array $arr
|
||||
* @return void
|
||||
* @deprecated
|
||||
*/
|
||||
public function add_log(array $arr): void
|
||||
{
|
||||
Log::add($arr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Запись выбранных ударов и блоков в массив $this->uAtc.
|
||||
* Технически это сеттер.
|
||||
|
||||
+202
-212
@@ -10,6 +10,7 @@ use Core\Config;
|
||||
use Core\Db;
|
||||
use Delo;
|
||||
use ItemModel;
|
||||
use Model\ActionModel;
|
||||
use User;
|
||||
use User\Clan;
|
||||
use User\Effects;
|
||||
@@ -54,7 +55,7 @@ class Finish
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//данные о игроках в бою
|
||||
$t = Db::getRows(
|
||||
@@ -125,7 +126,7 @@ class Finish
|
||||
}
|
||||
|
||||
$this->battle->i->setPlayerC();
|
||||
|
||||
|
||||
Db::sql('update battle set players_c = ? where id = ?', [$this->battle->i->getPlayersC(), $this->battle->i->id]);
|
||||
|
||||
if (!empty($vtvl)) {
|
||||
@@ -255,8 +256,7 @@ class Finish
|
||||
|
||||
mysql_query(
|
||||
'INSERT INTO `dungeon_items` (`dn`,`item_id`,`time`,`x`,`y`) VALUES (
|
||||
"' . $this->battle->users[$i]['dnow'] . '","' . $plik['item_id'] . '","' . (time(
|
||||
) - 600) . '","' . $this->battle->users[$i]['x'] . '","' . $this->battle->users[$i]['y'] . '"
|
||||
"' . $this->battle->users[$i]['dnow'] . '","' . $plik['item_id'] . '","' . (time() - 600) . '","' . $this->battle->users[$i]['x'] . '","' . $this->battle->users[$i]['y'] . '"
|
||||
)'
|
||||
);
|
||||
}
|
||||
@@ -488,8 +488,7 @@ class Finish
|
||||
'UPDATE `users` SET `battle` = "0" WHERE `id` = "' . $this->battle->users[$i]['id'] . '" LIMIT 1'
|
||||
);
|
||||
mysql_query(
|
||||
'UPDATE `stats` SET `zv` = "0",`team` = "0",`exp` = `exp` + `battle_exp`,`battle_exp` = "0",`battle_yron` = "0",`enemy` = "0", `timeGo` = "' . time(
|
||||
) . '" WHERE `id` = "' . $this->battle->users[$i]['id'] . '" LIMIT 1'
|
||||
'UPDATE `stats` SET `zv` = "0",`team` = "0",`exp` = `exp` + `battle_exp`,`battle_exp` = "0",`battle_yron` = "0",`enemy` = "0", `timeGo` = "' . time() . '" WHERE `id` = "' . $this->battle->users[$i]['id'] . '" LIMIT 1'
|
||||
);
|
||||
mysql_query('DELETE FROM `eff_users` WHERE `uid` = "' . $this->battle->users[$i]['id'] . '" LIMIT 100');
|
||||
}
|
||||
@@ -687,8 +686,7 @@ class Finish
|
||||
}
|
||||
}
|
||||
mysql_query(
|
||||
'UPDATE `dungeon_bots` SET `delete` = "' . time(
|
||||
) . '" AND `inBattle` = "' . $this->battle->i->id . '" WHERE `dn` = "' . $this->battle->i->dnId . '" AND `for_dn` = "0" AND `delete` = "0" '
|
||||
'UPDATE `dungeon_bots` SET `delete` = "' . time() . '" AND `inBattle` = "' . $this->battle->i->id . '" WHERE `dn` = "' . $this->battle->i->dnId . '" AND `for_dn` = "0" AND `delete` = "0" '
|
||||
);
|
||||
} else {
|
||||
//выкидываем всех игроков в клетку RESTART
|
||||
@@ -722,7 +720,7 @@ class Finish
|
||||
$this->expCoef += $this->battle->stats[$i]['pbe'];
|
||||
}
|
||||
|
||||
if ($this->battle->i->razdel == 5 && (Config::get('m') >= 6 && Config::get('m') <= 8 || Config::get('w') == 0 || Config::get('w') == 6)) {
|
||||
if ($this->battle->i->razdel == 5 && (date('m') >= 6 && date('m') <= 8 || date('w') == 0 || date('w') == 6)) {
|
||||
$this->expCoef += 5;
|
||||
}
|
||||
|
||||
@@ -911,11 +909,8 @@ class Finish
|
||||
$this->battle->users[$i]['battle_exp'] = floor($this->battle->users[$i]['battle_exp'] / 2);
|
||||
}
|
||||
if ($this->battle->users[$i]['animal'] > 0) {
|
||||
$ulan = $u->testAction(
|
||||
'`uid` = "' . $this->battle->users[$i]['id'] . '" AND `vars` = "animal_use' . $this->battle->i->id . '" LIMIT 1',
|
||||
1
|
||||
);
|
||||
if (isset($ulan['id']) && $this->battle->users[$i]['team'] == $this->battle->i->getTeamwin() && $this->battle->users[$i]['level'] > $ulan['vals']) {
|
||||
$ulan = ActionModel::getOne(["uid = {$this->battle->users[$i]['id']}", "vars = animal_use{$this->battle->i->id}"], 'vals');
|
||||
if ($ulan['id'] && $this->battle->users[$i]['team'] == $this->battle->i->getTeamwin() && $this->battle->users[$i]['level'] > $ulan) {
|
||||
$a004 = mysql_fetch_array(
|
||||
mysql_query(
|
||||
'SELECT `max_exp`,`name` FROM `users_animal` WHERE `uid` = "' . $this->battle->users[$i]['id'] . '" AND `id` = "' . $this->battle->users[$i]['animal'] . '" AND `pet_in_cage` = "0" AND `delete` = "0" LIMIT 1'
|
||||
@@ -1032,13 +1027,13 @@ class Finish
|
||||
];
|
||||
$admn = $admn[$this->battle->users[$i]['level']];
|
||||
|
||||
if (Config::get('m') >= 6 && Config::get('m') <= 8) {
|
||||
if (date('m') >= 6 && date('m') <= 8) {
|
||||
//Летний период
|
||||
if (Config::get('w') == 0 || Config::get('w') == 5 || Config::get('w') == 6) {
|
||||
if (date('w') == 0 || date('w') == 5 || date('w') == 6) {
|
||||
//Выходные дни
|
||||
$admn = $admn * 2;
|
||||
}
|
||||
} elseif (Config::get('w') == 0 || Config::get('w') == 5 || Config::get('w') == 6) {
|
||||
} elseif (date('w') == 0 || date('w') == 5 || date('w') == 6) {
|
||||
//Выходные дни
|
||||
$admn = $admn * 2;
|
||||
}
|
||||
@@ -1290,17 +1285,14 @@ class Finish
|
||||
}
|
||||
if ($this->battle->users[$i]['battle_yron'] > 0) {
|
||||
mysql_query(
|
||||
'INSERT INTO `eff_users` (`no_Ace`,`id_eff`,`overType`,`uid`,`name`,`data`,`timeUse`) VALUES ("1","478","111","' . $this->battle->users[$i]['id'] . '","Право на подвиг","pravonapodvig=1","' . time(
|
||||
) . '")'
|
||||
'INSERT INTO `eff_users` (`no_Ace`,`id_eff`,`overType`,`uid`,`name`,`data`,`timeUse`) VALUES ("1","478","111","' . $this->battle->users[$i]['id'] . '","Право на подвиг","pravonapodvig=1","' . time() . '")'
|
||||
);
|
||||
}
|
||||
mysql_query(
|
||||
'INSERT INTO `actions`(`uid`, `time`, `city`, `room`, `vars`, `ip`, `vals`, `val`) VALUES ("' . $this->battle->users[$i]['id'] . '","' . time(
|
||||
) . '","capitalcity","' . $this->battle->users[$i]['room'] . '","end_trup"," ","","")'
|
||||
'INSERT INTO `actions`(`uid`, `time`, `city`, `room`, `vars`, `ip`, `vals`, `val`) VALUES ("' . $this->battle->users[$i]['id'] . '","' . time() . '","capitalcity","' . $this->battle->users[$i]['room'] . '","end_trup"," ","","")'
|
||||
);
|
||||
mysql_query(
|
||||
'INSERT INTO `eff_users` (`no_Ace`,`id_eff`,`overType`,`uid`,`name`,`data`,`timeUse`) VALUES ("1","479","112","' . $u->info['id'] . '","Защита от нападения","zashitatk=1","' . time(
|
||||
) . '")'
|
||||
'INSERT INTO `eff_users` (`no_Ace`,`id_eff`,`overType`,`uid`,`name`,`data`,`timeUse`) VALUES ("1","479","112","' . $u->info['id'] . '","Защита от нападения","zashitatk=1","' . time() . '")'
|
||||
);
|
||||
$ritem = rand(1, 1000);
|
||||
if ($ritem == 555) {
|
||||
@@ -1361,8 +1353,7 @@ class Finish
|
||||
'UPDATE `rep` SET `rep3` = `rep3` + "' . $rzbvo . '" WHERE `id` = "' . $this->battle->users[$i]['id'] . '" LIMIT 1'
|
||||
);
|
||||
mysql_query(
|
||||
'INSERT INTO `actions`(`uid`, `time`, `city`, `room`, `vars`, `ip`, `vals`, `val`) VALUES ("' . $this->battle->users[$i]['id'] . '","' . time(
|
||||
) . '","capitalcity","' . $this->battle->users[$i]['room'] . '","end_xaot"," ","","")'
|
||||
'INSERT INTO `actions`(`uid`, `time`, `city`, `room`, `vars`, `ip`, `vals`, `val`) VALUES ("' . $this->battle->users[$i]['id'] . '","' . time() . '","capitalcity","' . $this->battle->users[$i]['room'] . '","end_xaot"," ","","")'
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1467,7 +1458,7 @@ class Finish
|
||||
$this->battle->users[$i]['id'],
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
if ($this->battle->i->turnir == 0) {
|
||||
//пишем в чат
|
||||
$cmsg->setTo($this->battle->users[$i]['login']);
|
||||
@@ -1514,17 +1505,19 @@ class Finish
|
||||
|
||||
}
|
||||
|
||||
private function addItemToItemsLocal(int $itemId, int $uid, string $data = ''): void
|
||||
/**
|
||||
* Сохраняем лог в архив
|
||||
* @return void
|
||||
*/
|
||||
private function saveLogs(): void
|
||||
{
|
||||
Db::sql(
|
||||
"insert into items_local (room, time, item_id, data, tr_login, colvo) values (?,unix_timestamp(),?,?,?,1)",
|
||||
[
|
||||
$this->battle->users[$this->battle->uids[$uid]]['room'],
|
||||
$itemId,
|
||||
$data,
|
||||
$this->battle->users[$this->battle->uids[$uid]]['login'],
|
||||
]
|
||||
'insert into battle_logs_save select id, time, battle, id_hod, text, vars, zona1, zonb1, zona2, zonb2, type from battle_logs where battle = ? and id_hod <= ?',
|
||||
[$this->battle->i->id, $this->battle->hodID]
|
||||
);
|
||||
Db::sql('delete from battle_logs where battle = ?', [$this->battle->i->id]);
|
||||
Db::sql('delete from battle_stat where battle < ?', [$this->battle->i->id - 100]);
|
||||
Db::sql('delete from battle_actions where btl = ?', [$this->battle->i->id]);
|
||||
}
|
||||
|
||||
private function addGlobalItems($bid, $uid, $itm, $ico, $exp, $cr, $ecr): void
|
||||
@@ -1583,159 +1576,53 @@ class Finish
|
||||
$this->addGlobalItemItm($itm, $uid, $cmsg, $chat);
|
||||
}
|
||||
|
||||
/**
|
||||
* Сохраняем лог в архив
|
||||
* @return void
|
||||
*/
|
||||
private function saveLogs(): void
|
||||
private function addGlobalItemsDropsOnMainStreet(int $bid, int $uid): void
|
||||
{
|
||||
Db::sql(
|
||||
'insert into battle_logs_save select id, time, battle, id_hod, text, vars, zona1, zonb1, zona2, zonb2, type from battle_logs where battle = ? and id_hod <= ?',
|
||||
[$this->battle->i->id, $this->battle->hodID]
|
||||
);
|
||||
Db::sql('delete from battle_logs where battle = ?', [$this->battle->i->id]);
|
||||
Db::sql('delete from battle_stat where battle < ?', [$this->battle->i->id - 100]);
|
||||
Db::sql('delete from battle_actions where btl = ?', [$this->battle->i->id]);
|
||||
//Выпадение дропа на ЦП
|
||||
$mf = Db::getValue('select floor(count(id) / 20) as c from users where online > unix_timestamp() - 120');
|
||||
$mf = mt_rand(1, max($mf, 1));
|
||||
if ($bid == 1008) {
|
||||
//Старый Новый Год
|
||||
for ($i = 0; $i < $mf; $i++) {
|
||||
if (mt_rand(0, 1) === 1) {
|
||||
continue;
|
||||
}
|
||||
if (mt_rand(0, 86) <= 71) {
|
||||
for ($j = 1; $j <= 7; $j++) {
|
||||
$this->addItemToItemsLocal(1000, $uid, '|nosale=1|srok=259200');
|
||||
}
|
||||
} else {
|
||||
$customs = [911, 1172, 1173, 1461, 1462, 1463, 2141, 2142, 2143, 2144, 2870, 4037, 4038, 4039, 4040];
|
||||
$this->addItemToItemsLocal($customs[array_rand($customs)], $uid, '|nosale=1|srok=259200');
|
||||
}
|
||||
}
|
||||
} elseif ($bid == 1007) {
|
||||
//Хэллоуин, Тыквоголовый CAPITAL CITY
|
||||
for ($i = 0; $i < $mf; $i++) {
|
||||
if (mt_rand(0, 1) === 1) {
|
||||
continue;
|
||||
}
|
||||
$this->addItemToItemsLocal(4504, $uid);
|
||||
}
|
||||
} elseif ($bid == 1006 && mt_rand(1, 10) === 1 || in_array($bid, range(1000, 1004))) {
|
||||
//Трупожор CAPITAL CITY
|
||||
$this->addItemToItemsLocal(4451, $uid, 'srok=2592000');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private function dieInDungeon(int $dnr, int $i, User $u, ChatMessage $cmsg, Chat $chat): void
|
||||
private function addItemToItemsLocal(int $itemId, int $uid, string $data = ''): void
|
||||
{
|
||||
if ($dnr != 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
$vars = $this->battle->users[$i]['room'] == 370 ? 'dielaba' : 'die';
|
||||
$dies = Actions::countDungeon(
|
||||
$this->battle->users[$i]['dnow'],
|
||||
$this->battle->users[$i]['id'],
|
||||
$vars
|
||||
Db::sql(
|
||||
"insert into items_local (room, time, item_id, data, tr_login, colvo) values (?,unix_timestamp(),?,?,?,1)",
|
||||
[
|
||||
$this->battle->users[$this->battle->uids[$uid]]['room'],
|
||||
$itemId,
|
||||
$data,
|
||||
$this->battle->users[$this->battle->uids[$uid]]['login'],
|
||||
]
|
||||
);
|
||||
Actions::addDungeon(
|
||||
$this->battle->users[$i]['dnow'],
|
||||
$this->battle->users[$i]['id'],
|
||||
$this->battle->users[$i]['x'],
|
||||
$this->battle->users[$i]['y'],
|
||||
$vars
|
||||
);
|
||||
|
||||
$la = $this->battle->users[$i]['sex'] == 1 ? 'ла' : '';
|
||||
|
||||
if ($dies < 2 || $this->battle->i->dungeon == 15) {
|
||||
|
||||
$shaibaItemId = Db::getValue('select id from items_users where uid = ? and item_id = 4910 limit 1', [$this->battle->users[$i]['id']]);
|
||||
|
||||
if ($shaibaItemId) {
|
||||
//выбрасываем шайбу
|
||||
ItemsModel::delete($shaibaItemId);
|
||||
Db::sql(
|
||||
"insert into dungeon_obj (name, dn, x, y, img, action, w, h, os1, os2, os3, date)
|
||||
values ('Шайба',?,?,?,'shaiba.png','fileact:15/shaiba',120,220,5,8,12,?)",
|
||||
[
|
||||
$this->battle->i->dnId,
|
||||
$this->battle->users[$i]['x'],
|
||||
$this->battle->users[$i]['y'],
|
||||
"{use:'takeit',rt1:69,rl1:-47,rt2:74,rl2:126,rt3:76,rl3:140,rt4:80,rl4:150}",
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
//телепортируем в рестарт (координата 0х0)
|
||||
$this->battle->users[$i]['x'] = $this->battle->users[$i]['res_x'];
|
||||
$this->battle->users[$i]['y'] = $this->battle->users[$i]['res_y'];
|
||||
$this->battle->users[$i]['s'] = $this->battle->users[$i]['res_s'];
|
||||
|
||||
$roomName = Db::getValue('select name from room where id = ?', [(int)$this->battle->users[$i]['room']]);
|
||||
|
||||
$reviveRoomName = $this->battle->users[$i]['room'] == 370 ? 'начале лабиринта' : "комнате «{$roomName}»";
|
||||
$rtxt = "<strong>{$this->battle->users[$i]['login']}</strong> трагически погиб$la и находится в $reviveRoomName";
|
||||
|
||||
} elseif ($this->battle->i->dungeon == 102) {
|
||||
$nld = '';
|
||||
$lab = Db::getRow('select id, users from laba_now where id = ?', [$this->battle->users[$i]['id']]);
|
||||
|
||||
if ($lab['users'] < 2) {
|
||||
//Удаляем подземелье
|
||||
Db::sql('delete from laba_now where id = ?', [$lab['id']]);
|
||||
Db::sql('delete from laba_map where id = ?', [$lab['id']]);
|
||||
Db::sql('delete from laba_obj where lib = ?', [$lab['id']]);
|
||||
Db::sql('delete from laba_act where lib = ?', [$lab['id']]);
|
||||
Db::sql('delete from laba_itm where lib = ?', [$lab['id']]);
|
||||
} else {
|
||||
$lab['users']--;
|
||||
mysql_query(
|
||||
'UPDATE `laba_now` SET `users` = "' . $lab['users'] . '" WHERE `id` = "' . $lab['id'] . '" LIMIT 1'
|
||||
);
|
||||
}
|
||||
mysql_query(
|
||||
'UPDATE `stats` SET `dnow` = "0" WHERE `id` = "' . $this->battle->users[$i]['id'] . '" LIMIT 1'
|
||||
);
|
||||
mysql_query(
|
||||
'UPDATE `users` SET `room` = "369" WHERE `id` = "' . $this->battle->users[$i]['id'] . '" LIMIT 1'
|
||||
);
|
||||
//удаляем все предметы которые пропадают после выхода из пещеры
|
||||
mysql_query(
|
||||
'UPDATE `items_users` SET `delete` = "' . time(
|
||||
) . '" WHERE `uid` = "' . $this->battle->users[$i]['id'] . '" AND `delete` < 1234567890 AND `inShop` = "0" AND (`dn_delete` = "1" OR `data` LIKE "%fromlaba=1%")'
|
||||
);
|
||||
if ($this->battle->users[$i]['login'] != '') {
|
||||
if ($this->battle->users[$i]['sex'] == 0) {
|
||||
$rtxt = '<strong>' . $this->battle->users[$i]['login'] . '</strong> трагически погиб без права на воскрешение и покидает подземелье' . $nld;
|
||||
} else {
|
||||
$rtxt = '<strong>' . $this->battle->users[$i]['login'] . '</strong> трагически погибла без права на воскрешение и покидает подземелье' . $nld;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$tinf = mysql_fetch_array(
|
||||
mysql_query(
|
||||
'SELECT `uid` FROM `dungeon_now` WHERE `id` = "' . $this->battle->i->dnId . '" LIMIT 1'
|
||||
)
|
||||
);
|
||||
$nld = '';
|
||||
if ($tinf['uid'] == $this->battle->users[$i]['id']) {
|
||||
$tinf = mysql_fetch_array(
|
||||
mysql_query(
|
||||
'SELECT `id` FROM `stats` WHERE `dnow` = "' . $this->battle->i->dnId . '" AND `hpNow` >= 1 LIMIT 1'
|
||||
)
|
||||
);
|
||||
if (isset($tinf['id'])) {
|
||||
$tinf = mysql_fetch_array(
|
||||
mysql_query(
|
||||
'SELECT `id`,`login` FROM `users` WHERE `id` = "' . $tinf['id'] . '" LIMIT 1'
|
||||
)
|
||||
);
|
||||
$nld .= ', новым лидером становится "' . $tinf['login'] . '"';
|
||||
mysql_query(
|
||||
'UPDATE `dungeon_now` SET `uid` = "' . $tinf['id'] . '" WHERE `id` = "' . $this->battle->i->dnId . '" LIMIT 1'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
mysql_query(
|
||||
'UPDATE `stats` SET `dnow` = "0" WHERE `id` = "' . $this->battle->users[$i]['id'] . '" LIMIT 1'
|
||||
);
|
||||
mysql_query(
|
||||
'UPDATE `users` SET `room` = "321" WHERE `id` = "' . $this->battle->users[$i]['id'] . '" LIMIT 1'
|
||||
);
|
||||
//удаляем все предметы которые пропадают после выхода из пещеры
|
||||
mysql_query(
|
||||
'UPDATE `items_users` SET `delete` = "' . time() . '" WHERE `uid` = "' . $this->battle->users[$i]['id'] . '" AND `dn_delete` = "1" LIMIT 1000'
|
||||
);
|
||||
mysql_query(
|
||||
'UPDATE `items_users` SET `delete` = "' . time() . '" WHERE `uid` = "' . $u->info['id'] . '" AND `item_id` = "1189" OR `item_id` = "4447" OR `item_id` = "1174") LIMIT 1000'
|
||||
);
|
||||
|
||||
if ($this->battle->users[$i]['sex'] == 0) {
|
||||
$rtxt = '<strong>' . $this->battle->users[$i]['login'] . '</strong> трагически погиб без права на воскрешение и покидает подземелье' . $nld;
|
||||
} else {
|
||||
$rtxt = '<strong>' . $this->battle->users[$i]['login'] . '</strong> трагически погибла без права на воскрешение и покидает подземелье' . $nld;
|
||||
}
|
||||
}
|
||||
if (!empty($rtxt)) {
|
||||
$cmsg->setDn($this->battle->i->dnId);
|
||||
$cmsg->setText($rtxt);
|
||||
$cmsg->setTypeTime(1);
|
||||
$chat->sendMsg($cmsg);
|
||||
}
|
||||
}
|
||||
|
||||
private function addGlobalItemsIco(string $ico, int $uid, ChatMessage $cmsg, Chat $chat): void
|
||||
@@ -1862,40 +1749,143 @@ class Finish
|
||||
}
|
||||
}
|
||||
|
||||
private function addGlobalItemsDropsOnMainStreet(int $bid, int $uid): void
|
||||
private function dieInDungeon(int $dnr, int $i, User $u, ChatMessage $cmsg, Chat $chat): void
|
||||
{
|
||||
//Выпадение дропа на ЦП
|
||||
$mf = Db::getValue('select floor(count(id) / 20) as c from users where online > unix_timestamp() - 120');
|
||||
$mf = mt_rand(1, max($mf, 1));
|
||||
if ($bid == 1008) {
|
||||
//Старый Новый Год
|
||||
for ($i = 0; $i < $mf; $i++) {
|
||||
if (mt_rand(0, 1) === 1) {
|
||||
continue;
|
||||
}
|
||||
if (mt_rand(0, 86) <= 71) {
|
||||
for ($j = 1; $j <= 7; $j++) {
|
||||
$this->addItemToItemsLocal(1000, $uid, '|nosale=1|srok=259200');
|
||||
}
|
||||
} else {
|
||||
$customs = [911, 1172, 1173, 1461, 1462, 1463, 2141, 2142, 2143, 2144, 2870, 4037, 4038, 4039, 4040];
|
||||
$this->addItemToItemsLocal($customs[array_rand($customs)], $uid, '|nosale=1|srok=259200');
|
||||
}
|
||||
}
|
||||
} elseif ($bid == 1007) {
|
||||
//Хэллоуин, Тыквоголовый CAPITAL CITY
|
||||
for ($i = 0; $i < $mf; $i++) {
|
||||
if (mt_rand(0, 1) === 1) {
|
||||
continue;
|
||||
}
|
||||
$this->addItemToItemsLocal(4504, $uid);
|
||||
}
|
||||
} elseif ($bid == 1006 && mt_rand(1, 10) === 1 || in_array($bid, range(1000, 1004))) {
|
||||
//Трупожор CAPITAL CITY
|
||||
$this->addItemToItemsLocal(4451, $uid, 'srok=2592000');
|
||||
if ($dnr != 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
$vars = $this->battle->users[$i]['room'] == 370 ? 'dielaba' : 'die';
|
||||
$dies = Actions::countDungeon(
|
||||
$this->battle->users[$i]['dnow'],
|
||||
$this->battle->users[$i]['id'],
|
||||
$vars
|
||||
);
|
||||
Actions::addDungeon(
|
||||
$this->battle->users[$i]['dnow'],
|
||||
$this->battle->users[$i]['id'],
|
||||
$this->battle->users[$i]['x'],
|
||||
$this->battle->users[$i]['y'],
|
||||
$vars
|
||||
);
|
||||
|
||||
$la = $this->battle->users[$i]['sex'] == 1 ? 'ла' : '';
|
||||
|
||||
if ($dies < 2 || $this->battle->i->dungeon == 15) {
|
||||
|
||||
$shaibaItemId = Db::getValue('select id from items_users where uid = ? and item_id = 4910 limit 1', [$this->battle->users[$i]['id']]);
|
||||
|
||||
if ($shaibaItemId) {
|
||||
//выбрасываем шайбу
|
||||
ItemsModel::delete($shaibaItemId);
|
||||
Db::sql(
|
||||
"insert into dungeon_obj (name, dn, x, y, img, action, w, h, os1, os2, os3, date)
|
||||
values ('Шайба',?,?,?,'shaiba.png','fileact:15/shaiba',120,220,5,8,12,?)",
|
||||
[
|
||||
$this->battle->i->dnId,
|
||||
$this->battle->users[$i]['x'],
|
||||
$this->battle->users[$i]['y'],
|
||||
"{use:'takeit',rt1:69,rl1:-47,rt2:74,rl2:126,rt3:76,rl3:140,rt4:80,rl4:150}",
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
//телепортируем в рестарт (координата 0х0)
|
||||
$this->battle->users[$i]['x'] = $this->battle->users[$i]['res_x'];
|
||||
$this->battle->users[$i]['y'] = $this->battle->users[$i]['res_y'];
|
||||
$this->battle->users[$i]['s'] = $this->battle->users[$i]['res_s'];
|
||||
|
||||
$roomName = Db::getValue('select name from room where id = ?', [(int)$this->battle->users[$i]['room']]);
|
||||
|
||||
$reviveRoomName = $this->battle->users[$i]['room'] == 370 ? 'начале лабиринта' : "комнате «{$roomName}»";
|
||||
$rtxt = "<strong>{$this->battle->users[$i]['login']}</strong> трагически погиб$la и находится в $reviveRoomName";
|
||||
|
||||
} elseif ($this->battle->i->dungeon == 102) {
|
||||
$nld = '';
|
||||
$lab = Db::getRow('select id, users from laba_now where id = ?', [$this->battle->users[$i]['id']]);
|
||||
|
||||
if ($lab['users'] < 2) {
|
||||
//Удаляем подземелье
|
||||
Db::sql('delete from laba_now where id = ?', [$lab['id']]);
|
||||
Db::sql('delete from laba_map where id = ?', [$lab['id']]);
|
||||
Db::sql('delete from laba_obj where lib = ?', [$lab['id']]);
|
||||
Db::sql('delete from laba_act where lib = ?', [$lab['id']]);
|
||||
Db::sql('delete from laba_itm where lib = ?', [$lab['id']]);
|
||||
} else {
|
||||
$lab['users']--;
|
||||
mysql_query(
|
||||
'UPDATE `laba_now` SET `users` = "' . $lab['users'] . '" WHERE `id` = "' . $lab['id'] . '" LIMIT 1'
|
||||
);
|
||||
}
|
||||
mysql_query(
|
||||
'UPDATE `stats` SET `dnow` = "0" WHERE `id` = "' . $this->battle->users[$i]['id'] . '" LIMIT 1'
|
||||
);
|
||||
mysql_query(
|
||||
'UPDATE `users` SET `room` = "369" WHERE `id` = "' . $this->battle->users[$i]['id'] . '" LIMIT 1'
|
||||
);
|
||||
//удаляем все предметы которые пропадают после выхода из пещеры
|
||||
mysql_query(
|
||||
'UPDATE `items_users` SET `delete` = "' . time() . '" WHERE `uid` = "' . $this->battle->users[$i]['id'] . '" AND `delete` < 1234567890 AND `inShop` = "0" AND (`dn_delete` = "1" OR `data` LIKE "%fromlaba=1%")'
|
||||
);
|
||||
if ($this->battle->users[$i]['login'] != '') {
|
||||
if ($this->battle->users[$i]['sex'] == 0) {
|
||||
$rtxt = '<strong>' . $this->battle->users[$i]['login'] . '</strong> трагически погиб без права на воскрешение и покидает подземелье' . $nld;
|
||||
} else {
|
||||
$rtxt = '<strong>' . $this->battle->users[$i]['login'] . '</strong> трагически погибла без права на воскрешение и покидает подземелье' . $nld;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$tinf = mysql_fetch_array(
|
||||
mysql_query(
|
||||
'SELECT `uid` FROM `dungeon_now` WHERE `id` = "' . $this->battle->i->dnId . '" LIMIT 1'
|
||||
)
|
||||
);
|
||||
$nld = '';
|
||||
if ($tinf['uid'] == $this->battle->users[$i]['id']) {
|
||||
$tinf = mysql_fetch_array(
|
||||
mysql_query(
|
||||
'SELECT `id` FROM `stats` WHERE `dnow` = "' . $this->battle->i->dnId . '" AND `hpNow` >= 1 LIMIT 1'
|
||||
)
|
||||
);
|
||||
if (isset($tinf['id'])) {
|
||||
$tinf = mysql_fetch_array(
|
||||
mysql_query(
|
||||
'SELECT `id`,`login` FROM `users` WHERE `id` = "' . $tinf['id'] . '" LIMIT 1'
|
||||
)
|
||||
);
|
||||
$nld .= ', новым лидером становится "' . $tinf['login'] . '"';
|
||||
mysql_query(
|
||||
'UPDATE `dungeon_now` SET `uid` = "' . $tinf['id'] . '" WHERE `id` = "' . $this->battle->i->dnId . '" LIMIT 1'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
mysql_query(
|
||||
'UPDATE `stats` SET `dnow` = "0" WHERE `id` = "' . $this->battle->users[$i]['id'] . '" LIMIT 1'
|
||||
);
|
||||
mysql_query(
|
||||
'UPDATE `users` SET `room` = "321" WHERE `id` = "' . $this->battle->users[$i]['id'] . '" LIMIT 1'
|
||||
);
|
||||
//удаляем все предметы которые пропадают после выхода из пещеры
|
||||
mysql_query(
|
||||
'UPDATE `items_users` SET `delete` = "' . time() . '" WHERE `uid` = "' . $this->battle->users[$i]['id'] . '" AND `dn_delete` = "1" LIMIT 1000'
|
||||
);
|
||||
mysql_query(
|
||||
'UPDATE `items_users` SET `delete` = "' . time() . '" WHERE `uid` = "' . $u->info['id'] . '" AND `item_id` = "1189" OR `item_id` = "4447" OR `item_id` = "1174") LIMIT 1000'
|
||||
);
|
||||
|
||||
if ($this->battle->users[$i]['sex'] == 0) {
|
||||
$rtxt = '<strong>' . $this->battle->users[$i]['login'] . '</strong> трагически погиб без права на воскрешение и покидает подземелье' . $nld;
|
||||
} else {
|
||||
$rtxt = '<strong>' . $this->battle->users[$i]['login'] . '</strong> трагически погибла без права на воскрешение и покидает подземелье' . $nld;
|
||||
}
|
||||
}
|
||||
if (!empty($rtxt)) {
|
||||
$cmsg->setDn($this->battle->i->dnId);
|
||||
$cmsg->setText($rtxt);
|
||||
$cmsg->setTypeTime(1);
|
||||
$chat->sendMsg($cmsg);
|
||||
}
|
||||
}
|
||||
|
||||
public function getBtlstatus(): array
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use Helper\Conversion;
|
||||
use Model\ActionModel;
|
||||
use Model\Constant\Stat;
|
||||
|
||||
class BotPriemLogic
|
||||
@@ -105,7 +106,6 @@ class BotPriemLogic
|
||||
|
||||
private static function testpriem($pl): int
|
||||
{
|
||||
global $u;
|
||||
$notr = 0;
|
||||
$statnames = new Stat();
|
||||
$statnames->getRequirement();
|
||||
@@ -125,8 +125,8 @@ class BotPriemLogic
|
||||
}
|
||||
|
||||
if ($pl['xuse'] > 0) {
|
||||
$xu = $u->testAction('`vars` = "use_priem_' . BotLogic::$bot['battle'] . '_' . BotLogic::$bot['id'] . '" AND `vals` = "' . $pl['id'] . '" LIMIT ' . $pl['xuse'] . '', 2);
|
||||
if ($xu[0] >= $pl['xuse']) {
|
||||
$xu = ActionModel::testCount(['vars = ' . 'use_priem_' . BotLogic::$bot['battle'] . '_' . BotLogic::$bot['id'], "vals = {$pl['id']}",], $pl['xuse']);
|
||||
if ($xu >= $pl['xuse']) {
|
||||
$notr++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,14 +2,16 @@
|
||||
|
||||
namespace Core;
|
||||
|
||||
use DateTime;
|
||||
|
||||
class Config
|
||||
{
|
||||
const EKR_RUB_PRICE = 30;
|
||||
const KR_TO_EKR_EXCHANGE = 500;
|
||||
const EKR_TO_KR_EXCHANGE = 200;
|
||||
private const HOSTNAME = 'new-combats.tech';
|
||||
public const GAMENAME = 'Новый Бойцовский Клуб';
|
||||
private static self $instance;
|
||||
private static string $hostname = 'new-combats.tech';
|
||||
private static string $gamename = 'Бойцовский Клуб';
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
@@ -27,75 +29,51 @@ class Config
|
||||
|
||||
private static function subdomain(string $name): string
|
||||
{
|
||||
return DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR . $name . '.' . self::$hostname;
|
||||
return DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR . $name . '.' . self::HOSTNAME;
|
||||
}
|
||||
|
||||
public static function get(?string $key = null)
|
||||
{
|
||||
$c['ver'] = '1.8.3.7';
|
||||
$c['ver'] = '0.8.2 alpha';
|
||||
/* Конфигурации игры */
|
||||
$c['name'] = 'Новый «' . self::$gamename . '»';
|
||||
$c['title'] = $c['name'] . ' - Бесплатная,браузерная онлайн игра'; //Название игры
|
||||
$c['title2'] = ' - Бесплатная, онлайн игра посвященная сражениям и магии!';
|
||||
$c['title3'] = $c['name'];
|
||||
$c['keys'] = self::$gamename . ', combats.com, ' . self::$gamename . ' игра, ' . self::$gamename . ' играть, игра ' . self::$gamename . ', старый ' . self::$gamename . ', ' . self::$gamename . ' онлайн игра, ' . self::$gamename . ' браузерная игра, играть в ' . $c['name'] . ', игра бк, бк игра, старый бк, играть в бк, бк онлайн игра, новый бк, Легендарный ' . $c['name'] . ', легендарный бк, combats, комбатс, combats ru, combats com, OldBK, oldbk ru, oldbk com, олдбк, old bk, олд бк, mycombats, rebk, recombats, oldcombats, obk2'; //Ключевые слова META
|
||||
$c['desc'] = self::$gamename . ' – это бесплатная увлекательная браузерная онлайн игра 2004-2009г, в которой сконцентрировано все самое лучшее от современных онлайн игр. В этой браузерной игре заложены самые интересные традиции всем известной онлайн игры под названием «' . self::$gamename . ' 2004-2009», которая, кстати, стала первооткрывателем всех браузерных игр.'; //Описание META
|
||||
$c['footer'] = $c['name'] . ' © 2013-' . date('Y');
|
||||
$c['title'] = self::GAMENAME . ' - Бесплатная, браузерная онлайн игра'; //Название игры
|
||||
$c['keys'] = self::GAMENAME . ', combats.com, ' . self::GAMENAME . ' игра, ' . self::GAMENAME . ' играть, игра ' . self::GAMENAME . ', старый ' . self::GAMENAME . ', ' . self::GAMENAME . ' онлайн игра, ' . self::GAMENAME . ' браузерная игра, играть в ' . self::GAMENAME . ', игра бк, бк игра, старый бк, играть в бк, бк онлайн игра, новый бк, Легендарный ' . self::GAMENAME . ', легендарный бк, combats, комбатс, combats ru, combats com, OldBK, oldbk ru, oldbk com, олдбк, old bk, олд бк, mycombats, rebk, recombats, oldcombats, obk2'; //Ключевые слова META
|
||||
$c['desc'] = self::GAMENAME . ' – это бесплатная увлекательная браузерная онлайн игра 2004-2009г, в которой сконцентрировано все самое лучшее от современных онлайн игр. В этой браузерной игре заложены самые интересные традиции всем известной онлайн игры под названием «' . self::GAMENAME . ' 2004-2009», которая, кстати, стала первооткрывателем всех браузерных игр.'; //Описание META
|
||||
$c['footer'] = self::GAMENAME . ' © 2013-' . date('Y');
|
||||
|
||||
//Сервера
|
||||
$c['host'] = self::$hostname;
|
||||
$c['host'] = self::HOSTNAME;
|
||||
$c['forum'] = self::subdomain('forum');
|
||||
$c['img'] = 'img.' . self::$hostname;
|
||||
$c['thiscity'] = 'capitalcity';
|
||||
$c['capitalcity'] = self::$hostname;
|
||||
$c['abandonedplain'] = self::$hostname;
|
||||
$c['https'] = DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR . self::$hostname;
|
||||
$c['img'] = 'img.' . self::HOSTNAME;
|
||||
$c['https'] = DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR . self::HOSTNAME;
|
||||
$c['img2'] = self::subdomain('img');
|
||||
$c['lib'] = self::subdomain('lib');
|
||||
$c['exit'] = "<script>window.location.replace('{$c['https']}');</script>";
|
||||
$c['support'] = 'support@' . $c['host'];
|
||||
|
||||
|
||||
//Валюта
|
||||
$c['curency_name'] = 'RUB';
|
||||
$c['curency_value'] = 30;
|
||||
$c['support'] = 'support@' . self::HOSTNAME;
|
||||
|
||||
//Бот клон
|
||||
$c['bot_level'] = 0; // до какого лвл бот (включительно)
|
||||
$c['propsk_die'] = 0; //Смерть при пропуске ходов, 0 - выкл. , >= 1 - количество пропусков до смерти при нападении
|
||||
|
||||
//Скупка
|
||||
$c['exp'] = 0; //бонус опыта
|
||||
$c['shop_type1'] = 100; //в гос НЕ ТРОГАТЬ
|
||||
|
||||
//Скупка
|
||||
$c['shop_type2'] = 90; //в березку НЕ ТРОГАТЬ
|
||||
$c['shop_all'] = 0; //Скупка на все! , 0 - сделать для отключения скупки.
|
||||
$c['shop_all_type1'] = 100; //Скупка только с госе! , 0 - сделать для отключения скупки.
|
||||
$c['shop_all_type2'] = 100; //Скупка только с березки! , 0 - сделать для отключения скупки.
|
||||
//
|
||||
$c['nosanich'] = true; //Странички Саныча не выпадают - true , выпадают - false
|
||||
$c['zuby'] = false; //зубы
|
||||
|
||||
$c['limitedexp'] = false; //лимит опыта
|
||||
$c['expstop'] = 2999999; //9; //Опыт на котором останавливаемся 11 149999999
|
||||
$c['expstopu'] = 2999999; //Опыт на котором останавливаемся
|
||||
$c['noobgade'] = false; //нуб квест (пещера)
|
||||
$c['level_ransfer'] = 8; //С какого уровня разрешены передачи
|
||||
|
||||
$c['level_transfer'] = 8; //С какого уровня разрешены передачи
|
||||
$c['noitembuy'] = false; //Не требует ресурсы для покупки
|
||||
$c['effz'] = 0; //Скольким секундам равен заряд
|
||||
$c['money_haot'] = true; //кр за хаоты
|
||||
$c['crtoecr'] = 500; //Курс обмена кр на екр (если 0, то выключено)
|
||||
$c['ecrtocr'] = 200; //Курс обмена екр на кр
|
||||
$c['bonuslevel'] = true; //Бонус уровня
|
||||
$c['bonussocial'] = false; //Бонус социальный
|
||||
|
||||
$c['w'] = date('w');
|
||||
$c['m'] = date('m');
|
||||
|
||||
$c['counters'] = '';
|
||||
$c['counters_noFrm'] = '';
|
||||
$c['securetime'] = 0; //Время последнего возможного взлома персов (подбор пароля по базам данных других игр)
|
||||
|
||||
$c['copyright'] = 'Copyright © ' . date('Y') . ' « Новый Бойцовский Клуб »';
|
||||
$c['db_host'] = 'db';
|
||||
$c['db_user'] = 'prod1';
|
||||
$c['db_name'] = 'game_production';
|
||||
@@ -110,4 +88,9 @@ class Config
|
||||
}
|
||||
return self::$instance;
|
||||
}
|
||||
|
||||
public static function getCopyright(): string
|
||||
{
|
||||
return '©' . (new DateTime())->format('Y') . ' Copyright «<a href="//' . self::HOSTNAME . '">' . self::GAMENAME . '</a>». All Rights Reserved.';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
namespace Core;
|
||||
|
||||
readonly class TOTP
|
||||
{
|
||||
private const BASE32CHARS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'; // RFC 4648 Base32
|
||||
|
||||
public function __construct(private string $secret)
|
||||
{
|
||||
}
|
||||
|
||||
public static function otpSecret($uniqueString, $length = 20): string
|
||||
{
|
||||
// Уникальная строка + текущее время в микросекундах
|
||||
$seed = $uniqueString . microtime(true);
|
||||
|
||||
// Хэшируем сид для более случайного распределения
|
||||
$seed = hash('sha256', $seed);
|
||||
|
||||
$secret = '';
|
||||
$max = strlen(self::BASE32CHARS) - 1;
|
||||
|
||||
// Генерируем случайную строку нужной длины
|
||||
for ($i = 0; $i < $length; $i++) {
|
||||
$index = hexdec(substr($seed, $i, 2)) % $max; // Получаем индекс символа из хэшированного сида
|
||||
$secret .= self::BASE32CHARS[$index];
|
||||
}
|
||||
|
||||
return $secret;
|
||||
}
|
||||
|
||||
public function generate(int $digits = 6, int $timeStep = 30): string
|
||||
{
|
||||
$time = floor(time() / $timeStep);
|
||||
$secretKey = $this->base32_decode($this->secret);
|
||||
$binaryTime = pack('N*', 0) . pack('N*', $time);
|
||||
$hash = hash_hmac('sha1', $binaryTime, $secretKey, true);
|
||||
$offset = ord($hash[strlen($hash) - 1]) & 0x0F;
|
||||
$otp = (
|
||||
((ord($hash[$offset]) & 0x7F) << 24) |
|
||||
((ord($hash[$offset + 1]) & 0xFF) << 16) |
|
||||
((ord($hash[$offset + 2]) & 0xFF) << 8) |
|
||||
(ord($hash[$offset + 3]) & 0xFF)
|
||||
) % 10 ** $digits;
|
||||
return str_pad((string)$otp, $digits, '0', STR_PAD_LEFT);
|
||||
}
|
||||
|
||||
private function base32_decode(string $input): string
|
||||
{
|
||||
$base32charsFlipped = array_flip(str_split(self::BASE32CHARS));
|
||||
$output = '';
|
||||
$v = 0;
|
||||
$vbits = 0;
|
||||
|
||||
for ($i = 0, $j = strlen($input); $i < $j; $i++) {
|
||||
$v <<= 5;
|
||||
if ($input[$i] == '=') continue;
|
||||
$v += $base32charsFlipped[$input[$i]];
|
||||
$vbits += 5;
|
||||
|
||||
if ($vbits >= 8) {
|
||||
$vbits -= 8;
|
||||
$output .= chr(($v & (0xFF << $vbits)) >> $vbits);
|
||||
}
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
+76
-102
@@ -2,6 +2,7 @@
|
||||
|
||||
use Core\Db;
|
||||
use Helper\Conversion;
|
||||
use Model\ActionModel;
|
||||
use User\ItemsModel;
|
||||
use User\Stats;
|
||||
|
||||
@@ -413,7 +414,7 @@ class Dungeon
|
||||
if ($usr_real['clan'] > 0) {
|
||||
$usrreal .= '<img src=//img.new-combats.tech/i/clan/' . $usr_real['clan'] . '.gif width=24 height=15 >';
|
||||
}
|
||||
$usrreal .= '<b>' . $usr_real['login'] . '</b>[' . $usr_real['level'] . ']<a target=_blank href=/info/' . $usr_real['id'] . ' ><img width=12 hiehgt=11 src=//img.new-combats.tech/i/inf_capitalcity.gif ></a>';
|
||||
$usrreal .= '<b>' . $usr_real['login'] . '</b>[' . $usr_real['level'] . ']<a target=_blank href=/info/' . $usr_real['id'] . ' ><img width=12 heihgt=11 src=//img.new-combats.tech/i/inf_capitalcity.gif ></a>';
|
||||
} else {
|
||||
$mereal = '<i>Невидимка</i>[??]';
|
||||
}
|
||||
@@ -425,7 +426,7 @@ class Dungeon
|
||||
if ($me_real['clan'] > 0) {
|
||||
$mereal .= '<img src=//img.new-combats.tech/i/clan/' . $me_real['clan'] . '.gif width=24 height=15 >';
|
||||
}
|
||||
$mereal .= '<b>' . $me_real['login'] . '</b>[' . $me_real['level'] . ']<a target=_blank href=/info/' . $me_real['id'] . ' ><img width=12 hiehgt=11 src=//img.new-combats.tech/i/inf_capitalcity.gif ></a>';
|
||||
$mereal .= '<b>' . $me_real['login'] . '</b>[' . $me_real['level'] . ']<a target=_blank href=/info/' . $me_real['id'] . ' ><img width=12 heihgt=11 src=//img.new-combats.tech/i/inf_capitalcity.gif ></a>';
|
||||
} else {
|
||||
$mereal = '<i>Невидимка</i>[??]';
|
||||
}
|
||||
@@ -540,7 +541,7 @@ class Dungeon
|
||||
if ($usr_real['clan'] > 0) {
|
||||
$usrreal .= '<img src=//img.new-combats.tech/i/clan/' . $usr_real['clan'] . '.gif width=24 height=15 >';
|
||||
}
|
||||
$usrreal .= '<b>' . $usr_real['login'] . '</b>[' . $usr_real['level'] . ']<a target=_blank href=/info/' . $usr_real['id'] . ' ><img width=12 hiehgt=11 src=//img.new-combats.tech/i/inf_capitalcity.gif ></a>';
|
||||
$usrreal .= '<b>' . $usr_real['login'] . '</b>[' . $usr_real['level'] . ']<a target=_blank href=/info/' . $usr_real['id'] . ' ><img width=12 heihgt=11 src=//img.new-combats.tech/i/inf_capitalcity.gif ></a>';
|
||||
} else {
|
||||
$mereal = '<i>Невидимка</i>[??]';
|
||||
}
|
||||
@@ -552,7 +553,7 @@ class Dungeon
|
||||
if ($me_real['clan'] > 0) {
|
||||
$mereal .= '<img src=//img.new-combats.tech/i/clan/' . $me_real['clan'] . '.gif width=24 height=15 >';
|
||||
}
|
||||
$mereal .= '<b>' . $me_real['login'] . '</b>[' . $me_real['level'] . ']<a target=_blank href=/info/' . $me_real['id'] . ' ><img width=12 hiehgt=11 src=//img.new-combats.tech/i/inf_capitalcity.gif ></a>';
|
||||
$mereal .= '<b>' . $me_real['login'] . '</b>[' . $me_real['level'] . ']<a target=_blank href=/info/' . $me_real['id'] . ' ><img width=12 heihgt=11 src=//img.new-combats.tech/i/inf_capitalcity.gif ></a>';
|
||||
} else {
|
||||
$mereal = '<i>Невидимка</i>[??]';
|
||||
}
|
||||
@@ -876,7 +877,7 @@ class Dungeon
|
||||
$i = count($a);
|
||||
}
|
||||
} elseif ($s[0] == 'repl_ptp') {
|
||||
require_once('dnaction/_dungeon_replace.php');
|
||||
require_once 'dnaction/_dungeon_replace.php';
|
||||
die();
|
||||
} elseif ($s[0] == 'add_eff') {
|
||||
//Кастуем эффект
|
||||
@@ -884,16 +885,10 @@ class Dungeon
|
||||
$j = 0;
|
||||
while ($j < count($t)) {
|
||||
$itm = explode('=', $t[$j]);
|
||||
$ch = $u->testAction(
|
||||
'`vars` = "add_eff_' . $this->info['id'] . '_' . $obj['id'] . '" AND `uid` = "' . $this->userinfo['id'] . '" LIMIT ' . (1 + (int)$itm[2]) . '',
|
||||
2
|
||||
); //кол-во прошлых попыток
|
||||
$ch = $ch[0];
|
||||
$ch2 = $u->testAction(
|
||||
' `vars` = "add_eff_' . $this->info['id'] . '_' . $obj['id'] . '" LIMIT ' . (1 + (int)$itm[4]) . '',
|
||||
2
|
||||
); //кол-во прошлых попыток (все юзеры)
|
||||
$ch2 = $ch2[0];
|
||||
|
||||
$ch = ActionModel::testCount(["uid = {$this->userinfo['id']}", "vars = add_eff_{$this->info['id']}_{$obj['id']}"], 1 + (int)$itm[2]); //кол-во прошлых попыток
|
||||
$ch2 = ActionModel::testCount(["vars = add_eff_{$this->info['id']}_{$obj['id']}"], 1 + (int)$itm[4]); //кол-во прошлых попыток (все юзеры)
|
||||
|
||||
if (($ch2 < $itm[4] || $itm[4] == 0) && $ch < $itm[2]) {
|
||||
if ($itm[1] * 100 >= rand(0, 10000)) {
|
||||
//удачно
|
||||
@@ -936,11 +931,8 @@ class Dungeon
|
||||
$t = explode(',', $s[1]);
|
||||
while ($j < count($t)) {
|
||||
$itm = explode('=', $t[$j]);
|
||||
$ch = $u->testAction(
|
||||
'`vars` = "bafit_' . $this->info['id'] . '_' . $obj['id'] . '" LIMIT ' . (1 + (int)$itm[2]) . '',
|
||||
2
|
||||
); //кол-во прошлых попыток
|
||||
$ch = $ch[0];
|
||||
$ch = ActionModel::testCount(["vars = bafit_{$this->info['id']}_{$obj['id']}"], 1 + (int)$itm[2]); //кол-во прошлых попыток
|
||||
|
||||
if ($ch < $itm[3]) {
|
||||
if ($itm[2] * 1000 >= rand(1, 100000)) {
|
||||
if ($itm[0] == 'hpNow') {
|
||||
@@ -1026,11 +1018,8 @@ class Dungeon
|
||||
$t = explode(',', $s[1]);
|
||||
while ($j < count($t)) {
|
||||
$itm = explode('=', $t[$j]);
|
||||
$ch = $u->testAction(
|
||||
'`uid` = "' . $this->userinfo['id'] . '" AND `vars` = "takeit_' . $this->info['id'] . '_' . $obj['id'] . '" LIMIT ' . (1 + (int)$itm[2]) . '',
|
||||
2
|
||||
); //кол-во прошлых попыток
|
||||
$ch = $ch[0];
|
||||
$ch = ActionModel::testCount(["uid = {$this->userinfo['id']}", "vars = takeit_{$this->info['id']}_{$obj['id']}"], 1 + (int)$itm[2]); //кол-во прошлых попыток
|
||||
|
||||
if ($ch >= $itm[2]) {
|
||||
//закончились попытки
|
||||
$r = 'ничего не произошло...<br>';
|
||||
@@ -1050,9 +1039,8 @@ class Dungeon
|
||||
);
|
||||
if (isset($it['id'])) {
|
||||
$r .= 'Вы обнаружили предмет "<b>' . $it['name'] . '</b>".<br>';
|
||||
ItemsModel::addItem(
|
||||
['uid' => $this->userinfo['id'], 'iid' => $it['id'], 'x' => $this->userinfo['x'], 'y' => $this->userinfo['y'], 'del' => (int)$itm[4]]
|
||||
);
|
||||
ItemsModel::addItem($it['id'], $this->userinfo['id']);
|
||||
//ItemsModel::addItem(['uid' => $this->userinfo['id'], 'iid' => $it['id'], 'x' => $this->userinfo['x'], 'y' => $this->userinfo['y'], 'del' => (int)$itm[4]]);
|
||||
}
|
||||
} else {
|
||||
//неудачная попытка
|
||||
@@ -1067,98 +1055,84 @@ class Dungeon
|
||||
}
|
||||
} elseif ($s[0] == 'itm1') {
|
||||
//Добавляем предмет , только 1 предмет из всех и все юзеры могут тоже
|
||||
$nj = 0;
|
||||
$t = explode(',', $s[1]);
|
||||
$j = rand(0, count($t));
|
||||
if ($nj == 0) {
|
||||
$itm = explode('=', $t[$j]);
|
||||
$ch = $u->testAction(
|
||||
'`uid` = "' . $this->userinfo['id'] . '" AND `vars` = "takeit_' . $this->info['id'] . '_' . $obj['id'] . '" LIMIT ' . (1 + (int)$itm[2]) . '',
|
||||
2
|
||||
); //кол-во прошлых попыток
|
||||
$ch = $ch[0];
|
||||
if ($ch >= $itm[2]) {
|
||||
//закончились попытки
|
||||
$r .= 'Странно, но ничего не произошло... <br>';
|
||||
} else {
|
||||
if ($itm[1] * 1000 >= rand(1, 100000)) {
|
||||
$itm = explode('=', $t[$j]);
|
||||
$ch = ActionModel::testCount(["uid = {$this->userinfo['id']}", "vars = takeit_{$this->info['id']}_{$obj['id']}"], 1 + (int)$itm[2]); //кол-во прошлых попыток
|
||||
|
||||
//Случайный предмет (Башня смерти)
|
||||
if ($itm[0] == 'random1') {
|
||||
$itm[0] = $this->itbs[rand(0, count($this->itbs))];
|
||||
}
|
||||
if ($ch >= $itm[2]) {
|
||||
//закончились попытки
|
||||
$r .= 'Странно, но ничего не произошло... <br>';
|
||||
} else {
|
||||
if ($itm[1] * 1000 >= rand(1, 100000)) {
|
||||
|
||||
//удачная попытка
|
||||
$it = mysql_fetch_assoc(
|
||||
mysql_query(
|
||||
'SELECT * FROM `items_main` WHERE `id`="' . ((int)$itm[0]) . '" LIMIT 1'
|
||||
)
|
||||
);
|
||||
if (isset($it['id'])) {
|
||||
$r .= 'Вы обнаружили предмет "<b>' . $it['name'] . '</b>".<br>';
|
||||
$u->addAction(
|
||||
time(), 'takeit_' . $this->info['id'] . '_' . $obj['id'], $this->userinfo['city']
|
||||
);
|
||||
ItemsModel::addItem(
|
||||
['uid' => $this->userinfo['id'], 'iid' => $it['id'], 'x' => $this->userinfo['x'], 'y' => $this->userinfo['y'], 'del' => (int)$itm[4]]
|
||||
);
|
||||
$nj++;
|
||||
}
|
||||
} else {
|
||||
//неудачная попытка
|
||||
//Случайный предмет (Башня смерти)
|
||||
if ($itm[0] == 'random1') {
|
||||
$itm[0] = $this->itbs[rand(0, count($this->itbs))];
|
||||
}
|
||||
|
||||
//удачная попытка
|
||||
$it = mysql_fetch_assoc(
|
||||
mysql_query(
|
||||
'SELECT * FROM `items_main` WHERE `id`="' . ((int)$itm[0]) . '" LIMIT 1'
|
||||
)
|
||||
);
|
||||
if (isset($it['id'])) {
|
||||
$r .= 'Вы обнаружили предмет "<b>' . $it['name'] . '</b>".<br>';
|
||||
$u->addAction(
|
||||
time(), 'takeit_' . $this->info['id'] . '_' . $obj['id'], $this->userinfo['city']
|
||||
);
|
||||
$r .= 'Вы ничего не нашли ... <br>';
|
||||
ItemsModel::addItem($it['id'], $this->userinfo['id']);
|
||||
//ItemsModel::addItem(['uid' => $this->userinfo['id'], 'iid' => $it['id'], 'x' => $this->userinfo['x'], 'y' => $this->userinfo['y'], 'del' => (int)$itm[4]]);
|
||||
}
|
||||
} else {
|
||||
//неудачная попытка
|
||||
$u->addAction(
|
||||
time(), 'takeit_' . $this->info['id'] . '_' . $obj['id'], $this->userinfo['city']
|
||||
);
|
||||
$r .= 'Вы ничего не нашли ... <br>';
|
||||
}
|
||||
}
|
||||
|
||||
} elseif ($s[0] == 'itm2') {
|
||||
//Добавляем предмет , только 1 предмет из всех и только 1 юзер может поднять
|
||||
$nj = 0;
|
||||
|
||||
$t = explode(',', $s[1]);
|
||||
$j = rand(0, count($t) - 1);
|
||||
if ($nj == 0) {
|
||||
$itm = explode('=', $t[$j]);
|
||||
$ch = $u->testAction(
|
||||
'`vars` = "takeit_' . $this->info['id'] . '_' . $obj['id'] . '" LIMIT ' . (1 + (int)$itm[2]) . '',
|
||||
2
|
||||
); //кол-во прошлых попыток
|
||||
$ch = $ch[0];
|
||||
if ($ch >= $itm[2]) {
|
||||
//закончились попытки
|
||||
$r .= 'Ничего не произошло... <br>';
|
||||
} else {
|
||||
if ($itm[1] * 1000 >= rand(1, 100000)) {
|
||||
$itm = explode('=', $t[$j]);
|
||||
$ch = ActionModel::testCount(["vars = takeit_{$this->info['id']}_{$obj['id']}"], 1 + (int)$itm[2]); //кол-во прошлых попыток
|
||||
|
||||
//Случайный предмет (Башня смерти)
|
||||
if ($itm[0] == 'random1') {
|
||||
$itm[0] = $this->itbs[rand(0, count($this->itbs))];
|
||||
}
|
||||
if ($ch >= $itm[2]) {
|
||||
//закончились попытки
|
||||
$r .= 'Ничего не произошло... <br>';
|
||||
} else {
|
||||
if ($itm[1] * 1000 >= rand(1, 100000)) {
|
||||
|
||||
//удачная попытка
|
||||
$it = mysql_fetch_assoc(
|
||||
mysql_query(
|
||||
'SELECT * FROM `items_main` WHERE `id`="' . ((int)$itm[0]) . '" LIMIT 1'
|
||||
)
|
||||
);
|
||||
if (isset($it['id'])) {
|
||||
$r .= 'Вы обнаружили предмет "<b>' . $it['name'] . '</b>".<br>';
|
||||
$u->addAction(
|
||||
time(), 'takeit_' . $this->info['id'] . '_' . $obj['id'], $this->userinfo['city']
|
||||
);
|
||||
ItemsModel::addItem(
|
||||
['uid' => $this->userinfo['id'], 'iid' => $it['id'], 'x' => $this->userinfo['x'], 'y' => $this->userinfo['y'], 'del' => (int)$itm[4]]
|
||||
);
|
||||
$nj++;
|
||||
}
|
||||
} else {
|
||||
//неудачная попытка
|
||||
//Случайный предмет (Башня смерти)
|
||||
if ($itm[0] == 'random1') {
|
||||
$itm[0] = $this->itbs[rand(0, count($this->itbs))];
|
||||
}
|
||||
|
||||
//удачная попытка
|
||||
$it = mysql_fetch_assoc(
|
||||
mysql_query(
|
||||
'SELECT * FROM `items_main` WHERE `id`="' . ((int)$itm[0]) . '" LIMIT 1'
|
||||
)
|
||||
);
|
||||
if (isset($it['id'])) {
|
||||
$r .= 'Вы обнаружили предмет "<b>' . $it['name'] . '</b>".<br>';
|
||||
$u->addAction(
|
||||
time(), 'takeit_' . $this->info['id'] . '_' . $obj['id'], $this->userinfo['city']
|
||||
);
|
||||
$r .= 'Вы ничего не нашли ... <br>';
|
||||
ItemsModel::addItem($it['id'], $this->userinfo['id']);
|
||||
//ItemsModel::addItem(['uid' => $this->userinfo['id'], 'iid' => $it['id'], 'x' => $this->userinfo['x'], 'y' => $this->userinfo['y'], 'del' => (int)$itm[4]]);
|
||||
}
|
||||
} else {
|
||||
//неудачная попытка
|
||||
$u->addAction(
|
||||
time(), 'takeit_' . $this->info['id'] . '_' . $obj['id'], $this->userinfo['city']
|
||||
);
|
||||
$r .= 'Вы ничего не нашли ... <br>';
|
||||
}
|
||||
}
|
||||
} elseif ($s[0] == 'fileact') {
|
||||
@@ -1166,7 +1140,7 @@ class Dungeon
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$r = rtrim($r, '\<br\>');
|
||||
$r = rtrim($r, '\<br>');
|
||||
if ($r == '') {
|
||||
$r = 'В этот раз не удалось найти что-либо еще';
|
||||
}
|
||||
@@ -1690,7 +1664,7 @@ class Dungeon
|
||||
}
|
||||
|
||||
|
||||
$sp = mysql_query('SELECT * FROM `dungeon_now` WHERE `time_finish` = "0" LIMIT 50');
|
||||
$sp = mysql_query('select * from dungeon_now where time_finish = 0 limit 50');
|
||||
while ($pl = mysql_fetch_assoc($sp)) {
|
||||
$cn = mysql_fetch_assoc(
|
||||
mysql_query('SELECT `id` FROM `stats` WHERE `dnow` = "' . $pl['id'] . '" LIMIT 1')
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace Helper;
|
||||
|
||||
use Exception;
|
||||
|
||||
class QueryBuilder
|
||||
{
|
||||
public function __construct(private readonly string $tableName, private string $columns = '*') {}
|
||||
|
||||
public function setColumns(string $columns): void
|
||||
{
|
||||
$this->columns = $columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function select(array $filters = [], int $limit = 0): array
|
||||
{
|
||||
if (empty($filters)) {
|
||||
return ['sql' => "select $this->columns from $this->tableName"];
|
||||
}
|
||||
$where = [];
|
||||
$params = [];
|
||||
foreach ($filters as $filter) {
|
||||
[$name, $operation, $value] = explode(' ', $filter, 3);
|
||||
$placeholder = ":$name";
|
||||
$value = explode(' ', $value, 3); //todo: а ведь может прилететь значение из нескольких слов с пробелом...
|
||||
if (count($value) === 1) {
|
||||
$value = $value[0];
|
||||
if (is_numeric($value)) {
|
||||
$value = (int)$value;
|
||||
}
|
||||
} else {
|
||||
array_walk_recursive($value, function (&$var) {
|
||||
if (is_numeric($var)) {
|
||||
$var = (int)$var;
|
||||
}
|
||||
});
|
||||
if (is_numeric($value[0]) && is_numeric($value[2])) {
|
||||
$value = match ($value[1]) {
|
||||
'+' => $value[0] + $value[2],
|
||||
'-' => $value[0] - $value[2],
|
||||
'*' => $value[0] * $value[2],
|
||||
'/' => ($value[2] != 0) ? $value[0] / $value[2] : throw new Exception('Деление на ноль недопустимо.'),
|
||||
default => throw new Exception('Недопустимый оператор. Допустимы: +, -, *, /.'),
|
||||
};
|
||||
} elseif (is_string($value[0])) {
|
||||
$placeholder = "$value[0] $value[1] :$name";
|
||||
$value = $value[2];
|
||||
} elseif (is_string($value[2])) {
|
||||
$placeholder = "$value[2] $value[1] :$name";
|
||||
$value = $value[0];
|
||||
}
|
||||
}
|
||||
//todo: но есть ещё форменное скотство, когда в запрос кидают сложные формулы...
|
||||
|
||||
$where[] = "$name $operation $placeholder";
|
||||
$params[$name] = $value;
|
||||
}
|
||||
|
||||
return [
|
||||
'sql' => "select $this->columns from $this->tableName where " . implode(" and ", $where) . ($limit > 0 ? " limit $limit" : ""),
|
||||
'binds' => $params,
|
||||
];
|
||||
}
|
||||
}
|
||||
+1
-168
@@ -1491,9 +1491,6 @@ class Magic
|
||||
} else {
|
||||
$u->error = 'Персонаж "' . $jl . '" не найден в этом городе (' . $u->info['city'] . ')';
|
||||
}
|
||||
} elseif (isset($st['useOnItem']) && $st['useOnItem'] == 1) {
|
||||
//используем на предмет
|
||||
|
||||
} else {
|
||||
//на себя
|
||||
$goodUse = 1;
|
||||
@@ -1502,170 +1499,7 @@ class Magic
|
||||
$u->error = 'Хаосники не могут использовать данное заклятие';
|
||||
}
|
||||
|
||||
if ($itm['magic_inci'] == 'sanich2') {
|
||||
if ($u->info['battle'] == 0) {
|
||||
$sz = $u->testAction(
|
||||
'`uid` = "' . $u->info['id'] . '" AND `vars` = "sanich2" AND `time` > ' . (time() - 4 * 60 * 60) . ' LIMIT 1', 1
|
||||
);
|
||||
if (!isset($sz['id'])) {
|
||||
$slech = rand(0, 4);
|
||||
$goodUse = 0;
|
||||
if ($slech == 1) {
|
||||
//3083 Настойка на жучьей требухе
|
||||
//$this->add_eff($u->info['id'],3083);
|
||||
mysql_query(
|
||||
'DELETE FROM `eff_users` WHERE `uid` = "' . $u->info['id'] . '" AND `id_eff` = 290 AND `delete` =0'
|
||||
);
|
||||
$this->addEffect($u->info['id'], 290);
|
||||
$echotext = 'Настойка на жучьей требухе!';
|
||||
$u->error = 'Вы получили эфект от ' . $echotext . '';
|
||||
} elseif ($slech == 2) {
|
||||
//5239 Амброзия подмастерья Владык
|
||||
//$this->add_eff($u->info['id'],5239);
|
||||
mysql_query(
|
||||
'DELETE FROM `eff_users` WHERE `uid` = "' . $u->info['id'] . '" AND `id_eff` = 472 AND `delete` =0'
|
||||
);
|
||||
mysql_query(
|
||||
'DELETE FROM `eff_users` WHERE `uid` = "' . $u->info['id'] . '" AND `id_eff` = 470 AND `delete` =0'
|
||||
);
|
||||
$this->addEffect($u->info['id'], 472);
|
||||
$echotext = 'Амброзия подмастерья Владык!';
|
||||
$u->error = 'Вы получили эфект от ' . $echotext . '';
|
||||
} elseif ($slech == 3) {
|
||||
//5069 Амброзия Скучающих Владык
|
||||
//$this->add_eff($u->info['id'],470);
|
||||
mysql_query(
|
||||
'DELETE FROM `eff_users` WHERE `uid` = "' . $u->info['id'] . '" AND `id_eff` = 472 AND `delete` =0'
|
||||
);
|
||||
mysql_query(
|
||||
'DELETE FROM `eff_users` WHERE `uid` = "' . $u->info['id'] . '" AND `id_eff` = 470 AND `delete` =0'
|
||||
);
|
||||
$this->addEffect($u->info['id'], 470);
|
||||
$echotext = 'Амброзия Скучающих Владык!';
|
||||
$u->error = 'Вы получили эфект от ' . $echotext . '';
|
||||
} elseif ($slech == 4) {
|
||||
//1463 Звездное Сияние
|
||||
//$this->add_eff($u->info['id'],1463);
|
||||
mysql_query(
|
||||
'DELETE FROM `eff_users` WHERE `uid` = "' . $u->info['id'] . '" AND `id_eff` = 35 AND `delete` =0'
|
||||
);
|
||||
$this->addEffect($u->info['id'], 35);
|
||||
$echotext = 'Звездное Сияние!';
|
||||
$u->error = 'Вы получили эфект от ' . $echotext . '';
|
||||
} else {
|
||||
$slech = 1;
|
||||
|
||||
$echotext = 'Не удалось прочитать страницу!';
|
||||
$u->error = ' ' . $echotext . ' ';
|
||||
}
|
||||
|
||||
$itm['iznosNOW'] += $slech;
|
||||
mysql_query(
|
||||
'UPDATE `items_users` SET `iznosNOW` = "' . $itm['iznosNOW'] . '" WHERE `id` = "' . $itm['id'] . '" AND `uid` = "' . $u->info['id'] . '" LIMIT 1'
|
||||
);
|
||||
$u->addAction(time(), 'sanich2', $slech);
|
||||
|
||||
if ($u->info['sex'] == 1) {
|
||||
$rtxt = '[img[items/' . $itm['img'] . ']] "' . $u->info['login'] . '" использовала "' . $itm['name'] . ' Саныча" и получила эффект ' . $echotext . ' травмы.';
|
||||
} else {
|
||||
$rtxt = '[img[items/' . $itm['img'] . ']] "' . $u->info['login'] . '" использовал "' . $itm['name'] . ' Саныча" и получил эффект ' . $echotext . ' травмы.';
|
||||
}
|
||||
|
||||
} else {
|
||||
$u->error = 'Задержка использования ' . Conversion::secondsToTimeout(
|
||||
($sz['time'] + 4 * 60 * 60) - time()
|
||||
) . '.';
|
||||
}
|
||||
} else {
|
||||
$u->error = 'Невозможно использовать в бою';
|
||||
}
|
||||
|
||||
} elseif ($itm['magic_inci'] == 'sanich1' && $u->info['battle'] > 0) {
|
||||
|
||||
$sz = $u->testAction(
|
||||
'`uid` = "' . $u->info['id'] . '" AND `vars` = "sanich1" AND `time` > ' . (time() - 6 * 60) . ' LIMIT 1', 1
|
||||
);
|
||||
if (!isset($sz['id'])) {
|
||||
$goodUse = 0;
|
||||
$u->error = 'Вы успешно использовали "' . $itm['name'] . '"';
|
||||
$z = 1;
|
||||
while ($z <= 5) {
|
||||
$u->info['tactic' . $z]++;
|
||||
if ($u->info['tactic' . $z] > 25) {
|
||||
$u->info['tactic' . $z] = 25;
|
||||
} elseif ($u->info['tactic' . $z] < 0) {
|
||||
$u->info['tactic' . $z] = 0;
|
||||
}
|
||||
$z++;
|
||||
}
|
||||
if ($u->info['sex'] == 1) {
|
||||
$this->inBattleLog('{u1} использовала "<b>' . $itm['name'] . ' Саныча</b>".');
|
||||
} else {
|
||||
$this->inBattleLog('{u1} использовал "<b>' . $itm['name'] . ' Саныча</b>".');
|
||||
}
|
||||
mysql_query(
|
||||
'UPDATE `stats` SET `tactic1` = "' . $u->info['tactic1'] . '",`tactic2` = "' . $u->info['tactic2'] . '",`tactic3` = "' . $u->info['tactic3'] . '",`tactic4` = "' . $u->info['tactic4'] . '",`tactic5` = "' . $u->info['tactic5'] . '" WHERE `id` = "' . $u->info['id'] . '" LIMIT 1'
|
||||
);
|
||||
$itm['iznosNOW']++;
|
||||
mysql_query(
|
||||
'UPDATE `items_users` SET `iznosNOW` = "' . $itm['iznosNOW'] . '" WHERE `id` = "' . $itm['id'] . '" AND `uid` = "' . $u->info['id'] . '" LIMIT 1'
|
||||
);
|
||||
$u->addAction(time(), 'sanich1', $u->info['battle']);
|
||||
} else {
|
||||
$u->error = 'Задержка использования ' . Conversion::secondsToTimeout(($sz['time'] + 6 * 60) - time()) . '.';
|
||||
}
|
||||
|
||||
} elseif ($itm['magic_inci'] == 'sanich3' && $u->info['battle'] > 0) {
|
||||
|
||||
$sz = $u->testAction(
|
||||
'`uid` = "' . $u->info['id'] . '" AND `vars` = "sanich3" AND `time` > ' . (time() - 3 * 60 * 60) . ' LIMIT 1', 1
|
||||
);
|
||||
if (!isset($sz['id'])) {
|
||||
|
||||
$usr = mysql_fetch_array(
|
||||
mysql_query(
|
||||
'SELECT `u`.`id`,`u`.`level`,`s`.`hpNow`,`s`.`team`,`u`.`login`,`u`.`sex` FROM `users` AS `u` LEFT JOIN `stats` AS `s` ON `s`.`id` = `u`.`id` WHERE `u`.`id` = "' . $u->info['enemy'] . '" AND `u`.`battle` = "' . $u->info['battle'] . '" LIMIT 1'
|
||||
)
|
||||
);
|
||||
if (isset($usr['id']) && $usr['hpNow'] >= 1) {
|
||||
$iznslvl = $usr['level'];
|
||||
|
||||
$goodUse = 0;
|
||||
$u->error = 'Вы успешно использовали "' . $itm['name'] . '" на ' . $usr['login'] . '';
|
||||
|
||||
if ($u->info['sex'] == 1) {
|
||||
$this->inBattleLog(
|
||||
'{u1} использовала "<b>' . $itm['name'] . ' Саныча</b>" на {u2}.',
|
||||
$usr
|
||||
);
|
||||
} else {
|
||||
$this->inBattleLog(
|
||||
'{u1} использовал "<b>' . $itm['name'] . ' Саныча</b>" на {u2}.', $usr
|
||||
);
|
||||
}
|
||||
|
||||
mysql_query(
|
||||
'UPDATE `stats` SET `hpNow` = "' . $usr['hpNow'] . '" WHERE `id` = "' . $u->info['id'] . '" LIMIT 1'
|
||||
);
|
||||
mysql_query(
|
||||
'UPDATE `stats` SET `hpNow` = "' . $u->stats['hpNow'] . '" WHERE `id` = "' . $usr['id'] . '" LIMIT 1'
|
||||
);
|
||||
$itm['iznosNOW'] += $iznslvl;
|
||||
mysql_query(
|
||||
'UPDATE `items_users` SET `iznosNOW` = "' . $itm['iznosNOW'] . '" WHERE `id` = "' . $itm['id'] . '" AND `uid` = "' . $u->info['id'] . '" LIMIT 1'
|
||||
);
|
||||
$u->addAction(time(), 'sanich3', $u->info['battle']);
|
||||
} else {
|
||||
$u->error = 'Нет подходящего противника';
|
||||
}
|
||||
|
||||
} else {
|
||||
$u->error = 'Задержка использования ' . Conversion::secondsToTimeout(
|
||||
($sz['time'] + 3 * 60 * 60) - time()
|
||||
) . '.';
|
||||
}
|
||||
|
||||
} elseif ($itm['magic_inci'] == 'lech') {
|
||||
if ($itm['magic_inci'] == 'lech') {
|
||||
$goodUse = 0;
|
||||
if ($u->info['level'] >= 2 and $u->info['level'] <= 13) {
|
||||
$travm = mysql_fetch_array(
|
||||
@@ -1698,7 +1532,6 @@ class Magic
|
||||
|
||||
|
||||
if ($goodUse == 1) {
|
||||
|
||||
$upd1 = 1;
|
||||
$upd2 = 1;
|
||||
//добавляем эффект персонажу
|
||||
|
||||
@@ -1,38 +1,39 @@
|
||||
<?php
|
||||
|
||||
use Core\Db;
|
||||
use Helper\Conversion;
|
||||
use Model\ActionModel;
|
||||
use User\ItemsModel;
|
||||
|
||||
if (!defined('GAME')) {
|
||||
die();
|
||||
}
|
||||
|
||||
if ($itm['magic_inci'] == 'podvig') {
|
||||
$test = mysql_fetch_array(mysql_query('SELECT `id`,`time` FROM `actions` WHERE `uid` = "' . $u->info['id'] . '" AND `vars` = "podvig" AND `time` > "' . (time()) . '" LIMIT 1'));
|
||||
if ($u->info['align'] != 2) {
|
||||
if (isset($test['id'])) {
|
||||
$u->error = 'Задержка не прошла, еще ' . Conversion::secondsToTimeout($test['time'] - time());
|
||||
} else {
|
||||
//
|
||||
$dngcity = [
|
||||
5035 => ['angelscity', 'Бездна'],
|
||||
5036 => ['capitalcity', 'Пещера Тысячи Проклятий'],
|
||||
5037 => ['demonscity', 'Катакомбы'],
|
||||
5038 => ['abandonedplain', 'Гора Легиона'], //mooncity
|
||||
5039 => ['suncity', 'Грибница'],
|
||||
5040 => ['sandcity', 'Пещера Мглы'],
|
||||
];
|
||||
$dngcity = $dngcity[$itm['item_id']];
|
||||
$hgo1 = $u->testAction('`uid` = "' . $u->info['id'] . '" AND `time` > "' . (time() - 86400) . '" AND `vars` = "psh_qt_' . $dngcity[0] . '" LIMIT 1', 1);
|
||||
if (!isset($hgo1['id'])) {
|
||||
$u->error = 'Нет задержки для подземелья ' . $dngcity[1] . '.';
|
||||
} else {
|
||||
$u->addAction(time(), 'podvig', '');
|
||||
$u->error = 'Успешно использован свиток Право на Подвиг (' . $dngcity[1] . ')';
|
||||
mysql_query('UPDATE `actions` SET `time` = "' . (time() - 86401) . '" WHERE `id` = "' . ($hgo1['id']) . '" LIMIT 1');
|
||||
mysql_query('UPDATE `items_users` SET `iznosNOW` = `iznosNOW` + 1 WHERE `id` = "' . $itm['id'] . '" LIMIT 1');
|
||||
}
|
||||
}
|
||||
$test = Db::getRow("select id, time from actions where uid = ? and vars = 'podvig' and time > unix_timestamp() limit 1", [$u->info['id']]);
|
||||
if (isset($test['id'])) {
|
||||
$u->error = 'Задержка не прошла, еще ' . Conversion::secondsToTimeout($test['time'] - time());
|
||||
} else {
|
||||
$u->error = 'Хаосники не могут пользоваться этим свитком!';
|
||||
//
|
||||
$dngcity = [
|
||||
5035 => ['angelscity', 'Бездна'],
|
||||
5036 => ['capitalcity', 'Пещера Тысячи Проклятий'],
|
||||
5037 => ['demonscity', 'Катакомбы'],
|
||||
5038 => ['abandonedplain', 'Гора Легиона'], //mooncity
|
||||
5039 => ['suncity', 'Грибница'],
|
||||
5040 => ['sandcity', 'Пещера Мглы'],
|
||||
];
|
||||
$dngcity = $dngcity[$itm['item_id']];
|
||||
$hgo1 = ActionModel::getOne(["uid = {$u->info['id']}", "time > unix_timestamp() - 86400", "vars = psh_qt_$dngcity[0]"], 'id');
|
||||
|
||||
if (!isset($hgo1)) {
|
||||
$u->error = 'Нет задержки для подземелья ' . $dngcity[1] . '.';
|
||||
} else {
|
||||
$u->addAction(time(), 'podvig', '');
|
||||
$u->error = "Успешно использован свиток Право на Подвиг ($dngcity[1])";
|
||||
Db::sql('update actions set time = unix_timestamp() - 86401 where id = ?', [$hgo1]);
|
||||
ItemsModel::addIznos($itm['id']);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
<?php
|
||||
|
||||
use Model\ActionModel;
|
||||
use User\ItemsModel;
|
||||
|
||||
if (!defined('GAME')) {
|
||||
die();
|
||||
}
|
||||
@@ -15,15 +19,16 @@ if (isset($po['finish_file']) && $po['finish_file'] == 'tznanie') {
|
||||
//Уже что-то изучаем
|
||||
$u->error = 'Так не пойдет, вы уже что-то изучаете';
|
||||
} else {
|
||||
$tst = $u->testAction('`uid` = "' . $u->info['id'] . '" AND `vars` = "read" AND `vals` = "' . $itm['item_id'] . '" LIMIT 1', 1);
|
||||
if (isset($tst['id'])) {
|
||||
$tst = (bool)ActionModel::testCount(["uid = $u->info['id']", 'vars = read', "vals = {$itm['item_id']}"]);
|
||||
|
||||
if ($tst) {
|
||||
$u->error = 'Вы уже изучили данное знание';
|
||||
} else {
|
||||
$fn = '';
|
||||
$tom_iz = 0;
|
||||
if (($itm['item_id'] >= 1045 && $itm['item_id'] <= 1047) || ($itm['item_id'] >= 4812 && $itm['item_id'] <= 4813)) {
|
||||
$tst2 = $u->testAction('`uid` = "' . $u->info['id'] . '" AND `vars` = "read" AND `vals` = "' . ($itm['item_id'] - 1) . '" LIMIT 1', 1);
|
||||
if (!isset($tst2['id'])) {
|
||||
$tst2 = (bool)ActionModel::testCount(["uid = $u->info['id']", 'vars = read', "vals = {$itm['item_id']} - 1"]);
|
||||
if (!$tst2) {
|
||||
$tom_iz = 1;
|
||||
}
|
||||
unset($tst2);
|
||||
@@ -41,7 +46,7 @@ if (isset($po['finish_file']) && $po['finish_file'] == 'tznanie') {
|
||||
|
||||
$u->error = 'Вы изучили "' . $itm['name'] . '".';
|
||||
$u->addAction(time() + $st['timeRead'], 'read', $itm['item_id']);
|
||||
mysql_query('UPDATE `items_users` SET `iznosNOW` = `iznosNOW` + 1 WHERE `id` = ' . $itm['id'] . ' LIMIT 1');
|
||||
ItemsModel::addIznos($itm['id']);
|
||||
|
||||
} else {
|
||||
$u->error = 'Требует изучения предыдущего тома';
|
||||
|
||||
@@ -3,10 +3,13 @@
|
||||
namespace Model;
|
||||
|
||||
use Core\Db;
|
||||
use Exception;
|
||||
use Helper\QueryBuilder;
|
||||
use User\UserIp;
|
||||
|
||||
class ActionModel
|
||||
{
|
||||
private const TABLE_NAME = 'actions';
|
||||
private int $uid;
|
||||
|
||||
public function __construct(int $uid)
|
||||
@@ -34,9 +37,51 @@ class ActionModel
|
||||
);
|
||||
}
|
||||
|
||||
public static function getAll(string $filter = ''): array
|
||||
public static function get(array $filters, string $columns = '*'): array
|
||||
{
|
||||
return Db::getRows('select * from actions');
|
||||
$query = new QueryBuilder(self::TABLE_NAME, $columns);
|
||||
try {
|
||||
$stmt = $query->select($filters, 1);
|
||||
return Db::getRow($stmt['sql'], $stmt['binds']);
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
trigger_error(__METHOD__ . ': ' . $e->getMessage(), E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
public static function getOne(array $filters, string $column): mixed
|
||||
{
|
||||
$result = self::get($filters, $column);
|
||||
if (!empty($result)) {
|
||||
return array_shift($result);
|
||||
}
|
||||
return '';
|
||||
}
|
||||
|
||||
public static function deleteById(int $id): void
|
||||
{
|
||||
Db::sql('delete from actions where id = ?', [$id]);
|
||||
}
|
||||
|
||||
public static function testCount(array $filters, int $limit = 0): int
|
||||
{
|
||||
$query = new QueryBuilder(self::TABLE_NAME, 'count(id)');
|
||||
try {
|
||||
$stmt = $query->select($filters, $limit);
|
||||
return Db::getValue($stmt['sql'], $stmt['binds']);
|
||||
} catch (Exception $e) {
|
||||
echo $e->getMessage();
|
||||
trigger_error(__METHOD__ . ': ' . $e->getMessage(), E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
public static function testCountCustom(string $filter, array $binds, int $limit = 0): int
|
||||
{
|
||||
$sql = "select count(id) from actions where $filter";
|
||||
if ($limit > 0) {
|
||||
$sql .= ' limit ' . $limit;
|
||||
}
|
||||
return (int)Db::getValue($sql, $binds);
|
||||
}
|
||||
|
||||
public function getByVals(string $vals)
|
||||
@@ -54,6 +99,11 @@ class ActionModel
|
||||
|
||||
public function getLastByValsAndTime(string $vals, int $time)
|
||||
{
|
||||
$filter = [
|
||||
"uid = $this->uid",
|
||||
"vals = '$vals'",
|
||||
"time > unix_timestamp() - $time",
|
||||
];
|
||||
return Db::getRow(
|
||||
'select * from actions where uid = ? and vals = ? and time > unix_timestamp() - ? order by time desc limit 1',
|
||||
[$this->uid, $vals, $time]
|
||||
@@ -65,28 +115,14 @@ class ActionModel
|
||||
Db::sql('delete from actions where uid = ? and vals = ?', [$this->uid, $vals]);
|
||||
}
|
||||
|
||||
public static function deleteById(int $id): void
|
||||
public function getDailyQuest(): array
|
||||
{
|
||||
Db::sql('delete from actions where id = ?', [$id]);
|
||||
}
|
||||
$filter = [
|
||||
"uid = $this->uid",
|
||||
"vars = 'day_quest'",
|
||||
];
|
||||
|
||||
/*protected function testAction($filter, $tp): array
|
||||
{
|
||||
if ($tp == 1) {
|
||||
$query = 'select * from actions where ' . $filter;
|
||||
} elseif ($tp == 2) {
|
||||
$query = 'select count(*) from actions where ' . $filter;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
$arr = mysql_fetch_array(mysql_query($query));
|
||||
|
||||
return !empty($arr) ? $arr : [];
|
||||
}*/
|
||||
|
||||
public function getDailyQuest(): array|false
|
||||
{
|
||||
return Db::getRow("select * from actions where uid = ? and vars = 'day_quest' limit 1", [$this->uid]);
|
||||
return self::get($filter);
|
||||
}
|
||||
|
||||
public function getFinishedDailyQuestTasks(int $timeout): array
|
||||
|
||||
+280
-324
@@ -5,6 +5,7 @@ use Core\Db;
|
||||
use DarksLight2\Training\TrainingManager;
|
||||
use Helper\Conversion;
|
||||
use Helper\Math;
|
||||
use Model\ActionModel;
|
||||
use Model\Constant\Stat;
|
||||
use User\Effects;
|
||||
|
||||
@@ -108,7 +109,7 @@ class Priems
|
||||
|
||||
/** используем прием каждый ход
|
||||
* @param Battle $btl
|
||||
* @param array $eff
|
||||
* @param array $eff
|
||||
* @return bool
|
||||
*/
|
||||
public function hodUsePriem(Battle $btl, array $eff): bool
|
||||
@@ -466,11 +467,11 @@ class Priems
|
||||
/**
|
||||
* Новая функция магического заклинания с приёма.
|
||||
* Работает с числовыми приёмами в папке [priem].
|
||||
* @param int $attackerId кто использует приём
|
||||
* @param int $defenderId на кого использует приём
|
||||
* @param float $damage базовый урон приёма
|
||||
* @param string $damageType тип урона (стихия?) приходит строкой, и конвертируется функцией.
|
||||
* @param bool $hasCritical флаг, что приём МОЖЕТ критовать
|
||||
* @param int $attackerId кто использует приём
|
||||
* @param int $defenderId на кого использует приём
|
||||
* @param float $damage базовый урон приёма
|
||||
* @param string $damageType тип урона (стихия?) приходит строкой, и конвертируется функцией.
|
||||
* @param bool $hasCritical флаг, что приём МОЖЕТ критовать
|
||||
* @return array [0|damage] int урон, [1|crit] bool был ли крит, [2|miss] bool был ли промах, [3|miss_type] int тип промаха (всегда = 2).
|
||||
* @author Insallah
|
||||
*/
|
||||
@@ -786,7 +787,8 @@ class Priems
|
||||
$krituet = true,
|
||||
$heal = 0,
|
||||
$namenew = null
|
||||
) {
|
||||
)
|
||||
{
|
||||
$trawm_off = false;
|
||||
global $btl;
|
||||
if ($namenew != null) {
|
||||
@@ -965,8 +967,7 @@ class Priems
|
||||
);
|
||||
|
||||
//заносим в лог боя
|
||||
$vLog = 'time1=' . time(
|
||||
) . '||s1=' . $btl->users[$btl->uids[$usu]]['sex'] . '||t1=' . $btl->users[$btl->uids[$usu]]['team'] . '||login1=' . $btl->users[$btl->uids[$usu]]['login'] . '||s2=' . $btl->users[$btl->uids[$uen]]['sex'] . '||t2=' . $btl->users[$btl->uids[$uen]]['team'] . '||login2=' . $btl->users[$btl->uids[$uen]]['login'] . '';
|
||||
$vLog = 'time1=' . time() . '||s1=' . $btl->users[$btl->uids[$usu]]['sex'] . '||t1=' . $btl->users[$btl->uids[$usu]]['team'] . '||login1=' . $btl->users[$btl->uids[$usu]]['login'] . '||s2=' . $btl->users[$btl->uids[$uen]]['sex'] . '||t2=' . $btl->users[$btl->uids[$uen]]['team'] . '||login2=' . $btl->users[$btl->uids[$uen]]['login'] . '';
|
||||
$mas1 = [
|
||||
'time' => time(),
|
||||
'battle' => $btl->i->id,
|
||||
@@ -1088,276 +1089,245 @@ class Priems
|
||||
return $rr;
|
||||
}
|
||||
|
||||
public function pruse($id)
|
||||
public function pruse($id): void
|
||||
{
|
||||
global $btl;
|
||||
$u = $this->u; // Для присоедиянемых файлов.
|
||||
if ($id == 100500 && $this->u->info['animal'] > 0) {
|
||||
$use_lst = $this->u->testAction(
|
||||
'`uid` = "' . $this->u->info['id'] . '" AND `vars` = "animal_use' . $btl->i->id . '" LIMIT 1',
|
||||
1
|
||||
);
|
||||
if (!isset($use_lst['id'])) {
|
||||
$a = mysql_fetch_assoc(
|
||||
mysql_query(
|
||||
'SELECT * FROM `users_animal` WHERE `uid` = "' . $this->u->info['id'] . '" AND `id` = "' . $this->u->info['animal'] . '" AND `pet_in_cage` = "0" AND `delete` = "0" LIMIT 1'
|
||||
)
|
||||
);
|
||||
if ($this->u->stats['hpNow'] < 1) {
|
||||
echo 'Вы не можете выпустить зверя, вы потеряли все НР';
|
||||
} elseif (isset($a['id']) && $a['eda'] < 1) {
|
||||
echo 'Вы не накормили зверя...';
|
||||
} elseif (isset($a['id'])) {
|
||||
//Добавляем зверя в бой
|
||||
$tp = [
|
||||
1 => 'Кот',
|
||||
2 => 'Сова',
|
||||
3 => 'Светляк',
|
||||
4 => 'Чертяка',
|
||||
5 => 'Пес',
|
||||
6 => 'Свин',
|
||||
7 => 'Дракон',
|
||||
];
|
||||
$id = mysql_fetch_assoc(
|
||||
mysql_query(
|
||||
'SELECT `id` FROM `test_bot` WHERE `login` = "' . $tp[$a['type']] . ' [' . $a['level'] . ']" LIMIT 1'
|
||||
)
|
||||
);
|
||||
if (isset($id['id']) && $btl->i->type != 500) {
|
||||
$b = $this->u->addNewbot($id['id'], null, null);
|
||||
if ($b > 0 && $b) {
|
||||
$a['eda'] -= 4;
|
||||
if ($a['eda'] < 0) {
|
||||
$a['eda'] = 0;
|
||||
}
|
||||
|
||||
$vLog = 'time1=' . time() . '||s1=' . $this->u->info['sex'] . '||t1=' . $this->u->info['team'] . '||login1=' . $this->u->info['login'] . '';
|
||||
$mas1 = [
|
||||
'time' => time(),
|
||||
'battle' => $btl->i->id,
|
||||
'id_hod' => $btl->hodID,
|
||||
'vars' => $vLog,
|
||||
'zona1' => '',
|
||||
'zonb1' => '',
|
||||
'zona2' => '',
|
||||
'zonb2' => '',
|
||||
'type' => '1',
|
||||
];
|
||||
|
||||
$sex = $this->u->info['sex'] === 1 ? 'a' : '';
|
||||
$mas1['text'] = "{tm1} {u1} выпустил$sex зверя "<b>" . $a['name'] . '"</b>';
|
||||
Log::add($mas1);
|
||||
|
||||
mysql_query(
|
||||
'UPDATE `users` SET `login` = "' . $a['name'] . ' (зверь ' . $this->u->info['login'] . ')",`obraz` = "' . $a['obraz'] . '.gif",`battle` = "' . $btl->i->id . '" WHERE `id` = "' . $b['id'] . '" LIMIT 1'
|
||||
);
|
||||
mysql_query(
|
||||
'UPDATE `stats` SET `team` = "' . $this->u->info['team'] . '" WHERE `id` = "' . $b['id'] . '" LIMIT 1'
|
||||
);
|
||||
mysql_query(
|
||||
'UPDATE `users_animal` SET `eda` = "' . $a['eda'] . '" WHERE `id` = "' . $a['id'] . '" LIMIT 1'
|
||||
);
|
||||
$this->u->addAction(time(), 'animal_use' . $btl->i->id, $a['level']);
|
||||
} else {
|
||||
echo 'Не удалось выпустить зверя...';
|
||||
}
|
||||
} else {
|
||||
//Бот не найден
|
||||
echo '<br>Не удалось выпустить зверя - он боится...';
|
||||
}
|
||||
} else {
|
||||
//зверь не найден
|
||||
echo 'У Вас нет зверя ...';
|
||||
}
|
||||
} else {
|
||||
//зверь уже выпущен
|
||||
echo 'Вы уже выпускали зверя в этом бою ...';
|
||||
}
|
||||
$this->processAnimal($btl);
|
||||
} else {
|
||||
$p = explode('|', $this->u->info['priems']);
|
||||
$pz = explode('|', $this->u->info['priems_z']);
|
||||
if ($p[(int)$id] > 0 && $pz[(int)$id] <= 0 && $this->u->info['hpNow'] >= 1) {
|
||||
$pl = mysql_fetch_assoc(
|
||||
mysql_query(
|
||||
'SELECT * FROM `priems` WHERE `level`<=' . $this->u->info['level'] . ' AND `id` = ' . $p[(int)$id]
|
||||
)
|
||||
);
|
||||
if (isset($pl['id']) && $pl['activ'] != 1) {
|
||||
if ($pl['activ'] == 0) {
|
||||
unset($pl);
|
||||
} elseif ($pl['activ'] > 1) {
|
||||
//Книжный прием
|
||||
if ($this->testActiv($pl['activ']) == 0) {
|
||||
unset($pl);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($pl['id'])) {
|
||||
$notr = 0;
|
||||
$pl['useon_user'] = $this->u->info['enemy'];
|
||||
if (isset($_POST['useon']) && $_POST['useon'] != '' && $_POST['useon'] != 'none') {
|
||||
$this->ue = mysql_fetch_assoc(
|
||||
mysql_query(
|
||||
'SELECT
|
||||
|
||||
`u`.`id`,`u`.`login`,`u`.`login2`,`u`.`online`,`u`.`admin`,`u`.`city`,`u`.`cityreg`,`u`.`align`,`u`.`clan`,
|
||||
`u`.`level`,`u`.`money`,`u`.`money3`,`u`.`money4`,`u`.`battle`,`u`.`sex`,`u`.`obraz`,`u`.`win`,`u`.`win_t`,
|
||||
`u`.`lose`,`u`.`lose_t`,`u`.`nich`,`u`.`timeMain`,`u`.`invis`,`u`.`bot_id`,`u`.`animal`,`u`.`type_pers`,
|
||||
`u`.`notrhod`,`u`.`bot_room`,`u`.`inUser`,`u`.`inTurnir`,`u`.`inTurnirnew`,`u`.`stopexp`,`u`.`real`,
|
||||
|
||||
`st`.*
|
||||
|
||||
FROM `users` AS `u`
|
||||
LEFT JOIN `stats` AS `st` ON (`u`.`id`=`st`.`id`)
|
||||
WHERE (
|
||||
`u`.`login`="' . mysql_real_escape_string($_POST['useon']) . '" OR
|
||||
(
|
||||
`u`.`login2` = "' . mysql_real_escape_string($_POST['useon']) . '" AND
|
||||
`u`.`login2` != "")
|
||||
) AND
|
||||
(
|
||||
`u`.`inUser` > 0 OR
|
||||
(
|
||||
`u`.`battle`="' . $btl->i->id . '" AND
|
||||
`st`.`hpNow` > 0
|
||||
)
|
||||
) ORDER BY `u`.`id` DESC LIMIT 1'
|
||||
)
|
||||
);
|
||||
if (isset($this->ue['id']) && $this->ue['inUser'] > 0) {
|
||||
$this->ue = mysql_fetch_assoc(
|
||||
mysql_query(
|
||||
'SELECT
|
||||
|
||||
`u`.`id`,`u`.`login`,`u`.`login2`,`u`.`online`,`u`.`admin`,`u`.`city`,`u`.`cityreg`,`u`.`align`,`u`.`clan`,
|
||||
`u`.`level`,`u`.`money`,`u`.`money3`,`u`.`money4`,`u`.`battle`,`u`.`sex`,`u`.`obraz`,`u`.`win`,`u`.`win_t`,
|
||||
`u`.`lose`,`u`.`lose_t`,`u`.`nich`,`u`.`timeMain`,`u`.`invis`,`u`.`bot_id`,`u`.`animal`,`u`.`type_pers`,
|
||||
`u`.`notrhod`,`u`.`bot_room`,`u`.`inUser`,`u`.`inTurnir`,`u`.`inTurnirnew`,`u`.`stopexp`,`u`.`real`,
|
||||
|
||||
`st`.*
|
||||
|
||||
FROM `users` AS `u`
|
||||
LEFT JOIN `stats` AS `st` ON (`u`.`id`=`st`.`id`)
|
||||
WHERE
|
||||
`u`.`battle`="' . $btl->i->id . '" AND
|
||||
`st`.`hpNow` > 0) AND
|
||||
`u`.`id` = "' . $this->ue['inUser'] . '" ORDER BY `u`.`id` ASC LIMIT 1'
|
||||
)
|
||||
);
|
||||
}
|
||||
if (!isset($this->ue['id']) && $pl['trUser'] > 0) {
|
||||
$notr++;
|
||||
}
|
||||
if ($pl['team'] == 1) {
|
||||
//свои
|
||||
if ($this->u->info['team'] != $this->ue['team']) {
|
||||
$notr++;
|
||||
}
|
||||
} elseif ($pl['team'] == 2) {
|
||||
//противники
|
||||
if ($this->u->info['team'] == $this->ue['team']) {
|
||||
$notr++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$ga = mysql_fetch_assoc(
|
||||
mysql_query(
|
||||
'SELECT * FROM `battle_act` WHERE `battle` = "' . $btl->i->id . '" AND `uid1` = "' . $this->u->info['id'] . '" AND `uid2` = "' . $this->u->info['enemy'] . '" LIMIT 1'
|
||||
)
|
||||
);
|
||||
if (($this->u->info['enemy'] == 0 || isset($ga['id'])) && ($pl['tr_hod'] > 0 || $pl['trUser'] > 0)) {
|
||||
$notr++;
|
||||
}
|
||||
}
|
||||
|
||||
$notr += $this->testpriem($pl, 1, $this->ue['id']);
|
||||
|
||||
if ($this->ue['id'] > 0) {
|
||||
$notr += $this->testRazmenOldUser($this->ue['id'], $this->u->info['enemy'], $pl['id']);
|
||||
}
|
||||
|
||||
if ($notr == 0) {
|
||||
mysql_query(
|
||||
'UPDATE `stats` SET `last_pr` = "' . $pl['id'] . '" WHERE `id` = "' . $this->u->info['id'] . '" LIMIT 1'
|
||||
);
|
||||
|
||||
//Приемы на персонажах
|
||||
if ($this->ue['id'] > 0) {
|
||||
$btl->priemsRazmen([$this->u->info['id'], $this->ue['id']], 'fast');
|
||||
mysql_query(
|
||||
'UPDATE `eff_users` SET `mark` = 1 WHERE `uid` = "' . $this->ue['id'] . '" AND `delete` = 0'
|
||||
);
|
||||
} else {
|
||||
$btl->priemsRazmen([$this->u->info['id'], $this->u->info['enemy']], 'fast');
|
||||
mysql_query(
|
||||
'UPDATE `eff_users` SET `mark` = 1 WHERE `uid` = "' . $this->u->info['enemy'] . '" AND `delete` = 0'
|
||||
);
|
||||
}
|
||||
mysql_query(
|
||||
'UPDATE `eff_users` SET `mark` = 1 WHERE `uid` = "' . $this->u->info['id'] . '" AND `delete` = 0'
|
||||
);
|
||||
|
||||
if (file_exists('../../_incl_data/class/Priem/' . $pl['id'] . '.php')) {
|
||||
require('../../_incl_data/class/Priem/' . $pl['id'] . '.php');
|
||||
$this->testDie($this->ue['id']);
|
||||
} else {
|
||||
echo 'useSkill' . $pl['id'];
|
||||
}
|
||||
|
||||
if (!isset($cup)) {
|
||||
$this->uppz($pl, $id);
|
||||
//Отнимаем тактики
|
||||
//$this->mintr($pl);
|
||||
if ($pl['tr_hod'] > 0) {
|
||||
$this->trhod($pl);
|
||||
}
|
||||
if ($pl['id'] != 258) {
|
||||
if ($pl['cancel_eff'] == '') {
|
||||
$pl['cancel_eff'] = '258';
|
||||
} else {
|
||||
$pl['cancel_eff'] .= ',258';
|
||||
}
|
||||
}
|
||||
if ($pl['cancel_eff'] != '') {
|
||||
$i = 0;
|
||||
$e = explode(',', $pl['cancel_eff']);
|
||||
while ($i < count($e)) {
|
||||
if ($e[$i] > 0) {
|
||||
if ($e[$i] == 258) {
|
||||
$nem = mysql_fetch_assoc(
|
||||
mysql_query(
|
||||
'SELECT * FROM `eff_users` WHERE `uid` = "' . $this->u->info['id'] . '" AND `v1` = "priem" AND `v2` = "' . $e[$i] . '" AND `delete` = "0" AND `mark` = 1 LIMIT 1'
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$nem = mysql_fetch_assoc(
|
||||
mysql_query(
|
||||
'SELECT * FROM `eff_users` WHERE `uid` = "' . $this->ue['id'] . '" AND `v1` = "priem" AND `v2` = "' . $e[$i] . '" AND `delete` = "0" AND `mark` = 1 LIMIT 1'
|
||||
)
|
||||
);
|
||||
}
|
||||
if (isset($nem['id'])) {
|
||||
$nem['priem'] = mysql_fetch_assoc(
|
||||
mysql_query(
|
||||
'SELECT * FROM `priems` WHERE `id` = "' . $e[$i] . '" LIMIT 1'
|
||||
)
|
||||
);
|
||||
if (isset($nem['id'])) {
|
||||
$btl->delPriem($nem, $btl->users[$btl->uids[$this->ue['id']]], 500);
|
||||
}
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->processPriem($id, $btl);
|
||||
}
|
||||
}
|
||||
|
||||
//для папки priems
|
||||
private function processAnimal(Battle $btl): void
|
||||
{
|
||||
if ($this->u->stats['hpNow'] < 1) {
|
||||
echo 'Вы не можете выпустить зверя, вы потеряли все НР';
|
||||
return;
|
||||
}
|
||||
|
||||
$alreadyReleased = ActionModel::testCount(["uid = {$this->u->info['id']}", "vars = animal_use{$btl->i->id}"]);
|
||||
|
||||
if (!empty($alreadyReleased)) {
|
||||
echo 'Вы уже выпускали зверя в этом бою ...';
|
||||
return;
|
||||
}
|
||||
|
||||
$animal = Db::getRow('select * from users_animal where uid = ? and id = ? and pet_in_cage = 0', [$this->u->info['id'], $this->u->info['animal']]);
|
||||
|
||||
if (!isset($animal['id'])) {
|
||||
echo 'У вас нет зверя.';
|
||||
return;
|
||||
}
|
||||
|
||||
if ($animal['eda'] < 1) {
|
||||
echo 'Вы не накормили зверя.';
|
||||
return;
|
||||
}
|
||||
|
||||
$animalTypes = [
|
||||
1 => 'Кот',
|
||||
2 => 'Сова',
|
||||
3 => 'Светляк',
|
||||
4 => 'Чертяка',
|
||||
5 => 'Пес',
|
||||
6 => 'Свин',
|
||||
7 => 'Дракон',
|
||||
];
|
||||
|
||||
$botLogin = $animalTypes[$animal['type']] . ' [' . $animal['level'] . ']';
|
||||
$botId = Db::getValue('select id from test_bot where login = ?', [$botLogin]);
|
||||
|
||||
if (!$botId) {
|
||||
echo 'Системная ошибка: Неизвестный зверь!';
|
||||
return;
|
||||
}
|
||||
|
||||
$b = $this->u->addNewbot($botId);
|
||||
|
||||
if (!$b) {
|
||||
echo 'Не удалось призвать зверя.';
|
||||
return;
|
||||
}
|
||||
|
||||
if ($b > 0) {
|
||||
$animal['eda'] -= 4;
|
||||
if ($animal['eda'] < 0) {
|
||||
$animal['eda'] = 0;
|
||||
}
|
||||
|
||||
$logData = [
|
||||
'time' => time(),
|
||||
'battle' => $btl->i->id,
|
||||
'id_hod' => $btl->hodID,
|
||||
'vars' => 'time1=' . time() . '||s1=' . $this->u->info['sex'] . '||t1=' . $this->u->info['team'] . '||login1=' . $this->u->info['login'],
|
||||
'zona1' => '',
|
||||
'zonb1' => '',
|
||||
'zona2' => '',
|
||||
'zonb2' => '',
|
||||
'type' => '1',
|
||||
'text' => '{tm1} {u1} выпустил' . ($this->u->info['sex'] === 1 ? 'a' : '') . " зверя «{$animal['name']}».",
|
||||
];
|
||||
Log::add($logData);
|
||||
|
||||
Db::sql('update users set login = ?, obraz = ?, battle = ? where id = ?', [$animal['name'], $animal['obraz'] . '.gif', $btl->i->id, $b['id']]);
|
||||
Db::sql('update stats set team = ? where id = ?', [$this->u->info['team'], $b['id']]);
|
||||
Db::sql('update users_animal set eda = ? where id = ?', [$animal['eda'], $animal['id']]);
|
||||
$this->u->addAction(time(), 'animal_use' . $btl->i->id, $animal['level']);
|
||||
}
|
||||
}
|
||||
|
||||
private function processPriem(int $id, Battle $btl): void
|
||||
{
|
||||
$target = '';
|
||||
$targetNotEmpty = false;
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$target = (string)filter_input(INPUT_POST, 'useon');
|
||||
$targetNotEmpty = $target && $target !== 'none';
|
||||
}
|
||||
$cup = false;
|
||||
$priemsOnPlayer = explode('|', $this->u->info['priems']);
|
||||
$pz = explode('|', $this->u->info['priems_z']);
|
||||
if ($priemsOnPlayer[$id] <= 0 || $pz[$id] > 0 || $this->u->info['hpNow'] < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
$priem = Db::getRow('select * from priems where level <= ? and id = ?', [$this->u->info['level'], $priemsOnPlayer['id']]);
|
||||
|
||||
if (isset($priem['id']) && $priem['activ'] != 1) {
|
||||
if ($priem['activ'] == 0) {
|
||||
unset($priem);
|
||||
} elseif ($priem['activ'] > 1) {
|
||||
//Книжный прием
|
||||
if ($this->testActiv($priem['activ']) == 0) {
|
||||
unset($priem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($priem['id'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$notr = 0;
|
||||
$priem['useon_user'] = $this->u->info['enemy'];
|
||||
if ($targetNotEmpty) {
|
||||
$this->ue = Db::getRow('select
|
||||
users.id, login, login2, online, admin, city, cityreg, align, clan, level, money, money3, money4, battle, sex, obraz, win, win_t, lose, lose_t, nich,
|
||||
timeMain, invis, bot_id, animal, type_pers, notrhod, bot_room, inUser, inTurnir, inTurnirnew, stopexp, `real`, stats.*
|
||||
from users inner join stats on users.id = stats.id where (login = ? or login2 = ?) and (inUser > 0 or (battle = ? and hpNow > 0))
|
||||
order by users.id desc limit 1', [$target, $target, $btl->i->id]);
|
||||
|
||||
if (isset($this->ue['id']) && $this->ue['inUser'] > 0) {
|
||||
$this->ue = Db::getRow('select
|
||||
users.id, login, login2, online, admin, city, cityreg, align, clan, level, money, money3, money4, battle, sex, obraz, win, win_t, lose, lose_t, nich,
|
||||
timeMain, invis, bot_id, animal, type_pers, notrhod, bot_room, inUser, inTurnir, inTurnirnew, stopexp, `real`, stats.*
|
||||
from users inner join stats on users.id = stats.id where battle = ? and hpNow > 0 and users.id = ?
|
||||
order by users.id limit 1', [$btl->i->id, $this->ue['inUser']]);
|
||||
}
|
||||
|
||||
if (!isset($this->ue['id']) && $priem['trUser'] > 0) {
|
||||
$notr++;
|
||||
}
|
||||
if ($priem['team'] == 1) {
|
||||
//свои
|
||||
if ($this->u->info['team'] != $this->ue['team']) {
|
||||
$notr++;
|
||||
}
|
||||
} elseif ($priem['team'] == 2) {
|
||||
//противники
|
||||
if ($this->u->info['team'] == $this->ue['team']) {
|
||||
$notr++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$check = Db::getValue('select count(id) from battle_act where battle = ? and uid1 = ? and uid2 = ?', [$btl->i->id, $this->u->info['id'], $this->u->info['enemy']]) > 0;
|
||||
|
||||
if (($this->u->info['enemy'] == 0 || $check) && ($priem['tr_hod'] > 0 || $priem['trUser'] > 0)) {
|
||||
$notr++;
|
||||
}
|
||||
}
|
||||
|
||||
$notr += $this->testpriem($priem, 1, $this->ue['id']);
|
||||
|
||||
if ($this->ue['id'] > 0) {
|
||||
$notr += $this->testRazmenOldUser($this->ue['id'], $this->u->info['enemy'], $priem['id']);
|
||||
}
|
||||
|
||||
if ($notr != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
Db::sql('update stats set last_pr = ? where id = ?', [$priem['id'], $this->u->info['id']]);
|
||||
|
||||
//Приемы на персонажах
|
||||
$markuids = [];
|
||||
if ($this->ue['id'] > 0) {
|
||||
$btl->priemsRazmen([$this->u->info['id'], $this->ue['id']], 'fast');
|
||||
$markuids[] = $this->ue['id'];
|
||||
} else {
|
||||
$btl->priemsRazmen([$this->u->info['id'], $this->u->info['enemy']], 'fast');
|
||||
$markuids[] = $this->u->info['enemy'];
|
||||
}
|
||||
$markuids[] = $this->u->info['id'];
|
||||
|
||||
Db::sql('update eff_users set mark = 1 where uid in (?)', [implode(',', $markuids)]);
|
||||
|
||||
if (file_exists('../../_incl_data/class/Priem/' . $priem['id'] . '.php')) {
|
||||
$u = $this->u; // Для присоедиянемых файлов.
|
||||
require_once '../../_incl_data/class/Priem/' . $priem['id'] . '.php';
|
||||
$this->testDie($this->ue['id']);
|
||||
} else {
|
||||
echo 'useSkill' . $priem['id'];
|
||||
}
|
||||
|
||||
if ($cup) { // Из подключаемых файлов.
|
||||
return;
|
||||
}
|
||||
|
||||
$this->uppz($priem, $id);
|
||||
//Отнимаем тактики
|
||||
//$this->mintr($pl);
|
||||
if ($priem['tr_hod'] > 0) {
|
||||
$this->trhod($priem);
|
||||
}
|
||||
|
||||
if ($priem['id'] != 258) {
|
||||
if ($priem['cancel_eff'] == '') {
|
||||
$priem['cancel_eff'] = '258';
|
||||
} else {
|
||||
$priem['cancel_eff'] .= ',258';
|
||||
}
|
||||
}
|
||||
|
||||
if ($priem['cancel_eff'] == '') {
|
||||
return;
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
$e = explode(',', $priem['cancel_eff']);
|
||||
while ($i < count($e)) {
|
||||
if ($e[$i] <= 0) {
|
||||
$i++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($e[$i] == 258) {
|
||||
$uid = $this->u->info['id'];
|
||||
} else {
|
||||
$uid = $this->ue['id'];
|
||||
}
|
||||
|
||||
$nem = Db::getRow('select * from eff_users where uid = ? and v1 = \'priem\' and v2 = ? and mark = 1 limit 1', [$uid, $e[$i]]);
|
||||
|
||||
if (isset($nem['id'])) {
|
||||
$nem['priem'] = Db::getRow('select * from priems where id = ?', [$e['id']]);
|
||||
$btl->delPriem($nem, $btl->users[$btl->uids[$this->ue['id']]], 500);
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
private function testActiv($id)
|
||||
{
|
||||
@@ -1368,11 +1338,8 @@ class Priems
|
||||
$this->u->info['id'] > 0) {
|
||||
$r = 1;
|
||||
} else {
|
||||
$tst = $this->u->testAction(
|
||||
'`uid` = "' . $this->u->info['id'] . '" AND `time` < ' . time() . ' AND `vars` = "read" AND `vals` = "' . $id . '" LIMIT 1',
|
||||
1
|
||||
);
|
||||
if (isset($tst['id'])) {
|
||||
$test = (bool)Db::getValue("select count(id) from actions where uid = ? and time < unix_timestamp() and vars = 'read' and vals = ?", [$this->u->info['id'], $id]);
|
||||
if ($test) {
|
||||
$r = 1;
|
||||
}
|
||||
}
|
||||
@@ -1428,11 +1395,8 @@ class Priems
|
||||
|
||||
|
||||
if ($pl['xuse'] > 0) {
|
||||
$xu = $this->u->testAction(
|
||||
'`vars` = "use_priem_' . $btl->i->id . '_' . $this->u->info['id'] . '" AND `vals` = "' . $pl['id'] . '" LIMIT ' . $pl['xuse'],
|
||||
2
|
||||
);
|
||||
if ($xu[0] >= $pl['xuse']) {
|
||||
$xu = ActionModel::testCount(["vars = use_priem_{$btl->i->id}_{$this->u->info['id']}", "vals = {$pl['id']}"], $pl['xuse']);
|
||||
if ($xu >= $pl['xuse']) {
|
||||
$notr++;
|
||||
}
|
||||
}
|
||||
@@ -1579,13 +1543,13 @@ class Priems
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $uid на кого кастуем
|
||||
* @param int $pr id приема
|
||||
* @param int $uid на кого кастуем
|
||||
* @param int $pr id приема
|
||||
* @param int|string $data дата, если -1, то добавляем дату3
|
||||
* @param int $d2
|
||||
* @param int $d2
|
||||
* @param $tm
|
||||
* @param int $h ход
|
||||
* @param int $uu id юзера который использовал
|
||||
* @param int $h ход
|
||||
* @param int $uu id юзера который использовал
|
||||
* @param $max
|
||||
* @param $bj
|
||||
* @param $tp
|
||||
@@ -1614,7 +1578,8 @@ class Priems
|
||||
$noupdatebtl = 0,
|
||||
$noplus = 0,
|
||||
$pname = null
|
||||
) {
|
||||
)
|
||||
{
|
||||
global $btl;
|
||||
//$pl = mysql_fetch_assoc(mysql_query('SELECT * FROM `priems` WHERE `id` = ' . (int)$pr));
|
||||
$pl = Db::getRow('select * from priems where id = ?', [$pr]);
|
||||
@@ -1732,8 +1697,8 @@ class Priems
|
||||
|
||||
/** Получает строку data c шаблонной записью типа add_m11=2*{lvl1} и конвертирует в реальную строку.
|
||||
* <br>Шаблон: <br>lvl1 = $uid[level] <br>ts5 = $uid[s5] <br>mpAll = $uid[mpAll]
|
||||
* @param string $pl строка в формате data
|
||||
* @param int $uid пользователь, параметры которого используются для подставки в шаблон.
|
||||
* @param string $pl строка в формате data
|
||||
* @param int $uid пользователь, параметры которого используются для подставки в шаблон.
|
||||
* @return string строка в формате data с развёрнутыми шаблонами.
|
||||
*/
|
||||
public function redate($pl, $uid)
|
||||
@@ -1981,8 +1946,7 @@ class Priems
|
||||
} else {
|
||||
//бьем противника с пропуском хода
|
||||
mysql_query(
|
||||
'INSERT INTO `battle_act` (`battle`,`uid1`,`uid2`,`time`,`out1`,`type`,`tpo1`) VALUES ("' . $btl->i->id . '","' . $this->u->info['id'] . '","' . $this->u->info['enemy'] . '","' . time(
|
||||
) . '","1","1","2")'
|
||||
'INSERT INTO `battle_act` (`battle`,`uid1`,`uid2`,`time`,`out1`,`type`,`tpo1`) VALUES ("' . $btl->i->id . '","' . $this->u->info['id'] . '","' . $this->u->info['enemy'] . '","' . time() . '","1","1","2")'
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -2046,6 +2010,8 @@ class Priems
|
||||
}
|
||||
}
|
||||
|
||||
//выводим приемы $id - 1 (вне боя), 2 - в бою
|
||||
|
||||
/** Одеть приём в слот?
|
||||
* @param $id
|
||||
* @return void
|
||||
@@ -2086,11 +2052,11 @@ class Priems
|
||||
);
|
||||
if ($upd) {
|
||||
TrainingManager::getInstance()
|
||||
->addPoint(
|
||||
'my_user_fourth_quest', function (TrainingManager $manager) {
|
||||
$manager->store();
|
||||
}
|
||||
);
|
||||
->addPoint(
|
||||
'my_user_fourth_quest', function (TrainingManager $manager) {
|
||||
$manager->store();
|
||||
}
|
||||
);
|
||||
$this->u->info['priems'] = $p;
|
||||
}
|
||||
} else {
|
||||
@@ -2099,28 +2065,15 @@ class Priems
|
||||
}
|
||||
}
|
||||
|
||||
//выводим приемы $id - 1 (вне боя), 2 - в бою
|
||||
|
||||
public function getTechniquesInfo(?int $id = null): array
|
||||
{
|
||||
# SELECT * FROM `priems` WHERE `level`<="' . $this->u->info['level'] . '" AND `activ` > "0" AND `id` = "' . $id . '" LIMIT 1
|
||||
|
||||
if (isset($id)) {
|
||||
return Db::getRow('select * from priems where level <= ? and activ > 0 and id = ? order by img,level', [$this->u->info['level'], $id]);
|
||||
// return Db::getRow(
|
||||
// 'select * from techniques_categories left join priems on techniques_categories.technique_id = priems.id
|
||||
// where priems.level <= ? and priems.activ > 0 and priems.id = ? order by priems.img,priems.level', [User::start()->info['level'], $id]
|
||||
// );
|
||||
}
|
||||
|
||||
return Db::getRows('select * from priems where level <= ? and activ > 0 order by img,level', [$this->u->info['level']]);
|
||||
// return Db::getRows(
|
||||
// 'select * from techniques_categories left join priems on techniques_categories.technique_id = priems.id
|
||||
// where priems.level <= ? and priems.activ > 0 order by priems.img,priems.level', [User::start()->info['level']]
|
||||
// );
|
||||
}
|
||||
|
||||
|
||||
public function seeMyPriems(): void
|
||||
{
|
||||
$i = 0;
|
||||
@@ -2172,7 +2125,7 @@ class Priems
|
||||
/**
|
||||
* Летит в js, двойные кавычки не использовать.
|
||||
* @param array $pl
|
||||
* @param int $id
|
||||
* @param int $id
|
||||
* @return array
|
||||
*/
|
||||
private function priemInfo(array $pl, int $id = -1): array
|
||||
@@ -2243,6 +2196,8 @@ class Priems
|
||||
return [0 => $lvar, 1 => $pz];
|
||||
}
|
||||
|
||||
//Мощность / подавление / сопротивление и т.д.
|
||||
|
||||
/**
|
||||
* Генерирует html строку для вставки в JS $("#priems").html(" сюда ");
|
||||
* @return string
|
||||
@@ -2281,11 +2236,11 @@ class Priems
|
||||
$cl = 'href="javascript:void(0);" onClick="top.priemOnUser(' . $i . ',1,\'' . $pl['name'] . '\',\'' . $oninuser . '\',\'' . $pl['img'] . '\');"';
|
||||
unset($oninuser);
|
||||
} else {
|
||||
$cl = 'href="javascript:void(0);" onClick="usepriem(' . $i . ',1,\'' . $pl['img'] . '\');"';
|
||||
$cl = 'href="javascript:void(0);" onClick="usepriem(' . $i . ');"';
|
||||
}
|
||||
} elseif ($pl['type'] == 2) {
|
||||
//длительное
|
||||
$cl = 'href="javascript:void(0);" onClick="usepriem(' . $i . ',1,\'' . $pl['img'] . '\');"';
|
||||
$cl = 'href="javascript:void(0);" onClick="usepriem(' . $i . ');"';
|
||||
} elseif ($pl['type'] == 3) {
|
||||
$cl = 'href="javascript:void(0);" onClick="alert(\'Возможно используем?\');"';
|
||||
}
|
||||
@@ -2323,12 +2278,9 @@ class Priems
|
||||
$i++;
|
||||
}
|
||||
if ($this->u->info['animal'] > 0) {
|
||||
$use_lst = $this->u->testAction(
|
||||
'`uid` = "' . $this->u->info['id'] . '" AND `vars` = "animal_use' . $btl->i->id . '" LIMIT 1',
|
||||
1
|
||||
);
|
||||
if (!isset($use_lst['id'])) {
|
||||
$pr .= '<a onMouseOver="top.hi(this,\'<b>Выпустить зверя</b><Br>Ваш зверь вмешивается в поединок. Можно применять один раз за бой.\',event,3,0,1,1,\'width:240px\');" onMouseOut="top.hic();" onMouseDown="top.hic();" href="javascript:void(0);" onClick="usepriem(100500,1,\'\');"><img style="margin-top:1px; margin-left:3px;" src="//img.new-combats.tech/i/eff/pet_unleash.gif" width="40" height="25" /></a>';
|
||||
$use_lst = (bool)ActionModel::testCount(["uid = {$this->u->info['id']}", "vars = animal_use{$btl->i->id}"]);
|
||||
if (!$use_lst) {
|
||||
$pr .= '<a onMouseOver="top.hi(this,\'<b>Выпустить зверя</b><Br>Ваш зверь вмешивается в поединок. Можно применять один раз за бой.\',event,3,0,1,1,\'width:240px\');" onMouseOut="top.hic();" onMouseDown="top.hic();" href="javascript:void(0);" onClick="usepriem(100500);"><img style="margin-top:1px; margin-left:3px;" src="//img.new-combats.tech/i/eff/pet_unleash.gif" width="40" height="25" /></a>';
|
||||
} else {
|
||||
$pr .= '<img onMouseOver="top.hi(this,\'<b>Выпустить зверя</b><Br>Ваш зверь вмешивается в поединок. Можно применять один раз за бой.\',event,3,0,1,1,\'width:240px\');" onMouseOut="top.hic();" onMouseDown="top.hic();" style="margin-top:1px; margin-left:2px;" class="nopriemuse" src="//img.new-combats.tech/i/eff/pet_unleash.gif" width="40" height="25" />';
|
||||
}
|
||||
@@ -2337,8 +2289,6 @@ class Priems
|
||||
return str_replace('"', '\\"', $pr);
|
||||
}
|
||||
|
||||
//Мощность / подавление / сопротивление и т.д.
|
||||
|
||||
public function getByCategory(?int $category_id = null)
|
||||
{
|
||||
|
||||
@@ -2437,10 +2387,16 @@ class Priems
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Что-то для подключаемых файлов приёмов.
|
||||
*
|
||||
* @param $uid
|
||||
* @param $mg
|
||||
* @return bool|mysqli_result|resource
|
||||
*/
|
||||
private function rezadEff($uid, $mg)
|
||||
{
|
||||
global $btl;
|
||||
//$this->rezadEff($this->u->info['id'],'wis_fire_');
|
||||
$md = '';
|
||||
$md2 = '';
|
||||
$ex = explode('|', $btl->users[$btl->uids[$uid]]['priems']);
|
||||
@@ -2787,7 +2743,7 @@ class Priems
|
||||
* Конечный damage после множителей делится на 5 и пишется в БД (atgm=).
|
||||
* Файлы: 33, 56, 57, 58, 59, 60.
|
||||
* @param $id
|
||||
* @param array $pl массив значений из БД priems.
|
||||
* @param array $pl массив значений из БД priems.
|
||||
* @param Battle $btl
|
||||
* @return void
|
||||
*/
|
||||
@@ -2819,7 +2775,7 @@ class Priems
|
||||
* Если есть одинаковые статы из них выбирается случайный.
|
||||
* Файл:267, приём 268. Понимай как хочешь.
|
||||
* @param $id
|
||||
* @param array $pl
|
||||
* @param array $pl
|
||||
* @param Battle $btl
|
||||
* @return void
|
||||
*/
|
||||
|
||||
+230
-216
@@ -2,6 +2,7 @@
|
||||
|
||||
use Core\Db;
|
||||
use Helper\Conversion;
|
||||
use Model\ActionModel;
|
||||
use User\ItemsModel;
|
||||
|
||||
class Quests
|
||||
@@ -67,16 +68,18 @@ class Quests
|
||||
}
|
||||
//Сколько раз можно пройти квест
|
||||
if (isset($d['tr_raz'])) {
|
||||
$qlst = $u->testAction('SELECT `id` FROM `actions` WHERE `uid` = "' . $u->info['id'] . '" AND `vars` = "start_quest' . $pl['id'] . '" LIMIT ' . $d['tr_raz'], 2);
|
||||
if ($d['tr_raz'] > 0 && $d['tr_raz'] - $qlst[0] <= 0) {
|
||||
$qlst = ActionModel::testCount(["uid = {$u->info['id']}", "vars = start_quest{$pl['id']}"], $d['tr_raz']);
|
||||
//$qlst = $u->testAction('SELECT `id` FROM `actions` WHERE `uid` = "' . $u->info['id'] . '" AND `vars` = "start_quest' . $pl['id'] . '" LIMIT ' . $d['tr_raz'], 2);
|
||||
if ($d['tr_raz'] > 0 && $d['tr_raz'] - $qlst <= 0) {
|
||||
$r = 0;
|
||||
}
|
||||
unset($qlst);
|
||||
}
|
||||
//Попыток пройти квест
|
||||
if (isset($d['tr_raz2'])) {
|
||||
$qlst = $u->testAction('SELECT `id` FROM `actions` WHERE `uid` = "' . $u->info['id'] . '" AND `vars` = "start_quest' . $pl['id'] . '" AND `vals` != "go" AND `vals` != "win" LIMIT ' . $d['tr_raz2'], 2);
|
||||
if ($d['tr_raz2'] - $qlst[0] <= 0) {
|
||||
$qlst = ActionModel::testCount(["uid = {$u->info['id']}", "vars = start_quest{$pl['id']}", "vals != go", "vals != win"], $d['tr_raz2']);
|
||||
//$qlst = $u->testAction('SELECT `id` FROM `actions` WHERE `uid` = "' . $u->info['id'] . '" AND `vars` = "start_quest' . $pl['id'] . '" AND `vals` != "go" AND `vals` != "win" LIMIT ' . $d['tr_raz2'], 2);
|
||||
if ($d['tr_raz2'] - $qlst <= 0) {
|
||||
$r = 0;
|
||||
}
|
||||
unset($qlst);
|
||||
@@ -212,8 +215,7 @@ class Quests
|
||||
$bot2 = mysql_fetch_array(mysql_query('SELECT * FROM `test_bot` WHERE `id` = "' . $ex2[0] . '" LIMIT 1'));
|
||||
if (isset($bot2['id'])) {
|
||||
if (isset($qst['id'])) {
|
||||
$x2 = $u->testAction('`uid` = "' . $u->info['id'] . '" AND `time` > ' . $qst['time'] . ' AND `vars` = "win_bot_' . $ex2[0] . '" LIMIT ' . $ex2[1], 2);
|
||||
$x2 = 0 + $x2[0];
|
||||
$x2 = ActionModel::testCount(["uid = {$u->info['id']}", "vars = win_bot_$ex2[0]", "time > {$qst['time']}"], $ex2[1]);
|
||||
}
|
||||
if (isset($d['all_kill']) && $d['all_kill'] > 0) {
|
||||
$r = $d['all_kill'];
|
||||
@@ -393,15 +395,17 @@ class Quests
|
||||
if ($d['tr_raz'] == -1) {
|
||||
$t .= 'Сколько еще раз можно выполнить задание: <b><small>бесконечно</small></b><br>';
|
||||
} else {
|
||||
$qlst = $u->testAction('SELECT `id` FROM `actions` WHERE `uid` = "' . $u->info['id'] . '" AND `vars` = "start_quest' . $pl['id'] . '" LIMIT ' . $d['tr_raz'], 2);
|
||||
$t .= 'Сколько раз можно выполнить задание: ' . ($d['tr_raz'] - $qlst[0]) . '<br>';
|
||||
$qlst = ActionModel::testCount(["uid = {$u->info['id']}", "vars = start_quest{$pl['id']}"], $d['tr_raz']);
|
||||
//$qlst = $u->testAction('SELECT `id` FROM `actions` WHERE `uid` = "' . $u->info['id'] . '" AND `vars` = "start_quest' . $pl['id'] . '" LIMIT ' . $d['tr_raz'], 2);
|
||||
$t .= 'Сколько раз можно выполнить задание: ' . ($d['tr_raz'] - $qlst) . '<br>';
|
||||
}
|
||||
unset($qlst);
|
||||
}
|
||||
//Попыток пройти квест
|
||||
if (isset($d['tr_raz2'])) {
|
||||
$qlst = $u->testAction('SELECT `id` FROM `actions` WHERE `uid` = "' . $u->info['id'] . '" AND `vars` = "start_quest' . $pl['id'] . '" AND `vals` != "go" AND `vals` != "win" LIMIT ' . $d['tr_raz2'], 2);
|
||||
$t .= 'Осталось попыток выполнить задание: ' . ($d['tr_raz2'] - $qlst[0]) . '<br>';
|
||||
$qlst = ActionModel::testCount(["uid = {$u->info['id']}", "vars = start_quest{$pl['id']}", "vals != go", "vals != win"], $d['tr_raz2']);
|
||||
//$qlst = $u->testAction('`uid` = "' . $u->info['id'] . '" AND `vars` = "start_quest' . $pl['id'] . '" AND `vals` != "go" AND `vals` != "win" LIMIT ' . $d['tr_raz2'], 2);
|
||||
$t .= 'Осталось попыток выполнить задание: ' . ($d['tr_raz2'] - $qlst) . '<br>';
|
||||
unset($qlst);
|
||||
}
|
||||
|
||||
@@ -479,28 +483,32 @@ class Quests
|
||||
|
||||
//Убить ботов
|
||||
if (isset($d['kill_bot'])) {
|
||||
|
||||
$ex = explode(',', $d['kill_bot']);
|
||||
if (isset($d['all_kill']) && (int)$d['all_kill'] > 0) {
|
||||
$x = '';
|
||||
$ex = explode(',', $d['kill_bot']);
|
||||
$i = 0; # Количество циклов для каждого типа бота.
|
||||
$q = '';
|
||||
$botid = 0;
|
||||
$sqlWhere = [];
|
||||
$sqlParams = [];
|
||||
while ($i < count($ex)) {
|
||||
$ex2 = explode('=', $ex[$i]);
|
||||
if ($q != '') {
|
||||
$q .= ' OR ';
|
||||
}
|
||||
$q .= ' (`uid` = "' . $u->info['id'] . '" AND `time` > ' . $qst['time'] . ' AND `vars` = "win_bot_' . $ex2[0] . '" )';
|
||||
$botid = $ex2[0];
|
||||
$sqlWhere[] = "(uid = :uid$i and time > :time$i and vars = :vars$i)";
|
||||
$sqlParams["uid$i"] = $u->info['id'];
|
||||
$sqlParams["time$i"] = $qst['time'];
|
||||
$sqlParams["vars$i"] = "win_bot_$ex2[0]";
|
||||
$i++;
|
||||
}
|
||||
$x2 = $u->testAction($q, 2);
|
||||
$x2 = $x2[0];
|
||||
$sqlWhere = implode(' or ', $sqlWhere);
|
||||
$x2 = ActionModel::testCountCustom($sqlWhere, $sqlParams);
|
||||
|
||||
if ($d['all_kill'] < $x2) {
|
||||
$x2 = $d['all_kill'];
|
||||
}
|
||||
$bot2 = mysql_fetch_array(mysql_query('SELECT * FROM `test_bot` WHERE `id` = "' . $ex2[0] . '" LIMIT 1'));
|
||||
if (isset($bot2['id'])) {
|
||||
$x .= ' • <b>' . $bot2['login'] . '</b> [' . $x2 . '/' . $d['all_kill'] . ']<br>';
|
||||
|
||||
$botlogin = Db::getValue('select login from test_bot where id = ?', [$botid]);
|
||||
if (isset($botlogin)) {
|
||||
$x .= ' • <b>' . $botlogin . '</b> [' . $x2 . '/' . $d['all_kill'] . ']<br>';
|
||||
} else {
|
||||
$x .= ' • <b>' . $pl['name'] . '</b> [' . $x2 . '/' . $d['all_kill'] . ']<br>';
|
||||
}
|
||||
@@ -509,13 +517,12 @@ class Quests
|
||||
while ($i < count($ex)) {
|
||||
$x2 = 0;
|
||||
$ex2 = explode('=', $ex[$i]);
|
||||
$bot2 = mysql_fetch_array(mysql_query('SELECT * FROM `test_bot` WHERE `id` = "' . $ex2[0] . '" LIMIT 1'));
|
||||
if (isset($bot2['id'])) {
|
||||
$botlogin = Db::getValue('select login from test_bot where id = ?', [$ex2[0]]);
|
||||
if (isset($botlogin)) {
|
||||
if (isset($qst['id'])) {
|
||||
$x2 = $u->testAction('`uid` = "' . $u->info['id'] . '" AND `time` > ' . $qst['time'] . ' AND `vars` = "win_bot_' . $ex2[0] . '" LIMIT ' . $ex2[1], 2);
|
||||
$x2 = 0 + $x2[0];
|
||||
$x2 = ActionModel::testCount(["uid = {$u->info['id']}", "vars = win_bot_$ex2[0]", "time > {$qst['time']}"], $ex2[1]);
|
||||
}
|
||||
$x .= ' • <b>' . $bot2['login'] . '</b> [' . $x2 . '/' . $ex2[1] . ']<br>';
|
||||
$x .= ' • <b>' . $botlogin . '</b> [' . $x2 . '/' . $ex2[1] . ']<br>';
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
@@ -525,7 +532,7 @@ class Quests
|
||||
$x = trim($x, ', ');
|
||||
$t .= 'Убить ботов: <br>' . $x;
|
||||
}
|
||||
unset($x, $ex, $x2, $bot2, $ex2);
|
||||
unset($x, $ex, $x2, $ex2, $botlogin);
|
||||
}
|
||||
|
||||
//Собрать ресурсы
|
||||
@@ -585,72 +592,86 @@ class Quests
|
||||
public function testquest(): void
|
||||
{
|
||||
global $u;
|
||||
if ($u->info['battle'] == 0 && $u->room['name'] != 'Башня Смерти') {
|
||||
$sp = mysql_query('SELECT * FROM `actions` WHERE `uid` = "' . $u->info['id'] . '" AND `vars` LIKE "%start_quest%" AND `vals` = "go" LIMIT 100');
|
||||
if ($u->info['battle'] != 0 || $u->room['name'] === 'Башня Смерти') {
|
||||
return;
|
||||
}
|
||||
|
||||
while ($pl2 = mysql_fetch_array($sp)) {
|
||||
$pl = mysql_fetch_array(mysql_query('SELECT * FROM `quests` WHERE `id` = "' . (str_replace('start_quest', '', $pl2['vars'])) . '" LIMIT 1'));
|
||||
$sp = mysql_query('SELECT * FROM `actions` WHERE `uid` = "' . $u->info['id'] . '" AND `vars` LIKE "%start_quest%" AND `vals` = "go" LIMIT 100');
|
||||
|
||||
$g = 1;
|
||||
//Действия квеста
|
||||
$d = $this->expl($pl['act_date']);
|
||||
while ($pl2 = mysql_fetch_array($sp)) {
|
||||
$pl = mysql_fetch_array(mysql_query('SELECT * FROM `quests` WHERE `id` = "' . (str_replace('start_quest', '', $pl2['vars'])) . '" LIMIT 1'));
|
||||
|
||||
//Поговорить с NPS
|
||||
if (isset($d['dlg_nps'])) {
|
||||
$g = 1;
|
||||
//Действия квеста
|
||||
$d = $this->expl($pl['act_date']);
|
||||
|
||||
//Поговорить с NPS
|
||||
if (isset($d['dlg_nps'])) {
|
||||
$g = 0;
|
||||
unset($x);
|
||||
}
|
||||
|
||||
//Убить игроков
|
||||
if (isset($d['kill_user'])) {
|
||||
$x = 0;
|
||||
if ($x < $d['kill_user']) {
|
||||
$g = 0;
|
||||
unset($x);
|
||||
}
|
||||
|
||||
//Убить игроков
|
||||
if (isset($d['kill_user'])) {
|
||||
$x = 0;
|
||||
if ($x < $d['kill_user']) {
|
||||
//$d['kill_user'] - стольких нужно убить
|
||||
unset($x);
|
||||
}
|
||||
//Убить ботов
|
||||
if (isset($d['kill_bot'])) {
|
||||
$ex = explode(',', $d['kill_bot']);
|
||||
$ii = 0; // Количество циклов для каждого типа бота.
|
||||
$smth2 = 0; // неизвестное.
|
||||
$sqlFilter = [];
|
||||
$sqlParams = [];
|
||||
while ($ii < count($ex)) {
|
||||
$ex2 = explode('=', $ex[$ii]);
|
||||
$smth2 = $ex2[1];
|
||||
$sqlFilter[] = "(uid = :uid$ii and time > :time$ii and vars = :vars$ii)";
|
||||
$sqlParams["uid$ii"] = $u->info['id'];
|
||||
$sqlParams["time$ii"] = $pl2['time'];
|
||||
$sqlFilter["vars$ii"] = "win_bot_$ex2[0]";
|
||||
$ii++;
|
||||
}
|
||||
$sqlFilter = implode(' or ', $sqlFilter);
|
||||
if (isset($d['all_kill']) && $d['all_kill'] > 0) {
|
||||
$x2 = ActionModel::testCountCustom($sqlFilter, $sqlParams, $d['all_kill']);
|
||||
if ($x2 < $d['all_kill']) {
|
||||
$g = 0;
|
||||
}
|
||||
//$d['kill_user'] - стольких нужно убить
|
||||
unset($x);
|
||||
}
|
||||
//Убить ботов
|
||||
if (isset($d['kill_bot'])) {
|
||||
$ex = explode(',', $d['kill_bot']);
|
||||
$ii = 0; // Количество циклов для каждого типа бота.
|
||||
$q = '';
|
||||
while ($ii < count($ex)) {
|
||||
$ex2 = explode('=', $ex[$ii]);
|
||||
if ($q != '') {
|
||||
$q .= ' OR ';
|
||||
}
|
||||
$q .= ' (`uid` = "' . $u->info['id'] . '" AND `time` > ' . $pl2['time'] . ' AND `vars` = "win_bot_' . $ex2[0] . '" )';
|
||||
$ii++;
|
||||
} else {
|
||||
$x2 = ActionModel::testCountCustom($sqlFilter, $sqlParams, $smth2);
|
||||
if (!isset($d['all_kill']) && $x2 < $smth2) {
|
||||
$g = 0;
|
||||
}
|
||||
if (isset($d['all_kill']) && $d['all_kill'] > 0) {
|
||||
$x2 = $u->testAction($q . ' LIMIT ' . $d['all_kill'], 2);
|
||||
if ($x2[0] < $d['all_kill']) {
|
||||
$g = 0;
|
||||
}
|
||||
} else {
|
||||
$x2 = $u->testAction($q . ' LIMIT ' . $ex2[1], 2);
|
||||
if (!isset($d['all_kill']) && $x2[0] < $ex2[1]) {
|
||||
$g = 0;
|
||||
}
|
||||
}
|
||||
unset($x, $ex, $x2, $x3, $bot2, $ex2);
|
||||
}
|
||||
}
|
||||
|
||||
//Собрать ресурсы
|
||||
if (isset($d['tk_itm'])) {
|
||||
$g = $this->collect_01(explode(',', $d['tk_itm']), $u);
|
||||
}
|
||||
//Собирание трофеев
|
||||
if (isset($d['tkill_itm'])) {
|
||||
$g = $this->collect_01(explode(',', $d['tkill_itm']), $u);
|
||||
}
|
||||
if ($g == 1) {
|
||||
$pl['time'] = $pl2['time'];
|
||||
$this->endq($pl['id'], 'win');
|
||||
$this->winQuest($pl);
|
||||
echo $pl['name'];
|
||||
//Собрать ресурсы
|
||||
if (isset($d['tk_itm'])) {
|
||||
$g = $this->collect_01(explode(',', $d['tk_itm']), $u);
|
||||
}
|
||||
//Собирание трофеев
|
||||
if (isset($d['tkill_itm'])) {
|
||||
$g = $this->collect_01(explode(',', $d['tkill_itm']), $u);
|
||||
}
|
||||
if ($g == 1) {
|
||||
$pl['time'] = $pl2['time'];
|
||||
$this->endq($pl['id'], 'win');
|
||||
$status = $this->winQuest($u->info['id'], $pl, $pl2['time']);
|
||||
//Отправляем сообщение в чат
|
||||
if ($status) {
|
||||
$chatDto = new ChatMessage();
|
||||
$chatDto->setRoom($u->info['room']);
|
||||
$chatDto->setTo($u->info['login']);
|
||||
$chatDto->setText($status);
|
||||
$chatDto->setType(5);
|
||||
(new Chat())->sendMsg($chatDto);
|
||||
}
|
||||
echo $pl['name'];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -688,125 +709,117 @@ class Quests
|
||||
|
||||
# Функция отвечает за ПРОВЕРКУ на ЗАВЕРШЕНИЕ квестов для ПОДЗЕМОК
|
||||
|
||||
private function winQuest($pl)
|
||||
private function winQuest($uid, $pl, $time): string
|
||||
{
|
||||
global $u, $c, $magic;
|
||||
global $magic;
|
||||
|
||||
if (isset($pl['id'])) {
|
||||
$d = $this->expl($pl['act_date']);
|
||||
|
||||
$d = array_merge($d, $this->expl($pl['win_date']));
|
||||
|
||||
if ($_COOKIE['login'] == 'R' || $_COOKIE['login'] == 'r') {
|
||||
echo '<script>alert("';
|
||||
print_r(str_replace("\n", ' ', $d));
|
||||
echo '");</script>';
|
||||
die();
|
||||
}
|
||||
|
||||
// Забираем ресурсы
|
||||
if (isset($d['tk_itm'])) {
|
||||
$ex = explode(',', $d['tk_itm']);
|
||||
$i = 0;
|
||||
while ($i < count($ex)) {
|
||||
$ex2 = explode('=', $ex[$i]);
|
||||
$ex2 = explode('=', $ex[$i]);
|
||||
$x2 = $u->testAction('`uid` = "' . $u->info['id'] . '" AND `time` > ' . $pl2['time'] . ' AND `vars` = "win_bot_' . $ex2[0] . '" LIMIT ' . $ex2[1], 2);
|
||||
ItemsModel::deleteItemsById($ex2[0], $ex2[1]);
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
// Забираем трофеи
|
||||
if (isset($d['tkill_itm'])) {
|
||||
$ex = explode(',', $d['tkill_itm']);
|
||||
$i = 0;
|
||||
while ($i < count($ex)) {
|
||||
$ex2 = explode('=', $ex[$i]);
|
||||
$ex2 = explode('=', $ex[$i]);
|
||||
$x2 = $u->testAction('`uid` = "' . $u->info['id'] . '" AND `time` > ' . $pl2['time'] . ' AND `vars` = "win_bot_' . $ex2[0] . '" LIMIT ' . $ex2[1], 2);
|
||||
ItemsModel::deleteItemsById($ex2[0], $ex2[1]);
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
$t = '';
|
||||
if (isset($d['add_rep'])) { // Получаем репутацию за квест, если это убийства ботов.
|
||||
if (isset($d['kill_bot']) && isset($d['all_kill']) && $d['add_rep'] > 0) {
|
||||
$ex = explode(',', $d['kill_bot']);
|
||||
$ii = 0;
|
||||
$d['add_rep'] = 0;
|
||||
while ($ii < count($ex)) {
|
||||
$i = 0;
|
||||
$ex2 = explode('=', $ex[$i]);
|
||||
while ($i < $d['all_kill']) {
|
||||
$x2 = 0;
|
||||
$d['add_rep'] = $d['add_rep'] + $ex2[1];
|
||||
$x2 = $u->testAction('`uid` = "' . $u->info['id'] . '" AND `time` > ' . $pl2['time'] . ' AND `vars` = "win_bot_' . $ex2[0] . '" LIMIT ' . $d['all_kill'], 2);
|
||||
$i++;
|
||||
}
|
||||
$ii++;
|
||||
}
|
||||
}
|
||||
unset($x, $i, $ii, $ex, $x2, $bot2, $ex2);
|
||||
if ($pl['city'] != '') {
|
||||
$t .= '' . $d['add_rep'] . ' ед. репутации ' . $pl['city'] . ', ';
|
||||
$rep = mysql_fetch_array(mysql_query('SELECT * FROM `rep` WHERE `id` = "' . $u->info['id'] . '" LIMIT 1'));
|
||||
|
||||
if ($rep['rep' . $pl['city']] < 24999 && $rep['rep' . $pl['city']] + $d['add_rep'] >= 24999 && $pl['kin'] != 2) {
|
||||
$rep['rep' . $pl['city']] = 24999;
|
||||
} else {
|
||||
$rep['rep' . $pl['city']] += $d['add_rep'];
|
||||
}
|
||||
mysql_query('UPDATE `rep` SET `rep' . $pl['city'] . '` = "' . $rep['rep' . $pl['city']] . '" WHERE `id` = "' . $rep['id'] . '" LIMIT 1');
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($d['add_repizlom'])) {
|
||||
$t .= '' . $d['add_repizlom'] . ' ед. репутации Излома Хаоса, ';
|
||||
$rep = mysql_fetch_array(mysql_query('SELECT * FROM `rep` WHERE `id` = "' . $u->info['id'] . '" LIMIT 1'));
|
||||
$rep['repizlom'] += $d['add_repizlom'];
|
||||
if ($rep['repizlom'] > 24999) {
|
||||
$rep['repizlom'] = 24999;
|
||||
}
|
||||
mysql_query('UPDATE `rep` SET `repizlom` = "' . $rep['repizlom'] . '" WHERE `id` = "' . $rep['id'] . '" LIMIT 1');
|
||||
}
|
||||
|
||||
if (isset($d['add_eff'])) {
|
||||
$i = 0;
|
||||
$j = explode('=', $d['add_eff']);
|
||||
while ($i < count($j)) {
|
||||
if ($j[$i] > 0) {
|
||||
$magic->addEffect($u->info['id'], $j[$i], 1);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($d['add_cr'])) {
|
||||
$t .= '' . $d['add_cr'] . ' кр., ';
|
||||
mysql_query('UPDATE `users` SET `money` = `money`+' . $d['add_cr'] . ' WHERE `id` = "' . $u->info['id'] . '" LIMIT 1');
|
||||
}
|
||||
|
||||
if ($t != '') {
|
||||
$t = rtrim($t, ', ');
|
||||
$r = 'Задание <b>' . $pl['name'] . '</b> было успешно выполнено! Вы получили награду: ' . $t . '.';
|
||||
unset($t);
|
||||
} else {
|
||||
$r = 'Задание <b>' . $pl['name'] . '</b> было успешно выполнено!';
|
||||
}
|
||||
$r = '<small>' . $r . '</small>';
|
||||
//Отправляем сообщение в чат
|
||||
$chatDto = new ChatMessage();
|
||||
$chatDto->setCity($u->info['city']);
|
||||
$chatDto->setRoom($u->info['room']);
|
||||
$chatDto->setTo($u->info['login']);
|
||||
$chatDto->setText($r);
|
||||
$chatDto->setType(5);
|
||||
(new Chat())->sendMsg($chatDto);
|
||||
if (!isset($pl['id'])) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$d = $this->expl($pl['act_date']);
|
||||
|
||||
$d = array_merge($d, $this->expl($pl['win_date']));
|
||||
|
||||
if ($_COOKIE['login'] == 'R' || $_COOKIE['login'] == 'r') {
|
||||
echo '<script>alert("';
|
||||
print_r(str_replace("\n", ' ', $d));
|
||||
echo '");</script>';
|
||||
die();
|
||||
}
|
||||
|
||||
// Забираем ресурсы
|
||||
if (isset($d['tk_itm'])) {
|
||||
$ex = explode(',', $d['tk_itm']);
|
||||
$i = 0;
|
||||
while ($i < count($ex)) {
|
||||
$ex2 = explode('=', $ex[$i]);
|
||||
$x2 = ActionModel::testCount(["uid = $uid", "vars = win_bot_$ex[2]", "time > $time"], $ex2[1]);
|
||||
ItemsModel::deleteItemsById($ex2[0], $ex2[1]);
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
// Забираем трофеи
|
||||
if (isset($d['tkill_itm'])) {
|
||||
$ex = explode(',', $d['tkill_itm']);
|
||||
$i = 0;
|
||||
while ($i < count($ex)) {
|
||||
$ex2 = explode('=', $ex[$i]);
|
||||
$x2 = ActionModel::testCount(["uid = $uid", "vars = win_bot_$ex[2]", "time > $time"], $ex2[1]);
|
||||
ItemsModel::deleteItemsById($ex2[0], $ex2[1]);
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
$t = '';
|
||||
if (isset($d['add_rep'])) { // Получаем репутацию за квест, если это убийства ботов.
|
||||
if (isset($d['kill_bot']) && isset($d['all_kill']) && $d['add_rep'] > 0) {
|
||||
$ex = explode(',', $d['kill_bot']);
|
||||
$ii = 0;
|
||||
$d['add_rep'] = 0;
|
||||
while ($ii < count($ex)) {
|
||||
$i = 0;
|
||||
$ex2 = explode('=', $ex[$i]);
|
||||
while ($i < $d['all_kill']) {
|
||||
$d['add_rep'] = $d['add_rep'] + (int)$ex2[1];
|
||||
$x2 = ActionModel::testCount(["uid = $uid", "vars = win_bot_$ex[2]", "time > $time"], $d['all_kill']);
|
||||
$i++;
|
||||
}
|
||||
$ii++;
|
||||
}
|
||||
}
|
||||
unset($x, $i, $ii, $ex, $x2, $bot2, $ex2);
|
||||
if ($pl['city'] != '') {
|
||||
$t .= '' . $d['add_rep'] . ' ед. репутации ' . $pl['city'] . ', ';
|
||||
$rep = mysql_fetch_array(mysql_query('SELECT * FROM `rep` WHERE `id` = "' . $uid . '" LIMIT 1'));
|
||||
|
||||
if ($rep['rep' . $pl['city']] < 24999 && $rep['rep' . $pl['city']] + $d['add_rep'] >= 24999 && $pl['kin'] != 2) {
|
||||
$rep['rep' . $pl['city']] = 24999;
|
||||
} else {
|
||||
$rep['rep' . $pl['city']] += $d['add_rep'];
|
||||
}
|
||||
mysql_query('UPDATE `rep` SET `rep' . $pl['city'] . '` = "' . $rep['rep' . $pl['city']] . '" WHERE `id` = "' . $rep['id'] . '" LIMIT 1');
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($d['add_repizlom'])) {
|
||||
$t .= '' . $d['add_repizlom'] . ' ед. репутации Излома Хаоса, ';
|
||||
$rep = mysql_fetch_array(mysql_query('SELECT * FROM `rep` WHERE `id` = "' . $uid . '" LIMIT 1'));
|
||||
$rep['repizlom'] += $d['add_repizlom'];
|
||||
if ($rep['repizlom'] > 24999) {
|
||||
$rep['repizlom'] = 24999;
|
||||
}
|
||||
mysql_query('UPDATE `rep` SET `repizlom` = "' . $rep['repizlom'] . '" WHERE `id` = "' . $rep['id'] . '" LIMIT 1');
|
||||
}
|
||||
|
||||
if (isset($d['add_eff'])) {
|
||||
$i = 0;
|
||||
$j = explode('=', $d['add_eff']);
|
||||
while ($i < count($j)) {
|
||||
if ($j[$i] > 0) {
|
||||
$magic->addEffect($uid, $j[$i], 1);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($d['add_cr'])) {
|
||||
$t .= '' . $d['add_cr'] . ' кр., ';
|
||||
mysql_query('UPDATE `users` SET `money` = `money`+' . $d['add_cr'] . ' WHERE `id` = "' . $uid . '" LIMIT 1');
|
||||
}
|
||||
|
||||
if ($t != '') {
|
||||
$t = rtrim($t, ', ');
|
||||
$r = 'Задание <b>' . $pl['name'] . '</b> было успешно выполнено! Вы получили награду: ' . $t . '.';
|
||||
unset($t);
|
||||
} else {
|
||||
$r = 'Задание <b>' . $pl['name'] . '</b> было успешно выполнено!';
|
||||
}
|
||||
|
||||
return "<small>$r</small>";
|
||||
}
|
||||
|
||||
public function questCheckEnd($pl)
|
||||
public function questCheckEnd($pl): int
|
||||
{
|
||||
global $u;
|
||||
$quest = mysql_fetch_array(mysql_query('SELECT * FROM `actions` WHERE `uid` = "' . $u->info['id'] . '" AND `vars` = "start_quest' . $pl['id'] . '" ORDER BY `time` DESC LIMIT 1'));
|
||||
@@ -836,29 +849,31 @@ class Quests
|
||||
if (isset($d['kill_bot'])) {
|
||||
$ex = explode(',', $d['kill_bot']);
|
||||
$i = 0; # Количество циклов для каждого типа бота.
|
||||
$q = '';
|
||||
$smth1 = 0; // неизвестно что.
|
||||
$sqlFilter = [];
|
||||
$sqlParams = [];
|
||||
while ($i < count($ex)) {
|
||||
$ex2 = explode('=', $ex[$i]);
|
||||
if ($q != '') {
|
||||
$q .= ' OR ';
|
||||
}
|
||||
$q .= ' (`uid` = "' . $u->info['id'] . '" AND `time` > ' . $quest['time'] . ' AND `vars` = "win_bot_' . $ex2[0] . '" )';
|
||||
$smth1 = $ex2[1];
|
||||
$sqlFilter[] = "(uid = :uid$i and time > :time$i and vars = :vars$i)";
|
||||
$sqlParams[":uid$i"] = $u->info['id'];
|
||||
$sqlParams[":time$i"] = $quest['time'];
|
||||
$sqlParams[":vars$i"] = "win_bot_$ex2[0]";
|
||||
$i++;
|
||||
}
|
||||
$sqlFilter = implode(' or ', $sqlFilter);
|
||||
if (isset($d['all_kill']) && (int)$d['all_kill'] > 0) {
|
||||
$x2 = $u->testAction($q, 2);
|
||||
if ((int)$d['all_kill'] <= $x2[0]) {
|
||||
$x2 = ActionModel::testCountCustom($sqlFilter, $sqlParams);
|
||||
if ((int)$d['all_kill'] <= $x2) {
|
||||
$x2 = (int)$d['all_kill'];
|
||||
} else {
|
||||
$x2 = $x2[0];
|
||||
}
|
||||
if ($x2 < (int)$d['all_kill']) {
|
||||
$g = 0;
|
||||
}
|
||||
} else {
|
||||
$x2 = $u->testAction($q . ' LIMIT ' . $ex2[1], 2);
|
||||
$x2 = min($ex2[1], $x2[0]);
|
||||
if ($x2 < $ex2[1]) {
|
||||
$x2 = ActionModel::testCountCustom($sqlFilter, $sqlParams, $smth1);
|
||||
$x2 = min($smth1, $x2);
|
||||
if ($x2 < $smth1) {
|
||||
$g = 0;
|
||||
}
|
||||
}
|
||||
@@ -886,10 +901,10 @@ class Quests
|
||||
$x2 = Db::getValue('select count(*) from items_users where maidin = ? and item_id = ? and uid = ? and `delete` in (0,1000) and inTransfer = 0 and inShop = 0',
|
||||
[$pl['city'], (int)$ex2[0], $u->info['id']]);
|
||||
if ($x2 >= $ex2[1]) {
|
||||
if ($x2 <= ($ex2[1] + round($ex2[1] * 0.15))) {
|
||||
if ($x2 <= ((int)$ex2[1] + round($ex2[1] * 0.15))) {
|
||||
$ex2[1] = $x2;
|
||||
} else {
|
||||
$ex2[1] = ($ex2[1] + round($ex2[1] * 0.15));
|
||||
$ex2[1] = ((int)$ex2[1] + round($ex2[1] * 0.15));
|
||||
}
|
||||
}
|
||||
if ($x2 < $ex2[1]) {
|
||||
@@ -928,10 +943,10 @@ class Quests
|
||||
$x2 = Db::getValue('select count(*) from items_users where maidin = ? and item_id = ? and uid = ? and `delete` in (0,1000) and inTransfer = 0 and inShop = 0',
|
||||
[$quest['city'], (int)$ex2[0], $u->info['id']]);
|
||||
if ($x2 >= $ex2[1]) {
|
||||
if ($x2 <= ($ex2[1] + round($ex2[1] * 0.15))) {
|
||||
if ($x2 <= ((int)$ex2[1] + round($ex2[1] * 0.15))) {
|
||||
$ex2[1] = $x2;
|
||||
} else {
|
||||
$ex2[1] = ($ex2[1] + round($ex2[1] * 0.15));
|
||||
$ex2[1] = ((int)$ex2[1] + round($ex2[1] * 0.15));
|
||||
}
|
||||
}
|
||||
$d['add_rep'] = (int)$d['add_rep'] * (int)$ex2[1];
|
||||
@@ -953,9 +968,8 @@ class Quests
|
||||
$i = 0;
|
||||
$ex2 = explode('=', $ex[$i]);
|
||||
while ($i < $d['all_kill']) {
|
||||
$x2 = 0;
|
||||
$d['add_rep'] = $d['add_rep'] + $ex2[1];
|
||||
$x2 = $u->testAction('`uid` = "' . $u->info['id'] . '" AND `time` > ' . $action['time'] . ' AND `vars` = "win_bot_' . $ex2[0] . '" LIMIT ' . $d['all_kill'], 2);
|
||||
$d['add_rep'] = $d['add_rep'] + (int)$ex2[1];
|
||||
$x2 = ActionModel::testCount(["uid = {$u->info['id']}", "vars = win_bot_$ex2[0]", "time > {$action['time']}"], $d['all_kill']);
|
||||
$i++;
|
||||
}
|
||||
$ii++;
|
||||
|
||||
+64
-91
@@ -243,17 +243,6 @@ class User
|
||||
$this->statnames->getBonus();
|
||||
$this->statnames->getRequirement();
|
||||
|
||||
if (Core\Config::get('securetime') > 0) {
|
||||
if (!defined('IP')) {
|
||||
define('IP', $_SERVER['REMOTE_ADDR']);
|
||||
}
|
||||
|
||||
if (isset($this->info['id']) && ($this->info['ip'] != IP || $this->info['banned'] > 0) && $_SERVER['REQUEST_URI'] != '/') {
|
||||
unset($this->info, $_COOKIE['login']);
|
||||
die(Config::get('exit'));
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset ($_COOKIE['btl'], $this->info['battle']) || $this->info['battle'] != $_COOKIE['btl']) {
|
||||
setcookie('btl', $this->info['battle'] ?? '', time() + 86400);
|
||||
}
|
||||
@@ -271,9 +260,9 @@ class User
|
||||
|
||||
if ($sb - 1 > $this->info['catch'] - $this->info['frg']) {
|
||||
if ($this->info['frg'] == -1) {
|
||||
$sm = $this->testAction('`uid` = "' . $this->info['id'] . '" AND `vars` = "frg" LIMIT 1', 1);
|
||||
$sm = (bool)ActionModel::testCount(["uid = {$this->info['id']}", 'vars = frg']);
|
||||
}
|
||||
if (!isset($sm['id']) && $this->info['frg'] == -1) {
|
||||
if (!$sm && $this->info['frg'] == -1) {
|
||||
mysql_query(
|
||||
'UPDATE `users` SET `catch` = "' . round(
|
||||
$sb
|
||||
@@ -298,6 +287,7 @@ class User
|
||||
);
|
||||
}
|
||||
}
|
||||
unset($sm);
|
||||
}
|
||||
|
||||
if ($this->info['login2'] != '' && $this->info['battle'] == 0 && $this->info['zv'] == 0) {
|
||||
@@ -315,8 +305,7 @@ class User
|
||||
}
|
||||
|
||||
if (isset($_GET['homeworld']) && $this->info['zv'] == 0 && $this->info['battle'] == 0 && $this->info['dnow'] == 0) {
|
||||
$hgo = $this->testHome();
|
||||
if (!isset($hgo['id']) && $this->info['room'] != 274 && $this->info['align'] != 2 && $this->info['inTurnir'] == 0) {
|
||||
if ($this->testHome() && $this->info['room'] != 274 && $this->info['align'] != 2 && $this->info['inTurnir'] == 0) {
|
||||
$this->addAction(time(), 'go_homeworld', '');
|
||||
$rmt = mysql_fetch_array(
|
||||
mysql_query(
|
||||
@@ -351,7 +340,6 @@ class User
|
||||
} else {
|
||||
$this->error = 'Вам запрещено пользоваться кнопкой возрата';
|
||||
}
|
||||
unset($hgo);
|
||||
}
|
||||
|
||||
//Заносим текст
|
||||
@@ -517,17 +505,14 @@ class User
|
||||
*/
|
||||
|
||||
//Статистика персонажа на сегодня
|
||||
$stat = $this->testAction(
|
||||
'`uid` = "' . $this->info['id'] . '" AND `time` >= ' . strtotime(
|
||||
'now 00:00:00'
|
||||
) . ' AND `vars` = "statistic_today" LIMIT 1', 1
|
||||
);
|
||||
if (!isset($stat['id'])) {
|
||||
$stat = (bool)ActionModel::testCount(["uid = {$this->info['id']}", "time >= " . strtotime('now 00:00:00'), 'vars = statistic_today']);
|
||||
if (!$stat) {
|
||||
$this->addAction(
|
||||
time(), 'statistic_today',
|
||||
'e=' . $this->info['exp'] . '|w=' . $this->info['win'] . '|l=' . $this->info['lose'] . '|n=' . $this->info['nich']
|
||||
);
|
||||
}
|
||||
unset($stat);
|
||||
|
||||
//Одеваем боевой комплект
|
||||
if (isset($_GET['usec1']) && $this->info['battle'] == 0) {
|
||||
@@ -611,11 +596,8 @@ class User
|
||||
}
|
||||
|
||||
if (isset($_GET['obr_sel']) || isset($_GET['obraz'])) {
|
||||
$sm = $this->testAction(
|
||||
'`uid` = "' . $this->info['id'] . '" AND `time` > ' . (time() - 86400) . ' AND `vars` = "sel_obraz" LIMIT 1',
|
||||
1
|
||||
);
|
||||
if (!isset($sm['id'])) {
|
||||
$obrazTimeout = ActionModel::getOne(["uid = {$this->info['id']}", 'time > unix_timestamp() - 86400', 'vars = sel_obraz'], 'time');
|
||||
if (!$obrazTimeout) {
|
||||
if (isset($_GET['obr_sel'])) {
|
||||
$tr = true;
|
||||
$o = mysql_fetch_array(
|
||||
@@ -686,7 +668,7 @@ class User
|
||||
}
|
||||
} else {
|
||||
$this->error = 'Выбирать образ можно не чаще одного раза в сутки, следующая смена ' . date(
|
||||
'd.m.Y H:i', $sm['time'] + 86400
|
||||
'd.m.Y H:i', $obrazTimeout + 86400
|
||||
);
|
||||
unset($_GET['obr_sel']);
|
||||
$_GET['inv'] = 1;
|
||||
@@ -822,22 +804,6 @@ class User
|
||||
return Db::getRow('select * from users left join stats on users.id = stats.id where users.id = ?', [$id]);
|
||||
}
|
||||
|
||||
public function testAction($filter, $tp): array
|
||||
{
|
||||
if ($tp == 1) {
|
||||
$query = 'select * from actions where ' . $filter;
|
||||
} elseif ($tp == 2) {
|
||||
$query = 'select count(*) from actions where ' . $filter;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
$arr = mysql_fetch_array(mysql_query($query));
|
||||
|
||||
return !empty($arr) ? $arr : [];
|
||||
}
|
||||
|
||||
//Удаление определенного типа предметов
|
||||
|
||||
public function addAction($time, $vars, $vls, $uid = null): bool
|
||||
{
|
||||
$info = $this->info;
|
||||
@@ -848,7 +814,14 @@ class User
|
||||
return true;
|
||||
}
|
||||
|
||||
public function testHome(): array
|
||||
//Удаление определенного типа предметов
|
||||
|
||||
/**
|
||||
* Кнопка "Возврат".
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function testHome(): bool
|
||||
{
|
||||
/*----Быстрый(Особенность)----*/
|
||||
$timeforwait = 3600;
|
||||
@@ -856,25 +829,27 @@ class User
|
||||
$timeforwait = 3600 - (($st['os6'] * 5) * 60);
|
||||
}
|
||||
/*----Быстрый(Особенность)----*/
|
||||
$hgo = $this->testAction(
|
||||
'`uid` = "' . $this->info['id'] . '" AND `time` >= ' . (time() - $timeforwait) . ' AND `vars` = "go_homeworld" LIMIT 1',
|
||||
1
|
||||
);
|
||||
if ($this->info['level'] == 0 || $this->info['active'] != '' || $this->info['inTurnir'] > 0 || $this->info['inTurnirnew'] > 0 || $this->info['zv'] > 0 || $this->info['dnow'] > 0) {
|
||||
$hgo['id'] = true;
|
||||
$buttonUsed = (bool)ActionModel::testCount(["uid = {$this->info['id']}", "time >= unix_timestamp - $timeforwait", 'vars = go_homeworld']);
|
||||
|
||||
if (
|
||||
$this->info['level'] == 0 ||
|
||||
$this->info['active'] != '' ||
|
||||
$this->info['inTurnir'] > 0 ||
|
||||
$this->info['inTurnirnew'] > 0 ||
|
||||
$this->info['zv'] > 0 ||
|
||||
$this->info['dnow'] > 0 ||
|
||||
!empty($this->info['noreal'])
|
||||
) {
|
||||
$buttonUsed = true;
|
||||
}
|
||||
if (isset($this->info['noreal']) || $this->info['dnow'] > 0) {
|
||||
$hgo['id'] = true;
|
||||
}
|
||||
if (!isset($hgo['id'])) {
|
||||
$ku = mysql_fetch_array(
|
||||
mysql_query('SELECT `id` FROM `katok_zv` WHERE `uid` = ' . $this->info['id'])
|
||||
);
|
||||
if (isset($ku['id'])) {
|
||||
$hgo['id'] = true;
|
||||
|
||||
if (!$buttonUsed) {
|
||||
$onKatok = (bool)Db::getValue('select id from katok_zv where uid = ?', [$this->info['id']]);
|
||||
if ($onKatok) {
|
||||
$buttonUsed = true;
|
||||
}
|
||||
}
|
||||
return $hgo ?? [];
|
||||
return !$buttonUsed;
|
||||
}
|
||||
|
||||
public function wipe()
|
||||
@@ -955,44 +930,41 @@ class User
|
||||
|
||||
//Расчет урона от оружия
|
||||
|
||||
public function allActionsStart()
|
||||
public function allActionsStart(): void
|
||||
{
|
||||
global $magic;
|
||||
define('VAREZHKI_ITEM_ID', 998);
|
||||
|
||||
if (!isset($_GET['use_snowball'])) {
|
||||
return;
|
||||
}
|
||||
$this->stats = $this->getStats($this->info, 0);
|
||||
//Начинаем лепить снежок на ЦП
|
||||
if (!isset($this->stats['items'][$this->stats['wp13id']]['id']) || $this->stats['items'][$this->stats['wp13id']]['item_id'] != 998) {
|
||||
if (!isset($this->stats['items'][$this->stats['wp13id']]['id']) || $this->stats['items'][$this->stats['wp13id']]['item_id'] != VAREZHKI_ITEM_ID) {
|
||||
return;
|
||||
}//варежки одеты, все ок
|
||||
if ($this->room['name'] != 'Центральная площадь') {
|
||||
$this->error2 = 'Собирать снег можно только на Центральной площади';
|
||||
} else {
|
||||
$smt = $this->testAction(
|
||||
'`uid` = "' . $this->info['id'] . '" AND `time`>=' . (time() - 120) . ' AND `vars` = "create_snowball_cp" LIMIT 1',
|
||||
1
|
||||
);
|
||||
if (isset($smt['id'])) {
|
||||
$this->error2 = 'Нельзя лепить несколько снежков одновременно ;)';
|
||||
} else {
|
||||
$smt = $this->testAction(
|
||||
'`uid` = "' . $this->info['id'] . '" AND `time`>=' . strtotime(
|
||||
'now 00:00:00'
|
||||
) . ' AND `vars` = "create_snowball_cp" LIMIT 25',
|
||||
2
|
||||
);
|
||||
$smt = $smt[0];
|
||||
if ($smt < 10) {
|
||||
$this->addAction(time(), 'create_snowball_cp', $this->info['city']);
|
||||
|
||||
$magic->addEffect($this->info['id'], 24);
|
||||
$this->error2 = 'Начинаем лепить снежок, осталось ' . (10 - $smt) . ' раз на сегодня ...';
|
||||
} else {
|
||||
$this->error2 = 'Вы уже слепили 10 снежка за сегодня ...';
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
$isMakingSnowball = (bool)ActionModel::testCount(["uid = {$this->info['id']}", "time >= unix_timestamp() - 120", 'vars = create_snowball_cp']);
|
||||
|
||||
if ($isMakingSnowball) {
|
||||
$this->error2 = 'Нельзя лепить несколько снежков одновременно ;)';
|
||||
return;
|
||||
}
|
||||
|
||||
$createdToday = ActionModel::testCount(["uid = {$this->info['id']}", 'vars = create_snowball_cp', 'time >= ' . strtotime('now 00:00:00')], 25);
|
||||
|
||||
if ($createdToday >= 10) {
|
||||
$this->error2 = 'Вы уже слепили 10 снежка за сегодня ...';
|
||||
return;
|
||||
}
|
||||
|
||||
$this->addAction(time(), 'create_snowball_cp', $this->info['city']);
|
||||
$magic->addEffect($this->info['id'], 24);
|
||||
$this->error2 = 'Начинаем лепить снежок, осталось ' . (10 - $createdToday) . ' раз на сегодня ...';
|
||||
}
|
||||
|
||||
//Расчет защиты
|
||||
@@ -2774,7 +2746,7 @@ class User
|
||||
Delo::add(
|
||||
2,
|
||||
'System.remont.upatack',
|
||||
$u->info['id'],
|
||||
$this->info['id'],
|
||||
'"<span style="color: #4863A0; ">System.remont.upatack</span>": Заточка "' . $data['upatack_name'] . '" была успешно <strong>встроена</strong> в предмет "' . $id['name'] . '" [itm:' . $id['id'] . ']',
|
||||
);
|
||||
|
||||
@@ -4905,7 +4877,7 @@ class User
|
||||
return 0;
|
||||
}
|
||||
|
||||
$sleep = $this->testAction('`vars` = "sleep" AND `uid` = "' . $e['uid'] . '" LIMIT 1', 1);
|
||||
$sleep = ActionModel::getOne(["uid = {$e['uid']}", 'vars = sleep'], 'vars');
|
||||
|
||||
if ($e['id_eff'] == 2) {
|
||||
//Проверка
|
||||
@@ -4929,6 +4901,7 @@ class User
|
||||
if (isset($po['finish_file']) && file_exists('_incl_data/class/Magic/' . $po['finish_file'] . '.php')) {
|
||||
require_once '_incl_data/class/Magic/' . $po['finish_file'] . '.php';
|
||||
}
|
||||
|
||||
if (isset($u['id']) && ($e['type1'] < 11 || $e['type1'] > 16 && $e['type1'] < 23) && $e['noch'] == 0) {
|
||||
$text = "Закончилось действие эффекта «<strong>{$e['name']}</strong>»";
|
||||
$cmsg = new ChatMessage();
|
||||
@@ -6103,7 +6076,7 @@ LIMIT 1'
|
||||
'UPDATE `items_users` SET `lastUPD` = "' . time() . '", `uid` = "' . $user['id'] . '", `data` = "' . $pl['data'] . '" WHERE `id` = "' . $pl['id'] . '"'
|
||||
);
|
||||
mysql_query(
|
||||
'INSERT INTO `clan_operations` (`clan`, `time`, `type`, `text`, `val`, `uid`) VALUES ("' . $res['id'] . '", "' . time() . '", "' . $type . '", "' . $user['login'] . '", "' . $it_n['name'] . ' (x' . $col . ') Ид : [' . $pl['id'] . ']", "' . $user['id'] . '")'
|
||||
'INSERT INTO `clan_operations` (`clan`, `time`, `type`, `text`, `val`, `uid`) VALUES ("' . $cl . '", "' . time() . '", "' . $type . '", "' . $user['login'] . '", "' . $it_n['name'] . ' (x' . $col . ') Ид : [' . $pl['id'] . ']", "' . $user['id'] . '")'
|
||||
);
|
||||
} elseif ($pl['uid'] == $user['id']) {
|
||||
$col = $this->itemsX(((int)$pl['id']));
|
||||
@@ -6114,7 +6087,7 @@ LIMIT 1'
|
||||
'UPDATE `items_users` SET `lastUPD` = "' . time() . '", `uid` = "-21' . $user['clan'] . '" WHERE `id` = "' . $pl['id'] . '"'
|
||||
);
|
||||
mysql_query(
|
||||
'INSERT INTO `clan_operations` (`clan`, `time`, `type`, `text`, `val`, `uid`) VALUES ("' . $res['id'] . '", "' . time() . '", "9", "' . $user['login'] . '", "' . $it_n['name'] . ' (x' . $col . ') Ид : [' . $pl['id'] . ']", "' . $user['id'] . '")'
|
||||
'INSERT INTO `clan_operations` (`clan`, `time`, `type`, `text`, `val`, `uid`) VALUES ("' . $cl . '", "' . time() . '", "9", "' . $user['login'] . '", "' . $it_n['name'] . ' (x' . $col . ') Ид : [' . $pl['id'] . ']", "' . $user['id'] . '")'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,30 +6,24 @@ use Core\Config;
|
||||
use Core\Db;
|
||||
use Helper\Mail;
|
||||
use PassGen;
|
||||
use UserIp;
|
||||
|
||||
class Confirmation
|
||||
{
|
||||
/**
|
||||
* Для однотипных писем с подтверждением.
|
||||
* @param array $userinfo Данные из (User)->info.
|
||||
* @param mixed $value Новое значение
|
||||
* @param string $value Новое значение
|
||||
* @param ?int $code Проверочный код
|
||||
* @param string $type Тип меняемого значения. С маленькой буквы, именительный падеж.
|
||||
* @return void
|
||||
*/
|
||||
public static function byEmail(array $userinfo, string $type, $value, ?int $code = null)
|
||||
public static function byEmail(array $userinfo, string $type, string $value, ?int $code = null): void
|
||||
{
|
||||
if ($type === 'pass2' && is_null($code)) {
|
||||
self::pass2ByEmailCustom($userinfo, $value);
|
||||
return;
|
||||
}
|
||||
$ip = UserIp::get();
|
||||
$date = date('d.m.y H:i');
|
||||
$https = Config::get('https');
|
||||
$support = Config::get('support');
|
||||
$activationLink = 'https://' . $userinfo['city'] . Config::get('host') .
|
||||
"/confirm.php?id={$userinfo['id']}&code=$code";
|
||||
$activationLink = Config::get('https') . "/confirm.php?id={$userinfo['id']}&code=$code";
|
||||
$fulllogin = $userinfo['login'] . "[{$userinfo['level']}]";
|
||||
Mail::send(
|
||||
$userinfo['mail'],
|
||||
@@ -55,31 +49,7 @@ class Confirmation
|
||||
);
|
||||
}
|
||||
|
||||
private static function pass2ByEmailCustom(array $userinfo, string $pass2)
|
||||
{
|
||||
|
||||
$ip = UserIp::get();
|
||||
$fulllogin = $userinfo['login'] . "[{$userinfo['level']}]";
|
||||
Mail::send(
|
||||
$userinfo['mail'],
|
||||
<<<HTML
|
||||
<html lang="ru">
|
||||
<head><title>Второй пароль от персонажа $fulllogin.</title></head>
|
||||
<body>
|
||||
Вами, с IP адреса - $ip, был установлен второй пароль в игре Бойцовский Клуб.<br>
|
||||
Если это были не Вы, свяжитесь с администрацией сайта.<br><br>
|
||||
------------------------------------------------------------------<br>
|
||||
Ваш логин | {$userinfo['login']}<br>
|
||||
Второй пароль | ' . $pass2 . '<br>
|
||||
------------------------------------------------------------------<br>
|
||||
<br><br>Желаем Вам приятной игры.<br><br><i>Администрация</i>
|
||||
</body>
|
||||
HTML,
|
||||
"Второй пароль от персонажа $fulllogin"
|
||||
);
|
||||
}
|
||||
|
||||
public static function userRegistrationCodeByEmail(string $email, string $login)
|
||||
public static function userRegistrationCodeByEmail(string $email, string $login): void
|
||||
{
|
||||
$code = PassGen::intCode(4);
|
||||
Db::sql('insert into secure_code (email, code, time) values (?,?,unix_timestamp())', [$email, $code]);
|
||||
|
||||
@@ -113,7 +113,7 @@ class InfoBox
|
||||
|
||||
$lvar = $this->getInfoItemInfo($pl, $td);
|
||||
|
||||
if (isset($sn['items_img'][$tp_img[$pl['inOdet']]])) {
|
||||
if (isset($tp_img[$pl['inOdet']], $sn['items_img'][$tp_img[$pl['inOdet']]])) {
|
||||
$uimg = 'rimg/r' . $sn['items_img'][$tp_img[$pl['inOdet']]];
|
||||
} else {
|
||||
$uimg = 'i/items/' . $pl['img'];
|
||||
@@ -469,7 +469,7 @@ class InfoBox
|
||||
if ($u['banned'] > 0) {
|
||||
$pb .= '<div style="margin:0 2px 0 2px; color: red; background-color: #fae0e0;"><strong>Персонаж заблокирован</strong></div>';
|
||||
}
|
||||
if ($u['allLock'] > time()) {
|
||||
if (isset($u['allLock']) && $u['allLock'] > time()) {
|
||||
$pb .= '<div style="margin:0 2px 0 2px; color: red; background-color: #fae0e0;"><strong>Временный запрет передач!</strong></div>';
|
||||
}
|
||||
|
||||
|
||||
@@ -211,4 +211,9 @@ class ItemsModel
|
||||
}
|
||||
return $rt;
|
||||
}
|
||||
|
||||
public static function addIznos(int $itemId): void
|
||||
{
|
||||
Db::sql('update items_users set iznosNOW = iznosNOW + 1 where id = ?', [$itemId]);
|
||||
}
|
||||
}
|
||||
@@ -57,28 +57,5 @@ class Password
|
||||
}
|
||||
return $this->info['pass'];
|
||||
}
|
||||
|
||||
public function changeSecond(?int $passLength): array
|
||||
{
|
||||
if (in_array($passLength, [4, 6, 8])) {
|
||||
$query = 'update users set pass2 = ? where id = ?';
|
||||
$pass2 = PassGen::intCode($passLength);
|
||||
$args = [
|
||||
password_hash($pass2, PASSWORD_DEFAULT),
|
||||
$this->info['id'],
|
||||
];
|
||||
Confirmation::byEmail($this->info, 'pass2', $pass2);
|
||||
$hash = $args[0];
|
||||
} else {
|
||||
$query = 'update users set pass2 = default where id = ?';
|
||||
$args = [$this->info['id']];
|
||||
}
|
||||
|
||||
Db::sql($query, $args);
|
||||
return [
|
||||
'pass2' => $pass2 ?? '',
|
||||
'hash' => $hash ?? null,
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,12 +57,6 @@ class Register
|
||||
'effects' => [8, 20, 25, 37, 38, 283, 296, 412, 472],
|
||||
],
|
||||
];
|
||||
private array $restrictedLogins = [
|
||||
'ангел', 'angel', 'администрация', 'administration', 'Комментатор',
|
||||
'Мироздатель', 'Мусорщик', 'Падальщик', 'Повелитель',
|
||||
'Архивариус', 'Пересмешник', 'Волынщик', 'Лорд Разрушитель',
|
||||
'Милосердие', 'Справедливость', 'Искушение', 'Вознесение',
|
||||
];
|
||||
|
||||
public function hasGoodEmail(string $email): bool
|
||||
{
|
||||
@@ -141,40 +135,30 @@ class Register
|
||||
|
||||
public function hasGoodLogin(string $login): bool
|
||||
{
|
||||
$isRestricted = in_array($login, $this->restrictedLogins);
|
||||
$isRegistered = Db::getValue('select count(*) from users where login = ?', [$login]);
|
||||
//Бывшие в употреблении логины. Дичь, но ладно.
|
||||
$wasRegistered = Db::getValue('select count(*) from lastnames where login = ?', [$login]);
|
||||
$login = str_replace(' ', ' ', $login);
|
||||
if (mb_strlen($login) > 20) {
|
||||
$this->error = 'Логин должен содержать не более 20 символов.';
|
||||
}
|
||||
if (mb_strlen($login) < 4) {
|
||||
$this->error = 'Логин должен содержать не менее 4 символов.';
|
||||
}
|
||||
if ($this->hasMixedLatCur($login)) {
|
||||
$this->error = 'В логине разрешено использовать только буквы одного алфавита русского или английского. Нельзя смешивать.';
|
||||
}
|
||||
if (substr_count($login, ' ') + substr_count($login, '-') + substr_count($login, '_') > 2) {
|
||||
$this->error = 'Не более двух разделителей одновременно (пробел, тире, нижнее подчеркивание).';
|
||||
}
|
||||
if (!empty($this->error)) {
|
||||
$validator = (new \Validator\Login())->setLogin($login);
|
||||
if (!$validator->check()) {
|
||||
$this->error = match ($validator->getErrorCode()) {
|
||||
1 => 'Логин ' . $login . ' уже занят, выберите другой.',
|
||||
2 => 'В логине разрешено использовать только буквы одного алфавита русского или английского. Нельзя смешивать.',
|
||||
3 => 'Логин должен содержать не менее ' . $validator::LENGTH['min'] . ' символов.',
|
||||
4 => 'Логин должен содержать не более ' . $validator::LENGTH['max'] . ' символов.',
|
||||
5 => 'Не более двух разделителей одновременно (пробел, тире, нижнее подчеркивание).',
|
||||
6 => 'В логине используются запрещённые символы.',
|
||||
};
|
||||
$this->error .= '<br>Пример правильного никнейма: Петя Убиватор, Коля, xalop.<br>Пример неправильного никнейма: )))), kolя)=-/.';
|
||||
}
|
||||
if ($isRegistered || $wasRegistered || $isRestricted) {
|
||||
$this->error = 'Логин ' . $login . ' уже занят, выберите другой.';
|
||||
} else {
|
||||
$login = $validator->get();
|
||||
$isRegistered = Db::getValue('select count(*) from users where login = ?', [$login]);
|
||||
//Бывшие в употреблении логины. Дичь, но ладно.
|
||||
$wasRegistered = Db::getValue('select count(*) from lastnames where login = ?', [$login]);
|
||||
if ($isRegistered || $wasRegistered) {
|
||||
$this->error = 'Логин ' . $login . ' уже занят, выберите другой.';
|
||||
}
|
||||
}
|
||||
|
||||
return !$this->error;
|
||||
}
|
||||
|
||||
public function hasMixedLatCur(string $txt): bool
|
||||
{
|
||||
$en = preg_match("/^(([0-9A-z -])+)$/iu", $txt);
|
||||
$ru = preg_match("/^([а-яёіїє\s\d]*)$/iu", $txt);
|
||||
return ($ru && $en) || (!$ru && !$en);
|
||||
}
|
||||
|
||||
private function setCookies($login): void
|
||||
{
|
||||
setcookie('login', 1, 1, '/', Config::get('host'), true);
|
||||
|
||||
@@ -124,6 +124,54 @@ class Stats
|
||||
];
|
||||
}
|
||||
|
||||
public static function saveBattleStats(array $stats, int $id): void
|
||||
{
|
||||
if (!isset(
|
||||
$stats['hpnow'],
|
||||
$stats['mpNow'],
|
||||
$stats['tactic1'],
|
||||
$stats['tactic2'],
|
||||
$stats['tactic3'],
|
||||
$stats['tactic4'],
|
||||
$stats['tactic5'],
|
||||
$stats['tactic6'],
|
||||
$stats['tactic7'],
|
||||
$stats['enemy'],
|
||||
$stats['battle_yron'],
|
||||
$stats['battle_exp'],
|
||||
$stats['last_hp'],
|
||||
$stats['priems_z'],
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
Db::sql(
|
||||
'update stats set hpNow = ?,mpNow = ?,
|
||||
tactic1 = ?,tactic2 = ?,tactic3 = ?,tactic4 = ?,tactic5 = ?,tactic6 = ?,tactic7 = ?,
|
||||
enemy = ?,battle_yron = ?,last_hp = ?,battle_exp = ?,priems_z = ?
|
||||
where id = ?',
|
||||
[
|
||||
$stats['hpnow'],
|
||||
$stats['mpNow'],
|
||||
$stats['tactic1'],
|
||||
$stats['tactic2'],
|
||||
$stats['tactic3'],
|
||||
$stats['tactic4'],
|
||||
$stats['tactic5'],
|
||||
$stats['tactic6'],
|
||||
$stats['tactic7'],
|
||||
$stats['enemy'],
|
||||
$stats['battle_yron'],
|
||||
$stats['battle_exp'],
|
||||
$stats['last_hp'],
|
||||
$stats['priems_z'],
|
||||
$id,
|
||||
]
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
public function getStats(int|array|null $uid = null, $i1 = 0, $reimg = false, $btl_cache = false): array
|
||||
{
|
||||
$u = match (true) {
|
||||
@@ -205,6 +253,7 @@ class Stats
|
||||
$noeffectbattle = false;
|
||||
if ($u['battle'] > 0) {
|
||||
$noeffectbattle = (bool)Db::getValue("select 1 from battle_actions where uid = ? and vars = 'noeffectbattle1' and btl = ? limit 1", [$u['id'], $u['battle']]);
|
||||
$st['team'] = $u['team'];
|
||||
}
|
||||
|
||||
//Характеристики от эффектов
|
||||
@@ -293,9 +342,6 @@ class Stats
|
||||
$st['m19'] += (int)($st['s3'] * 0.03);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//Бонусы комплектов
|
||||
if (isset($coms['new']) && is_iterable($coms['new'])) {
|
||||
foreach ($coms['new'] as $complect) {
|
||||
@@ -477,8 +523,8 @@ class Stats
|
||||
|
||||
/** Собираем динамически создаваемые параметры. Если ключа нет - создаём.
|
||||
* @param string $key
|
||||
* @param int $value
|
||||
* @param array $st
|
||||
* @param int $value
|
||||
* @param array $st
|
||||
* @return void
|
||||
*/
|
||||
private function addKeyIfNotExist(string $key, int $value, array &$st): void
|
||||
@@ -493,7 +539,7 @@ class Stats
|
||||
/**
|
||||
* Добавляет бонусы к статам игрока.
|
||||
* Генерирует переменную User:class->stats['items'], где лежат одетые предметы.
|
||||
* @param int $uid
|
||||
* @param int $uid
|
||||
* @param array $st
|
||||
* @param array $s_v
|
||||
* @param array $baseStats
|
||||
@@ -1081,6 +1127,10 @@ class Stats
|
||||
0 as finished from rep where id = ?', [$id]
|
||||
);
|
||||
|
||||
if (empty($finishedDungeons)) {
|
||||
return;
|
||||
}
|
||||
|
||||
//Бонус за количество полностью вырытых пещер.
|
||||
if (isset($st['m10'])) {
|
||||
$st['m10'] += 10 * $finishedDungeons;
|
||||
@@ -1133,52 +1183,4 @@ class Stats
|
||||
}
|
||||
unset($st['level'], $st['hpnow'], $st['mpnow'], $st['hpall'], $st['mpall']);
|
||||
}
|
||||
|
||||
public static function saveBattleStats(array $stats, int $id): void
|
||||
{
|
||||
if (!isset(
|
||||
$stats['hpnow'],
|
||||
$stats['mpNow'],
|
||||
$stats['tactic1'],
|
||||
$stats['tactic2'],
|
||||
$stats['tactic3'],
|
||||
$stats['tactic4'],
|
||||
$stats['tactic5'],
|
||||
$stats['tactic6'],
|
||||
$stats['tactic7'],
|
||||
$stats['enemy'],
|
||||
$stats['battle_yron'],
|
||||
$stats['battle_exp'],
|
||||
$stats['last_hp'],
|
||||
$stats['priems_z'],
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
Db::sql(
|
||||
'update stats set hpNow = ?,mpNow = ?,
|
||||
tactic1 = ?,tactic2 = ?,tactic3 = ?,tactic4 = ?,tactic5 = ?,tactic6 = ?,tactic7 = ?,
|
||||
enemy = ?,battle_yron = ?,last_hp = ?,battle_exp = ?,priems_z = ?
|
||||
where id = ?',
|
||||
[
|
||||
$stats['hpnow'],
|
||||
$stats['mpNow'],
|
||||
$stats['tactic1'],
|
||||
$stats['tactic2'],
|
||||
$stats['tactic3'],
|
||||
$stats['tactic4'],
|
||||
$stats['tactic5'],
|
||||
$stats['tactic6'],
|
||||
$stats['tactic7'],
|
||||
$stats['enemy'],
|
||||
$stats['battle_yron'],
|
||||
$stats['battle_exp'],
|
||||
$stats['last_hp'],
|
||||
$stats['priems_z'],
|
||||
$id,
|
||||
]
|
||||
);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
<?php
|
||||
|
||||
namespace Validator;
|
||||
|
||||
class Login
|
||||
{
|
||||
private const RESTRICTED = [
|
||||
'ангел', 'angel', 'администрация', 'administration', 'Комментатор',
|
||||
'Мироздатель', 'Мусорщик', 'Падальщик', 'Повелитель',
|
||||
'Архивариус', 'Пересмешник', 'Волынщик', 'Лорд Разрушитель',
|
||||
'Милосердие', 'Справедливость', 'Искушение', 'Вознесение',
|
||||
];
|
||||
public const LENGTH = ['min' => 4, 'max' => 16];
|
||||
protected readonly string $login;
|
||||
private int $errorcode = 0;
|
||||
|
||||
public function getErrorCode(): int
|
||||
{
|
||||
return $this->errorcode;
|
||||
}
|
||||
|
||||
public function setLogin(string $login): self
|
||||
{
|
||||
$login = preg_replace('!\s+!', ' ', $login); // remove inner spaces
|
||||
$login = trim($login); // remove outer spaces
|
||||
$this->login = $login;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function get(): string
|
||||
{
|
||||
return $this->check() ? $this->login : '';
|
||||
}
|
||||
|
||||
public function check(): bool
|
||||
{
|
||||
if (!$this->isAllowed()) {
|
||||
$this->errorcode = 1;
|
||||
} elseif ($this->isMixed()) {
|
||||
$this->errorcode = 2;
|
||||
} elseif (mb_strlen($this->login) < self::LENGTH['min']) {
|
||||
$this->errorcode = 3;
|
||||
} elseif (mb_strlen($this->login) > self::LENGTH['max']) {
|
||||
$this->errorcode = 4;
|
||||
} elseif (substr_count($this->login, ' ') + substr_count($this->login, '-') + substr_count($this->login, '_') > 2) {
|
||||
$this->errorcode = 5;
|
||||
} elseif (strpos("!@#$%^&*()\+|/'\"", $this->login) || empty($this->login)) {
|
||||
$this->errorcode = 6;
|
||||
}
|
||||
|
||||
return $this->errorcode === 0;
|
||||
}
|
||||
|
||||
private function isAllowed(): bool
|
||||
{
|
||||
$d = implode('|', self::RESTRICTED);
|
||||
$pattern = "/\b($d)\b/iu";
|
||||
return !preg_match($pattern, $this->login);
|
||||
}
|
||||
|
||||
private function isMixed(): bool
|
||||
{
|
||||
$en = preg_match("/^(([0-9A-z -])+)$/iu", $this->login);
|
||||
$ru = preg_match("/^([а-яёіїє\s\d]*)$/iu", $this->login);
|
||||
return ($ru && $en) || (!$ru && !$en);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user