This commit is contained in:
2024-12-16 16:51:46 +02:00
parent e264956831
commit 96fbfb60e8
16 changed files with 250 additions and 295 deletions
+27 -27
View File
@@ -2,7 +2,7 @@ import path, { dirname } from 'path';
import { fileURLToPath } from 'url';
/**
* Main backend application class
* Main backend application class, апликация - основен клас на сървърното приложение
*/
class App{
constructor(){
@@ -11,13 +11,13 @@ class App{
}
/**
* The plugins used by the application
* The plugins used by the application, списък на плъгините, използвани в приложението
* @type {AppPlugin[]}
*/
plugins = [];
/**
* Declaration of plugin usage
* Declaration of plugin usage, деклариране на употреба на плъгин
* @param {AppPlugin} plugin The plugin to be used
*/
async use(plugin){
@@ -27,7 +27,7 @@ class App{
}
/**
* Initializes the application. All plugins are initialized at this stage
* Initializes the application. All plugins are initialized at this stage, инициализация на приложението, на тази стъпка се инициализират всички регистрирани плъгини
*/
async init(){
for (let p of this.plugins){
@@ -37,8 +37,8 @@ class App{
}
/**
* Imports modules as plugins in the app by a given list
* @param {Array} modules Modules to be imported
* Imports modules as plugins in the app by a given list, импортиране на списък от модули, които да бъдат регистрирани като плъгини в приложението
* @param {Array} modules Modules to be imported, масив от модули
*/
async importModules(modules){
const mods = {};
@@ -52,8 +52,8 @@ class App{
}
/**
* Replaces a plugin
* @param {AppPlugin} p Plugin to be replaced
* Replaces a plugin, подмяна на плъгин
* @param {AppPlugin} p Plugin to be replaced, плъгин, който да бъде подменен
*/
async replace(p){
let old = this[p.name];
@@ -64,7 +64,7 @@ class App{
}
/**
* Starts the application. All Plugins are started at this point
* Starts the application. All Plugins are started at this point. Стартиране на приложението и всички негови плъгини
*/
async start(){
for (let p of this.plugins){
@@ -78,89 +78,89 @@ class App{
/* The following are pseudo in order to keep documentation aligned to the code */
/**
* The core application plugins
* The core application plugins, основни плъгини на приложението
*/
class AppCore{
/**
* The configuration plugin instance
* The configuration plugin instance, конфигурационен плъгин
* @type Config
*/
config = undefined;
/**
* The database plugin instance
* The database plugin instance, плъгин към базата от данни
* @type Db
*/
db = undefined;
/**
* The web server plugin instance
* The web server plugin instance, уеб сървър плъгин
* @type WebServer
*/
webServer = undefined;
}
/**
* The main logical part application plugins
* The main logical part application plugins, плъгини, свързани с логическия слой на приложението - контролни класове
*/
class AppManagement {
/**
* Game objects manager plugin instance
* Game objects manager plugin instance, управление на игрови обекти
* @type GameObjectsManager
*/
gameObject = undefined;
/**
* Games manager plugin instance
* Games manager plugin instance, управление на игрови дефиниции
* @type GamesManager
*/
games = undefined;
/**
* Rules manager plugin instance
* Rules manager plugin instance, управление на игрови правила
* @type RulesManager
*/
rules = undefined;
/**
* Scenarios manager plugin instance
* Scenarios manager plugin instance, управление на игрови сценарии
* @type ScenariosManager
*/
scenarios = undefined;
}
/**
* The main application controller plugin instances
* The main application controller plugin instances, основни комуникационни (гранични) класове
*/
class AppControllerApi {
/**
* Game objects controller plugin instance
* Game objects controller plugin instance, контролер на игрови обекти
* @type GameObjectsController
*/
gameObjectsApi = undefined;
/**
* Games controller plugin instance
* Games controller plugin instance, контролер на игрови дефиниции
* @type GamesController
*/
gamesApi = undefined;
/**
* Rules controller plugin instance
* Rules controller plugin instance, контролер на игрови правила
* @type RulesController
*/
rulesApi = undefined;
/**
* Scenarios controller plugin instance
* Scenarios controller plugin instance, контролер на игрови сценарии
* @type ScenariosController
*/
scenariosApi = undefined;
/**
* Asset controller plugin instance
* Asset controller plugin instance, контролер на игрови активи
* @type AssetController
*/
assetApi = undefined;
@@ -168,21 +168,21 @@ class AppControllerApi {
class AppConcrete {
/**
* Application core plugins
* Application core plugins, плъгини - ядро на приложението
* @type AppCore
* @memberof App
*/
core = undefined;
/**
* Application management plugins
* Application management plugins, управление на приложението - логически класове
* @type AppManagement
* @memberof App
*/
management = undefined;
/**
* Application controller API plugins
* Application controller API plugins, управление на граничните класове - контролери
* @type AppControllerApi
* @memberof App
*/
+23 -23
View File
@@ -1,18 +1,18 @@
import path from 'path'
const pe = process.env;
/**
* Configuration class
* Configuration class, конфигурационен клас
*/
class Config{
name = 'config';
/**
* @class File system options , repository setup
* @class File system options, repository setup, настройки на файловата система и хранилището за обекти
* @alias FileSystemOptions
* @memberof Config
*/
fs = {
/** Repository path
/** Repository path, път към хранилището във файловата система
* @type {string}
* @memberof FileSystemOptions
*/
@@ -20,18 +20,18 @@ class Config{
}
/**
* @class Database options
* @class Database options, опции за базата от данни
* @alias DatabaseOptions
* @memberof Config
*/
db = {
/** Database name
/** Database name, име на базата от данни
* @type {string}
* @memberof DatabaseOptions
*/
name:'pronature',
/** Database connection string
/** Database connection string, данни за свързване с базата от данни
* @type {string}
* @memberof DatabaseOptions
*/
@@ -39,51 +39,51 @@ class Config{
}
/**
* @class Web site endpoint options
* @class Web site endpoint options, опции за уеб сайта
* @alias SiteOptions
* @memberof Config
*/
site = {
/** Host name
/** Host name, име на хоста
* @type {string}
* @memberof SiteOptions
*/
host:'https://localhost:5173',
/** Whether to use SSL
/** Whether to use SSL, дали да използва сигурна връзка
* @type {boolean}
* @memberof SiteOptions
*/
ssl: !!parseInt(pe.SRV_SSL),
/** Port to use
/** Port to use, порт за достъп
* @type {Number}
* @memberof SiteOptions
*/
port: pe.SRV_PORT,
/**
* @class Certificate data
* @class Certificate data, данни за сертификат
* @alias CertificateOptions
* @memberof SiteOptions
*/
certificate: {
/**
* Certificate private key
* Certificate private key, частен ключ на сертификата
* @type {string}
* @memberof CertificateOptions
*/
key: './.cert/dev-key.pem',
/**
* Certificate public key
* Certificate public key, публичен ключ на сертификата
* @type {string}
* @memberof CertificateOptions
*/
cert: './.cert/dev-cert.pem',
/**
* PK Passphrase
* PK Passphrase, парола за частния ключ
* @type {string}
* @memberof CertificateOptions
*/
@@ -92,33 +92,33 @@ class Config{
}
/**
* @class Access management options
* @class Access management options, настройки за управление на достъпа
* @alias AccessManagementOptions
* @memberof Config
*/
am = {
/**
* Salt, a string to be used in order to make a more complex password hash
* Salt, a string to be used in order to make a more complex password hash, допълнителна защита при хеширане на паролите
* @type {string}
* @memberof AccessManagementOptions
*/
salt : 'P@ssSal7y!!',
/**
* @class Cookie options
* @class Cookie options, опции за бисквитките
* @alias CookieOptions
* @memberof AccessManagementOptions
*/
cookie: {
/**
* Cookie secret
* Cookie secret, защита
* @type {string}
* @memberof CookieOptions
*/
secret: 'S3cret4C00k!ie$',
/**
* Cookie max age (in seconds)
* Cookie max age (in seconds), максимална възраст на бисквитка
* @type {Number}
* @memberof CookieOptions
*/
@@ -127,8 +127,8 @@ class Config{
}
/**
* Initializes the configuration
* @param {App} app The application
* Initializes the configuration, инициализация
* @param {App} app The application, апликация
*/
async init(app){
if (!this.fs.repo){
@@ -137,8 +137,8 @@ class Config{
}
/**
* Starts the configuration plugin
* @param {App} app the application instance
* Starts the configuration plugin, стартиране
* @param {App} app the application instance, апликация
*/
async start(app){
+40 -40
View File
@@ -4,22 +4,22 @@ let db;
let dbo;
/**
* Manages database operations
* Manages database operations, управление на операциите към базата от данни
*/
class Db {
name = 'db';
/**
* Initializes the database plugin
* @param {App} app The application instance
* Initializes the database plugin, инициализация
* @param {App} app The application instance, апликация
*/
init(app){
}
/**
* Starts the database plugin
* @param {App} app The application instance
* Starts the database plugin, стартиране
* @param {App} app The application instance, апликация
*/
async start(app){
db = await MongoClient.connect(app.config.db.url, {maxPoolSize: 256});
@@ -36,10 +36,10 @@ class Db {
}
/**
* Inserts a record in a db collection
* @param {string} collection The name of the collection
* @param {Object} value The object to insert
* @returns {ObjectId} Inserted Id
* Inserts a record in a db collection, добавяне на запис в базата от данни
* @param {string} collection The name of the collection, име на колекцията, в която да бъде добавен записа
* @param {Object} value The object to insert, стойност на записа
* @returns {ObjectId} Inserted Id, идентификатор на новия запис
*/
async create(collection, value){
try {
@@ -50,11 +50,11 @@ class Db {
}
/**
* Loads a record from db collection
* @param {string} collection The name of the collection
* @param {Object} key Record identifier
* @param {Object} projection What data to take from the object
* @returns {Object} A record
* Loads a record from db collection, извличане на запис от базата от данни
* @param {string} collection The name of the collection, име на колекцията, съдържаща записа
* @param {Object} key Record identifier, идентификатор на записа
* @param {Object} projection What data to take from the object, проекция на очаквания резултат
* @returns {Object} A record, запис
*/
async get(collection, key, projection){
try {
@@ -65,10 +65,10 @@ class Db {
}
/**
* Performs a database query
* @param {string} collection Collection name
* @param {Object} query A mongo db query
* @returns {Object[]} Array of records
* Performs a database query, проста заявка за търсене в базата от данни
* @param {string} collection Collection name, име на колекция
* @param {Object} query A mongo db query, заявка
* @returns {Object[]} Array of records, масив от записи
*/
async list(collection, query){
try {
@@ -84,10 +84,10 @@ class Db {
}
/**
* Performs a database aggregation according to a given pipeline
* @param {string} collection Database collection name
* @param {Object} specs aggregation definition (the pipeline)
* @returns {Object[]} Array of records
* Performs a database aggregation according to a given pipeline, сложна заявка (агрегираща) към базата от данни
* @param {string} collection Database collection name, име на колекция
* @param {Object} specs aggregation definition (the pipeline), дефиниция на заявката
* @returns {Object[]} Array of records, списък от записи
*/
async aggregate(collection, specs){
try {
@@ -100,11 +100,11 @@ class Db {
}
/**
* Finds the distinct values for a specified field across a single collection
* @param {string} collection Database collection name
* @param {Object} key The target field for the distinction
* @param {Object} query filter to be applied
* @returns {Object[]}
* Finds the distinct values for a specified field across a single collection, извличане на списък от уникални записи в колекция по зададени критерии
* @param {string} collection Database collection name, име на колекцията
* @param {Object} key The target field for the distinction, целеви атрибут, по който се търси уникалност
* @param {Object} query filter to be applied, филтър на записите в колекцията
* @returns {Object[]} Array of records, списък от записи
*/
async distinct(collection, key, query){
try {
@@ -114,11 +114,11 @@ class Db {
}
/**
* Updates a record in database by given key and value
* @param {Object} collection DB collection
* @param {Object} key The key/query which identifies the record to be updated
* @param {Object} value The new value for the record
* @returns {Object} The result from the update operation
* Updates a record in database by given key and value, обновяване на запис в базата данни по дадени ключ и стойност
* @param {Object} collection DB collection, име на колекцията
* @param {Object} key The key/query which identifies the record to be updated, ключ или заявка за идентификация на съществуващия запис
* @param {Object} value The new value for the record, нова стойност на записа
* @returns {Object} The result from the update operation, резултат от операцията
*/
async update(collection, key, value){
let r;
@@ -131,11 +131,11 @@ class Db {
}
/**
* Performs partial update on a record by given key and partial value
* @param {Object} collection Database collection
* @param {Object} key The key/query which identifies the record to be updated
* @param {Object} value The partial value to be updated
* @returns {Object} The result from the update operation
* Performs partial update on a record by given key and partial value, частично обновяване на запис в базата от данни
* @param {Object} collection Database collection, име на колекция
* @param {Object} key The key/query which identifies the record to be updated, ключ или заявка за идентификация на целевите обекти
* @param {Object} value The partial value to be updated, дефиниция на частичното обновяване
* @returns {Object} The result from the update operation, резултат от операцията
*/
async updateSet(collection, key, value){
let r;
@@ -147,9 +147,9 @@ class Db {
}
/**
* Removes a record from the database by given key
* @param {Object} collection Database collection
* @param {Object} key The key/query which identifies the record to be updated
* Removes a record from the database by given key, изтриване на запис от базата от данни по зададен критерий
* @param {Object} collection Database collection, име на колекцията
* @param {Object} key The key/query which identifies the record to be updated, ключ/заявка за идентификация на целевите записи
*/
async remove(collection, key){
try {
+5 -5
View File
@@ -9,14 +9,14 @@ import helmet from 'helmet';
import { v4 as uuidv4 } from 'uuid';
/**
* The Web Server class, manages all request from the web platform, manages the APIs
* The Web Server class, manages all request from the web platform, manages the APIs, уеб сървър, управлява всички уеб заявки към платформата, агрегира всички комуникационни/гранични класове
*/
class WebServer {
name = 'webServer';
/**
* Initializes the web server plugin
* @param {App} app The application instance
* Initializes the web server plugin, инициализация
* @param {App} app The application instance, апликация
*/
async init(app) {
const xapp = express();
@@ -69,8 +69,8 @@ class WebServer {
}
/**
* Starts the web server plugin
* @param {App} app The application instance
* Starts the web server plugin, стартиране на уеб сървъра
* @param {App} app The application instance, апликация
*/
async start(app) {
+31 -30
View File
@@ -8,21 +8,21 @@ import path from 'path';
const collection = 'assets';
/**
* Game objects manager
* Game objects manager, контролен клас за управление на игрови обекти
*/
class GameObjectsManager{
name = 'gameObject';
/**
* Plugin initializer
* @param {App} app The Application
* Plugin initializer, инициализация на плъгин
* @param {App} app The Application, обект приложение
*/
init(app){
const {db, config} = app;
/**
* Gets last asset Id from database
* @returns {Number} Last Asset Id
* Gets last asset Id from database, намира последния пореден идентификатор на обект в базата от данни
* @returns {Number} Last Asset Id, последен (най-голям) идентификатор
*/
this.getLastId = async function(){
let ag = await db.aggregate(collection, [
@@ -39,9 +39,9 @@ class GameObjectsManager{
}
/**
* Creates a game object
* @param {Context} ctx Request context
* @param {GameObject} data Asset data
* Creates a game object, създаване на игрови обект
* @param {Context} ctx Request context, контекст на заявката
* @param {GameObject} data Asset data, данни за игровия обект
*/
this.create = async function(ctx, data){
data.id = (await this.getLastId()) + 1;
@@ -55,9 +55,9 @@ class GameObjectsManager{
}
/**
* Retrieves game object from database
* @param {Number} id Game object ID
* @returns {GameObject} The game object
* Retrieves game object from database, прочитане на обект от базата от данни
* @param {Number} id Game object ID, идентификатор на обекта
* @returns {GameObject} The game object, игрови обект
*/
this.read = async function(id){
id = parseInt(id);
@@ -65,9 +65,9 @@ class GameObjectsManager{
}
/**
* Updates game object into the database
* @param {Context} ctx Request context
* @param {GameObject} data Game object
* Updates game object into the database, обновяване на игрови обект
* @param {Context} ctx Request context, контекст на заявката
* @param {GameObject} data Game object, данни за игровия обект
*/
this.update = async function(ctx, data){
data.id = parseInt(data.id);
@@ -85,8 +85,8 @@ class GameObjectsManager{
}
/**
* Removes game object from database
* @param {Number} id Game object ID
* Removes game object from database, изтриване на игрови обект от базата от данни
* @param {Number} id Game object ID, идентификатор на игровия обект
*/
this.remove = async function(id){
id = parseInt(id);
@@ -94,9 +94,9 @@ class GameObjectsManager{
}
/**
* Assigns a file to a game object
* @param {GameObject} object Game object
* @param {File} tmpFile A file
* Assigns a file to a game object, закачване на файл към игрови обект
* @param {GameObject} object Game object, игрови обект
* @param {File} tmpFile A file, файл
*/
this.addFile = async function(object, tmpFile){
let i = tmpFile;
@@ -124,9 +124,9 @@ class GameObjectsManager{
}
/**
* Assigns a thumbnail to a game object
* @param {GameObject} object Game object
* @param {File} thumbSrc A thumbnail
* Assigns a thumbnail to a game object, закачане на представително изображение към игрови обект
* @param {GameObject} object Game object, игрови обект
* @param {File} thumbSrc A thumbnail, представително изображение
*/
this.addThumb = async function(object, thumbSrc){
let dest = `${config.fs.repo}/thumb/${object.id}.webp`;
@@ -135,9 +135,9 @@ class GameObjectsManager{
}
/**
* Returns list of GameObjects
* @param {Object} query Query to DB
* @returns {GameObject[]} Array of game objects
* Returns list of GameObjects, търсене в игровите обекти по зададени критерии
* @param {Object} query Query to DB, критерии - заявка към базата от данни
* @returns {GameObject[]} Array of game objects, масив от игрови обекти
*/
this.list = async function(query){
return await db.list(collection, {
@@ -148,8 +148,8 @@ class GameObjectsManager{
}
/**
* Class starter
* @param {App} app The application
* Class starter, стартиране на класа
* @param {App} app The application, базова апликация
*/
async start(app){
@@ -158,22 +158,23 @@ class GameObjectsManager{
/**
* GameObject entity, can be: panorama picture, 3d environment, 3d object, 2d object (picture), a player (3d), audio or video asset
* Игрови обект, може да бъде панорамна снимка, триизмерна среда, обект или играч, двуизмерен обект, аудио или видео актив
*/
class GameObject {
/**
* Game object name
* Game object name, име на игровия обект
* @type string
*/
name = null;
/**
* Game object type
* Game object type, тип на игровия обект
* @type string
*/
type = null;
/**
* Associated file
* Associated file, асоцииран файл
* @type File
*/
file = null;
+20 -20
View File
@@ -6,51 +6,51 @@ class GamesManager{
name = 'games';
/**
* Class initializer
* @param {App} app Class initializer
* Class initializer, инициализация на плъгин
* @param {App} app Class initializer, основна апликация
*/
init(app){
const {db} = app;
/**
* Creates a new game definition
* @param {Context} ctx Request context
* @param {Game} data the game description
* Creates a new game definition, създаване на нова игрова дефиниция
* @param {Context} ctx Request context, контекст на заявката
* @param {Game} data the game description, дефиниция на играта
*/
this.create = async function(ctx, data){
}
/**
* Reads game definition by ID
* @param {Number} id game ID
* @returns {Game} the game
* Reads game definition by ID, извличане на игрова дефиниция от базата от данни по подаден идентификатор
* @param {Number} id game ID, идентификатор на играта
* @returns {Game} the game, игрова дефиниция
*/
this.read = async function(id){
}
/**
* Updates game definition
* @param {Context} ctx Request context
* @param {Game} data the game description
* Updates game definition, обновяване на игрова дефиниция
* @param {Context} ctx Request context, контекст на заявката
* @param {Game} data the game description, игрова дефиниция
*/
this.update = async function(ctx, data){
}
/**
* Removes game by ID
* @param {Number} id game definition ID
* Removes game by ID, изтриване на игрова дефиниция по зададен идентификатор
* @param {Number} id game definition ID, идентификатор на игровата дефиниция
*/
this.remove = async function(id){
}
/**
* Returns a set of games by given criteria
* @param {Query} query criteria
* @returns {Game[]} Array of games
* Returns a set of games by given criteria, търсене в игровите дефиниции по зададени критерии
* @param {Query} query criteria, критерии за търсене - заявка към базата от данни
* @returns {Game[]} Array of games, масив от игрови дефиниции
*/
this.list = async function(query){
@@ -60,7 +60,7 @@ class GamesManager{
/**
* Class starter
* @param {App} app The application
* @param {App} app The application, основна апликация
*/
async start(app){
@@ -68,17 +68,17 @@ class GamesManager{
}
/**
* Game entity
* Game entity, игрова дефиниция - елемент
*/
class Game {
/**
* Game name
* Game name, име на играта
* @type {string}
*/
name = null;
/**
* Game scenario
* Game scenario, сценарий на играта
* @type { Scenario }
*/
scenario = null;
+19 -19
View File
@@ -1,29 +1,29 @@
/**
* Rules manager class
* Rules manager class, контролен клас за управление на игрови правила
*/
class RulesManager{
name = 'rules';
/**
* Class initializer
* @param {App} app Class initializer
* Class initializer, инициализация на плъгин
* @param {App} app Class initializer, основна апликация
*/
init(app){
const {db} = app;
/**
* Creates a new rule
* @param {Context} ctx Request context
* @param {Rule} data the rule
* Creates a new rule, създаване на ново правило
* @param {Context} ctx Request context, контекст на заявката
* @param {Rule} data the rule, данни за правилото
*/
this.create = async function(ctx, data){
}
/**
* Reads rule by ID
* @param {Number} id rule ID
* Reads rule by ID, извличане на игрово правило от базата от данни по подаден идентификатор
* @param {Number} id rule ID, идентификатор на правило
* @returns {Rule}
*/
this.read = async function(id){
@@ -31,25 +31,25 @@ class RulesManager{
}
/**
* Updates rule
* @param {Context} ctx Request context
* @param {Rule} data the rule
* Updates rule, обновяване на игрово правило
* @param {Context} ctx Request context, контекст на заявката
* @param {Rule} data the rule, данни за правилото
*/
this.update = async function(ctx, data){
}
/**
* Removes rule by ID
* @param {Number} id rule ID
* Removes rule by ID, изтриване на игрово правило по подаден идентификатор
* @param {Number} id rule ID, идентификатор на правилото
*/
this.remove = async function(id){
}
/**
* Returns a set of rules by given criteria
* @param {Query} query criteria
* Returns a set of rules by given criteria, търсене в игровите правила по зададени критерии
* @param {Query} query criteria, критерии, заявка към базата от данни
* @returns {Rule[]}
*/
this.list = async function(query){
@@ -60,7 +60,7 @@ class RulesManager{
/**
* Class starter
* @param {App} app The application
* @param {App} app The application, основна апликация
*/
async start(app){
@@ -68,17 +68,17 @@ class RulesManager{
}
/**
* Rule entity
* Rule entity, игрово правило - елемент
*/
class Rule {
/**
* Rule name
* Rule name, име на правилото
* @type string
*/
name = null;
/**
* Rule definition
* Rule definition, дефиниция на правилото
* @type Object
*/
name = null;
+37 -37
View File
@@ -1,29 +1,29 @@
/**
* Scenarios manager class
* Scenarios manager class, контролен клас за управление на игрови сценарии
*/
class ScenariosManager{
name = 'scenarios';
/**
* Class initializer
* @param {App} app Class initializer
* Class initializer, инициализация
* @param {App} app Class initializer, основна апликация
*/
init(app){
const {db} = app;
/**
* Creates a new scenario
* @param {Context} ctx Request context
* @param {Scenario} data the scenario
* Creates a new scenario, създаване на нов сценарий
* @param {Context} ctx Request context, контекст на заявката
* @param {Scenario} data the scenario, данни за сценария
*/
this.create = async function(ctx, data){
}
/**
* Reads scenario by ID
* @param {Number} id scenario ID
* Reads scenario by ID, извличане на сценарий по подаден идентификатор
* @param {Number} id scenario ID, идентификатор
* @returns {Scenario}
*/
this.read = async function(id){
@@ -31,8 +31,8 @@ class ScenariosManager{
}
/**
* Updates scenario
* @param {Context} ctx Request context
* Updates scenario, обновяване на сценарий
* @param {Context} ctx Request context, контекст на заявката
* @param {Scenario} data the scenario
*/
this.update = async function(ctx, data){
@@ -40,16 +40,16 @@ class ScenariosManager{
}
/**
* Removes scenario by ID
* @param {Number} id scenario ID
* Removes scenario by ID, изтриване на сценарий по подаден идентификатор
* @param {Number} id scenario ID, идентификатор на сценарий
*/
this.remove = async function(id){
}
/**
* Returns a set of scenarios by given criteria
* @param {Query} query criteria
* Returns a set of scenarios by given criteria, търсене в игровите сценарии по зададени критерии
* @param {Query} query criteria, критерии - заявка към базата от данни
* @returns {Scenario[]}
*/
this.list = async function(query){
@@ -59,8 +59,8 @@ class ScenariosManager{
}
/**
* Class starter
* @param {App} app The application
* Class starter, стартиране на класа
* @param {App} app The application, основна апликация
*/
async start(app){
@@ -68,121 +68,121 @@ class ScenariosManager{
}
/**
* Scenario entity
* Scenario entity, обект - сценарий
*/
class Scenario {
/**
* Scenario name
* Scenario name, име на сценария
* @type {string}
*/
name = null;
/**
* Scenario levels
* Scenario levels, нива
* @type {Level[]}
*/
levels = [];
}
/**
* Game scenario level
* Game scenario level, ниво на игрови сценарий
*/
class Level {
/**
* Scenario name
* Level name, име на нивото
* @type {string}
*/
name = null;
/**
* Active objects
* Active objects, активни обекти
* @type {LevelObject[]}
*/
activeObjects = []
}
/**
* Game object associated to a level
* Game object associated to a level, игрови обекти, асоциирани към дадено ниво
*/
class LevelObject {
/**
* Associated game object
* Associated game object, асоцииран игрови обект
* @type {GameObject}
*/
gameObject = null;
/**
* Available actions
* Available actions, възможни действия
* @type {GameAction}
*/
actions = []
}
/**
* Action associated to game object
* Action associated to game object, действие, асоциирано към игрови обект
*/
class GameAction {
/**
* Scenario name
* Action name, име на действието
* @type {string}
*/
name = null;
/**
* Scenario name
* Action description, описание на действието
* @type {string}
*/
description = null;
/**
* Associated inventory item
* Associated inventory item, асоцииран инвентар
* @type {InventoryItem}
*/
inventoryItem = null;
/**
* Available outcomes from the action
* Available outcomes from the action, възможни резултати от действието
* @type {GameActionResult}
*/
results = []
}
/**
* Result associated to game action
* Result associated to game action, резултати, асоциирани към дадено игрово действие
*/
class GameActionResult{
/**
* Applied rules to the specific result
* Applied rules to the specific result, приложени игрови правила към даден резултат
* @type Rule[]
*/
rules = []
/**
* Scenario name
* Result name, име на резултата
* @type string
*/
name = null;
/**
* Scenario name
* Result description, описание на резултата
* @type string
*/
description = null;
}
/**
* Inventory item required to perform specific action
* Inventory item required to perform specific action, инвентар необходим за изпълнението на определено действие
*/
class InventoryItem {
/**
* Scenario name
* Inventory item name, име на елемент от инвентара
* @type string
*/
name = null;
/**
* Scenario name
* Inventory item description, описание на елемент от инвентара
* @type string
*/
description = null;