Compare commits
No commits in common. "5518b335a864931d89930be546340e8843aa260a" and "037d43857dd9d47222c2f8746eaa264ccc9c7c7d" have entirely different histories.
5518b335a8
...
037d43857d
@ -1,5 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
use DarksLight2\Training\Steps\FirstStep;
|
||||||
|
use DarksLight2\Training\TrainingException;
|
||||||
|
use DarksLight2\Training\TrainingManager;
|
||||||
|
|
||||||
const GAME = true; // Для совместимости с этой "защитой".
|
const GAME = true; // Для совместимости с этой "защитой".
|
||||||
const GAME_VERSION = 'alpha-7.4';
|
const GAME_VERSION = 'alpha-7.4';
|
||||||
// Новая автозагрузка.
|
// Новая автозагрузка.
|
||||||
@ -46,3 +50,16 @@ spl_autoload_register(function (string $classname) {
|
|||||||
|
|
||||||
require_once $file;
|
require_once $file;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Нужно перенести в другое местечко, но пока так
|
||||||
|
*/
|
||||||
|
try {
|
||||||
|
$training_manager = TrainingManager::getInstance(User::start()->info['id']);
|
||||||
|
$training_manager->createDatabaseRecord();
|
||||||
|
$training_manager->register([
|
||||||
|
new FirstStep(),
|
||||||
|
]);
|
||||||
|
} catch (TrainingException $e) {
|
||||||
|
}
|
@ -1,11 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace DarksLight2\Helpers;
|
|
||||||
|
|
||||||
class Str
|
|
||||||
{
|
|
||||||
public static function snakeCase($string): string
|
|
||||||
{
|
|
||||||
return strtolower(preg_replace(['/([a-z\d])([A-Z])/', '/([^_])([A-Z][a-z])/'], '$1_$2', $string));
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,47 +2,12 @@
|
|||||||
|
|
||||||
namespace DarksLight2\Training;
|
namespace DarksLight2\Training;
|
||||||
|
|
||||||
use DarksLight2\Helpers\Str;
|
|
||||||
use User;
|
|
||||||
|
|
||||||
abstract class StepFactory
|
abstract class StepFactory
|
||||||
{
|
{
|
||||||
|
|
||||||
abstract public function getTitle(): string;
|
abstract public function getTitle(): string;
|
||||||
abstract public function getMessage(): string;
|
abstract public function getMessage(): string;
|
||||||
|
abstract public function getShortName(): string;
|
||||||
abstract public function getRewards(): array;
|
abstract public function getRewards(): array;
|
||||||
public function onLocations(): array
|
|
||||||
{
|
|
||||||
return ['all'];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getShortName(): string
|
|
||||||
{
|
|
||||||
return Str::snakeCase(get_class($this));
|
|
||||||
}
|
|
||||||
public function getAnswer()
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function allowedToMove(): array
|
|
||||||
{
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function isInfo(): bool
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function databaseRecord()
|
|
||||||
{
|
|
||||||
return [
|
|
||||||
'completed' => false,
|
|
||||||
'progress' => [
|
|
||||||
'current' => 0,
|
|
||||||
'need' => 1,
|
|
||||||
]
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
@ -1,30 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace DarksLight2\Training\Steps;
|
|
||||||
|
|
||||||
use DarksLight2\Training\StepFactory;
|
|
||||||
|
|
||||||
class ChatFirstStep extends StepFactory
|
|
||||||
{
|
|
||||||
|
|
||||||
public function getTitle(): string
|
|
||||||
{
|
|
||||||
return 'Начало.';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getMessage(): string
|
|
||||||
{
|
|
||||||
return 'Помните, оскорблять, унижать, обсуждать политику, подстёгивать других игроков, как в общем чате так и в приватном приведет к временному ограничению возможности отправки сообщений в любой из чатов.';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getShortName(): string
|
|
||||||
{
|
|
||||||
return 'chat_first_step';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getRewards(): array
|
|
||||||
{
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace DarksLight2\Training\Steps;
|
|
||||||
|
|
||||||
use DarksLight2\Training\StepFactory;
|
|
||||||
|
|
||||||
class ChatSecondQuest extends StepFactory
|
|
||||||
{
|
|
||||||
|
|
||||||
public function getTitle(): string
|
|
||||||
{
|
|
||||||
return 'Начало.';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getMessage(): string
|
|
||||||
{
|
|
||||||
return 'Отправьте адресное сообщение в общий чат, нажав 1 раз по никнейму игрока либо в чате, либо со списка онлайна, который находится справа.';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getShortName(): string
|
|
||||||
{
|
|
||||||
return 'chat_second_quest';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getRewards(): array
|
|
||||||
{
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function isInfo(): bool
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,34 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace DarksLight2\Training\Steps;
|
|
||||||
|
|
||||||
use DarksLight2\Training\StepFactory;
|
|
||||||
|
|
||||||
class ChatThirdQuest extends StepFactory
|
|
||||||
{
|
|
||||||
|
|
||||||
public function getTitle(): string
|
|
||||||
{
|
|
||||||
return 'Начало.';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getMessage(): string
|
|
||||||
{
|
|
||||||
return 'Отправьте адресное личное сообщение в чат, нажав 2 раза по никнему игрока либо в чате, либо со списка онлайна, который находится справа.';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getShortName(): string
|
|
||||||
{
|
|
||||||
return 'chat_third_quest';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getRewards(): array
|
|
||||||
{
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function isInfo(): bool
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
34
_incl_data/class/DarksLight2/Training/Steps/FirstStep.php
Normal file
34
_incl_data/class/DarksLight2/Training/Steps/FirstStep.php
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace DarksLight2\Training\Steps;
|
||||||
|
|
||||||
|
use DarksLight2\Training\StepFactory;
|
||||||
|
|
||||||
|
class FirstStep extends StepFactory
|
||||||
|
{
|
||||||
|
|
||||||
|
public function getTitle(): string
|
||||||
|
{
|
||||||
|
return 'Добро пожаловать в игру!';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getMessage(): string
|
||||||
|
{
|
||||||
|
return 'Мы поможем Вам адаптироваться в нашей браузерной онлайн игре.<br>
|
||||||
|
Суть игры, заключается стремлении стать непобедимым бойцом в игре среди других персонажей!<br>
|
||||||
|
Сделать это сможет каждый игрок, путём усиления своего персонажа, предметов улучшенного качества, интеграции рун и чарок в предметы и других, интересных усилений.<br>
|
||||||
|
На общем фоне слева, Вы можете наблюдать своего персонажа ( слева ), на котором показаны пустые слоты под предметы, его параметры, ваши деньги, победы/поражения, а с права, общее окно разных локаций, таких как: Магазин, Ремонтная Мастерская, Здание лото, Здание Бойцовского Клуба где проходят поединки, Почта, Переход на Страшилкину Улицу и т.д.<br>
|
||||||
|
Далее, мы подскажем Вам, для чего служит нижний фрейм.';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getRewards(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getShortName(): string
|
||||||
|
{
|
||||||
|
return 'first_step';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,35 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace DarksLight2\Training\Steps;
|
|
||||||
|
|
||||||
use DarksLight2\Training\StepFactory;
|
|
||||||
|
|
||||||
class MyUserFirstQuest extends StepFactory
|
|
||||||
{
|
|
||||||
|
|
||||||
public function getTitle(): string
|
|
||||||
{
|
|
||||||
return 'Персонаж.';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getMessage(): string
|
|
||||||
{
|
|
||||||
return 'Сколько всего основных игровых Валют? Введите их число...';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getShortName(): string
|
|
||||||
{
|
|
||||||
return 'my_user_first_quest';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getRewards(): array
|
|
||||||
{
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAnswer(): string
|
|
||||||
{
|
|
||||||
return '2';
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,30 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace DarksLight2\Training\Steps;
|
|
||||||
|
|
||||||
use DarksLight2\Training\StepFactory;
|
|
||||||
|
|
||||||
class MyUserFirstStep extends StepFactory
|
|
||||||
{
|
|
||||||
|
|
||||||
public function getTitle(): string
|
|
||||||
{
|
|
||||||
return 'Персонаж.';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getMessage(): string
|
|
||||||
{
|
|
||||||
return 'В нашей игре, ваш персонаж расположен слева от экрана с игровыми локациями, там же, можно увидеть пустые слоты под предметы и параметры персонажа, ваш опыт, деньги, ежедневные задания...';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getShortName(): string
|
|
||||||
{
|
|
||||||
return 'my_user_first_step';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getRewards(): array
|
|
||||||
{
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace DarksLight2\Training\Steps;
|
|
||||||
|
|
||||||
use DarksLight2\Training\StepFactory;
|
|
||||||
|
|
||||||
class MyUserFourthQuest extends StepFactory
|
|
||||||
{
|
|
||||||
|
|
||||||
public function getTitle(): string
|
|
||||||
{
|
|
||||||
return 'Персонаж.';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getMessage(): string
|
|
||||||
{
|
|
||||||
return 'Войдите во вкладку " Умения ", в правой части экрана, сверху, а далее, перейдите во вкладку " Приёмы ", после чего, выберите нужные Вам приемы, но будьте внимательны, некоторые из приемов могут быть на разные классы, обязательно прочтите их описание или потестируйте в поединках.';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getShortName(): string
|
|
||||||
{
|
|
||||||
return 'my_user_fourth_quest';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getRewards(): array
|
|
||||||
{
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function isInfo(): bool
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace DarksLight2\Training\Steps;
|
|
||||||
|
|
||||||
use DarksLight2\Training\StepFactory;
|
|
||||||
|
|
||||||
class MyUserFourthStep extends StepFactory
|
|
||||||
{
|
|
||||||
|
|
||||||
public function getTitle(): string
|
|
||||||
{
|
|
||||||
return 'Персонаж.';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getMessage(): string
|
|
||||||
{
|
|
||||||
return '"Параметры Персонажа"<br>
|
|
||||||
Все игроки имеют свободные очки распределения параметров, что они дают игрокам конкретные модификаторы в зависимости от того, в какой из параметров распределяются очки распределения.<br>
|
|
||||||
--- если можно, добавить скрин как выглядит эта кнопка ---
|
|
||||||
Сила - Увеличивает мощность рубящего урона ( для Силачей )<br>
|
|
||||||
Ловкость - Увеличивает мощность колющего урона ( для Критоуворотов и Уворотов )<br>
|
|
||||||
Интуиция - Увеличивает мощность режущего урона ( для Критовиков )<br>
|
|
||||||
Выносливость - Увеличивает защиту от урона и магии, а так же добавит немного жизней. ( для Танков )<br>
|
|
||||||
Интелект - Увеличивает мощность магии. ( Для Любого Мага )<br>
|
|
||||||
Мудрость - Увеличивает колличество маны. ( Для Любого Мага )<br>
|
|
||||||
<br>
|
|
||||||
Дополнительно, игроки имеют очки распределения Мастерства Оружия, это позволит воинам увеличить урон, а магам, открыть новые приемы.<br>
|
|
||||||
Очки распределения Оружий распределяются точно так же, как и очки распределения параметров ( статов ).<br>
|
|
||||||
<br>
|
|
||||||
В случае, если вы распределили неверно любые доступные очки распределения, или хотите их изменить, вы можете это сделать, поднявшись на 2 этаж здания " Бойцовский Клуб ".';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getShortName(): string
|
|
||||||
{
|
|
||||||
return 'my_user_fourth_step';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getRewards(): array
|
|
||||||
{
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAnswer(): string
|
|
||||||
{
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,35 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace DarksLight2\Training\Steps;
|
|
||||||
|
|
||||||
use DarksLight2\Training\StepFactory;
|
|
||||||
|
|
||||||
class MyUserSecondQuest extends StepFactory
|
|
||||||
{
|
|
||||||
|
|
||||||
public function getTitle(): string
|
|
||||||
{
|
|
||||||
return 'Персонаж.';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getMessage(): string
|
|
||||||
{
|
|
||||||
return 'Кого убивает игровой класс "Танк"?';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getShortName(): string
|
|
||||||
{
|
|
||||||
return 'my_user_second_quest';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getRewards(): array
|
|
||||||
{
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getAnswer(): string
|
|
||||||
{
|
|
||||||
return 'Уворотов и Силачей';
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,39 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace DarksLight2\Training\Steps;
|
|
||||||
|
|
||||||
use DarksLight2\Training\StepFactory;
|
|
||||||
|
|
||||||
class MyUserSecondStep extends StepFactory
|
|
||||||
{
|
|
||||||
|
|
||||||
public function getTitle(): string
|
|
||||||
{
|
|
||||||
return 'Персонаж.';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getMessage(): string
|
|
||||||
{
|
|
||||||
return 'Опыт - Получение опыта происходит после сыгранных поединков, в зависимости от выбитого урона с противников, нажав по своему опыту, откроется таблица опыта, в которой можно посмотреть, когда вы получите дополнительное очко распределение параметров персонажа/оружий, награду за взятие " апа " или " Уровня "<br>
|
|
||||||
Текущий уровень - Отображает ваш текущий уровень персонажа.<br>
|
|
||||||
Победы - Отображает сумму всех ваших побед, в любых поединках.<br>
|
|
||||||
Поражения - Отображает сумму всех ваших поражений, в любых поединках.<br>
|
|
||||||
Ничьих - Отображает сумму всех поединков, которые завершились в ничью.<br>
|
|
||||||
Кредиты - Обычная игровая валюта - кредиты ( креды ), которые можно потратить в обычном магазине.<br>
|
|
||||||
Еврокредиты - Покупная игровая валюта - еврокредиты ( екры ) , которые можно потратить в магазине " Берёзка ". <br>
|
|
||||||
Воинственность - Дополнительная игровая валюта, потратить её можно в Подпольной Лавке.<br>
|
|
||||||
Ежедневное задание - Отображает текущее ежедневное задание либо предоставляет возможность его взятия.<br>
|
|
||||||
Бонус - Позволяет получить немного кредитов или еврокредитов.';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getShortName(): string
|
|
||||||
{
|
|
||||||
return 'my_user_second_step';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getRewards(): array
|
|
||||||
{
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,40 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace DarksLight2\Training\Steps;
|
|
||||||
|
|
||||||
use DarksLight2\Training\StepFactory;
|
|
||||||
|
|
||||||
class MyUserThirdQuest extends StepFactory
|
|
||||||
{
|
|
||||||
|
|
||||||
public function getTitle(): string
|
|
||||||
{
|
|
||||||
return 'Персонаж.';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getMessage(): string
|
|
||||||
{
|
|
||||||
return 'Распределите свободные параметры распределения ( статы ) и параметры оружий ( умения ) в зависимости от выбранного вами при регистрации "Класса" игрока нажав по кнопке " + Способности ", а далее, после распределения параметров " Сохранить ".';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getShortName(): string
|
|
||||||
{
|
|
||||||
return 'my_user_third_quest';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getRewards(): array
|
|
||||||
{
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function isInfo(): bool
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function allowedToMove(): array
|
|
||||||
{
|
|
||||||
return ['cp1'];
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,45 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace DarksLight2\Training\Steps;
|
|
||||||
|
|
||||||
use DarksLight2\Training\StepFactory;
|
|
||||||
|
|
||||||
class MyUserThirdStep extends StepFactory
|
|
||||||
{
|
|
||||||
|
|
||||||
public function getTitle(): string
|
|
||||||
{
|
|
||||||
return 'Персонаж.';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getMessage(): string
|
|
||||||
{
|
|
||||||
return 'В нашей игре, существует 5 Воинских и 4 Магических класса, такие как:<br>
|
|
||||||
Критовик - Убивает Танков и Магов, основное оружие - Мечи<br>
|
|
||||||
Уворот - Убивает Критовиков и Силачей, основное оружие - Кинжалы<br>
|
|
||||||
Танк - Убивает Уворотов и Силачей, основное оружие - Дубина и щит.<br>
|
|
||||||
Силач - Убивает Критовиков и Магов, основное оружие - Топоры<br>
|
|
||||||
Критоуворот - Убивает Силачей и с небольшим шансом Критовиков и Уворотов, основное оружие - Кинжалы.<br>
|
|
||||||
<br>
|
|
||||||
Маг Огня - Атакующий маг, убивает Уворотов и Танков.<br>
|
|
||||||
Маг Воздуха - Атакующий маг, убивает Уворотов и Танков.<br>
|
|
||||||
Маг Земли - Защищающийся маг, слабый урон, хорошая защита.<br>
|
|
||||||
Маг Воды - Защищающийся маг, слабый урон, хорошая защита.';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getShortName(): string
|
|
||||||
{
|
|
||||||
return 'my_user_third_step';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getRewards(): array
|
|
||||||
{
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
public function allowedToMove(): array
|
|
||||||
{
|
|
||||||
return ['cp1'];
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -4,17 +4,22 @@ namespace DarksLight2\Training\Steps;
|
|||||||
|
|
||||||
use DarksLight2\Training\StepFactory;
|
use DarksLight2\Training\StepFactory;
|
||||||
|
|
||||||
class ChatFirstQuest extends StepFactory
|
class SecondStep extends StepFactory
|
||||||
{
|
{
|
||||||
|
|
||||||
public function getTitle(): string
|
public function getTitle(): string
|
||||||
{
|
{
|
||||||
return 'Начало.';
|
return 'Тест';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getMessage(): string
|
public function getMessage(): string
|
||||||
{
|
{
|
||||||
return 'Отправьте сообщение в общий чат.';
|
return 'Тест';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getShortName(): string
|
||||||
|
{
|
||||||
|
return 'second_step';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getRewards(): array
|
public function getRewards(): array
|
||||||
@ -22,13 +27,4 @@ class ChatFirstQuest extends StepFactory
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getShortName(): string
|
|
||||||
{
|
|
||||||
return 'chat_first_quest';
|
|
||||||
}
|
|
||||||
|
|
||||||
public function isInfo(): bool
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -3,129 +3,26 @@
|
|||||||
namespace DarksLight2\Training;
|
namespace DarksLight2\Training;
|
||||||
|
|
||||||
use Core\Db;
|
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 DarksLight2\Traits\Singleton;
|
||||||
use PassGen;
|
|
||||||
use PDO;
|
use PDO;
|
||||||
use stdClass;
|
use stdClass;
|
||||||
use User;
|
|
||||||
|
|
||||||
class TrainingManager
|
class TrainingManager
|
||||||
{
|
{
|
||||||
|
|
||||||
use Singleton;
|
use Singleton;
|
||||||
|
|
||||||
|
private $database_records = false;
|
||||||
|
private array $steps_data;
|
||||||
private int $user_id;
|
private int $user_id;
|
||||||
public string $current_step = '';
|
private array $steps;
|
||||||
private array $registered_steps;
|
|
||||||
private array $completed_steps;
|
|
||||||
private array $active_steps;
|
|
||||||
|
|
||||||
private $database;
|
public function __construct(int $user_id)
|
||||||
|
|
||||||
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;
|
$this->user_id = $user_id;
|
||||||
|
|
||||||
if($refresh_token) {
|
|
||||||
$this->generateToken();
|
$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]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param StepFactory[] $steps
|
* @param StepFactory[] $steps
|
||||||
*
|
*
|
||||||
@ -140,52 +37,44 @@ class TrainingManager
|
|||||||
|
|
||||||
foreach ($steps as $step) {
|
foreach ($steps as $step) {
|
||||||
if($step instanceof StepFactory) {
|
if($step instanceof StepFactory) {
|
||||||
$this->registered_steps[$step->getShortName()] = $step;
|
$this->steps[$step->getShortName()] = new class (
|
||||||
}
|
$step->getMessage(),
|
||||||
}
|
$step->getTitle(),
|
||||||
}
|
$step->getRewards(),
|
||||||
private function generateToken($length = 16)
|
$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;
|
||||||
|
|
||||||
$token = PassGen::new($length);
|
public stdClass $progress;
|
||||||
|
|
||||||
Db::run('UPDATE user_training SET api_token = ? WHERE user_id = ?', [
|
public function __construct(
|
||||||
$token,
|
string $message,
|
||||||
$this->user_id
|
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 createDatabaseRecord()
|
|
||||||
{
|
|
||||||
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($data, true),
|
|
||||||
array_key_first($data)
|
|
||||||
]);
|
|
||||||
|
|
||||||
$this->database = Db::getRow('SELECT * FROM user_training WHERE user_id = ?', [$this->user_id]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @throws \DarksLight2\Training\TrainingException
|
|
||||||
*/
|
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
if(in_array(User::start()->room['file'], $this->registered_steps[$this->getCurrentStepName()]->onLocations()) || in_array('all', $this->registered_steps[$this->getCurrentStepName()]->onLocations())) {
|
if(!$this->isComplete) {
|
||||||
$path = $_SERVER['DOCUMENT_ROOT'] . '/modules_data/steps/step.php';
|
$path = $_SERVER['DOCUMENT_ROOT'] . '/modules_data/steps/' . $this->short_name . '.php';
|
||||||
|
|
||||||
if (file_exists($path)) {
|
if (file_exists($path)) {
|
||||||
$short_name = $this->getCurrentStepName();
|
|
||||||
$answer = $this->registered_steps[$this->getCurrentStepName()]->getAnswer();
|
|
||||||
require $path;
|
require $path;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -193,4 +82,120 @@ class TrainingManager
|
|||||||
throw TrainingException::noRenderingFile();
|
throw TrainingException::noRenderingFile();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function stepData(string $short_name): object
|
||||||
|
{
|
||||||
|
$data = $this->getDatabaseRecords()->data;
|
||||||
|
|
||||||
|
if(!isset($data->$short_name)) {
|
||||||
|
$this->updateDatabaseRecord($short_name);
|
||||||
|
$data = $this->getDatabaseRecords()->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data->$short_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function generateToken($length = 16)
|
||||||
|
{
|
||||||
|
$letters = 'abcdefgmikiHGJKLjkGASysj7603456';
|
||||||
|
|
||||||
|
$token = '';
|
||||||
|
|
||||||
|
for ($i = 0; $i <= $length; $i++) {
|
||||||
|
$token .= $letters[rand(0, strlen($letters))];
|
||||||
|
}
|
||||||
|
|
||||||
|
Db::run('UPDATE user_training SET api_token = ? WHERE user_id = ?', [
|
||||||
|
$token,
|
||||||
|
$this->user_id
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDatabaseRecords(): stdClass
|
||||||
|
{
|
||||||
|
if(!$this->database_records) {
|
||||||
|
$data = Db::run('SELECT * FROM user_training WHERE user_id = ?', [$this->user_id])
|
||||||
|
->fetch(PDO::FETCH_OBJ);
|
||||||
|
|
||||||
|
$this->database_records = new stdClass();
|
||||||
|
|
||||||
|
$this->database_records->user_id = $data->user_id;
|
||||||
|
$this->database_records->api_token = $data->api_token;
|
||||||
|
$this->database_records->data = json_decode($data->data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->database_records;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateDatabaseRecord(string $short_name)
|
||||||
|
{
|
||||||
|
if($this->getDatabaseRecords()) {
|
||||||
|
|
||||||
|
$this->database_records->data->$short_name = $this->firstRecordData()->$short_name;
|
||||||
|
|
||||||
|
Db::run('UPDATE user_training SET data = ? WHERE user_id = ?', [
|
||||||
|
json_encode($this->database_records->data),
|
||||||
|
$this->user_id
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function createDatabaseRecord()
|
||||||
|
{
|
||||||
|
if(!$this->getDatabaseRecords()) {
|
||||||
|
Db::run('INSERT INTO user_training (user_id, data) VALUES (?, ?)', [
|
||||||
|
$this->user_id,
|
||||||
|
json_encode($this->firstRecordData())
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function firstRecordData(): stdClass
|
||||||
|
{
|
||||||
|
$data = new stdClass();
|
||||||
|
$short_names = [
|
||||||
|
'first_step',
|
||||||
|
'second_step'
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($short_names as $name) {
|
||||||
|
$data->$name->complete = false;
|
||||||
|
$data->$name->progress->current = 0;
|
||||||
|
$data->$name->progress->need = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
public function __get(string $name)
|
||||||
|
{
|
||||||
|
return $this->steps[$name];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addPoint(string $short_name)
|
||||||
|
{
|
||||||
|
$this->database_records->data->$short_name->progress->current++;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function nextStep()
|
||||||
|
{
|
||||||
|
foreach ($this->database_records->data as $step) {
|
||||||
|
if($step->complete === false && $step->progress->current >= $step->progress->need) {
|
||||||
|
$step->complete = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function store()
|
||||||
|
{
|
||||||
|
$this->nextStep();
|
||||||
|
|
||||||
|
Db::run('UPDATE user_training SET data = ? WHERE user_id = ?', [
|
||||||
|
json_encode($this->database_records->data),
|
||||||
|
$this->user_id
|
||||||
|
]);
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,7 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Core\Db;
|
use Core\Db;
|
||||||
use DarksLight2\Training\TrainingManager;
|
|
||||||
use Insallah\Math;
|
use Insallah\Math;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -2055,10 +2054,6 @@ class Priems
|
|||||||
'UPDATE `stats` SET `priems` = "' . $p . '" WHERE `id` = "' . $this->u->info['id'] . '" LIMIT 1'
|
'UPDATE `stats` SET `priems` = "' . $p . '" WHERE `id` = "' . $this->u->info['id'] . '" LIMIT 1'
|
||||||
);
|
);
|
||||||
if ($upd) {
|
if ($upd) {
|
||||||
TrainingManager::getInstance()
|
|
||||||
->addPoint('my_user_fourth_quest', function (TrainingManager $manager) {
|
|
||||||
$manager->store();
|
|
||||||
});
|
|
||||||
$this->u->info['priems'] = $p;
|
$this->u->info['priems'] = $p;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
<IfModule mod_rewrite.c>
|
<IfModule mod_rewrite.c>
|
||||||
RewriteEngine On
|
RewriteEngine On
|
||||||
RewriteRule ^training/complete/?$ index.php?get=complete [L]
|
RewriteRule ^training/complete/?$ index.php?get=complete [L]
|
||||||
RewriteRule ^training/go_back/?$ index.php?get=go_back [L]
|
|
||||||
</IfModule>
|
</IfModule>
|
@ -1,8 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use DarksLight2\Training\Steps\ChatFirstStep;
|
|
||||||
use DarksLight2\Training\Steps\MyUserFirstQuest;
|
|
||||||
use DarksLight2\Training\TrainingException;
|
|
||||||
use DarksLight2\Training\TrainingManager;
|
use DarksLight2\Training\TrainingManager;
|
||||||
|
|
||||||
header('Content-type: application/json');
|
header('Content-type: application/json');
|
||||||
@ -19,19 +16,10 @@ if($input = file_get_contents("php://input")) {
|
|||||||
|
|
||||||
if(!empty($user->info)) {
|
if(!empty($user->info)) {
|
||||||
|
|
||||||
$training = TrainingManager::getInstance($user->info['id'], false);
|
$training = TrainingManager::getInstance($user->info['id']);
|
||||||
|
|
||||||
try {
|
|
||||||
$training->createDatabaseRecord();
|
|
||||||
$training->register([
|
|
||||||
new MyUserFirstQuest(),
|
|
||||||
new ChatFirstStep()
|
|
||||||
]);
|
|
||||||
} catch (TrainingException $e) {
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isset($data->token) || !password_verify(
|
if (!isset($data->token) || !password_verify(
|
||||||
$training->getDatabaseData()->api_token . $data->time . $user->info['id'],
|
$training->getDatabaseRecords()->api_token . $data->time . $user->info['id'],
|
||||||
$data->token
|
$data->token
|
||||||
)) {
|
)) {
|
||||||
http_response_code(401);
|
http_response_code(401);
|
||||||
@ -44,27 +32,16 @@ if(!empty($user->info)) {
|
|||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
die;
|
die;
|
||||||
case 'complete':
|
case 'complete':
|
||||||
if ($training->getDatabaseData()['data'][$training->getCurrentStepName()]['completed']) {
|
if ($training->{$data->short_name}->isComplete) {
|
||||||
http_response_code(400);
|
http_response_code(400);
|
||||||
die;
|
die;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($training->getRegistered()[$data->short_name]->isInfo()) {
|
$training->addPoint($data->short_name);
|
||||||
|
|
||||||
$training->addPoint($training->getCurrentStepName());
|
|
||||||
}
|
|
||||||
|
|
||||||
$training->nextStep();
|
$training->nextStep();
|
||||||
|
|
||||||
$training->store();
|
$training->store();
|
||||||
|
|
||||||
die(json_encode(['status' => 'ok']));
|
die(json_encode(['status' => 'ok']));
|
||||||
|
|
||||||
case 'go_back':
|
|
||||||
$training->previousStep();
|
|
||||||
$training->store();
|
|
||||||
die(json_encode(['status' => 'ok', 'message' => 'Вы указал не верный ответ!']));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,44 +1,23 @@
|
|||||||
const request = new XMLHttpRequest();
|
const request = new XMLHttpRequest();
|
||||||
|
|
||||||
const training_handler = () => {
|
const training_handler = () => {
|
||||||
|
request.open('POST', '/api/training/complete')
|
||||||
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.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
|
||||||
request.onreadystatechange = function() {//Call a function when the state changes.
|
request.onreadystatechange = function() {//Call a function when the state changes.
|
||||||
if (request.readyState === 4) {
|
if(request.readyState === 4 && request.status === 200) {
|
||||||
if(request.status === 200) {
|
|
||||||
parent.frames['main'].location.reload();
|
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({
|
request.send(JSON.stringify({
|
||||||
time: training_data().time,
|
time: training_data().time,
|
||||||
token: training_data().token,
|
token: training_data().token,
|
||||||
short_name: training_data().short_name,
|
short_name: training_data().short_name
|
||||||
answer: get_user_answer(),
|
|
||||||
}))
|
}))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_user_answer() {
|
let active_training = null;
|
||||||
if(training_data().answer === '') {
|
|
||||||
return '';
|
|
||||||
}
|
|
||||||
|
|
||||||
return document.getElementsByName('user_answer')[0].value;
|
|
||||||
}
|
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
if (typeof window.CustomEvent === "function") return false;
|
if (typeof window.CustomEvent === "function") return false;
|
||||||
@ -65,24 +44,20 @@ $modal = function (options) {
|
|||||||
elemModal = document.createElement('div'),
|
elemModal = document.createElement('div'),
|
||||||
modalTemplate = '<div class="modal__backdrop" data-dismiss="modal"><div class="modal__content"><div class="modal__header"><div class="modal__title" data-modal="title">{{title}}</div><span class="modal__btn-close" data-dismiss="modal" title="Закрыть">×</span></div><div id="modal_content" class="modal__body" data-modal="content">{{content}}</div>{{footer}}</div></div>',
|
modalTemplate = '<div class="modal__backdrop" data-dismiss="modal"><div class="modal__content"><div class="modal__header"><div class="modal__title" data-modal="title">{{title}}</div><span class="modal__btn-close" data-dismiss="modal" title="Закрыть">×</span></div><div id="modal_content" class="modal__body" data-modal="content">{{content}}</div>{{footer}}</div></div>',
|
||||||
modalFooterTemplate = '<div class="modal__footer">{{buttons}}</div>',
|
modalFooterTemplate = '<div class="modal__footer">{{buttons}}</div>',
|
||||||
modalInputAnswer = '',
|
|
||||||
modalButtonTemplate = '<button type="button" class="{{button_class}}" data-handler={{button_handler}}>{{button_text}}</button>',
|
modalButtonTemplate = '<button type="button" class="{{button_class}}" data-handler={{button_handler}}>{{button_text}}</button>',
|
||||||
modalHTML,
|
modalHTML,
|
||||||
modal_content,
|
modal_content,
|
||||||
modalFooterHTML = '';
|
modalFooterHTML = '';
|
||||||
|
|
||||||
if(training_data().answer !== '') {
|
|
||||||
modalInputAnswer = '<br><br><input name="user_answer" placeholder="Укажите ответ"/>';
|
|
||||||
}
|
|
||||||
|
|
||||||
elemModal.classList.add('modal');
|
elemModal.classList.add('modal');
|
||||||
modalHTML = modalTemplate.replace('{{title}}', options.title || 'Новое окно');
|
modalHTML = modalTemplate.replace('{{title}}', options.title || 'Новое окно');
|
||||||
|
//modalHTML = modalHTML.replace('{{content}}', options.content || '');
|
||||||
|
|
||||||
if (options.footerButtons) {
|
if (options.footerButtons) {
|
||||||
for (var i = 0, length = options.footerButtons.length; i < length; i++) {
|
for (var i = 0, length = options.footerButtons.length; i < length; i++) {
|
||||||
var modalFooterButton = modalButtonTemplate.replace('{{button_class}}', options.footerButtons[i].class);
|
var modalFooterButton = modalButtonTemplate.replace('{{button_class}}', options.footerButtons[i].class);
|
||||||
modalFooterButton = modalFooterButton.replace('{{button_handler}}', options.footerButtons[i].handler);
|
modalFooterButton = modalFooterButton.replace('{{button_handler}}', options.footerButtons[i].handler);
|
||||||
modalFooterButton = modalFooterButton.replace('{{button_text}}', options.footerButtons[i].text) + modalInputAnswer;
|
modalFooterButton = modalFooterButton.replace('{{button_text}}', options.footerButtons[i].text);
|
||||||
modalFooterHTML += modalFooterButton;
|
modalFooterHTML += modalFooterButton;
|
||||||
}
|
}
|
||||||
modalFooterHTML = modalFooterTemplate.replace('{{buttons}}', modalFooterHTML);
|
modalFooterHTML = modalFooterTemplate.replace('{{buttons}}', modalFooterHTML);
|
||||||
|
12
main.php
12
main.php
@ -36,11 +36,8 @@ if (!defined('GAME_VERSION')) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
use Core\{Config, Database, Db};
|
use Core\{Config, Database, Db};
|
||||||
use DarksLight2\Training\TrainingException;
|
|
||||||
use DarksLight2\Training\TrainingManager;
|
use DarksLight2\Training\TrainingManager;
|
||||||
|
|
||||||
$training_manager = TrainingManager::getInstance(User::start()->info['id']);
|
|
||||||
|
|
||||||
function var_info($vars, $d = false)
|
function var_info($vars, $d = false)
|
||||||
{
|
{
|
||||||
echo "<pre style='border: 1px solid gray;border-radius: 5px;padding: 3px 6px;background: #cecece;color: black;font-family: Arial;font-size: 12px;'>\n";
|
echo "<pre style='border: 1px solid gray;border-radius: 5px;padding: 3px 6px;background: #cecece;color: black;font-family: Arial;font-size: 12px;'>\n";
|
||||||
@ -562,10 +559,11 @@ $spl = $spl['exp'];
|
|||||||
echo '<script>top.myexpLineTop27(' . $u->info['exp'] . ',' . $spl . ');' . $tjs . 'top.ctest("' . $u->info['city'] . '");top.sd4key="' . $u->info['nextAct'] . '"; var battle = ' . (0 + $u->info['battle']) . '; top.hic();</script></body>
|
echo '<script>top.myexpLineTop27(' . $u->info['exp'] . ',' . $spl . ');' . $tjs . 'top.ctest("' . $u->info['city'] . '");top.sd4key="' . $u->info['nextAct'] . '"; var battle = ' . (0 + $u->info['battle']) . '; top.hic();</script></body>
|
||||||
</html>';
|
</html>';
|
||||||
|
|
||||||
try {
|
$training_manager = TrainingManager::getInstance();
|
||||||
$training_manager->render();
|
|
||||||
} catch (TrainingException $e) {
|
if($u->room['file']=='cp1') {
|
||||||
echo $e->getMessage();
|
$training_manager->first_step->render();
|
||||||
|
$training_manager->second_step->render();
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.2/modernizr.js"></script>-->
|
<!--<script src="https://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.2/modernizr.js"></script>-->
|
||||||
|
@ -139,8 +139,6 @@ function thisInfRm($id, $tp = null, $json = false)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isset($_GET['loc'])) {
|
if (isset($_GET['loc'])) {
|
||||||
$training_manager = \DarksLight2\Training\TrainingManager::getInstance();
|
|
||||||
|
|
||||||
$go = mysql_fetch_array(
|
$go = mysql_fetch_array(
|
||||||
mysql_query(
|
mysql_query(
|
||||||
'SELECT * FROM `room` WHERE `code` = "' . mysql_real_escape_string(
|
'SELECT * FROM `room` WHERE `code` = "' . mysql_real_escape_string(
|
||||||
@ -148,13 +146,6 @@ if (isset($_GET['loc'])) {
|
|||||||
) . '" AND `city` = "' . $u->info['city'] . '" LIMIT 1'
|
) . '" AND `city` = "' . $u->info['city'] . '" LIMIT 1'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
if (in_array(
|
|
||||||
$go['file'],
|
|
||||||
$training_manager->getRegistered(
|
|
||||||
)[$training_manager->getCurrentStepName()]->allowedToMove()
|
|
||||||
)) {
|
|
||||||
|
|
||||||
$tr_pl = mysql_fetch_array(
|
$tr_pl = mysql_fetch_array(
|
||||||
mysql_query(
|
mysql_query(
|
||||||
'SELECT `id`,`v1` FROM `eff_users` WHERE `id_eff` = 4 AND `uid` = "' . $u->info['id'] . '" AND `delete` = "0" ORDER BY `v1` DESC LIMIT 1'
|
'SELECT `id`,`v1` FROM `eff_users` WHERE `id_eff` = 4 AND `uid` = "' . $u->info['id'] . '" AND `delete` = "0" ORDER BY `v1` DESC LIMIT 1'
|
||||||
@ -185,6 +176,7 @@ if (isset($_GET['loc'])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isset($tr_pl['id'])) {
|
if (isset($tr_pl['id'])) {
|
||||||
|
|
||||||
$zadej = 0;
|
$zadej = 0;
|
||||||
|
|
||||||
if ($tr_pl['v1'] == 1) {
|
if ($tr_pl['v1'] == 1) {
|
||||||
@ -226,25 +218,20 @@ if (isset($_GET['loc'])) {
|
|||||||
while ($i < count($rg)) {
|
while ($i < count($rg)) {
|
||||||
if ($rg[$i] >= 0) {
|
if ($rg[$i] >= 0) {
|
||||||
$rmgo[$rg[$i]] = 1;
|
$rmgo[$rg[$i]] = 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
$sleep = $u->testAction(
|
$sleep = $u->testAction('`vars` = "sleep" AND `uid` = "' . $u->info['id'] . '" LIMIT 1', 1);
|
||||||
'`vars` = "sleep" AND `uid` = "' . $u->info['id'] . '" LIMIT 1',
|
|
||||||
1
|
|
||||||
);
|
|
||||||
if (isset($sleep['id']) && $sleep['vars'] == 'sleep' && $go['name'] != 'Общ. Этаж 1' && $go['name'] != 'Общ. Этаж 2' && $go['name'] != 'Общ. Этаж 3') {
|
if (isset($sleep['id']) && $sleep['vars'] == 'sleep' && $go['name'] != 'Общ. Этаж 1' && $go['name'] != 'Общ. Этаж 2' && $go['name'] != 'Общ. Этаж 3') {
|
||||||
$re = '<font color=red><b>Вы можете перемещаться только когда бодрствуете.</b></font>';
|
$re = '<font color=red><b>Вы можете перемещаться только когда бодрствуете.</b></font>';
|
||||||
echo ' ' . $re;
|
echo ' ' . $re;
|
||||||
} elseif ($u->info['timeGo'] >= time()) {
|
} elseif ($u->info['timeGo'] >= time()) {
|
||||||
$re = 'Вы не можете перемещаться еще ' . ($u->info['timeGo'] - time(
|
$re = 'Вы не можете перемещаться еще ' . ($u->info['timeGo'] - time()) . ' сек.';
|
||||||
)) . ' сек.';
|
|
||||||
} elseif ($rmgo[$go['id']] == 1) {
|
} elseif ($rmgo[$go['id']] == 1) {
|
||||||
$alg = explode('-', $go['align']);
|
$alg = explode('-', $go['align']);
|
||||||
$ku = mysql_fetch_array(
|
$ku = mysql_fetch_array(
|
||||||
mysql_query(
|
mysql_query('SELECT `id` FROM `katok_zv` WHERE `uid` = "' . $u->info['id'] . '" LIMIT 1')
|
||||||
'SELECT `id` FROM `katok_zv` WHERE `uid` = "' . $u->info['id'] . '" LIMIT 1'
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
|
||||||
if (isset($ku['id'])) {
|
if (isset($ku['id'])) {
|
||||||
@ -262,9 +249,7 @@ if (isset($_GET['loc'])) {
|
|||||||
$re = 'Подали заявку и убегаем?.. Не хорошо!';
|
$re = 'Подали заявку и убегаем?.. Не хорошо!';
|
||||||
} else {
|
} else {
|
||||||
$re = 'Ваша заявка была удалена... Теперь вы можете перейти в другую локацию!';
|
$re = 'Ваша заявка была удалена... Теперь вы можете перейти в другую локацию!';
|
||||||
mysql_query(
|
mysql_query('UPDATE `stats` SET `zv` = 0 WHERE `id` = "' . $u->info['id'] . '" LIMIT 1');
|
||||||
'UPDATE `stats` SET `zv` = 0 WHERE `id` = "' . $u->info['id'] . '" LIMIT 1'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
} elseif ((($go['clan'] > 0 && $u->info['clan'] != $go['clan']) || ($go['clan'] == -1 && $u->info['clan'] == 0)) && $u->info['admin'] == 0) {
|
} elseif ((($go['clan'] > 0 && $u->info['clan'] != $go['clan']) || ($go['clan'] == -1 && $u->info['clan'] == 0)) && $u->info['admin'] == 0) {
|
||||||
$re = 'Вы не можете попасть в эту комнату';
|
$re = 'Вы не можете попасть в эту комнату';
|
||||||
@ -314,6 +299,7 @@ if (isset($_GET['loc'])) {
|
|||||||
) . '" WHERE `id` = "' . $u->info['id'] . '" LIMIT 1'
|
) . '" WHERE `id` = "' . $u->info['id'] . '" LIMIT 1'
|
||||||
);
|
);
|
||||||
if ($upd2) {
|
if ($upd2) {
|
||||||
|
|
||||||
if ($u->room['file'] == 'bsenter' && $go['file'] != 'bsenter') {
|
if ($u->room['file'] == 'bsenter' && $go['file'] != 'bsenter') {
|
||||||
//Удаляем все ставки в БС
|
//Удаляем все ставки в БС
|
||||||
$sp_bs = mysql_query(
|
$sp_bs = mysql_query(
|
||||||
@ -333,13 +319,10 @@ if (isset($_GET['loc'])) {
|
|||||||
|
|
||||||
$smt = $u->testAction(
|
$smt = $u->testAction(
|
||||||
'`uid` = "' . $u->info['id'] . '" AND `time`>=' . (time(
|
'`uid` = "' . $u->info['id'] . '" AND `time`>=' . (time(
|
||||||
) - 600) . ' AND `vars` = "create_snowball_cp" LIMIT 1',
|
) - 600) . ' AND `vars` = "create_snowball_cp" LIMIT 1', 1
|
||||||
1
|
|
||||||
);
|
);
|
||||||
if (isset($smt['id'])) {
|
if (isset($smt['id'])) {
|
||||||
mysql_query(
|
mysql_query('DELETE FROM `actions` WHERE `id` = "' . $smt['id'] . '" LIMIT 1');
|
||||||
'DELETE FROM `actions` WHERE `id` = "' . $smt['id'] . '" LIMIT 1'
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
mysql_query(
|
mysql_query(
|
||||||
'UPDATE `eff_users` SET `delete` = "' . time(
|
'UPDATE `eff_users` SET `delete` = "' . time(
|
||||||
@ -368,9 +351,6 @@ if (isset($_GET['loc'])) {
|
|||||||
} else {
|
} else {
|
||||||
$re = 'Проход не существует';
|
$re = 'Проход не существует';
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
$re = 'Вам запрещено передвигаться до окончания обучения!!!';
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($u->info['room'] == 209) {
|
if ($u->info['room'] == 209) {
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
use DarksLight2\Training\TrainingManager;
|
|
||||||
|
|
||||||
if (!defined('GAME')) {
|
if (!defined('GAME')) {
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
@ -444,11 +441,6 @@ $tma = '';
|
|||||||
WHERE
|
WHERE
|
||||||
`id` = '" . (int)$u->info['id'] . "';"
|
`id` = '" . (int)$u->info['id'] . "';"
|
||||||
)) {
|
)) {
|
||||||
TrainingManager::getInstance()
|
|
||||||
->addPoint('my_user_third_quest', function (TrainingManager $manager) {
|
|
||||||
$manager->store();
|
|
||||||
});
|
|
||||||
|
|
||||||
//if($_GET['energy']>0) {echo ' <font color=red>Увеличение способности "<B>Энергия</B>" произведено удачно</font><br>';}
|
//if($_GET['energy']>0) {echo ' <font color=red>Увеличение способности "<B>Энергия</B>" произведено удачно</font><br>';}
|
||||||
if ($_GET['str'] > 0) {
|
if ($_GET['str'] > 0) {
|
||||||
echo ' <font color=red>Увеличение способности "<B>Сила</B>" произведено удачно</font><br>';
|
echo ' <font color=red>Увеличение способности "<B>Сила</B>" произведено удачно</font><br>';
|
||||||
|
@ -4,6 +4,8 @@ if(!defined('GAME'))
|
|||||||
{
|
{
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
require_once('/home/newcom1/public_html/_incl_data/__config.php');
|
||||||
|
require_once('/home/newcom1/public_html/_incl_data/class/__db_connect.php');
|
||||||
|
|
||||||
if($u->room['file']=='cp1') {
|
if($u->room['file']=='cp1') {
|
||||||
|
|
||||||
|
31
modules_data/steps/first_step.php
Normal file
31
modules_data/steps/first_step.php
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string $token
|
||||||
|
* @var int $time
|
||||||
|
* @var string $button_text
|
||||||
|
* @var object $step
|
||||||
|
*/
|
||||||
|
|
||||||
|
$short_name = 'first_step';
|
||||||
|
|
||||||
|
require 'step.php';
|
||||||
|
|
||||||
|
?>
|
||||||
|
<script>
|
||||||
|
const training_data = () => {
|
||||||
|
return {
|
||||||
|
content: `<?=$step->message?>`,
|
||||||
|
title: `<?=$step->title?>`,
|
||||||
|
button_text: `<?=$button_text?>`,
|
||||||
|
time: <?=$time?>,
|
||||||
|
token: '<?=$token?>',
|
||||||
|
short_name: '<?=$short_name?>',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<script src="/js/training/modal.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
modal.show()
|
||||||
|
</script>
|
31
modules_data/steps/second_step.php
Normal file
31
modules_data/steps/second_step.php
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string $token
|
||||||
|
* @var int $time
|
||||||
|
* @var string $button_text
|
||||||
|
* @var object $step
|
||||||
|
*/
|
||||||
|
|
||||||
|
$short_name = 'second_step';
|
||||||
|
|
||||||
|
require 'step.php';
|
||||||
|
|
||||||
|
?>
|
||||||
|
<script>
|
||||||
|
const training_data = () => {
|
||||||
|
return {
|
||||||
|
content: `<?=$step->message?>`,
|
||||||
|
title: `<?=$step->title?>`,
|
||||||
|
button_text: `<?=$button_text?>`,
|
||||||
|
time: <?=$time?>,
|
||||||
|
token: '<?=$token?>',
|
||||||
|
short_name: '<?=$short_name?>',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<script src="/js/training/modal.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
modal.show()
|
||||||
|
</script>
|
@ -1,42 +1,16 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
ini_set('display_errors', 1);
|
|
||||||
error_reporting(E_ALL);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var string $short_name
|
* @var string $short_name
|
||||||
* @var $answer
|
|
||||||
* @var \DarksLight2\Training\StepFactory $step
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
$user = User::start();
|
$user = User::start();
|
||||||
|
|
||||||
use DarksLight2\Training\TrainingManager;
|
use DarksLight2\Training\TrainingManager;
|
||||||
|
|
||||||
$manager = TrainingManager::getInstance();
|
$manager = TrainingManager::getInstance();
|
||||||
$step = $manager->getRegistered()[$short_name];
|
$step = $manager->$short_name;
|
||||||
$button_text = 'Продолжить';
|
$button_text = 'Продолжить';
|
||||||
$time = time();
|
$time = time();
|
||||||
|
|
||||||
$token = password_hash($manager->getDatabaseData()->api_token . $time . $user->info['id'], PASSWORD_DEFAULT);
|
$token = password_hash($manager->getDatabaseRecords()->api_token . $time . $user->info['id'], PASSWORD_DEFAULT);
|
||||||
?>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
const training_data = () => {
|
|
||||||
return {
|
|
||||||
content: `<?=$step->getMessage()?>`,
|
|
||||||
title: `<?=$step->getTitle()?>`,
|
|
||||||
button_text: `<?=$button_text?>`,
|
|
||||||
time: <?=$time?>,
|
|
||||||
token: '<?=$token?>',
|
|
||||||
short_name: '<?=$short_name?>',
|
|
||||||
answer: '<?=$answer?>'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<script src="/js/training/modal.js"></script>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
modal.show()
|
|
||||||
</script>
|
|
||||||
|
13
online.php
13
online.php
@ -7,7 +7,6 @@ if (!defined('GAME_VERSION')) {
|
|||||||
use Core\Config;
|
use Core\Config;
|
||||||
use Core\Database;
|
use Core\Database;
|
||||||
use Core\Db;
|
use Core\Db;
|
||||||
use DarksLight2\Training\TrainingManager;
|
|
||||||
|
|
||||||
|
|
||||||
Config::init();
|
Config::init();
|
||||||
@ -266,18 +265,6 @@ if (isset($_POST['msg']) && str_replace(' ', '', $_POST['msg']) != '') {
|
|||||||
mysql_query("UPDATE `chat` SET `delete` = 1 WHERE `login` = '" . $u->info['login'] . "' LIMIT 1000");
|
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'] . '';
|
$_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(
|
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 (
|
'INSERT INTO `chat` (`nosee`,`invis`,`da`,`delete`,`molch`,`new`,`login`,`to`,`city`,`room`,`time`,`type`,`spam`,`text`,`toChat`,`color`,`typeTime`,`sound`,`global`) VALUES (
|
||||||
"0",
|
"0",
|
||||||
|
17
test.php
Normal file
17
test.php
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use DarksLight2\Training\Steps\FirstStep;
|
||||||
|
use DarksLight2\Training\TrainingException;
|
||||||
|
use DarksLight2\Training\TrainingManager;
|
||||||
|
|
||||||
|
if (session_status() === PHP_SESSION_NONE) {
|
||||||
|
session_start();
|
||||||
|
}
|
||||||
|
if (isset($_GET['unset'])) {
|
||||||
|
session_unset();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!defined('GAME_VERSION')) {
|
||||||
|
require_once '_incl_data/autoload.php';
|
||||||
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user