diff --git a/_incl_data/autoload.php b/_incl_data/autoload.php index 4c68d220..d5f54a2b 100644 --- a/_incl_data/autoload.php +++ b/_incl_data/autoload.php @@ -1,4 +1,5 @@ false, + 'progress' => [ + 'current' => 0, + 'need' => 1, + ] + ]; + } } \ No newline at end of file diff --git a/_incl_data/class/DarksLight2/Training/Steps/FirstStep.php b/_incl_data/class/DarksLight2/Training/Steps/ChatFirstQuest.php similarity index 55% rename from _incl_data/class/DarksLight2/Training/Steps/FirstStep.php rename to _incl_data/class/DarksLight2/Training/Steps/ChatFirstQuest.php index 4e93b75e..9c4f5f8d 100644 --- a/_incl_data/class/DarksLight2/Training/Steps/FirstStep.php +++ b/_incl_data/class/DarksLight2/Training/Steps/ChatFirstQuest.php @@ -4,17 +4,17 @@ namespace DarksLight2\Training\Steps; use DarksLight2\Training\StepFactory; -class FirstStep extends StepFactory +class ChatFirstQuest extends StepFactory { public function getTitle(): string { - return 'Первое знакомство'; + return 'Начало.'; } public function getMessage(): string { - return 'test'; + return 'Отправьте сообщение в общий чат.'; } public function getRewards(): array @@ -24,7 +24,11 @@ class FirstStep extends StepFactory public function getShortName(): string { - return 'first_step'; + return 'chat_first_quest'; } + public function isInfo(): bool + { + return false; + } } \ No newline at end of file diff --git a/_incl_data/class/DarksLight2/Training/Steps/ChatFirstStep.php b/_incl_data/class/DarksLight2/Training/Steps/ChatFirstStep.php new file mode 100644 index 00000000..debe5c5e --- /dev/null +++ b/_incl_data/class/DarksLight2/Training/Steps/ChatFirstStep.php @@ -0,0 +1,30 @@ + + Все игроки имеют свободные очки распределения параметров, что они дают игрокам конкретные модификаторы в зависимости от того, в какой из параметров распределяются очки распределения.
+ --- если можно, добавить скрин как выглядит эта кнопка --- + Сила - Увеличивает мощность рубящего урона ( для Силачей )
+ Ловкость - Увеличивает мощность колющего урона ( для Критоуворотов и Уворотов )
+ Интуиция - Увеличивает мощность режущего урона ( для Критовиков )
+ Выносливость - Увеличивает защиту от урона и магии, а так же добавит немного жизней. ( для Танков )
+ Интелект - Увеличивает мощность магии. ( Для Любого Мага )
+ Мудрость - Увеличивает колличество маны. ( Для Любого Мага )
+
+ Дополнительно, игроки имеют очки распределения Мастерства Оружия, это позволит воинам увеличить урон, а магам, открыть новые приемы.
+ Очки распределения Оружий распределяются точно так же, как и очки распределения параметров ( статов ).
+
+ В случае, если вы распределили неверно любые доступные очки распределения, или хотите их изменить, вы можете это сделать, поднявшись на 2 этаж здания " Бойцовский Клуб ".'; + } + + public function getShortName(): string + { + return 'my_user_fourth_step'; + } + + public function getRewards(): array + { + return []; + } + + public function getAnswer(): string + { + return ''; + } + +} \ No newline at end of file diff --git a/_incl_data/class/DarksLight2/Training/Steps/MyUserSecondQuest.php b/_incl_data/class/DarksLight2/Training/Steps/MyUserSecondQuest.php new file mode 100644 index 00000000..7e23fbd3 --- /dev/null +++ b/_incl_data/class/DarksLight2/Training/Steps/MyUserSecondQuest.php @@ -0,0 +1,35 @@ + + Текущий уровень - Отображает ваш текущий уровень персонажа.
+ Победы - Отображает сумму всех ваших побед, в любых поединках.
+ Поражения - Отображает сумму всех ваших поражений, в любых поединках.
+ Ничьих - Отображает сумму всех поединков, которые завершились в ничью.
+ Кредиты - Обычная игровая валюта - кредиты ( креды ), которые можно потратить в обычном магазине.
+ Еврокредиты - Покупная игровая валюта - еврокредиты ( екры ) , которые можно потратить в магазине " Берёзка ".
+ Воинственность - Дополнительная игровая валюта, потратить её можно в Подпольной Лавке.
+ Ежедневное задание - Отображает текущее ежедневное задание либо предоставляет возможность его взятия.
+ Бонус - Позволяет получить немного кредитов или еврокредитов.'; + } + + public function getShortName(): string + { + return 'my_user_second_step'; + } + + public function getRewards(): array + { + return []; + } + +} \ No newline at end of file diff --git a/_incl_data/class/DarksLight2/Training/Steps/MyUserThirdQuest.php b/_incl_data/class/DarksLight2/Training/Steps/MyUserThirdQuest.php new file mode 100644 index 00000000..7c78455b --- /dev/null +++ b/_incl_data/class/DarksLight2/Training/Steps/MyUserThirdQuest.php @@ -0,0 +1,40 @@ + + Критовик - Убивает Танков и Магов, основное оружие - Мечи
+ Уворот - Убивает Критовиков и Силачей, основное оружие - Кинжалы
+ Танк - Убивает Уворотов и Силачей, основное оружие - Дубина и щит.
+ Силач - Убивает Критовиков и Магов, основное оружие - Топоры
+ Критоуворот - Убивает Силачей и с небольшим шансом Критовиков и Уворотов, основное оружие - Кинжалы.
+
+ Маг Огня - Атакующий маг, убивает Уворотов и Танков.
+ Маг Воздуха - Атакующий маг, убивает Уворотов и Танков.
+ Маг Земли - Защищающийся маг, слабый урон, хорошая защита.
+ Маг Воды - Защищающийся маг, слабый урон, хорошая защита.'; + } + + public function getShortName(): string + { + return 'my_user_third_step'; + } + + public function getRewards(): array + { + return []; + } + + public function allowedToMove(): array + { + return ['cp1']; + } + +} \ No newline at end of file diff --git a/_incl_data/class/DarksLight2/Training/TrainingManager.php b/_incl_data/class/DarksLight2/Training/TrainingManager.php index 7e892719..1cb3060a 100644 --- a/_incl_data/class/DarksLight2/Training/TrainingManager.php +++ b/_incl_data/class/DarksLight2/Training/TrainingManager.php @@ -3,24 +3,125 @@ namespace DarksLight2\Training; use Core\Db; +use DarksLight2\Training\Steps\ChatFirstStep; +use DarksLight2\Training\Steps\MyUserFirstQuest; +use DarksLight2\Training\Steps\MyUserFirstStep; +use DarksLight2\Training\Steps\MyUserFourthQuest; +use DarksLight2\Training\Steps\MyUserFourthStep; +use DarksLight2\Training\Steps\MyUserSecondQuest; +use DarksLight2\Training\Steps\MyUserSecondStep; +use DarksLight2\Training\Steps\MyUserThirdQuest; +use DarksLight2\Training\Steps\MyUserThirdStep; use DarksLight2\Traits\Singleton; -use PDO; -use stdClass; +use PassGen; +use User; class TrainingManager { - use Singleton; - - private $database_records = false; - private array $steps_data; private int $user_id; - private array $steps; + public string $current_step = ''; + private array $registered_steps; + private array $completed_steps; + private array $active_steps; - public function __construct(int $user_id) + private $database; + + public function __construct(int $user_id, $refresh_token = true) { + try { + $this->register([ + new ChatFirstStep(), + new MyUserFirstStep(), + new MyUserFirstQuest(), + new MyUserSecondStep(), + new MyUserSecondQuest(), + new MyUserThirdStep(), + new MyUserThirdQuest(), + new MyUserFourthStep(), + new MyUserFourthQuest(), + ]); + } catch (TrainingException $e) { + } + $this->user_id = $user_id; + if($refresh_token) { + $this->generateToken(); + } + + $this->database = Db::getRow('SELECT * FROM user_training WHERE user_id = ?', [$user_id]); + + $this->createDatabaseRecord(); + + $this->database['data'] = json_decode($this->database['data'], true); + + $this->selectActiveSteps(); + } + + public function getCurrentStepName(): string + { + if(empty($this->current_step)) { + $this->current_step = array_key_first($this->active_steps) ?? ''; + } + + return $this->current_step; + } + public function getRegistered(): array + { + return $this->registered_steps; + } + + public function getDatabaseData() + { + return $this->database; + } + + public function addPoint($short_name, $closure = null) + { + if($short_name === $this->getCurrentStepName()) { + $this->database['data'][$short_name]['progress']['current']++; + if(isset($closure)) { + $closure($this); + } + } + } + + public function nextStep() + { + + if($this->database['data'][$this->getCurrentStepName()]['progress']['need'] <= $this->database['data'][$this->getCurrentStepName()]['progress']['current']) { + $this->database['data'][$this->getCurrentStepName()]['progress']['current'] = 0; + $this->database['data'][$this->getCurrentStepName()]['completed'] = true; + unset($this->active_steps[$this->getCurrentStepName()]); + $this->current_step = array_key_first($this->active_steps) ?? ''; + $this->database['current'] = $this->getCurrentStepName(); + } + } + + public function previousStep() + { + $this->current_step = end($this->completed_steps) ?? ''; + $this->database['current'] = $this->current_step; + $this->database['data'][$this->getCurrentStepName()]['completed'] = false; + } + + public function selectActiveSteps() + { + foreach ($this->database['data'] as $step_name => $data) { + if($data['completed'] === false) { + $this->active_steps[$step_name] = $data; + continue; + } + + $this->completed_steps[] = $step_name; + + } + } + + public function store() + { + Db::sql('UPDATE user_training SET data = ?, current = ? WHERE user_id = ?', [json_encode($this->database['data']), $this->database['current'], $this->user_id]); } /** @@ -37,104 +138,55 @@ class TrainingManager foreach ($steps as $step) { if($step instanceof StepFactory) { - $this->steps[$step->getShortName()] = new class ( - $step->getMessage(), - $step->getTitle(), - $step->getRewards(), - $this->stepData($step->getShortName())->complete, - $step->getShortName(), - $this->stepData($step->getShortName())->progress - ) { - public string $message; - public string $title; - public string $short_name; - public array $rewards; - public bool $isComplete; - - public stdClass $progress; - - public function __construct( - string $message, - string $title, - array $rewards, - bool $isComplete, - string $short_name, - stdClass $progress - ) { - $this->rewards = $rewards; - $this->title = $title; - $this->isComplete = $isComplete; - $this->message = $message; - $this->short_name = $short_name; - $this->progress = $progress; - } - - public function render() - { - $path = $_SERVER['DOCUMENT_ROOT'] . '/modules_data/steps/' . $this->short_name . '.php'; - - if(file_exists($path)) { - require $path; - return; - } - - throw TrainingException::noRenderingFile(); - } - }; + $this->registered_steps[$step->getShortName()] = $step; } } } - - private function stepData(string $short_name): object + private function generateToken($length = 16) { - return json_decode($this->getDatabaseRecords()->data)->$short_name; - } - private function getDatabaseRecords() - { - if(!$this->database_records) { - $this->database_records = Db::run('SELECT * FROM user_training WHERE user_id = ?', [$this->user_id]) - ->fetch(PDO::FETCH_OBJ); - } - - return $this->database_records; + Db::run('UPDATE user_training SET api_token = ? WHERE user_id = ?', [ + PassGen::new($length), + $this->user_id + ]); } public function createDatabaseRecord() { - if(!$this->getDatabaseRecords()) { - Db::run('INSERT INTO user_training (user_id, data) VALUES (?, ?)', [ + if(!$this->database) { + + $data = []; + + foreach ($this->registered_steps as $step) { + $data[$step->getShortName()] = $step->databaseRecord(); + } + + Db::sql('INSERT INTO user_training (user_id, data, current) VALUES (?, ?, ?)', [ $this->user_id, - json_encode($this->firstRecordData()) + json_encode($data, true), + array_key_first($data) ]); + + $this->database = Db::getRow('SELECT * FROM user_training WHERE user_id = ?', [$this->user_id]); } } - private function firstRecordData(): array + /** + * @throws \DarksLight2\Training\TrainingException + */ + public function render() { - return [ - 'first_step' => [ - 'complete' => 0, - 'progress' => [ - 'current' => 0, - 'need' => 0, - ] - ] - ]; - } + if(in_array(User::start()->room['file'], $this->registered_steps[$this->getCurrentStepName()]->onLocations()) || in_array('all', $this->registered_steps[$this->getCurrentStepName()]->onLocations())) { + $path = $_SERVER['DOCUMENT_ROOT'] . '/modules_data/steps/step.php'; - public function __get(string $name) - { - return $this->steps[$name]; - } - - public function addPoint(string $short_name) - { - $this->$short_name->progress++; - } - - public function store() - { + if (file_exists($path)) { + $short_name = $this->getCurrentStepName(); + $answer = $this->registered_steps[$this->getCurrentStepName()]->getAnswer(); + require $path; + return; + } + throw TrainingException::noRenderingFile(); + } } } \ No newline at end of file diff --git a/_incl_data/class/Priems.php b/_incl_data/class/Priems.php index 7af8851b..dfac9620 100644 --- a/_incl_data/class/Priems.php +++ b/_incl_data/class/Priems.php @@ -1,6 +1,7 @@ u->info['id'] . '" LIMIT 1' ); if ($upd) { + TrainingManager::getInstance() + ->addPoint('my_user_fourth_quest', function (TrainingManager $manager) { + $manager->store(); + }); $this->u->info['priems'] = $p; } } else { diff --git a/api/.htaccess b/api/.htaccess new file mode 100644 index 00000000..6705c6ff --- /dev/null +++ b/api/.htaccess @@ -0,0 +1,5 @@ + + RewriteEngine On + RewriteRule ^training/complete/?$ index.php?get=complete [L] + RewriteRule ^training/go_back/?$ index.php?get=go_back [L] + \ No newline at end of file diff --git a/api/index.php b/api/index.php new file mode 100644 index 00000000..408a93a0 --- /dev/null +++ b/api/index.php @@ -0,0 +1,70 @@ +info)) { + + $training = TrainingManager::getInstance($user->info['id'], false); + + try { + $training->createDatabaseRecord(); + $training->register([ + new MyUserFirstQuest(), + new ChatFirstStep() + ]); + } catch (TrainingException $e) { + } + + if (!isset($data->token) || !password_verify( + $training->getDatabaseData()['api_token'] . $data->time . $user->info['id'], + $data->token + )) { + http_response_code(401); + die; + } + + if (isset($_GET['get'])) { + switch ($_GET['get']) { + default: + http_response_code(400); + die; + case 'complete': + if ($training->getDatabaseData()['data'][$training->getCurrentStepName()]['completed']) { + http_response_code(400); + die; + } + + if($training->getRegistered()[$data->short_name]->isInfo()) { + + $training->addPoint($training->getCurrentStepName()); + } + + $training->nextStep(); + + $training->store(); + + die(json_encode(['status' => 'ok'])); + + case 'go_back': + $training->previousStep(); + $training->store(); + die(json_encode(['status' => 'ok', 'message' => 'Вы указали не верный ответ!'])); + + } + } +} \ No newline at end of file diff --git a/css/training/modal.css b/css/training/modal.css new file mode 100644 index 00000000..09fda884 --- /dev/null +++ b/css/training/modal.css @@ -0,0 +1,94 @@ +.modal__backdrop { + position: fixed; + top: 0; + right: 0; + bottom: 0; + left: 0; + /*background: rgba(0, 0, 0, 0.5);*/ + opacity: 0; + z-index: -1; + pointer-events: none; + transition: opacity0 .2s ease-in; +} + +.modal__content { + position: relative; + width: auto; + margin: 10px; + transition: opacity 0.3s ease-in; + display: flex; + flex-direction: column; + background-color: #fff; + background-clip: padding-box; + border: 1px solid rgba(0, 0, 0, 0.2); + border-radius: 0.3rem; + box-shadow: 0 0 7px 0 rgba(0, 0, 0, 0.3); +} + +@media (min-width: 576px) { + .modal__content { + max-width: 500px; + margin: 50px auto; + } +} + +.modal__show .modal__backdrop, +.modal__show .modal__content { + opacity: 1; + z-index: 1050; + pointer-events: auto; + overflow-y: auto; +} + +.modal__header { + display: flex; + align-items: center; + justify-content: space-between; + padding: 15px; + border-bottom: 1px solid #eceeef; +} + +.modal__title { + margin-top: 0; + margin-bottom: 0; + line-height: 1.5; + font-size: 1.25rem; + font-weight: 500; +} + +.modal__btn-close { + float: right; + font-family: sans-serif; + font-size: 24px; + font-weight: 700; + line-height: 1; + color: #000; + text-shadow: 0 1px 0 #fff; + opacity: 0.5; + text-decoration: none; +} + +.modal__btn-close:focus, +.modal__btn-close:hover { + color: #000; + text-decoration: none; + cursor: pointer; + opacity: 0.75; +} + +.modal__body { + position: relative; + flex: 1 1 auto; + padding: 15px; + overflow: auto; +} + +.modal__footer { + display: flex; + align-items: center; + justify-content: flex-end; + padding: 1rem; + border-top: 1px solid #e9ecef; + border-bottom-right-radius: 0.3rem; + border-bottom-left-radius: 0.3rem; +} \ No newline at end of file diff --git a/js/training/index.js b/js/training/index.js new file mode 100644 index 00000000..e69de29b diff --git a/js/training/modal.js b/js/training/modal.js new file mode 100644 index 00000000..11c3ea62 --- /dev/null +++ b/js/training/modal.js @@ -0,0 +1,164 @@ +const request = new XMLHttpRequest(); + +const training_handler = () => { + + const url = (condition) => { + return condition ? '/api/training/complete' : '/api/training/go_back'; + }; + + request.open('POST', url(training_data().answer === null || training_data().answer === get_user_answer())) + request.setRequestHeader("Content-Type", "application/json;charset=UTF-8"); + request.onreadystatechange = function () {//Call a function when the state changes. + if (request.readyState === 4) { + if(request.status === 200) { + parent.frames['main'].location.reload(); + } + + if(request.responseText !== '') { + let response = JSON.parse(request.responseText); + + if (response.message !== undefined) { + alert(response.message); + } + } + } + } + + request.send(JSON.stringify({ + time: training_data().time, + token: training_data().token, + short_name: training_data().short_name, + answer: get_user_answer(), + })) +} + +function get_user_answer() { + if(training_data().answer === '') { + return ''; + } + + return document.getElementsByName('user_answer')[0].value; +} + +(function () { + if (typeof window.CustomEvent === "function") return false; + function CustomEvent(event, params) { + params = params || { bubbles: false, cancelable: false, detail: null }; + var evt = document.createEvent('CustomEvent'); + evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail); + return evt; + } + window.CustomEvent = CustomEvent; +})(); + +$modal = function (options) { + var + _elemModal, + _eventShowModal, + _eventHideModal, + _hiding = false, + _destroyed = false, + _animationSpeed = 200; + + function _createModal(options) { + var + elemModal = document.createElement('div'), + modalTemplate = '', + modalFooterTemplate = '', + modalInputAnswer = '', + modalButtonTemplate = '', + modalHTML, + modal_content, + modalFooterHTML = ''; + + if(training_data().answer !== '') { + modalInputAnswer = '

'; + } + + elemModal.classList.add('modal'); + modalHTML = modalTemplate.replace('{{title}}', options.title || 'Новое окно'); + + if (options.footerButtons) { + for (var i = 0, length = options.footerButtons.length; i < length; i++) { + var modalFooterButton = modalButtonTemplate.replace('{{button_class}}', options.footerButtons[i].class); + modalFooterButton = modalFooterButton.replace('{{button_handler}}', options.footerButtons[i].handler); + modalFooterButton = modalFooterButton.replace('{{button_text}}', options.footerButtons[i].text) + modalInputAnswer; + modalFooterHTML += modalFooterButton; + } + modalFooterHTML = modalFooterTemplate.replace('{{buttons}}', modalFooterHTML); + } + modalHTML = modalHTML.replace('{{footer}}', modalFooterHTML); + elemModal.innerHTML = modalHTML; + document.body.appendChild(elemModal); + + modal_content = document.getElementById('modal_content') + modal_content.innerHTML = options.content + + return elemModal; + } + + function _showModal() { + if (!_destroyed && !_hiding) { + _elemModal.classList.add('modal__show'); + document.dispatchEvent(_eventShowModal); + } + } + + function _hideModal() { + _hiding = true; + _elemModal.classList.remove('modal__show'); + _elemModal.classList.add('modal__hiding'); + setTimeout(function () { + _elemModal.classList.remove('modal__hiding'); + _hiding = false; + }, _animationSpeed); + document.dispatchEvent(_eventHideModal); + } + + function _handlerCloseModal(e) { + if (e.target.dataset.dismiss === 'modal') { + _hideModal(); + } + } + + _elemModal = _createModal(options || {}); + + + _elemModal.addEventListener('click', _handlerCloseModal); + _eventShowModal = new CustomEvent('show.modal', { detail: _elemModal }); + _eventHideModal = new CustomEvent('hide.modal', { detail: _elemModal }); + + return { + show: _showModal, + hide: _hideModal, + destroy: function () { + _elemModal.parentElement.removeChild(_elemModal), + _elemModal.removeEventListener('click', _handlerCloseModal), + _destroyed = true; + }, + setContent: function (html) { + _elemModal.querySelector('[data-modal="content"]').innerHTML = html; + }, + setTitle: function (text) { + _elemModal.querySelector('[data-modal="title"]').innerHTML = text; + } + } +}; + +let modal = $modal({ + title: training_data().title, + content: training_data().content, + footerButtons: [ + { + class: 'btn btn__ok', + text: 'Продолжить', + handler: 'next_step' + } + ] +}); + +document.addEventListener('click', function (e) { + if (e.target.dataset.handler === 'next_step') { + training_handler() + } +}) \ No newline at end of file diff --git a/main.php b/main.php index bbed52f0..b80dd6bb 100644 --- a/main.php +++ b/main.php @@ -25,14 +25,18 @@ +
info['id']); + /** Восстанавливаем всем ботам, которые не в бою здоровье до максимума. */ Db::exec( 'update stats set hpNow = hpAll, mpNow = mpAll @@ -555,6 +561,7 @@ $spl = $spl['exp']; echo ' '; +$training_manager->render(); ?> '; + $u->info['room'] = $go['id']; + $u->room = $go; + if (!isset($_GET['mAjax'])) { + echo ''; + } + } else { + $re = 'Вы не смогли перейти в локацию, возможно она была разрушена'; } } else { - $re = 'Вы не смогли перейти в локацию, возможно она была разрушена'; + $re = 'Вы не смогли перейти в локацию'; } + } elseif ($go['destroy'] == 1) { + $re = 'Здание было разрушено, в данный момент оно реставрируется'; } else { - $re = 'Вы не смогли перейти в локацию'; + $re = 'Временно закрыто'; } - } elseif ($go['destroy'] == 1) { - $re = 'Здание было разрушено, в данный момент оно реставрируется'; } else { - $re = 'Временно закрыто'; + $re = 'Проход не существует'; } } else { $re = 'Проход не существует'; } } else { - $re = 'Проход не существует'; + $re = 'Вам запрещено передвигаться до окончания обучения!!!'; } } diff --git a/modules_data/_umenie.php b/modules_data/_umenie.php index ea1bba4f..9b0e1fce 100644 --- a/modules_data/_umenie.php +++ b/modules_data/_umenie.php @@ -1,4 +1,7 @@ info['id'] . "';" )) { + if((int)$u->info['ability'] === 0 && (int)$u->info['skills'] === 0) { + TrainingManager::getInstance() + ->addPoint( + 'my_user_third_quest', + function (TrainingManager $manager) { + $manager->store(); + } + ); + } + //if($_GET['energy']>0) {echo '   Увеличение способности "Энергия" произведено удачно
';} if ($_GET['str'] > 0) { echo '   Увеличение способности "Сила" произведено удачно
'; diff --git a/modules_data/location/cp1.php b/modules_data/location/cp1.php index d0d95eed..272c8222 100644 --- a/modules_data/location/cp1.php +++ b/modules_data/location/cp1.php @@ -1,13 +1,12 @@ room['file']=='cp1') -{ +if($u->room['file']=='cp1') { + if(date("H")>=8 && date("H")<=23) { $now = 'day'; $tattack = 'Напасть на игрока   '; diff --git a/modules_data/steps/first_step.php b/modules_data/steps/first_step.php deleted file mode 100644 index 2bae859e..00000000 --- a/modules_data/steps/first_step.php +++ /dev/null @@ -1,11 +0,0 @@ -$short_name->progress); - -echo 'it\'s work'; diff --git a/modules_data/steps/step.php b/modules_data/steps/step.php new file mode 100644 index 00000000..d0e3d7e6 --- /dev/null +++ b/modules_data/steps/step.php @@ -0,0 +1,38 @@ +getRegistered()[$short_name]; + +$time = time(); + +$token = password_hash($manager->getDatabaseData()['api_token'] . $time . $user->info['id'], PASSWORD_DEFAULT); +?> + + + + + diff --git a/online.php b/online.php index cf050dbf..a26ac39c 100644 --- a/online.php +++ b/online.php @@ -7,6 +7,7 @@ if (!defined('GAME_VERSION')) { use Core\Config; use Core\Database; use Core\Db; +use DarksLight2\Training\TrainingManager; Config::init(); @@ -265,6 +266,18 @@ if (isset($_POST['msg']) && str_replace(' ', '', $_POST['msg']) != '') { mysql_query("UPDATE `chat` SET `delete` = 1 WHERE `login` = '" . $u->info['login'] . "' LIMIT 1000"); $_POST['msg'] = 'Я спамер ' . $u->info['login'] . ' и меня нужно заблокировать https://new-combats.com/info/' . $u->info['id'] . ''; + $training_manager = TrainingManager::getInstance(); + + $training_manager->addPoint('chat_first_quest'); + + if(preg_match("/to\[(.*?)\]/", $_POST['msg'])) { + $training_manager->addPoint('chat_second_quest'); + } + + if(preg_match("/private\[(.*?)\]/", $_POST['msg'])) { + $training_manager->addPoint('chat_third_quest'); + } + mysql_query( 'INSERT INTO `chat` (`nosee`,`invis`,`da`,`delete`,`molch`,`new`,`login`,`to`,`city`,`room`,`time`,`type`,`spam`,`text`,`toChat`,`color`,`typeTime`,`sound`,`global`) VALUES ( "0", diff --git a/test.php b/test.php deleted file mode 100644 index 63691622..00000000 --- a/test.php +++ /dev/null @@ -1,33 +0,0 @@ -info['id']); - -$manager->createDatabaseRecord(); - -try { - $manager->register([ - new FirstStep(), - ]); -} catch (TrainingException $e) { -} - -if(!$manager->first_step->complete) { - $manager->first_step->render(); -}