From 96fbfb60e888c24a30d6083ad7d6ec1844da196e Mon Sep 17 00:00:00 2001 From: goynov Date: Mon, 16 Dec 2024 16:51:46 +0200 Subject: [PATCH] docs --- .docs/diagram-template/publish.js | 3 +- .docs/diagram-template/vp/ShortDetails2.xml | 55 ++----------- .docs/server-installation.md | 4 +- backend/app/App.js | 54 ++++++------- backend/app/Config.js | 46 +++++------ backend/app/Db.js | 80 +++++++++---------- backend/app/WebServer.js | 10 +-- backend/app/bl/GameObjectsManager.js | 61 +++++++------- backend/app/bl/GamesManager.js | 40 +++++----- backend/app/bl/RulesManager.js | 38 ++++----- backend/app/bl/ScenariosManager.js | 74 ++++++++--------- backend/controllers/AssetController.js | 8 +- .../controllers/api/GameObjectsController.js | 18 ++--- backend/controllers/api/GamesController.js | 18 ++--- backend/controllers/api/RulesController.js | 18 ++--- .../controllers/api/ScenariosController.js | 18 ++--- 16 files changed, 250 insertions(+), 295 deletions(-) diff --git a/.docs/diagram-template/publish.js b/.docs/diagram-template/publish.js index 75578a9..020c10f 100644 --- a/.docs/diagram-template/publish.js +++ b/.docs/diagram-template/publish.js @@ -1,4 +1,5 @@ const fs = require('fs'); +const iconv = require('iconv-lite'); const typeMap = { string: 'std::string', @@ -46,5 +47,5 @@ exports.publish = (data, {destination, query}) => { let result = `#include \n\n` + graft(docs); //console.log(result) - fs.promises.writeFile(destination, result, {encoding:'utf-8'}); + fs.promises.writeFile(destination, iconv.encode(result, 'win1251'), {encoding: 'binary'}); }; diff --git a/.docs/diagram-template/vp/ShortDetails2.xml b/.docs/diagram-template/vp/ShortDetails2.xml index c407a20..17ceab0 100644 --- a/.docs/diagram-template/vp/ShortDetails2.xml +++ b/.docs/diagram-template/vp/ShortDetails2.xml @@ -5,9 +5,9 @@ - + @@ -77,23 +77,22 @@ - Enumeration Literals Summary + Допустими стойности - Name + Име - Description + Описание - @@ -131,50 +130,6 @@ - - - Enumeration Literals - - - - - - - - - - Specification - - - - - - - - - - Slots - - - - - = - - - - , - - - - - - - - - - - - diff --git a/.docs/server-installation.md b/.docs/server-installation.md index 982c75c..33e5196 100644 --- a/.docs/server-installation.md +++ b/.docs/server-installation.md @@ -1,4 +1,4 @@ -# Server and Application Installation +# ProNature Server and Application Installation ## Services to install ### [Mongo DB Community 8+ ](https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-ubuntu/) > sudo apt-get install gnupg curl @@ -28,8 +28,6 @@ 4. SPHINX. Install in **/opt/sphinx**. Create a service using config in sphinx.service. Copy to sphinx bin/ folder and configure FTS indexes in [**sphinx.conf**](./sphinx.conf) template. Make sure all paths are available. **/opt/sphinx** should be owned by the nonroot user. ## Tools to install -1. NodeJS and NPM (currently Node v16, NPM v8) -1. [Mongo DB tools](https://www.mongodb.com/try/download/database-tools?tck=docs_databasetools) 1. Let's Encrypt CertBot, for certificates issuing and renewal. The certificate is installed using the following command: `certbot certonly -d your.server.name`. Use `--nginx` or `--apache` in order to have automatic renewal 1. ffmpeg - for converting video and audio content 1. ghostscript - for creating thumbnails for PDF files diff --git a/backend/app/App.js b/backend/app/App.js index 0db85af..5da6596 100644 --- a/backend/app/App.js +++ b/backend/app/App.js @@ -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 */ diff --git a/backend/app/Config.js b/backend/app/Config.js index 3767306..c6a81c1 100644 --- a/backend/app/Config.js +++ b/backend/app/Config.js @@ -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){ diff --git a/backend/app/Db.js b/backend/app/Db.js index a093e53..acfa3b9 100644 --- a/backend/app/Db.js +++ b/backend/app/Db.js @@ -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 { diff --git a/backend/app/WebServer.js b/backend/app/WebServer.js index c4e4a09..365adbc 100644 --- a/backend/app/WebServer.js +++ b/backend/app/WebServer.js @@ -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) { diff --git a/backend/app/bl/GameObjectsManager.js b/backend/app/bl/GameObjectsManager.js index e399d8b..965276a 100644 --- a/backend/app/bl/GameObjectsManager.js +++ b/backend/app/bl/GameObjectsManager.js @@ -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; diff --git a/backend/app/bl/GamesManager.js b/backend/app/bl/GamesManager.js index 521682e..c072f40 100644 --- a/backend/app/bl/GamesManager.js +++ b/backend/app/bl/GamesManager.js @@ -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; diff --git a/backend/app/bl/RulesManager.js b/backend/app/bl/RulesManager.js index c492648..8d15b2b 100644 --- a/backend/app/bl/RulesManager.js +++ b/backend/app/bl/RulesManager.js @@ -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; diff --git a/backend/app/bl/ScenariosManager.js b/backend/app/bl/ScenariosManager.js index 13e678c..20d2421 100644 --- a/backend/app/bl/ScenariosManager.js +++ b/backend/app/bl/ScenariosManager.js @@ -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; diff --git a/backend/controllers/AssetController.js b/backend/controllers/AssetController.js index f6e5af1..6b57755 100644 --- a/backend/controllers/AssetController.js +++ b/backend/controllers/AssetController.js @@ -1,7 +1,7 @@ import express from 'express'; /** - * Asset controller plugin + * Asset controller plugin, граничен клас за обработка на заявките към игрови активи */ class AssetController{ @@ -9,15 +9,15 @@ class AssetController{ route = '/asset' /** - * Initializes the AssetController plugin - * @param {App} app The application instance + * Initializes the AssetController plugin, инициализация + * @param {App} app The application instance, апликация */ init(app){ const router = express.Router(); const {config} = app; /** - * API: GET /asset/:type/:id Retrieve asset by type and ID + * API: GET /asset/:type/:id Retrieve asset by type and ID, извличане на актив по подаден идентификатор * @function read * @param {string} type Type can be "source", "default" or "thumb" * @param {string} id The name of the asset diff --git a/backend/controllers/api/GameObjectsController.js b/backend/controllers/api/GameObjectsController.js index 944c1fc..cf36594 100644 --- a/backend/controllers/api/GameObjectsController.js +++ b/backend/controllers/api/GameObjectsController.js @@ -4,7 +4,7 @@ import multipart from 'connect-multiparty'; const multipartMiddleware = multipart(); /** - * GameObjectsController. API for the game objects manager + * GameObjectsController. API for the game objects manager, граничен клас за комуникация с модула за игрови обекти */ class GameObjectsController{ @@ -12,15 +12,15 @@ class GameObjectsController{ route = '/api/game-object' /** - * Initializes the GameObjectsController plugin - * @param {App} app The application instance + * Initializes the GameObjectsController plugin, инициализация + * @param {App} app The application instance, апликация */ init(app){ const { gameObject } = app; const router = express.Router(); /** - * API: PUT /api/game-object/ Create or update game object + * API: PUT /api/game-object/ Create or update game object, създаване или обновяване на игрови обект * @function createOrUpdate * @memberof GameObjectsController */ @@ -36,7 +36,7 @@ class GameObjectsController{ }); /** - * API: POST /api/game-object/ List game objects by given criteria + * API: POST /api/game-object/ List game objects by given criteria, търсене на обекти по критерии * @function list * @returns {GameObject[]} * @memberof GameObjectsController @@ -47,9 +47,9 @@ class GameObjectsController{ }) /** - * API: GET /api/game-object/:id Retrieve game object by ID + * API: GET /api/game-object/:id Retrieve game object by ID, извличане на обект по идентификатор * @function read - * @param {string} id The id of the game object + * @param {string} id The id of the game object, идентификатор на обекта * @returns {GameObject} * @memberof GameObjectsController */ @@ -59,9 +59,9 @@ class GameObjectsController{ }) /** - * API: DELETE /api/game-object/:id Delete game object by ID + * API: DELETE /api/game-object/:id Delete game object by ID, изтриване на обект по даден идентификатор * @function remove - * @param {string} id The id of the game object + * @param {string} id The id of the game object, идентификатор на обекта * @memberof GameObjectsController */ router.delete('/:id', async (req, res)=>{ diff --git a/backend/controllers/api/GamesController.js b/backend/controllers/api/GamesController.js index 47e4a35..6f8fea7 100644 --- a/backend/controllers/api/GamesController.js +++ b/backend/controllers/api/GamesController.js @@ -1,7 +1,7 @@ import express from 'express'; /** - * GamesController. API for the games manager + * GamesController. API for the games manager, граничен клас за комуникация с модула за игрови дефиниции */ class GamesController{ @@ -9,15 +9,15 @@ class GamesController{ route = '/api/game' /** - * Initializes the GamesController plugin - * @param {App} app The application instance + * Initializes the GamesController plugin, инициализация + * @param {App} app The application instance, апликация */ init(app){ const router = express.Router(); const { games } = app; /** - * API: PUT /api/game/ Create or update game + * API: PUT /api/game/ Create or update game, създаване/обновяване на игрова дефиниция * @function createOrUpdate * @memberof GamesController */ @@ -26,7 +26,7 @@ class GamesController{ }); /** - * API: POST /api/game/ List games by given criteria + * API: POST /api/game/ List games by given criteria, търсене в игрови дефиниции * @function list * @returns {Game[]} * @memberof GamesController @@ -35,9 +35,9 @@ class GamesController{ }) /** - * API: GET /api/game/:id Retrieve game by ID + * API: GET /api/game/:id Retrieve game by ID, извличане на игрова дефиниция * @function read - * @param {string} id The id of the game + * @param {string} id The id of the game, идентификатор на дефиницията * @returns {Game} * @memberof GamesController */ @@ -45,9 +45,9 @@ class GamesController{ }) /** - * API: DELETE /api/game/:id Delete game by ID + * API: DELETE /api/game/:id Delete game by ID, изтриване на игрова дефиниция * @function remove - * @param {string} id The id of the game + * @param {string} id The id of the game, идентификатор на дефиницията * @memberof GamesController */ router.delete('/:id', async (req, res)=>{ diff --git a/backend/controllers/api/RulesController.js b/backend/controllers/api/RulesController.js index be14e05..f7b9a91 100644 --- a/backend/controllers/api/RulesController.js +++ b/backend/controllers/api/RulesController.js @@ -1,7 +1,7 @@ import express from 'express'; /** - * RulesController. API for the game rules manager + * RulesController. API for the game rules manager, граничен клас за комуникация с модула за игрови правила */ class RulesController{ @@ -9,15 +9,15 @@ class RulesController{ route = '/api/rule' /** - * Initializes the RulesController plugin - * @param {App} app The application instance + * Initializes the RulesController plugin, инициализация + * @param {App} app The application instance, апликация */ init(app){ const router = express.Router(); const { rules } = app; /** - * API: PUT /api/rule/ Create or update rule + * API: PUT /api/rule/ Create or update rule, създаване/обновяване на игрово правило * @function createOrUpdate * @memberof RulesController */ @@ -26,7 +26,7 @@ class RulesController{ }); /** - * API: POST /api/rule/ List rules by given criteria + * API: POST /api/rule/ List rules by given criteria, търсене в игровите правила * @function list * @returns {Rule[]} * @memberof RulesController @@ -35,9 +35,9 @@ class RulesController{ }) /** - * API: GET /api/rule/:id Retrieve rule by ID + * API: GET /api/rule/:id Retrieve rule by ID, извличане на игрово правило * @function read - * @param {string} id The id of the rule + * @param {string} id The id of the rule, идентификатор * @returns {Rule} * @memberof RulesController */ @@ -45,9 +45,9 @@ class RulesController{ }) /** - * API: DELETE /api/rule/:id Delete rule by ID + * API: DELETE /api/rule/:id Delete rule by ID, изтриване на игрово правило * @function remove - * @param {string} id The id of the rule + * @param {string} id The id of the rule, идентификатор * @memberof RulesController */ router.delete('/:id', async (req, res)=>{ diff --git a/backend/controllers/api/ScenariosController.js b/backend/controllers/api/ScenariosController.js index e737874..97f4211 100644 --- a/backend/controllers/api/ScenariosController.js +++ b/backend/controllers/api/ScenariosController.js @@ -1,7 +1,7 @@ import express from 'express'; /** - * ScenariosController. API for the scenarios manager + * ScenariosController. API for the scenarios manager, граничен клас за комуникация с модула за игрови сценарии */ class ScenariosController{ @@ -9,15 +9,15 @@ class ScenariosController{ route = '/api/scenario' /** - * Initializes the ScenariosController plugin - * @param {App} app The application instance + * Initializes the ScenariosController plugin, инициализация + * @param {App} app The application instance, апликация */ init(app){ const router = express.Router(); const { scenarios } = app; /** - * API: PUT /api/scenario/ Create or update scenario + * API: PUT /api/scenario/ Create or update scenario, създаване/обновяване на игрови сценарий * @function createOrUpdate * @memberof ScenariosController */ @@ -26,7 +26,7 @@ class ScenariosController{ }); /** - * API: POST /api/scenario/ List scenarios by given criteria + * API: POST /api/scenario/ List scenarios by given criteria, търсене в игровите сценарии * @function list * @returns {Scenario[]} * @memberof ScenariosController @@ -35,9 +35,9 @@ class ScenariosController{ }) /** - * API: GET /api/scenario/:id Retrieve scenario by ID + * API: GET /api/scenario/:id Retrieve scenario by ID, извличане на игрови сценарий * @function read - * @param {string} id The id of the scenario + * @param {string} id The id of the scenario, идентификатор * @returns {Scenario} * @memberof ScenariosController */ @@ -45,9 +45,9 @@ class ScenariosController{ }) /** - * API: DELETE /api/scenario/:id Delete scenario by ID + * API: DELETE /api/scenario/:id Delete scenario by ID, изтриване на игрови сценарий * @function remove - * @param {string} id The id of the scenario + * @param {string} id The id of the scenario, идентификатор * @memberof ScenariosController */ router.delete('/:id', async (req, res)=>{